Skip to content

Commit

Permalink
Fix HiDPI #68
Browse files Browse the repository at this point in the history
  • Loading branch information
rodlie committed Sep 10, 2023
1 parent 9eb1559 commit e6de2d8
Show file tree
Hide file tree
Showing 7 changed files with 2,297 additions and 18 deletions.
4 changes: 2 additions & 2 deletions src/app/GUI/GradientWidgets/gradientslistwidget.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -51,9 +51,9 @@ void GradientsListWidget::resizeEvent(QResizeEvent *e) {
const QSize size = e->size();
mDisplayedGradients->setMinimumHeight(size.height());
mDisplayedGradients->updateHeight();
const int scrollBarWidth = verticalScrollBar()->width();
/*const int scrollBarWidth = verticalScrollBar()->width();
const int availableWidth = size.width() - scrollBarWidth;
mDisplayedGradients->setFixedWidth(availableWidth);
mDisplayedGradients->setFixedWidth(availableWidth);*/
}

void GradientsListWidget::showEvent(QShowEvent *e) {
Expand Down
6 changes: 5 additions & 1 deletion src/app/GUI/alignwidget.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,8 @@
#include <QHBoxLayout>
#include <QPushButton>

#include "GUI/global.h"

AlignWidget::AlignWidget(QWidget* const parent)
: QWidget(parent)
, mAlignPivot(nullptr)
Expand All @@ -47,13 +49,15 @@ AlignWidget::AlignWidget(QWidget* const parent)

combosLay->addWidget(new QLabel(tr("Align")));
mAlignPivot = new QComboBox(this);
mAlignPivot->setSizePolicy(QSizePolicy::Preferred, QSizePolicy::Expanding);
mAlignPivot->setFocusPolicy(Qt::NoFocus);
mAlignPivot->addItem(tr("Geometry"));
mAlignPivot->addItem(tr("Pivot"));
combosLay->addWidget(mAlignPivot);

combosLay->addWidget(new QLabel(tr("Relative to")));
mRelativeTo = new QComboBox(this);
mRelativeTo->setSizePolicy(QSizePolicy::Preferred, QSizePolicy::Expanding);
mRelativeTo->setFocusPolicy(Qt::NoFocus);
mRelativeTo->addItem(tr("Scene"));
mRelativeTo->addItem(tr("Last Selected"));
Expand All @@ -63,7 +67,7 @@ AlignWidget::AlignWidget(QWidget* const parent)
mainLayout->addLayout(buttonsLay);
mainLayout->addStretch();

int buttonSize = 20;
int buttonSize = eSizesUI::button;

const auto leftButton = new QPushButton(this);
leftButton->setFocusPolicy(Qt::NoFocus);
Expand Down
6 changes: 0 additions & 6 deletions src/app/GUI/timelinedockwidget.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -82,10 +82,6 @@ TimelineDockWidget::TimelineDockWidget(Document& document,
mMainLayout->setSpacing(0);
mMainLayout->setMargin(0);

const QSize iconSize(AppSupport::getSettings("ui",
"timelineToolbarIconSize",
QSize(24, 24)).toSize());

mFrameRewindAct = new QAction(QIcon::fromTheme("rewind"),
tr("Rewind"),
this);
Expand Down Expand Up @@ -203,8 +199,6 @@ TimelineDockWidget::TimelineDockWidget(Document& document,
mToolBar = new QToolBar(this);
mToolBar->setMovable(false);

mToolBar->setIconSize(iconSize);

mRenderProgress = new QProgressBar(this);
mRenderProgress->setSizePolicy(QSizePolicy::Preferred,
QSizePolicy::Preferred);
Expand Down
13 changes: 9 additions & 4 deletions src/app/friction.qss
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,8 @@ QToolBar#ViewerDrawBar,

QComboBox#blendModeCombo,
QWidget#menuBarWidget QPushButton,
QLineEdit#SearchLine {
QLineEdit#SearchLine,
AlignWidget QComboBox {
background-color: rgb(23, 23, 28);
}

Expand Down Expand Up @@ -96,13 +97,17 @@ QToolButton#WelcomeOpenButton:hover {

QToolButton#WelcomeOpenButton::menu-button {
padding-right: 0.5em;
border-top-right: 2px solid #ebebeb;
border-bottom-right: 2px solid #ebebeb;
border-top-right-radius: 10%;
border-bottom-right-radius: 10%;
color: #ebebeb;
}

QToolButton#WelcomeOpenButton[popupMode="1"] {
padding-right: 0.5em;
padding-right: 1em;
}

AlignWidget QPushButton {
background-color: none;
border: 0;
border-radius: 10%;
}
11 changes: 7 additions & 4 deletions src/app/main.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@
#include <QApplication>
#include <QSurfaceFormat>
#include <QProcess>
#include <QDesktopWidget>

#include "hardwareinfo.h"
#include "Private/esettings.h"
Expand Down Expand Up @@ -149,15 +150,17 @@ int main(int argc, char *argv[])
HardwareInfo::sGpuVendor());

OS_FONT = QApplication::font();
eSizesUI::font.setEvaluator([/*&settings*/]() {
eSizesUI::font.setEvaluator([]() {
double dpi = (qApp->desktop()->logicalDpiX() / 96.0);
qDebug() << "DPI" << dpi;
const auto fm = QFontMetrics(OS_FONT);
const qreal scaling = qBound(0.5, /*settings.fInterfaceScaling*/1.0, 1.5);
const qreal scaling = qBound(0.5, dpi, 1.5);
return qRound(fm.height()*scaling);
});
eSizesUI::widget.setEvaluator([]() {
return eSizesUI::font.size()*4/3;
});
/*QObject::connect(&eSizesUI::font, &SizeSetter::sizeChanged,
QObject::connect(&eSizesUI::font, &SizeSetter::sizeChanged,
&eSizesUI::widget, &SizeSetter::updateSize);
eSizesUI::font.add(&app, [&app](const int size) {
const auto fm = QFontMetrics(OS_FONT);
Expand All @@ -169,7 +172,7 @@ int main(int argc, char *argv[])
font.setPixelSize(qRound(mult*OS_FONT.pixelSize()));
}
app.setFont(font);
});*/
});

eSizesUI::widget.add(&eSizesUI::button, [](const int size) {
eSizesUI::button.set(qRound(size*1.1));
Expand Down
2 changes: 1 addition & 1 deletion src/patches/qt/README.md
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
# Qt 5.12.12 patches

Patches used in releases of Friction.
Patches used in Windows releases of Friction.

Loading

0 comments on commit e6de2d8

Please sign in to comment.