diff --git a/src/Mod/Start/Gui/AppStartGui.cpp b/src/Mod/Start/Gui/AppStartGui.cpp index 72a89dfcfd..b2cd79f1df 100644 --- a/src/Mod/Start/Gui/AppStartGui.cpp +++ b/src/Mod/Start/Gui/AppStartGui.cpp @@ -99,6 +99,7 @@ PyMOD_INIT_FUNC(StartGui) // register preferences pages new Gui::PrefPageProducer (QT_TRANSLATE_NOOP("QObject", "Start")); + new Gui::PrefPageProducer (QT_TRANSLATE_NOOP("QObject", "Start")); // instantiating the commands CreateStartCommands(); diff --git a/src/Mod/Start/Gui/CMakeLists.txt b/src/Mod/Start/Gui/CMakeLists.txt index fc1c86391b..7140934b15 100644 --- a/src/Mod/Start/Gui/CMakeLists.txt +++ b/src/Mod/Start/Gui/CMakeLists.txt @@ -14,6 +14,7 @@ set(StartGui_LIBS set(StartGui_UIC_SRCS DlgStartPreferences.ui + DlgStartPreferencesAdvanced.ui ) set (Start_TR_QRC ${CMAKE_CURRENT_BINARY_DIR}/Resources/Start_translation.qrc) @@ -26,6 +27,7 @@ SET(StartGui_SRCS ${Start_QRC_SRCS} ${StartGui_UIC_SRCS} DlgStartPreferences.ui + DlgStartPreferencesAdvanced.ui DlgStartPreferencesImp.cpp DlgStartPreferencesImp.h AppStartGui.cpp diff --git a/src/Mod/Start/Gui/DlgStartPreferences.ui b/src/Mod/Start/Gui/DlgStartPreferences.ui index a88215a6db..032a8fc33c 100644 --- a/src/Mod/Start/Gui/DlgStartPreferences.ui +++ b/src/Mod/Start/Gui/DlgStartPreferences.ui @@ -11,31 +11,9 @@ - Start page options + General - - - - Start page template - - - - - - An optional HTML template that will be used instead of the default start page. - - - Template - - - Mod/Start - - - - - - diff --git a/src/Mod/Start/Gui/DlgStartPreferencesAdvanced.ui b/src/Mod/Start/Gui/DlgStartPreferencesAdvanced.ui new file mode 100644 index 0000000000..eb373c18a2 --- /dev/null +++ b/src/Mod/Start/Gui/DlgStartPreferencesAdvanced.ui @@ -0,0 +1,87 @@ + + + DlgStartPreferencesAdvanced + + + + 0 + 0 + 548 + 896 + + + + Advanced + + + + + + Custom HTML Template + + + + + + An optional HTML template that will be used instead of the default start page. + + + Template + + + Mod/Start + + + + + + + + + + Custom CSS + + + + + + <html><head/><body><p>You can paste your custom CSS here and the Start Page will apply it for you. To learn more about how you can style the Start Page, take a look at the HTML and CSS sources:</p><p><a href="https://github.com/FreeCAD/FreeCAD/blob/master/src/Mod/Start/StartPage/StartPage.html"><span style=" text-decoration: underline; color:#1d99f3;">https://github.com/FreeCAD/FreeCAD/blob/master/src/Mod/Start/StartPage/StartPage.html</span></a></p><p><a href="https://github.com/FreeCAD/FreeCAD/blob/master/src/Mod/Start/StartPage/StartPage.css"><span style=" text-decoration: underline; color:#1d99f3;">https://github.com/FreeCAD/FreeCAD/blob/master/src/Mod/Start/StartPage/StartPage.css</span></a></p></body></html> + + + true + + + + + + + false + + + CustomCSS + + + Mod/Start + + + + + + + + + + + Gui::PrefFileChooser + QWidget +
Gui/PrefWidgets.h
+
+ + Gui::PrefTextEdit + QWidget +
Gui/PrefWidgets.h
+
+
+ + +
diff --git a/src/Mod/Start/Gui/DlgStartPreferencesImp.cpp b/src/Mod/Start/Gui/DlgStartPreferencesImp.cpp index eab8120c2b..efe2bf6169 100644 --- a/src/Mod/Start/Gui/DlgStartPreferencesImp.cpp +++ b/src/Mod/Start/Gui/DlgStartPreferencesImp.cpp @@ -26,6 +26,7 @@ #include "DlgStartPreferencesImp.h" #include "ui_DlgStartPreferences.h" +#include "ui_DlgStartPreferencesAdvanced.h" using namespace StartGui; @@ -33,9 +34,9 @@ using namespace StartGui; /** * Constructs a DlgStartPreferencesImp which is a child of 'parent' */ -DlgStartPreferencesImp::DlgStartPreferencesImp( QWidget* parent ) - : PreferencePage( parent ) - , ui(new Ui_DlgStartPreferences) +DlgStartPreferencesImp::DlgStartPreferencesImp(QWidget* parent) + : PreferencePage(parent) + , ui(new Ui_DlgStartPreferences) { ui->setupUi(this); @@ -55,8 +56,10 @@ DlgStartPreferencesImp::DlgStartPreferencesImp( QWidget* parent ) menuText[text] = it; } - { // add special workbench to selection - QPixmap px = Gui::Application::Instance->workbenchIcon(QString::fromLatin1("NoneWorkbench")); + // add special workbench to selection + { + QPixmap px = + Gui::Application::Instance->workbenchIcon(QString::fromLatin1("NoneWorkbench")); QString key = QString::fromLatin1(""); QString value = QString::fromLatin1("$LastModule"); if (px.isNull()) { @@ -69,12 +72,13 @@ DlgStartPreferencesImp::DlgStartPreferencesImp( QWidget* parent ) for (QMap::Iterator it = menuText.begin(); it != menuText.end(); ++it) { QPixmap px = Gui::Application::Instance->workbenchIcon(it.value()); - if (px.isNull()) + if (px.isNull()) { ui->AutoloadModuleCombo->addItem(it.key(), QVariant(it.value())); - else + } + else { ui->AutoloadModuleCombo->addItem(px, it.key(), QVariant(it.value())); + } } - } /** @@ -87,8 +91,9 @@ void DlgStartPreferencesImp::saveSettings() int index = ui->AutoloadModuleCombo->currentIndex(); QVariant data = ui->AutoloadModuleCombo->itemData(index); QString startWbName = data.toString(); - App::GetApplication().GetParameterGroupByPath("User parameter:BaseApp/Preferences/Mod/Start")-> - SetASCII("AutoloadModule", startWbName.toLatin1()); + App::GetApplication() + .GetParameterGroupByPath("User parameter:BaseApp/Preferences/Mod/Start") + ->SetASCII("AutoloadModule", startWbName.toLatin1()); ui->colorButton_1->onSave(); ui->colorButton_2->onSave(); ui->colorButton_3->onSave(); @@ -96,7 +101,6 @@ void DlgStartPreferencesImp::saveSettings() ui->colorButton_5->onSave(); ui->colorButton_6->onSave(); ui->colorButton_7->onSave(); - ui->fileChooser_1->onSave(); ui->fileChooser_2->onSave(); ui->fileChooser_3->onSave(); ui->radioButton_1->onSave(); @@ -118,8 +122,9 @@ void DlgStartPreferencesImp::saveSettings() void DlgStartPreferencesImp::loadSettings() { std::string start = App::Application::Config()["StartWorkbench"]; - start = App::GetApplication().GetParameterGroupByPath("User parameter:BaseApp/Preferences/Mod/Start")-> - GetASCII("AutoloadModule", start.c_str()); + start = App::GetApplication() + .GetParameterGroupByPath("User parameter:BaseApp/Preferences/Mod/Start") + ->GetASCII("AutoloadModule", start.c_str()); QString startWbName = QLatin1String(start.c_str()); ui->AutoloadModuleCombo->setCurrentIndex(ui->AutoloadModuleCombo->findData(startWbName)); ui->colorButton_1->onRestore(); @@ -129,7 +134,6 @@ void DlgStartPreferencesImp::loadSettings() ui->colorButton_5->onRestore(); ui->colorButton_6->onRestore(); ui->colorButton_7->onRestore(); - ui->fileChooser_1->onRestore(); ui->fileChooser_2->onRestore(); ui->fileChooser_3->onRestore(); ui->radioButton_1->onRestore(); @@ -151,7 +155,48 @@ void DlgStartPreferencesImp::loadSettings() /** * Sets the strings of the subwidgets using the current language. */ -void DlgStartPreferencesImp::changeEvent(QEvent *ev) +void DlgStartPreferencesImp::changeEvent(QEvent* ev) +{ + if (ev->type() == QEvent::LanguageChange) { + ui->retranslateUi(this); + } + else { + Gui::Dialog::PreferencePage::changeEvent(ev); + } +} + + +/** + * Constructs a DlgStartPreferencesAdvancedImp which is a child of 'parent' + */ +DlgStartPreferencesAdvancedImp::DlgStartPreferencesAdvancedImp(QWidget* parent) + : PreferencePage(parent) + , ui(new Ui_DlgStartPreferencesAdvanced) +{ + ui->setupUi(this); +} + +/** + * Destroys the object and frees any allocated resources + */ +DlgStartPreferencesAdvancedImp::~DlgStartPreferencesAdvancedImp() = default; + +void DlgStartPreferencesAdvancedImp::saveSettings() +{ + ui->templateFileChooser->onSave(); + ui->customCSSTextEdit->onSave(); +} + +void DlgStartPreferencesAdvancedImp::loadSettings() +{ + ui->templateFileChooser->onRestore(); + ui->customCSSTextEdit->onRestore(); +} + +/** + * Sets the strings of the subwidgets using the current language. + */ +void DlgStartPreferencesAdvancedImp::changeEvent(QEvent* ev) { if (ev->type() == QEvent::LanguageChange) { ui->retranslateUi(this); diff --git a/src/Mod/Start/Gui/DlgStartPreferencesImp.h b/src/Mod/Start/Gui/DlgStartPreferencesImp.h index 391e5c3bd9..83cfeade92 100644 --- a/src/Mod/Start/Gui/DlgStartPreferencesImp.h +++ b/src/Mod/Start/Gui/DlgStartPreferencesImp.h @@ -23,29 +23,48 @@ #ifndef STARTGUI_DLGSTARTPREFERENCESIMP_H #define STARTGUI_DLGSTARTPREFERENCESIMP_H -#include #include +#include class Ui_DlgStartPreferences; -namespace StartGui { - class DlgStartPreferencesImp : public Gui::Dialog::PreferencePage - { - Q_OBJECT +class Ui_DlgStartPreferencesAdvanced; +namespace StartGui +{ +class DlgStartPreferencesImp: public Gui::Dialog::PreferencePage +{ + Q_OBJECT - public: - explicit DlgStartPreferencesImp( QWidget* parent = nullptr ); - ~DlgStartPreferencesImp() override; +public: + explicit DlgStartPreferencesImp(QWidget* parent = nullptr); + ~DlgStartPreferencesImp() override; - protected: - void saveSettings() override; - void loadSettings() override; - void changeEvent(QEvent *e) override; +protected: + void saveSettings() override; + void loadSettings() override; + void changeEvent(QEvent* e) override; - private: - std::unique_ptr ui; - }; +private: + std::unique_ptr ui; +}; -} // namespace StartGui +class DlgStartPreferencesAdvancedImp: public Gui::Dialog::PreferencePage +{ + Q_OBJECT -#endif // STARTGUI_DLGSTARTPREFERENCESIMP_H +public: + explicit DlgStartPreferencesAdvancedImp(QWidget* parent = nullptr); + ~DlgStartPreferencesAdvancedImp() override; + +protected: + void saveSettings() override; + void loadSettings() override; + void changeEvent(QEvent* e) override; + +private: + std::unique_ptr ui; +}; + +}// namespace StartGui + +#endif// STARTGUI_DLGSTARTPREFERENCESIMP_H diff --git a/src/Mod/Start/StartPage/StartPage.html b/src/Mod/Start/StartPage/StartPage.html index e852d2b616..943b4cbd0c 100644 --- a/src/Mod/Start/StartPage/StartPage.html +++ b/src/Mod/Start/StartPage/StartPage.html @@ -6,7 +6,8 @@ diff --git a/src/Mod/Start/StartPage/StartPage.py b/src/Mod/Start/StartPage/StartPage.py index f02928d392..11ba83e8d0 100644 --- a/src/Mod/Start/StartPage/StartPage.py +++ b/src/Mod/Start/StartPage/StartPage.py @@ -352,7 +352,8 @@ def handle(): with open(css_filename, 'r') as f: CSS = f.read() HTML = HTML.replace("JS",JS) - HTML = HTML.replace("CSS",CSS) + HTML = HTML.replace("DEFAULT_CSS",CSS) + HTML = HTML.replace("CUSTOM_CSS",FreeCAD.ParamGet("User parameter:BaseApp/Preferences/Mod/Start").GetString("CustomCSS","").replace("\n","")) # set the language