+ reset built-in scheme when setting global style sheet

This commit is contained in:
wmayer 2015-07-07 12:35:48 +02:00
parent 997001bbd9
commit 7b37841fdc
3 changed files with 35 additions and 4 deletions

View File

@ -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*>();
QMdiArea* mdi = getMainWindow()->findChild<QMdiArea*>();
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)));
}
}

View File

@ -619,5 +619,21 @@ void TaskView::clicked (QAbstractButton * button)
ActiveDialog->clicked(id);
}
void TaskView::clearActionStyle()
{
#if defined (QSINT_ACTIONPANEL)
static_cast<QSint::FreeCADPanelScheme*>(QSint::FreeCADPanelScheme::defaultScheme())->clearActionStyle();
taskPanel->setScheme(QSint::FreeCADPanelScheme::defaultScheme());
#endif
}
void TaskView::restoreActionStyle()
{
#if defined (QSINT_ACTIONPANEL)
static_cast<QSint::FreeCADPanelScheme*>(QSint::FreeCADPanelScheme::defaultScheme())->restoreActionStyle();
taskPanel->setScheme(QSint::FreeCADPanelScheme::defaultScheme());
#endif
}
#include "moc_TaskView.cpp"

View File

@ -173,6 +173,9 @@ public:
void addTaskWatcher(const std::vector<TaskWatcher*> &Watcher);
void clearTaskWatcher(void);
void clearActionStyle();
void restoreActionStyle();
protected Q_SLOTS:
void accept();
void reject();