Move QOpenGLWidget from QtOpenGL to its own module

Same pattern as QtQuickWidgets. Gets rid of QtOpenGL's dependency on QtWidgets.

Task-number: QTBUG-74409
Change-Id: I4f9b55c23e25a1e0519734037b768a16e870c7d2
Reviewed-by: Laszlo Agocs <laszlo.agocs@qt.io>
This commit is contained in:
Johan Klokkhammer Helsing 2020-02-04 11:47:39 +01:00
parent 077959972b
commit 00eeed234f
33 changed files with 141 additions and 43 deletions

View File

@ -1,4 +1,4 @@
QT += widgets opengl
QT += widgets opengl openglwidgets
HEADERS = glwidget.h \
helper.h \

View File

@ -15,6 +15,7 @@ find_package(Qt6 COMPONENTS Core)
find_package(Qt6 COMPONENTS Gui)
find_package(Qt6 COMPONENTS Widgets)
find_package(Qt6 COMPONENTS OpenGL)
find_package(Qt6 COMPONENTS OpenGLWidgets)
add_qt_gui_executable(2dpainting
glwidget.cpp glwidget.h
@ -27,6 +28,7 @@ target_link_libraries(2dpainting PUBLIC
Qt::Core
Qt::Gui
Qt::OpenGL
Qt::OpenGLWidgets
Qt::Widgets
)

View File

@ -15,6 +15,7 @@ find_package(Qt6 COMPONENTS Core)
find_package(Qt6 COMPONENTS Gui)
find_package(Qt6 COMPONENTS Widgets)
find_package(Qt6 COMPONENTS OpenGL)
find_package(Qt6 COMPONENTS OpenGLWidgets)
add_qt_gui_executable(cube
geometryengine.cpp geometryengine.h
@ -25,6 +26,7 @@ target_link_libraries(cube PUBLIC
Qt::Core
Qt::Gui
Qt::OpenGL
Qt::OpenGLWidgets
Qt::Widgets
)

View File

@ -1,4 +1,4 @@
QT += core gui widgets opengl
QT += core gui widgets opengl openglwidgets
TARGET = cube
TEMPLATE = app

View File

@ -15,6 +15,7 @@ find_package(Qt6 COMPONENTS Core)
find_package(Qt6 COMPONENTS Gui)
find_package(Qt6 COMPONENTS Widgets)
find_package(Qt6 COMPONENTS OpenGL)
find_package(Qt6 COMPONENTS OpenGLWidgets)
add_qt_gui_executable(hellogl2
glwidget.cpp glwidget.h
@ -27,6 +28,7 @@ target_link_libraries(hellogl2 PUBLIC
Qt::Core
Qt::Gui
Qt::OpenGL
Qt::OpenGLWidgets
Qt::Widgets
)

View File

@ -8,7 +8,7 @@ SOURCES = glwidget.cpp \
mainwindow.cpp \
logo.cpp
QT += widgets opengl
QT += widgets opengl openglwidgets
# install
target.path = $$[QT_INSTALL_EXAMPLES]/opengl/hellogl2

View File

@ -15,6 +15,7 @@ find_package(Qt6 COMPONENTS Core)
find_package(Qt6 COMPONENTS Gui)
find_package(Qt6 COMPONENTS Widgets)
find_package(Qt6 COMPONENTS OpenGL)
find_package(Qt6 COMPONENTS OpenGLWidgets)
add_qt_gui_executable(qopenglwidget
bubble.cpp bubble.h
@ -26,6 +27,7 @@ target_link_libraries(qopenglwidget PUBLIC
Qt::Core
Qt::Gui
Qt::OpenGL
Qt::OpenGLWidgets
Qt::Widgets
)

View File

@ -1,4 +1,4 @@
QT += widgets opengl
QT += widgets opengl openglwidgets
SOURCES += main.cpp \
glwidget.cpp \

View File

@ -15,6 +15,7 @@ find_package(Qt6 COMPONENTS Core)
find_package(Qt6 COMPONENTS Gui)
find_package(Qt6 COMPONENTS Widgets)
find_package(Qt6 COMPONENTS OpenGL)
find_package(Qt6 COMPONENTS OpenGLWidgets)
add_qt_gui_executable(textures
glwidget.cpp glwidget.h
@ -25,6 +26,7 @@ target_link_libraries(textures PUBLIC
Qt::Core
Qt::Gui
Qt::OpenGL
Qt::OpenGLWidgets
Qt::Widgets
)

View File

@ -6,7 +6,7 @@ SOURCES = glwidget.cpp \
RESOURCES = textures.qrc
QT += widgets opengl
QT += widgets opengl openglwidgets
# install
target.path = $$[QT_INSTALL_EXAMPLES]/opengl/textures

View File

@ -15,6 +15,7 @@ find_package(Qt6 COMPONENTS Core)
find_package(Qt6 COMPONENTS Gui)
find_package(Qt6 COMPONENTS Widgets)
find_package(Qt6 COMPONENTS OpenGL)
find_package(Qt6 COMPONENTS OpenGLWidgets)
add_qt_gui_executable(threadedqopenglwidget
glwidget.cpp glwidget.h
@ -25,6 +26,7 @@ target_link_libraries(threadedqopenglwidget PUBLIC
Qt::Core
Qt::Gui
Qt::OpenGL
Qt::OpenGLWidgets
Qt::Widgets
)

View File

@ -1,4 +1,4 @@
QT += widgets opengl
QT += widgets opengl openglwidgets
SOURCES += main.cpp \
glwidget.cpp \

View File

@ -53,6 +53,7 @@ qt6_add_resources(padnavigator "padnavigator"
if(TARGET Qt::OpenGL)
target_link_libraries(padnavigator PUBLIC
Qt::OpenGL
Qt::OpenGLWidgets
)
endif()

View File

@ -54,6 +54,7 @@ qt6_add_resources(padnavigator "padnavigator"
if(TARGET Qt::OpenGL)
target_link_libraries(padnavigator PUBLIC
Qt::OpenGL
Qt::OpenGLWidgets
)
endif()

View File

@ -18,7 +18,7 @@ FORMS += \
QT += widgets
requires(qtConfig(treewidget))
qtHaveModule(opengl): QT += opengl
qtHaveModule(opengl): QT += opengl openglwidgets
# install
target.path = $$[QT_INSTALL_EXAMPLES]/widgets/graphicsview/padnavigator

View File

@ -41,6 +41,9 @@ if(QT_FEATURE_gui)
if(QT_FEATURE_widgets)
add_subdirectory(widgets)
if(QT_FEATURE_opengl)
add_subdirectory(openglwidgets)
endif()
endif()
add_subdirectory(platformsupport)
add_subdirectory(platformheaders)

View File

@ -42,17 +42,6 @@ qt_add_module(OpenGL
## Scopes:
#####################################################################
qt_extend_target(OpenGL CONDITION QT_FEATURE_widgets
SOURCES
qopenglwidget.cpp qopenglwidget.h
LIBRARIES
Qt::WidgetsPrivate
PUBLIC_LIBRARIES
Qt::Widgets
PRIVATE_MODULE_INTERFACE
Qt::WidgetsPrivate
)
qt_extend_target(OpenGL CONDITION NOT QT_FEATURE_opengles2
SOURCES
qopenglqueryhelper_p.h

View File

@ -1,6 +1,5 @@
TARGET = QtOpenGL
QT = core-private gui-private
qtConfig(widgets): QT += widgets widgets-private
DEFINES += QT_NO_USING_NAMESPACE QT_NO_FOREACH
@ -59,9 +58,4 @@ SOURCES += \
SOURCES += qopengltimerquery.cpp
}
qtConfig(widgets) {
HEADERS += qopenglwidget.h
SOURCES += qopenglwidget.cpp
}
load(qt_module)

View File

@ -0,0 +1,19 @@
# Generated from openglwidgets.pro.
#####################################################################
## OpenGLWidgets Module:
#####################################################################
qt_add_module(OpenGLWidgets
SOURCES
qopenglwidget.cpp qopenglwidget.h
DEFINES
QT_NO_FOREACH
QT_NO_USING_NAMESPACE
LIBRARIES
Qt::OpenGLPrivate
Qt::WidgetsPrivate
PUBLIC_LIBRARIES
Qt::OpenGL
Qt::Widgets
)

View File

@ -0,0 +1,13 @@
TARGET = QtOpenGLWidgets
QT = opengl widgets
QT_PRIVATE += opengl-private widgets-private
DEFINES += QT_NO_USING_NAMESPACE QT_NO_FOREACH
HEADERS += \
qopenglwidget.h
SOURCES += \
qopenglwidget.cpp
load(qt_module)

View File

@ -3,7 +3,7 @@
** Copyright (C) 2016 The Qt Company Ltd.
** Contact: https://www.qt.io/licensing/
**
** This file is part of the QtOpenGL module of the Qt Toolkit.
** This file is part of the QtOpenGLWidgets module of the Qt Toolkit.
**
** $QT_BEGIN_LICENSE:LGPL$
** Commercial License Usage
@ -62,7 +62,7 @@ QT_BEGIN_NAMESPACE
/*!
\class QOpenGLWidget
\inmodule QtOpenGL
\inmodule QtOpenGLWidgets
\since 5.4
\brief The QOpenGLWidget class is a widget for rendering OpenGL graphics.

View File

@ -3,7 +3,7 @@
** Copyright (C) 2016 The Qt Company Ltd.
** Contact: https://www.qt.io/licensing/
**
** This file is part of the QtOpenGL module of the Qt Toolkit.
** This file is part of the QtOpenGLWidgets module of the Qt Toolkit.
**
** $QT_BEGIN_LICENSE:LGPL$
** Commercial License Usage
@ -40,9 +40,7 @@
#ifndef QOPENGLWIDGET_H
#define QOPENGLWIDGET_H
#include <QtOpenGL/qtopenglglobal.h>
#ifdef QT_WIDGETS_LIB
#include <QtOpenGLWidgets/qtopenglwidgetsglobal.h>
#include <QtWidgets/QWidget>
#include <QtGui/QSurfaceFormat>
@ -52,7 +50,7 @@ QT_BEGIN_NAMESPACE
class QOpenGLWidgetPrivate;
class Q_OPENGL_EXPORT QOpenGLWidget : public QWidget
class Q_OPENGLWIDGETS_EXPORT QOpenGLWidget : public QWidget
{
Q_OBJECT
Q_DECLARE_PRIVATE(QOpenGLWidget)
@ -110,6 +108,4 @@ private:
QT_END_NAMESPACE
#endif // QT_WIDGETS_LIB
#endif // QOPENGLWIDGET_H

View File

@ -0,0 +1,59 @@
/****************************************************************************
**
** Copyright (C) 2020 The Qt Company Ltd.
** Contact: https://www.qt.io/licensing/
**
** This file is part of the QtOpenGLWidgets module of the Qt Toolkit.
**
** $QT_BEGIN_LICENSE:LGPL$
** 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.
**
** GNU Lesser General Public License Usage
** Alternatively, this file may be used under the terms of the GNU Lesser
** General Public License version 3 as published by the Free Software
** Foundation and appearing in the file LICENSE.LGPL3 included in the
** packaging of this file. Please review the following information to
** ensure the GNU Lesser General Public License version 3 requirements
** will be met: https://www.gnu.org/licenses/lgpl-3.0.html.
**
** GNU General Public License Usage
** Alternatively, this file may be used under the terms of the GNU
** General Public License version 2.0 or (at your option) the GNU General
** Public license version 3 or any later version approved by the KDE Free
** Qt Foundation. The licenses are as published by the Free Software
** Foundation and appearing in the file LICENSE.GPL2 and LICENSE.GPL3
** included in the packaging of this file. Please review the following
** information to ensure the GNU General Public License requirements will
** be met: https://www.gnu.org/licenses/gpl-2.0.html and
** https://www.gnu.org/licenses/gpl-3.0.html.
**
** $QT_END_LICENSE$
**
****************************************************************************/
#ifndef QTOPENGLWIDGETSGLOBAL_H
#define QTOPENGLWIDGETSGLOBAL_H
#include <QtCore/qglobal.h>
QT_BEGIN_NAMESPACE
#ifndef QT_STATIC
# if defined(QT_BUILD_OPENGLWIDGETS_LIB)
# define Q_OPENGLWIDGETS_EXPORT Q_DECL_EXPORT
# else
# define Q_OPENGLWIDGETS_EXPORT Q_DECL_IMPORT
# endif
#else
# define Q_OPENGLWIDGETS_EXPORT
#endif
QT_END_NAMESPACE
#endif // QTOPENGLWIDGETSGLOBAL_H

View File

@ -136,6 +136,10 @@ src_opengl.subdir = $$PWD/opengl
src_opengl.target = sub-opengl
src_opengl.depends = src_gui
src_openglwidgets.subdir = $$PWD/openglwidgets
src_openglwidgets.target = sub-openglwidgets
src_openglwidgets.depends = src_opengl src_widgets
src_openglextensions.subdir = $$PWD/openglextensions
src_openglextensions.target = sub-openglextensions
src_openglextensions.depends = src_gui
@ -230,11 +234,13 @@ qtConfig(gui) {
TOOLS += src_tools_uic
src_plugins.depends += src_widgets
src_testlib.depends += src_widgets # if QtWidgets is enabled, QtTest requires QtWidgets's headers
src_opengl.depends += src_widgets
qtConfig(printer) {
SUBDIRS += src_printsupport
src_plugins.depends += src_printsupport
}
qtConfig(opengl) {
SUBDIRS += src_openglwidgets
}
}
}
SUBDIRS += src_plugins

View File

@ -3,6 +3,7 @@
"QtWidgets" => "$basedir/src/widgets",
"QtPrintSupport" => "$basedir/src/printsupport",
"QtOpenGL" => "$basedir/src/opengl",
"QtOpenGLWidgets" => "$basedir/src/openglwidgets",
"QtCore" => "$basedir/src/corelib",
"QtXml" => "$basedir/src/xml",
"QtSql" => "$basedir/src/sql",

View File

@ -1,4 +1,6 @@
if (QT_FEATURE_private_tests)
# Generated from graphicsview.pro.
if(QT_FEATURE_private_tests)
add_subdirectory(qgraphicsanchorlayout)
add_subdirectory(qgraphicsanchorlayout1)
add_subdirectory(qgraphicsitem)
@ -15,11 +17,10 @@ add_subdirectory(qgraphicsobject)
add_subdirectory(qgraphicspixmapitem)
add_subdirectory(qgraphicspolygonitem)
add_subdirectory(qgraphicstransform)
if (NOT WINRT)
add_subdirectory(qgraphicsview)
endif()
if(QT_FEATURE_style_fusion)
add_subdirectory(qgraphicsproxywidget)
add_subdirectory(qgraphicswidget)
endif()
if(NOT WINRT)
add_subdirectory(qgraphicsview)
endif()

View File

@ -28,4 +28,5 @@ add_qt_test(tst_qgraphicsview
extend_target(tst_qgraphicsview CONDITION QT_FEATURE_opengl
PUBLIC_LIBRARIES
Qt::OpenGL
Qt::OpenGLWidgets
)

View File

@ -4,7 +4,7 @@ TARGET = tst_qgraphicsview
QT += widgets widgets-private testlib
QT += core-private gui-private testlib-private
qtConfig(opengl): QT += opengl
qtConfig(opengl): QT += opengl openglwidgets
SOURCES += tst_qgraphicsview.cpp tst_qgraphicsview_2.cpp
HEADERS += tst_qgraphicsview.h

View File

@ -49,7 +49,7 @@
#include <QtWidgets/QStyle>
#include <QtWidgets/QPushButton>
#if QT_CONFIG(opengl)
#include <QtOpenGL/QOpenGLWidget>
#include <QtOpenGLWidgets/QOpenGLWidget>
#endif
#include <private/qgraphicsscene_p.h>
#include <private/qgraphicsview_p.h>

View File

@ -13,5 +13,6 @@ add_qt_test(tst_qopenglwidget
Qt::GuiPrivate
Qt::OpenGL
Qt::OpenGLPrivate
Qt::OpenGLWidgets
Qt::Widgets
)

View File

@ -1,5 +1,5 @@
CONFIG += testcase
TARGET = tst_qopenglwidget
QT += opengl opengl-private gui-private core-private testlib widgets
QT += opengl opengl-private gui-private core-private testlib widgets openglwidgets
SOURCES += tst_qopenglwidget.cpp

View File

@ -26,7 +26,7 @@
**
****************************************************************************/
#include <QtOpenGL/QOpenGLWidget>
#include <QtOpenGLWidgets/QOpenGLWidget>
#include <QtGui/QOpenGLFunctions>
#include <QtGui/QPainter>
#include <QtGui/QScreen>

View File

@ -213,6 +213,7 @@ _qt_library_map = [
"openglextensions", "Qt6", "Qt::OpenGLExtensions", extra=["COMPONENTS", "OpenGLExtensions"]
),
LibraryMapping("opengl", "Qt6", "Qt::OpenGL", extra=["COMPONENTS", "OpenGL"]),
LibraryMapping("openglwidgets", "Qt6", "Qt::OpenGLWidgets", extra=["COMPONENTS", "OpenGLWidgets"]),
LibraryMapping(
"package-lib", "Qt6", "Qt::AppManPackage", extra=["COMPONENTS", "AppManPackage"]
),