- enhancement: recalc layout info for code editors when dpi changed
This commit is contained in:
parent
0e0689ad64
commit
956b717a14
1
NEWS.md
1
NEWS.md
|
@ -1,5 +1,6 @@
|
||||||
Version 0.11.1 For Dev-C++ 7 Beta
|
Version 0.11.1 For Dev-C++ 7 Beta
|
||||||
- enhancement: Problem's test case shouldn't accept rich text inputs
|
- enhancement: Problem's test case shouldn't accept rich text inputs
|
||||||
|
- enhancement: recalc layout info for code editors when dpi changed
|
||||||
|
|
||||||
Version 0.11.0 For Dev-C++ 7 Beta
|
Version 0.11.0 For Dev-C++ 7 Beta
|
||||||
- enhancement: redesign the expression parser for code completion
|
- enhancement: redesign the expression parser for code completion
|
||||||
|
|
|
@ -351,13 +351,7 @@ public:
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
void mouseReleaseEvent(QMouseEvent *event) override;
|
void mouseReleaseEvent(QMouseEvent *event) override;
|
||||||
|
|
||||||
// QWidget interface
|
|
||||||
protected:
|
|
||||||
void inputMethodEvent(QInputMethodEvent *) override;
|
void inputMethodEvent(QInputMethodEvent *) override;
|
||||||
|
|
||||||
// QWidget interface
|
|
||||||
protected:
|
|
||||||
void closeEvent(QCloseEvent *event) override;
|
void closeEvent(QCloseEvent *event) override;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
|
@ -7,6 +7,7 @@
|
||||||
#include "settings.h"
|
#include "settings.h"
|
||||||
#include "project.h"
|
#include "project.h"
|
||||||
#include "systemconsts.h"
|
#include "systemconsts.h"
|
||||||
|
#include <QApplication>
|
||||||
|
|
||||||
EditorList::EditorList(QTabWidget* leftPageWidget,
|
EditorList::EditorList(QTabWidget* leftPageWidget,
|
||||||
QTabWidget* rightPageWidget,
|
QTabWidget* rightPageWidget,
|
||||||
|
@ -263,6 +264,18 @@ void EditorList::selectPreviousPage()
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void EditorList::notifyDPIChanged(int dpi)
|
||||||
|
{
|
||||||
|
for (int i=0;i<mLeftPageWidget->count();i++) {
|
||||||
|
Editor* e = static_cast<Editor*>(mLeftPageWidget->widget(i));
|
||||||
|
e->changeDPI(dpi);
|
||||||
|
}
|
||||||
|
for (int i=0;i<mRightPageWidget->count();i++) {
|
||||||
|
Editor* e = static_cast<Editor*>(mRightPageWidget->widget(i));
|
||||||
|
e->changeDPI(dpi);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
Editor *EditorList::operator[](int index)
|
Editor *EditorList::operator[](int index)
|
||||||
{
|
{
|
||||||
if (index>=0 && index<mLeftPageWidget->count()) {
|
if (index>=0 && index<mLeftPageWidget->count()) {
|
||||||
|
|
|
@ -53,6 +53,7 @@ public:
|
||||||
int pageCount();
|
int pageCount();
|
||||||
void selectNextPage();
|
void selectNextPage();
|
||||||
void selectPreviousPage();
|
void selectPreviousPage();
|
||||||
|
void notifyDPIChanged(int dpi);
|
||||||
|
|
||||||
Editor* operator[](int index);
|
Editor* operator[](int index);
|
||||||
|
|
||||||
|
|
|
@ -28,7 +28,8 @@ public:
|
||||||
|
|
||||||
bool WindowLogoutEventFilter::nativeEventFilter(const QByteArray & /*eventType*/, void *message, long *result){
|
bool WindowLogoutEventFilter::nativeEventFilter(const QByteArray & /*eventType*/, void *message, long *result){
|
||||||
MSG * pMsg = static_cast<MSG *>(message);
|
MSG * pMsg = static_cast<MSG *>(message);
|
||||||
if (pMsg->message == WM_QUERYENDSESSION) {
|
switch(pMsg->message) {
|
||||||
|
case WM_QUERYENDSESSION:
|
||||||
if (pMsg->lParam == 0
|
if (pMsg->lParam == 0
|
||||||
|| (pMsg->lParam & ENDSESSION_LOGOFF)) {
|
|| (pMsg->lParam & ENDSESSION_LOGOFF)) {
|
||||||
if (!pMainWindow->close()) {
|
if (!pMainWindow->close()) {
|
||||||
|
@ -38,8 +39,13 @@ bool WindowLogoutEventFilter::nativeEventFilter(const QByteArray & /*eventType*/
|
||||||
}
|
}
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
} else if (pMsg->message == WM_DPICHANGED) {
|
break;
|
||||||
qDebug()<<"app dpi changed!";
|
case WM_DPICHANGED:
|
||||||
|
if (pMainWindow) {
|
||||||
|
int dpi = HIWORD(pMsg->wParam);
|
||||||
|
pMainWindow->notifyDPIChanged(dpi);
|
||||||
|
}
|
||||||
|
break;
|
||||||
}
|
}
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
|
@ -175,6 +175,8 @@ MainWindow::MainWindow(QWidget *parent)
|
||||||
this, &MainWindow::onDebugEvaluateInput);
|
this, &MainWindow::onDebugEvaluateInput);
|
||||||
connect(ui->cbMemoryAddress->lineEdit(), &QLineEdit::returnPressed,
|
connect(ui->cbMemoryAddress->lineEdit(), &QLineEdit::returnPressed,
|
||||||
this, &MainWindow::onDebugMemoryAddressInput);
|
this, &MainWindow::onDebugMemoryAddressInput);
|
||||||
|
connect(this,&MainWindow::dpiChanged,
|
||||||
|
this,&MainWindow::onDPIChanged);
|
||||||
|
|
||||||
mTodoParser = std::make_shared<TodoParser>();
|
mTodoParser = std::make_shared<TodoParser>();
|
||||||
mSymbolUsageManager = std::make_shared<SymbolUsageManager>();
|
mSymbolUsageManager = std::make_shared<SymbolUsageManager>();
|
||||||
|
@ -641,6 +643,11 @@ void MainWindow::setActiveBreakpoint(QString FileName, int Line, bool setFocus)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void MainWindow::dpiChanged(int dpi)
|
||||||
|
{
|
||||||
|
mEditorList->notifyDPIChanged(dpi);
|
||||||
|
}
|
||||||
|
|
||||||
void MainWindow::updateAppTitle()
|
void MainWindow::updateAppTitle()
|
||||||
{
|
{
|
||||||
QString appName=tr("Red Panda Dev-C++");
|
QString appName=tr("Red Panda Dev-C++");
|
||||||
|
@ -5626,6 +5633,11 @@ bool MainWindow::openningFiles() const
|
||||||
return mOpenningFiles;
|
return mOpenningFiles;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void MainWindow::notifyDPIChanged(int dpi)
|
||||||
|
{
|
||||||
|
emit dpiChanged(dpi);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
void MainWindow::on_actionTool_Window_Bars_triggered()
|
void MainWindow::on_actionTool_Window_Bars_triggered()
|
||||||
{
|
{
|
||||||
|
|
|
@ -163,6 +163,10 @@ public:
|
||||||
|
|
||||||
bool openningFiles() const;
|
bool openningFiles() const;
|
||||||
|
|
||||||
|
void notifyDPIChanged(int dpi);
|
||||||
|
|
||||||
|
signals:
|
||||||
|
void dpiChanged(int dpi);
|
||||||
public slots:
|
public slots:
|
||||||
void onCompileLog(const QString& msg);
|
void onCompileLog(const QString& msg);
|
||||||
void onCompileIssue(PCompileIssue issue);
|
void onCompileIssue(PCompileIssue issue);
|
||||||
|
@ -194,6 +198,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 onDPIChanged();
|
||||||
|
|
||||||
private:
|
private:
|
||||||
void prepareProjectForCompile();
|
void prepareProjectForCompile();
|
||||||
|
|
|
@ -24,6 +24,7 @@
|
||||||
|
|
||||||
SynEdit::SynEdit(QWidget *parent) : QAbstractScrollArea(parent)
|
SynEdit::SynEdit(QWidget *parent) : QAbstractScrollArea(parent)
|
||||||
{
|
{
|
||||||
|
mDPI = -1;
|
||||||
mLastKey = 0;
|
mLastKey = 0;
|
||||||
mLastKeyModifiers = Qt::NoModifier;
|
mLastKeyModifiers = Qt::NoModifier;
|
||||||
mModified = false;
|
mModified = false;
|
||||||
|
@ -148,6 +149,8 @@ SynEdit::SynEdit(QWidget *parent) : QAbstractScrollArea(parent)
|
||||||
|
|
||||||
//setMouseTracking(true);
|
//setMouseTracking(true);
|
||||||
setAcceptDrops(true);
|
setAcceptDrops(true);
|
||||||
|
|
||||||
|
mDPI = fontMetrics().fontDpi();
|
||||||
}
|
}
|
||||||
|
|
||||||
int SynEdit::displayLineCount() const
|
int SynEdit::displayLineCount() const
|
||||||
|
@ -3138,8 +3141,9 @@ void SynEdit::recalcCharExtent()
|
||||||
|
|
||||||
mTextHeight = 0;
|
mTextHeight = 0;
|
||||||
mCharWidth = 0;
|
mCharWidth = 0;
|
||||||
mTextHeight = fontMetrics().lineSpacing();
|
QFontMetrics fm(font());
|
||||||
mCharWidth = fontMetrics().horizontalAdvance("M");
|
mTextHeight = fm.lineSpacing();
|
||||||
|
mCharWidth = fm.horizontalAdvance("M");
|
||||||
if (hasStyles[0]) { // has bold font
|
if (hasStyles[0]) { // has bold font
|
||||||
QFont f = font();
|
QFont f = font();
|
||||||
f.setBold(true);
|
f.setBold(true);
|
||||||
|
@ -3177,8 +3181,6 @@ void SynEdit::recalcCharExtent()
|
||||||
mCharWidth = fm.horizontalAdvance("M");
|
mCharWidth = fm.horizontalAdvance("M");
|
||||||
}
|
}
|
||||||
mTextHeight += mExtraLineSpacing;
|
mTextHeight += mExtraLineSpacing;
|
||||||
//mCharWidth = mCharWidth * dpiFactor();
|
|
||||||
//mTextHeight = mTextHeight * dpiFactor();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
QString SynEdit::expandAtWideGlyphs(const QString &S)
|
QString SynEdit::expandAtWideGlyphs(const QString &S)
|
||||||
|
@ -5807,8 +5809,26 @@ void SynEdit::updateMouseCursor(){
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void SynEdit::changeDPI(int dpi)
|
||||||
|
{
|
||||||
|
if (dpi!=mDPI) {
|
||||||
|
mDPI=dpi;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
void SynEdit::paintEvent(QPaintEvent *event)
|
void SynEdit::paintEvent(QPaintEvent *event)
|
||||||
{
|
{
|
||||||
|
if (fontMetrics().fontDpi()!=mDPI) {
|
||||||
|
QFont f;
|
||||||
|
f.setFamily(font().family());
|
||||||
|
f.setPointSize(font().pointSize());
|
||||||
|
f.setBold(font().bold());
|
||||||
|
f.setItalic(font().bold());
|
||||||
|
f.setUnderline(font().underline());
|
||||||
|
f.setStrikeOut(font().strikeOut());
|
||||||
|
setFont(f);
|
||||||
|
return;
|
||||||
|
}
|
||||||
if (mPainterLock>0)
|
if (mPainterLock>0)
|
||||||
return;
|
return;
|
||||||
if (mPainting)
|
if (mPainting)
|
||||||
|
@ -6264,18 +6284,6 @@ void SynEdit::dragLeaveEvent(QDragLeaveEvent *)
|
||||||
// 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
|
int SynEdit::maxScrollHeight() const
|
||||||
{
|
{
|
||||||
if (mOptions.testFlag(eoScrollPastEof))
|
if (mOptions.testFlag(eoScrollPastEof))
|
||||||
|
|
|
@ -274,6 +274,8 @@ public:
|
||||||
const PSynHighlighterAttribute &attr3);
|
const PSynHighlighterAttribute &attr3);
|
||||||
|
|
||||||
void updateMouseCursor();
|
void updateMouseCursor();
|
||||||
|
|
||||||
|
void changeDPI(int dpi);
|
||||||
// setter && getters
|
// setter && getters
|
||||||
int topLine() const;
|
int topLine() const;
|
||||||
void setTopLine(int value);
|
void setTopLine(int value);
|
||||||
|
@ -704,6 +706,8 @@ private:
|
||||||
BufferCoord mDragSelEndSave;
|
BufferCoord mDragSelEndSave;
|
||||||
bool mDragging;
|
bool mDragging;
|
||||||
|
|
||||||
|
int mDPI;
|
||||||
|
|
||||||
friend class SynEditTextPainter;
|
friend class SynEditTextPainter;
|
||||||
|
|
||||||
// QWidget interface
|
// QWidget interface
|
||||||
|
@ -737,10 +741,6 @@ void dragEnterEvent(QDragEnterEvent *event) override;
|
||||||
void dropEvent(QDropEvent *event) override;
|
void dropEvent(QDropEvent *event) override;
|
||||||
void dragMoveEvent(QDragMoveEvent *event) override;
|
void dragMoveEvent(QDragMoveEvent *event) override;
|
||||||
void dragLeaveEvent(QDragLeaveEvent *event) override;
|
void dragLeaveEvent(QDragLeaveEvent *event) override;
|
||||||
|
|
||||||
// QWidget interface
|
|
||||||
protected:
|
|
||||||
bool nativeEvent(const QByteArray &eventType, void *message, long *result) override;
|
|
||||||
};
|
};
|
||||||
|
|
||||||
#endif // SYNEDIT_H
|
#endif // SYNEDIT_H
|
||||||
|
|
Loading…
Reference in New Issue