Skip to content

Commit

Permalink
Try to fix icon sizes (again)
Browse files Browse the repository at this point in the history
Only apply icon size if dpi not 1.

Icons looks good with no scaling again, and should in theory work in hidpi (not tested).
  • Loading branch information
rodlie committed Apr 9, 2024
1 parent eea2623 commit 8f3eebd
Show file tree
Hide file tree
Showing 18 changed files with 94 additions and 47 deletions.
4 changes: 3 additions & 1 deletion src/app/GUI/ColorWidgets/colorsettingswidget.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -369,7 +369,9 @@ ColorSettingsWidget::ColorSettingsWidget(QWidget *parent)
this, &ColorSettingsWidget::startColorPicking);
eSizesUI::widget.add(mPickingButton, [this](const int size) {
mPickingButton->setFixedHeight(size);
mPickingButton->setIconSize(QSize(size, size));
if (eSettings::instance().fCurrentInterfaceDPI != 1.) {
mPickingButton->setIconSize(QSize(size, size));
}
});

mColorLabelLayout->addWidget(mColorLabel);
Expand Down
6 changes: 4 additions & 2 deletions src/app/GUI/Expressions/expressiondialog.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -593,8 +593,10 @@ ExpressionDialog::ExpressionDialog(QrealAnimator* const target,
updateAllScript();

const int pixSize = eSizesUI::widget/2;
mBindingsButton->setIconSize({pixSize, pixSize});
mDefinitionsButon->setIconSize({pixSize, pixSize});
if (eSettings::instance().fCurrentInterfaceDPI != 1.) {
mBindingsButton->setIconSize({pixSize, pixSize});
mDefinitionsButon->setIconSize({pixSize, pixSize});
}

QPixmap pix(pixSize, pixSize);
pix.fill(Qt::transparent);
Expand Down
4 changes: 3 additions & 1 deletion src/app/GUI/RenderWidgets/closablecontainer.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,9 @@ ClosableContainer::ClosableContainer(QWidget *parent) : QWidget(parent) {
mContentArrow->setObjectName("FlatButton");
mContentArrow->setCheckable(true);
mContentArrow->setFixedSize(eSizesUI::widget, eSizesUI::widget);
mContentArrow->setIconSize(QSize(eSizesUI::widget, eSizesUI::widget));
if (eSettings::instance().fCurrentInterfaceDPI != 1.) {
mContentArrow->setIconSize(QSize(eSizesUI::widget, eSizesUI::widget));
}
connect(mContentArrow, &QPushButton::toggled,
this, &ClosableContainer::setContentVisible);

Expand Down
8 changes: 5 additions & 3 deletions src/app/GUI/RenderWidgets/renderinstancewidget.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -178,13 +178,15 @@ void RenderInstanceWidget::iniGUI() {
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);
if (eSettings::instance().fCurrentInterfaceDPI != 1.) {
mOutputSettingsProfilesButton->setIconSize(QSize(size, size));
mOutputDestinationButton->setIconSize(QSize(size, size));
mPlayButton->setIconSize(QSize(size, size));
}
});

QWidget *outputDestinationWidget = new QWidget(this);
Expand Down
10 changes: 6 additions & 4 deletions src/app/GUI/RenderWidgets/renderwidget.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -115,14 +115,16 @@ RenderWidget::RenderWidget(QWidget *parent)
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));
if (eSettings::instance().fCurrentInterfaceDPI != 1.) {
mStartRenderButton->setIconSize(QSize(size, size));
mStopRenderButton->setIconSize(QSize(size, size));
mAddRenderButton->setIconSize(QSize(size, size));
mClearQueueButton->setIconSize(QSize(size, size));
}
});

mContWidget = new QWidget(this);
Expand Down
5 changes: 4 additions & 1 deletion src/app/GUI/Settings/pluginssettingswidget.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,7 @@
#include <QHeaderView>

#include "GUI/global.h"
#include "Private/esettings.h"

PluginsSettingsWidget::PluginsSettingsWidget(QWidget *parent)
: SettingsWidget(parent)
Expand All @@ -60,7 +61,9 @@ PluginsSettingsWidget::PluginsSettingsWidget(QWidget *parent)
this);
mShaderPathButton->setObjectName("FlatButton");
mShaderPathButton->setFocusPolicy(Qt::NoFocus);
mShaderPathButton->setIconSize(QSize(eSizesUI::widget, eSizesUI::widget));
if (eSettings::instance().fCurrentInterfaceDPI != 1.) {
mShaderPathButton->setIconSize(QSize(eSizesUI::widget, eSizesUI::widget));
}
mShaderPathButton->setFixedSize(QSize(eSizesUI::widget, eSizesUI::widget));

mShaderLayout->addWidget(mShaderLabel);
Expand Down
9 changes: 6 additions & 3 deletions src/app/GUI/Settings/settingsdialog.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -73,13 +73,16 @@ 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);

if (eSettings::instance().fCurrentInterfaceDPI != 1.) {
restoreButton->setIconSize(QSize(eSizesUI::widget, eSizesUI::widget));
cancelButton->setIconSize(QSize(eSizesUI::widget, eSizesUI::widget));
applyButton->setIconSize(QSize(eSizesUI::widget, eSizesUI::widget));
}

mainLayout->addLayout(buttonsLayout);
const auto statusBar = new QStatusBar(this);
statusBar->setSizeGripEnabled(false);
Expand Down
14 changes: 8 additions & 6 deletions src/app/GUI/fillstrokesettings.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -266,17 +266,19 @@ FillStrokeSettingsWidget::FillStrokeSettingsWidget(Document &document,
// adjust sizes
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));
if (eSettings::instance().fCurrentInterfaceDPI != 1.) {
mBevelJoinStyleButton->setIconSize(QSize(size, size));
mMiterJointStyleButton->setIconSize(QSize(size, size));
mRoundJoinStyleButton->setIconSize(QSize(size, size));
mFlatCapStyleButton->setIconSize(QSize(size, size));
mSquareCapStyleButton->setIconSize(QSize(size, size));
mRoundCapStyleButton->setIconSize(QSize(size, size));
}
});

// layout
Expand Down
14 changes: 8 additions & 6 deletions src/app/GUI/fontswidget.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -158,17 +158,19 @@ FontsWidget::FontsWidget(QWidget *parent)

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));
if (eSettings::instance().fCurrentInterfaceDPI != 1.) {
mAlignLeft->setIconSize(QSize(size, size));
mAlignCenter->setIconSize(QSize(size, size));
mAlignRight->setIconSize(QSize(size, size));
mAlignTop->setIconSize(QSize(size, size));
mAlignVCenter->setIconSize(QSize(size, size));
mAlignBottom->setIconSize(QSize(size, size));
}
});

mTextInput = new QPlainTextEdit(this);
Expand Down
8 changes: 6 additions & 2 deletions src/app/GUI/layouthandler.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,9 @@ LayoutHandler::LayoutHandler(Document& document,
newLayPush->setObjectName("FlatButton");
eSizesUI::widget.add(newLayPush, [newLayPush](const int size) {
newLayPush->setFixedSize(QSize(size, size));
newLayPush->setIconSize(QSize(size, size));
if (eSettings::instance().fCurrentInterfaceDPI != 1.) {
newLayPush->setIconSize(QSize(size, size));
}
});
//newLayPush->setSizePolicy(QSizePolicy::Fixed, QSizePolicy::Minimum);

Expand All @@ -65,7 +67,9 @@ LayoutHandler::LayoutHandler(Document& document,
removeLayPush->setObjectName("FlatButton");
eSizesUI::widget.add(removeLayPush, [removeLayPush](const int size) {
removeLayPush->setFixedSize(QSize(size, size));
removeLayPush->setIconSize(QSize(size, size));
if (eSettings::instance().fCurrentInterfaceDPI != 1.) {
removeLayPush->setIconSize(QSize(size, size));
}
});
//removeLayPush->setSizePolicy(QSizePolicy::Fixed, QSizePolicy::Minimum);

Expand Down
16 changes: 12 additions & 4 deletions src/app/GUI/mainwindow.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -309,7 +309,9 @@ MainWindow::MainWindow(Document& document,
mTabColorText->setMinimumWidth(sideBarMin);
mTabColorText->setTabPosition(QTabWidget::South);
eSizesUI::widget.add(mTabColorText, [this](const int size) {
mTabColorText->setIconSize(QSize(size, size));
if (eSettings::instance().fCurrentInterfaceDPI != 1.) {
mTabColorText->setIconSize(QSize(size, size));
}
});

mTabColorIndex = mTabColorText->addTab(mFillStrokeSettings,
Expand All @@ -326,7 +328,9 @@ MainWindow::MainWindow(Document& document,
mTabProperties->setMinimumWidth(sideBarMin);
mTabProperties->setTabPosition(QTabWidget::South);
eSizesUI::widget.add(mTabProperties, [this](const int size) {
mTabProperties->setIconSize(QSize(size, size));
if (eSettings::instance().fCurrentInterfaceDPI != 1.) {
mTabProperties->setIconSize(QSize(size, size));
}
});

const auto propertiesWidget = new QWidget(this);
Expand Down Expand Up @@ -1150,7 +1154,9 @@ 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));
if (eSettings::instance().fCurrentInterfaceDPI != 1.) {
frictionButton->setIconSize(QSize(eSizesUI::widget, eSizesUI::widget));
}
frictionButton->setIcon(QIcon::fromTheme("friction"));
frictionButton->setDefaultAction(aboutAct);
frictionButton->setToolTip(QString());
Expand Down Expand Up @@ -1293,7 +1299,9 @@ void MainWindow::setupToolBar()
mToolbar->setToolButtonStyle(Qt::ToolButtonTextBesideIcon);
mToolbar->setMovable(false);
eSizesUI::widget.add(mToolbar, [this](const int size) {
mToolbar->setIconSize(QSize(size, size));
if (eSettings::instance().fCurrentInterfaceDPI != 1.) {
mToolbar->setIconSize(QSize(size, size));
}
});
addToolBar(mToolbar);

Expand Down
4 changes: 3 additions & 1 deletion src/app/GUI/timelinedockwidget.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -222,7 +222,9 @@ TimelineDockWidget::TimelineDockWidget(Document& document,

mToolBar = new QToolBar(this);
eSizesUI::widget.add(mToolBar, [this](const int size) {
mToolBar->setIconSize(QSize(size, size));
if (eSettings::instance().fCurrentInterfaceDPI != 1.) {
mToolBar->setIconSize(QSize(size, size));
}
});
mToolBar->setMovable(false);

Expand Down
8 changes: 5 additions & 3 deletions src/app/GUI/toolbox.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -39,9 +39,11 @@ void MainWindow::setupToolBox()
setupToolBoxDraw();

eSizesUI::widget.add(mToolBoxMain, [this](const int size) {
mToolBoxMain->setIconSize(QSize(size, size));
mToolBoxNodes->setIconSize(QSize(size, size));
mToolBoxDraw->setIconSize(QSize(size, size));
if (eSettings::instance().fCurrentInterfaceDPI != 1.) {
mToolBoxMain->setIconSize(QSize(size, size));
mToolBoxNodes->setIconSize(QSize(size, size));
mToolBoxDraw->setIconSize(QSize(size, size));
}
});

mToolBoxMainIndex = mToolBoxStack->addWidget(mToolBoxMain);
Expand Down
1 change: 1 addition & 0 deletions src/app/main.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -152,6 +152,7 @@ int main(int argc, char *argv[])
} else {
dpi = qApp->desktop()->logicalDpiX() / 96.0; //QGuiApplication::primaryScreen()->logicalDotsPerInch() / 96.0
}
settings.fCurrentInterfaceDPI = dpi;
qDebug() << "DPI" << dpi;
const auto fm = QFontMetrics(OS_FONT);
const qreal scaling = qBound(0.5, dpi, 1.5);
Expand Down
1 change: 1 addition & 0 deletions src/core/Private/esettings.h
Original file line number Diff line number Diff line change
Expand Up @@ -100,6 +100,7 @@ class CORE_EXPORT eSettings : public QObject

// ui settings
qreal fInterfaceScaling;
qreal fCurrentInterfaceDPI;
bool fDefaultInterfaceScaling;

// canvas settings
Expand Down
19 changes: 11 additions & 8 deletions src/ui/widgets/alignwidget.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,7 @@
#include <QPushButton>

#include "GUI/global.h"
#include "Private/esettings.h"

AlignWidget::AlignWidget(QWidget* const parent)
: QWidget(parent)
Expand Down Expand Up @@ -67,12 +68,9 @@ AlignWidget::AlignWidget(QWidget* const parent)
mainLayout->addLayout(buttonsLay);
mainLayout->addStretch();

int buttonSize = eSizesUI::widget;

const auto leftButton = new QPushButton(this);
leftButton->setFocusPolicy(Qt::NoFocus);
leftButton->setIcon(QIcon::fromTheme("pivot-align-left"));
leftButton->setIconSize(QSize(buttonSize, buttonSize));
leftButton->setToolTip(tr("Align Left"));
connect(leftButton, &QPushButton::pressed, this, [this]() {
triggerAlign(Qt::AlignLeft);
Expand All @@ -82,7 +80,6 @@ AlignWidget::AlignWidget(QWidget* const parent)
const auto hCenterButton = new QPushButton(this);
hCenterButton->setFocusPolicy(Qt::NoFocus);
hCenterButton->setIcon(QIcon::fromTheme("pivot-align-hcenter"));
hCenterButton->setIconSize(QSize(buttonSize, buttonSize));
hCenterButton->setToolTip(tr("Align Horizontal Center"));
connect(hCenterButton, &QPushButton::pressed, this, [this]() {
triggerAlign(Qt::AlignHCenter);
Expand All @@ -92,7 +89,6 @@ AlignWidget::AlignWidget(QWidget* const parent)
const auto rightButton = new QPushButton(this);
rightButton->setFocusPolicy(Qt::NoFocus);
rightButton->setIcon(QIcon::fromTheme("pivot-align-right"));
rightButton->setIconSize(QSize(buttonSize, buttonSize));
rightButton->setToolTip(tr("Align Right"));
connect(rightButton, &QPushButton::pressed, this, [this]() {
triggerAlign(Qt::AlignRight);
Expand All @@ -102,7 +98,6 @@ AlignWidget::AlignWidget(QWidget* const parent)
const auto topButton = new QPushButton(this);
topButton->setFocusPolicy(Qt::NoFocus);
topButton->setIcon(QIcon::fromTheme("pivot-align-top"));
topButton->setIconSize(QSize(buttonSize, buttonSize));
topButton->setToolTip(tr("Align Top"));
connect(topButton, &QPushButton::pressed, this, [this]() {
triggerAlign(Qt::AlignTop);
Expand All @@ -112,7 +107,6 @@ AlignWidget::AlignWidget(QWidget* const parent)
const auto vCenterButton = new QPushButton(this);
vCenterButton->setFocusPolicy(Qt::NoFocus);
vCenterButton->setIcon(QIcon::fromTheme("pivot-align-vcenter"));
vCenterButton->setIconSize(QSize(buttonSize, buttonSize));
vCenterButton->setToolTip(tr("Align Vertical Center"));
connect(vCenterButton, &QPushButton::pressed, this, [this]() {
triggerAlign(Qt::AlignVCenter);
Expand All @@ -122,12 +116,21 @@ AlignWidget::AlignWidget(QWidget* const parent)
const auto bottomButton = new QPushButton(this);
bottomButton->setFocusPolicy(Qt::NoFocus);
bottomButton->setIcon(QIcon::fromTheme("pivot-align-bottom"));
bottomButton->setIconSize(QSize(buttonSize, buttonSize));
bottomButton->setToolTip(tr("Align Bottom"));
connect(bottomButton, &QPushButton::pressed, this, [this]() {
triggerAlign(Qt::AlignBottom);
});
buttonsLay->addWidget(bottomButton);

if (eSettings::instance().fCurrentInterfaceDPI != 1.) {
int buttonSize = eSizesUI::widget;
leftButton->setIconSize(QSize(buttonSize, buttonSize));
hCenterButton->setIconSize(QSize(buttonSize, buttonSize));
rightButton->setIconSize(QSize(buttonSize, buttonSize));
topButton->setIconSize(QSize(buttonSize, buttonSize));
vCenterButton->setIconSize(QSize(buttonSize, buttonSize));
bottomButton->setIconSize(QSize(buttonSize, buttonSize));
}
}

void AlignWidget::triggerAlign(const Qt::Alignment align)
Expand Down
4 changes: 3 additions & 1 deletion src/ui/widgets/assetswidget.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,9 @@ AssetsTreeWidget::AssetsTreeWidget(QWidget *parent)
header()->setStretchLastSection(true);
setContextMenuPolicy(Qt::CustomContextMenu);
eSizesUI::widget.add(this, [this](const int size) {
setIconSize(QSize(size, size));
if (eSettings::instance().fCurrentInterfaceDPI != 1.) {
setIconSize(QSize(size, size));
}
});
}

Expand Down
6 changes: 5 additions & 1 deletion src/ui/widgets/fakemenubar.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -31,13 +31,17 @@
#include <QPushButton>
#include <QFrame>

#include "Private/esettings.h"

class QActionButton : public QPushButton {
public:
explicit QActionButton(QWidget *parent = nullptr) :
QPushButton(parent) {
eSizesUI::widget.add(this, [this](const int size) {
setFixedHeight(size);
//setIconSize(QSize(size, size));
if (eSettings::instance().fCurrentInterfaceDPI != 1.) {
setIconSize(QSize(size, size));
}
});
//setSizePolicy(QSizePolicy::Fixed, QSizePolicy::Fixed);
setObjectName("QActionButton");
Expand Down

0 comments on commit 8f3eebd

Please sign in to comment.