From 86b83da0605cbdfde1f3be9422df9dff5e4efe54 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Ole-Andr=C3=A9=20Rodlie?= Date: Fri, 8 Nov 2024 14:10:07 +0100 Subject: [PATCH 1/6] Toolbar related UI changes --- src/app/GUI/mainwindow.cpp | 17 ++--- src/app/GUI/mainwindow.h | 3 +- src/ui/CMakeLists.txt | 1 + src/ui/widgets/colortoolbar.cpp | 2 +- src/ui/widgets/toolbar.cpp | 104 +++++++++++++++++++++++++++++++ src/ui/widgets/toolbar.h | 20 +++--- src/ui/widgets/welcomedialog.cpp | 2 +- 7 files changed, 124 insertions(+), 25 deletions(-) create mode 100644 src/ui/widgets/toolbar.cpp diff --git a/src/app/GUI/mainwindow.cpp b/src/app/GUI/mainwindow.cpp index acd221575..92f771a5a 100644 --- a/src/app/GUI/mainwindow.cpp +++ b/src/app/GUI/mainwindow.cpp @@ -193,6 +193,7 @@ MainWindow::MainWindow(Document& document, this, &MainWindow::handleCurrentPixelColor); setWindowIcon(QIcon::fromTheme(AppSupport::getAppName())); + setContextMenuPolicy(Qt::NoContextMenu); mAutoSaveTimer = new QTimer(this); connect (mAutoSaveTimer, &QTimer::timeout, @@ -387,7 +388,7 @@ void MainWindow::setupMenuBar() mFileMenu = mMenuBar->addMenu(tr("File", "MenuBar")); - const auto newAct = mFileMenu->addAction(QIcon::fromTheme("file_new"), + const auto newAct = mFileMenu->addAction(QIcon::fromTheme("file_blank"), tr("New", "MenuBar_File"), this, &MainWindow::newFile, Qt::CTRL + Qt::Key_N); @@ -1347,17 +1348,9 @@ void MainWindow::updateSettingsForCurrentCanvas(Canvas* const scene) void MainWindow::setupToolBar() { - mToolbar = new QToolBar(tr("Toolbar"), this); - mToolbar->setObjectName("MainToolBar"); - mToolbar->setFocusPolicy(Qt::NoFocus); - mToolbar->setToolButtonStyle(Qt::ToolButtonTextBesideIcon); - mToolbar->setMovable(false); -#ifdef Q_OS_MAC - mToolbar->setStyleSheet(QString("font-size: %1pt;").arg(font().pointSize())); -#endif - eSizesUI::widget.add(mToolbar, [this](const int size) { - mToolbar->setIconSize({size, size}); - }); + mToolbar = new Ui::ToolBar(tr("Main Toolbar"), + "MainToolBar", + this); addToolBar(Qt::TopToolBarArea, mToolbar); } diff --git a/src/app/GUI/mainwindow.h b/src/app/GUI/mainwindow.h index 0f2dcef36..b55b056ee 100644 --- a/src/app/GUI/mainwindow.h +++ b/src/app/GUI/mainwindow.h @@ -55,6 +55,7 @@ #include "window.h" #include "widgets/aboutwidget.h" #include "widgets/uilayout.h" +#include "widgets/toolbar.h" class VideoEncoder; class RenderWidget; @@ -220,7 +221,7 @@ class MainWindow : public QMainWindow TimelineDockWidget *mTimeline; RenderWidget *mRenderWidget; - QToolBar *mToolbar; + Friction::Ui::ToolBar *mToolbar; QActionGroup *mToolBoxGroupMain; QActionGroup *mToolBoxGroupNodes; diff --git a/src/ui/CMakeLists.txt b/src/ui/CMakeLists.txt index fb3388af7..e262e064f 100644 --- a/src/ui/CMakeLists.txt +++ b/src/ui/CMakeLists.txt @@ -101,6 +101,7 @@ set( widgets/savedcolorswidget.cpp widgets/scenechooser.cpp widgets/settingswidget.cpp + widgets/toolbar.cpp widgets/twocolumnlayout.cpp widgets/uilayout.cpp widgets/welcomedialog.cpp diff --git a/src/ui/widgets/colortoolbar.cpp b/src/ui/widgets/colortoolbar.cpp index 481cb33ec..c6370a36f 100644 --- a/src/ui/widgets/colortoolbar.cpp +++ b/src/ui/widgets/colortoolbar.cpp @@ -165,7 +165,7 @@ void ColorToolBar::adjustWidgets() setToolButtonStyle(horiz ? Qt::ToolButtonTextBesideIcon : - Qt::ToolButtonTextUnderIcon); + Qt::ToolButtonIconOnly); mColorFill->setMinimumWidth(min); mColorStroke->setMinimumWidth(min); diff --git a/src/ui/widgets/toolbar.cpp b/src/ui/widgets/toolbar.cpp new file mode 100644 index 000000000..0093e4437 --- /dev/null +++ b/src/ui/widgets/toolbar.cpp @@ -0,0 +1,104 @@ +/* +# +# Friction - https://friction.graphics +# +# Copyright (c) Ole-André Rodlie and contributors +# +# This program is free software: you can redistribute it and/or modify +# it under the terms of the GNU General Public License as published by +# the Free Software Foundation, either version 3 of the License, or +# (at your option) any later version. +# +# This program 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 General Public License for more details. +# +# You should have received a copy of the GNU General Public License +# along with this program. If not, see . +# +# See 'README.md' for more information. +# +*/ + +#include "toolbar.h" +#include "GUI/global.h" +#include "appsupport.h" + +#include + +Friction::Ui::ToolBar::ToolBar(const QString &title, + QWidget *parent) + : QToolBar(title, parent) +{ + setup(); +} + +Friction::Ui::ToolBar::ToolBar(const QString &title, + const QString &objectName, + QWidget *parent) + : QToolBar(title, parent) +{ + setObjectName(objectName); + setup(); +} + +void Friction::Ui::ToolBar::setup() +{ +#ifdef Q_OS_MAC + mToolbar->setStyleSheet(QString("font-size: %1pt;").arg(font().pointSize())); +#endif + + if (objectName().isEmpty()) { + setObjectName(windowTitle().replace(" ", "").simplified()); + } + + setMovable(AppSupport::getSettings("ui", + QString("ToolBarMovable_%1").arg(objectName()), + false).toBool()); + setFocusPolicy(Qt::NoFocus); + + setToolButtonStyle(Qt::ToolButtonTextBesideIcon); + connect(this, &QToolBar::orientationChanged, + this, [this]() { + setToolButtonStyle(orientation() == Qt::Horizontal ? + Qt::ToolButtonTextBesideIcon : + Qt::ToolButtonIconOnly); + }); + + setContextMenuPolicy(Qt::CustomContextMenu); + connect(this, &QWidget::customContextMenuRequested, + this, &ToolBar::showContextMenu); + + eSizesUI::widget.add(this, [this](const int size) { + this->setIconSize({size, size}); + }); +} + +void Friction::Ui::ToolBar::showContextMenu(const QPoint &pos) +{ + QMenu menu(this); + + const auto act = menu.addAction(QIcon::fromTheme("window"), windowTitle()); + act->setEnabled(false); + menu.addSeparator(); + + menu.addAction(QIcon::fromTheme(isMovable() ? "locked" : "unlocked"), + tr(isMovable() ? "Lock" : "Unlock"), + this, [this]() { + setMovable(!isMovable()); + AppSupport::setSettings("ui", + QString("ToolBarMovable_%1").arg(objectName()), + isMovable()); + }); + + menu.exec(mapToGlobal(pos)); +} + +QAction *Friction::Ui::ToolBar::addSpacer(QWidget *widget) +{ + if (!widget) { return nullptr; } + widget->setSizePolicy(QSizePolicy::Expanding, + QSizePolicy::Minimum); + return addWidget(widget); +} diff --git a/src/ui/widgets/toolbar.h b/src/ui/widgets/toolbar.h index 2535d3320..983801b11 100644 --- a/src/ui/widgets/toolbar.h +++ b/src/ui/widgets/toolbar.h @@ -27,6 +27,7 @@ #include "ui_global.h" #include +#include namespace Friction { @@ -35,16 +36,15 @@ namespace Friction class UI_EXPORT ToolBar : public QToolBar { public: - explicit ToolBar(QWidget *parent = nullptr) - : QToolBar(parent) { - setToolButtonStyle(Qt::ToolButtonTextBesideIcon); - connect(this, &QToolBar::orientationChanged, - this, [this]() { - setToolButtonStyle(orientation() == Qt::Horizontal ? - Qt::ToolButtonTextBesideIcon : - Qt::ToolButtonIconOnly); - }); - } + explicit ToolBar(const QString &title, + QWidget *parent = nullptr); + explicit ToolBar(const QString &title, + const QString &objectName, + QWidget *parent = nullptr); + private: + void setup(); + void showContextMenu(const QPoint &pos); + QAction* addSpacer(QWidget *widget); }; } } diff --git a/src/ui/widgets/welcomedialog.cpp b/src/ui/widgets/welcomedialog.cpp index 8f3672d9c..40dbef6c0 100644 --- a/src/ui/widgets/welcomedialog.cpp +++ b/src/ui/widgets/welcomedialog.cpp @@ -71,7 +71,7 @@ WelcomeDialog::WelcomeDialog(QMenu *recentMenu, const auto buttonLay = new QHBoxLayout(buttonWid); buttonLay->setMargin(0); - const auto newButton = new QPushButton(QIcon::fromTheme("file_new"), + const auto newButton = new QPushButton(QIcon::fromTheme("file_blank"), tr("New"), this); newButton->setFocusPolicy(Qt::NoFocus); From 0717eadbcd1e104675a02392a202b53b8b178c82 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Ole-Andr=C3=A9=20Rodlie?= Date: Fri, 8 Nov 2024 16:32:02 +0100 Subject: [PATCH 2/6] VLabel: support orientation --- src/ui/widgets/vlabel.h | 30 +++++++++++++++++++++++++----- 1 file changed, 25 insertions(+), 5 deletions(-) diff --git a/src/ui/widgets/vlabel.h b/src/ui/widgets/vlabel.h index 65c8c5292..f4d33bb3a 100644 --- a/src/ui/widgets/vlabel.h +++ b/src/ui/widgets/vlabel.h @@ -35,29 +35,49 @@ class UI_EXPORT VLabel : public QLabel Q_OBJECT public: - explicit VLabel(QWidget *parent = nullptr) - : QLabel(parent) {} + explicit VLabel(QWidget *parent = nullptr, + const Qt::Orientation &orientation = Qt::Vertical) + : QLabel(parent) + , mOrientation(orientation) + {} explicit VLabel(const QString &text, - QWidget *parent = nullptr) - : QLabel(text, parent) {} + QWidget *parent = nullptr, + const Qt::Orientation &orientation = Qt::Vertical) + : QLabel(text, parent) + , mOrientation(orientation) + {} + void setOrientation(Qt::Orientation orientation) + { + mOrientation = orientation; + update(); + } protected: - void paintEvent(QPaintEvent*) + void paintEvent(QPaintEvent *e) { + if (mOrientation == Qt::Horizontal) { + QLabel::paintEvent(e); + return; + } QStylePainter painter(this); painter.rotate(90); painter.drawText(0, -(sizeHint().width() / 2)-2, text()); } QSize sizeHint() const { + if (mOrientation == Qt::Horizontal) { return QLabel::sizeHint(); } const auto s = QLabel::sizeHint(); return QSize(s.height(), s.width()); } QSize minimumSizeHint() const { + if (mOrientation == Qt::Horizontal) { return QLabel::minimumSizeHint(); } const auto s = QLabel::minimumSizeHint(); return QSize(s.height(), s.width()); } + +private: + Qt::Orientation mOrientation; }; #endif // VLABEL_H From c648e50ac9b893d717a84a0d6e86728468718e74 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Ole-Andr=C3=A9=20Rodlie?= Date: Fri, 8 Nov 2024 16:33:14 +0100 Subject: [PATCH 3/6] ToolBar: support icons-only mode --- src/ui/widgets/toolbar.cpp | 11 ++++++++--- src/ui/widgets/toolbar.h | 8 ++++++-- 2 files changed, 14 insertions(+), 5 deletions(-) diff --git a/src/ui/widgets/toolbar.cpp b/src/ui/widgets/toolbar.cpp index 0093e4437..a23452c01 100644 --- a/src/ui/widgets/toolbar.cpp +++ b/src/ui/widgets/toolbar.cpp @@ -28,16 +28,20 @@ #include Friction::Ui::ToolBar::ToolBar(const QString &title, - QWidget *parent) + QWidget *parent, + const bool &iconsOnly) : QToolBar(title, parent) + , mIconsOnly(iconsOnly) { setup(); } Friction::Ui::ToolBar::ToolBar(const QString &title, const QString &objectName, - QWidget *parent) + QWidget *parent, + const bool iconsOnly) : QToolBar(title, parent) + , mIconsOnly(iconsOnly) { setObjectName(objectName); setup(); @@ -58,9 +62,10 @@ void Friction::Ui::ToolBar::setup() false).toBool()); setFocusPolicy(Qt::NoFocus); - setToolButtonStyle(Qt::ToolButtonTextBesideIcon); + setToolButtonStyle(mIconsOnly ? Qt::ToolButtonIconOnly : Qt::ToolButtonTextBesideIcon); connect(this, &QToolBar::orientationChanged, this, [this]() { + if (mIconsOnly) { return; } setToolButtonStyle(orientation() == Qt::Horizontal ? Qt::ToolButtonTextBesideIcon : Qt::ToolButtonIconOnly); diff --git a/src/ui/widgets/toolbar.h b/src/ui/widgets/toolbar.h index 983801b11..9d5fa0b4d 100644 --- a/src/ui/widgets/toolbar.h +++ b/src/ui/widgets/toolbar.h @@ -35,13 +35,17 @@ namespace Friction { class UI_EXPORT ToolBar : public QToolBar { + Q_OBJECT public: explicit ToolBar(const QString &title, - QWidget *parent = nullptr); + QWidget *parent = nullptr, + const bool &iconsOnly = false); explicit ToolBar(const QString &title, const QString &objectName, - QWidget *parent = nullptr); + QWidget *parent = nullptr, + const bool iconsOnly = false); private: + bool mIconsOnly; void setup(); void showContextMenu(const QPoint &pos); QAction* addSpacer(QWidget *widget); From cd1f6706c260e7868c16c590422fd6b9e7f86dce Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Ole-Andr=C3=A9=20Rodlie?= Date: Fri, 8 Nov 2024 19:43:44 +0100 Subject: [PATCH 4/6] ToolBar: support show/hide actions with state --- src/ui/widgets/toolbar.cpp | 86 +++++++++++++++++++++++++++++++------- src/ui/widgets/toolbar.h | 4 ++ 2 files changed, 76 insertions(+), 14 deletions(-) diff --git a/src/ui/widgets/toolbar.cpp b/src/ui/widgets/toolbar.cpp index a23452c01..3c8d07cd3 100644 --- a/src/ui/widgets/toolbar.cpp +++ b/src/ui/widgets/toolbar.cpp @@ -27,19 +27,21 @@ #include -Friction::Ui::ToolBar::ToolBar(const QString &title, - QWidget *parent, - const bool &iconsOnly) +using namespace Friction::Ui; + +ToolBar::ToolBar(const QString &title, + QWidget *parent, + const bool &iconsOnly) : QToolBar(title, parent) , mIconsOnly(iconsOnly) { setup(); } -Friction::Ui::ToolBar::ToolBar(const QString &title, - const QString &objectName, - QWidget *parent, - const bool iconsOnly) +ToolBar::ToolBar(const QString &title, + const QString &objectName, + QWidget *parent, + const bool iconsOnly) : QToolBar(title, parent) , mIconsOnly(iconsOnly) { @@ -47,7 +49,20 @@ Friction::Ui::ToolBar::ToolBar(const QString &title, setup(); } -void Friction::Ui::ToolBar::setup() +void ToolBar::updateActions() +{ + const auto disabled = AppSupport::getSettings("ui", + QString("ToolBarActionsDisabled_%1") + .arg(objectName())).toStringList(); + for (const auto &act : actions()) { + if (act->objectName().isEmpty()) { continue; } + if (disabled.contains(act->objectName())) { + act->setVisible(false); + } + } +} + +void ToolBar::setup() { #ifdef Q_OS_MAC mToolbar->setStyleSheet(QString("font-size: %1pt;").arg(font().pointSize())); @@ -80,13 +95,14 @@ void Friction::Ui::ToolBar::setup() }); } -void Friction::Ui::ToolBar::showContextMenu(const QPoint &pos) +void ToolBar::showContextMenu(const QPoint &pos) { QMenu menu(this); - - const auto act = menu.addAction(QIcon::fromTheme("window"), windowTitle()); - act->setEnabled(false); - menu.addSeparator(); + { + const auto act = menu.addAction(QIcon::fromTheme("window"), windowTitle()); + act->setEnabled(false); + menu.addSeparator(); + } menu.addAction(QIcon::fromTheme(isMovable() ? "locked" : "unlocked"), tr(isMovable() ? "Lock" : "Unlock"), @@ -97,13 +113,55 @@ void Friction::Ui::ToolBar::showContextMenu(const QPoint &pos) isMovable()); }); + const auto disabled = AppSupport::getSettings("ui", + QString("ToolBarActionsDisabled_%1") + .arg(objectName())).toStringList(); + const auto acts = actions(); + if (acts.count() > 0) { menu.addSeparator(); } + + for (const auto &act : acts) { + if (act->objectName().isEmpty()) { continue; } + const auto mAct = menu.addAction(act->text()); + mAct->setCheckable(true); + mAct->setData(act->objectName()); + mAct->setChecked(!disabled.contains(act->objectName())); + connect(mAct, &QAction::triggered, + this, [this, mAct](bool checked) { + setEnableAction(mAct->data().toString(), checked); + }); + } + menu.exec(mapToGlobal(pos)); } -QAction *Friction::Ui::ToolBar::addSpacer(QWidget *widget) +QAction* ToolBar::addSpacer(QWidget *widget) { if (!widget) { return nullptr; } widget->setSizePolicy(QSizePolicy::Expanding, QSizePolicy::Minimum); return addWidget(widget); } + +void ToolBar::setEnableAction(const QString &title, + const bool &enable) +{ + for (const auto &act : actions()) { + if (act->objectName().isEmpty()) { continue; } + if (act->objectName() == title) { + act->setVisible(enable); + QStringList disabled = AppSupport::getSettings("ui", + QString("ToolBarActionsDisabled_%1") + .arg(objectName())).toStringList(); + if (enable && disabled.contains(title)) { + disabled.removeAll(title); + } else if (!enable && !disabled.contains(title)) { + disabled << title; + } else { break; } + AppSupport::setSettings("ui", + QString("ToolBarActionsDisabled_%1").arg(objectName()), + disabled, + false); + break; + } + } +} diff --git a/src/ui/widgets/toolbar.h b/src/ui/widgets/toolbar.h index 9d5fa0b4d..d6fbcc33d 100644 --- a/src/ui/widgets/toolbar.h +++ b/src/ui/widgets/toolbar.h @@ -44,11 +44,15 @@ namespace Friction const QString &objectName, QWidget *parent = nullptr, const bool iconsOnly = false); + void updateActions(); + private: bool mIconsOnly; void setup(); void showContextMenu(const QPoint &pos); QAction* addSpacer(QWidget *widget); + void setEnableAction(const QString &title, + const bool &enable); }; } } From 3d8b0ba5d39e01e40a60cdd6ef9c3d1208edec1c Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Ole-Andr=C3=A9=20Rodlie?= Date: Fri, 8 Nov 2024 22:08:21 +0100 Subject: [PATCH 5/6] ToolBar: support labels on/off --- src/ui/widgets/toolbar.cpp | 20 ++++++++++++++++++++ 1 file changed, 20 insertions(+) diff --git a/src/ui/widgets/toolbar.cpp b/src/ui/widgets/toolbar.cpp index 3c8d07cd3..7e8f726c2 100644 --- a/src/ui/widgets/toolbar.cpp +++ b/src/ui/widgets/toolbar.cpp @@ -72,6 +72,9 @@ void ToolBar::setup() setObjectName(windowTitle().replace(" ", "").simplified()); } + mIconsOnly = AppSupport::getSettings("ui", + QString("ToolBarIconsOnly_%1").arg(objectName()), + mIconsOnly).toBool(); setMovable(AppSupport::getSettings("ui", QString("ToolBarMovable_%1").arg(objectName()), false).toBool()); @@ -113,6 +116,23 @@ void ToolBar::showContextMenu(const QPoint &pos) isMovable()); }); + { + const auto act = menu.addAction(tr("Labels")); + act->setCheckable(true); + act->setChecked(!mIconsOnly); + connect(act, &QAction::triggered, + this, [this](bool checked) { + mIconsOnly = !checked; + setToolButtonStyle(mIconsOnly ? + Qt::ToolButtonIconOnly : + Qt::ToolButtonTextBesideIcon); + update(); + AppSupport::setSettings("ui", + QString("ToolBarIconsOnly_%1").arg(objectName()), + mIconsOnly); + }); + } + const auto disabled = AppSupport::getSettings("ui", QString("ToolBarActionsDisabled_%1") .arg(objectName())).toStringList(); From 6d9721862850256e021b510a15fadc52260d748b Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Ole-Andr=C3=A9=20Rodlie?= Date: Fri, 8 Nov 2024 22:11:19 +0100 Subject: [PATCH 6/6] UI: adapt to new ToolBar --- .../GUI/Settings/generalsettingswidget.cpp | 72 ----- src/app/GUI/Settings/generalsettingswidget.h | 11 - src/app/GUI/mainwindow.cpp | 71 ++-- src/app/GUI/mainwindow.h | 16 +- src/app/GUI/toolbox.cpp | 302 ++++++++++-------- src/app/friction.qss | 13 +- src/core/Private/esettings.cpp | 12 +- src/core/Private/esettings.h | 9 - 8 files changed, 227 insertions(+), 279 deletions(-) diff --git a/src/app/GUI/Settings/generalsettingswidget.cpp b/src/app/GUI/Settings/generalsettingswidget.cpp index c3c731eac..79d62ac11 100644 --- a/src/app/GUI/Settings/generalsettingswidget.cpp +++ b/src/app/GUI/Settings/generalsettingswidget.cpp @@ -43,14 +43,6 @@ GeneralSettingsWidget::GeneralSettingsWidget(QWidget *parent) , mDefaultInterfaceScaling(nullptr) , mInterfaceScaling(nullptr) , mImportFileDir(nullptr) - , mToolBarActionNew(nullptr) - , mToolBarActionOpen(nullptr) - , mToolBarActionImport(nullptr) - , mToolBarActionSave(nullptr) - //, mToolBarActionScene(nullptr) - , mToolBarActionRender(nullptr) - , mToolBarActionPreview(nullptr) - , mToolBarActionExport(nullptr) { const auto mGeneralWidget = new QWidget(this); mGeneralWidget->setContentsMargins(0, 0, 0, 0); @@ -148,8 +140,6 @@ GeneralSettingsWidget::GeneralSettingsWidget(QWidget *parent) mProjectLayout->addSpacing(10); mProjectLayout->addWidget(mImportFileWidget); - setupToolBarWidgets(mGeneralLayout); - mGeneralLayout->addStretch(); addWidget(mGeneralWidget); @@ -177,15 +167,6 @@ void GeneralSettingsWidget::applySettings() mSett.fInterfaceScaling = mInterfaceScaling->value() * 0.01; mSett.fImportFileDirOpt = mImportFileDir->currentData().toInt(); - mSett.fToolBarActionNew = mToolBarActionNew->isChecked(); - mSett.fToolBarActionOpen = mToolBarActionOpen->isChecked(); - mSett.fToolBarActionImport = mToolBarActionImport->isChecked(); - mSett.fToolBarActionSave = mToolBarActionSave->isChecked(); - //mSett.fToolBarActionScene = mToolBarActionScene->isChecked(); - mSett.fToolBarActionRender = mToolBarActionRender->isChecked(); - mSett.fToolBarActionPreview = mToolBarActionPreview->isChecked(); - mSett.fToolBarActionExport = mToolBarActionExport->isChecked(); - //eSizesUI::font.updateSize(); //eSizesUI::widget.updateSize(); } @@ -208,15 +189,6 @@ void GeneralSettingsWidget::updateSettings(bool restore) mInterfaceScaling->setEnabled(!mDefaultInterfaceScaling->isChecked()); mInterfaceScaling->setValue(mDefaultInterfaceScaling->isChecked() ? 100 : 100 * mSett.fInterfaceScaling); - mToolBarActionNew->setChecked(mSett.fToolBarActionNew); - mToolBarActionOpen->setChecked(mSett.fToolBarActionOpen); - mToolBarActionImport->setChecked(mSett.fToolBarActionImport); - mToolBarActionSave->setChecked(mSett.fToolBarActionSave); - //mToolBarActionScene->setChecked(mSett.fToolBarActionScene); - mToolBarActionRender->setChecked(mSett.fToolBarActionRender); - mToolBarActionPreview->setChecked(mSett.fToolBarActionPreview); - mToolBarActionExport->setChecked(mSett.fToolBarActionExport); - for (int i = 0; i < mImportFileDir->count(); i++) { if (mImportFileDir->itemData(i).toInt() == mSett.fImportFileDirOpt) { mImportFileDir->setCurrentIndex(i); @@ -224,47 +196,3 @@ void GeneralSettingsWidget::updateSettings(bool restore) } } } - -void GeneralSettingsWidget::setupToolBarWidgets(QVBoxLayout *lay) -{ - if (!lay) { return; } - - const auto area = new QScrollArea(this); - const auto container = new QGroupBox(this); - container->setObjectName("BlueBox"); - const auto containerLayout = new QVBoxLayout(container); - const auto containerInner = new QWidget(this); - const auto containerInnerLayout = new TwoColumnLayout(); - containerInner->setLayout(containerInnerLayout); - - area->setWidget(containerInner); - area->setWidgetResizable(true); - area->setContentsMargins(0, 0, 0, 0); - area->setFrameShape(QFrame::NoFrame); - - container->setTitle(tr("Toolbar Actions")); - - container->setContentsMargins(0, 0, 0, 0); - - containerInnerLayout->setMargin(5); - //containerLayout->setMargin(0); - - containerLayout->addWidget(area); - - mToolBarActionNew = new QCheckBox(tr("New"), this); - mToolBarActionOpen = new QCheckBox(tr("Open"), this); - mToolBarActionImport = new QCheckBox(tr("Import"), this); - mToolBarActionSave = new QCheckBox(tr("Save"), this); - //mToolBarActionScene = new QCheckBox(tr("Scene"), this); - mToolBarActionRender = new QCheckBox(tr("Render"), this); - mToolBarActionPreview = new QCheckBox(tr("Preview SVG"), this); - mToolBarActionExport = new QCheckBox(tr("Export SVG"), this); - - containerInnerLayout->addPair(mToolBarActionNew, mToolBarActionOpen); - containerInnerLayout->addPair(mToolBarActionImport, mToolBarActionSave); - containerInnerLayout->addPair(mToolBarActionRender, mToolBarActionPreview); - containerInnerLayout->addWidgetToFirstColumn(mToolBarActionExport); - containerLayout->addStretch(); - - lay->addWidget(container); -} diff --git a/src/app/GUI/Settings/generalsettingswidget.h b/src/app/GUI/Settings/generalsettingswidget.h index 0ef0109d8..6686a5563 100644 --- a/src/app/GUI/Settings/generalsettingswidget.h +++ b/src/app/GUI/Settings/generalsettingswidget.h @@ -48,17 +48,6 @@ class GeneralSettingsWidget : public SettingsWidget QSlider *mInterfaceScaling; QComboBox *mImportFileDir; - - QCheckBox *mToolBarActionNew; - QCheckBox *mToolBarActionOpen; - QCheckBox *mToolBarActionImport; - QCheckBox *mToolBarActionSave; - //QCheckBox *mToolBarActionScene; - QCheckBox *mToolBarActionRender; - QCheckBox *mToolBarActionPreview; - QCheckBox *mToolBarActionExport; - - void setupToolBarWidgets(QVBoxLayout *lay); }; #endif // GENERALSETTINGSWIDGET_H diff --git a/src/app/GUI/mainwindow.cpp b/src/app/GUI/mainwindow.cpp index 92f771a5a..7ee721b77 100644 --- a/src/app/GUI/mainwindow.cpp +++ b/src/app/GUI/mainwindow.cpp @@ -102,8 +102,6 @@ MainWindow::MainWindow(Document& document, , mToolBoxGroupMain(nullptr) , mToolBoxGroupNodes(nullptr) , mToolBoxMain(nullptr) - , mToolBoxNodes(nullptr) - , mToolBoxDraw(nullptr) , mUI(nullptr) , mSaveAct(nullptr) , mSaveAsAct(nullptr) @@ -124,11 +122,19 @@ MainWindow::MainWindow(Document& document, , mViewFullScreenAct(nullptr) , mLocalPivotAct(nullptr) , mNodeVisibility(nullptr) + , mNodeVisibilityAct(nullptr) , mFontWidget(nullptr) , mFontWidgetAct(nullptr) , mDrawPathAuto(nullptr) , mDrawPathSmooth(nullptr) , mDrawPathMaxError(nullptr) + , mToolBoxDrawActLabel1(nullptr) + , mToolBoxDrawActLabel2(nullptr) + , mToolBoxDrawActIcon1(nullptr) + , mToolBoxDrawActIcon2(nullptr) + , mToolBoxDrawActMaxError(nullptr) + , mToolBoxDrawActSmooth(nullptr) + , mToolBoxDrawActSep(nullptr) , mDocument(document) , mActions(actions) , mAudioHandler(audioHandler) @@ -393,15 +399,17 @@ void MainWindow::setupMenuBar() this, &MainWindow::newFile, Qt::CTRL + Qt::Key_N); newAct->setData(tr("New Project")); + newAct->setObjectName("NewProjectAct"); + cmdAddAction(newAct); - if (eSettings::instance().fToolBarActionNew) { - mToolbar->addAction(newAct); - } + const auto openAct = mFileMenu->addAction(QIcon::fromTheme("file_folder"), tr("Open", "MenuBar_File"), this, qOverload<>(&MainWindow::openFile), Qt::CTRL + Qt::Key_O); openAct->setData(tr("Open Project")); + openAct->setObjectName("OpenProjectAct"); + cmdAddAction(openAct); mRecentMenu = mFileMenu->addMenu(QIcon::fromTheme("file_folder"), tr("Open Recent", "MenuBar_File")); @@ -412,6 +420,8 @@ void MainWindow::setupMenuBar() Qt::CTRL + Qt::Key_L); mLinkedAct->setEnabled(false); mLinkedAct->setData(tr("Link File")); + mLinkedAct->setObjectName("LinkFileAct"); + cmdAddAction(mLinkedAct); mImportAct = mFileMenu->addAction(QIcon::fromTheme("file_import"), @@ -419,6 +429,7 @@ void MainWindow::setupMenuBar() this, qOverload<>(&MainWindow::importFile), Qt::CTRL + Qt::Key_I); mImportAct->setEnabled(false); + mImportAct->setObjectName("ImportFileAct"); cmdAddAction(mImportAct); mImportSeqAct = mFileMenu->addAction(QIcon::fromTheme("renderlayers"), @@ -427,10 +438,6 @@ void MainWindow::setupMenuBar() mImportSeqAct->setEnabled(false); cmdAddAction(mImportSeqAct); - if (eSettings::instance().fToolBarActionOpen) { - mToolbar->addAction(openAct); - } - mRevertAct = mFileMenu->addAction(QIcon::fromTheme("loop_back"), tr("Revert", "MenuBar_File"), this, &MainWindow::revert); @@ -446,6 +453,7 @@ void MainWindow::setupMenuBar() Qt::CTRL + Qt::Key_S); mSaveAct->setEnabled(false); mSaveAct->setData(tr("Save Project")); + mSaveAct->setObjectName("SaveProjectAct"); cmdAddAction(mSaveAct); mSaveAsAct = mFileMenu->addAction(QIcon::fromTheme("disk_drive"), @@ -472,6 +480,7 @@ void MainWindow::setupMenuBar() mPreviewSVGAct->setEnabled(false); mPreviewSVGAct->setToolTip(tr("Preview SVG Animation in Web Browser")); mPreviewSVGAct->setData(mPreviewSVGAct->toolTip()); + mPreviewSVGAct->setObjectName("PreviewSVGAct"); cmdAddAction(mPreviewSVGAct); mExportSVGAct = mFileMenu->addAction(QIcon::fromTheme("output"), @@ -483,16 +492,9 @@ void MainWindow::setupMenuBar() mExportSVGAct->setEnabled(false); mExportSVGAct->setToolTip(tr("Export SVG Animation for the Web")); mExportSVGAct->setData(mExportSVGAct->toolTip()); + mExportSVGAct->setObjectName("ExportSVGAct"); cmdAddAction(mExportSVGAct); - if (eSettings::instance().fToolBarActionSave) { - mToolbar->addAction(mSaveAct); - } - - if (eSettings::instance().fToolBarActionImport) { - mToolbar->addAction(mImportAct); - } - mFileMenu->addSeparator(); mCloseProjectAct = mFileMenu->addAction(QIcon::fromTheme("dialog-cancel"), tr("Close", "MenuBar_File"), @@ -1084,20 +1086,23 @@ void MainWindow::setupMenuBar() tr("Reinstall default render profiles"), this, &MainWindow::askInstallRenderPresets); - if (eSettings::instance().fToolBarActionRender) { - mRenderVideoAct = mToolbar->addAction(QIcon::fromTheme("render_animation"), - tr("Render"), - this, &MainWindow::openRendererWindow); - mRenderVideoAct->setEnabled(false); - } - if (eSettings::instance().fToolBarActionPreview) { - mToolbar->addAction(mPreviewSVGAct); - } + // toolbar actions + mToolbar->addAction(newAct); + mToolbar->addAction(openAct); + mToolbar->addAction(mSaveAct); + mToolbar->addAction(mImportAct); + mToolbar->addAction(mLinkedAct); - if (eSettings::instance().fToolBarActionExport) { - mToolbar->addAction(mExportSVGAct); - } + mRenderVideoAct = mToolbar->addAction(QIcon::fromTheme("render_animation"), + tr("Render"), + this, &MainWindow::openRendererWindow); + mRenderVideoAct->setEnabled(false); + mRenderVideoAct->setObjectName("RenderVideoAct"); + + mToolbar->addAction(mPreviewSVGAct); + mToolbar->addAction(mExportSVGAct); + mToolbar->updateActions(); setMenuBar(mMenuBar); @@ -1348,7 +1353,7 @@ void MainWindow::updateSettingsForCurrentCanvas(Canvas* const scene) void MainWindow::setupToolBar() { - mToolbar = new Ui::ToolBar(tr("Main Toolbar"), + mToolbar = new Ui::ToolBar(tr("Toolbar"), "MainToolBar", this); addToolBar(Qt::TopToolBarArea, mToolbar); @@ -1367,10 +1372,8 @@ void MainWindow::updateCanvasModeButtonsChecked() const bool pointMode = mode == CanvasMode::pointTransform; const bool drawMode = mode == CanvasMode::drawPath; - mToolBoxNodes->setEnabled(pointMode); - mToolBoxNodes->setVisible(pointMode); - mToolBoxDraw->setEnabled(drawMode); - mToolBoxDraw->setVisible(drawMode); + setEnableToolBoxNodes(pointMode); + setEnableToolBoxDraw(drawMode); mLocalPivotAct->setEnabled(pointMode || boxMode); if (mColorPickLabel) { diff --git a/src/app/GUI/mainwindow.h b/src/app/GUI/mainwindow.h index b55b056ee..33b6209a8 100644 --- a/src/app/GUI/mainwindow.h +++ b/src/app/GUI/mainwindow.h @@ -226,9 +226,7 @@ class MainWindow : public QMainWindow QActionGroup *mToolBoxGroupMain; QActionGroup *mToolBoxGroupNodes; - QToolBar *mToolBoxMain; - QToolBar *mToolBoxNodes; - QToolBar *mToolBoxDraw; + Friction::Ui::ToolBar *mToolBoxMain; UILayout *mUI; @@ -281,6 +279,7 @@ class MainWindow : public QMainWindow QAction *mLocalPivotAct; QToolButton *mNodeVisibility; + QAction *mNodeVisibilityAct; Friction::Ui::FontsWidget *mFontWidget; QAction* mFontWidgetAct; @@ -289,6 +288,14 @@ class MainWindow : public QMainWindow QDoubleSlider *mDrawPathSmooth; QDoubleSlider *mDrawPathMaxError; + QAction *mToolBoxDrawActLabel1; + QAction *mToolBoxDrawActLabel2; + QAction *mToolBoxDrawActIcon1; + QAction *mToolBoxDrawActIcon2; + QAction *mToolBoxDrawActMaxError; + QAction *mToolBoxDrawActSmooth; + QAction *mToolBoxDrawActSep; + QMenuBar *mMenuBar; QMenu *mFileMenu; QMenu *mRecentMenu; @@ -356,6 +363,9 @@ class MainWindow : public QMainWindow void setupToolBoxNodes(); void setupToolBoxDraw(); + void setEnableToolBoxNodes(const bool &enable); + void setEnableToolBoxDraw(const bool &enable); + bool mBackupOnSave; bool mAutoSave; int mAutoSaveTimeout; diff --git a/src/app/GUI/toolbox.cpp b/src/app/GUI/toolbox.cpp index 7cd6af479..6f695fe1d 100644 --- a/src/app/GUI/toolbox.cpp +++ b/src/app/GUI/toolbox.cpp @@ -25,6 +25,9 @@ #include "appsupport.h" #include "widgets/vlabel.h" +#include "widgets/toolbar.h" + +using namespace Friction; void MainWindow::setupToolBox() { @@ -32,23 +35,16 @@ void MainWindow::setupToolBox() setupToolBoxNodes(); setupToolBoxDraw(); - eSizesUI::widget.add(mToolBoxMain, [this](const int size) { - mToolBoxMain->setIconSize(QSize(size, size)); - mToolBoxNodes->setIconSize(QSize(size, size)); - mToolBoxDraw->setIconSize(QSize(size, size)); - }); - // set default mDocument.setCanvasMode(CanvasMode::boxTransform); } void MainWindow::setupToolBoxMain() { - mToolBoxMain = new QToolBar(this); - mToolBoxMain->setObjectName("ToolBoxMain"); - mToolBoxMain->setWindowTitle(tr("ToolBox Main")); - mToolBoxMain->setMovable(false); - mToolBoxMain->setOrientation(Qt::Vertical); + mToolBoxMain = new Ui::ToolBar(tr("ToolBox"), + "ToolBoxMain", + this, + true); mToolBoxGroupMain = new QActionGroup(this); @@ -64,16 +60,16 @@ void MainWindow::setupToolBoxMain() &QAction::triggered, this, [boxTransformAct, this]() { - if (boxTransformAct->isChecked()) { mActions.setMovePathMode(); } - }); + if (boxTransformAct->isChecked()) { mActions.setMovePathMode(); } + }); connect(&mDocument, &Document::canvasModeSet, this, [this, boxTransformAct]() { - if (mDocument.fCanvasMode == CanvasMode::boxTransform) { - boxTransformAct->setChecked(true); - } - }); + if (mDocument.fCanvasMode == CanvasMode::boxTransform) { + boxTransformAct->setChecked(true); + } + }); boxTransformAct->setChecked(true); // default mToolBoxGroupMain->addAction(boxTransformAct); @@ -89,16 +85,16 @@ void MainWindow::setupToolBoxMain() &QAction::triggered, this, [pointTransformAct, this]() { - if (pointTransformAct->isChecked()) { mActions.setMovePointMode(); } - }); + if (pointTransformAct->isChecked()) { mActions.setMovePointMode(); } + }); connect(&mDocument, &Document::canvasModeSet, this, [this, pointTransformAct]() { - if (mDocument.fCanvasMode == CanvasMode::pointTransform) { - pointTransformAct->setChecked(true); - } - }); + if (mDocument.fCanvasMode == CanvasMode::pointTransform) { + pointTransformAct->setChecked(true); + } + }); mToolBoxGroupMain->addAction(pointTransformAct); // addPointMode @@ -113,16 +109,16 @@ void MainWindow::setupToolBoxMain() &QAction::triggered, this, [addPointModeAct, this]() { - if (addPointModeAct->isChecked()) { mActions.setAddPointMode(); } - }); + if (addPointModeAct->isChecked()) { mActions.setAddPointMode(); } + }); connect(&mDocument, &Document::canvasModeSet, this, [this, addPointModeAct]() { - if (mDocument.fCanvasMode == CanvasMode::pathCreate) { - addPointModeAct->setChecked(true); - } - }); + if (mDocument.fCanvasMode == CanvasMode::pathCreate) { + addPointModeAct->setChecked(true); + } + }); mToolBoxGroupMain->addAction(addPointModeAct); // drawPathMode @@ -137,16 +133,16 @@ void MainWindow::setupToolBoxMain() &QAction::triggered, this, [drawPathModeAct, this]() { - if (drawPathModeAct->isChecked()) { mActions.setDrawPathMode(); } - }); + if (drawPathModeAct->isChecked()) { mActions.setDrawPathMode(); } + }); connect(&mDocument, &Document::canvasModeSet, this, [this, drawPathModeAct]() { - if (mDocument.fCanvasMode == CanvasMode::drawPath) { - drawPathModeAct->setChecked(true); - } - }); + if (mDocument.fCanvasMode == CanvasMode::drawPath) { + drawPathModeAct->setChecked(true); + } + }); mToolBoxGroupMain->addAction(drawPathModeAct); // circleMode @@ -161,16 +157,16 @@ void MainWindow::setupToolBoxMain() &QAction::triggered, this, [circleModeAct, this]() { - if (circleModeAct->isChecked()) { mActions.setCircleMode(); } - }); + if (circleModeAct->isChecked()) { mActions.setCircleMode(); } + }); connect(&mDocument, &Document::canvasModeSet, this, [this, circleModeAct]() { - if (mDocument.fCanvasMode == CanvasMode::circleCreate) { - circleModeAct->setChecked(true); - } - }); + if (mDocument.fCanvasMode == CanvasMode::circleCreate) { + circleModeAct->setChecked(true); + } + }); mToolBoxGroupMain->addAction(circleModeAct); // rectangleMode @@ -185,16 +181,16 @@ void MainWindow::setupToolBoxMain() &QAction::triggered, this, [rectModeAct, this]() { - if (rectModeAct->isChecked()) { mActions.setRectangleMode(); } - }); + if (rectModeAct->isChecked()) { mActions.setRectangleMode(); } + }); connect(&mDocument, &Document::canvasModeSet, this, [this, rectModeAct]() { - if (mDocument.fCanvasMode == CanvasMode::rectCreate) { - rectModeAct->setChecked(true); - } - }); + if (mDocument.fCanvasMode == CanvasMode::rectCreate) { + rectModeAct->setChecked(true); + } + }); mToolBoxGroupMain->addAction(rectModeAct); // textMode @@ -210,17 +206,17 @@ void MainWindow::setupToolBoxMain() &QAction::triggered, this, [textModeAct, this]() { - if (textModeAct->isChecked()) { mActions.setTextMode(); } - }); + if (textModeAct->isChecked()) { mActions.setTextMode(); } + }); connect(&mDocument, &Document::canvasModeSet, this, [this, textModeAct]() { - if (mDocument.fCanvasMode == CanvasMode::textCreate) { - focusFontWidget(true); - textModeAct->setChecked(true); - } - }); + if (mDocument.fCanvasMode == CanvasMode::textCreate) { + focusFontWidget(true); + textModeAct->setChecked(true); + } + }); mToolBoxGroupMain->addAction(textModeAct); // nullMode @@ -235,16 +231,16 @@ void MainWindow::setupToolBoxMain() &QAction::triggered, this, [nullModeAct, this]() { - if (nullModeAct->isChecked()) { mActions.setNullMode(); } - }); + if (nullModeAct->isChecked()) { mActions.setNullMode(); } + }); connect(&mDocument, &Document::canvasModeSet, this, [this, nullModeAct]() { - if (mDocument.fCanvasMode == CanvasMode::nullCreate) { - nullModeAct->setChecked(true); - } - }); + if (mDocument.fCanvasMode == CanvasMode::nullCreate) { + nullModeAct->setChecked(true); + } + }); mToolBoxGroupMain->addAction(nullModeAct); // pickMode @@ -259,24 +255,24 @@ void MainWindow::setupToolBoxMain() &QAction::triggered, this, [pickModeAct, this]() { - if (pickModeAct->isChecked()) { mActions.setPickPaintSettingsMode(); } - }); + if (pickModeAct->isChecked()) { mActions.setPickPaintSettingsMode(); } + }); connect(&mDocument, &Document::canvasModeSet, this, [this, pickModeAct]() { - if (mDocument.fCanvasMode == CanvasMode::pickFillStroke || - mDocument.fCanvasMode == CanvasMode::pickFillStrokeEvent) { - pickModeAct->setChecked(true); - } - }); + if (mDocument.fCanvasMode == CanvasMode::pickFillStroke || + mDocument.fCanvasMode == CanvasMode::pickFillStrokeEvent) { + pickModeAct->setChecked(true); + } + }); mToolBoxGroupMain->addAction(pickModeAct); - mToolBoxMain->addActions(mToolBoxGroupMain->actions()); - // pivot - mLocalPivotAct = new QAction(mDocument.fLocalPivot ? QIcon::fromTheme("pivotLocal") : QIcon::fromTheme("pivotGlobal"), + mLocalPivotAct = new QAction(mDocument.fLocalPivot ? + QIcon::fromTheme("pivotLocal") : + QIcon::fromTheme("pivotGlobal"), tr("Pivot Global / Local"), this); mLocalPivotAct->setShortcut(QKeySequence(AppSupport::getSettings("shortcuts", @@ -284,28 +280,24 @@ void MainWindow::setupToolBoxMain() "P").toString())); connect(mLocalPivotAct, &QAction::triggered, this, [this]() { - mDocument.fLocalPivot = !mDocument.fLocalPivot; - for (const auto& scene : mDocument.fScenes) { scene->updatePivot(); } - Document::sInstance->actionFinished(); - mLocalPivotAct->setIcon(mDocument.fLocalPivot ? QIcon::fromTheme("pivotLocal") : QIcon::fromTheme("pivotGlobal")); - }); + mDocument.fLocalPivot = !mDocument.fLocalPivot; + for (const auto& scene : mDocument.fScenes) { scene->updatePivot(); } + Document::sInstance->actionFinished(); + mLocalPivotAct->setIcon(mDocument.fLocalPivot ? + QIcon::fromTheme("pivotLocal") : + QIcon::fromTheme("pivotGlobal")); + }); - mToolBoxMain->addAction(mLocalPivotAct); + mToolBoxGroupMain->addAction(mLocalPivotAct); + mToolBoxMain->addActions(mToolBoxGroupMain->actions()); addToolBar(Qt::LeftToolBarArea, mToolBoxMain); } void MainWindow::setupToolBoxNodes() { - mToolBoxNodes = new QToolBar(this); - mToolBoxNodes->setMovable(false); - mToolBoxNodes->setObjectName(QString::fromUtf8("ToolBoxNodes")); - mToolBoxNodes->setWindowTitle(tr("ToolBox Nodes")); - mToolBoxNodes->setOrientation(Qt::Vertical); - - mToolBoxNodes->addSeparator(); - mToolBoxGroupNodes = new QActionGroup(this); + mToolBoxGroupNodes->addAction(mToolBoxMain->addSeparator()); // nodeConnect mActionConnectPointsAct = new QAction(QIcon::fromTheme("nodeConnect"), @@ -388,8 +380,6 @@ void MainWindow::setupToolBoxNodes() this, [this]() { mActions.makeSegmentCurve(); }); mToolBoxGroupNodes->addAction(mActionCurveAct); - mToolBoxNodes->addActions(mToolBoxGroupNodes->actions()); - // nodeVisibility mNodeVisibility = new QToolButton(this); mNodeVisibility->setObjectName(QString::fromUtf8("ToolButton")); @@ -413,75 +403,125 @@ void MainWindow::setupToolBoxNodes() mNodeVisibility->setDefaultAction(nodeVisibilityAction1); connect(mNodeVisibility, &QToolButton::triggered, this, [this](QAction *act) { - qDebug() << "set node visibility" << act->data().toInt(); - mNodeVisibility->setDefaultAction(act); - mDocument.fNodeVisibility = static_cast(act->data().toInt()); - Document::sInstance->actionFinished(); - }); + mNodeVisibility->setDefaultAction(act); + mDocument.fNodeVisibility = static_cast(act->data().toInt()); + Document::sInstance->actionFinished(); + }); - mToolBoxNodes->addWidget(mNodeVisibility); + mToolBoxMain->addActions(mToolBoxGroupNodes->actions()); + mNodeVisibilityAct = mToolBoxMain->addWidget(mNodeVisibility); - addToolBar(Qt::LeftToolBarArea, mToolBoxNodes); + setEnableToolBoxNodes(false); } void MainWindow::setupToolBoxDraw() { mDocument.fDrawPathManual = false; - mDrawPathAuto = new QAction(mDocument.fDrawPathManual ? QIcon::fromTheme("drawPathAutoUnchecked") : QIcon::fromTheme("drawPathAutoChecked"), + mDrawPathAuto = new QAction(mDocument.fDrawPathManual ? + QIcon::fromTheme("drawPathAutoUnchecked") : + QIcon::fromTheme("drawPathAutoChecked"), tr("Automatic/Manual Fitting"), this); connect(mDrawPathAuto, &QAction::triggered, this, [this]() { - mDocument.fDrawPathManual = !mDocument.fDrawPathManual; - qDebug() << "manual fitting?" << mDocument.fDrawPathManual; - mDrawPathMaxError->setDisabled(mDocument.fDrawPathManual); - mDrawPathAuto->setIcon(mDocument.fDrawPathManual ? QIcon::fromTheme("drawPathAutoUnchecked") : QIcon::fromTheme("drawPathAutoChecked")); - }); + mDocument.fDrawPathManual = !mDocument.fDrawPathManual; + mDrawPathMaxError->setDisabled(mDocument.fDrawPathManual); + mDrawPathAuto->setIcon(mDocument.fDrawPathManual ? + QIcon::fromTheme("drawPathAutoUnchecked") : + QIcon::fromTheme("drawPathAutoChecked")); + }); mDrawPathMaxError = new QDoubleSlider(1, 200, 1, this, false); - mDrawPathMaxError->setSizePolicy(QSizePolicy::Minimum, QSizePolicy::Preferred); + mDrawPathMaxError->setSizePolicy(QSizePolicy::MinimumExpanding, + QSizePolicy::Preferred); mDrawPathMaxError->setNumberDecimals(0); - mDrawPathMaxError->setMinimumHeight(25); + mDrawPathMaxError->setMinimumSize({eSizesUI::widget, + eSizesUI::widget}); mDrawPathMaxError->setDisplayedValue(mDocument.fDrawPathMaxError); connect(mDrawPathMaxError, &QDoubleSlider::valueEdited, this, [this](const qreal value) { - mDocument.fDrawPathMaxError = qFloor(value); - }); + mDocument.fDrawPathMaxError = qFloor(value); + }); mDrawPathSmooth = new QDoubleSlider(1, 200, 1, this, false); - mDrawPathSmooth->setSizePolicy(QSizePolicy::Minimum, QSizePolicy::Preferred); - mDrawPathSmooth->setMinimumHeight(25); + mDrawPathSmooth->setSizePolicy(QSizePolicy::MinimumExpanding, + QSizePolicy::Preferred); mDrawPathSmooth->setNumberDecimals(0); + mDrawPathSmooth->setMinimumSize({eSizesUI::widget, + eSizesUI::widget}); mDrawPathSmooth->setDisplayedValue(mDocument.fDrawPathSmooth); connect(mDrawPathSmooth, &QDoubleSlider::valueEdited, this, [this](const qreal value) { - mDocument.fDrawPathSmooth = qFloor(value); - }); - - const auto label1 = new VLabel(tr("Max Error"), this); - const auto label2 = new VLabel(tr("Smooth"), this); - - mToolBoxDraw = new QToolBar(this); - mToolBoxDraw->setMovable(false); - mToolBoxDraw->setObjectName(QString::fromUtf8("ToolBoxDraw")); - mToolBoxDraw->setWindowTitle(tr("ToolBox Draw")); - mToolBoxDraw->setOrientation(Qt::Vertical); - - mToolBoxDraw->addSeparator(); - { - const auto act = mToolBoxDraw->addAction(QIcon::fromTheme("drawPath"), QString()); - act->setDisabled(true); - } - mToolBoxDraw->addWidget(label1); - mToolBoxDraw->addWidget(mDrawPathMaxError); - { - const auto act = mToolBoxDraw->addAction(QIcon::fromTheme("drawPath"), QString()); - act->setDisabled(true); + mDocument.fDrawPathSmooth = qFloor(value); + }); + + eSizesUI::widget.add(mDrawPathMaxError, [this](const int size) { + mDrawPathMaxError->setMinimumSize({size, size}); + mDrawPathSmooth->setMinimumSize({size, size}); + }); + + connect(mToolBoxMain, &QToolBar::orientationChanged, + this, [this](Qt::Orientation orientation) { + const auto policyH = orientation == Qt::Vertical ? + QSizePolicy::MinimumExpanding : + QSizePolicy::Preferred; + const auto policyV = orientation == Qt::Vertical ? + QSizePolicy::Preferred : + QSizePolicy::MinimumExpanding; + mDrawPathMaxError->setSizePolicy(policyH, policyV); + mDrawPathSmooth->setSizePolicy(policyH, policyV); + }); + + const auto label1 = new VLabel(QString("%1 ").arg(tr("Max Error")), + this, + mToolBoxMain->orientation()); + const auto label2 = new VLabel(QString("%1 ").arg(tr("Smooth")), + this, + mToolBoxMain->orientation()); + + connect(mToolBoxMain, &QToolBar::orientationChanged, + this, [label1, label2](Qt::Orientation orientation){ + label1->setOrientation(orientation); + label2->setOrientation(orientation); + }); + + mToolBoxDrawActSep = mToolBoxMain->addSeparator(); + + mToolBoxDrawActIcon1 = mToolBoxMain->addAction(QIcon::fromTheme("drawPath"), + QString()); + mToolBoxDrawActIcon1->setDisabled(true); + + mToolBoxDrawActLabel1 = mToolBoxMain->addWidget(label1); + mToolBoxDrawActMaxError = mToolBoxMain->addWidget(mDrawPathMaxError); + + mToolBoxDrawActIcon2 = mToolBoxMain->addAction(QIcon::fromTheme("drawPath"), + QString()); + mToolBoxDrawActIcon2->setDisabled(true); + + mToolBoxDrawActLabel2 = mToolBoxMain->addWidget(label2); + mToolBoxDrawActSmooth = mToolBoxMain->addWidget(mDrawPathSmooth); + mToolBoxMain->addAction(mDrawPathAuto); + + setEnableToolBoxDraw(false); +} + +void MainWindow::setEnableToolBoxNodes(const bool &enable) +{ + mToolBoxGroupNodes->setVisible(enable); + if (mNodeVisibilityAct) { + mNodeVisibilityAct->setVisible(enable); } - mToolBoxDraw->addWidget(label2); - mToolBoxDraw->addWidget(mDrawPathSmooth); - mToolBoxDraw->addAction(mDrawPathAuto); +} - addToolBar(Qt::LeftToolBarArea, mToolBoxDraw); +void MainWindow::setEnableToolBoxDraw(const bool &enable) +{ + if (mToolBoxDrawActSep) { mToolBoxDrawActSep->setVisible(enable); } + if (mToolBoxDrawActLabel1) { mToolBoxDrawActLabel1->setVisible(enable); } + if (mToolBoxDrawActLabel2) { mToolBoxDrawActLabel2->setVisible(enable); } + if (mToolBoxDrawActIcon1) { mToolBoxDrawActIcon1->setVisible(enable); } + if (mToolBoxDrawActIcon2) { mToolBoxDrawActIcon2->setVisible(enable); } + if (mToolBoxDrawActMaxError) { mToolBoxDrawActMaxError->setVisible(enable); } + if (mToolBoxDrawActSmooth) { mToolBoxDrawActSmooth->setVisible(enable); } + if (mDrawPathAuto) { mDrawPathAuto->setVisible(enable); } } diff --git a/src/app/friction.qss b/src/app/friction.qss index d9374dfbc..1c482a00b 100644 --- a/src/app/friction.qss +++ b/src/app/friction.qss @@ -583,21 +583,14 @@ QSlider::handle:horizontal:disabled { background: transparent; } -QToolBar#ToolBoxDraw::separator, -QToolBar#ToolBoxNodes::separator { +Friction--Ui--ToolBar::separator { background-color: %4; } -QToolBar#ToolBoxDraw::separator:vertical, -QToolBar#ToolBoxNodes::separator:vertical { +Friction--Ui--ToolBar::separator:vertical { height: 1px; } -QToolBar#ToolBoxDraw::separator:horizontal, -QToolBar#ToolBoxNodes::separator:horizontal { +Friction--Ui--ToolBar::separator:horizontal { width: 1px; } - -VLabel { - padding-right: 1px; -} diff --git a/src/core/Private/esettings.cpp b/src/core/Private/esettings.cpp index 7a57ed645..9fdff3133 100644 --- a/src/core/Private/esettings.cpp +++ b/src/core/Private/esettings.cpp @@ -196,15 +196,9 @@ eSettings::eSettings(const int cpuThreads, fDefaultInterfaceScaling, "defaultInterfaceScaling", true); - gSettings << std::make_shared(fImportFileDirOpt, "ImportFileDirOpt", ImportFileDirRecent); - gSettings << std::make_shared(fToolBarActionNew, "ToolBarActionNew", true); - gSettings << std::make_shared(fToolBarActionOpen, "ToolBarActionOpen", true); - gSettings << std::make_shared(fToolBarActionImport, "ToolBarActionImport", true); - gSettings << std::make_shared(fToolBarActionSave, "ToolBarActionSave", true); - gSettings << std::make_shared(fToolBarActionScene, "ToolBarActionScene", true); - gSettings << std::make_shared(fToolBarActionRender, "ToolBarActionRender", true); - gSettings << std::make_shared(fToolBarActionPreview, "ToolBarActionPreview", true); - gSettings << std::make_shared(fToolBarActionExport, "ToolBarActionExport", true); + gSettings << std::make_shared(fImportFileDirOpt, + "ImportFileDirOpt", + ImportFileDirRecent); gSettings << std::make_shared( fCanvasRtlSupport, diff --git a/src/core/Private/esettings.h b/src/core/Private/esettings.h index 95b957d49..797fde362 100644 --- a/src/core/Private/esettings.h +++ b/src/core/Private/esettings.h @@ -97,15 +97,6 @@ class CORE_EXPORT eSettings : public QObject int fImportFileDirOpt = ImportFileDirRecent; - bool fToolBarActionNew = true; - bool fToolBarActionOpen = true; - bool fToolBarActionImport = true; - bool fToolBarActionSave = true; - bool fToolBarActionScene = true; - bool fToolBarActionRender = true; - bool fToolBarActionPreview = true; - bool fToolBarActionExport = true; - bool fHddCache = true; QString fHddCacheFolder = ""; // "" - use system default temporary files folder intMB fHddCacheMBCap = intMB(0); // <= 0 - no cap