From e190cd3c5061c7d8484821780d089a851c0cc576 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Ole-Andr=C3=A9=20Rodlie?= Date: Sun, 19 Nov 2023 11:14:59 +0100 Subject: [PATCH] Interface scaling fixes --- .../GUI/ColorWidgets/colorsettingswidget.cpp | 7 ++- src/app/GUI/Dialogs/scenesettingsdialog.cpp | 6 ++ .../GUI/RenderWidgets/closablecontainer.cpp | 5 +- .../RenderWidgets/renderinstancewidget.cpp | 30 +++++++--- .../GUI/RenderWidgets/renderinstancewidget.h | 2 + src/app/GUI/RenderWidgets/renderwidget.cpp | 14 ++++- .../GUI/Settings/generalsettingswidget.cpp | 57 +++++++++++++++++++ src/app/GUI/Settings/generalsettingswidget.h | 3 + .../Settings/performancesettingswidget.cpp | 9 +++ .../GUI/Settings/pluginssettingswidget.cpp | 4 ++ src/app/GUI/Settings/presetsettingswidget.cpp | 13 +++++ src/app/GUI/Settings/settingsdialog.cpp | 7 +++ .../GUI/Settings/timelinesettingswidget.cpp | 9 +++ src/app/GUI/alignwidget.cpp | 6 +- src/app/GUI/assetswidget.cpp | 5 ++ src/app/GUI/fakemenubar.cpp | 11 ++-- src/app/GUI/fillstrokesettings.cpp | 15 +++++ src/app/GUI/fontswidget.cpp | 16 +++++- src/app/GUI/layouthandler.cpp | 14 +++-- src/app/GUI/mainwindow.cpp | 27 ++++++--- src/app/GUI/timelinedockwidget.cpp | 3 + src/app/GUI/timelinewidget.cpp | 2 +- src/app/main.cpp | 17 +++--- src/core/Private/esettings.cpp | 3 + src/core/Private/esettings.h | 1 + 25 files changed, 242 insertions(+), 44 deletions(-) diff --git a/src/app/GUI/ColorWidgets/colorsettingswidget.cpp b/src/app/GUI/ColorWidgets/colorsettingswidget.cpp index 3f2f1cfc5..22a7ef83f 100755 --- a/src/app/GUI/ColorWidgets/colorsettingswidget.cpp +++ b/src/app/GUI/ColorWidgets/colorsettingswidget.cpp @@ -282,7 +282,7 @@ ColorSettingsWidget::ColorSettingsWidget(QWidget *parent) : QWidget(parent) { // mWheelLayout->setAlignment(wheel_triangle_widget, Qt::AlignHCenter); - int spinWidth = 50; + int spinWidth = eSizesUI::widget * 3; rSpin->setFixedWidth(spinWidth); gSpin->setFixedWidth(spinWidth); bSpin->setFixedWidth(spinWidth); @@ -351,6 +351,11 @@ ColorSettingsWidget::ColorSettingsWidget(QWidget *parent) : QWidget(parent) { mPickingButton->setToolTip(tr("Pick Color")); connect(mPickingButton, &QPushButton::released, this, &ColorSettingsWidget::startColorPicking); + eSizesUI::widget.add(mPickingButton, [this](const int size) { + mPickingButton->setFixedHeight(size); + mPickingButton->setIconSize(QSize(size, size)); + }); + mColorLabelLayout->addWidget(mColorLabel); mColorLabelLayout->addWidget(mPickingButton); mWidgetsLayout->addLayout(mColorLabelLayout); diff --git a/src/app/GUI/Dialogs/scenesettingsdialog.cpp b/src/app/GUI/Dialogs/scenesettingsdialog.cpp index a98d7f767..38eaaabbf 100644 --- a/src/app/GUI/Dialogs/scenesettingsdialog.cpp +++ b/src/app/GUI/Dialogs/scenesettingsdialog.cpp @@ -28,6 +28,8 @@ #include "GUI/coloranimatorbutton.h" #include "appsupport.h" +#include "GUI/global.h" + SceneSettingsDialog::SceneSettingsDialog(Canvas * const canvas, QWidget * const parent) : SceneSettingsDialog(canvas->prp_getName(), @@ -103,6 +105,8 @@ SceneSettingsDialog::SceneSettingsDialog(const QString &name, mResToolButton->setIcon(QIcon::fromTheme("dots")); mResToolButton->setVisible(mEnableResolutionPresets); mResToolButton->setEnabled(mEnableResolutionPresets); + mResToolButton->setIconSize(QSize(eSizesUI::widget, eSizesUI::widget)); + mResToolButton->setFixedSize(QSize(eSizesUI::widget, eSizesUI::widget)); mSizeLayout = new QHBoxLayout(); mSizeLayout->addWidget(mWidthLabel); @@ -140,6 +144,8 @@ SceneSettingsDialog::SceneSettingsDialog(const QString &name, mFpsToolButton->setIcon(QIcon::fromTheme("dots")); mFpsToolButton->setVisible(mEnableFpsPresets); mFpsToolButton->setEnabled(mEnableFpsPresets); + mFpsToolButton->setIconSize(QSize(eSizesUI::widget, eSizesUI::widget)); + mFpsToolButton->setFixedSize(QSize(eSizesUI::widget, eSizesUI::widget)); mFPSLabel = new QLabel(tr("Fps"), this); mFPSSpinBox = new QDoubleSpinBox(this); diff --git a/src/app/GUI/RenderWidgets/closablecontainer.cpp b/src/app/GUI/RenderWidgets/closablecontainer.cpp index c077f0320..c1010e6b9 100755 --- a/src/app/GUI/RenderWidgets/closablecontainer.cpp +++ b/src/app/GUI/RenderWidgets/closablecontainer.cpp @@ -69,7 +69,10 @@ void ClosableContainer::setCheckable(const bool check) { if(check) { mCheckBox = new QCheckBox(this); mCheckBox->setFocusPolicy(Qt::NoFocus); - mCheckBox->setFixedSize(eSizesUI::widget, eSizesUI::widget); + eSizesUI::widget.add(mCheckBox, [this](const int size) { + mCheckBox->setFixedSize(QSize(size, size)); + mCheckBox->setStyleSheet(QString("QCheckBox::indicator { width: %1px; height: %1px;}").arg(size/1.5)); + }); mMainLayout->insertWidget(0, mCheckBox, 0, Qt::AlignTop); mCheckBox->setChecked(true); } else { diff --git a/src/app/GUI/RenderWidgets/renderinstancewidget.cpp b/src/app/GUI/RenderWidgets/renderinstancewidget.cpp index 14bafd06e..e112d756c 100755 --- a/src/app/GUI/RenderWidgets/renderinstancewidget.cpp +++ b/src/app/GUI/RenderWidgets/renderinstancewidget.cpp @@ -147,19 +147,19 @@ void RenderInstanceWidget::iniGUI() { this); mOutputDestinationButton->setFocusPolicy(Qt::NoFocus); mOutputDestinationButton->setToolTip(tr("Select output file")); - mOutputDestinationButton->setSizePolicy(QSizePolicy::Preferred, - QSizePolicy::Preferred); + //mOutputDestinationButton->setSizePolicy(QSizePolicy::Preferred, + // QSizePolicy::Preferred); connect(mOutputDestinationButton, &QPushButton::pressed, this, &RenderInstanceWidget::openOutputDestinationDialog); - const auto playButton = new QPushButton(QIcon::fromTheme("play"), + mPlayButton = new QPushButton(QIcon::fromTheme("play"), QString(), this); - playButton->setFocusPolicy(Qt::NoFocus); - playButton->setToolTip(tr("Open in default application")); - playButton->setSizePolicy(QSizePolicy::Preferred, - QSizePolicy::Preferred); - connect(playButton, &QPushButton::pressed, + mPlayButton->setFocusPolicy(Qt::NoFocus); + mPlayButton->setToolTip(tr("Open in default application")); + //mPlayButton->setSizePolicy(QSizePolicy::Preferred, + // QSizePolicy::Preferred); + connect(mPlayButton, &QPushButton::pressed, this, [this]() { QString dst = mOutputDestinationLineEdit->text(); if (QFile::exists(dst)) { @@ -175,13 +175,25 @@ void RenderInstanceWidget::iniGUI() { mOutputDestinationLineEdit->setPlaceholderText(tr("Destination ...")); mOutputDestinationLineEdit->setObjectName(QString::fromUtf8("OutputDestinationLineEdit")); + eSizesUI::widget.add(mOutputSettingsProfilesButton, [this](const int size) { + mRenderSettingsButton->setFixedHeight(size); + mOutputSettingsButton->setFixedHeight(size); + mOutputSettingsProfilesButton->setIconSize(QSize(size, size)); + mOutputSettingsProfilesButton->setFixedSize(QSize(size, size)); + mOutputDestinationButton->setIconSize(QSize(size, size)); + mOutputDestinationButton->setFixedSize(QSize(size, size)); + mPlayButton->setIconSize(QSize(size, size)); + mPlayButton->setFixedSize(QSize(size, size)); + mOutputDestinationLineEdit->setFixedHeight(size); + }); + QWidget *outputDestinationWidget = new QWidget(this); outputDestinationWidget->setContentsMargins(0, 0, 0, 0); const auto outputDesinationLayout = new QHBoxLayout(outputDestinationWidget); outputDesinationLayout->setMargin(0); outputDesinationLayout->addWidget(mOutputDestinationButton); - outputDesinationLayout->addWidget(playButton); + outputDesinationLayout->addWidget(mPlayButton); outputDesinationLayout->addWidget(mOutputDestinationLineEdit); outputSettingsLayout->addWidget(outputDestinationWidget); diff --git a/src/app/GUI/RenderWidgets/renderinstancewidget.h b/src/app/GUI/RenderWidgets/renderinstancewidget.h index 3e2456745..3aa451d83 100755 --- a/src/app/GUI/RenderWidgets/renderinstancewidget.h +++ b/src/app/GUI/RenderWidgets/renderinstancewidget.h @@ -79,6 +79,8 @@ class RenderInstanceWidget : public ClosableContainer { QLineEdit *mNameLabel; QVBoxLayout *mContentLayout = new QVBoxLayout(); RenderInstanceSettings mSettings; + QPushButton *mPlayButton; + signals: void duplicate(RenderInstanceSettings&); protected: diff --git a/src/app/GUI/RenderWidgets/renderwidget.cpp b/src/app/GUI/RenderWidgets/renderwidget.cpp index 312b20c8d..da6e17375 100755 --- a/src/app/GUI/RenderWidgets/renderwidget.cpp +++ b/src/app/GUI/RenderWidgets/renderwidget.cpp @@ -60,6 +60,7 @@ RenderWidget::RenderWidget(QWidget *parent) const auto darkPal= AppSupport::getDarkPalette(); bottomWidget->setAutoFillBackground(true); bottomWidget->setPalette(darkPal); + bottomWidget->setSizePolicy(QSizePolicy::Expanding, QSizePolicy::Minimum); mRenderProgressBar = new QProgressBar(this); //mRenderProgressBar->setObjectName(QString::fromUtf8("RenderProgressBar")); @@ -68,7 +69,7 @@ RenderWidget::RenderWidget(QWidget *parent) mRenderProgressBar->setFormat("%p%"); mRenderProgressBar->setValue(0); - mStartRenderButton = new QPushButton(QIcon::fromTheme("play"), + mStartRenderButton = new QPushButton(QIcon::fromTheme("render_animation"), tr("Render"), this); mStartRenderButton->setFocusPolicy(Qt::NoFocus); @@ -109,6 +110,17 @@ RenderWidget::RenderWidget(QWidget *parent) connect(mClearQueueButton, &QPushButton::pressed, this, &RenderWidget::clearRenderQueue); + eSizesUI::widget.add(mStartRenderButton, [this](const int size) { + mStartRenderButton->setIconSize(QSize(size, size)); + mStartRenderButton->setFixedHeight(size); + mStopRenderButton->setIconSize(QSize(size, size)); + mStopRenderButton->setFixedSize(QSize(size, size)); + mAddRenderButton->setIconSize(QSize(size, size)); + mAddRenderButton->setFixedSize(QSize(size, size)); + mClearQueueButton->setIconSize(QSize(size, size)); + mClearQueueButton->setFixedSize(QSize(size, size)); + }); + mContWidget = new QWidget(this); mContWidget->setContentsMargins(0, 0, 0, 0); mContLayout = new QVBoxLayout(mContWidget); diff --git a/src/app/GUI/Settings/generalsettingswidget.cpp b/src/app/GUI/Settings/generalsettingswidget.cpp index ad9e37b40..42fd7e914 100755 --- a/src/app/GUI/Settings/generalsettingswidget.cpp +++ b/src/app/GUI/Settings/generalsettingswidget.cpp @@ -29,6 +29,10 @@ #include #include +#include "Private/esettings.h" +#include "GUI/global.h" +#include "labeledslider.h" + #include "../mainwindow.h" GeneralSettingsWidget::GeneralSettingsWidget(QWidget *parent) @@ -36,6 +40,8 @@ GeneralSettingsWidget::GeneralSettingsWidget(QWidget *parent) , mAutoBackup(nullptr) , mAutoSave(nullptr) , mAutoSaveTimer(nullptr) + , mDefaultInterfaceScaling(nullptr) + , mInterfaceScaling(nullptr) { const auto mGeneralWidget = new QWidget(this); mGeneralWidget->setContentsMargins(0, 0, 0, 0); @@ -83,8 +89,51 @@ GeneralSettingsWidget::GeneralSettingsWidget(QWidget *parent) mGeneralLayout->addWidget(mAutoSaveWidget); + const auto mScaleWidget = new QGroupBox(this); + mScaleWidget->setTitle(tr("Interface Scaling")); + mScaleWidget->setContentsMargins(0, 0, 0, 0); + const auto mScaleLayout = new QVBoxLayout(mScaleWidget); + + const auto mScaleContainer = new QWidget(this); + mScaleContainer->setContentsMargins(0, 0, 0, 0); + const auto mScaleContainerLayout = new QHBoxLayout(mScaleContainer); + mScaleLayout->addWidget(mScaleContainer); + + mInterfaceScaling = new QSlider(Qt::Horizontal, this); + mInterfaceScaling->setRange(50, 150); + mScaleContainerLayout->addWidget(mInterfaceScaling); + + const auto mScaleLabel = new QLabel(this); + connect(mInterfaceScaling, &QSlider::valueChanged, + mScaleLabel, [mScaleLabel](const int value) { + mScaleLabel->setText(QString("%1 %").arg(value)); + }); + emit mInterfaceScaling->valueChanged(100); + mScaleContainerLayout->addWidget(mScaleLabel); + + mDefaultInterfaceScaling = new QCheckBox(this); + mDefaultInterfaceScaling->setText(tr("Auto")); + mDefaultInterfaceScaling->setToolTip(tr("Use scaling reported by the system.\n\nMay not always work as expected.")); + + mScaleContainerLayout->addWidget(mDefaultInterfaceScaling); + + const auto infoLabel = new QLabel(this); + infoLabel->setText(tr("Changes here will require a restart of Friction.")); + mScaleLayout->addWidget(infoLabel); + + mGeneralLayout->addWidget(mScaleWidget); + mGeneralLayout->addStretch(); addWidget(mGeneralWidget); + + eSizesUI::widget.add(mAutoBackup, [this](const int size) { + mAutoBackup->setFixedSize(QSize(size, size)); + mAutoBackup->setStyleSheet(QString("QCheckBox::indicator { width: %1px; height: %1px;}").arg(size/1.5)); + mAutoSave->setFixedSize(QSize(size, size)); + mAutoSave->setStyleSheet(QString("QCheckBox::indicator { width: %1px; height: %1px;}").arg(size/1.5)); + mDefaultInterfaceScaling->setFixedHeight(size); + mDefaultInterfaceScaling->setStyleSheet(QString("QCheckBox::indicator { width: %1px; height: %1px;}").arg(size/1.5)); + }); } void GeneralSettingsWidget::applySettings() @@ -99,6 +148,11 @@ void GeneralSettingsWidget::applySettings() "AutoSaveTimeout", (mAutoSaveTimer->value() * 60) * 1000); MainWindow::sGetInstance()->updateAutoSaveBackupState(); + + mSett.fDefaultInterfaceScaling = mDefaultInterfaceScaling->isChecked(); + mSett.fInterfaceScaling = mInterfaceScaling->value() * 0.01; + eSizesUI::font.updateSize(); + eSizesUI::widget.updateSize(); } void GeneralSettingsWidget::updateSettings(bool restore) @@ -114,4 +168,7 @@ void GeneralSettingsWidget::updateSettings(bool restore) 300000).toInt(); if (ms < 60000) { ms = 60000; } mAutoSaveTimer->setValue((ms / 1000) / 60); + + mDefaultInterfaceScaling->setChecked(mSett.fDefaultInterfaceScaling); + mInterfaceScaling->setValue(mDefaultInterfaceScaling->isChecked() ? 100 : 100 * mSett.fInterfaceScaling); } diff --git a/src/app/GUI/Settings/generalsettingswidget.h b/src/app/GUI/Settings/generalsettingswidget.h index 7e8bb4eaa..aa6ea36c3 100755 --- a/src/app/GUI/Settings/generalsettingswidget.h +++ b/src/app/GUI/Settings/generalsettingswidget.h @@ -28,6 +28,7 @@ #include #include +#include class GeneralSettingsWidget : public SettingsWidget { @@ -40,6 +41,8 @@ class GeneralSettingsWidget : public SettingsWidget QCheckBox *mAutoBackup; QCheckBox *mAutoSave; QSpinBox *mAutoSaveTimer; + QCheckBox *mDefaultInterfaceScaling; + QSlider *mInterfaceScaling; }; #endif // GENERALSETTINGSWIDGET_H diff --git a/src/app/GUI/Settings/performancesettingswidget.cpp b/src/app/GUI/Settings/performancesettingswidget.cpp index 8779d3519..c09cf6162 100755 --- a/src/app/GUI/Settings/performancesettingswidget.cpp +++ b/src/app/GUI/Settings/performancesettingswidget.cpp @@ -118,6 +118,15 @@ PerformanceSettingsWidget::PerformanceSettingsWidget(QWidget *parent) setupRasterEffectWidgets(); + eSizesUI::widget.add(mCpuThreadsCapCheck, [this](const int size) { + mCpuThreadsCapCheck->setFixedHeight(size); + mCpuThreadsCapCheck->setStyleSheet(QString("QCheckBox::indicator { width: %1px; height: %1px;}").arg(size/1.5)); + mRamMBCapCheck->setFixedHeight(size); + mRamMBCapCheck->setStyleSheet(QString("QCheckBox::indicator { width: %1px; height: %1px;}").arg(size/1.5)); + mPathGpuAccCheck->setFixedHeight(size); + mPathGpuAccCheck->setStyleSheet(QString("QCheckBox::indicator { width: %1px; height: %1px;}").arg(size/1.5)); + }); + QTimer::singleShot(250, this, &PerformanceSettingsWidget::updateAudioDevices); connect(AudioHandler::sInstance, &AudioHandler::deviceChanged, diff --git a/src/app/GUI/Settings/pluginssettingswidget.cpp b/src/app/GUI/Settings/pluginssettingswidget.cpp index bc396cc92..00c60196a 100755 --- a/src/app/GUI/Settings/pluginssettingswidget.cpp +++ b/src/app/GUI/Settings/pluginssettingswidget.cpp @@ -34,6 +34,8 @@ #include #include +#include "GUI/global.h" + PluginsSettingsWidget::PluginsSettingsWidget(QWidget *parent) : SettingsWidget(parent) , mShaderPath(nullptr) @@ -57,6 +59,8 @@ PluginsSettingsWidget::PluginsSettingsWidget(QWidget *parent) QString(), this); mShaderPathButton->setFocusPolicy(Qt::NoFocus); + mShaderPathButton->setIconSize(QSize(eSizesUI::widget, eSizesUI::widget)); + mShaderPathButton->setFixedSize(QSize(eSizesUI::widget, eSizesUI::widget)); mShaderLayout->addWidget(mShaderLabel); mShaderLayout->addWidget(mShaderPath); diff --git a/src/app/GUI/Settings/presetsettingswidget.cpp b/src/app/GUI/Settings/presetsettingswidget.cpp index 9aea1be07..2afa68025 100755 --- a/src/app/GUI/Settings/presetsettingswidget.cpp +++ b/src/app/GUI/Settings/presetsettingswidget.cpp @@ -31,6 +31,8 @@ #include #include +#include "GUI/global.h" + PresetSettingsWidget::PresetSettingsWidget(QWidget *parent) : SettingsWidget(parent) , mTreeResolutions(nullptr) @@ -42,6 +44,17 @@ PresetSettingsWidget::PresetSettingsWidget(QWidget *parent) { setupResolutionPresetWidget(); setupFpsPresetWidget(); + + eSizesUI::widget.add(this, [this](const int size) { + mCheckResolutions->setFixedHeight(size); + mCheckResolutions->setStyleSheet(QString("QCheckBox::indicator { width: %1px; height: %1px;}").arg(size/1.5)); + mCheckResolutionsAuto->setFixedHeight(size); + mCheckResolutionsAuto->setStyleSheet(QString("QCheckBox::indicator { width: %1px; height: %1px;}").arg(size/1.5)); + mCheckFps->setFixedHeight(size); + mCheckFps->setStyleSheet(QString("QCheckBox::indicator { width: %1px; height: %1px;}").arg(size/1.5)); + mCheckFpsAuto->setFixedHeight(size); + mCheckFpsAuto->setStyleSheet(QString("QCheckBox::indicator { width: %1px; height: %1px;}").arg(size/1.5)); + }); } void PresetSettingsWidget::applySettings() diff --git a/src/app/GUI/Settings/settingsdialog.cpp b/src/app/GUI/Settings/settingsdialog.cpp index c967ae7bc..4da6b1cdb 100755 --- a/src/app/GUI/Settings/settingsdialog.cpp +++ b/src/app/GUI/Settings/settingsdialog.cpp @@ -70,6 +70,13 @@ SettingsDialog::SettingsDialog(QWidget * const parent) buttonsLayout->addWidget(applyButton); buttonsLayout->addWidget(cancelButton); + restoreButton->setIconSize(QSize(eSizesUI::widget, eSizesUI::widget)); + restoreButton->setFixedHeight(eSizesUI::widget); + cancelButton->setIconSize(QSize(eSizesUI::widget, eSizesUI::widget)); + cancelButton->setFixedHeight(eSizesUI::widget); + applyButton->setIconSize(QSize(eSizesUI::widget, eSizesUI::widget)); + applyButton->setFixedHeight(eSizesUI::widget); + mainLayout->addLayout(buttonsLayout); const auto statusBar = new QStatusBar(this); statusBar->setSizeGripEnabled(false); diff --git a/src/app/GUI/Settings/timelinesettingswidget.cpp b/src/app/GUI/Settings/timelinesettingswidget.cpp index c6dcaf7c5..769f133ce 100755 --- a/src/app/GUI/Settings/timelinesettingswidget.cpp +++ b/src/app/GUI/Settings/timelinesettingswidget.cpp @@ -30,6 +30,8 @@ #include +#include "GUI/global.h" + TimelineSettingsWidget::TimelineSettingsWidget(QWidget *parent) : SettingsWidget(parent) { mAlternateRowCheck = new QCheckBox("Alternate row color", this); @@ -77,6 +79,13 @@ TimelineSettingsWidget::TimelineSettingsWidget(QWidget *parent) : mSelectedVisibilityRangeColor); add2HWidgets(new QLabel("Animation range color"), mAnimationRangeColor); + + eSizesUI::widget.add(mAlternateRowCheck, [this](const int size) { + mAlternateRowCheck->setFixedHeight(size); + mAlternateRowCheck->setStyleSheet(QString("QCheckBox::indicator { width: %1px; height: %1px;}").arg(size/1.5)); + mHighlightRowCheck->setFixedHeight(size); + mHighlightRowCheck->setStyleSheet(QString("QCheckBox::indicator { width: %1px; height: %1px;}").arg(size/1.5)); + }); } void TimelineSettingsWidget::applySettings() { diff --git a/src/app/GUI/alignwidget.cpp b/src/app/GUI/alignwidget.cpp index d487bc61e..f45ad2cdf 100644 --- a/src/app/GUI/alignwidget.cpp +++ b/src/app/GUI/alignwidget.cpp @@ -49,7 +49,7 @@ AlignWidget::AlignWidget(QWidget* const parent) combosLay->addWidget(new QLabel(tr("Align"))); mAlignPivot = new QComboBox(this); - mAlignPivot->setSizePolicy(QSizePolicy::Preferred, QSizePolicy::Expanding); + mAlignPivot->setSizePolicy(QSizePolicy::Expanding, QSizePolicy::Expanding); mAlignPivot->setFocusPolicy(Qt::NoFocus); mAlignPivot->addItem(tr("Geometry")); mAlignPivot->addItem(tr("Pivot")); @@ -57,7 +57,7 @@ AlignWidget::AlignWidget(QWidget* const parent) combosLay->addWidget(new QLabel(tr("Relative to"))); mRelativeTo = new QComboBox(this); - mRelativeTo->setSizePolicy(QSizePolicy::Preferred, QSizePolicy::Expanding); + mRelativeTo->setSizePolicy(QSizePolicy::Expanding, QSizePolicy::Expanding); mRelativeTo->setFocusPolicy(Qt::NoFocus); mRelativeTo->addItem(tr("Scene")); mRelativeTo->addItem(tr("Last Selected")); @@ -67,7 +67,7 @@ AlignWidget::AlignWidget(QWidget* const parent) mainLayout->addLayout(buttonsLay); mainLayout->addStretch(); - int buttonSize = eSizesUI::button; + int buttonSize = eSizesUI::widget; const auto leftButton = new QPushButton(this); leftButton->setFocusPolicy(Qt::NoFocus); diff --git a/src/app/GUI/assetswidget.cpp b/src/app/GUI/assetswidget.cpp index 3b22d3881..26d8158b4 100644 --- a/src/app/GUI/assetswidget.cpp +++ b/src/app/GUI/assetswidget.cpp @@ -36,6 +36,8 @@ #include "FileCacheHandlers/imagesequencecachehandler.h" #include "filesourcescache.h" +#include "GUI/global.h" + AssetsTreeWidget::AssetsTreeWidget(QWidget *parent) : QTreeWidget(parent) { @@ -50,6 +52,9 @@ AssetsTreeWidget::AssetsTreeWidget(QWidget *parent) header()->setSectionResizeMode(QHeaderView::ResizeToContents); header()->setStretchLastSection(true); setContextMenuPolicy(Qt::CustomContextMenu); + eSizesUI::widget.add(this, [this](const int size) { + setIconSize(QSize(size, size)); + }); } void AssetsTreeWidget::dropEvent(QDropEvent *event) diff --git a/src/app/GUI/fakemenubar.cpp b/src/app/GUI/fakemenubar.cpp index 49e7d4ce9..06a077f76 100644 --- a/src/app/GUI/fakemenubar.cpp +++ b/src/app/GUI/fakemenubar.cpp @@ -35,9 +35,10 @@ class QActionButton : public QPushButton { public: explicit QActionButton(QWidget *parent = nullptr) : QPushButton(parent) { - /*eSizesUI::widget.add(this, [this](const int size) { - setFixedHeight(size - 1); - });*/ + eSizesUI::widget.add(this, [this](const int size) { + setFixedHeight(size); + setIconSize(QSize(size, size)); + }); //setSizePolicy(QSizePolicy::Fixed, QSizePolicy::Fixed); setObjectName("QActionButton"); setFocusPolicy(Qt::NoFocus); @@ -92,9 +93,9 @@ FakeMenuBar::FakeMenuBar(QWidget* const parent) : setLayout(mainLayout); - /*eSizesUI::widget.add(this, [this](const int size) { + eSizesUI::widget.add(this, [this](const int size) { setFixedHeight(size); - });*/ + }); } void FakeMenuBar::addSeparator() { diff --git a/src/app/GUI/fillstrokesettings.cpp b/src/app/GUI/fillstrokesettings.cpp index a5b83bc98..b3ec8f5da 100755 --- a/src/app/GUI/fillstrokesettings.cpp +++ b/src/app/GUI/fillstrokesettings.cpp @@ -165,6 +165,21 @@ FillStrokeSettingsWidget::FillStrokeSettingsWidget(Document &document, connect(mRoundCapStyleButton, &QPushButton::released, this, &FillStrokeSettingsWidget::setRoundCapStyleAction); + eSizesUI::widget.add(mBevelJoinStyleButton, [this](const int size) { + mBevelJoinStyleButton->setFixedHeight(size); + mBevelJoinStyleButton->setIconSize(QSize(size, size)); + mMiterJointStyleButton->setFixedHeight(size); + mMiterJointStyleButton->setIconSize(QSize(size, size)); + mRoundJoinStyleButton->setFixedHeight(size); + mRoundJoinStyleButton->setIconSize(QSize(size, size)); + mFlatCapStyleButton->setFixedHeight(size); + mFlatCapStyleButton->setIconSize(QSize(size, size)); + mSquareCapStyleButton->setFixedHeight(size); + mSquareCapStyleButton->setIconSize(QSize(size, size)); + mRoundCapStyleButton->setFixedHeight(size); + mRoundCapStyleButton->setIconSize(QSize(size, size)); + }); + mCapStyleLayout->addWidget(new QLabel("Cap:", this)); mCapStyleLayout->addWidget(mFlatCapStyleButton); mCapStyleLayout->addWidget(mSquareCapStyleButton); diff --git a/src/app/GUI/fontswidget.cpp b/src/app/GUI/fontswidget.cpp index fd48f01aa..3d8df6745 100755 --- a/src/app/GUI/fontswidget.cpp +++ b/src/app/GUI/fontswidget.cpp @@ -135,7 +135,6 @@ FontsWidget::FontsWidget(QWidget *parent) connect(mAlignRight, &QPushButton::pressed, this, [this]() { emit textAlignmentChanged(Qt::AlignRight); }); - mAlignTop = new QPushButton(QIcon::fromTheme("alignTop"), QString(), this); mAlignTop->setFocusPolicy(Qt::NoFocus); @@ -157,6 +156,21 @@ FontsWidget::FontsWidget(QWidget *parent) connect(mAlignBottom, &QPushButton::pressed, this, [this]() { emit textVAlignmentChanged(Qt::AlignBottom); }); + eSizesUI::widget.add(mAlignLeft, [this](const int size) { + mAlignLeft->setFixedHeight(size); + mAlignLeft->setIconSize(QSize(size, size)); + mAlignCenter->setFixedHeight(size); + mAlignCenter->setIconSize(QSize(size, size)); + mAlignRight->setFixedHeight(size); + mAlignRight->setIconSize(QSize(size, size)); + mAlignTop->setFixedHeight(size); + mAlignTop->setIconSize(QSize(size, size)); + mAlignVCenter->setFixedHeight(size); + mAlignVCenter->setIconSize(QSize(size, size)); + mAlignBottom->setFixedHeight(size); + mAlignBottom->setIconSize(QSize(size, size)); + }); + mTextInput = new QPlainTextEdit(this); mTextInput->setFocusPolicy(Qt::ClickFocus); mTextInput->setPlaceholderText(tr("Enter text ...")); diff --git a/src/app/GUI/layouthandler.cpp b/src/app/GUI/layouthandler.cpp index 9452a958c..9a09b01ba 100755 --- a/src/app/GUI/layouthandler.cpp +++ b/src/app/GUI/layouthandler.cpp @@ -53,18 +53,20 @@ LayoutHandler::LayoutHandler(Document& document, newLayPush->setFocusPolicy(Qt::NoFocus); newLayPush->setToolTip(tr("Add")); //newLayPush->setObjectName("addCanvasButton"); - /*eSizesUI::widget.add(newLayPush, [newLayPush](const int size) { - newLayPush->setFixedWidth(size); - });*/ + eSizesUI::widget.add(newLayPush, [newLayPush](const int size) { + newLayPush->setFixedSize(QSize(size, size)); + newLayPush->setIconSize(QSize(size, size)); + }); //newLayPush->setSizePolicy(QSizePolicy::Fixed, QSizePolicy::Minimum); const auto removeLayPush = new QPushButton(QIcon::fromTheme("minus"), QString(), mComboWidget); removeLayPush->setFocusPolicy(Qt::NoFocus); removeLayPush->setToolTip(tr("Remove")); //removeLayPush->setObjectName("removeCanvasButton"); - /*eSizesUI::widget.add(removeLayPush, [removeLayPush](const int size) { - removeLayPush->setFixedWidth(size); - });*/ + eSizesUI::widget.add(removeLayPush, [removeLayPush](const int size) { + removeLayPush->setFixedSize(QSize(size, size)); + removeLayPush->setIconSize(QSize(size, size)); + }); //removeLayPush->setSizePolicy(QSizePolicy::Fixed, QSizePolicy::Minimum); canvasComboLayout->addWidget(mComboBox); diff --git a/src/app/GUI/mainwindow.cpp b/src/app/GUI/mainwindow.cpp index dcba4d35d..d3528e97d 100755 --- a/src/app/GUI/mainwindow.cpp +++ b/src/app/GUI/mainwindow.cpp @@ -275,14 +275,23 @@ MainWindow::MainWindow(Document& document, QToolBar *viewerToolBar = new QToolBar(this); viewerToolBar->setOrientation(Qt::Vertical); + eSizesUI::widget.add(viewerToolBar, [viewerToolBar](const int size) { + viewerToolBar->setIconSize(QSize(size, size)); + }); mViewerNodeBar = new QToolBar(this); mViewerNodeBar->setObjectName(QString::fromUtf8("ViewerNodeBar")); mViewerNodeBar->setOrientation(Qt::Vertical); + eSizesUI::widget.add(mViewerNodeBar, [this](const int size) { + mViewerNodeBar->setIconSize(QSize(size, size)); + }); mViewerDrawBar = new QToolBar(this); mViewerDrawBar->setObjectName(QString::fromUtf8("ViewerDrawBar")); mViewerDrawBar->setOrientation(Qt::Horizontal); + eSizesUI::widget.add(mViewerDrawBar, [this](const int size) { + mViewerDrawBar->setIconSize(QSize(size, size)); + }); setupToolBar(); setupMenuBar(); @@ -384,6 +393,10 @@ MainWindow::MainWindow(Document& document, mTopSideBarWidget->setContentsMargins(frictionMargins); mTopSideBarWidget->setMinimumWidth(sideBarMin); mTopSideBarWidget->setTabPosition(QTabWidget::South); + eSizesUI::widget.add(mTopSideBarWidget, [this](const int size) { + mTopSideBarWidget->setIconSize(QSize(size, size)); + }); + mTabColorIndex = mTopSideBarWidget->addTab(mFillStrokeSettings, QIcon::fromTheme("color"), tr("Fill and Stroke")); @@ -416,6 +429,9 @@ MainWindow::MainWindow(Document& document, mBottomSideBarWidget->setContentsMargins(frictionMargins); mBottomSideBarWidget->setMinimumWidth(sideBarMin); mBottomSideBarWidget->setTabPosition(QTabWidget::South); + eSizesUI::widget.add(mBottomSideBarWidget, [this](const int size) { + mBottomSideBarWidget->setIconSize(QSize(size, size)); + }); mTabPropertiesIndex = mBottomSideBarWidget->addTab(propertiesWidget, QIcon::fromTheme("drawPathAutoChecked"), @@ -485,8 +501,6 @@ void MainWindow::setupMenuBar() mMenuBar = new QMenuBar(nullptr); connectAppFont(mMenuBar); - QList frictionButtonActions; - mFileMenu = mMenuBar->addMenu(tr("File", "MenuBar")); const auto newAct = mFileMenu->addAction(QIcon::fromTheme("file_blank"), @@ -1203,6 +1217,7 @@ void MainWindow::setupMenuBar() const auto frictionButton = new QToolButton(this); frictionButton->setObjectName(QString::fromUtf8("ToolButton")); frictionButton->setPopupMode(QToolButton::InstantPopup); + frictionButton->setIconSize(QSize(eSizesUI::widget, eSizesUI::widget)); frictionButton->setIcon(QIcon::fromTheme("friction")); frictionButton->setDefaultAction(aboutAct); frictionButton->setToolTip(QString()); @@ -1390,16 +1405,14 @@ void MainWindow::updateSettingsForCurrentCanvas(Canvas* const scene) void MainWindow::setupToolBar() { - /*const QSize iconSize(AppSupport::getSettings("ui", - "mainToolbarIconSize", - QSize(24, 24)).toSize());*/ - mToolbar = new QToolBar(tr("Toolbar"), this); mToolbar->setObjectName("mainToolbar"); mToolbar->setFocusPolicy(Qt::NoFocus); - //mToolbar->setIconSize(iconSize); mToolbar->setToolButtonStyle(Qt::ToolButtonTextBesideIcon); mToolbar->setMovable(false); + eSizesUI::widget.add(mToolbar, [this](const int size) { + mToolbar->setIconSize(QSize(size, size)); + }); addToolBar(mToolbar); mToolbarActGroup = new QActionGroup(this); diff --git a/src/app/GUI/timelinedockwidget.cpp b/src/app/GUI/timelinedockwidget.cpp index 0736e61df..3490270e5 100755 --- a/src/app/GUI/timelinedockwidget.cpp +++ b/src/app/GUI/timelinedockwidget.cpp @@ -221,6 +221,9 @@ TimelineDockWidget::TimelineDockWidget(Document& document, }); mToolBar = new QToolBar(this); + eSizesUI::widget.add(mToolBar, [this](const int size) { + mToolBar->setIconSize(QSize(size, size)); + }); mToolBar->setMovable(false); mRenderProgress = new QProgressBar(this); diff --git a/src/app/GUI/timelinewidget.cpp b/src/app/GUI/timelinewidget.cpp index 5842bf7b5..0438cb5af 100755 --- a/src/app/GUI/timelinewidget.cpp +++ b/src/app/GUI/timelinewidget.cpp @@ -85,7 +85,7 @@ TimelineWidget::TimelineWidget(Document &document, mBoxesListMenuBar->addMenu(mSceneChooser); mCornerMenuBar = new FakeMenuBar(this); - mCornerMenuBar->setSizePolicy(QSizePolicy::Fixed, QSizePolicy::Preferred); + // mCornerMenuBar->setSizePolicy(QSizePolicy::Fixed, QSizePolicy::Preferred); //mCornerMenuBar->setStyleSheet("QMenuBar::item { padding: 1px 0px; }"); const auto iconsDir = eSettings::sIconsDir(); diff --git a/src/app/main.cpp b/src/app/main.cpp index d8cf2f624..3ffcd881b 100755 --- a/src/app/main.cpp +++ b/src/app/main.cpp @@ -26,6 +26,7 @@ #include #include #include +//#include #ifdef FRICTION_BUNDLE_ROBOTO #include @@ -146,15 +147,13 @@ int main(int argc, char *argv[]) HardwareInfo::sRamKB()); OS_FONT = QApplication::font(); - eSizesUI::font.setEvaluator([]() { - double dpi = (qApp->desktop()->logicalDpiX() / 96.0); -#ifdef FRICTION_BUNDLE_ROBOTO -#ifdef Q_OS_WIN - dpi -= 0.2; -#else - dpi -= 0.1; -#endif -#endif + eSizesUI::font.setEvaluator([&settings]() { + qreal dpi = 1.0; + if (!settings.fDefaultInterfaceScaling) { + dpi = settings.fInterfaceScaling; + } else { + dpi = qApp->desktop()->logicalDpiX() / 96.0; //QGuiApplication::primaryScreen()->logicalDotsPerInch() / 96.0 + } qDebug() << "DPI" << dpi; const auto fm = QFontMetrics(OS_FONT); const qreal scaling = qBound(0.5, dpi, 1.5); diff --git a/src/core/Private/esettings.cpp b/src/core/Private/esettings.cpp index 19b4e0c71..e99246caf 100755 --- a/src/core/Private/esettings.cpp +++ b/src/core/Private/esettings.cpp @@ -193,6 +193,9 @@ eSettings::eSettings(const int cpuThreads, gSettings << std::make_shared( fInterfaceScaling, "interfaceScaling", 1.); + gSettings << std::make_shared( + fDefaultInterfaceScaling, + "defaultInterfaceScaling", false); gSettings << std::make_shared( fCanvasRtlSupport, diff --git a/src/core/Private/esettings.h b/src/core/Private/esettings.h index e25b75f65..e9c3bed96 100755 --- a/src/core/Private/esettings.h +++ b/src/core/Private/esettings.h @@ -100,6 +100,7 @@ class CORE_EXPORT eSettings : public QObject // ui settings qreal fInterfaceScaling; + bool fDefaultInterfaceScaling; // canvas settings bool fCanvasRtlSupport;