diff --git a/src/Main/MainGui.cpp b/src/Main/MainGui.cpp index 1fb00406ec..71ed46a2ef 100644 --- a/src/Main/MainGui.cpp +++ b/src/Main/MainGui.cpp @@ -164,7 +164,7 @@ int main( int argc, char ** argv ) App::Application::Config()["AppIcon"] = "freecad"; App::Application::Config()["SplashScreen"] = "freecadsplash"; App::Application::Config()["AboutImage"] = "freecadabout"; - App::Application::Config()["StartWorkbench"] = "NoneWorkbench"; + App::Application::Config()["StartWorkbench"] = "PartDesignWorkbench"; //App::Application::Config()["HiddenDockWindow"] = "Property editor"; App::Application::Config()["SplashAlignment" ] = "Bottom|Left"; App::Application::Config()["SplashTextColor" ] = "#8aadf4"; // light blue diff --git a/src/Mod/Start/CMakeLists.txt b/src/Mod/Start/CMakeLists.txt index e01e688e38..8583e280a4 100644 --- a/src/Mod/Start/CMakeLists.txt +++ b/src/Mod/Start/CMakeLists.txt @@ -21,6 +21,10 @@ # * * # ***************************************************************************/ +if( NOT EXISTS "${CMAKE_SOURCE_DIR}/src/3rdParty/GSL" ) + message( SEND_ERROR "The C++ Guidelines Support Library (GSL) submodule is not available. Please run git submodule update --init" ) +endif() + add_subdirectory(App) set(Start_Scripts diff --git a/src/Mod/Start/Gui/AppStartGui.cpp b/src/Mod/Start/Gui/AppStartGui.cpp index e181b31894..0b4b8a1f60 100644 --- a/src/Mod/Start/Gui/AppStartGui.cpp +++ b/src/Mod/Start/Gui/AppStartGui.cpp @@ -22,13 +22,17 @@ ***************************************************************************/ #include "PreCompiled.h" +#ifndef _PreComp_ +#include +#include +#endif #include #include #include #include +#include -#include #include <3rdParty/GSL/include/gsl/pointers> @@ -60,6 +64,28 @@ public: } }; +class StartLauncher +{ +public: + StartLauncher() + { + // QTimers don't fire until the event loop starts, which is our signal that the GUI is up + QTimer::singleShot(1000, [this] { + Launch(); + }); + } + + void Launch() + { + auto hGrp = App::GetApplication().GetParameterGroupByPath( + "User parameter:BaseApp/Preferences/Mod/Start"); + bool showOnStartup = hGrp->GetBool("ShowOnStartup", true); + if (showOnStartup) { + Gui::Application::Instance->commandManager().runCommandByName("Start_Start"); + } + } +}; + PyObject* initModule() { auto newModule = gsl::owner(new Module); @@ -71,6 +97,8 @@ PyObject* initModule() /* Python entry */ PyMOD_INIT_FUNC(StartGui) { + static StartGui::StartLauncher* launcher = new StartGui::StartLauncher(); + Base::Console().Log("Loading GUI of Start module... "); PyObject* mod = StartGui::initModule(); auto manipulator = std::make_shared(); diff --git a/src/Mod/Start/Gui/CMakeLists.txt b/src/Mod/Start/Gui/CMakeLists.txt index d16b95623e..9f8141ad35 100644 --- a/src/Mod/Start/Gui/CMakeLists.txt +++ b/src/Mod/Start/Gui/CMakeLists.txt @@ -62,7 +62,8 @@ SET(StartGui_SRCS ) SET(StartGuiIcon_SVG - Resources/icons/StartWorkbench.svg + Resources/icons/StartCommandIcon.svg + Resources/icons/PartDesignWorkbench.svg ) # TODO: Evaluate PCH use with Qt6/QtQuick/Qml diff --git a/src/Mod/Start/Gui/FileCardDelegate.cpp b/src/Mod/Start/Gui/FileCardDelegate.cpp index b6ea1abafb..0118a36a19 100644 --- a/src/Mod/Start/Gui/FileCardDelegate.cpp +++ b/src/Mod/Start/Gui/FileCardDelegate.cpp @@ -55,7 +55,7 @@ void FileCardDelegate::paint(QPainter* painter, const QModelIndex& index) const { auto thumbnailSize = - static_cast(_parameterGroup->GetInt("FileThumbnailIconsSize", 64)); // NOLINT + static_cast(_parameterGroup->GetInt("FileThumbnailIconsSize", 128)); // NOLINT auto cardWidth = thumbnailSize; auto baseName = index.data(static_cast(DisplayedFilesModelRoles::baseName)).toString(); auto size = index.data(static_cast(DisplayedFilesModelRoles::size)).toString(); @@ -126,16 +126,14 @@ QPixmap pixmapToSizedQImage(const QImage& pixmap, int size) QPixmap FileCardDelegate::generateThumbnail(const QString& path) const { auto thumbnailSize = - static_cast(_parameterGroup->GetInt("FileThumbnailIconsSize", 64)); // NOLINT + static_cast(_parameterGroup->GetInt("FileThumbnailIconsSize", 128)); // NOLINT if (path.endsWith(QLatin1String(".fcstd"), Qt::CaseSensitivity::CaseInsensitive)) { QImageReader reader(QLatin1String(":/icons/freecad-doc.svg")); - ; reader.setScaledSize({thumbnailSize, thumbnailSize}); return QPixmap::fromImage(reader.read()); } if (path.endsWith(QLatin1String(".fcmacro"), Qt::CaseSensitivity::CaseInsensitive)) { QImageReader reader(QLatin1String(":/icons/MacroEditor.svg")); - ; reader.setScaledSize({thumbnailSize, thumbnailSize}); return QPixmap::fromImage(reader.read()); } diff --git a/src/Mod/Start/Gui/Manipulator.cpp b/src/Mod/Start/Gui/Manipulator.cpp index e9338dad05..4b060ef6f3 100644 --- a/src/Mod/Start/Gui/Manipulator.cpp +++ b/src/Mod/Start/Gui/Manipulator.cpp @@ -49,7 +49,7 @@ CmdStart::CmdStart() sToolTipText = QT_TR_NOOP("Displays the Start in an MDI view"); sWhatsThis = "Start_Start"; sStatusTip = sToolTipText; - sPixmap = "StartWorkbench"; + sPixmap = "StartCommandIcon"; } void CmdStart::activated(int iMsg) diff --git a/src/Mod/Start/Gui/PreCompiled.h b/src/Mod/Start/Gui/PreCompiled.h index 28c77a66df..e5c164a33c 100644 --- a/src/Mod/Start/Gui/PreCompiled.h +++ b/src/Mod/Start/Gui/PreCompiled.h @@ -43,6 +43,7 @@ #include // Qt +#include #include #include #include @@ -56,7 +57,9 @@ #include #include #include +#include #include +#include #include #include #include diff --git a/src/Mod/Start/Gui/Resources/Start.qrc b/src/Mod/Start/Gui/Resources/Start.qrc index cfd3c7cc7f..0104840591 100644 --- a/src/Mod/Start/Gui/Resources/Start.qrc +++ b/src/Mod/Start/Gui/Resources/Start.qrc @@ -1,5 +1,6 @@ - icons/StartWorkbench.svg + icons/StartCommandIcon.svg + icons/PartDesignWorkbench.svg diff --git a/src/Mod/Start/Gui/Resources/icons/PartDesignWorkbench.svg b/src/Mod/Start/Gui/Resources/icons/PartDesignWorkbench.svg new file mode 100644 index 0000000000..4382404c0c --- /dev/null +++ b/src/Mod/Start/Gui/Resources/icons/PartDesignWorkbench.svg @@ -0,0 +1,322 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + image/svg+xml + + + Path-Stock + 2015-07-04 + https://www.freecad.org/wiki/index.php?title=Artwork + + + FreeCAD + + + FreeCAD/src/Mod/Path/Gui/Resources/icons/Path-Stock.svg + + + FreeCAD LGPL2+ + + + https://www.gnu.org/copyleft/lesser.html + + + [agryson] Alexander Gryson + + + + + + + + + + + + + + + + + diff --git a/src/Mod/Start/Gui/Resources/icons/StartWorkbench.svg b/src/Mod/Start/Gui/Resources/icons/StartCommandIcon.svg similarity index 100% rename from src/Mod/Start/Gui/Resources/icons/StartWorkbench.svg rename to src/Mod/Start/Gui/Resources/icons/StartCommandIcon.svg diff --git a/src/Mod/Start/Gui/StartView.cpp b/src/Mod/Start/Gui/StartView.cpp index 8a581c2715..678c1cb799 100644 --- a/src/Mod/Start/Gui/StartView.cpp +++ b/src/Mod/Start/Gui/StartView.cpp @@ -25,6 +25,7 @@ #ifndef _PreComp_ #include +#include #include #include #include @@ -112,13 +113,25 @@ StartView::StartView(Gui::Document* pcDocument, QWidget* parent) // New WB notice: temporary to explain why all your setting disappeared auto newStartWBNotice = gsl::owner( new QLabel(tr("NOTE: The Start Workbench has been completely rewritten to remove all " - "network access, and to remove " - "its dependency on Chromium. This is still a work-in-progress, and not all " - "settings from the previous " - "version of Start have been migrated yet."))); + "network access, and to remove its dependency on Chromium. This is still a " + "work-in-progress, and not all settings from the previous version of Start " + "have been migrated yet."))); newStartWBNotice->setWordWrap(true); layout->addWidget(newStartWBNotice); + // Launch start automatically? + QString application = QString::fromUtf8(App::Application::Config()["ExeName"].c_str()); + auto launchAutomaticallyCheckbox = + gsl::owner(new QCheckBox(tr("Show Start when starting %1").arg(application))); + bool showOnStartup = hGrp->GetBool("ShowOnStartup", true); + launchAutomaticallyCheckbox->setCheckState(showOnStartup ? Qt::CheckState::Checked + : Qt::CheckState::Unchecked); + connect(launchAutomaticallyCheckbox, + &QCheckBox::toggled, + this, + &StartView::showOnStartupChanged); + layout->addWidget(launchAutomaticallyCheckbox); + const QLatin1String h1Start("

"); const QLatin1String h1End("

"); @@ -149,7 +162,7 @@ StartView::StartView(Gui::Document* pcDocument, QWidget* parent) setWindowTitle(title); configureExamplesListWidget(examplesListWidget); - configureRecentFilesListWidget(recentFilesListWidget); + configureRecentFilesListWidget(recentFilesListWidget, recentFilesLabel); } @@ -174,6 +187,8 @@ void StartView::configureNewFileButtons(QGridLayout* layout) const tr("Create an architectural project"), QLatin1String(":/icons/ArchWorkbench.svg")}); + // TODO: Ensure all of the required WBs are actually available + // TODO: Make this layout more flexible (e.g. use a single line if possible) layout->addWidget(partDesign, 0, 0); layout->addWidget(assembly, 0, 1); layout->addWidget(draft, 0, 2); @@ -200,11 +215,24 @@ void StartView::configureFileCardWidget(QListView* fileCardWidget) } -void StartView::configureRecentFilesListWidget(QListView* recentFilesListWidget) +void StartView::configureRecentFilesListWidget(QListView* recentFilesListWidget, + QLabel* recentFilesLabel) { _recentFilesModel.loadRecentFiles(); recentFilesListWidget->setModel(&_recentFilesModel); configureFileCardWidget(recentFilesListWidget); + + auto recentFilesGroup = App::GetApplication().GetParameterGroupByPath( + "User parameter:BaseApp/Preferences/RecentFiles"); + auto numRecentFiles {recentFilesGroup->GetInt("RecentFiles", 0)}; + if (numRecentFiles == 0) { + recentFilesListWidget->hide(); + recentFilesLabel->hide(); + } + else { + recentFilesListWidget->show(); + recentFilesLabel->show(); + } } @@ -311,3 +339,10 @@ void StartView::fileCardSelected(const QModelIndex& index) Base::Console().Error("An unknown error occurred"); } } + +void StartView::showOnStartupChanged(bool checked) +{ + auto hGrp = App::GetApplication().GetParameterGroupByPath( + "User parameter:BaseApp/Preferences/Mod/Start"); + hGrp->SetBool("ShowOnStartup", checked); +} diff --git a/src/Mod/Start/Gui/StartView.h b/src/Mod/Start/Gui/StartView.h index e52b5af32f..f8aba3314c 100644 --- a/src/Mod/Start/Gui/StartView.h +++ b/src/Mod/Start/Gui/StartView.h @@ -33,6 +33,7 @@ #include "../App/ExamplesModel.h" +class QLabel; class QListView; class QGridLayout; class QScrollArea; @@ -76,13 +77,15 @@ public: protected: void configureNewFileButtons(QGridLayout* layout) const; static void configureFileCardWidget(QListView* fileCardWidget); - void configureRecentFilesListWidget(QListView* recentFilesListWidget); + void configureRecentFilesListWidget(QListView* recentFilesListWidget, QLabel* recentFilesLabel); void configureExamplesListWidget(QListView* examplesListWidget); void postStart(PostStartBehavior behavior) const; void fileCardSelected(const QModelIndex& index); + void showOnStartupChanged(bool checked); + private: QScrollArea* _contents = nullptr; Start::RecentFilesModel _recentFilesModel; diff --git a/src/Mod/Start/InitGui.py b/src/Mod/Start/InitGui.py index 14efbea9e3..7e88975723 100644 --- a/src/Mod/Start/InitGui.py +++ b/src/Mod/Start/InitGui.py @@ -24,5 +24,5 @@ import StartGui # Not unused, import has a side-effect of creating the "Start_Start" command import StartMigrator -migrator = StartMigrator.StartMigrator2024() -migrator.run_migration() +# migrator = StartMigrator.StartMigrator2024() +# migrator.run_migration()