Add a ThemeChange event.
- Pass it from QWindowSystemInterface via QWindow to the widgets. - Add handler code from 4.8 / qapplication_win.cpp to qwidget.cpp. Change-Id: Ic759563aa00cb93fe014c1bf41020446c1927dec Reviewed-by: Morten Johan Sørvig <morten.sorvig@nokia.com> Reviewed-by: Samuel Rødal <samuel.rodal@nokia.com>
This commit is contained in:
parent
394315d902
commit
1747f66457
@ -279,6 +279,8 @@ public:
|
|||||||
|
|
||||||
TouchCancel = 211,
|
TouchCancel = 211,
|
||||||
|
|
||||||
|
ThemeChange = 212,
|
||||||
|
|
||||||
// 512 reserved for Qt Jambi's MetaCall event
|
// 512 reserved for Qt Jambi's MetaCall event
|
||||||
// 513 reserved for Qt Jambi's DeleteOnMainThread event
|
// 513 reserved for Qt Jambi's DeleteOnMainThread event
|
||||||
|
|
||||||
|
@ -661,6 +661,10 @@ void QGuiApplicationPrivate::processWindowSystemEvent(QWindowSystemInterfacePriv
|
|||||||
QGuiApplicationPrivate::reportLogicalDotsPerInchChange(
|
QGuiApplicationPrivate::reportLogicalDotsPerInchChange(
|
||||||
static_cast<QWindowSystemInterfacePrivate::ScreenLogicalDotsPerInchEvent *>(e));
|
static_cast<QWindowSystemInterfacePrivate::ScreenLogicalDotsPerInchEvent *>(e));
|
||||||
break;
|
break;
|
||||||
|
case QWindowSystemInterfacePrivate::ThemeChange:
|
||||||
|
QGuiApplicationPrivate::processThemeChanged(
|
||||||
|
static_cast<QWindowSystemInterfacePrivate::ThemeChangeEvent *>(e));
|
||||||
|
break;
|
||||||
case QWindowSystemInterfacePrivate::Map:
|
case QWindowSystemInterfacePrivate::Map:
|
||||||
QGuiApplicationPrivate::processMapEvent(static_cast<QWindowSystemInterfacePrivate::MapEvent *>(e));
|
QGuiApplicationPrivate::processMapEvent(static_cast<QWindowSystemInterfacePrivate::MapEvent *>(e));
|
||||||
break;
|
break;
|
||||||
@ -888,6 +892,14 @@ void QGuiApplicationPrivate::processWindowStateChangedEvent(QWindowSystemInterfa
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void QGuiApplicationPrivate::processThemeChanged(QWindowSystemInterfacePrivate::ThemeChangeEvent *tce)
|
||||||
|
{
|
||||||
|
if (QWindow *window = tce->window.data()) {
|
||||||
|
QEvent e(QEvent::ThemeChange);
|
||||||
|
QGuiApplication::sendSpontaneousEvent(window, &e);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
void QGuiApplicationPrivate::processGeometryChangeEvent(QWindowSystemInterfacePrivate::GeometryChangeEvent *e)
|
void QGuiApplicationPrivate::processGeometryChangeEvent(QWindowSystemInterfacePrivate::GeometryChangeEvent *e)
|
||||||
{
|
{
|
||||||
if (e->tlw.isNull())
|
if (e->tlw.isNull())
|
||||||
|
@ -125,6 +125,7 @@ public:
|
|||||||
static void reportGeometryChange(QWindowSystemInterfacePrivate::ScreenGeometryEvent *e);
|
static void reportGeometryChange(QWindowSystemInterfacePrivate::ScreenGeometryEvent *e);
|
||||||
static void reportAvailableGeometryChange(QWindowSystemInterfacePrivate::ScreenAvailableGeometryEvent *e);
|
static void reportAvailableGeometryChange(QWindowSystemInterfacePrivate::ScreenAvailableGeometryEvent *e);
|
||||||
static void reportLogicalDotsPerInchChange(QWindowSystemInterfacePrivate::ScreenLogicalDotsPerInchEvent *e);
|
static void reportLogicalDotsPerInchChange(QWindowSystemInterfacePrivate::ScreenLogicalDotsPerInchEvent *e);
|
||||||
|
static void processThemeChanged(QWindowSystemInterfacePrivate::ThemeChangeEvent *tce);
|
||||||
|
|
||||||
static void processMapEvent(QWindowSystemInterfacePrivate::MapEvent *e);
|
static void processMapEvent(QWindowSystemInterfacePrivate::MapEvent *e);
|
||||||
static void processUnmapEvent(QWindowSystemInterfacePrivate::UnmapEvent *e);
|
static void processUnmapEvent(QWindowSystemInterfacePrivate::UnmapEvent *e);
|
||||||
|
@ -340,6 +340,12 @@ void QWindowSystemInterface::handleScreenLogicalDotsPerInchChange(QScreen *scree
|
|||||||
QWindowSystemInterfacePrivate::queueWindowSystemEvent(e);
|
QWindowSystemInterfacePrivate::queueWindowSystemEvent(e);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void QWindowSystemInterface::handleThemeChange(QWindow *tlw)
|
||||||
|
{
|
||||||
|
QWindowSystemInterfacePrivate::ThemeChangeEvent *e = new QWindowSystemInterfacePrivate::ThemeChangeEvent(tlw);
|
||||||
|
QWindowSystemInterfacePrivate::queueWindowSystemEvent(e);
|
||||||
|
}
|
||||||
|
|
||||||
void QWindowSystemInterface::handleMapEvent(QWindow *tlw)
|
void QWindowSystemInterface::handleMapEvent(QWindow *tlw)
|
||||||
{
|
{
|
||||||
QWindowSystemInterfacePrivate::MapEvent *e = new QWindowSystemInterfacePrivate::MapEvent(tlw);
|
QWindowSystemInterfacePrivate::MapEvent *e = new QWindowSystemInterfacePrivate::MapEvent(tlw);
|
||||||
|
@ -130,6 +130,8 @@ public:
|
|||||||
static void handleScreenAvailableGeometryChange(QScreen *screen, const QRect &newAvailableGeometry);
|
static void handleScreenAvailableGeometryChange(QScreen *screen, const QRect &newAvailableGeometry);
|
||||||
static void handleScreenLogicalDotsPerInchChange(QScreen *screen, qreal newDpiX, qreal newDpiY);
|
static void handleScreenLogicalDotsPerInchChange(QScreen *screen, qreal newDpiX, qreal newDpiY);
|
||||||
|
|
||||||
|
static void handleThemeChange(QWindow *tlw);
|
||||||
|
|
||||||
// For event dispatcher implementations
|
// For event dispatcher implementations
|
||||||
static bool sendWindowSystemEvents(QAbstractEventDispatcher *eventDispatcher, QEventLoop::ProcessEventsFlags flags);
|
static bool sendWindowSystemEvents(QAbstractEventDispatcher *eventDispatcher, QEventLoop::ProcessEventsFlags flags);
|
||||||
static int windowSystemEventsQueued();
|
static int windowSystemEventsQueued();
|
||||||
|
@ -64,6 +64,7 @@ public:
|
|||||||
ScreenGeometry,
|
ScreenGeometry,
|
||||||
ScreenAvailableGeometry,
|
ScreenAvailableGeometry,
|
||||||
ScreenLogicalDotsPerInch,
|
ScreenLogicalDotsPerInch,
|
||||||
|
ThemeChange,
|
||||||
Map,
|
Map,
|
||||||
Unmap,
|
Unmap,
|
||||||
Expose
|
Expose
|
||||||
@ -230,6 +231,13 @@ public:
|
|||||||
qreal dpiY;
|
qreal dpiY;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
class ThemeChangeEvent : public WindowSystemEvent {
|
||||||
|
public:
|
||||||
|
explicit ThemeChangeEvent(QWindow * w)
|
||||||
|
: WindowSystemEvent(ThemeChange), window(w) { }
|
||||||
|
QWeakPointer<QWindow> window;
|
||||||
|
};
|
||||||
|
|
||||||
class MapEvent : public WindowSystemEvent {
|
class MapEvent : public WindowSystemEvent {
|
||||||
public:
|
public:
|
||||||
MapEvent(QWindow *mapped)
|
MapEvent(QWindow *mapped)
|
||||||
|
@ -8046,6 +8046,7 @@ bool QWidget::event(QEvent *event)
|
|||||||
case QEvent::LocaleChange:
|
case QEvent::LocaleChange:
|
||||||
case QEvent::MacSizeChange:
|
case QEvent::MacSizeChange:
|
||||||
case QEvent::ContentsRectChange:
|
case QEvent::ContentsRectChange:
|
||||||
|
case QEvent::ThemeChange:
|
||||||
changeEvent(event);
|
changeEvent(event);
|
||||||
break;
|
break;
|
||||||
|
|
||||||
@ -8249,6 +8250,20 @@ void QWidget::changeEvent(QEvent * event)
|
|||||||
update();
|
update();
|
||||||
break;
|
break;
|
||||||
|
|
||||||
|
case QEvent::ThemeChange:
|
||||||
|
if (QApplication::desktopSettingsAware() && windowType() != Qt::Desktop
|
||||||
|
&& qApp && !QApplication::closingDown()) {
|
||||||
|
if (testAttribute(Qt::WA_WState_Polished))
|
||||||
|
QApplication::style()->unpolish(this);
|
||||||
|
if (testAttribute(Qt::WA_WState_Polished))
|
||||||
|
QApplication::style()->polish(this);
|
||||||
|
QEvent styleChangedEvent(QEvent::StyleChange);
|
||||||
|
QCoreApplication::sendEvent(this, &styleChangedEvent);
|
||||||
|
if (isVisible())
|
||||||
|
update();
|
||||||
|
}
|
||||||
|
break;
|
||||||
|
|
||||||
#ifdef Q_WS_MAC
|
#ifdef Q_WS_MAC
|
||||||
case QEvent::MacSizeChange:
|
case QEvent::MacSizeChange:
|
||||||
updateGeometry();
|
updateGeometry();
|
||||||
|
@ -150,6 +150,12 @@ bool QWidgetWindow::event(QEvent *event)
|
|||||||
handleWindowStateChangedEvent(static_cast<QWindowStateChangeEvent *>(event));
|
handleWindowStateChangedEvent(static_cast<QWindowStateChangeEvent *>(event));
|
||||||
return true;
|
return true;
|
||||||
|
|
||||||
|
case QEvent::ThemeChange: {
|
||||||
|
QEvent widgetEvent(QEvent::ThemeChange);
|
||||||
|
QGuiApplication::sendSpontaneousEvent(m_widget, &widgetEvent);
|
||||||
|
}
|
||||||
|
return true;
|
||||||
|
|
||||||
default:
|
default:
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user