Skip to content

Commit

Permalink
Move QOpenGLWidget from QtOpenGL to its own module
Browse files Browse the repository at this point in the history
Same pattern as QtQuickWidgets. Gets rid of QtOpenGL's dependency on QtWidgets.

Task-number: QTBUG-74409
Change-Id: I4f9b55c23e25a1e0519734037b768a16e870c7d2
Reviewed-by: Laszlo Agocs <[email protected]>
  • Loading branch information
Johan Klokkhammer Helsing committed Feb 18, 2020
1 parent 0779599 commit 00eeed2
Show file tree
Hide file tree
Showing 33 changed files with 141 additions and 43 deletions.
2 changes: 1 addition & 1 deletion examples/opengl/2dpainting/2dpainting.pro
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
QT += widgets opengl
QT += widgets opengl openglwidgets

HEADERS = glwidget.h \
helper.h \
Expand Down
2 changes: 2 additions & 0 deletions examples/opengl/2dpainting/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -27,6 +28,7 @@ target_link_libraries(2dpainting PUBLIC
Qt::Core
Qt::Gui
Qt::OpenGL
Qt::OpenGLWidgets
Qt::Widgets
)

Expand Down
2 changes: 2 additions & 0 deletions examples/opengl/cube/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -25,6 +26,7 @@ target_link_libraries(cube PUBLIC
Qt::Core
Qt::Gui
Qt::OpenGL
Qt::OpenGLWidgets
Qt::Widgets
)

Expand Down
2 changes: 1 addition & 1 deletion examples/opengl/cube/cube.pro
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
QT += core gui widgets opengl
QT += core gui widgets opengl openglwidgets

TARGET = cube
TEMPLATE = app
Expand Down
2 changes: 2 additions & 0 deletions examples/opengl/hellogl2/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -27,6 +28,7 @@ target_link_libraries(hellogl2 PUBLIC
Qt::Core
Qt::Gui
Qt::OpenGL
Qt::OpenGLWidgets
Qt::Widgets
)

Expand Down
2 changes: 1 addition & 1 deletion examples/opengl/hellogl2/hellogl2.pro
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
2 changes: 2 additions & 0 deletions examples/opengl/qopenglwidget/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -26,6 +27,7 @@ target_link_libraries(qopenglwidget PUBLIC
Qt::Core
Qt::Gui
Qt::OpenGL
Qt::OpenGLWidgets
Qt::Widgets
)

Expand Down
2 changes: 1 addition & 1 deletion examples/opengl/qopenglwidget/qopenglwidget.pro
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
QT += widgets opengl
QT += widgets opengl openglwidgets

SOURCES += main.cpp \
glwidget.cpp \
Expand Down
2 changes: 2 additions & 0 deletions examples/opengl/textures/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -25,6 +26,7 @@ target_link_libraries(textures PUBLIC
Qt::Core
Qt::Gui
Qt::OpenGL
Qt::OpenGLWidgets
Qt::Widgets
)

Expand Down
2 changes: 1 addition & 1 deletion examples/opengl/textures/textures.pro
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
2 changes: 2 additions & 0 deletions examples/opengl/threadedqopenglwidget/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -25,6 +26,7 @@ target_link_libraries(threadedqopenglwidget PUBLIC
Qt::Core
Qt::Gui
Qt::OpenGL
Qt::OpenGLWidgets
Qt::Widgets
)

Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
QT += widgets opengl
QT += widgets opengl openglwidgets

SOURCES += main.cpp \
glwidget.cpp \
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -53,6 +53,7 @@ qt6_add_resources(padnavigator "padnavigator"
if(TARGET Qt::OpenGL)
target_link_libraries(padnavigator PUBLIC
Qt::OpenGL
Qt::OpenGLWidgets
)
endif()

Expand Down
1 change: 1 addition & 0 deletions examples/widgets/graphicsview/padnavigator/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -54,6 +54,7 @@ qt6_add_resources(padnavigator "padnavigator"
if(TARGET Qt::OpenGL)
target_link_libraries(padnavigator PUBLIC
Qt::OpenGL
Qt::OpenGLWidgets
)
endif()

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
3 changes: 3 additions & 0 deletions src/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down
11 changes: 0 additions & 11 deletions src/opengl/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
6 changes: 0 additions & 6 deletions src/opengl/opengl.pro
Original file line number Diff line number Diff line change
@@ -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

Expand Down Expand Up @@ -59,9 +58,4 @@ SOURCES += \
SOURCES += qopengltimerquery.cpp
}

qtConfig(widgets) {
HEADERS += qopenglwidget.h
SOURCES += qopenglwidget.cpp
}

load(qt_module)
19 changes: 19 additions & 0 deletions src/openglwidgets/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -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
)
13 changes: 13 additions & 0 deletions src/openglwidgets/openglwidgets.pro
Original file line number Diff line number Diff line change
@@ -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)
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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.
Expand Down
10 changes: 3 additions & 7 deletions src/opengl/qopenglwidget.h → src/openglwidgets/qopenglwidget.h
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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>
Expand All @@ -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)
Expand Down Expand Up @@ -110,6 +108,4 @@ class Q_OPENGL_EXPORT QOpenGLWidget : public QWidget

QT_END_NAMESPACE

#endif // QT_WIDGETS_LIB

#endif // QOPENGLWIDGET_H
59 changes: 59 additions & 0 deletions src/openglwidgets/qtopenglwidgetsglobal.h
Original file line number Diff line number Diff line change
@@ -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
8 changes: 7 additions & 1 deletion src/src.pro
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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
Expand Down
1 change: 1 addition & 0 deletions sync.profile
Original file line number Diff line number Diff line change
Expand Up @@ -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",
Expand Down
Loading

0 comments on commit 00eeed2

Please sign in to comment.