diff options
Diffstat (limited to 'src/widgets/util')
-rw-r--r-- | src/widgets/util/qcompleter.h | 4 | ||||
-rw-r--r-- | src/widgets/util/qcompleter_p.h | 26 | ||||
-rw-r--r-- | src/widgets/util/qflickgesture.cpp | 2 | ||||
-rw-r--r-- | src/widgets/util/qscroller.cpp | 4 | ||||
-rw-r--r-- | src/widgets/util/qsystemtrayicon.cpp | 6 | ||||
-rw-r--r-- | src/widgets/util/qsystemtrayicon.h | 2 | ||||
-rw-r--r-- | src/widgets/util/qsystemtrayicon_p.h | 12 | ||||
-rw-r--r-- | src/widgets/util/qsystemtrayicon_qpa.cpp | 8 | ||||
-rw-r--r-- | src/widgets/util/qsystemtrayicon_x11.cpp | 43 | ||||
-rw-r--r-- | src/widgets/util/qundoview.cpp | 10 |
10 files changed, 69 insertions, 48 deletions
diff --git a/src/widgets/util/qcompleter.h b/src/widgets/util/qcompleter.h index 3bee280719..c252284b85 100644 --- a/src/widgets/util/qcompleter.h +++ b/src/widgets/util/qcompleter.h @@ -136,8 +136,8 @@ public: virtual QStringList splitPath(const QString &path) const; protected: - bool eventFilter(QObject *o, QEvent *e); - bool event(QEvent *); + bool eventFilter(QObject *o, QEvent *e) Q_DECL_OVERRIDE; + bool event(QEvent *) Q_DECL_OVERRIDE; Q_SIGNALS: void activated(const QString &text); diff --git a/src/widgets/util/qcompleter_p.h b/src/widgets/util/qcompleter_p.h index 50f7cdacdb..b4ead17cab 100644 --- a/src/widgets/util/qcompleter_p.h +++ b/src/widgets/util/qcompleter_p.h @@ -167,7 +167,7 @@ class QSortedModelEngine : public QCompletionEngine { public: QSortedModelEngine(QCompleterPrivate *c) : QCompletionEngine(c) { } - QMatchData filter(const QString&, const QModelIndex&, int); + QMatchData filter(const QString&, const QModelIndex&, int) Q_DECL_OVERRIDE; QIndexMapper indexHint(QString, const QModelIndex&, Qt::SortOrder); Qt::SortOrder sortOrder(const QModelIndex&) const; }; @@ -177,8 +177,8 @@ class QUnsortedModelEngine : public QCompletionEngine public: QUnsortedModelEngine(QCompleterPrivate *c) : QCompletionEngine(c) { } - void filterOnDemand(int); - QMatchData filter(const QString&, const QModelIndex&, int); + void filterOnDemand(int) Q_DECL_OVERRIDE; + QMatchData filter(const QString&, const QModelIndex&, int) Q_DECL_OVERRIDE; private: int buildIndices(const QString& str, const QModelIndex& parent, int n, const QIndexMapper& iv, QMatchData* m); @@ -189,7 +189,7 @@ class QCompleterItemDelegate : public QItemDelegate public: QCompleterItemDelegate(QAbstractItemView *view) : QItemDelegate(view), view(view) { } - void paint(QPainter *p, const QStyleOptionViewItem& opt, const QModelIndex& idx) const { + void paint(QPainter *p, const QStyleOptionViewItem& opt, const QModelIndex& idx) const Q_DECL_OVERRIDE { QStyleOptionViewItem optCopy = opt; optCopy.showDecorationSelected = true; if (view->currentIndex() == idx) @@ -218,16 +218,16 @@ public: bool setCurrentRow(int row); QModelIndex currentIndex(bool) const; - QModelIndex index(int row, int column, const QModelIndex & = QModelIndex()) const; - int rowCount(const QModelIndex &index = QModelIndex()) const; - int columnCount(const QModelIndex &index = QModelIndex()) const; - bool hasChildren(const QModelIndex &parent = QModelIndex()) const; - QModelIndex parent(const QModelIndex & = QModelIndex()) const { return QModelIndex(); } - QVariant data(const QModelIndex& index, int role = Qt::DisplayRole) const; + QModelIndex index(int row, int column, const QModelIndex & = QModelIndex()) const Q_DECL_OVERRIDE; + int rowCount(const QModelIndex &index = QModelIndex()) const Q_DECL_OVERRIDE; + int columnCount(const QModelIndex &index = QModelIndex()) const Q_DECL_OVERRIDE; + bool hasChildren(const QModelIndex &parent = QModelIndex()) const Q_DECL_OVERRIDE; + QModelIndex parent(const QModelIndex & = QModelIndex()) const Q_DECL_OVERRIDE { return QModelIndex(); } + QVariant data(const QModelIndex& index, int role = Qt::DisplayRole) const Q_DECL_OVERRIDE; - void setSourceModel(QAbstractItemModel *sourceModel); - QModelIndex mapToSource(const QModelIndex& proxyIndex) const; - QModelIndex mapFromSource(const QModelIndex& sourceIndex) const; + void setSourceModel(QAbstractItemModel *sourceModel) Q_DECL_OVERRIDE; + QModelIndex mapToSource(const QModelIndex& proxyIndex) const Q_DECL_OVERRIDE; + QModelIndex mapFromSource(const QModelIndex& sourceIndex) const Q_DECL_OVERRIDE; QCompleterPrivate *c; QScopedPointer<QCompletionEngine> engine; diff --git a/src/widgets/util/qflickgesture.cpp b/src/widgets/util/qflickgesture.cpp index 42ead263f8..f7abd008b7 100644 --- a/src/widgets/util/qflickgesture.cpp +++ b/src/widgets/util/qflickgesture.cpp @@ -248,7 +248,7 @@ public: } protected: - void timerEvent(QTimerEvent *e) + void timerEvent(QTimerEvent *e) Q_DECL_OVERRIDE { if (e->timerId() == pressDelayTimer) { if (pressDelayEvent && mouseTarget) { diff --git a/src/widgets/util/qscroller.cpp b/src/widgets/util/qscroller.cpp index 8cd7b97e30..5235511b6d 100644 --- a/src/widgets/util/qscroller.cpp +++ b/src/widgets/util/qscroller.cpp @@ -190,7 +190,7 @@ public: : d(_d), ignoreUpdate(false), skip(0) { } - int duration() const + int duration() const Q_DECL_OVERRIDE { return -1; } @@ -206,7 +206,7 @@ public: } protected: - void updateCurrentTime(int /*currentTime*/) + void updateCurrentTime(int /*currentTime*/) Q_DECL_OVERRIDE { if (!ignoreUpdate) { if (++skip >= d->frameRateSkip()) { diff --git a/src/widgets/util/qsystemtrayicon.cpp b/src/widgets/util/qsystemtrayicon.cpp index 7d04cab05e..30ef7e82e5 100644 --- a/src/widgets/util/qsystemtrayicon.cpp +++ b/src/widgets/util/qsystemtrayicon.cpp @@ -718,8 +718,8 @@ void QSystemTrayIconPrivate::updateToolTip_sys_qpa() qpa_sys->updateToolTip(toolTip); } -void QSystemTrayIconPrivate::showMessage_sys_qpa(const QString &message, - const QString &title, +void QSystemTrayIconPrivate::showMessage_sys_qpa(const QString &title, + const QString &message, QSystemTrayIcon::MessageIcon icon, int msecs) { @@ -737,7 +737,7 @@ void QSystemTrayIconPrivate::showMessage_sys_qpa(const QString &message, default: break; } - qpa_sys->showMessage(message, title, notificationIcon, + qpa_sys->showMessage(title, message, notificationIcon, static_cast<QPlatformSystemTrayIcon::MessageIcon>(icon), msecs); } diff --git a/src/widgets/util/qsystemtrayicon.h b/src/widgets/util/qsystemtrayicon.h index 4d92d811ed..29a9f849b4 100644 --- a/src/widgets/util/qsystemtrayicon.h +++ b/src/widgets/util/qsystemtrayicon.h @@ -102,7 +102,7 @@ Q_SIGNALS: void messageClicked(); protected: - bool event(QEvent *event); + bool event(QEvent *event) Q_DECL_OVERRIDE; private: Q_DISABLE_COPY(QSystemTrayIcon) diff --git a/src/widgets/util/qsystemtrayicon_p.h b/src/widgets/util/qsystemtrayicon_p.h index 0dda689c51..fdf91d4c43 100644 --- a/src/widgets/util/qsystemtrayicon_p.h +++ b/src/widgets/util/qsystemtrayicon_p.h @@ -77,7 +77,7 @@ public: void updateToolTip_sys(); void updateMenu_sys(); QRect geometry_sys() const; - void showMessage_sys(const QString &msg, const QString &title, QSystemTrayIcon::MessageIcon icon, int secs); + void showMessage_sys(const QString &title, const QString &msg, QSystemTrayIcon::MessageIcon icon, int secs); static bool isSystemTrayAvailable_sys(); static bool supportsMessages_sys(); @@ -98,7 +98,7 @@ private: void updateToolTip_sys_qpa(); void updateMenu_sys_qpa(); QRect geometry_sys_qpa() const; - void showMessage_sys_qpa(const QString &msg, const QString &title, QSystemTrayIcon::MessageIcon icon, int secs); + void showMessage_sys_qpa(const QString &title, const QString &msg, QSystemTrayIcon::MessageIcon icon, int secs); }; class QBalloonTip : public QWidget @@ -119,10 +119,10 @@ private: void balloon(const QPoint&, int, bool); protected: - void paintEvent(QPaintEvent *); - void resizeEvent(QResizeEvent *); - void mousePressEvent(QMouseEvent *e); - void timerEvent(QTimerEvent *e); + void paintEvent(QPaintEvent *) Q_DECL_OVERRIDE; + void resizeEvent(QResizeEvent *) Q_DECL_OVERRIDE; + void mousePressEvent(QMouseEvent *e) Q_DECL_OVERRIDE; + void timerEvent(QTimerEvent *e) Q_DECL_OVERRIDE; private: QSystemTrayIcon *trayIcon; diff --git a/src/widgets/util/qsystemtrayicon_qpa.cpp b/src/widgets/util/qsystemtrayicon_qpa.cpp index 08764b405d..7dc848d3ab 100644 --- a/src/widgets/util/qsystemtrayicon_qpa.cpp +++ b/src/widgets/util/qsystemtrayicon_qpa.cpp @@ -111,13 +111,11 @@ bool QSystemTrayIconPrivate::supportsMessages_sys() return false; } -void QSystemTrayIconPrivate::showMessage_sys(const QString &message, - const QString &title, - QSystemTrayIcon::MessageIcon icon, - int msecs) +void QSystemTrayIconPrivate::showMessage_sys(const QString &title, const QString &message, + QSystemTrayIcon::MessageIcon icon, int msecs) { if (qpa_sys) - showMessage_sys_qpa(message, title, icon, msecs); + showMessage_sys_qpa(title, message, icon, msecs); } QT_END_NAMESPACE diff --git a/src/widgets/util/qsystemtrayicon_x11.cpp b/src/widgets/util/qsystemtrayicon_x11.cpp index 09f2d6266c..ba80734876 100644 --- a/src/widgets/util/qsystemtrayicon_x11.cpp +++ b/src/widgets/util/qsystemtrayicon_x11.cpp @@ -74,12 +74,12 @@ public: QRect globalGeometry() const; protected: - virtual void mousePressEvent(QMouseEvent *ev); - virtual void mouseDoubleClickEvent(QMouseEvent *ev); - virtual bool event(QEvent *); - virtual void paintEvent(QPaintEvent *); - virtual void resizeEvent(QResizeEvent *); - virtual void moveEvent(QMoveEvent *); + virtual void mousePressEvent(QMouseEvent *ev) Q_DECL_OVERRIDE; + virtual void mouseDoubleClickEvent(QMouseEvent *ev) Q_DECL_OVERRIDE; + virtual bool event(QEvent *) Q_DECL_OVERRIDE; + virtual void paintEvent(QPaintEvent *) Q_DECL_OVERRIDE; + virtual void resizeEvent(QResizeEvent *) Q_DECL_OVERRIDE; + virtual void moveEvent(QMoveEvent *) Q_DECL_OVERRIDE; private slots: void systemTrayWindowChanged(QScreen *screen); @@ -107,13 +107,29 @@ QSystemTrayIconSys::QSystemTrayIconSys(QSystemTrayIcon *qIn) // If we have a visual that has an alpha channel, we can paint this widget with a transparent // background and it will work. // However, if there's no alpha channel visual, in order for transparent tray icons to work, - // we do not have a transparent background on the widget, but call xcb_clear_region before - // painting the icon + // we do not have a transparent background on the widget, but set the BackPixmap property of our + // window to ParentRelative (so that it inherits the background of its X11 parent window), call + // xcb_clear_region before painting (so that the inherited background is visible) and then grab + // the just-drawn background from the X11 server. bool hasAlphaChannel = false; QMetaObject::invokeMethod(QGuiApplication::platformNativeInterface(), "systrayVisualHasAlphaChannel", Qt::DirectConnection, Q_RETURN_ARG(bool, hasAlphaChannel)); setAttribute(Qt::WA_TranslucentBackground, hasAlphaChannel); + if (!hasAlphaChannel) { + createWinId(); + QMetaObject::invokeMethod(QGuiApplication::platformNativeInterface(), + "setParentRelativeBackPixmap", Qt::DirectConnection, + Q_ARG(const QWindow *, windowHandle()) + ); + + // XXX: This is actually required, but breaks things ("QWidget::paintEngine: Should no + // longer be called"). Why is this needed? When the widget is drawn, we use tricks to grab + // the tray icon's background from the server. If the tray icon isn't visible (because + // another window is on top of it), the trick fails and instead uses the content of that + // other window as the background. + // setAttribute(Qt::WA_PaintOnScreen); + } addToTray(); } @@ -214,11 +230,18 @@ void QSystemTrayIconSys::paintEvent(QPaintEvent *) painter.setCompositionMode(QPainter::CompositionMode_Source); painter.fillRect(rect, Qt::transparent); } else { + // Without Qt::WA_TranslucentBackground, we use a ParentRelative BackPixmap and jump through + // some hops to draw this background below our icon. This clears the whole tray icon to its + // background color and thus causes flickering (you can see that the icon is being + // repainted). However, we can't really do much about this. QMetaObject::invokeMethod(QGuiApplication::platformNativeInterface(), "clearRegion", Qt::DirectConnection, Q_ARG(const QWindow *, windowHandle()), Q_ARG(const QRect&, rect) ); + painter.drawPixmap(QPoint(0, 0), + QGuiApplication::primaryScreen()->grabWindow(winId(), + 0, 0, rect.size().width(), rect.size().height())); } painter.setCompositionMode(QPainter::CompositionMode_SourceOver); q->icon().paint(&painter, rect); @@ -341,11 +364,11 @@ bool QSystemTrayIconPrivate::supportsMessages_sys() return true; } -void QSystemTrayIconPrivate::showMessage_sys(const QString &message, const QString &title, +void QSystemTrayIconPrivate::showMessage_sys(const QString &title, const QString &message, QSystemTrayIcon::MessageIcon icon, int msecs) { if (qpa_sys) { - showMessage_sys_qpa(message, title, icon, msecs); + showMessage_sys_qpa(title, message, icon, msecs); return; } if (!sys) diff --git a/src/widgets/util/qundoview.cpp b/src/widgets/util/qundoview.cpp index 970541cf73..4ead2910a2 100644 --- a/src/widgets/util/qundoview.cpp +++ b/src/widgets/util/qundoview.cpp @@ -53,11 +53,11 @@ public: QUndoStack *stack() const; virtual QModelIndex index(int row, int column, - const QModelIndex &parent = QModelIndex()) const; - virtual QModelIndex parent(const QModelIndex &child) const; - virtual int rowCount(const QModelIndex &parent = QModelIndex()) const; - virtual int columnCount(const QModelIndex &parent = QModelIndex()) const; - virtual QVariant data(const QModelIndex &index, int role = Qt::DisplayRole) const; + const QModelIndex &parent = QModelIndex()) const Q_DECL_OVERRIDE; + virtual QModelIndex parent(const QModelIndex &child) const Q_DECL_OVERRIDE; + virtual int rowCount(const QModelIndex &parent = QModelIndex()) const Q_DECL_OVERRIDE; + virtual int columnCount(const QModelIndex &parent = QModelIndex()) const Q_DECL_OVERRIDE; + virtual QVariant data(const QModelIndex &index, int role = Qt::DisplayRole) const Q_DECL_OVERRIDE; QModelIndex selectedIndex() const; QItemSelectionModel *selectionModel() const; |