- enhancement: auto zoom ui when screen's zoom factor changed (windows)

This commit is contained in:
Roy Qu 2022-01-24 18:37:16 +08:00
parent 1135fcf7dd
commit e89ac58462
6 changed files with 25 additions and 4 deletions

View File

@ -24,6 +24,7 @@ Red Panda C++ Version 0.13.3
- fix: insert code snippets will crash, if current compiler set's include dir list is not empty and lib dir list is empty - fix: insert code snippets will crash, if current compiler set's include dir list is not empty and lib dir list is empty
- fix: search around option can't be disabled - fix: search around option can't be disabled
- enhancement: show a confirm dialog when search/replace around - enhancement: show a confirm dialog when search/replace around
- enhancement: auto zoom ui when screen's zoom factor changed (windows)
Red Panda C++ Version 0.13.2 Red Panda C++ Version 0.13.2
- fix: "delete and exit" button in the environtment / folder option page doesn't work correctly - fix: "delete and exit" button in the environtment / folder option page doesn't work correctly

View File

@ -25,6 +25,7 @@
#include <QMessageBox> #include <QMessageBox>
#include <QStringList> #include <QStringList>
#include <QAbstractNativeEventFilter> #include <QAbstractNativeEventFilter>
#include <QDesktopWidget>
#include <QDir> #include <QDir>
#include "common.h" #include "common.h"
#include "colorscheme.h" #include "colorscheme.h"
@ -60,7 +61,8 @@ bool WindowLogoutEventFilter::nativeEventFilter(const QByteArray & /*eventType*/
} }
break; break;
case WM_DPICHANGED: case WM_DPICHANGED:
//todo setDesktopDpi(HIWORD(pMsg->wParam));
pMainWindow->updateDPI();
break; break;
} }
return false; return false;
@ -159,6 +161,7 @@ int main(int argc, char *argv[])
//set default open folder //set default open folder
QDir::setCurrent(pSettings->environment().defaultOpenFolder()); QDir::setCurrent(pSettings->environment().defaultOpenFolder());
setDesktopDpi(qApp->desktop()->logicalDpiY());
MainWindow mainWindow; MainWindow mainWindow;
pMainWindow = &mainWindow; pMainWindow = &mainWindow;

View File

@ -689,6 +689,12 @@ void MainWindow::setActiveBreakpoint(QString FileName, int Line, bool setFocus)
} }
} }
void MainWindow::updateDPI()
{
qDebug()<<"dpi changed!"<<desktopDpi();
applySettings();
}
void MainWindow::updateAppTitle() void MainWindow::updateAppTitle()
{ {
QString appName=tr("Red Panda C++"); QString appName=tr("Red Panda C++");

View File

@ -215,6 +215,7 @@ public slots:
void onTodoParsing(const QString& filename, int lineNo, int ch, const QString& line); void onTodoParsing(const QString& filename, int lineNo, int ch, const QString& line);
void onTodoParseFinished(); void onTodoParseFinished();
void setActiveBreakpoint(QString FileName, int Line, bool setFocus); void setActiveBreakpoint(QString FileName, int Line, bool setFocus);
void updateDPI();
private: private:
void prepareProjectForCompile(); void prepareProjectForCompile();

View File

@ -1001,12 +1001,12 @@ QString localizePath(const QString &path)
float pointToPixel(float point) float pointToPixel(float point)
{ {
return point * qApp->desktop()->logicalDpiY() / 72; return point * desktopDpi() / 72;
} }
float pixelToPoint(float pixel) float pixelToPoint(float pixel)
{ {
return pixel * 72 / qApp->desktop()->logicalDpiY(); return pixel * 72 / desktopDpi();
} }
@ -1076,9 +1076,12 @@ QStringList splitProcessCommand(const QString &cmd)
return result; return result;
} }
static float saved_desktop_dpi = -1;
float desktopDpi() float desktopDpi()
{ {
return qApp->desktop()->logicalDpiY(); if (saved_desktop_dpi<1)
saved_desktop_dpi = qApp->desktop()->logicalDpiY();
return saved_desktop_dpi;
} }
qulonglong stringToHex(const QString &str, qulonglong defaultValue) qulonglong stringToHex(const QString &str, qulonglong defaultValue)
@ -1089,3 +1092,8 @@ qulonglong stringToHex(const QString &str, qulonglong defaultValue)
return value; return value;
return defaultValue; return defaultValue;
} }
void setDesktopDpi(float dpi)
{
saved_desktop_dpi = dpi;
}

View File

@ -232,6 +232,8 @@ class CppParser;
void resetCppParser(std::shared_ptr<CppParser> parser, int compilerSetIndex=-1); void resetCppParser(std::shared_ptr<CppParser> parser, int compilerSetIndex=-1);
float desktopDpi(); float desktopDpi();
void setDesktopDpi(float dpi);
float pointToPixel(float point); float pointToPixel(float point);
float pixelToPoint(float pixel); float pixelToPoint(float pixel);