- 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
|
||||
- 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
|
||||
- enhancement: redesign the expression parser for code completion
|
||||
|
|
|
@ -351,13 +351,7 @@ public:
|
|||
|
||||
protected:
|
||||
void mouseReleaseEvent(QMouseEvent *event) override;
|
||||
|
||||
// QWidget interface
|
||||
protected:
|
||||
void inputMethodEvent(QInputMethodEvent *) override;
|
||||
|
||||
// QWidget interface
|
||||
protected:
|
||||
void closeEvent(QCloseEvent *event) override;
|
||||
};
|
||||
|
||||
|
|
|
@ -7,6 +7,7 @@
|
|||
#include "settings.h"
|
||||
#include "project.h"
|
||||
#include "systemconsts.h"
|
||||
#include <QApplication>
|
||||
|
||||
EditorList::EditorList(QTabWidget* leftPageWidget,
|
||||
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)
|
||||
{
|
||||
if (index>=0 && index<mLeftPageWidget->count()) {
|
||||
|
|
|
@ -53,6 +53,7 @@ public:
|
|||
int pageCount();
|
||||
void selectNextPage();
|
||||
void selectPreviousPage();
|
||||
void notifyDPIChanged(int dpi);
|
||||
|
||||
Editor* operator[](int index);
|
||||
|
||||
|
|
|
@ -28,7 +28,8 @@ public:
|
|||
|
||||
bool WindowLogoutEventFilter::nativeEventFilter(const QByteArray & /*eventType*/, void *message, long *result){
|
||||
MSG * pMsg = static_cast<MSG *>(message);
|
||||
if (pMsg->message == WM_QUERYENDSESSION) {
|
||||
switch(pMsg->message) {
|
||||
case WM_QUERYENDSESSION:
|
||||
if (pMsg->lParam == 0
|
||||
|| (pMsg->lParam & ENDSESSION_LOGOFF)) {
|
||||
if (!pMainWindow->close()) {
|
||||
|
@ -38,8 +39,13 @@ bool WindowLogoutEventFilter::nativeEventFilter(const QByteArray & /*eventType*/
|
|||
}
|
||||
return true;
|
||||
}
|
||||
} else if (pMsg->message == WM_DPICHANGED) {
|
||||
qDebug()<<"app dpi changed!";
|
||||
break;
|
||||
case WM_DPICHANGED:
|
||||
if (pMainWindow) {
|
||||
int dpi = HIWORD(pMsg->wParam);
|
||||
pMainWindow->notifyDPIChanged(dpi);
|
||||
}
|
||||
break;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
|
|
@ -175,6 +175,8 @@ MainWindow::MainWindow(QWidget *parent)
|
|||
this, &MainWindow::onDebugEvaluateInput);
|
||||
connect(ui->cbMemoryAddress->lineEdit(), &QLineEdit::returnPressed,
|
||||
this, &MainWindow::onDebugMemoryAddressInput);
|
||||
connect(this,&MainWindow::dpiChanged,
|
||||
this,&MainWindow::onDPIChanged);
|
||||
|
||||
mTodoParser = std::make_shared<TodoParser>();
|
||||
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()
|
||||
{
|
||||
QString appName=tr("Red Panda Dev-C++");
|
||||
|
@ -5626,6 +5633,11 @@ bool MainWindow::openningFiles() const
|
|||
return mOpenningFiles;
|
||||
}
|
||||
|
||||
void MainWindow::notifyDPIChanged(int dpi)
|
||||
{
|
||||
emit dpiChanged(dpi);
|
||||
}
|
||||
|
||||
|
||||
void MainWindow::on_actionTool_Window_Bars_triggered()
|
||||
{
|
||||
|
|
|
@ -163,6 +163,10 @@ public:
|
|||
|
||||
bool openningFiles() const;
|
||||
|
||||
void notifyDPIChanged(int dpi);
|
||||
|
||||
signals:
|
||||
void dpiChanged(int dpi);
|
||||
public slots:
|
||||
void onCompileLog(const QString& msg);
|
||||
void onCompileIssue(PCompileIssue issue);
|
||||
|
@ -194,6 +198,7 @@ public slots:
|
|||
void onTodoParsing(const QString& filename, int lineNo, int ch, const QString& line);
|
||||
void onTodoParseFinished();
|
||||
void setActiveBreakpoint(QString FileName, int Line, bool setFocus);
|
||||
void onDPIChanged();
|
||||
|
||||
private:
|
||||
void prepareProjectForCompile();
|
||||
|
|
|
@ -24,6 +24,7 @@
|
|||
|
||||
SynEdit::SynEdit(QWidget *parent) : QAbstractScrollArea(parent)
|
||||
{
|
||||
mDPI = -1;
|
||||
mLastKey = 0;
|
||||
mLastKeyModifiers = Qt::NoModifier;
|
||||
mModified = false;
|
||||
|
@ -148,6 +149,8 @@ SynEdit::SynEdit(QWidget *parent) : QAbstractScrollArea(parent)
|
|||
|
||||
//setMouseTracking(true);
|
||||
setAcceptDrops(true);
|
||||
|
||||
mDPI = fontMetrics().fontDpi();
|
||||
}
|
||||
|
||||
int SynEdit::displayLineCount() const
|
||||
|
@ -3138,8 +3141,9 @@ void SynEdit::recalcCharExtent()
|
|||
|
||||
mTextHeight = 0;
|
||||
mCharWidth = 0;
|
||||
mTextHeight = fontMetrics().lineSpacing();
|
||||
mCharWidth = fontMetrics().horizontalAdvance("M");
|
||||
QFontMetrics fm(font());
|
||||
mTextHeight = fm.lineSpacing();
|
||||
mCharWidth = fm.horizontalAdvance("M");
|
||||
if (hasStyles[0]) { // has bold font
|
||||
QFont f = font();
|
||||
f.setBold(true);
|
||||
|
@ -3177,8 +3181,6 @@ void SynEdit::recalcCharExtent()
|
|||
mCharWidth = fm.horizontalAdvance("M");
|
||||
}
|
||||
mTextHeight += mExtraLineSpacing;
|
||||
//mCharWidth = mCharWidth * dpiFactor();
|
||||
//mTextHeight = mTextHeight * dpiFactor();
|
||||
}
|
||||
|
||||
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)
|
||||
{
|
||||
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)
|
||||
return;
|
||||
if (mPainting)
|
||||
|
@ -6264,18 +6284,6 @@ void SynEdit::dragLeaveEvent(QDragLeaveEvent *)
|
|||
// 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
|
||||
{
|
||||
if (mOptions.testFlag(eoScrollPastEof))
|
||||
|
|
|
@ -274,6 +274,8 @@ public:
|
|||
const PSynHighlighterAttribute &attr3);
|
||||
|
||||
void updateMouseCursor();
|
||||
|
||||
void changeDPI(int dpi);
|
||||
// setter && getters
|
||||
int topLine() const;
|
||||
void setTopLine(int value);
|
||||
|
@ -704,6 +706,8 @@ private:
|
|||
BufferCoord mDragSelEndSave;
|
||||
bool mDragging;
|
||||
|
||||
int mDPI;
|
||||
|
||||
friend class SynEditTextPainter;
|
||||
|
||||
// QWidget interface
|
||||
|
@ -737,10 +741,6 @@ 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
|
||||
|
|
Loading…
Reference in New Issue