update for DWM QtWinExtras on PictureDialog

This commit is contained in:
Rafael 2016-11-01 18:39:25 +01:00
parent c7b0a8917e
commit 833bb90e4a
2 changed files with 36 additions and 10 deletions

View File

@ -30,6 +30,7 @@
#ifdef GTA5SYNC_WIN #ifdef GTA5SYNC_WIN
#if QT_VERSION >= 0x050000 #if QT_VERSION >= 0x050000
#include <QtWinExtras/QtWin> #include <QtWinExtras/QtWin>
#include <QWinEvent>
#endif #endif
#endif #endif
@ -100,24 +101,47 @@ void PictureDialog::addPreviousNextButtons()
// Windows Vista additions // Windows Vista additions
#ifdef GTA5SYNC_WIN #ifdef GTA5SYNC_WIN
#if QT_VERSION >= 0x050000 #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()) if (QtWin::isCompositionEnabled())
{ {
QPalette palette; //qDebug() << this->layout()->menuBar()->height();
QToolBar *uiToolbar = new QToolBar("Picture Toolbar", this); QtWin::extendFrameIntoClientArea(this, 0, this->layout()->menuBar()->height() - 2, 0, 0);
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);
setAttribute(Qt::WA_TranslucentBackground, true); setAttribute(Qt::WA_TranslucentBackground, true);
setAttribute(Qt::WA_NoSystemBackground, false); setAttribute(Qt::WA_NoSystemBackground, false);
setStyleSheet("PictureDialog { background: transparent; }"); 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
#endif #endif
return QDialog::event(event);
} }
void PictureDialog::nextPictureRequestedSlot() void PictureDialog::nextPictureRequestedSlot()

View File

@ -63,6 +63,7 @@ private slots:
void exportCustomContextMenuRequestedPrivate(const QPoint &pos, bool fullscreen); void exportCustomContextMenuRequestedPrivate(const QPoint &pos, bool fullscreen);
void nextPictureRequestedSlot(); void nextPictureRequestedSlot();
void previousPictureRequestedSlot(); void previousPictureRequestedSlot();
void stylize();
signals: signals:
void nextPictureRequested(); void nextPictureRequested();
@ -72,6 +73,7 @@ signals:
protected: protected:
bool eventFilter(QObject *obj, QEvent *ev); bool eventFilter(QObject *obj, QEvent *ev);
void mousePressEvent(QMouseEvent *ev); void mousePressEvent(QMouseEvent *ev);
bool event(QEvent *event);
private: private:
ProfileDatabase *profileDB; ProfileDatabase *profileDB;