Skip to content
Snippets Groups Projects
Commit cc8f1bd0 authored by jpbl's avatar jpbl
Browse files

it doesn't flicker anymore

parent 5c42c523
No related branches found
No related tags found
No related merge requests found
...@@ -15,7 +15,7 @@ ...@@ -15,7 +15,7 @@
#define OVERSCREEN "overscreen.png" #define OVERSCREEN "overscreen.png"
SFLLcd::SFLLcd(QWidget *parent) SFLLcd::SFLLcd(QWidget *parent)
: QLabel(parent) : QLabel(parent, "SFLLcd", Qt::WNoAutoErase)
, mScreen(TransparentWidget::retreive(SCREEN)) , mScreen(TransparentWidget::retreive(SCREEN))
, mOverscreen(TransparentWidget::transparize(OVERSCREEN)) , mOverscreen(TransparentWidget::transparize(OVERSCREEN))
, mGlobalStatusPos(-1) , mGlobalStatusPos(-1)
...@@ -140,14 +140,20 @@ SFLLcd::getTimeStatus() ...@@ -140,14 +140,20 @@ SFLLcd::getTimeStatus()
} }
void void
SFLLcd::paintEvent(QPaintEvent *) SFLLcd::paintEvent(QPaintEvent *event)
{ {
static QPixmap pixmap(size());
QRect rect = event->rect();
QSize newSize = rect.size().expandedTo(pixmap.size());
pixmap.resize(newSize);
pixmap.fill(this, rect.topLeft());
QPainter p(&pixmap, this);
// Painter settings // Painter settings
QFontMetrics fm(mFont); QFontMetrics fm(mFont);
int margin = 2; int margin = 2;
QPainter p(this);
p.setFont(mFont); p.setFont(mFont);
p.drawPixmap(0,0, mScreen); p.drawPixmap(0,0, mScreen);
p.drawText(QPoint(margin, fm.height()), p.drawText(QPoint(margin, fm.height()),
...@@ -162,6 +168,8 @@ SFLLcd::paintEvent(QPaintEvent *) ...@@ -162,6 +168,8 @@ SFLLcd::paintEvent(QPaintEvent *)
p.drawText(QPoint(margin, mScreen.size().height() - margin), getTimeStatus()); p.drawText(QPoint(margin, mScreen.size().height() - margin), getTimeStatus());
p.drawPixmap(0,0, mOverscreen); p.drawPixmap(0,0, mOverscreen);
p.end(); p.end();
bitBlt(this, event->rect().topLeft(), &pixmap);
} }
bool bool
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment