From 3942ec77945117e678ca928fb1a38f93295f8efc Mon Sep 17 00:00:00 2001 From: Furgo <148809153+furgo16@users.noreply.github.com> Date: Fri, 28 Feb 2025 19:10:46 +0100 Subject: [PATCH 1/4] Add initial preferences page for Start --- src/Mod/Start/Gui/AppStartGui.cpp | 6 + src/Mod/Start/Gui/CMakeLists.txt | 6 + src/Mod/Start/Gui/DlgStartPreferences.ui | 145 +++++++++++++++++++ src/Mod/Start/Gui/DlgStartPreferencesImp.cpp | 84 +++++++++++ src/Mod/Start/Gui/DlgStartPreferencesImp.h | 52 +++++++ 5 files changed, 293 insertions(+) create mode 100644 src/Mod/Start/Gui/DlgStartPreferences.ui create mode 100644 src/Mod/Start/Gui/DlgStartPreferencesImp.cpp create mode 100644 src/Mod/Start/Gui/DlgStartPreferencesImp.h diff --git a/src/Mod/Start/Gui/AppStartGui.cpp b/src/Mod/Start/Gui/AppStartGui.cpp index 561485d147..5750b1baab 100644 --- a/src/Mod/Start/Gui/AppStartGui.cpp +++ b/src/Mod/Start/Gui/AppStartGui.cpp @@ -33,6 +33,8 @@ #include #include #include +#include +#include "DlgStartPreferencesImp.h" #include @@ -124,5 +126,9 @@ PyMOD_INIT_FUNC(StartGui) loadStartResource(); Base::Console().Log("done\n"); + // register preferences pages + new Gui::PrefPageProducer( + QT_TRANSLATE_NOOP("QObject", "Start")); + PyMOD_Return(mod); } diff --git a/src/Mod/Start/Gui/CMakeLists.txt b/src/Mod/Start/Gui/CMakeLists.txt index 162be78499..98706d562c 100644 --- a/src/Mod/Start/Gui/CMakeLists.txt +++ b/src/Mod/Start/Gui/CMakeLists.txt @@ -44,6 +44,10 @@ set(StartGui_LIBS FreeCADGui ) +set(StartGui_UIC_SRCS + DlgStartPreferences.ui + ) + set(Start_TR_QRC ${CMAKE_CURRENT_BINARY_DIR}/Resources/Start_translation.qrc) qt_find_and_add_translation(QM_SRCS "Resources/translations/*_*.ts" ${CMAKE_CURRENT_BINARY_DIR}/Resources/translations) @@ -54,6 +58,8 @@ qt_add_resources(Start_QRC_SRCS Resources/Start.qrc ${Start_TR_QRC}) SET(StartGui_SRCS ${Start_QRC_SRCS} ${StartGui_UIC_SRCS} + DlgStartPreferencesImp.cpp + DlgStartPreferencesImp.h AppStartGui.cpp FileCardDelegate.cpp FileCardDelegate.h diff --git a/src/Mod/Start/Gui/DlgStartPreferences.ui b/src/Mod/Start/Gui/DlgStartPreferences.ui new file mode 100644 index 0000000000..0102c5e340 --- /dev/null +++ b/src/Mod/Start/Gui/DlgStartPreferences.ui @@ -0,0 +1,145 @@ + + + DlgStartPreferences + + + + 0 + 0 + 537 + 766 + + + + General + + + + + + Contents + + + + + + Show additional folder contents + + + + + + + If you want the examples to show on the first page + + + Qt::RightToLeft + + + + + + true + + + ShowExamples + + + Mod/Start + + + + + + + An optional custom folder to be displayed at the bottom of the first page. +By using ";;" to separate paths, you can add several folders here + + + CustomFolder + + + Mod/Start + + + + + + + Show examples folder contents + + + + + + + + + + Options + + + + + + If checked, will automatically close the Start page when FreeCAD launches + + + Qt::RightToLeft + + + + + + closeStart + + + Mod/Start + + + + + + + Close start page after loading + + + + + + + + + + Qt::Vertical + + + + 20 + 40 + + + + + + + + + Gui::FileChooser + QWidget +
Gui/FileDialog.h
+
+ + Gui::PrefFileChooser + Gui::FileChooser +
Gui/PrefWidgets.h
+
+ + Gui::PrefCheckBox + QCheckBox +
Gui/PrefWidgets.h
+
+
+ + +
diff --git a/src/Mod/Start/Gui/DlgStartPreferencesImp.cpp b/src/Mod/Start/Gui/DlgStartPreferencesImp.cpp new file mode 100644 index 0000000000..e893f5b7b3 --- /dev/null +++ b/src/Mod/Start/Gui/DlgStartPreferencesImp.cpp @@ -0,0 +1,84 @@ +/*************************************************************************** + * Copyright (c) 2018 Yorik van Havre * + * * + * This file is part of the FreeCAD CAx development system. * + * * + * This library is free software; you can redistribute it and/or * + * modify it under the terms of the GNU Library General Public * + * License as published by the Free Software Foundation; either * + * version 2 of the License, or (at your option) any later version. * + * * + * This library is distributed in the hope that it will be useful, * + * but WITHOUT ANY WARRANTY; without even the implied warranty of * + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * + * GNU Library General Public License for more details. * + * * + * You should have received a copy of the GNU Library General Public * + * License along with this library; see the file COPYING.LIB. If not, * + * write to the Free Software Foundation, Inc., 59 Temple Place, * + * Suite 330, Boston, MA 02111-1307, USA * + * * + ***************************************************************************/ + +#include "PreCompiled.h" + +#include + +#include "DlgStartPreferencesImp.h" +#include "ui_DlgStartPreferences.h" + + +using namespace StartGui; + +/** + * Constructs a DlgStartPreferencesImp which is a child of 'parent' + */ +DlgStartPreferencesImp::DlgStartPreferencesImp(QWidget* parent) + : PreferencePage(parent) + , ui(new Ui_DlgStartPreferences) +{ + ui->setupUi(this); +} + +/** + * Destroys the object and frees any allocated resources + */ +DlgStartPreferencesImp::~DlgStartPreferencesImp() +{ + // no need to delete child widgets, Qt does it all for us +} + +void DlgStartPreferencesImp::saveSettings() +{ + ui->fileChooserCustomFolder->onSave(); + ui->checkBoxShowExamples->onSave(); + ui->checkBoxCloseAfterLoading->onSave(); +} + +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()); + // QString startWbName = QLatin1String(start.c_str()); + + ui->fileChooserCustomFolder->onRestore(); + ui->checkBoxShowExamples->onRestore(); + ui->checkBoxCloseAfterLoading->onRestore(); +} + +/** + * Sets the strings of the subwidgets using the current language. + */ +void DlgStartPreferencesImp::changeEvent(QEvent* e) +{ + if (e->type() == QEvent::LanguageChange) { + ui->retranslateUi(this); + } + else { + QWidget::changeEvent(e); + } +} + +#include "moc_DlgStartPreferencesImp.cpp" diff --git a/src/Mod/Start/Gui/DlgStartPreferencesImp.h b/src/Mod/Start/Gui/DlgStartPreferencesImp.h new file mode 100644 index 0000000000..61696ad39f --- /dev/null +++ b/src/Mod/Start/Gui/DlgStartPreferencesImp.h @@ -0,0 +1,52 @@ +/*************************************************************************** + * Copyright (c) 2018 Yorik van Havre * + * * + * This file is part of the FreeCAD CAx development system. * + * * + * This library is free software; you can redistribute it and/or * + * modify it under the terms of the GNU Library General Public * + * License as published by the Free Software Foundation; either * + * version 2 of the License, or (at your option) any later version. * + * * + * This library is distributed in the hope that it will be useful, * + * but WITHOUT ANY WARRANTY; without even the implied warranty of * + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * + * GNU Library General Public License for more details. * + * * + * You should have received a copy of the GNU Library General Public * + * License along with this library; see the file COPYING.LIB. If not, * + * write to the Free Software Foundation, Inc., 59 Temple Place, * + * Suite 330, Boston, MA 02111-1307, USA * + * * + ***************************************************************************/ + +#ifndef STARTGUI_DLGSTARTPREFERENCESIMP_H +#define STARTGUI_DLGSTARTPREFERENCESIMP_H + +#include +#include + + +class Ui_DlgStartPreferences; +namespace StartGui +{ +class DlgStartPreferencesImp: public Gui::Dialog::PreferencePage +{ + Q_OBJECT + +public: + explicit DlgStartPreferencesImp(QWidget* parent = nullptr); + ~DlgStartPreferencesImp() override; + +protected: + void saveSettings() override; + void loadSettings() override; + void changeEvent(QEvent* e) override; + +private: + std::unique_ptr ui; +}; + +} // namespace StartGui + +#endif // STARTGUI_DLGSTARTPREFERENCESIMP_H From 463d2025ec6d06b66812a0ea40cbeb4dce2f5a9a Mon Sep 17 00:00:00 2001 From: Furgo <148809153+furgo16@users.noreply.github.com> Date: Sat, 1 Mar 2025 01:10:36 +0100 Subject: [PATCH 2/4] Add icon for Start page preferences tab --- src/Mod/Start/Gui/Resources/Start.qrc | 1 + .../Gui/Resources/icons/preferences-start.svg | 182 ++++++++++++++++++ 2 files changed, 183 insertions(+) create mode 100644 src/Mod/Start/Gui/Resources/icons/preferences-start.svg diff --git a/src/Mod/Start/Gui/Resources/Start.qrc b/src/Mod/Start/Gui/Resources/Start.qrc index e02454d61d..ce6754ea91 100644 --- a/src/Mod/Start/Gui/Resources/Start.qrc +++ b/src/Mod/Start/Gui/Resources/Start.qrc @@ -1,6 +1,7 @@ icons/StartCommandIcon.svg + icons/preferences-start.svg icons/PartDesignWorkbench.svg thumbnails/Theme_thumbnail_classic.png thumbnails/Theme_thumbnail_light.png diff --git a/src/Mod/Start/Gui/Resources/icons/preferences-start.svg b/src/Mod/Start/Gui/Resources/icons/preferences-start.svg new file mode 100644 index 0000000000..2e09d1511c --- /dev/null +++ b/src/Mod/Start/Gui/Resources/icons/preferences-start.svg @@ -0,0 +1,182 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + image/svg+xml + + + + + [triplus] + + + StartWorkbench + 2016-02-26 + http://www.freecad.org/wiki/index.php?title=Artwork + + + FreeCAD + + + FreeCAD/src/Mod/Start/Gui/Resources/icons/StartWorkbench.svg + + + FreeCAD LGPL2+ + + + https://www.gnu.org/copyleft/lesser.html + + + [agryson] Alexander Gryson + + + + + arrow + right + + + Arrow pointing towards the right + + + + + + + + From 05e1f4937070df8dbe20054bb274ffdf88109877 Mon Sep 17 00:00:00 2001 From: Furgo <148809153+furgo16@users.noreply.github.com> Date: Sat, 1 Mar 2025 01:31:07 +0100 Subject: [PATCH 3/4] Use the correct file chooser mode for folders, update tooltip --- src/Mod/Start/Gui/DlgStartPreferences.ui | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/src/Mod/Start/Gui/DlgStartPreferences.ui b/src/Mod/Start/Gui/DlgStartPreferences.ui index 0102c5e340..2dcf6df394 100644 --- a/src/Mod/Start/Gui/DlgStartPreferences.ui +++ b/src/Mod/Start/Gui/DlgStartPreferences.ui @@ -52,8 +52,10 @@ - An optional custom folder to be displayed at the bottom of the first page. -By using ";;" to separate paths, you can add several folders here + An optional custom folder to be displayed on the Start page. + + + Gui::FileChooser::Directory CustomFolder From a4bf8b5194e7b91b9cff6c59d756912e33f660cc Mon Sep 17 00:00:00 2001 From: Furgo <148809153+furgo16@users.noreply.github.com> Date: Sat, 1 Mar 2025 20:11:59 +0100 Subject: [PATCH 4/4] Remove dead code --- src/Mod/Start/Gui/DlgStartPreferencesImp.cpp | 6 ------ 1 file changed, 6 deletions(-) diff --git a/src/Mod/Start/Gui/DlgStartPreferencesImp.cpp b/src/Mod/Start/Gui/DlgStartPreferencesImp.cpp index e893f5b7b3..0d842d1b23 100644 --- a/src/Mod/Start/Gui/DlgStartPreferencesImp.cpp +++ b/src/Mod/Start/Gui/DlgStartPreferencesImp.cpp @@ -57,12 +57,6 @@ 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()); - // QString startWbName = QLatin1String(start.c_str()); - ui->fileChooserCustomFolder->onRestore(); ui->checkBoxShowExamples->onRestore(); ui->checkBoxCloseAfterLoading->onRestore();