Merge pull request #2090 from Cacodemon345/newqt
qt: Use non-integer HiDPI scaling on Qt 5
This commit is contained in:
@@ -134,6 +134,7 @@ int main(int argc, char* argv[]) {
|
||||
QApplication::setAttribute(Qt::AA_UseHighDpiPixmaps);
|
||||
QApplication::setAttribute(Qt::AA_EnableHighDpiScaling);
|
||||
#endif
|
||||
QApplication::setHighDpiScaleFactorRoundingPolicy(Qt::HighDpiScaleFactorRoundingPolicy::PassThrough);
|
||||
QApplication app(argc, argv);
|
||||
qt_set_sequence_auto_mnemonic(false);
|
||||
Q_INIT_RESOURCE(qt_resources);
|
||||
|
@@ -68,6 +68,7 @@ extern "C" {
|
||||
#include "qt_settings.hpp"
|
||||
#include "qt_machinestatus.hpp"
|
||||
#include "qt_mediamenu.hpp"
|
||||
#include "qt_util.hpp"
|
||||
|
||||
#ifdef __unix__
|
||||
#ifdef WAYLAND
|
||||
@@ -184,9 +185,9 @@ MainWindow::MainWindow(QWidget *parent) :
|
||||
|
||||
connect(this, &MainWindow::resizeContents, this, [this](int w, int h) {
|
||||
if (!QApplication::platformName().contains("eglfs") && vid_resize == 0) {
|
||||
w = w / (!dpi_scale ? this->screen()->devicePixelRatio() : 1);
|
||||
w = w / (!dpi_scale ? util::screenOfWidget(this)->devicePixelRatio() : 1);
|
||||
|
||||
int modifiedHeight = (h / (!dpi_scale ? this->screen()->devicePixelRatio() : 1))
|
||||
int modifiedHeight = (h / (!dpi_scale ? util::screenOfWidget(this)->devicePixelRatio() : 1))
|
||||
+ menuBar()->height()
|
||||
+ (statusBar()->height() * !hide_status_bar)
|
||||
+ (ui->toolBar->height() * !hide_tool_bar);
|
||||
|
@@ -25,6 +25,7 @@
|
||||
#include "qt_hardwarerenderer.hpp"
|
||||
|
||||
#include "qt_mainwindow.hpp"
|
||||
#include "qt_util.hpp"
|
||||
|
||||
#include "evdev_mouse.hpp"
|
||||
|
||||
@@ -173,7 +174,7 @@ void RendererStack::mouseMoveEvent(QMouseEvent *event)
|
||||
ignoreNextMouseEvent--;
|
||||
}
|
||||
else if (event->globalPos().x() == 0 || event->globalPos().y() == 0) leaveEvent((QEvent*)event);
|
||||
else if (event->globalPos().x() == (screen()->geometry().width() - 1) || event->globalPos().y() == (screen()->geometry().height() - 1)) leaveEvent((QEvent*)event);
|
||||
else if (event->globalPos().x() == (util::screenOfWidget(this)->geometry().width() - 1) || event->globalPos().y() == (util::screenOfWidget(this)->geometry().height() - 1)) leaveEvent((QEvent*)event);
|
||||
oldPos = event->pos();
|
||||
#endif
|
||||
}
|
||||
|
@@ -16,10 +16,23 @@
|
||||
*/
|
||||
#include <QStringBuilder>
|
||||
#include <QStringList>
|
||||
#include <QWidget>
|
||||
#include <QApplication>
|
||||
#if QT_VERSION <= QT_VERSION_CHECK(5, 14, 0)
|
||||
#include <QDesktopWidget>
|
||||
#endif
|
||||
#include "qt_util.hpp"
|
||||
|
||||
namespace util
|
||||
{
|
||||
QScreen* screenOfWidget(QWidget* widget)
|
||||
{
|
||||
#if QT_VERSION <= QT_VERSION_CHECK(5, 14, 0)
|
||||
return QApplication::screens()[QApplication::desktop()->screenNumber(widget) == -1 ? 0 : QApplication::desktop()->screenNumber(widget)];
|
||||
#else
|
||||
return widget->screen();
|
||||
#endif
|
||||
}
|
||||
|
||||
QString DlgFilter(std::initializer_list<QString> extensions, bool last)
|
||||
{
|
||||
|
@@ -2,13 +2,17 @@
|
||||
#define QT_UTIL_HPP
|
||||
|
||||
#include <QString>
|
||||
#include <QWidget>
|
||||
|
||||
#include <initializer_list>
|
||||
|
||||
class QScreen;
|
||||
namespace util
|
||||
{
|
||||
/* Creates extension list for qt filedialog */
|
||||
QString DlgFilter(std::initializer_list<QString> extensions, bool last = false);
|
||||
/* Returns screen the widget is on */
|
||||
QScreen* screenOfWidget(QWidget* widget);
|
||||
};
|
||||
|
||||
#endif
|
||||
#endif
|
||||
|
Reference in New Issue
Block a user