26 #include <QApplication>
27 #include <QDesktopWidget>
43 QWidget(parent,
Qt::
Popup |
Qt::FramelessWindowHint),
76 if (evt->type() == QEvent::KeyPress) {
77 keyEvent =
static_cast<QKeyEvent*
>(evt);
78 if (keyEvent->key() == Qt::Key_Enter ||
79 keyEvent->key() == Qt::Key_Return) {
96 if ((le = this->findChild<QLineEdit*>())) {
101 if (le->parent()->metaObject()->className() ==
102 this->metaObject()->className())
103 le->installEventFilter(
this);
105 le->parent()->installEventFilter(
this);
127 if (
point_.x() < (x() + width()))
132 if (
point_.y() < (y() + height()))
144 const QPoint p = mapFromGlobal(
point_);
149 poly << QPoint(p.x() + l, p.y() - l);
153 poly << QPoint(p.x() - l, p.y() + l);
158 poly << QPoint(p.x() - l, p.y() - l);
167 poly << QPoint(p.x() + l, p.y() + l);
171 poly << QPoint(p.x() - l, p.y() + l);
175 poly << QPoint(p.x() + l, p.y() - l);
203 const unsigned int d = 2 * r;
204 return QRegion(rect.adjusted(r, 0, -r, 0)).united(
205 QRegion(rect.adjusted(0, r, 0, -r))).united(
206 QRegion(rect.left(), rect.top(), d, d,
207 QRegion::Ellipse)).united(
208 QRegion(rect.right() - d, rect.top(), d, d,
209 QRegion::Ellipse)).united(
210 QRegion(rect.left(), rect.bottom() - d, d, d,
211 QRegion::Ellipse)).united(
212 QRegion(rect.right() - d, rect.bottom() - d, d, d,
228 const QRect screen_rect = QApplication::desktop()->availableGeometry(
229 QApplication::desktop()->screenNumber(
point_));
232 o.ry() = -height() / 2;
234 o.rx() = -width() / 2;
242 move(max(min(o.x(), screen_rect.right() - width()),
244 max(min(o.y(), screen_rect.bottom() - height()),
255 QPainter painter(
this);
256 painter.setRenderHint(QPainter::Antialiasing);
258 const QColor outline_color(QApplication::palette().color(
263 const QRegion bubble_outline = QRegion(rect()).subtracted(
264 b.translated(1, 0).intersected(b.translated(0, 1).intersected(
265 b.translated(-1, 0).intersected(b.translated(0, -1)))));
267 painter.setPen(Qt::NoPen);
268 painter.setBrush(QApplication::palette().brush(QPalette::Window));
269 painter.drawRect(rect());
275 const QPoint ArrowOffsets[] = {
276 QPoint(1, 0), QPoint(0, -1), QPoint(-1, 0), QPoint(0, 1)};
279 const QRegion arrow_outline = a.subtracted(
280 a.translated(ArrowOffsets[
pos_]));
282 painter.setClipRegion(bubble_outline.subtracted(a).united(
284 painter.setBrush(outline_color);
285 painter.drawRect(rect());