| | |
| | |
| | |
| | |
| | |
| | |
| | |
| | |
| | |
| | |
| | |
| | |
| | |
| | |
| | |
| | |
| | |
| | |
| | |
| | |
| | |
| |
|
| | #include <QPushButton> |
| |
|
| |
|
| | #include <Gui/Application.h> |
| | #include <Gui/ParamHandler.h> |
| |
|
| | #include "DlgSettingsUI.h" |
| | #include "ui_DlgSettingsUI.h" |
| |
|
| | #include "Dialogs/DlgThemeEditor.h" |
| |
|
| | #include <Base/ServiceProvider.h> |
| |
|
| |
|
| | using namespace Gui::Dialog; |
| |
|
| | |
| |
|
| | |
| | |
| | |
| | |
| | DlgSettingsUI::DlgSettingsUI(QWidget* parent) |
| | : PreferencePage(parent) |
| | , ui(new Ui_DlgSettingsUI) |
| | { |
| | ui->setupUi(this); |
| |
|
| | connect(ui->themeEditorButton, &QPushButton::clicked, [this]() { openThemeEditor(); }); |
| | } |
| |
|
| | |
| | |
| | |
| | DlgSettingsUI::~DlgSettingsUI() = default; |
| |
|
| | void DlgSettingsUI::saveSettings() |
| | { |
| | |
| | ui->ThemeAccentColor1->onSave(); |
| | ui->ThemeAccentColor2->onSave(); |
| | ui->ThemeAccentColor3->onSave(); |
| | ui->StyleSheets->onSave(); |
| | ui->OverlayStyleSheets->onSave(); |
| |
|
| | |
| | ui->fontSizeSpinBox->onSave(); |
| | ui->iconSizeSpinBox->onSave(); |
| | ui->resizableColumnsCheckBox->onSave(); |
| | ui->showVisibilityIconCheckBox->onSave(); |
| | ui->hideDescriptionCheckBox->onSave(); |
| | ui->hideInternalNamesCheckBox->onSave(); |
| | ui->hideTreeViewScrollBarCheckBox->onSave(); |
| | ui->hideHeaderCheckBox->onSave(); |
| |
|
| | |
| | ui->hideTabBarCheckBox->onSave(); |
| | ui->hintShowTabBarCheckBox->onSave(); |
| | ui->hidePropertyViewScrollBarCheckBox->onSave(); |
| | ui->overlayAutoHideCheckBox->onSave(); |
| | ui->mouseClickPassThroughCheckBox->onSave(); |
| | ui->mouseWheelPassThroughCheckBox->onSave(); |
| |
|
| | |
| | ui->showTaskWatcherCheckBox->onSave(); |
| | } |
| |
|
| | void DlgSettingsUI::loadSettings() |
| | { |
| | |
| | ui->ThemeAccentColor1->onRestore(); |
| | ui->ThemeAccentColor2->onRestore(); |
| | ui->ThemeAccentColor3->onRestore(); |
| |
|
| | |
| | ui->fontSizeSpinBox->onRestore(); |
| | ui->iconSizeSpinBox->onRestore(); |
| | ui->resizableColumnsCheckBox->onRestore(); |
| | ui->showVisibilityIconCheckBox->onRestore(); |
| | ui->hideDescriptionCheckBox->onRestore(); |
| | ui->hideInternalNamesCheckBox->onRestore(); |
| | ui->hideTreeViewScrollBarCheckBox->onRestore(); |
| | ui->hideHeaderCheckBox->onRestore(); |
| |
|
| | |
| | ui->hideTabBarCheckBox->onRestore(); |
| | ui->hintShowTabBarCheckBox->onRestore(); |
| | ui->hidePropertyViewScrollBarCheckBox->onRestore(); |
| | ui->overlayAutoHideCheckBox->onRestore(); |
| | ui->mouseClickPassThroughCheckBox->onRestore(); |
| | ui->mouseWheelPassThroughCheckBox->onRestore(); |
| |
|
| | |
| | ui->showTaskWatcherCheckBox->onRestore(); |
| |
|
| | loadStyleSheet(); |
| | } |
| |
|
| | void DlgSettingsUI::loadStyleSheet() |
| | { |
| | static std::string translatedString; |
| | translatedString = tr("No style sheet").toStdString(); |
| | populateStylesheets("StyleSheet", "qss", ui->StyleSheets, translatedString.c_str()); |
| | populateStylesheets("OverlayActiveStyleSheet", "overlay", ui->OverlayStyleSheets, "Auto"); |
| | } |
| |
|
| | void DlgSettingsUI::populateStylesheets( |
| | const char* key, |
| | const char* path, |
| | PrefComboBox* combo, |
| | const char* def, |
| | QStringList filter |
| | ) |
| | { |
| | auto hGrp = App::GetApplication().GetParameterGroupByPath( |
| | "User parameter:BaseApp/Preferences/MainWindow" |
| | ); |
| | |
| | QMap<QString, QString> cssFiles; |
| | QDir dir; |
| | if (filter.isEmpty()) { |
| | filter << QStringLiteral("*.qss"); |
| | filter << QStringLiteral("*.css"); |
| | } |
| | QFileInfoList fileNames; |
| |
|
| | |
| | QStringList qssPaths = QDir::searchPaths(QString::fromUtf8(path)); |
| | for (QStringList::iterator it = qssPaths.begin(); it != qssPaths.end(); ++it) { |
| | dir.setPath(*it); |
| | fileNames = dir.entryInfoList(filter, QDir::Files, QDir::Name); |
| | for (QFileInfoList::iterator jt = fileNames.begin(); jt != fileNames.end(); ++jt) { |
| | if (cssFiles.find(jt->baseName()) == cssFiles.end()) { |
| | cssFiles[jt->baseName()] = jt->fileName(); |
| | } |
| | } |
| | } |
| |
|
| | combo->clear(); |
| |
|
| | |
| | combo->addItem(tr(def), QStringLiteral("")); |
| | for (QMap<QString, QString>::iterator it = cssFiles.begin(); it != cssFiles.end(); ++it) { |
| | combo->addItem(it.key(), it.value()); |
| | } |
| |
|
| | QString selectedStyleSheet = QString::fromUtf8(hGrp->GetASCII(key).c_str()); |
| | int index = combo->findData(selectedStyleSheet); |
| |
|
| | |
| | if (index < 0 && !selectedStyleSheet.isEmpty()) { |
| | QFileInfo fi(selectedStyleSheet); |
| | if (fi.isAbsolute()) { |
| | QString path = fi.absolutePath(); |
| | if (qssPaths.indexOf(path) >= 0) { |
| | selectedStyleSheet = fi.fileName(); |
| | } |
| | else { |
| | selectedStyleSheet = fi.absoluteFilePath(); |
| | combo->addItem(fi.baseName(), selectedStyleSheet); |
| | } |
| | } |
| | } |
| |
|
| | combo->setCurrentIndex(index); |
| | combo->onRestore(); |
| | } |
| |
|
| | void DlgSettingsUI::openThemeEditor() |
| | { |
| | Gui::DlgThemeEditor editor; |
| | editor.exec(); |
| | } |
| |
|
| | |
| | |
| | |
| | void DlgSettingsUI::changeEvent(QEvent* e) |
| | { |
| | if (e->type() == QEvent::LanguageChange) { |
| | ui->retranslateUi(this); |
| | loadStyleSheet(); |
| | } |
| | else { |
| | QWidget::changeEvent(e); |
| | } |
| | } |
| |
|
| | #include "moc_DlgSettingsUI.cpp" |
| |
|