summaryrefslogtreecommitdiffstats
path: root/src/widgets/util
diff options
context:
space:
mode:
Diffstat (limited to 'src/widgets/util')
-rw-r--r--src/widgets/util/qcompleter.h4
-rw-r--r--src/widgets/util/qcompleter_p.h26
-rw-r--r--src/widgets/util/qflickgesture.cpp4
-rw-r--r--src/widgets/util/qscroller.cpp10
-rw-r--r--src/widgets/util/qscroller.h2
-rw-r--r--src/widgets/util/qscroller_mac.mm2
-rw-r--r--src/widgets/util/qscrollerproperties.cpp4
-rw-r--r--src/widgets/util/qsystemtrayicon.cpp20
-rw-r--r--src/widgets/util/qsystemtrayicon.h2
-rw-r--r--src/widgets/util/qsystemtrayicon_p.h12
-rw-r--r--src/widgets/util/qsystemtrayicon_qpa.cpp8
-rw-r--r--src/widgets/util/qsystemtrayicon_x11.cpp49
-rw-r--r--src/widgets/util/qundoview.cpp10
13 files changed, 89 insertions, 64 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..d05a6ae91e 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) {
@@ -455,7 +455,7 @@ QGestureRecognizer::Result QFlickGestureRecognizer::recognize(QGesture *state,
}
break;
-#if defined(Q_WS_MAC)
+#if defined(Q_DEAD_CODE_FROM_QT4_MAC)
// the only way to distinguish between real mouse wheels and wheel
// events generated by the native 2 finger swipe gesture is to listen
// for these events (according to Apple's Cocoa Event-Handling Guide)
diff --git a/src/widgets/util/qscroller.cpp b/src/widgets/util/qscroller.cpp
index 8cd7b97e30..a26e6d42b1 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()) {
@@ -1002,12 +1002,12 @@ bool QScroller::handleInput(Input input, const QPointF &position, qint64 timesta
return false;
}
-#if !defined(Q_WS_MAC)
+#if !defined(Q_DEAD_CODE_FROM_QT4_MAC)
// the Mac version is implemented in qscroller_mac.mm
QPointF QScrollerPrivate::realDpi(int screen)
{
-# if defined(Q_WS_X11) && !defined(QT_NO_XRANDR)
+# if defined(Q_DEAD_CODE_FROM_QT4_X11) && !defined(QT_NO_XRANDR)
if (X11 && X11->use_xrandr && X11->ptrXRRSizes && X11->ptrXRRRootToScreen) {
int nsizes = 0;
// QDesktopWidget is based on Xinerama screens, which do not always
@@ -1033,7 +1033,7 @@ QPointF QScrollerPrivate::realDpi(int screen)
return QPointF(w->physicalDpiX(), w->physicalDpiY());
}
-#endif // !Q_WS_MAC
+#endif // !Q_DEAD_CODE_FROM_QT4_MAC
/*! \internal
diff --git a/src/widgets/util/qscroller.h b/src/widgets/util/qscroller.h
index bdbd015711..c6c39e8808 100644
--- a/src/widgets/util/qscroller.h
+++ b/src/widgets/util/qscroller.h
@@ -54,7 +54,6 @@ class Q_WIDGETS_EXPORT QScroller : public QObject
Q_OBJECT
Q_PROPERTY(State state READ state NOTIFY stateChanged)
Q_PROPERTY(QScrollerProperties scrollerProperties READ scrollerProperties WRITE setScrollerProperties NOTIFY scrollerPropertiesChanged)
- Q_ENUMS(State)
public:
enum State
@@ -64,6 +63,7 @@ public:
Dragging,
Scrolling
};
+ Q_ENUM(State)
enum ScrollerGestureType
{
diff --git a/src/widgets/util/qscroller_mac.mm b/src/widgets/util/qscroller_mac.mm
index 0f9f2a028c..08d70923a1 100644
--- a/src/widgets/util/qscroller_mac.mm
+++ b/src/widgets/util/qscroller_mac.mm
@@ -41,7 +41,7 @@
#include <QtCore/qglobal.h>
-#ifdef Q_WS_MAC
+#ifdef Q_DEAD_CODE_FROM_QT4_MAC
#import <Cocoa/Cocoa.h>
diff --git a/src/widgets/util/qscrollerproperties.cpp b/src/widgets/util/qscrollerproperties.cpp
index 193396c4fc..073fcaf2e6 100644
--- a/src/widgets/util/qscrollerproperties.cpp
+++ b/src/widgets/util/qscrollerproperties.cpp
@@ -34,7 +34,7 @@
#include <QPointer>
#include <QObject>
#include <QtCore/qmath.h>
-#ifdef Q_WS_WIN
+#ifdef Q_DEAD_CODE_FROM_QT4_WIN
# include <QLibrary>
#endif
@@ -67,7 +67,7 @@ QScrollerPropertiesPrivate *QScrollerPropertiesPrivate::defaults()
spp.overshootDragDistanceFactor = qreal(1);
spp.overshootScrollDistanceFactor = qreal(0.5);
spp.overshootScrollTime = qreal(0.7);
-# ifdef Q_WS_WIN
+# ifdef Q_DEAD_CODE_FROM_QT4_WIN
if (QLibrary::resolve(QLatin1String("UxTheme"), "BeginPanningFeedback"))
spp.overshootScrollTime = qreal(0.35);
# endif
diff --git a/src/widgets/util/qsystemtrayicon.cpp b/src/widgets/util/qsystemtrayicon.cpp
index d151e57d04..034894aa24 100644
--- a/src/widgets/util/qsystemtrayicon.cpp
+++ b/src/widgets/util/qsystemtrayicon.cpp
@@ -1,6 +1,6 @@
/****************************************************************************
**
-** Copyright (C) 2014 Digia Plc and/or its subsidiary(-ies).
+** Copyright (C) 2015 Digia Plc and/or its subsidiary(-ies).
** Contact: http://www.qt-project.org/legal
**
** This file is part of the QtWidgets module of the Qt Toolkit.
@@ -70,8 +70,12 @@ QT_BEGIN_NAMESPACE
\list
\li All supported versions of Windows.
- \li All window managers for X11 that implement the \l{freedesktop.org} system
- tray specification, including recent versions of KDE and GNOME.
+ \li All window managers and independent tray implementations for X11 that implement the
+ \l{http://standards.freedesktop.org/systemtray-spec/systemtray-spec-0.2.html freedesktop.org}
+ XEmbed system tray specification.
+ \li All X11 desktop environments that implement the D-Bus
+ \l{http://www.freedesktop.org/wiki/Specifications/StatusNotifierItem/ StatusNotifierItem}
+ specification, including recent versions of KDE and Unity.
\li All supported versions of Mac OS X. Note that the Growl
notification system must be installed for
QSystemTrayIcon::showMessage() to display messages on Mac OS X prior to 10.8 (Mountain Lion).
@@ -280,7 +284,7 @@ bool QSystemTrayIcon::isVisible() const
*/
bool QSystemTrayIcon::event(QEvent *e)
{
-#if defined(Q_WS_X11)
+#if defined(Q_DEAD_CODE_FROM_QT4_X11)
if (e->type() == QEvent::ToolTip) {
Q_D(QSystemTrayIcon);
return d->sys->deliverToolTipEvent(e);
@@ -583,7 +587,7 @@ void QBalloonTip::balloon(const QPoint& pos, int msecs, bool showArrow)
}
QPainterPath path;
-#if defined(QT_NO_XSHAPE) && defined(Q_WS_X11)
+#if defined(QT_NO_XSHAPE) && defined(Q_DEAD_CODE_FROM_QT4_X11)
// XShape is required for setting the mask, so we just
// draw an ugly square when its not available
path.moveTo(0, 0);
@@ -715,8 +719,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)
{
@@ -734,7 +738,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 f05bf9e3f9..8bf2302ab5 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);
void addPlatformMenu(QMenu *menu) const;
};
@@ -120,10 +120,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..13562ee27a 100644
--- a/src/widgets/util/qsystemtrayicon_x11.cpp
+++ b/src/widgets/util/qsystemtrayicon_x11.cpp
@@ -1,6 +1,6 @@
/****************************************************************************
**
-** Copyright (C) 2014 Digia Plc and/or its subsidiary(-ies).
+** Copyright (C) 2015 Digia Plc and/or its subsidiary(-ies).
** Contact: http://www.qt-project.org/legal
**
** This file is part of the QtWidgets module of the Qt Toolkit.
@@ -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);
@@ -321,8 +344,8 @@ void QSystemTrayIconPrivate::updateToolTip_sys()
bool QSystemTrayIconPrivate::isSystemTrayAvailable_sys()
{
QScopedPointer<QPlatformSystemTrayIcon> sys(QGuiApplicationPrivate::platformTheme()->createPlatformSystemTrayIcon());
- if (sys)
- return sys->isSystemTrayAvailable();
+ if (sys && sys->isSystemTrayAvailable())
+ return true;
// no QPlatformSystemTrayIcon so fall back to default xcb platform behavior
const QString platform = QGuiApplication::platformName();
@@ -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;