From 4c2a5169701a84c950fee87f95a31fc33aa40898 Mon Sep 17 00:00:00 2001 From: Matt Chang Date: Fri, 19 Apr 2024 13:30:14 +0800 Subject: [PATCH 01/13] Make OnionSkins UI more compact by reducing spacing between UI components --- app/ui/onionskin.ui | 84 +++++++++++++++++++++++++++++---------------- 1 file changed, 54 insertions(+), 30 deletions(-) diff --git a/app/ui/onionskin.ui b/app/ui/onionskin.ui index 20c6eec598..f015223ae0 100644 --- a/app/ui/onionskin.ui +++ b/app/ui/onionskin.ui @@ -6,14 +6,14 @@ 0 0 - 213 - 382 + 219 + 238 - 187 - 122 + 190 + 124 @@ -30,6 +30,9 @@ + + 0 + 0 @@ -76,8 +79,8 @@ 0 0 - 213 - 360 + 219 + 214 @@ -87,17 +90,20 @@ + + 3 + - 6 + 3 - 6 + 3 - 6 + 3 - 6 + 3 @@ -108,6 +114,9 @@ true + + 3 + QLayout::SetDefaultConstraint @@ -115,13 +124,13 @@ 0 - 6 + 3 0 - 6 + 3 @@ -189,6 +198,9 @@ true + + 3 + QLayout::SetDefaultConstraint @@ -196,13 +208,13 @@ 0 - 6 + 3 0 - 6 + 3 @@ -278,25 +290,28 @@ Distributed Opacity - + - 6 + 0 0 - 6 + 0 0 - 6 + 3 - - + + + + 3 + 0 @@ -310,7 +325,7 @@ 0 - + 0 @@ -318,12 +333,15 @@ - Min + Max + + + Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter - + 0 @@ -332,7 +350,7 @@ - 60 + 50 0 @@ -354,8 +372,11 @@ - - + + + + 3 + 0 @@ -369,7 +390,7 @@ 0 - + 0 @@ -377,12 +398,15 @@ - Max + Min + + + Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter - + 0 @@ -391,7 +415,7 @@ - 60 + 50 0 From 1d746a09de58c7e80695ad57e0837b57396ee81d Mon Sep 17 00:00:00 2001 From: MrStevns Date: Sat, 27 Apr 2024 11:40:30 +0200 Subject: [PATCH 02/13] Tweak dock layout to be more compact - Font size: 11 - Minimum width: 140 px or less - Padding adjusted to be 3 px. The size has to be set specifically, otherwise the designer will adjust to what it thinks is best. --- app/ui/bucketoptionswidget.ui | 62 +++++++++++++++++- app/ui/cameraoptionswidget.ui | 34 +++++++--- app/ui/colorinspector.ui | 119 ++++++++++++++++++++++++++++++---- app/ui/colorpalette.ui | 13 +++- app/ui/onionskin.ui | 86 +++++++++++++++++++----- app/ui/toolboxwidget.ui | 14 ++-- app/ui/tooloptions.ui | 19 ++++-- 7 files changed, 292 insertions(+), 55 deletions(-) diff --git a/app/ui/bucketoptionswidget.ui b/app/ui/bucketoptionswidget.ui index 49ffe7ee29..d894b36e0c 100644 --- a/app/ui/bucketoptionswidget.ui +++ b/app/ui/bucketoptionswidget.ui @@ -6,10 +6,21 @@ 0 0 - 400 + 140 221 + + + 140 + 0 + + + + + 11 + + Form @@ -44,6 +55,11 @@ + + + 11 + + Reference @@ -57,6 +73,11 @@ 0 + + + 11 + + @@ -68,6 +89,11 @@ + + + 11 + + Blend mode @@ -81,6 +107,11 @@ 0 + + + 11 + + @@ -92,8 +123,17 @@ QLayout::SetDefaultConstraint + + 3 + - 0 + 3 + + + 3 + + + 3 6 @@ -117,6 +157,11 @@ + + + 11 + + 0 @@ -124,6 +169,11 @@ + + + 11 + + 0 @@ -161,7 +211,13 @@ - + + + + 11 + + + diff --git a/app/ui/cameraoptionswidget.ui b/app/ui/cameraoptionswidget.ui index f2100f77f5..4867492221 100644 --- a/app/ui/cameraoptionswidget.ui +++ b/app/ui/cameraoptionswidget.ui @@ -6,10 +6,21 @@ 0 0 - 254 + 140 208 + + + 140 + 0 + + + + + 11 + + 0 @@ -25,21 +36,26 @@ + + + 11 + + Transform - 0 + 3 - 0 + 3 - 0 + 3 - 0 + 3 2 @@ -125,16 +141,16 @@ 2 - 4 + 3 - 4 + 3 - 4 + 3 - 4 + 3 diff --git a/app/ui/colorinspector.ui b/app/ui/colorinspector.ui index e228df76c7..0807861df7 100644 --- a/app/ui/colorinspector.ui +++ b/app/ui/colorinspector.ui @@ -7,28 +7,39 @@ 0 0 - 271 + 120 263 + + + 120 + 0 + + 0 114 + + + 11 + + - 5 + 3 - 2 + 3 - 2 + 3 - 2 + 3 @@ -39,13 +50,25 @@ - 1 + 0 HSV + + 3 + + + 3 + + + 3 + + + 3 + @@ -75,16 +98,44 @@ - + + + + 0 + 0 + + + - + + + + 0 + 0 + + + - + + + + 0 + 0 + + + - + + + + 0 + 0 + + + @@ -133,6 +184,18 @@ RGB + + 3 + + + 3 + + + 3 + + + 3 + @@ -148,10 +211,24 @@ - + + + + 0 + 0 + + + - + + + + 0 + 0 + + + @@ -161,10 +238,24 @@ - + + + + 0 + 0 + + + - + + + + 0 + 0 + + + diff --git a/app/ui/colorpalette.ui b/app/ui/colorpalette.ui index 559d9a1e7e..47bb8c647f 100644 --- a/app/ui/colorpalette.ui +++ b/app/ui/colorpalette.ui @@ -6,10 +6,21 @@ 0 0 - 268 + 140 241 + + + 140 + 132 + + + + + 11 + + Color Palette diff --git a/app/ui/onionskin.ui b/app/ui/onionskin.ui index f015223ae0..e96d22a652 100644 --- a/app/ui/onionskin.ui +++ b/app/ui/onionskin.ui @@ -6,16 +6,21 @@ 0 0 - 219 - 238 + 140 + 291 - 190 - 124 + 140 + 122 + + + 11 + + false @@ -29,6 +34,11 @@ 0 + + + 11 + + 0 @@ -79,8 +89,8 @@ 0 0 - 219 - 214 + 160 + 254 @@ -107,6 +117,11 @@ + + + 11 + + Previous Frames @@ -191,6 +206,11 @@ + + + 11 + + Next Frames @@ -287,6 +307,11 @@ + + + 11 + + Distributed Opacity @@ -332,6 +357,11 @@ 0 + + + 11 + + Max @@ -397,6 +427,11 @@ 0 + + + 11 + + Min @@ -440,18 +475,35 @@ - - - Show Keyframes Only - - - - - - - Show During Playback + + + 0 - + + + + + 11 + + + + Show Keyframes Only + + + + + + + + 11 + + + + Show During Playback + + + + diff --git a/app/ui/toolboxwidget.ui b/app/ui/toolboxwidget.ui index b2c062096b..0acaa7db8f 100644 --- a/app/ui/toolboxwidget.ui +++ b/app/ui/toolboxwidget.ui @@ -6,13 +6,13 @@ 0 0 - 88 + 38 502 - 88 + 38 105 @@ -25,13 +25,13 @@ 0 - 0 + 3 - 0 + 3 - 0 + 3 0 @@ -55,8 +55,8 @@ 0 0 - 88 - 480 + 32 + 477 diff --git a/app/ui/tooloptions.ui b/app/ui/tooloptions.ui index 8f63adf4b7..375abb3334 100644 --- a/app/ui/tooloptions.ui +++ b/app/ui/tooloptions.ui @@ -6,10 +6,21 @@ 0 0 - 174 + 140 355 + + + 140 + 0 + + + + + 11 + + Form @@ -42,12 +53,12 @@ 0 0 - 174 - 355 + 166 + 340 - false + true From 1f988edbab817e99ef130d5717b5ccca748bb5a5 Mon Sep 17 00:00:00 2001 From: MrStevns Date: Sat, 27 Apr 2024 12:02:27 +0200 Subject: [PATCH 03/13] Remove extra padding --- app/ui/cameraoptionswidget.ui | 10 +- app/ui/tooloptions.ui | 201 ++++++++++++++++++---------------- 2 files changed, 109 insertions(+), 102 deletions(-) diff --git a/app/ui/cameraoptionswidget.ui b/app/ui/cameraoptionswidget.ui index 4867492221..691255fd92 100644 --- a/app/ui/cameraoptionswidget.ui +++ b/app/ui/cameraoptionswidget.ui @@ -138,19 +138,19 @@ - 2 + 0 - 3 + 0 - 3 + 0 - 3 + 0 - 3 + 0 diff --git a/app/ui/tooloptions.ui b/app/ui/tooloptions.ui index 375abb3334..a54c5b7d2b 100644 --- a/app/ui/tooloptions.ui +++ b/app/ui/tooloptions.ui @@ -26,16 +26,16 @@ - 0 + 3 - 0 + 3 - 0 + 3 - 0 + 3 @@ -53,8 +53,8 @@ 0 0 - 166 - 340 + 147 + 334 @@ -62,16 +62,16 @@ - 6 + 0 - 6 + 0 - 6 + 0 - 6 + 0 @@ -146,24 +146,101 @@ - - - Enable or disable feathering + + + 0 - - Use Feather - - - - - - - Show Size and Diff. - - - false - - + + + + Enable or disable feathering + + + Use Feather + + + + + + + Show Size and Diff. + + + false + + + + + + + Contour will be filled + + + Fill Contour + + + + + + + Use Bézier curves to create curved lines + + + Bézier + + + + + + + Vary strokes based on pressure when drawing on a tablet + + + Pressure + + + + + + + Use anti-aliasing to create smooth edges + + + Anti-Aliasing + + + + + + + Make invisible + + + Invisible + + + + + + + Preserve Alpha + + + Alpha + + + + + + + Merge vector lines when they are close together + + + Merge + + + + @@ -178,76 +255,6 @@ - - - - Contour will be filled - - - Fill Contour - - - - - - - Use Bézier curves to create curved lines - - - Bézier - - - - - - - Vary strokes based on pressure when drawing on a tablet - - - Pressure - - - - - - - Use anti-aliasing to create smooth edges - - - Anti-Aliasing - - - - - - - Make invisible - - - Invisible - - - - - - - Preserve Alpha - - - Alpha - - - - - - - Merge vector lines when they are close together - - - Merge - - - From bce7381374e85b536bb28a5bc4191fde75917011 Mon Sep 17 00:00:00 2001 From: MrStevns Date: Tue, 30 Apr 2024 17:49:56 +0200 Subject: [PATCH 04/13] Update colorbox margins --- app/src/colorbox.cpp | 2 +- app/ui/colorpalette.ui | 6 ------ 2 files changed, 1 insertion(+), 7 deletions(-) diff --git a/app/src/colorbox.cpp b/app/src/colorbox.cpp index 249fca92c4..4b11f3ff15 100644 --- a/app/src/colorbox.cpp +++ b/app/src/colorbox.cpp @@ -35,7 +35,7 @@ void ColorBox::initUI() mColorWheel = new ColorWheel(this); QVBoxLayout* layout = new QVBoxLayout; - layout->setContentsMargins(5, 5, 5, 5); + layout->setContentsMargins(3, 3, 3, 3); layout->addWidget(mColorWheel); layout->setStretch(0, 1); layout->setStretch(1, 0); diff --git a/app/ui/colorpalette.ui b/app/ui/colorpalette.ui index 47bb8c647f..a458293e2e 100644 --- a/app/ui/colorpalette.ui +++ b/app/ui/colorpalette.ui @@ -236,12 +236,6 @@ 0 - - - 0 - 0 - - 16777215 From 4d79973f24422aeba38a164360ff7fa470996a9f Mon Sep 17 00:00:00 2001 From: MrStevns Date: Wed, 1 May 2024 19:10:07 +0200 Subject: [PATCH 05/13] Adjust spacing for toolbox flow layout --- app/src/toolbox.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/app/src/toolbox.cpp b/app/src/toolbox.cpp index ff155ec225..6225718c07 100644 --- a/app/src/toolbox.cpp +++ b/app/src/toolbox.cpp @@ -138,7 +138,7 @@ void ToolBoxWidget::initUI() connect(editor()->layers(), &LayerManager::currentLayerChanged, this, &ToolBoxWidget::onLayerDidChange); - FlowLayout* flowlayout = new FlowLayout; + FlowLayout* flowlayout = new FlowLayout(0,3,3); flowlayout->addWidget(ui->pencilButton); flowlayout->addWidget(ui->eraserButton); From 1ad3fc010501e5423df25ba79cfa4803532954b0 Mon Sep 17 00:00:00 2001 From: MrStevns Date: Sun, 5 May 2024 14:22:53 +0200 Subject: [PATCH 06/13] Fix scroll bar is offset from panel The reason is that we add the margins to the outer layout instead of inside the scroll area. --- app/src/toolbox.cpp | 1 + app/ui/toolboxwidget.ui | 6 +++--- app/ui/tooloptions.ui | 20 ++++++++++---------- 3 files changed, 14 insertions(+), 13 deletions(-) diff --git a/app/src/toolbox.cpp b/app/src/toolbox.cpp index 6225718c07..5e6735d621 100644 --- a/app/src/toolbox.cpp +++ b/app/src/toolbox.cpp @@ -154,6 +154,7 @@ void ToolBoxWidget::initUI() delete ui->scrollAreaWidgetContents_2->layout(); ui->scrollAreaWidgetContents_2->setLayout(flowlayout); + ui->scrollAreaWidgetContents_2->setContentsMargins(3,3,3,3); QSettings settings(PENCIL2D, PENCIL2D); restoreGeometry(settings.value("ToolBoxGeom").toByteArray()); diff --git a/app/ui/toolboxwidget.ui b/app/ui/toolboxwidget.ui index 0acaa7db8f..a2449d45f8 100644 --- a/app/ui/toolboxwidget.ui +++ b/app/ui/toolboxwidget.ui @@ -25,13 +25,13 @@ 0 - 3 + 0 - 3 + 0 - 3 + 0 0 diff --git a/app/ui/tooloptions.ui b/app/ui/tooloptions.ui index a54c5b7d2b..645193bf86 100644 --- a/app/ui/tooloptions.ui +++ b/app/ui/tooloptions.ui @@ -26,16 +26,16 @@ - 3 + 0 - 3 + 0 - 3 + 0 - 3 + 0 @@ -53,8 +53,8 @@ 0 0 - 147 - 334 + 153 + 340 @@ -62,16 +62,16 @@ - 0 + 3 - 0 + 3 - 0 + 3 - 0 + 3 From 1ed529390f9239dbd30b040acf4b16001972243b Mon Sep 17 00:00:00 2001 From: MrStevns Date: Thu, 9 May 2024 13:56:36 +0200 Subject: [PATCH 07/13] Allow toolbox to be small in all directions --- app/src/toolbox.cpp | 37 ++++++++++++++++++++++++++++++------- app/src/toolbox.h | 3 +++ 2 files changed, 33 insertions(+), 7 deletions(-) diff --git a/app/src/toolbox.cpp b/app/src/toolbox.cpp index 5e6735d621..d03ea1e87e 100644 --- a/app/src/toolbox.cpp +++ b/app/src/toolbox.cpp @@ -137,8 +137,17 @@ void ToolBoxWidget::initUI() connect(editor()->layers(), &LayerManager::currentLayerChanged, this, &ToolBoxWidget::onLayerDidChange); + connect(this, &QDockWidget::dockLocationChanged, this, [=](Qt::DockWidgetArea area) { - FlowLayout* flowlayout = new FlowLayout(0,3,3); + mDockArea = area; + if (area == Qt::DockWidgetArea::TopDockWidgetArea || area == Qt::BottomDockWidgetArea) { + ui->scrollArea->setMinimumHeight(getMinHeightForWidth(width())); + } else { + ui->scrollArea->setMinimumHeight(1); + } + }); + + FlowLayout* flowlayout = new FlowLayout(3,3,3); flowlayout->addWidget(ui->pencilButton); flowlayout->addWidget(ui->eraserButton); @@ -154,16 +163,35 @@ void ToolBoxWidget::initUI() delete ui->scrollAreaWidgetContents_2->layout(); ui->scrollAreaWidgetContents_2->setLayout(flowlayout); - ui->scrollAreaWidgetContents_2->setContentsMargins(3,3,3,3); + ui->scrollAreaWidgetContents_2->setContentsMargins(0,0,0,0); + + setMinimumHeight(1); QSettings settings(PENCIL2D, PENCIL2D); restoreGeometry(settings.value("ToolBoxGeom").toByteArray()); + + ui->scrollArea->setMinimumHeight(getMinHeightForWidth(width())); } void ToolBoxWidget::updateUI() { } +void ToolBoxWidget::resizeEvent(QResizeEvent* event) +{ + BaseDockWidget::resizeEvent(event); + + setMinimumSize(QSize(layout()->minimumSize().width(), ui->scrollArea->minimumHeight())); +} + +int ToolBoxWidget::getMinHeightForWidth(int width) +{ + if (mDockArea != Qt::LeftDockWidgetArea && mDockArea != Qt::RightDockWidgetArea) { + return ui->scrollAreaWidgetContents_2->layout()->heightForWidth(width); + } + return BaseDockWidget::getMinHeightForWidth(width); +} + void ToolBoxWidget::onToolSetActive(ToolType toolType) { deselectAllTools(); @@ -266,11 +294,6 @@ void ToolBoxWidget::smudgeOn() toolOn(SMUDGE, ui->smudgeButton); } -int ToolBoxWidget::getMinHeightForWidth(int width) -{ - return ui->toolGroup->layout()->heightForWidth(width); -} - void ToolBoxWidget::deselectAllTools() { ui->pencilButton->setChecked(false); diff --git a/app/src/toolbox.h b/app/src/toolbox.h index e053988b2b..df31f2488f 100644 --- a/app/src/toolbox.h +++ b/app/src/toolbox.h @@ -60,12 +60,15 @@ public slots: protected: int getMinHeightForWidth(int width) override; + void resizeEvent(QResizeEvent* event) override; private: void deselectAllTools(); void toolOn(ToolType toolType, QToolButton* toolButton); Ui::ToolBoxWidget* ui = nullptr; + + Qt::DockWidgetArea mDockArea; }; #endif From 13bb720dcf0eb0b3aaf335ca65566f214933adbd Mon Sep 17 00:00:00 2001 From: MrStevns Date: Mon, 13 May 2024 20:01:55 +0200 Subject: [PATCH 08/13] Remove setting font specifically on widgets instead use qstylesheet and it might work better. --- app/src/basedockwidget.cpp | 2 ++ app/src/timelinepage.cpp | 2 ++ app/ui/bucketoptionswidget.ui | 43 +-------------------------------- app/ui/cameraoptionswidget.ui | 10 -------- app/ui/colorinspector.ui | 5 ---- app/ui/colorpalette.ui | 5 ---- app/ui/onionskin.ui | 45 ----------------------------------- app/ui/timelinepage.ui | 5 ---- app/ui/tooloptions.ui | 5 ---- 9 files changed, 5 insertions(+), 117 deletions(-) diff --git a/app/src/basedockwidget.cpp b/app/src/basedockwidget.cpp index d052dd1cc1..68032d50dd 100644 --- a/app/src/basedockwidget.cpp +++ b/app/src/basedockwidget.cpp @@ -35,6 +35,8 @@ BaseDockWidget::BaseDockWidget(QWidget* pParent) } #endif + setStyleSheet("QWidget { font-size: 11px } "); + } BaseDockWidget::~BaseDockWidget() diff --git a/app/src/timelinepage.cpp b/app/src/timelinepage.cpp index c25a901c68..aaebde3579 100644 --- a/app/src/timelinepage.cpp +++ b/app/src/timelinepage.cpp @@ -49,6 +49,8 @@ TimelinePage::TimelinePage() connect(ui->visibilitySlider, &QSlider::valueChanged, this, &TimelinePage::layerVisibilityThresholdChanged); connect(ui->visibilitySpinbox, spinBoxValueChange, this, &TimelinePage::layerVisibilityThresholdChanged); ui->visibilitySpinbox->setSuffix("%"); + + ui->labelAppliesTo->setStyleSheet("font-size: 10px"); } TimelinePage::~TimelinePage() diff --git a/app/ui/bucketoptionswidget.ui b/app/ui/bucketoptionswidget.ui index d894b36e0c..f3fd9c2554 100644 --- a/app/ui/bucketoptionswidget.ui +++ b/app/ui/bucketoptionswidget.ui @@ -16,11 +16,6 @@ 0 - - - 11 - - Form @@ -55,11 +50,6 @@ - - - 11 - - Reference @@ -73,11 +63,6 @@ 0 - - - 11 - - @@ -89,11 +74,6 @@ - - - 11 - - Blend mode @@ -107,11 +87,6 @@ 0 - - - 11 - - @@ -157,11 +132,6 @@ - - - 11 - - 0 @@ -169,11 +139,6 @@ - - - 11 - - 0 @@ -211,13 +176,7 @@ - - - - 11 - - - + diff --git a/app/ui/cameraoptionswidget.ui b/app/ui/cameraoptionswidget.ui index 691255fd92..092c75fb6e 100644 --- a/app/ui/cameraoptionswidget.ui +++ b/app/ui/cameraoptionswidget.ui @@ -16,11 +16,6 @@ 0 - - - 11 - - 0 @@ -36,11 +31,6 @@ - - - 11 - - Transform diff --git a/app/ui/colorinspector.ui b/app/ui/colorinspector.ui index 0807861df7..2140a289c6 100644 --- a/app/ui/colorinspector.ui +++ b/app/ui/colorinspector.ui @@ -23,11 +23,6 @@ 114 - - - 11 - - 3 diff --git a/app/ui/colorpalette.ui b/app/ui/colorpalette.ui index a458293e2e..1155562fdd 100644 --- a/app/ui/colorpalette.ui +++ b/app/ui/colorpalette.ui @@ -16,11 +16,6 @@ 132 - - - 11 - - Color Palette diff --git a/app/ui/onionskin.ui b/app/ui/onionskin.ui index e96d22a652..9694cfc12f 100644 --- a/app/ui/onionskin.ui +++ b/app/ui/onionskin.ui @@ -16,11 +16,6 @@ 122 - - - 11 - - false @@ -34,11 +29,6 @@ 0 - - - 11 - - 0 @@ -117,11 +107,6 @@ - - - 11 - - Previous Frames @@ -206,11 +191,6 @@ - - - 11 - - Next Frames @@ -307,11 +287,6 @@ - - - 11 - - Distributed Opacity @@ -357,11 +332,6 @@ 0 - - - 11 - - Max @@ -427,11 +397,6 @@ 0 - - - 11 - - Min @@ -481,11 +446,6 @@ - - - 11 - - Show Keyframes Only @@ -493,11 +453,6 @@ - - - 11 - - Show During Playback diff --git a/app/ui/timelinepage.ui b/app/ui/timelinepage.ui index bb67929173..90e3c72e20 100644 --- a/app/ui/timelinepage.ui +++ b/app/ui/timelinepage.ui @@ -126,11 +126,6 @@ - - - 10 - - <html><head/><body><p>(Applies to Pencil, Eraser, Pen, Polyline, Bucket and Brush tools)</p></body></html> diff --git a/app/ui/tooloptions.ui b/app/ui/tooloptions.ui index 645193bf86..e9744147b4 100644 --- a/app/ui/tooloptions.ui +++ b/app/ui/tooloptions.ui @@ -16,11 +16,6 @@ 0 - - - 11 - - Form From 7d7996e2b1b5ecb63521311fefad71bc8ed211f8 Mon Sep 17 00:00:00 2001 From: MrStevns Date: Thu, 16 May 2024 18:35:49 +0200 Subject: [PATCH 09/13] Revert font change --- app/src/basedockwidget.cpp | 3 --- 1 file changed, 3 deletions(-) diff --git a/app/src/basedockwidget.cpp b/app/src/basedockwidget.cpp index 68032d50dd..d2a47fbb80 100644 --- a/app/src/basedockwidget.cpp +++ b/app/src/basedockwidget.cpp @@ -34,9 +34,6 @@ BaseDockWidget::BaseDockWidget(QWidget* pParent) "border-width: 1px; }"); } #endif - - setStyleSheet("QWidget { font-size: 11px } "); - } BaseDockWidget::~BaseDockWidget() From 30df82d1fd4744123aa09fded855b6e3c3faa6fc Mon Sep 17 00:00:00 2001 From: MrStevns Date: Tue, 28 May 2024 08:00:32 +0200 Subject: [PATCH 10/13] Fix warning resize warning when height is less than zero --- app/src/toolbox.cpp | 2 ++ 1 file changed, 2 insertions(+) diff --git a/app/src/toolbox.cpp b/app/src/toolbox.cpp index d03ea1e87e..731ade4507 100644 --- a/app/src/toolbox.cpp +++ b/app/src/toolbox.cpp @@ -181,6 +181,8 @@ void ToolBoxWidget::resizeEvent(QResizeEvent* event) { BaseDockWidget::resizeEvent(event); + if (ui->scrollArea->minimumHeight() <= 0) { return; } + setMinimumSize(QSize(layout()->minimumSize().width(), ui->scrollArea->minimumHeight())); } From 97b69a9231da1602634d1ce41efb3ac6ae8d13a1 Mon Sep 17 00:00:00 2001 From: MrStevns Date: Wed, 24 Jul 2024 17:49:31 +0200 Subject: [PATCH 11/13] Remove fixed font size in timeline --- app/src/timelinepage.cpp | 2 -- 1 file changed, 2 deletions(-) diff --git a/app/src/timelinepage.cpp b/app/src/timelinepage.cpp index aaebde3579..c25a901c68 100644 --- a/app/src/timelinepage.cpp +++ b/app/src/timelinepage.cpp @@ -49,8 +49,6 @@ TimelinePage::TimelinePage() connect(ui->visibilitySlider, &QSlider::valueChanged, this, &TimelinePage::layerVisibilityThresholdChanged); connect(ui->visibilitySpinbox, spinBoxValueChange, this, &TimelinePage::layerVisibilityThresholdChanged); ui->visibilitySpinbox->setSuffix("%"); - - ui->labelAppliesTo->setStyleSheet("font-size: 10px"); } TimelinePage::~TimelinePage() From ed25a46b121885536726580d3069db2086b1774d Mon Sep 17 00:00:00 2001 From: MrStevns Date: Mon, 29 Jul 2024 19:34:02 +0200 Subject: [PATCH 12/13] Remove setMinimumHeight because dockLocationChanged is called afterwards Initially we'll also set a default dock value but as soon as the dock is added, it will be updated with the new dock location. --- app/src/toolbox.cpp | 4 +--- app/src/toolbox.h | 2 +- 2 files changed, 2 insertions(+), 4 deletions(-) diff --git a/app/src/toolbox.cpp b/app/src/toolbox.cpp index 731ade4507..c74da9b48a 100644 --- a/app/src/toolbox.cpp +++ b/app/src/toolbox.cpp @@ -169,8 +169,6 @@ void ToolBoxWidget::initUI() QSettings settings(PENCIL2D, PENCIL2D); restoreGeometry(settings.value("ToolBoxGeom").toByteArray()); - - ui->scrollArea->setMinimumHeight(getMinHeightForWidth(width())); } void ToolBoxWidget::updateUI() @@ -191,7 +189,7 @@ int ToolBoxWidget::getMinHeightForWidth(int width) if (mDockArea != Qt::LeftDockWidgetArea && mDockArea != Qt::RightDockWidgetArea) { return ui->scrollAreaWidgetContents_2->layout()->heightForWidth(width); } - return BaseDockWidget::getMinHeightForWidth(width); + return 1; } void ToolBoxWidget::onToolSetActive(ToolType toolType) diff --git a/app/src/toolbox.h b/app/src/toolbox.h index df31f2488f..f2e6c6ece7 100644 --- a/app/src/toolbox.h +++ b/app/src/toolbox.h @@ -68,7 +68,7 @@ public slots: Ui::ToolBoxWidget* ui = nullptr; - Qt::DockWidgetArea mDockArea; + Qt::DockWidgetArea mDockArea = Qt::DockWidgetArea::LeftDockWidgetArea; }; #endif From 80aedf8bc9e39c889cbe4b7f37d276e8595331dd Mon Sep 17 00:00:00 2001 From: Jakob Gahde Date: Sat, 3 Aug 2024 22:06:21 +0200 Subject: [PATCH 13/13] Consolidate BaseDockWidget/Toolbox minimum size handling --- app/src/basedockwidget.cpp | 25 ------------------------- app/src/basedockwidget.h | 5 ----- app/src/toolbox.cpp | 27 +++++++++------------------ app/src/toolbox.h | 3 --- 4 files changed, 9 insertions(+), 51 deletions(-) diff --git a/app/src/basedockwidget.cpp b/app/src/basedockwidget.cpp index d2a47fbb80..4d9cac3662 100644 --- a/app/src/basedockwidget.cpp +++ b/app/src/basedockwidget.cpp @@ -39,28 +39,3 @@ BaseDockWidget::BaseDockWidget(QWidget* pParent) BaseDockWidget::~BaseDockWidget() { } - -void BaseDockWidget::resizeEvent(QResizeEvent *event) -{ - QDockWidget::resizeEvent(event); - - // Not sure where the -2 comes from, but the event width is always 2 more than what is passed to FlowLayout::setGeometry - int minHeight = getMinHeightForWidth(event->size().width() - 2); - - if (minHeight < 0) return; - -#ifdef __APPLE__ - // For some reason the behavior of minimumSize and the margin changes on mac when floating, so we need to do this -#else - int top, bottom; - layout()->getContentsMargins(nullptr, &top, nullptr, &bottom); - minHeight += top + bottom; -#endif - setMinimumSize(QSize(layout()->minimumSize().width(), minHeight)); -} - -int BaseDockWidget::getMinHeightForWidth(int width) -{ - Q_UNUSED(width) - return -1; -} diff --git a/app/src/basedockwidget.h b/app/src/basedockwidget.h index ddc91c2a5d..2f4e349264 100644 --- a/app/src/basedockwidget.h +++ b/app/src/basedockwidget.h @@ -30,8 +30,6 @@ class BaseDockWidget : public QDockWidget explicit BaseDockWidget(QWidget* pParent); virtual ~BaseDockWidget(); - void resizeEvent(QResizeEvent *event) override; - public: virtual void initUI() = 0; virtual void updateUI() = 0; @@ -39,9 +37,6 @@ class BaseDockWidget : public QDockWidget Editor* editor() const { return mEditor; } void setEditor( Editor* e ) { mEditor = e; } -protected: - virtual int getMinHeightForWidth(int width); - private: Editor* mEditor = nullptr; }; diff --git a/app/src/toolbox.cpp b/app/src/toolbox.cpp index c74da9b48a..653172cff7 100644 --- a/app/src/toolbox.cpp +++ b/app/src/toolbox.cpp @@ -138,12 +138,13 @@ void ToolBoxWidget::initUI() connect(editor()->layers(), &LayerManager::currentLayerChanged, this, &ToolBoxWidget::onLayerDidChange); connect(this, &QDockWidget::dockLocationChanged, this, [=](Qt::DockWidgetArea area) { - - mDockArea = area; if (area == Qt::DockWidgetArea::TopDockWidgetArea || area == Qt::BottomDockWidgetArea) { - ui->scrollArea->setMinimumHeight(getMinHeightForWidth(width())); + const int minimumHeight = ui->scrollAreaWidgetContents_2->layout()->heightForWidth(width()); + ui->scrollArea->setMinimumHeight(minimumHeight); + setMinimumHeight(minimumHeight); } else { - ui->scrollArea->setMinimumHeight(1); + ui->scrollArea->setMinimumHeight(0); // Default value + // Don't set own minimum height and let Qt come up with a sensible value } }); @@ -165,8 +166,6 @@ void ToolBoxWidget::initUI() ui->scrollAreaWidgetContents_2->setLayout(flowlayout); ui->scrollAreaWidgetContents_2->setContentsMargins(0,0,0,0); - setMinimumHeight(1); - QSettings settings(PENCIL2D, PENCIL2D); restoreGeometry(settings.value("ToolBoxGeom").toByteArray()); } @@ -177,19 +176,11 @@ void ToolBoxWidget::updateUI() void ToolBoxWidget::resizeEvent(QResizeEvent* event) { - BaseDockWidget::resizeEvent(event); + QDockWidget::resizeEvent(event); - if (ui->scrollArea->minimumHeight() <= 0) { return; } - - setMinimumSize(QSize(layout()->minimumSize().width(), ui->scrollArea->minimumHeight())); -} - -int ToolBoxWidget::getMinHeightForWidth(int width) -{ - if (mDockArea != Qt::LeftDockWidgetArea && mDockArea != Qt::RightDockWidgetArea) { - return ui->scrollAreaWidgetContents_2->layout()->heightForWidth(width); - } - return 1; + const int minimumHeight = ui->scrollArea->minimumHeight(); + if (minimumHeight <= 0) { return; } + setMinimumHeight(minimumHeight); } void ToolBoxWidget::onToolSetActive(ToolType toolType) diff --git a/app/src/toolbox.h b/app/src/toolbox.h index f2e6c6ece7..617d9b07a1 100644 --- a/app/src/toolbox.h +++ b/app/src/toolbox.h @@ -59,7 +59,6 @@ public slots: void smudgeOn(); protected: - int getMinHeightForWidth(int width) override; void resizeEvent(QResizeEvent* event) override; private: @@ -67,8 +66,6 @@ public slots: void toolOn(ToolType toolType, QToolButton* toolButton); Ui::ToolBoxWidget* ui = nullptr; - - Qt::DockWidgetArea mDockArea = Qt::DockWidgetArea::LeftDockWidgetArea; }; #endif