- fix: can't compile under linux

- enhancement: support Devcie Pixel Ratio ( for linux )
This commit is contained in:
Roy Qu 2022-04-02 18:22:29 +08:00
parent 13c7ea4d3b
commit 9302439fcb
3 changed files with 24 additions and 5 deletions

View File

@ -3,6 +3,8 @@ Red Panda C++ Version 1.0.3
the app is restored to normal state, no matter it's current state.
- enhancement: input shortcut in the option dialog's general -> shortcut page by pressing keys.
- enhancement: shift+ctrl+down/up to move currenlt selection lines up / down
- fix: can't compile under linux
- enhancement: support Devcie Pixel Ratio ( for linux )
Red Panda C++ Version 1.0.2
- enhancement: press tab in column mode won't exit column mode

View File

@ -67,7 +67,7 @@
#include <QTextBlock>
#include <QTranslator>
#include <QFileIconProvider>
#include "MainWindow.h"
#include "mainwindow.h"
#include <QScrollBar>
#include <QTextDocumentFragment>

View File

@ -146,7 +146,9 @@ SynEdit::SynEdit(QWidget *parent) : QAbstractScrollArea(parent),
mScrollHintColor = Qt::yellow;
mScrollHintFormat = SynScrollHintFormat::shfTopLineOnly;
mContentImage = std::make_shared<QImage>(clientWidth(),clientHeight(),QImage::Format_ARGB32);
qreal dpr=devicePixelRatioF();
mContentImage = std::make_shared<QImage>(clientWidth()*dpr,clientHeight()*dpr,QImage::Format_ARGB32);
mContentImage->setDevicePixelRatio(dpr);
mUseCodeFolding = true;
m_blinkTimerId = 0;
@ -5970,7 +5972,14 @@ void SynEdit::paintEvent(QPaintEvent *event)
// only update caret
// calculate the needed invalid area for caret
//qDebug()<<"update caret"<<rcCaret;
painter.drawImage(rcCaret,*mContentImage,rcCaret);
QRectF cacheRC;
qreal dpr = mContentImage->devicePixelRatioF();
cacheRC.setLeft(rcClip.left()*dpr);
cacheRC.setTop(rcClip.top()*dpr);
cacheRC.setWidth(rcClip.width()*dpr);
cacheRC.setHeight(rcClip.height()*dpr);
qDebug()<<rcClip<<rcCaret<<cacheRC;
painter.drawImage(rcCaret,*mContentImage,cacheRC);
} else {
QRect rcDraw;
int nL1, nL2, nC1, nC2;
@ -6009,7 +6018,13 @@ void SynEdit::paintEvent(QPaintEvent *event)
// If there is a custom paint handler call it.
onPaint(painter);
doOnPaintTransient(SynTransientType::ttAfter);
painter.drawImage(rcClip,*mContentImage,rcClip);
QRectF cacheRC;
qreal dpr = mContentImage->devicePixelRatioF();
cacheRC.setLeft(rcClip.left()*dpr);
cacheRC.setTop(rcClip.top()*dpr);
cacheRC.setWidth(rcClip.width()*dpr);
cacheRC.setHeight(rcClip.height()*dpr);
painter.drawImage(rcClip,*mContentImage,cacheRC);
}
paintCaret(painter, rcCaret);
}
@ -6017,8 +6032,10 @@ void SynEdit::paintEvent(QPaintEvent *event)
void SynEdit::resizeEvent(QResizeEvent *)
{
//resize the cache image
std::shared_ptr<QImage> image = std::make_shared<QImage>(clientWidth(),clientHeight(),
qreal dpr = devicePixelRatioF();
std::shared_ptr<QImage> image = std::make_shared<QImage>(clientWidth()*dpr,clientHeight()*dpr,
QImage::Format_ARGB32);
image->setDevicePixelRatio(dpr);
QRect newRect = image->rect().intersected(mContentImage->rect());
QPainter painter(image.get());