From 7b37841fdc54ce2314116197a51ea0e223b7678f Mon Sep 17 00:00:00 2001 From: wmayer Date: Tue, 7 Jul 2015 12:35:48 +0200 Subject: [PATCH] + reset built-in scheme when setting global style sheet --- src/Gui/DlgGeneralImp.cpp | 20 ++++++++++++++++---- src/Gui/TaskView/TaskView.cpp | 16 ++++++++++++++++ src/Gui/TaskView/TaskView.h | 3 +++ 3 files changed, 35 insertions(+), 4 deletions(-) diff --git a/src/Gui/DlgGeneralImp.cpp b/src/Gui/DlgGeneralImp.cpp index cb651dd3e..75ebc75ab 100644 --- a/src/Gui/DlgGeneralImp.cpp +++ b/src/Gui/DlgGeneralImp.cpp @@ -36,6 +36,8 @@ #include "MainWindow.h" #include "PrefWidgets.h" #include "Language/Translator.h" +#include "Control.h" +#include "TaskView/TaskView.h" using namespace Gui::Dialog; @@ -148,7 +150,7 @@ void DlgGeneralImp::saveSettings() hGrp = App::GetApplication().GetParameterGroupByPath("User parameter:BaseApp/Preferences/MainWindow"); hGrp->SetBool("TiledBackground", this->tiledBackground->isChecked()); - QMdiArea* mdi = getMainWindow()->findChild(); + QMdiArea* mdi = getMainWindow()->findChild(); mdi->setProperty("showImage", this->tiledBackground->isChecked()); QVariant sheet = this->StyleSheets->itemData(this->StyleSheets->currentIndex()); @@ -159,9 +161,13 @@ void DlgGeneralImp::saveSettings() if (!sheet.toString().isEmpty()) { QFile f(sheet.toString()); if (f.open(QFile::ReadOnly)) { - mdi->setBackground(QBrush(Qt::NoBrush)); + mdi->setBackground(QBrush(Qt::NoBrush)); QTextStream str(&f); qApp->setStyleSheet(str.readAll()); + + Gui::TaskView::TaskView* taskPanel = Control().taskPanel(); + if (taskPanel) + taskPanel->clearActionStyle(); } } } @@ -169,11 +175,17 @@ void DlgGeneralImp::saveSettings() if (sheet.toString().isEmpty()) { if (this->tiledBackground->isChecked()) { qApp->setStyleSheet(QString()); - mdi->setBackground(QPixmap(QLatin1String(":/icons/background.png"))); + Gui::TaskView::TaskView* taskPanel = Control().taskPanel(); + if (taskPanel) + taskPanel->restoreActionStyle(); + mdi->setBackground(QPixmap(QLatin1String(":/icons/background.png"))); } else { qApp->setStyleSheet(QString()); - mdi->setBackground(QBrush(QColor(160,160,160))); + Gui::TaskView::TaskView* taskPanel = Control().taskPanel(); + if (taskPanel) + taskPanel->restoreActionStyle(); + mdi->setBackground(QBrush(QColor(160,160,160))); } } diff --git a/src/Gui/TaskView/TaskView.cpp b/src/Gui/TaskView/TaskView.cpp index e8c42c2b0..da7048019 100644 --- a/src/Gui/TaskView/TaskView.cpp +++ b/src/Gui/TaskView/TaskView.cpp @@ -619,5 +619,21 @@ void TaskView::clicked (QAbstractButton * button) ActiveDialog->clicked(id); } +void TaskView::clearActionStyle() +{ +#if defined (QSINT_ACTIONPANEL) + static_cast(QSint::FreeCADPanelScheme::defaultScheme())->clearActionStyle(); + taskPanel->setScheme(QSint::FreeCADPanelScheme::defaultScheme()); +#endif +} + +void TaskView::restoreActionStyle() +{ +#if defined (QSINT_ACTIONPANEL) + static_cast(QSint::FreeCADPanelScheme::defaultScheme())->restoreActionStyle(); + taskPanel->setScheme(QSint::FreeCADPanelScheme::defaultScheme()); +#endif +} + #include "moc_TaskView.cpp" diff --git a/src/Gui/TaskView/TaskView.h b/src/Gui/TaskView/TaskView.h index 8c785d3d1..dbc5fe4d6 100644 --- a/src/Gui/TaskView/TaskView.h +++ b/src/Gui/TaskView/TaskView.h @@ -173,6 +173,9 @@ public: void addTaskWatcher(const std::vector &Watcher); void clearTaskWatcher(void); + void clearActionStyle(); + void restoreActionStyle(); + protected Q_SLOTS: void accept(); void reject();