summaryrefslogtreecommitdiffstats
path: root/examples/widgets/painting/shared/arthurwidgets.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'examples/widgets/painting/shared/arthurwidgets.cpp')
-rw-r--r--examples/widgets/painting/shared/arthurwidgets.cpp131
1 files changed, 4 insertions, 127 deletions
diff --git a/examples/widgets/painting/shared/arthurwidgets.cpp b/examples/widgets/painting/shared/arthurwidgets.cpp
index 61e73c4a60..4ff435783b 100644
--- a/examples/widgets/painting/shared/arthurwidgets.cpp
+++ b/examples/widgets/painting/shared/arthurwidgets.cpp
@@ -1,52 +1,5 @@
-/****************************************************************************
-**
-** Copyright (C) 2016 The Qt Company Ltd.
-** Contact: https://www.qt.io/licensing/
-**
-** This file is part of the demonstration applications of the Qt Toolkit.
-**
-** $QT_BEGIN_LICENSE:BSD$
-** Commercial License Usage
-** Licensees holding valid commercial Qt licenses may use this file in
-** accordance with the commercial license agreement provided with the
-** Software or, alternatively, in accordance with the terms contained in
-** a written agreement between you and The Qt Company. For licensing terms
-** and conditions see https://www.qt.io/terms-conditions. For further
-** information use the contact form at https://www.qt.io/contact-us.
-**
-** BSD License Usage
-** Alternatively, you may use this file under the terms of the BSD license
-** as follows:
-**
-** "Redistribution and use in source and binary forms, with or without
-** modification, are permitted provided that the following conditions are
-** met:
-** * Redistributions of source code must retain the above copyright
-** notice, this list of conditions and the following disclaimer.
-** * Redistributions in binary form must reproduce the above copyright
-** notice, this list of conditions and the following disclaimer in
-** the documentation and/or other materials provided with the
-** distribution.
-** * Neither the name of The Qt Company Ltd nor the names of its
-** contributors may be used to endorse or promote products derived
-** from this software without specific prior written permission.
-**
-**
-** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
-** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
-** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
-** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
-** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
-** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
-** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
-** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
-** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
-** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
-** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE."
-**
-** $QT_END_LICENSE$
-**
-****************************************************************************/
+// Copyright (C) 2016 The Qt Company Ltd.
+// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR BSD-3-Clause
#include "arthurwidgets.h"
#include <QApplication>
@@ -61,11 +14,6 @@
#include <QBoxLayout>
#include <QRegularExpression>
#include <QOffscreenSurface>
-#include <QOpenGLContext>
-#if QT_CONFIG(opengl)
-#include <QtOpenGL/QOpenGLPaintDevice>
-#include <QtOpenGL/QOpenGLWindow>
-#endif
extern QPixmap cached(const QString &img);
@@ -81,61 +29,13 @@ ArthurFrame::ArthurFrame(QWidget *parent)
pt.end();
}
-
-#if QT_CONFIG(opengl)
-void ArthurFrame::enableOpenGL(bool use_opengl)
-{
- if (m_use_opengl == use_opengl)
- return;
-
- m_use_opengl = use_opengl;
-
- if (!m_glWindow && use_opengl) {
- createGlWindow();
- QApplication::postEvent(this, new QResizeEvent(size(), size()));
- }
-
- if (use_opengl) {
- m_glWidget->show();
- } else {
- if (m_glWidget)
- m_glWidget->hide();
- }
-
- update();
-}
-
-void ArthurFrame::createGlWindow()
-{
- Q_ASSERT(m_use_opengl);
-
- m_glWindow = new QOpenGLWindow();
- QSurfaceFormat f = QSurfaceFormat::defaultFormat();
- f.setSamples(4);
- f.setAlphaBufferSize(8);
- f.setStencilBufferSize(8);
- m_glWindow->setFormat(f);
- m_glWindow->setFlags(Qt::WindowTransparentForInput);
- m_glWindow->resize(width(), height());
- m_glWidget = QWidget::createWindowContainer(m_glWindow, this);
- // create() must be called after createWindowContainer() otherwise
- // an incorrect offsetting of the position will occur.
- m_glWindow->create();
-}
-#endif
-
-
void ArthurFrame::paintEvent(QPaintEvent *e)
{
static QImage *static_image = nullptr;
QPainter painter;
- if (preferImage()
-#if QT_CONFIG(opengl)
- && !m_use_opengl
-#endif
- ) {
+ if (preferImage()) {
if (!static_image || static_image->size() != size()) {
delete static_image;
static_image = new QImage(size(), QImage::Format_RGB32);
@@ -150,18 +50,7 @@ void ArthurFrame::paintEvent(QPaintEvent *e)
painter.fillRect(0, height() - o, o, o, bg);
painter.fillRect(width() - o, height() - o, o, o, bg);
} else {
-#if QT_CONFIG(opengl)
- if (m_use_opengl && m_glWindow->isValid()) {
- m_glWindow->makeCurrent();
-
- painter.begin(m_glWindow);
- painter.fillRect(QRectF(0, 0, m_glWindow->width(), m_glWindow->height()), palette().color(backgroundRole()));
- } else {
- painter.begin(this);
- }
-#else
painter.begin(this);
-#endif
}
painter.setClipRect(e->rect());
@@ -205,27 +94,15 @@ void ArthurFrame::paintEvent(QPaintEvent *e)
painter.setBrush(Qt::NoBrush);
painter.drawPath(clipPath);
- if (preferImage()
-#if QT_CONFIG(opengl)
- && !m_use_opengl
-#endif
- ) {
+ if (preferImage()) {
painter.end();
painter.begin(this);
painter.drawImage(e->rect(), *static_image, e->rect());
}
-#if QT_CONFIG(opengl)
- if (m_use_opengl)
- m_glWindow->update();
-#endif
}
void ArthurFrame::resizeEvent(QResizeEvent *e)
{
-#if QT_CONFIG(opengl)
- if (m_glWidget)
- m_glWidget->setGeometry(0, 0, e->size().width(), e->size().height());
-#endif
QWidget::resizeEvent(e);
}