Compare commits

...

16 Commits

Author SHA1 Message Date
Renato Araujo
b7b1d6d4e9 Fixed unit test for PySide6 2021-09-30 06:04:52 -07:00
Allen Winter
a90417de55 python/examples-qt6/main.py - uncomment rc_assets
commented by mistake
2021-09-29 17:17:54 -04:00
Allen Winter
73f08df224 Merge pull request #247 from KDAB/python38
Fixed module import for python 3.8
2021-09-29 16:41:26 -04:00
Renato Araujo Oliveira Filho
db9babbdca Fixed module import for python 3.8 2021-09-29 13:36:16 -07:00
Allen Winter
463dd2261e various - spelling fixes 2021-09-28 16:45:44 -04:00
Allen Winter
4dd66969af examples/dockwidgets/MyTitleBar_CSS.h - add multiple include guard 2021-09-28 16:36:55 -04:00
Allen Winter
2c98003219 CMakeLists.txt,python/tests/CMakeLists.txt - minor coding style 2021-09-28 16:28:51 -04:00
Allen Winter
dd853a8f72 python/tests/ - add copyright+license header 2021-09-28 16:24:35 -04:00
Allen Winter
88d5e6b29d Merge pull request #242 from KDAB/python-unittest
Fixed import module for windows and python 3.7
2021-09-28 16:03:40 -04:00
Renato Araujo
71e5d8cc31 Fixed import module for windows and python 3.7
create unit test
2021-09-28 14:45:52 -03:00
Allen Winter
15b3843172 ../KDAB/modules/PySide6ModuleBuild.cmake - set INSTALL_PATH for Mac
on Mac we need to set the rpath to "@loader_path"
2021-09-27 16:42:07 -04:00
Allen Winter
3cffe3b3be ../KDAB/modules/PySide2ModuleBuild.cmake - set INSTALL_PATH for Mac
on Mac we need to set the rpath to "@loader_path"
2021-09-27 16:27:54 -04:00
Allen Winter
9dd87b7777 python/PyKDDockWidgets/CMakeLists.txt - fix TARGET_SONAME_FILE
TARGET_SONAME_FILE isn't supported on Windows
2021-09-27 15:46:23 -04:00
Allen Winter
b057cf905b python/examples-qt6/main.py - uncomment rc_assets
commented by mistake
2021-09-27 12:59:59 -04:00
Allen Winter
d7943d30d8 cmake/KDAB/modules/PySide6ModuleBuild.cmake - add rpath property
follow PySide2ModuleBuild.cmake
2021-09-27 12:59:19 -04:00
Renato Araujo Oliveira Filho
1826d68841 Install library so into python module dir
We do the same a PySide and install the target library into the python
module this. This way the bindings can work without need to export
system paths.
2021-09-25 11:02:18 +01:00
14 changed files with 167 additions and 22 deletions

View File

@@ -1,4 +1,4 @@
[codespell] [codespell]
skip = ./build-*,.git skip = ./build-*,.git,*.svg,rc_assets.py
interactive = 3 interactive = 3
ignore-words-list = overlay,overlayed ignore-words-list = overlay,overlayed

View File

@@ -213,7 +213,7 @@ if((CMAKE_CXX_COMPILER_ID STREQUAL "GNU" AND NOT APPLE) OR
endif() endif()
# cannot enable this for clang + sanitizers # cannot enable this for clang + sanitizers
if (NOT sanitizers_enabled OR NOT CMAKE_CXX_COMPILER_ID MATCHES "Clang") if(NOT sanitizers_enabled OR NOT CMAKE_CXX_COMPILER_ID MATCHES "Clang")
# Do not allow undefined symbols, even in non-symbolic shared libraries # Do not allow undefined symbols, even in non-symbolic shared libraries
set(CMAKE_SHARED_LINKER_FLAGS "-Wl,--no-undefined ${CMAKE_SHARED_LINKER_FLAGS}") set(CMAKE_SHARED_LINKER_FLAGS "-Wl,--no-undefined ${CMAKE_SHARED_LINKER_FLAGS}")
set(CMAKE_MODULE_LINKER_FLAGS "-Wl,--no-undefined ${CMAKE_MODULE_LINKER_FLAGS}") set(CMAKE_MODULE_LINKER_FLAGS "-Wl,--no-undefined ${CMAKE_MODULE_LINKER_FLAGS}")
@@ -267,13 +267,6 @@ endif()
add_subdirectory(src) add_subdirectory(src)
if(${PROJECT_NAME}_PYTHON_BINDINGS)
if(CMAKE_BUILD_TYPE MATCHES "^[Dd]eb" OR ${PROJECT_NAME}_STATIC)
message(FATAL_ERROR "** Python Bindings are disabled in debug or static builds.")
endif()
add_subdirectory(python)
endif()
if(${PROJECT_NAME}_IS_ROOT_PROJECT) if(${PROJECT_NAME}_IS_ROOT_PROJECT)
if(${PROJECT_NAME}_EXAMPLES) if(${PROJECT_NAME}_EXAMPLES)
if(${PROJECT_NAME}_QTQUICK) if(${PROJECT_NAME}_QTQUICK)
@@ -339,4 +332,11 @@ if(${PROJECT_NAME}_IS_ROOT_PROJECT)
include(ECMUninstallTarget) include(ECMUninstallTarget)
endif() endif()
if(${PROJECT_NAME}_PYTHON_BINDINGS)
if(CMAKE_BUILD_TYPE MATCHES "^[Dd]eb" OR ${PROJECT_NAME}_STATIC)
message(FATAL_ERROR "** Python Bindings are disabled in debug or static builds.")
endif()
add_subdirectory(python)
endif()
feature_summary(WHAT ALL INCLUDE_QUIET_PACKAGES FATAL_ON_MISSING_REQUIRED_PACKAGES) feature_summary(WHAT ALL INCLUDE_QUIET_PACKAGES FATAL_ON_MISSING_REQUIRED_PACKAGES)

View File

@@ -130,6 +130,11 @@ macro(CREATE_PYTHON_BINDINGS
OUTPUT_NAME ${MODULE_NAME} OUTPUT_NAME ${MODULE_NAME}
LIBRARY_OUTPUT_DIRECTORY ${MODULE_OUTPUT_DIR} LIBRARY_OUTPUT_DIRECTORY ${MODULE_OUTPUT_DIR}
) )
if(APPLE)
set_target_properties(${TARGET_NAME} PROPERTIES INSTALL_RPATH "@loader_path")
elseif(NOT WIN32) #ie. linux
set_target_properties(${TARGET_NAME} PROPERTIES INSTALL_RPATH "$ORIGIN")
endif()
if(WIN32) if(WIN32)
set_target_properties(${TARGET_NAME} PROPERTIES SUFFIX ".pyd") set_target_properties(${TARGET_NAME} PROPERTIES SUFFIX ".pyd")

View File

@@ -130,6 +130,11 @@ macro(CREATE_PYTHON_BINDINGS
OUTPUT_NAME ${MODULE_NAME} OUTPUT_NAME ${MODULE_NAME}
LIBRARY_OUTPUT_DIRECTORY ${MODULE_OUTPUT_DIR} LIBRARY_OUTPUT_DIRECTORY ${MODULE_OUTPUT_DIR}
) )
if(APPLE)
set_target_properties(${TARGET_NAME} PROPERTIES INSTALL_RPATH "@loader_path")
elseif(NOT WIN32) #ie. linux
set_target_properties(${TARGET_NAME} PROPERTIES INSTALL_RPATH "$ORIGIN")
endif()
if(WIN32) if(WIN32)
set_target_properties(${TARGET_NAME} PROPERTIES SUFFIX ".pyd") set_target_properties(${TARGET_NAME} PROPERTIES SUFFIX ".pyd")

View File

@@ -9,6 +9,11 @@
Contact KDAB at <info@kdab.com> for commercial licensing options. Contact KDAB at <info@kdab.com> for commercial licensing options.
*/ */
#ifndef EXAMPLETITLEBAR_CSS_H
#define EXAMPLETITLEBAR_CSS_H
#pragma once
#include <kddockwidgets/private/widgets/TitleBarWidget_p.h> #include <kddockwidgets/private/widgets/TitleBarWidget_p.h>
/** /**
@@ -77,3 +82,5 @@ public:
MyTitleBar_CSS::~MyTitleBar_CSS() MyTitleBar_CSS::~MyTitleBar_CSS()
{ {
} }
#endif

View File

@@ -39,3 +39,4 @@ set(${PROJECT_NAME}_PYTHON_BINDINGS_INSTALL_PREFIX "${${PROJECT_NAME}_PYTHON_BIN
include(PySide${PYSIDE_MAJOR_VERSION}ModuleBuild) include(PySide${PYSIDE_MAJOR_VERSION}ModuleBuild)
add_subdirectory(PyKDDockWidgets) add_subdirectory(PyKDDockWidgets)
add_subdirectory(tests)

View File

@@ -81,5 +81,19 @@ create_python_bindings(
configure_file(${CMAKE_CURRENT_SOURCE_DIR}/__init__.py.cmake ${CMAKE_CURRENT_BINARY_DIR}/__init__.py @ONLY) configure_file(${CMAKE_CURRENT_SOURCE_DIR}/__init__.py.cmake ${CMAKE_CURRENT_BINARY_DIR}/__init__.py @ONLY)
# install # install
install(FILES ${CMAKE_CURRENT_BINARY_DIR}/__init__.py install(
DESTINATION ${${PROJECT_NAME}_PYTHON_BINDINGS_INSTALL_PREFIX}) FILES
${CMAKE_CURRENT_BINARY_DIR}/__init__.py
$<TARGET_FILE:KDAB::kddockwidgets>
DESTINATION
${${PROJECT_NAME}_PYTHON_BINDINGS_INSTALL_PREFIX}
)
if(NOT WIN32)
install(
FILES
$<TARGET_LINKER_FILE:KDAB::kddockwidgets>
$<TARGET_SONAME_FILE:KDAB::kddockwidgets>
DESTINATION
${${PROJECT_NAME}_PYTHON_BINDINGS_INSTALL_PREFIX}
)
endif()

View File

@@ -10,9 +10,31 @@
# #
import sys import sys
import os
__all__ = ['KDDockWidgets'] __all__ = ['KDDockWidgets']
def setupLibraryPath():
if sys.platform != 'win32':
return
if "@PYSIDE_MAJOR_VERSION@" == "6":
from shiboken@PYSIDE_MAJOR_VERSION@ import Shiboken
else:
from shiboken@PYSIDE_MAJOR_VERSION@ import shiboken@PYSIDE_MAJOR_VERSION@ as Shiboken
from PySide@PYSIDE_MAJOR_VERSION@ import QtCore
extra_dll_dirs = [ os.path.abspath(os.path.dirname(Shiboken.__file__)),
os.path.abspath(os.path.dirname(QtCore.__file__)),
os.path.abspath(os.path.dirname(__file__)) ]
if sys.version_info[0] == 3 and sys.version_info[1] >= 8:
for dll_dir in extra_dll_dirs:
os.add_dll_directory(dll_dir)
for dll_dir in extra_dll_dirs:
os.environ['PATH'] = os.fspath(dll_dir) + os.pathsep + os.environ['PATH']
# Preload PySide libraries to avoid missing libraries while loading KDDockWidgets # Preload PySide libraries to avoid missing libraries while loading KDDockWidgets
try: try:
from PySide@PYSIDE_MAJOR_VERSION@ import QtCore from PySide@PYSIDE_MAJOR_VERSION@ import QtCore
@@ -22,3 +44,5 @@ try:
except Exception: except Exception:
print("Failed to load PySide") print("Failed to load PySide")
raise raise
setupLibraryPath()

View File

@@ -0,0 +1,40 @@
#
# This file is part of KDDockWidgets.
#
# SPDX-FileCopyrightText: 2020-2021 Klarälvdalens Datakonsult AB, a KDAB Group company <info@kdab.com>
# Author: Renato Araujo Oliveira Filho <renato.araujo@kdab.com>
#
# SPDX-License-Identifier: GPL-2.0-only OR GPL-3.0-only
#
# Contact KDAB at <info@kdab.com> for commercial licensing options.
#
configure_file(${CMAKE_CURRENT_SOURCE_DIR}/config.py.cmake ${CMAKE_CURRENT_BINARY_DIR}/config.py @ONLY)
set(TEST_PYTHONPATH
${CMAKE_BINARY_DIR}/python
${CMAKE_CURRENT_BINARY_DIR}
)
set(TEST_LIBRARYPATH ${CMAKE_RUNTIME_OUTPUT_DIRECTORY})
if(WIN32)
set(TEST_LIBRARY_VAR "PATH")
string(REPLACE "\\" "/" TEST_PYTHONPATH "${TEST_PYTHONPATH}")
string(REPLACE "\\" "/" TEST_LIBRARYPATH "${TEST_LIBRARYPATH}")
list(JOIN TEST_PYTHONPATH "\\;" TEST_PYTHONPATH)
list(JOIN TEST_LIBRARYPATH "\\;" TEST_LIBRARYPATH)
else()
set(TEST_LIBRARY_VAR "LD_LIBRARY_PATH")
list(JOIN TEST_PYTHONPATH ":" TEST_PYTHONPATH)
list(JOIN TEST_LIBRARYPATH ":" TEST_LIBRARYPATH)
endif()
set(PYTHON_ENV_COMMON "PYTHONPATH=${TEST_PYTHONPATH};${TEST_LIBRARY_VAR}=${TEST_LIBRARYPATH}")
file(GLOB TEST_FILES ${CMAKE_CURRENT_SOURCE_DIR}/tst_*.py)
foreach(test_file ${TEST_FILES})
get_filename_component(test_name ${test_file} NAME_WE)
add_test(${test_name} ${Python3_EXECUTABLE} ${test_file})
set_tests_properties(${test_name} PROPERTIES ENVIRONMENT "${PYTHON_ENV_COMMON}")
endforeach()

View File

@@ -0,0 +1,19 @@
# This file is part of KDDockWidgets.
#
# SPDX-FileCopyrightText: 2021 Klarälvdalens Datakonsult AB, a KDAB Group company <info@kdab.com>
# Author: Renato Araujo <renato.araujo@kdab.com>
#
# SPDX-License-Identifier: GPL-2.0-only OR GPL-3.0-only
#
# Contact KDAB at <info@kdab.com> for commercial licensing options.
#
import os
import sys
class TstConfig(object):
bindingsNamespace = "PyKDDockWidgets"
def initLibraryPath():
if sys.platform == 'win32' and sys.version_info[0] == 3 and sys.version_info[1] >= 8:
os.add_dll_directory("@CMAKE_RUNTIME_OUTPUT_DIRECTORY@")

View File

@@ -0,0 +1,30 @@
# This file is part of KDDockWidgets.
#
# SPDX-FileCopyrightText: 2021 Klarälvdalens Datakonsult AB, a KDAB Group company <info@kdab.com>
# Author: Renato Araujo <renato.araujo@kdab.com>
#
# SPDX-License-Identifier: GPL-2.0-only OR GPL-3.0-only
#
# Contact KDAB at <info@kdab.com> for commercial licensing options.
#
import unittest
import importlib
import inspect
from config import TstConfig
class TestImportModules(unittest.TestCase):
def test_importModules(self):
m = importlib.import_module(TstConfig.bindingsNamespace + '.KDDockWidgets')
moduleSymbols = []
for t in inspect.getmembers(m):
moduleSymbols.append(t[0])
symbols = ['MainWindow', 'DockWidget']
for symbol in symbols:
self.assertIn(symbol, moduleSymbols)
if __name__ == '__main__':
TstConfig.initLibraryPath()
unittest.main()

View File

@@ -205,7 +205,7 @@ public:
///@brief By default equivalent to QWidget::normalGeometry() ///@brief By default equivalent to QWidget::normalGeometry()
/// Derived classes can implement something different here, to workaround window manager issues with Qt::Tool /// Derived classes can implement something different here, to workaround window manager issues with Qt::Tool
/// Also useful for QtQuick to eventually perserve normal geometry uppon save/restore of a maximized window. As /// Also useful for QtQuick to eventually preserve normal geometry upon save/restore of a maximized window. As
/// QWindow has no notion of normal geometry, so we need to implement it here. /// QWindow has no notion of normal geometry, so we need to implement it here.
/// @sa QTBUG-95478 /// @sa QTBUG-95478
virtual QRect normalGeometry() const; virtual QRect normalGeometry() const;

View File

@@ -212,7 +212,7 @@ void TabWidgetWidget::showContextMenu(QPoint pos)
return; return;
QTabBar *tabBar = QTabWidget::tabBar(); QTabBar *tabBar = QTabWidget::tabBar();
// We dont want context menu if there is only one tab // We don't want context menu if there is only one tab
if (tabBar->count() <= 1) if (tabBar->count() <= 1)
return; return;

View File

@@ -27,9 +27,9 @@ using namespace KDDockWidgets;
using namespace KDDockWidgets::Testing; using namespace KDDockWidgets::Testing;
using namespace KDDockWidgets::Testing::Operations; using namespace KDDockWidgets::Testing::Operations;
static QString operationTypeStr(OperationType ot) static QString operationTypeStr(OperationType optype)
{ {
return QMetaEnum::fromType<OperationType>().valueToKey(ot); return QMetaEnum::fromType<OperationType>().valueToKey(optype);
} }
OperationBase::OperationBase(KDDockWidgets::Testing::Operations::OperationType type, Fuzzer *fuzzer) OperationBase::OperationBase(KDDockWidgets::Testing::Operations::OperationType type, Fuzzer *fuzzer)