From 0e0689ad6435453494f67c828f558ed6be29a3fd Mon Sep 17 00:00:00 2001 From: "royqh1979@gmail.com" Date: Mon, 13 Dec 2021 12:09:37 +0800 Subject: [PATCH] work save --- RedPandaIDE/main.cpp | 3 +++ RedPandaIDE/mainwindow.h | 1 + RedPandaIDE/qsynedit/SynEdit.cpp | 14 +++++++++++++- RedPandaIDE/qsynedit/SynEdit.h | 4 ++++ 4 files changed, 21 insertions(+), 1 deletion(-) diff --git a/RedPandaIDE/main.cpp b/RedPandaIDE/main.cpp index 64d8fd45..6a2abee6 100644 --- a/RedPandaIDE/main.cpp +++ b/RedPandaIDE/main.cpp @@ -38,6 +38,8 @@ bool WindowLogoutEventFilter::nativeEventFilter(const QByteArray & /*eventType*/ } return true; } + } else if (pMsg->message == WM_DPICHANGED) { + qDebug()<<"app dpi changed!"; } return false; } @@ -77,6 +79,7 @@ QString getSettingFilename(const QString& filepath = QString()) { int main(int argc, char *argv[]) { + //QApplication::setAttribute(Qt::AA_EnableHighDpiScaling); QApplication app(argc, argv); //Translation must be loaded first diff --git a/RedPandaIDE/mainwindow.h b/RedPandaIDE/mainwindow.h index 9997d355..f1b706b2 100644 --- a/RedPandaIDE/mainwindow.h +++ b/RedPandaIDE/mainwindow.h @@ -653,6 +653,7 @@ protected: void closeEvent(QCloseEvent *event) override; void showEvent(QShowEvent* event) override; void hideEvent(QHideEvent *event) override; + }; extern MainWindow* pMainWindow; diff --git a/RedPandaIDE/qsynedit/SynEdit.cpp b/RedPandaIDE/qsynedit/SynEdit.cpp index 180be67c..94a22705 100644 --- a/RedPandaIDE/qsynedit/SynEdit.cpp +++ b/RedPandaIDE/qsynedit/SynEdit.cpp @@ -6261,7 +6261,19 @@ void SynEdit::dragLeaveEvent(QDragLeaveEvent *) // setCaretXY(mDragCaretSave); // setBlockBegin(mDragSelBeginSave); // setBlockEnd(mDragSelEndSave); -// showCaret(); + // showCaret(); +} + +bool SynEdit::nativeEvent(const QByteArray &eventType, void *message, long *result) +{ +#ifdef Q_OS_WIN + MSG* msg = (MSG*)message; + if (msg && msg->message == WM_DPICHANGED) { + qDebug()<<"dpi changed!"; + synFontChanged(); + } +#endif + return QAbstractScrollArea::nativeEvent(eventType,message,result); } int SynEdit::maxScrollHeight() const diff --git a/RedPandaIDE/qsynedit/SynEdit.h b/RedPandaIDE/qsynedit/SynEdit.h index da0571d0..7dcf8a74 100644 --- a/RedPandaIDE/qsynedit/SynEdit.h +++ b/RedPandaIDE/qsynedit/SynEdit.h @@ -737,6 +737,10 @@ void dragEnterEvent(QDragEnterEvent *event) override; void dropEvent(QDropEvent *event) override; void dragMoveEvent(QDragMoveEvent *event) override; void dragLeaveEvent(QDragLeaveEvent *event) override; + +// QWidget interface +protected: +bool nativeEvent(const QByteArray &eventType, void *message, long *result) override; }; #endif // SYNEDIT_H