-
-
Notifications
You must be signed in to change notification settings - Fork 1.1k
Refactor gui_templates.h
#7159
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Refactor gui_templates.h
#7159
Changes from 4 commits
44c95f8
63799cc
2945a6c
832cf78
137b5d5
296583e
76cf4a7
9513333
1f2cba0
9ce2993
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -31,37 +31,27 @@ | |
| #include <QFont> | ||
| #include <QDesktopWidget> | ||
|
|
||
| // TODO: cleanup for qt6 | ||
| #if (QT_VERSION < QT_VERSION_CHECK(6,0,0)) | ||
| #include <QScreen> | ||
| #else | ||
| #include <QGuiApplication> | ||
| #endif | ||
|
|
||
| namespace lmms | ||
| { | ||
|
|
||
|
|
||
| // return DPI-independent font-size - font with returned font-size has always | ||
| // the same size in pixels | ||
| template<int SIZE> | ||
| inline QFont pointSize( QFont _f ) | ||
| template<typename T> | ||
| inline QFont pointSize(QFont _f, T SIZE) | ||
| { | ||
| static const float DPI = 96; | ||
| #ifdef LMMS_BUILD_WIN32 | ||
| _f.setPointSizeF( ((float) SIZE+0.5f) * DPI / | ||
| QApplication::desktop()->logicalDpiY() ); | ||
| #else | ||
| _f.setPointSizeF( (float) SIZE * DPI / | ||
| QApplication::desktop()->logicalDpiY() ); | ||
| #endif | ||
| return( _f ); | ||
| } | ||
|
|
||
| // to calculate DPI of a screen to make it HiDPI ready | ||
| qreal devicePixelRatio = QGuiApplication::primaryScreen()->devicePixelRatio(); | ||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. When using
Contributor
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I get what you mean but can you suggest a way to handle this one properly?
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I think this is something that should be handled by the GUI framework, i.e. by Qt. It just one example of why using these functions in application code is problematic. Using code like this also won't do the "right thing" when LMMS is in the middle of being dragged from one screen to another with different DPI values. Qt likely knows that one part of the application rectangle must be rendered with different settings than the other and can do so. The application code does not even have the knowledge of the current state ("I am shown on two different monitors.") and cannot do the right thing. |
||
| qreal scaleFactor = devicePixelRatio > 1.0 ? devicePixelRatio : 1.0; // Ensure scaleFactor is at least 1.0 | ||
Rossmaxx marked this conversation as resolved.
Outdated
Show resolved
Hide resolved
|
||
|
|
||
| inline QFont pointSizeF( QFont _f, float SIZE ) | ||
| { | ||
| static const float DPI = 96; | ||
| #ifdef LMMS_BUILD_WIN32 | ||
| _f.setPointSizeF( (SIZE+0.5f) * DPI / | ||
| QApplication::desktop()->logicalDpiY() ); | ||
| #else | ||
| _f.setPointSizeF( SIZE * DPI / | ||
| QApplication::desktop()->logicalDpiY() ); | ||
| #endif | ||
| _f.setPointSizeF((float)SIZE * scaleFactor); | ||
| return( _f ); | ||
| } | ||
|
|
||
|
|
||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -32,7 +32,6 @@ | |
|
|
||
| #include "AudioEngine.h" | ||
| #include "ConfigManager.h" | ||
| #include "gui_templates.h" | ||
|
|
||
| namespace lmms | ||
| { | ||
|
|
||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -31,7 +31,6 @@ | |
|
|
||
| #include "ConfigManager.h" | ||
| #include "LcdSpinBox.h" | ||
| #include "gui_templates.h" | ||
|
|
||
| namespace lmms::gui | ||
| { | ||
|
|
||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -28,7 +28,6 @@ | |
| #include <QLineEdit> | ||
|
|
||
| #include "ConfigManager.h" | ||
| #include "gui_templates.h" | ||
|
|
||
|
|
||
| namespace lmms::gui | ||
|
|
||
Uh oh!
There was an error while loading. Please reload this page.