From 833bb90e4a98f5c3ca3148abe236276f2b049baa Mon Sep 17 00:00:00 2001 From: Rafael Date: Tue, 1 Nov 2016 18:39:25 +0100 Subject: [PATCH] update for DWM QtWinExtras on PictureDialog --- PictureDialog.cpp | 44 ++++++++++++++++++++++++++++++++++---------- PictureDialog.h | 2 ++ 2 files changed, 36 insertions(+), 10 deletions(-) diff --git a/PictureDialog.cpp b/PictureDialog.cpp index 4aaa088..3de2bcf 100755 --- a/PictureDialog.cpp +++ b/PictureDialog.cpp @@ -30,6 +30,7 @@ #ifdef GTA5SYNC_WIN #if QT_VERSION >= 0x050000 #include +#include #endif #endif @@ -100,24 +101,47 @@ void PictureDialog::addPreviousNextButtons() // Windows Vista additions #ifdef GTA5SYNC_WIN #if QT_VERSION >= 0x050000 + QPalette palette; + QToolBar *uiToolbar = new QToolBar("Picture Toolbar", this); + layout()->setMenuBar(uiToolbar); + QAction *backAction = uiToolbar->addAction("<-", this, SLOT(previousPictureRequestedSlot())); + QAction *nextAction = uiToolbar->addAction("->", this, SLOT(nextPictureRequestedSlot())); + backAction->setToolTip(""); + nextAction->setToolTip(""); + ui->jsonFrame->setStyleSheet(QString("QFrame { background: %1; }").arg(palette.window().color().name())); + stylize(); +#endif +#endif +} + +void PictureDialog::stylize() +{ if (QtWin::isCompositionEnabled()) { - QPalette palette; - QToolBar *uiToolbar = new QToolBar("Picture Toolbar", this); - layout()->setMenuBar(uiToolbar); - QAction *backAction = uiToolbar->addAction("<-", this, SLOT(previousPictureRequestedSlot())); - QAction *nextAction = uiToolbar->addAction("->", this, SLOT(nextPictureRequestedSlot())); - backAction->setToolTip(""); - nextAction->setToolTip(""); - - QtWin::extendFrameIntoClientArea(this, 0, uiToolbar->height() - 2, 0, 0); + //qDebug() << this->layout()->menuBar()->height(); + QtWin::extendFrameIntoClientArea(this, 0, this->layout()->menuBar()->height() - 2, 0, 0); setAttribute(Qt::WA_TranslucentBackground, true); setAttribute(Qt::WA_NoSystemBackground, false); setStyleSheet("PictureDialog { background: transparent; }"); - ui->jsonFrame->setStyleSheet(QString("QFrame { background: %1; }").arg(palette.window().color().name())); + } + else + { + QtWin::resetExtendedFrame(this); + setAttribute(Qt::WA_TranslucentBackground, false); + } +} + +bool PictureDialog::event(QEvent *event) +{ +#ifdef GTA5SYNC_WIN +#if QT_VERSION >= 0x050000 + if (event->type() == QWinEvent::CompositionChange || event->type() == QWinEvent::ColorizationChange) + { + stylize(); } #endif #endif + return QDialog::event(event); } void PictureDialog::nextPictureRequestedSlot() diff --git a/PictureDialog.h b/PictureDialog.h index 083c462..7103e87 100755 --- a/PictureDialog.h +++ b/PictureDialog.h @@ -63,6 +63,7 @@ private slots: void exportCustomContextMenuRequestedPrivate(const QPoint &pos, bool fullscreen); void nextPictureRequestedSlot(); void previousPictureRequestedSlot(); + void stylize(); signals: void nextPictureRequested(); @@ -72,6 +73,7 @@ signals: protected: bool eventFilter(QObject *obj, QEvent *ev); void mousePressEvent(QMouseEvent *ev); + bool event(QEvent *event); private: ProfileDatabase *profileDB;