diff options
author | Friedemann Kleint <Friedemann.Kleint@qt.io> | 2021-10-12 17:39:00 +0200 |
---|---|---|
committer | Qt Cherry-pick Bot <cherrypick_bot@qt-project.org> | 2021-10-17 10:57:55 +0000 |
commit | fc3b800e7ff3a0320b754cfc8bfc881c8b1748f4 (patch) | |
tree | dd90d5b4b0a1b857e41901d4eb9080840bcdfe27 /examples/widgets/painting/shared/arthurwidgets.cpp | |
parent | 6c9cb02fd22b19083b4d6d2bb92a3e911b4ec768 (diff) |
Polish the painting/affine example
- Use member initialization
- Remove C-style casts
- Add space around operators
- Use qsizetype for list indexes
- Remove commented out debugging code
Task-number: QTBUG-97095
Change-Id: I11a17fa6e7f17968367a57291d83ee6fba731a34
Reviewed-by: Qt CI Bot <qt_ci_bot@qt-project.org>
Reviewed-by: Shawn Rutledge <shawn.rutledge@qt.io>
(cherry picked from commit bb56560b6b323933773608d006fb282693ea6106)
Reviewed-by: Qt Cherry-pick Bot <cherrypick_bot@qt-project.org>
Diffstat (limited to 'examples/widgets/painting/shared/arthurwidgets.cpp')
-rw-r--r-- | examples/widgets/painting/shared/arthurwidgets.cpp | 30 |
1 files changed, 8 insertions, 22 deletions
diff --git a/examples/widgets/painting/shared/arthurwidgets.cpp b/examples/widgets/painting/shared/arthurwidgets.cpp index 667246b79a..61e73c4a60 100644 --- a/examples/widgets/painting/shared/arthurwidgets.cpp +++ b/examples/widgets/painting/shared/arthurwidgets.cpp @@ -70,28 +70,15 @@ extern QPixmap cached(const QString &img); ArthurFrame::ArthurFrame(QWidget *parent) - : QWidget(parent) - , m_prefer_image(false) + : QWidget(parent), + m_tile(QPixmap(128, 128)) { -#if QT_CONFIG(opengl) - m_glWindow = nullptr; - m_glWidget = nullptr; - m_use_opengl = false; -#endif - m_document = nullptr; - m_show_doc = false; - - m_tile = QPixmap(128, 128); m_tile.fill(Qt::white); QPainter pt(&m_tile); QColor color(230, 230, 230); pt.fillRect(0, 0, 64, 64, color); pt.fillRect(64, 64, 64, 64, color); pt.end(); - -// QPalette pal = palette(); -// pal.setBrush(backgroundRole(), m_tile); -// setPalette(pal); } @@ -209,7 +196,7 @@ void ArthurFrame::paintEvent(QPaintEvent *e) painter.restore(); painter.save(); - if (m_show_doc) + if (m_showDoc) paintDescription(&painter); painter.restore(); @@ -244,9 +231,9 @@ void ArthurFrame::resizeEvent(QResizeEvent *e) void ArthurFrame::setDescriptionEnabled(bool enabled) { - if (m_show_doc != enabled) { - m_show_doc = enabled; - emit descriptionEnabledChanged(m_show_doc); + if (m_showDoc != enabled) { + m_showDoc = enabled; + emit descriptionEnabledChanged(m_showDoc); update(); } } @@ -276,9 +263,8 @@ void ArthurFrame::paintDescription(QPainter *painter) int pageWidth = qMax(width() - 100, 100); int pageHeight = qMax(height() - 100, 100); - if (pageWidth != m_document->pageSize().width()) { + if (pageWidth != m_document->pageSize().width()) m_document->setPageSize(QSize(pageWidth, pageHeight)); - } QRect textRect(width() / 2 - pageWidth / 2, height() / 2 - pageHeight / 2, @@ -340,7 +326,7 @@ void ArthurFrame::showSource() if (!f.open(QFile::ReadOnly)) contents = tr("Could not open file: '%1'").arg(m_sourceFileName); else - contents = f.readAll(); + contents = QString::fromUtf8(f.readAll()); } contents.replace(QLatin1Char('&'), QStringLiteral("&")); |