Skip to content

Commit

Permalink
Start: UX refinements
Browse files Browse the repository at this point in the history
Start: Automatically run command when event loop starts
Also sets PartDesign as the default startup Workbench.
Start: Add checkbox for starting or not starting Start
Start: Correct default card size parameter access
Start: General cleanup
  • Loading branch information
chennes committed Apr 22, 2024
1 parent 7742832 commit bbf9192
Show file tree
Hide file tree
Showing 13 changed files with 413 additions and 18 deletions.
2 changes: 1 addition & 1 deletion src/Main/MainGui.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
4 changes: 4 additions & 0 deletions src/Mod/Start/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
30 changes: 29 additions & 1 deletion src/Mod/Start/Gui/AppStartGui.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -22,13 +22,17 @@
***************************************************************************/

#include "PreCompiled.h"
#ifndef _PreComp_
#include <QString>
#include <QTimer>
#endif

#include <Base/Console.h>
#include <Base/Interpreter.h>
#include <Base/PyObjectBase.h>
#include <Gui/Language/Translator.h>
#include <Gui/Command.h>

#include <QString>

#include <3rdParty/GSL/include/gsl/pointers>

Expand Down Expand Up @@ -60,6 +64,28 @@ class Module: public Py::ExtensionModule<Module>
}
};

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<Module*>(new Module);
Expand All @@ -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<StartGui::Manipulator>();
Expand Down
3 changes: 2 additions & 1 deletion src/Mod/Start/Gui/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
6 changes: 2 additions & 4 deletions src/Mod/Start/Gui/FileCardDelegate.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,7 @@ void FileCardDelegate::paint(QPainter* painter,
const QModelIndex& index) const
{
auto thumbnailSize =
static_cast<int>(_parameterGroup->GetInt("FileThumbnailIconsSize", 64)); // NOLINT
static_cast<int>(_parameterGroup->GetInt("FileThumbnailIconsSize", 128)); // NOLINT
auto cardWidth = thumbnailSize;
auto baseName = index.data(static_cast<int>(DisplayedFilesModelRoles::baseName)).toString();
auto size = index.data(static_cast<int>(DisplayedFilesModelRoles::size)).toString();
Expand Down Expand Up @@ -126,16 +126,14 @@ QPixmap pixmapToSizedQImage(const QImage& pixmap, int size)
QPixmap FileCardDelegate::generateThumbnail(const QString& path) const
{
auto thumbnailSize =
static_cast<int>(_parameterGroup->GetInt("FileThumbnailIconsSize", 64)); // NOLINT
static_cast<int>(_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());
}
Expand Down
2 changes: 1 addition & 1 deletion src/Mod/Start/Gui/Manipulator.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down
3 changes: 3 additions & 0 deletions src/Mod/Start/Gui/PreCompiled.h
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,7 @@
#include <unordered_map>

// Qt
#include <QCheckBox>
#include <QCoreApplication>
#include <QFile>
#include <QFileIconProvider>
Expand All @@ -56,7 +57,9 @@
#include <QPushButton>
#include <QScrollArea>
#include <QSpacerItem>
#include <QString>
#include <QStyleOptionViewItem>
#include <QTimer>
#include <QUrl>
#include <QVBoxLayout>
#include <QWidget>
Expand Down
3 changes: 2 additions & 1 deletion src/Mod/Start/Gui/Resources/Start.qrc
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
<RCC>
<qresource prefix="/">
<file>icons/StartWorkbench.svg</file>
<file>icons/StartCommandIcon.svg</file>
<file>icons/PartDesignWorkbench.svg</file>
</qresource>
</RCC>
Loading

0 comments on commit bbf9192

Please sign in to comment.