diff --git a/src/Gui/PreferencePages/DlgSettingsGeneral.cpp b/src/Gui/PreferencePages/DlgSettingsGeneral.cpp index d1e1cfd232..9030ecd9e2 100644 --- a/src/Gui/PreferencePages/DlgSettingsGeneral.cpp +++ b/src/Gui/PreferencePages/DlgSettingsGeneral.cpp @@ -31,6 +31,7 @@ # include # include # include +# include # include # include #endif @@ -40,6 +41,7 @@ #include #include +#include #include #include @@ -83,6 +85,7 @@ DlgSettingsGeneral::DlgSettingsGeneral( QWidget* parent ) connect(ui->ImportConfig, &QPushButton::clicked, this, &DlgSettingsGeneral::onImportConfigClicked); connect(ui->SaveNewPreferencePack, &QPushButton::clicked, this, &DlgSettingsGeneral::saveAsNewPreferencePack); connect(ui->themesCombobox, qOverload(&QComboBox::activated), this, &DlgSettingsGeneral::onThemeChanged); + connect(ui->moreThemesLabel, &QLabel::linkActivated, this, &DlgSettingsGeneral::onLinkActivated); ui->ManagePreferencePacks->setToolTip(tr("Manage preference packs")); connect(ui->ManagePreferencePacks, &QPushButton::clicked, this, &DlgSettingsGeneral::onManagePreferencePacksClicked); @@ -728,6 +731,23 @@ void DlgSettingsGeneral::onThemeChanged(int index) { themeChanged = true; } +void DlgSettingsGeneral::onLinkActivated(const QString& link) +{ + auto const addonManagerLink = QStringLiteral("freecad:Std_AddonMgr"); + + if (link != addonManagerLink) { + return; + } + + // Set the user preferences to include only preference packs. + // This is a quick and dirty way to open Addon Manager with only themes. + auto pref = App::GetApplication().GetParameterGroupByPath("User parameter:BaseApp/Preferences/Addons"); + pref->SetInt("PackageTypeSelection", 3); // 3 stands for Preference Packs + pref->SetInt("StatusSelection", 0); // 0 stands for any installation status + + Gui::Application::Instance->commandManager().runCommandByName("Std_AddonMgr"); +} + /////////////////////////////////////////////////////////// namespace { diff --git a/src/Gui/PreferencePages/DlgSettingsGeneral.h b/src/Gui/PreferencePages/DlgSettingsGeneral.h index cde07059f3..0779117c5e 100644 --- a/src/Gui/PreferencePages/DlgSettingsGeneral.h +++ b/src/Gui/PreferencePages/DlgSettingsGeneral.h @@ -70,6 +70,7 @@ protected Q_SLOTS: void onManagePreferencePacksClicked(); void onImportConfigClicked(); void onThemeChanged(int index); + void onLinkActivated(const QString& link); public Q_SLOTS: void onUnitSystemIndexChanged(int index); diff --git a/src/Gui/PreferencePages/DlgSettingsGeneral.ui b/src/Gui/PreferencePages/DlgSettingsGeneral.ui index 182340488d..5fda837424 100644 --- a/src/Gui/PreferencePages/DlgSettingsGeneral.ui +++ b/src/Gui/PreferencePages/DlgSettingsGeneral.ui @@ -235,14 +235,29 @@ dot/period will always be printed. - + + + + + 8 + + + + Looking for more themes? You can obtain them using <a href="freecad:Std_AddonMgr">Addon Manager</a>. + + + Qt::RichText + + + + Size of toolbar icons: - + Choose your preference for toolbar icon size. You can adjust @@ -250,14 +265,14 @@ this according to your screen size or personal taste - + Tree view and Property view mode: - + Customize how tree view is shown in the panel (restart required). @@ -267,14 +282,14 @@ this according to your screen size or personal taste - + Size of recent file list: - + How many files should be listed in recent files list @@ -290,7 +305,7 @@ this according to your screen size or personal taste - + Background of the main window (when no document is opened) will consist of tiles of a special image. @@ -301,7 +316,7 @@ See the FreeCAD Wiki for details about the image. - + The text cursor will be blinking @@ -320,7 +335,7 @@ See the FreeCAD Wiki for details about the image. - + A Splash screen is a small loading window that is shown @@ -341,7 +356,7 @@ display the splash screen - + Activate overlay handling of dock windows diff --git a/src/Mod/Start/Gui/ThemeSelectorWidget.cpp b/src/Mod/Start/Gui/ThemeSelectorWidget.cpp index 5a11316979..7c5c726a98 100644 --- a/src/Mod/Start/Gui/ThemeSelectorWidget.cpp +++ b/src/Mod/Start/Gui/ThemeSelectorWidget.cpp @@ -33,7 +33,7 @@ #include "ThemeSelectorWidget.h" #include #include -#include +#include #include using namespace StartGui; @@ -101,10 +101,29 @@ void ThemeSelectorWidget::setupUi() _titleLabel = gsl::owner(new QLabel); _descriptionLabel = gsl::owner(new QLabel); outerLayout->addWidget(_titleLabel); - outerLayout->addWidget(_descriptionLabel); outerLayout->addLayout(buttonLayout); + outerLayout->addWidget(_descriptionLabel); setupButtons(buttonLayout); retranslateUi(); + connect(_descriptionLabel, &QLabel::linkActivated, this, &ThemeSelectorWidget::onLinkActivated); +} + +void ThemeSelectorWidget::onLinkActivated(const QString& link) +{ + auto const addonManagerLink = QStringLiteral("freecad:Std_AddonMgr"); + + if (link != addonManagerLink) { + return; + } + + // Set the user preferences to include only preference packs. + // This is a quick and dirty way to open Addon Manager with only themes. + auto pref = + App::GetApplication().GetParameterGroupByPath("User parameter:BaseApp/Preferences/Addons"); + pref->SetInt("PackageTypeSelection", 3); // 3 stands for Preference Packs + pref->SetInt("StatusSelection", 0); // 0 stands for any installation status + + Gui::Application::Instance->commandManager().runCommandByName("Std_AddonMgr"); } void ThemeSelectorWidget::themeChanged(Theme newTheme) @@ -135,7 +154,8 @@ bool ThemeSelectorWidget::eventFilter(QObject* object, QEvent* event) void ThemeSelectorWidget::retranslateUi() { _titleLabel->setText(QLatin1String("

") + tr("Theme") + QLatin1String("

")); - _descriptionLabel->setText(tr("More themes are available online using the Addon Manager")); + _descriptionLabel->setText(tr("Looking for more themes? You can obtain them using " + "Addon Manager.")); _buttons[static_cast(Theme::Dark)]->setText(tr("Dark theme", "Visual theme name")); _buttons[static_cast(Theme::Light)]->setText(tr("Light theme", "Visual theme name")); _buttons[static_cast(Theme::Classic)]->setText(tr("Classic", "Visual theme name")); diff --git a/src/Mod/Start/Gui/ThemeSelectorWidget.h b/src/Mod/Start/Gui/ThemeSelectorWidget.h index d555c72bec..3ff9ebbc44 100644 --- a/src/Mod/Start/Gui/ThemeSelectorWidget.h +++ b/src/Mod/Start/Gui/ThemeSelectorWidget.h @@ -56,6 +56,7 @@ private: void retranslateUi(); void setupUi(); void setupButtons(QBoxLayout* layout); + void onLinkActivated(const QString& link); QLabel* _titleLabel; QLabel* _descriptionLabel;