Skip to content

Commit

Permalink
HiDPI: try to fix issues on Windows (part V)
Browse files Browse the repository at this point in the history
Cleanup and a hack.
  • Loading branch information
rodlie committed Aug 11, 2024
1 parent 1ada101 commit 4dbd221
Show file tree
Hide file tree
Showing 18 changed files with 51 additions and 98 deletions.
3 changes: 0 additions & 3 deletions src/app/GUI/ColorWidgets/colorsettingswidget.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -383,9 +383,6 @@ ColorSettingsWidget::ColorSettingsWidget(QWidget *parent)
this, &ColorSettingsWidget::startColorPicking);
eSizesUI::widget.add(mPickingButton, [this](const int size) {
mPickingButton->setFixedSize(size, size);
//if (eSettings::instance().fCurrentInterfaceDPI != 1.) {
//mPickingButton->setIconSize(QSize(size, size));
//}
});

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

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

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

Expand Down
5 changes: 0 additions & 5 deletions src/app/GUI/RenderWidgets/renderinstancewidget.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -182,11 +182,6 @@ void RenderInstanceWidget::iniGUI() {
mOutputDestinationButton->setFixedSize(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
6 changes: 0 additions & 6 deletions src/app/GUI/RenderWidgets/renderwidget.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -122,12 +122,6 @@ RenderWidget::RenderWidget(QWidget *parent)
mStopRenderButton->setFixedHeight(size);
mAddRenderButton->setFixedHeight(size);
mClearQueueButton->setFixedHeight(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
8 changes: 4 additions & 4 deletions src/app/GUI/Settings/pluginssettingswidget.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -61,10 +61,10 @@ PluginsSettingsWidget::PluginsSettingsWidget(QWidget *parent)
this);
mShaderPathButton->setObjectName("FlatButton");
mShaderPathButton->setFocusPolicy(Qt::NoFocus);
if (eSettings::instance().fCurrentInterfaceDPI != 1.) {
mShaderPathButton->setIconSize(QSize(eSizesUI::widget, eSizesUI::widget));
}
mShaderPathButton->setFixedSize(QSize(eSizesUI::widget, eSizesUI::widget));

eSizesUI::widget.add(mShaderPathButton, [mShaderPathButton](const int size) {
mShaderPathButton->setFixedSize(size, size);
});

mShaderLayout->addWidget(mShaderLabel);
mShaderLayout->addWidget(mShaderPath);
Expand Down
12 changes: 7 additions & 5 deletions src/app/GUI/Settings/settingsdialog.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -70,11 +70,13 @@ SettingsDialog::SettingsDialog(QWidget * const parent)
buttonsLayout->addWidget(applyButton);
buttonsLayout->addWidget(cancelButton);

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));
}
eSizesUI::widget.add(restoreButton, [restoreButton,
applyButton,
cancelButton](const int size) {
restoreButton->setFixedHeight(size);
cancelButton->setFixedHeight(size);
applyButton->setFixedHeight(size);
});

mainLayout->addLayout(buttonsLayout);
const auto statusBar = new QStatusBar(this);
Expand Down
15 changes: 0 additions & 15 deletions src/app/GUI/fillstrokesettings.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -269,21 +269,6 @@ FillStrokeSettingsWidget::FillStrokeSettingsWidget(Document &document,
mFillGradientButton->setFixedHeight(size);
mLinearGradientButton->setFixedHeight(size);
mRadialGradientButton->setFixedHeight(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));
mFillTargetButton->setIconSize(QSize(size, size));
mStrokeTargetButton->setIconSize(QSize(size, size));
mFillNoneButton->setIconSize(QSize(size, size));
mFillFlatButton->setIconSize(QSize(size, size));
mFillGradientButton->setIconSize(QSize(size, size));
mLinearGradientButton->setIconSize(QSize(size, size));
mRadialGradientButton->setIconSize(QSize(size, size));
}*/
});

// layout
Expand Down
8 changes: 0 additions & 8 deletions src/app/GUI/fontswidget.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -166,14 +166,6 @@ FontsWidget::FontsWidget(QWidget *parent)
mAlignTop->setFixedHeight(size);
mAlignVCenter->setFixedHeight(size);
mAlignBottom->setFixedHeight(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
6 changes: 0 additions & 6 deletions src/app/GUI/layouthandler.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -55,9 +55,6 @@ LayoutHandler::LayoutHandler(Document& document,
newLayPush->setObjectName("FlatButton");
eSizesUI::widget.add(newLayPush, [newLayPush](const int size) {
newLayPush->setFixedSize(QSize(size, size));
/*if (eSettings::instance().fCurrentInterfaceDPI != 1.) {
newLayPush->setIconSize(QSize(size, size));
}*/
});
//newLayPush->setSizePolicy(QSizePolicy::Fixed, QSizePolicy::Minimum);

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

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

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

const auto propertiesWidget = new QWidget(this);
Expand Down Expand Up @@ -1280,9 +1276,6 @@ void MainWindow::setupMenuBar()
const auto frictionButton = new QToolButton(this);
frictionButton->setObjectName(QString::fromUtf8("ToolButton"));
frictionButton->setPopupMode(QToolButton::InstantPopup);
/*if (eSettings::instance().fCurrentInterfaceDPI != 1.) {
frictionButton->setIconSize(QSize(eSizesUI::widget, eSizesUI::widget));
}*/
frictionButton->setIcon(QIcon::fromTheme(AppSupport::getAppID()));
frictionButton->setDefaultAction(aboutAct);
frictionButton->setToolTip(QString());
Expand Down Expand Up @@ -1474,9 +1467,7 @@ void MainWindow::setupToolBar()
mToolbar->setToolButtonStyle(Qt::ToolButtonTextBesideIcon);
mToolbar->setMovable(false);
eSizesUI::widget.add(mToolbar, [this](const int size) {
//if (eSettings::instance().fCurrentInterfaceDPI != 1.) {
mToolbar->setIconSize(QSize(size, size));
//}
mToolbar->setIconSize(QSize(size, size));
});
addToolBar(mToolbar);

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

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

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

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

mToolBoxMainIndex = mToolBoxStack->addWidget(mToolBoxMain);
Expand Down
8 changes: 5 additions & 3 deletions src/app/friction.qss
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,8 @@ Colors and icon size from 'src/core/themesupport.cpp'.
%8 = getThemeColorOrange
%9 = getThemeRangeSelectedColor
%10 = half icon size
%11 = icon pixel ratio
%12 = half icon pixel ratio

*/

Expand Down Expand Up @@ -61,13 +63,13 @@ QSpinBox::down-button {
}
QDoubleSpinBox::up-arrow,
QSpinBox::up-arrow {
image: url(:/icons/hicolor/scalable/actions/go-up.svg);
image: url(:/icons/hicolor/scalable/actions/go-up.svg); /* half */
width: %10px;
height: %10px;
}
QDoubleSpinBox::down-arrow,
QSpinBox::down-arrow {
image: url(:/icons/hicolor/scalable/actions/go-down.svg);
image: url(:/icons/hicolor/scalable/actions/go-down.svg); /* half */
width: %10px;
height: %10px;
}
Expand Down Expand Up @@ -227,7 +229,7 @@ QComboBox::drop-down:button{

QToolButton::menu-arrow,
QComboBox::down-arrow {
image: url(:/icons/hicolor/scalable/actions/go-down.svg);
image: url(:/icons/hicolor/scalable/actions/go-down.svg); /* full */
width: %7px;
height: %7px;
}
Expand Down
21 changes: 20 additions & 1 deletion src/core/themesupport.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,7 @@
#include <QIcon>
#include <QApplication>
#include <QDebug>
#include <QDesktopWidget>

const QColor ThemeSupport::getQColor(int r,
int g,
Expand Down Expand Up @@ -191,6 +192,22 @@ const QString ThemeSupport::getThemeStyle(int iconSize)
css = stylesheet.readAll();
stylesheet.close();
}
#ifdef Q_OS_WIN
// svg in qss on windows are broken!
css.replace("/scalable/actions/go-up.svg); /* half */",
"/%12x%12/actions/go-up.png);");
css.replace("/scalable/actions/go-up.svg); /* full */",
"/%12x%12/actions/go-up.png);");
css.replace("/scalable/actions/go-down.svg); /* half */",
"/%12x%12/actions/go-down.png);");
css.replace("/scalable/actions/go-down.svg); /* full */",
"/%12x%12/actions/go-down.png);");
css.replace("/scalable/actions/dialog-ok.svg",
"/%11x%11/actions/dialog-ok.png");
css.replace("/scalable/actions/dialog-cancel.svg",
"/%11x%11/actions/dialog-cancel.png");
#endif
const qreal iconPixelRatio = iconSize * qApp->desktop()->devicePixelRatioF();
return css.arg(getThemeButtonBaseColor().name(),
getThemeButtonBorderColor().name(),
getThemeBaseDarkerColor().name(),
Expand All @@ -200,7 +217,9 @@ const QString ThemeSupport::getThemeStyle(int iconSize)
QString::number(getIconSize(iconSize).width()),
getThemeColorOrange().name(),
getThemeRangeSelectedColor().name(),
QString::number(getIconSize(iconSize / 2).width()));
QString::number(getIconSize(iconSize / 2).width()),
QString::number(getIconSize(qRound(iconPixelRatio)).width()),
QString::number(getIconSize(qRound(iconPixelRatio / 2)).width()));
}

void ThemeSupport::setupTheme(const int iconSize)
Expand Down
8 changes: 0 additions & 8 deletions src/ui/widgets/alignwidget.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -132,14 +132,6 @@ AlignWidget::AlignWidget(QWidget* const parent)
topButton->setFixedHeight(size);
vCenterButton->setFixedHeight(size);
bottomButton->setFixedHeight(size);
/*if (eSettings::instance().fCurrentInterfaceDPI != 1.) {
leftButton->setIconSize(QSize(size, size));
hCenterButton->setIconSize(QSize(size, size));
rightButton->setIconSize(QSize(size, size));
topButton->setIconSize(QSize(size, size));
vCenterButton->setIconSize(QSize(size, size));
bottomButton->setIconSize(QSize(size, size));
}*/
});
}

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

Expand Down
3 changes: 0 additions & 3 deletions src/ui/widgets/fakemenubar.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -39,9 +39,6 @@ class QActionButton : public QPushButton {
QPushButton(parent) {
eSizesUI::widget.add(this, [this](const int size) {
setFixedHeight(size);
/*if (eSettings::instance().fCurrentInterfaceDPI != 1.) {
setIconSize(QSize(size, size));
}*/
});
//setSizePolicy(QSizePolicy::Fixed, QSizePolicy::Fixed);
setObjectName("QActionButton");
Expand Down

0 comments on commit 4dbd221

Please sign in to comment.