diff options
author | Friedemann Kleint <Friedemann.Kleint@qt.io> | 2020-10-06 10:55:34 +0200 |
---|---|---|
committer | Friedemann Kleint <Friedemann.Kleint@qt.io> | 2020-10-06 10:55:34 +0200 |
commit | 0e3a58441644faa14698a44f2ed682150430529a (patch) | |
tree | de19c693a802abf6f020867f6ca8e912b0d019c6 | |
parent | 82934bc00c2de7ea51fd7e95601472fcdf7b6aea (diff) | |
parent | b57f329ecbf1fd0b29ae0e8284c885adc0eb4ed3 (diff) |
Merge remote-tracking branch 'origin/5.15' into dev
Change-Id: I7b4ff138799ee81940c36e68a105cb42bb38a3ff
24 files changed, 201 insertions, 131 deletions
diff --git a/examples/widgets/layouts/flowlayout.py b/examples/widgets/layouts/flowlayout.py index f63fd5549..970d5ac07 100644 --- a/examples/widgets/layouts/flowlayout.py +++ b/examples/widgets/layouts/flowlayout.py @@ -2,7 +2,7 @@ ############################################################################ ## ## Copyright (C) 2013 Riverbank Computing Limited. -## Copyright (C) 2016 The Qt Company Ltd. +## Copyright (C) 2020 The Qt Company Ltd. ## Contact: http://www.qt.io/licensing/ ## ## This file is part of the Qt for Python examples of the Qt Toolkit. @@ -42,34 +42,34 @@ """PySide2 port of the widgets/layouts/flowlayout example from Qt v5.x""" -from PySide2 import QtCore, QtWidgets +import sys +from PySide2.QtCore import Qt, QMargins, QPoint, QRect, QSize +from PySide2.QtWidgets import (QApplication, QLayout, QPushButton, + QSizePolicy, QWidget) -class Window(QtWidgets.QWidget): +class Window(QWidget): def __init__(self): super(Window, self).__init__() - flowLayout = FlowLayout() - flowLayout.addWidget(QtWidgets.QPushButton("Short")) - flowLayout.addWidget(QtWidgets.QPushButton("Longer")) - flowLayout.addWidget(QtWidgets.QPushButton("Different text")) - flowLayout.addWidget(QtWidgets.QPushButton("More text")) - flowLayout.addWidget(QtWidgets.QPushButton("Even longer button text")) - self.setLayout(flowLayout) + flowLayout = FlowLayout(self) + flowLayout.addWidget(QPushButton("Short")) + flowLayout.addWidget(QPushButton("Longer")) + flowLayout.addWidget(QPushButton("Different text")) + flowLayout.addWidget(QPushButton("More text")) + flowLayout.addWidget(QPushButton("Even longer button text")) self.setWindowTitle("Flow Layout") -class FlowLayout(QtWidgets.QLayout): - def __init__(self, parent=None, margin=0, spacing=-1): +class FlowLayout(QLayout): + def __init__(self, parent=None): super(FlowLayout, self).__init__(parent) if parent is not None: - self.setMargin(margin) + self.setContentsMargins(QMargins(0, 0, 0, 0)) - self.setSpacing(spacing) - - self.itemList = [] + self._item_list = [] def __del__(self): item = self.takeAt(0) @@ -77,79 +77,84 @@ class FlowLayout(QtWidgets.QLayout): item = self.takeAt(0) def addItem(self, item): - self.itemList.append(item) + self._item_list.append(item) def count(self): - return len(self.itemList) + return len(self._item_list) def itemAt(self, index): - if index >= 0 and index < len(self.itemList): - return self.itemList[index] + if index >= 0 and index < len(self._item_list): + return self._item_list[index] return None def takeAt(self, index): - if index >= 0 and index < len(self.itemList): - return self.itemList.pop(index) + if index >= 0 and index < len(self._item_list): + return self._item_list.pop(index) return None def expandingDirections(self): - return QtCore.Qt.Orientations(QtCore.Qt.Orientation(0)) + return Qt.Orientations(Qt.Orientation(0)) def hasHeightForWidth(self): return True def heightForWidth(self, width): - height = self.doLayout(QtCore.QRect(0, 0, width, 0), True) + height = self._do_layout(QRect(0, 0, width, 0), True) return height def setGeometry(self, rect): super(FlowLayout, self).setGeometry(rect) - self.doLayout(rect, False) + self._do_layout(rect, False) def sizeHint(self): return self.minimumSize() def minimumSize(self): - size = QtCore.QSize() + size = QSize() - for item in self.itemList: + for item in self._item_list: size = size.expandedTo(item.minimumSize()) - size += QtCore.QSize(2 * self.contentsMargins().top(), 2 * self.contentsMargins().top()) + size += QSize(2 * self.contentsMargins().top(), + 2 * self.contentsMargins().top()) return size - def doLayout(self, rect, testOnly): + def _do_layout(self, rect, test_only): x = rect.x() y = rect.y() - lineHeight = 0 - - for item in self.itemList: - wid = item.widget() - spaceX = self.spacing() + wid.style().layoutSpacing(QtWidgets.QSizePolicy.PushButton, QtWidgets.QSizePolicy.PushButton, QtCore.Qt.Horizontal) - spaceY = self.spacing() + wid.style().layoutSpacing(QtWidgets.QSizePolicy.PushButton, QtWidgets.QSizePolicy.PushButton, QtCore.Qt.Vertical) - nextX = x + item.sizeHint().width() + spaceX - if nextX - spaceX > rect.right() and lineHeight > 0: + line_height = 0 + spacing = self.spacing() + + for item in self._item_list: + style = item.widget().style() + layout_spacing_x = style.layoutSpacing(QSizePolicy.PushButton, + QSizePolicy.PushButton, + Qt.Horizontal) + layout_spacing_y = style.layoutSpacing(QSizePolicy.PushButton, + QSizePolicy.PushButton, + Qt.Vertical) + space_x = spacing + layout_spacing_x + space_y = spacing + layout_spacing_y + next_x = x + item.sizeHint().width() + space_x + if next_x - space_x > rect.right() and line_height > 0: x = rect.x() - y = y + lineHeight + spaceY - nextX = x + item.sizeHint().width() + spaceX - lineHeight = 0 + y = y + line_height + space_y + next_x = x + item.sizeHint().width() + space_x + line_height = 0 - if not testOnly: - item.setGeometry(QtCore.QRect(QtCore.QPoint(x, y), item.sizeHint())) + if not test_only: + item.setGeometry(QRect(QPoint(x, y), item.sizeHint())) - x = nextX - lineHeight = max(lineHeight, item.sizeHint().height()) + x = next_x + line_height = max(line_height, item.sizeHint().height()) - return y + lineHeight - rect.y() + return y + line_height - rect.y() if __name__ == '__main__': - - import sys - - app = QtWidgets.QApplication(sys.argv) + app = QApplication(sys.argv) mainWin = Window() mainWin.show() sys.exit(app.exec_()) diff --git a/sources/pyside2/PySide2/QtWebEngineCore/CMakeLists.txt b/sources/pyside2/PySide2/QtWebEngineCore/CMakeLists.txt index f0fb1eeda..52a071606 100644 --- a/sources/pyside2/PySide2/QtWebEngineCore/CMakeLists.txt +++ b/sources/pyside2/PySide2/QtWebEngineCore/CMakeLists.txt @@ -21,14 +21,17 @@ set(QtWebEngineCore_include_dirs ${QtWebEngineCore_SOURCE_DIR} ${QtWebEngineCore_BINARY_DIR} ${Qt${QT_MAJOR_VERSION}Core_INCLUDE_DIRS} + ${Qt${QT_MAJOR_VERSION}Network_INCLUDE_DIRS} ${libpyside_SOURCE_DIR} ${QtCore_GEN_DIR} + ${QtNetwork_GEN_DIR} ) set(QtWebEngineCore_libraries pyside2 ${Qt${QT_MAJOR_VERSION}WebEngineCore_LIBRARIES} ${Qt${QT_MAJOR_VERSION}Core_LIBRARIES} + ${Qt${QT_MAJOR_VERSION}Network_LIBRARIES} ) -set(QtWebEngineCore_deps QtCore) +set(QtWebEngineCore_deps QtCore QtNetwork) create_pyside_module(NAME QtWebEngineCore INCLUDE_DIRS QtWebEngineCore_include_dirs LIBRARIES QtWebEngineCore_libraries diff --git a/sources/pyside2/PySide2/QtWebEngineCore/typesystem_webenginecore.xml b/sources/pyside2/PySide2/QtWebEngineCore/typesystem_webenginecore.xml index eb1ab3d61..65c0e8137 100644 --- a/sources/pyside2/PySide2/QtWebEngineCore/typesystem_webenginecore.xml +++ b/sources/pyside2/PySide2/QtWebEngineCore/typesystem_webenginecore.xml @@ -41,6 +41,7 @@ --> <typesystem package="PySide2.QtWebEngineCore"> <load-typesystem name="QtCore/typesystem_core.xml" generate="no"/> + <load-typesystem name="QtNetwork/typesystem_network.xml" generate="no"/> <object-type name="QWebEngineCookieStore"/> diff --git a/sources/pyside2/doc/quickstart.rst b/sources/pyside2/doc/quickstart.rst index 5d8ddfe2d..b6a3dbbb3 100644 --- a/sources/pyside2/doc/quickstart.rst +++ b/sources/pyside2/doc/quickstart.rst @@ -9,7 +9,7 @@ Before you can install |project|, first you must install the following software: * Python 2.7 or 3.5+, * We recommend using a virtual environment, such as `venv <https://docs.python.org/3/library/venv.html>`_ or - `virtualenv <https://virtualenv.pypa.io/en/stable/installation>`_ + `virtualenv <https://virtualenv.pypa.io/en/latest>`_ Installation ------------ diff --git a/sources/pyside2/doc/tutorials/datavisualize/datavisualize3/main_window.py b/sources/pyside2/doc/tutorials/datavisualize/datavisualize3/main_window.py index 656609a55..d97db65aa 100644 --- a/sources/pyside2/doc/tutorials/datavisualize/datavisualize3/main_window.py +++ b/sources/pyside2/doc/tutorials/datavisualize/datavisualize3/main_window.py @@ -38,7 +38,7 @@ ## ############################################################################# -from PySide2.QtCore import Slot, qApp +from PySide2.QtCore import Slot from PySide2.QtGui import QAction, QKeySequence from PySide2.QtWidgets import QMainWindow diff --git a/sources/pyside2/doc/tutorials/datavisualize/datavisualize4/main_window.py b/sources/pyside2/doc/tutorials/datavisualize/datavisualize4/main_window.py index 2157b7b15..db9517f42 100644 --- a/sources/pyside2/doc/tutorials/datavisualize/datavisualize4/main_window.py +++ b/sources/pyside2/doc/tutorials/datavisualize/datavisualize4/main_window.py @@ -38,7 +38,7 @@ ## ############################################################################# -from PySide2.QtCore import Slot, qApp +from PySide2.QtCore import Slot from PySide2.QtGui import QAction, QKeySequence from PySide2.QtWidgets import QMainWindow diff --git a/sources/pyside2/doc/tutorials/datavisualize/datavisualize5/main_window.py b/sources/pyside2/doc/tutorials/datavisualize/datavisualize5/main_window.py index 30d6582ba..e8979ab25 100644 --- a/sources/pyside2/doc/tutorials/datavisualize/datavisualize5/main_window.py +++ b/sources/pyside2/doc/tutorials/datavisualize/datavisualize5/main_window.py @@ -38,7 +38,7 @@ ## ############################################################################# -from PySide2.QtCore import Slot, qApp +from PySide2.QtCore import Slot from PySide2.QtGui import QAction, QKeySequence from PySide2.QtWidgets import QMainWindow diff --git a/sources/pyside2/doc/tutorials/datavisualize/datavisualize6/main_window.py b/sources/pyside2/doc/tutorials/datavisualize/datavisualize6/main_window.py index 9e9ea8472..ef4e06f41 100644 --- a/sources/pyside2/doc/tutorials/datavisualize/datavisualize6/main_window.py +++ b/sources/pyside2/doc/tutorials/datavisualize/datavisualize6/main_window.py @@ -38,7 +38,7 @@ ## ############################################################################# -from PySide2.QtCore import Slot, qApp +from PySide2.QtCore import Slot from PySide2.QtGui import QAction, QKeySequence from PySide2.QtWidgets import QMainWindow diff --git a/sources/pyside2/doc/tutorials/portingguide/chapter3/bookwindow.py b/sources/pyside2/doc/tutorials/portingguide/chapter3/bookwindow.py index 8b0c7a6ad..792bcab51 100644 --- a/sources/pyside2/doc/tutorials/portingguide/chapter3/bookwindow.py +++ b/sources/pyside2/doc/tutorials/portingguide/chapter3/bookwindow.py @@ -41,7 +41,7 @@ from __future__ import print_function, absolute_import from PySide2.QtGui import QAction -from PySide2.QtWidgets import (QAbstractItemView, qApp, QDataWidgetMapper, +from PySide2.QtWidgets import (QAbstractItemView, QDataWidgetMapper, QHeaderView, QMainWindow, QMessageBox) from PySide2.QtGui import QKeySequence from PySide2.QtSql import (QSqlRelation, QSqlRelationalTableModel, QSqlTableModel, diff --git a/sources/pyside2/libpyside/CMakeLists.txt b/sources/pyside2/libpyside/CMakeLists.txt index d6b20c45a..e31c87eef 100644 --- a/sources/pyside2/libpyside/CMakeLists.txt +++ b/sources/pyside2/libpyside/CMakeLists.txt @@ -100,7 +100,7 @@ set_target_properties(pyside2 PROPERTIES VERSION ${BINDING_API_VERSION} SOVERSION "${PYSIDE_SO_VERSION}" OUTPUT_NAME "pyside2${pyside2_SUFFIX}${SHIBOKEN_PYTHON_SHARED_LIBRARY_SUFFIX}" - DEFINE_SYMBOL PYSIDE_EXPORTS) + DEFINE_SYMBOL BUILD_LIBPYSIDE) if(${QT_MAJOR_VERSION} GREATER_EQUAL 6) set_property(TARGET pyside2 PROPERTY CXX_STANDARD 17) diff --git a/sources/pyside2/libpyside/pysidemacros.h b/sources/pyside2/libpyside/pysidemacros.h index 5b493a279..fcdfe3c6e 100644 --- a/sources/pyside2/libpyside/pysidemacros.h +++ b/sources/pyside2/libpyside/pysidemacros.h @@ -1,6 +1,6 @@ /**************************************************************************** ** -** Copyright (C) 2016 The Qt Company Ltd. +** Copyright (C) 2020 The Qt Company Ltd. ** Contact: https://www.qt.io/licensing/ ** ** This file is part of Qt for Python. @@ -40,25 +40,16 @@ #ifndef PYSIDEMACROS_H #define PYSIDEMACROS_H -#if defined _WIN32 - #if PYSIDE_EXPORTS - #define PYSIDE_API __declspec(dllexport) - #else - #if defined __MINGW32__ - #define PYSIDE_API - #else - #define PYSIDE_API __declspec(dllimport) - #endif - #endif - #define PYSIDE_DEPRECATED(func) __declspec(deprecated) func +#include <shibokenmacros.h> + +#define PYSIDE_EXPORT LIBSHIBOKEN_EXPORT +#define PYSIDE_IMPORT LIBSHIBOKEN_IMPORT +#define PYSIDE_DEPRECATED(func) SBK_DEPRECATED(func) + +#ifdef BUILD_LIBPYSIDE +# define PYSIDE_API PYSIDE_EXPORT #else - #if __GNUC__ >= 4 - #define PYSIDE_API __attribute__ ((visibility("default"))) - #define PYSIDE_DEPRECATED(func) func __attribute__ ((deprecated)) - #else - #define PYSIDE_API - #define PYSIDE_DEPRECATED(func) func - #endif +# define PYSIDE_API PYSIDE_IMPORT #endif -#endif +#endif // PYSIDEMACROS_H diff --git a/sources/pyside2/tests/pysidetest/CMakeLists.txt b/sources/pyside2/tests/pysidetest/CMakeLists.txt index 2f7633e9a..972793519 100644 --- a/sources/pyside2/tests/pysidetest/CMakeLists.txt +++ b/sources/pyside2/tests/pysidetest/CMakeLists.txt @@ -65,6 +65,7 @@ endif() make_path(testbinding_include_dirs ${pyside2_BINARY_DIR} ${CMAKE_CURRENT_SOURCE_DIR} + ${CMAKE_CURRENT_SOURCE_DIR}/../../../shiboken2/libshiboken ${CMAKE_CURRENT_SOURCE_DIR}/../../PySide2 ${CMAKE_CURRENT_SOURCE_DIR}/../../libpyside ${QT_INCLUDE_DIR} @@ -103,6 +104,9 @@ include_directories(${CMAKE_CURRENT_SOURCE_DIR} ${libpyside_SOURCE_DIR}) add_library(pysidetest SHARED ${pysidetest_SRC} ${pysidetest_MOC_SRC}) +set_target_properties(pysidetest PROPERTIES + DEFINE_SYMBOL BUILD_PYSIDETEST) + target_link_libraries(pysidetest Shiboken2::libshiboken ${Qt${QT_MAJOR_VERSION}Core_LIBRARIES} diff --git a/sources/pyside2/tests/pysidetest/hiddenobject.h b/sources/pyside2/tests/pysidetest/hiddenobject.h index ffa8d614a..97a2864c5 100644 --- a/sources/pyside2/tests/pysidetest/hiddenobject.h +++ b/sources/pyside2/tests/pysidetest/hiddenobject.h @@ -29,11 +29,9 @@ #ifndef HIDDENOBJECT_H #define HIDDENOBJECT_H -#ifdef pysidetest_EXPORTS -#define PYSIDE_EXPORTS 1 -#endif -#include "pysidemacros.h" -#include <QObject> +#include "pysidetest_macros.h" + +#include <QtCore/QObject> // This class shouldn't be exported! class HiddenObject : public QObject @@ -49,7 +47,6 @@ private: }; // Return a instance of HiddenObject -PYSIDE_API QObject* getHiddenObject(); - +PYSIDETEST_API QObject* getHiddenObject(); #endif diff --git a/sources/pyside2/tests/pysidetest/pysidetest_global.h b/sources/pyside2/tests/pysidetest/pysidetest_global.h index 0077ade96..f65662cb5 100644 --- a/sources/pyside2/tests/pysidetest/pysidetest_global.h +++ b/sources/pyside2/tests/pysidetest/pysidetest_global.h @@ -1,6 +1,6 @@ /**************************************************************************** ** -** Copyright (C) 2016 The Qt Company Ltd. +** Copyright (C) 2020 The Qt Company Ltd. ** Contact: https://www.qt.io/licensing/ ** ** This file is part of the test suite of Qt for Python. @@ -26,9 +26,12 @@ ** ****************************************************************************/ +#ifndef PYSIDETEST_GLOBAL_H +#define PYSIDETEST_GLOBAL_H + // PySide global.h file -#include "pyside2_global.h" #include "testobject.h" #include "testview.h" -#define PYSIDE_API #include "hiddenobject.h" + +#endif // PYSIDETEST_GLOBAL_H diff --git a/sources/pyside2/tests/pysidetest/pysidetest_macros.h b/sources/pyside2/tests/pysidetest/pysidetest_macros.h new file mode 100644 index 000000000..b561efbbc --- /dev/null +++ b/sources/pyside2/tests/pysidetest/pysidetest_macros.h @@ -0,0 +1,43 @@ +/**************************************************************************** +** +** Copyright (C) 2020 The Qt Company Ltd. +** Contact: https://www.qt.io/licensing/ +** +** This file is part of the test suite of Qt for Python. +** +** $QT_BEGIN_LICENSE:GPL-EXCEPT$ +** 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 General Public License Usage +** Alternatively, this file may be used under the terms of the GNU +** General Public License version 3 as published by the Free Software +** Foundation with exceptions as appearing in the file LICENSE.GPL3-EXCEPT +** 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-3.0.html. +** +** $QT_END_LICENSE$ +** +****************************************************************************/ + +#ifndef PYSIDETEST_MACROS_H +#define PYSIDETEST_MACROS_H + +#include <pysidemacros.h> + +#define PYSIDETEST_EXPORT PYSIDE_EXPORT +#define PYSIDETEST_IMPORT PYSIDE_IMPORT + +#ifdef BUILD_PYSIDETEST +# define PYSIDETEST_API PYSIDETEST_EXPORT +#else +# define PYSIDETEST_API PYSIDETEST_IMPORT +#endif + +#endif // PYSIDETEST_MACROS_H diff --git a/sources/pyside2/tests/pysidetest/testobject.cpp b/sources/pyside2/tests/pysidetest/testobject.cpp index 441ae872f..43fa93bac 100644 --- a/sources/pyside2/tests/pysidetest/testobject.cpp +++ b/sources/pyside2/tests/pysidetest/testobject.cpp @@ -28,6 +28,8 @@ #include "testobject.h" +#include <QtCore/QDebug> + void TestObject::emitIdValueSignal() { emit idValue(m_idValue); diff --git a/sources/pyside2/tests/pysidetest/testobject.h b/sources/pyside2/tests/pysidetest/testobject.h index f8a174d46..41a97a0db 100644 --- a/sources/pyside2/tests/pysidetest/testobject.h +++ b/sources/pyside2/tests/pysidetest/testobject.h @@ -29,15 +29,15 @@ #ifndef TESTOBJECT_H #define TESTOBJECT_H -#include <QObject> -#include <QApplication> -#include <QMetaType> -#include <QVariant> -#include <QDebug> -#ifdef pysidetest_EXPORTS -#define PYSIDE_EXPORTS 1 -#endif -#include "pysidemacros.h" +#include "pysidetest_macros.h" + +#include <QtWidgets/QApplication> + +#include <QtCore/QObject> +#include <QtCore/QMetaType> +#include <QtCore/QVariant> + +QT_FORWARD_DECLARE_CLASS(QDebug) class IntValue { @@ -50,7 +50,7 @@ public: typedef IntValue TypedefValue; -class PYSIDE_API TestObject : public QObject +class PYSIDETEST_API TestObject : public QObject { Q_OBJECT public: @@ -82,15 +82,15 @@ private: int m_idValue; QList<QObject*> m_children; }; -PYSIDE_API QDebug operator<<(QDebug dbg, TestObject &testObject); +PYSIDETEST_API QDebug operator<<(QDebug dbg, TestObject &testObject); typedef int PySideInt; namespace PySideCPP { -class PYSIDE_API TestObjectWithNamespace : public QObject +class PYSIDETEST_API TestObjectWithNamespace : public QObject { Q_OBJECT public: @@ -106,17 +106,18 @@ signals: void emitSignalWithNamespace(PySideCPP::TestObjectWithNamespace* obj); void emitSignalWithTypedef(PySideInt val); }; -PYSIDE_API QDebug operator<<(QDebug dbg, TestObjectWithNamespace &testObject); -class PYSIDE_API TestObject2WithNamespace : public QObject +PYSIDETEST_API QDebug operator<<(QDebug dbg, TestObjectWithNamespace &testObject); + +class PYSIDETEST_API TestObject2WithNamespace : public QObject { Q_OBJECT public: TestObject2WithNamespace(QObject* parent) : QObject(parent) {} QString name() { return "TestObject2WithNamespace"; } }; -PYSIDE_API QDebug operator<<(QDebug dbg, TestObject2WithNamespace& testObject); +PYSIDETEST_API QDebug operator<<(QDebug dbg, TestObject2WithNamespace& testObject); } // Namespace PySideCPP @@ -127,7 +128,7 @@ enum Enum1 { Option1 = 1, Option2 = 2 }; typedef long PySideLong; -class PYSIDE_API TestObjectWithoutNamespace : public QObject +class PYSIDETEST_API TestObjectWithoutNamespace : public QObject { Q_OBJECT public: diff --git a/sources/pyside2/tests/pysidetest/testview.h b/sources/pyside2/tests/pysidetest/testview.h index 66d0a94d9..b80a7fca9 100644 --- a/sources/pyside2/tests/pysidetest/testview.h +++ b/sources/pyside2/tests/pysidetest/testview.h @@ -29,11 +29,9 @@ #ifndef TESTVIEW_H #define TESTVIEW_H -#include <QObject> -#ifdef pysidetest_EXPORTS -#define PYSIDE_EXPORTS 1 -#endif -#include "pysidemacros.h" +#include "pysidetest_macros.h" + +#include <QtCore/QObject> QT_BEGIN_NAMESPACE class QWidget; @@ -41,7 +39,7 @@ class QAbstractListModel; class QAbstractItemDelegate; QT_END_NAMESPACE -class PYSIDE_API TestView : public QObject +class PYSIDETEST_API TestView : public QObject { Q_OBJECT public: diff --git a/sources/shiboken2/ApiExtractor/apiextractor.cpp b/sources/shiboken2/ApiExtractor/apiextractor.cpp index 3fdd613ae..aa552cdd3 100644 --- a/sources/shiboken2/ApiExtractor/apiextractor.cpp +++ b/sources/shiboken2/ApiExtractor/apiextractor.cpp @@ -172,7 +172,20 @@ int ApiExtractor::classCount() const return m_builder->classes().count(); } -bool ApiExtractor::run() +// Add defines required for parsing Qt code headers +static void addPySideExtensions(QByteArrayList *a) +{ + // Make "signals:", "slots:" visible as access specifiers + a->append(QByteArrayLiteral("-DQT_ANNOTATE_ACCESS_SPECIFIER(a)=__attribute__((annotate(#a)))")); + + // Q_PROPERTY is defined as class annotation which does not work since a + // sequence of properties will to expand to a sequence of annotations + // annotating nothing, causing clang to complain. Instead, define it away in a + // static assert with the stringified argument in a ','-operator (cf qdoc). + a->append(QByteArrayLiteral("-DQT_ANNOTATE_CLASS(type,...)=static_assert(sizeof(#__VA_ARGS__),#type);")); +} + +bool ApiExtractor::run(bool usePySideExtensions) { if (m_builder) return false; @@ -215,6 +228,10 @@ bool ApiExtractor::run() << "clang language level: " << int(m_languageLevel) << "\nclang arguments: " << arguments; } + + if (usePySideExtensions) + addPySideExtensions(&arguments); + const bool result = m_builder->build(arguments, m_languageLevel); if (!result) autoRemove = false; diff --git a/sources/shiboken2/ApiExtractor/apiextractor.h b/sources/shiboken2/ApiExtractor/apiextractor.h index b0c2c696f..9c79ae7a5 100644 --- a/sources/shiboken2/ApiExtractor/apiextractor.h +++ b/sources/shiboken2/ApiExtractor/apiextractor.h @@ -93,7 +93,7 @@ public: int classCount() const; - bool run(); + bool run(bool usePySideExtensions); private: QString m_typeSystemFileName; QFileInfoList m_cppFileNames; diff --git a/sources/shiboken2/generator/main.cpp b/sources/shiboken2/generator/main.cpp index 201603f38..3c5c5876c 100644 --- a/sources/shiboken2/generator/main.cpp +++ b/sources/shiboken2/generator/main.cpp @@ -612,7 +612,10 @@ int main(int argc, char *argv[]) extractor.setCppFileNames(cppFileNames); extractor.setTypeSystem(typeSystemFileName); - if (!extractor.run()) { + auto shibokenGenerator = dynamic_cast<const ShibokenGenerator *>(generators.constFirst().data()); + const bool usePySideExtensions = shibokenGenerator && shibokenGenerator->usePySideExtensions(); + + if (!extractor.run(usePySideExtensions)) { errorPrint(QLatin1String("Error running ApiExtractor.")); return EXIT_FAILURE; } diff --git a/sources/shiboken2/generator/shiboken2/shibokengenerator.h b/sources/shiboken2/generator/shiboken2/shibokengenerator.h index 33da01a3a..6d36026cd 100644 --- a/sources/shiboken2/generator/shiboken2/shibokengenerator.h +++ b/sources/shiboken2/generator/shiboken2/shibokengenerator.h @@ -90,6 +90,9 @@ public: /// Returns a list of all ancestor classes for the given class. AbstractMetaClassList getAllAncestors(const AbstractMetaClass *metaClass) const; + /// Returns true if the user enabled PySide extensions. + bool usePySideExtensions() const; + protected: bool doSetup() override; @@ -377,8 +380,6 @@ protected: bool useCtorHeuristic() const; /// Returns true if the user enabled the so called "return value heuristic". bool useReturnValueHeuristic() const; - /// Returns true if the user enabled PySide extensions. - bool usePySideExtensions() const; /// Returns true if the generator should use the result of isNull()const to compute boolean casts. bool useIsNullAsNbNonZero() const; /// Returns true if the generated code should use the "#define protected public" hack. diff --git a/sources/shiboken2/libshiboken/CMakeLists.txt b/sources/shiboken2/libshiboken/CMakeLists.txt index a95a6358c..752613417 100644 --- a/sources/shiboken2/libshiboken/CMakeLists.txt +++ b/sources/shiboken2/libshiboken/CMakeLists.txt @@ -119,7 +119,7 @@ endif() set_target_properties(libshiboken PROPERTIES OUTPUT_NAME "shiboken2${shiboken2_SUFFIX}${PYTHON_SHARED_LIBRARY_SUFFIX}" VERSION ${libshiboken_VERSION} SOVERSION ${libshiboken_SOVERSION} - DEFINE_SYMBOL LIBSHIBOKEN_EXPORTS) + DEFINE_SYMBOL BUILD_LIBSHIBOKEN) install(FILES autodecref.h diff --git a/sources/shiboken2/libshiboken/shibokenmacros.h b/sources/shiboken2/libshiboken/shibokenmacros.h index 7bebd85e4..d8f45868a 100644 --- a/sources/shiboken2/libshiboken/shibokenmacros.h +++ b/sources/shiboken2/libshiboken/shibokenmacros.h @@ -1,6 +1,6 @@ /**************************************************************************** ** -** Copyright (C) 2016 The Qt Company Ltd. +** Copyright (C) 2020 The Qt Company Ltd. ** Contact: https://www.qt.io/licensing/ ** ** This file is part of Qt for Python. @@ -42,22 +42,23 @@ // LIBSHIBOKEN_API macro is used for the public API symbols. #if defined _WIN32 - #if LIBSHIBOKEN_EXPORTS - #define LIBSHIBOKEN_API __declspec(dllexport) - #else - #ifdef _MSC_VER - #define LIBSHIBOKEN_API __declspec(dllimport) - #endif - #endif - #define SBK_DEPRECATED(func) __declspec(deprecated) func -#elif __GNUC__ >= 4 - #define LIBSHIBOKEN_API __attribute__ ((visibility("default"))) - #define SBK_DEPRECATED(func) func __attribute__ ((deprecated)) +# define LIBSHIBOKEN_EXPORT __declspec(dllexport) +# ifdef _MSC_VER +# define LIBSHIBOKEN_IMPORT __declspec(dllimport) +# else +# define LIBSHIBOKEN_IMPORT +# endif +# define SBK_DEPRECATED(func) __declspec(deprecated) func +#else +# define LIBSHIBOKEN_EXPORT __attribute__ ((visibility("default"))) +# define LIBSHIBOKEN_IMPORT +# define SBK_DEPRECATED(func) func __attribute__ ((deprecated)) #endif -#ifndef LIBSHIBOKEN_API - #define LIBSHIBOKEN_API - #define SBK_DEPRECATED(func) func +#ifdef BUILD_LIBSHIBOKEN +# define LIBSHIBOKEN_API LIBSHIBOKEN_EXPORT +#else +# define LIBSHIBOKEN_API LIBSHIBOKEN_IMPORT #endif -#endif +#endif // SHIBOKENMACROS_H |