summaryrefslogtreecommitdiffstats
path: root/src/gui/kernel
diff options
context:
space:
mode:
Diffstat (limited to 'src/gui/kernel')
-rw-r--r--src/gui/kernel/qguiapplication.cpp5
-rw-r--r--src/gui/kernel/qplatformwindow.cpp26
-rw-r--r--src/gui/kernel/qplatformwindow.h3
-rw-r--r--src/gui/kernel/qwindow.cpp30
-rw-r--r--src/gui/kernel/qwindow.h3
-rw-r--r--src/gui/kernel/qwindow_p.h1
6 files changed, 68 insertions, 0 deletions
diff --git a/src/gui/kernel/qguiapplication.cpp b/src/gui/kernel/qguiapplication.cpp
index b05ba28e48..fba516c135 100644
--- a/src/gui/kernel/qguiapplication.cpp
+++ b/src/gui/kernel/qguiapplication.cpp
@@ -1592,6 +1592,11 @@ void QGuiApplicationPrivate::processActivatedEvent(QWindowSystemInterfacePrivate
if (previous == newFocus)
return;
+ if (newFocus)
+ if (QPlatformWindow *platformWindow = newFocus->handle())
+ if (platformWindow->isAlertState())
+ platformWindow->setAlertState(false);
+
QObject *previousFocusObject = previous ? previous->focusObject() : 0;
if (previous) {
diff --git a/src/gui/kernel/qplatformwindow.cpp b/src/gui/kernel/qplatformwindow.cpp
index bfb6ab5a68..1e8ac60cca 100644
--- a/src/gui/kernel/qplatformwindow.cpp
+++ b/src/gui/kernel/qplatformwindow.cpp
@@ -463,6 +463,32 @@ QString QPlatformWindow::formatWindowTitle(const QString &title, const QString &
}
/*!
+ Reimplement this method to set whether the window demands attention
+ (for example, by flashing the taskbar icon) depending on \a enabled.
+
+ \sa isAlertState()
+ \since 5.1
+*/
+
+void QPlatformWindow::setAlertState(bool enable)
+{
+ Q_UNUSED(enable)
+}
+
+/*!
+ Reimplement this method return whether the window is in
+ an alert state.
+
+ \sa setAlertState()
+ \since 5.1
+*/
+
+bool QPlatformWindow::isAlertState() const
+{
+ return false;
+}
+
+/*!
Helper function to get initial geometry on windowing systems which do not
do smart positioning and also do not provide a means of centering a
transient window w.r.t. its parent. For example this is useful on Windows
diff --git a/src/gui/kernel/qplatformwindow.h b/src/gui/kernel/qplatformwindow.h
index 7ade461890..7dfbae036f 100644
--- a/src/gui/kernel/qplatformwindow.h
+++ b/src/gui/kernel/qplatformwindow.h
@@ -128,6 +128,9 @@ public:
virtual void setFrameStrutEventsEnabled(bool enabled);
virtual bool frameStrutEventsEnabled() const;
+ virtual void setAlertState(bool enabled);
+ virtual bool isAlertState() const;
+
static QRect initialGeometry(const QWindow *w,
const QRect &initialGeometry, int defaultWidth, int defaultHeight);
diff --git a/src/gui/kernel/qwindow.cpp b/src/gui/kernel/qwindow.cpp
index 2307df37ac..8c9bc575bd 100644
--- a/src/gui/kernel/qwindow.cpp
+++ b/src/gui/kernel/qwindow.cpp
@@ -58,6 +58,7 @@
#include <private/qevent_p.h>
+#include <QtCore/QTimer>
#include <QtCore/QDebug>
#include <QStyleHints>
@@ -2150,6 +2151,33 @@ QWindow *QWindow::fromWinId(WId id)
return window;
}
+/*!
+ Causes an alert to be shown for \a msec miliseconds. If \a msec is \c 0 (the
+ default), then the alert is shown indefinitely until the window becomes
+ active again.
+
+ In alert state, the window indicates that it demands attention, for example by
+ flashing or bouncing the taskbar entry.
+
+ \since 5.1
+*/
+
+void QWindow::alert(int msec)
+{
+ Q_D(QWindow);
+ if (!d->platformWindow || d->platformWindow->isAlertState())
+ return;
+ d->platformWindow->setAlertState(true);
+ if (d->platformWindow->isAlertState() && msec)
+ QTimer::singleShot(msec, this, SLOT(_q_clearAlert()));
+}
+
+void QWindowPrivate::_q_clearAlert()
+{
+ if (platformWindow && platformWindow->isAlertState())
+ platformWindow->setAlertState(false);
+}
+
#ifndef QT_NO_CURSOR
/*!
\brief set the cursor shape for this window
@@ -2233,3 +2261,5 @@ void QWindowPrivate::applyCursor()
#endif // QT_NO_CURSOR
QT_END_NAMESPACE
+
+#include "moc_qwindow.cpp"
diff --git a/src/gui/kernel/qwindow.h b/src/gui/kernel/qwindow.h
index 1b63e185f8..9b1ed2c702 100644
--- a/src/gui/kernel/qwindow.h
+++ b/src/gui/kernel/qwindow.h
@@ -290,6 +290,8 @@ public Q_SLOTS:
Q_REVISION(1) void setMaximumWidth(int w);
Q_REVISION(1) void setMaximumHeight(int h);
+ void alert(int msec);
+
Q_SIGNALS:
void screenChanged(QScreen *screen);
void modalityChanged(Qt::WindowModality modality);
@@ -346,6 +348,7 @@ protected:
QWindow(QWindowPrivate &dd, QWindow *parent);
private:
+ Q_PRIVATE_SLOT(d_func(), void _q_clearAlert())
QPlatformSurface *surfaceHandle() const;
Q_DISABLE_COPY(QWindow)
diff --git a/src/gui/kernel/qwindow_p.h b/src/gui/kernel/qwindow_p.h
index e32d45acca..ea2cb722ab 100644
--- a/src/gui/kernel/qwindow_p.h
+++ b/src/gui/kernel/qwindow_p.h
@@ -125,6 +125,7 @@ public:
virtual QWindow *eventReceiver() { Q_Q(QWindow); return q; }
void updateVisibility();
+ void _q_clearAlert();
QWindow::SurfaceType surfaceType;
Qt::WindowFlags windowFlags;