Compare commits

...

92 Commits

Author SHA1 Message Date
Renato Araujo Oliveira Filho
cd01e9cdde 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-24 12:34:41 -03:00
Allen Winter
dc1e5103e2 docs/api/CMakeLists.txt - use INSTALL_DOC_DIR
install api docs files to ${INSTALL_DOC_DIR},
not to ${CMAKE_INSTALL_DOCDIR}
2021-09-20 17:28:48 -04:00
Sergio Martins
33c5647e57 Don't create duplicate central frame with restoring
When using MainWindowOption_HasCentralFrame we have a persistent
central frame which is never destroyed. When restoring a layout
we shouldn't create it, as it exists already.
2021-09-20 12:26:45 +01:00
Waqar Ahmed
f6f772edc5 Fix leaks in kddockwidgets_example 2021-09-17 11:27:09 +01:00
Allen Winter
7e460d8f34 examples/main.py, examples-qt6/main.py - uncomment import
uncomment the import rc_assets (commented by mistake)
2021-09-12 11:24:28 -04:00
Waqar Ahmed
7af2095f2f Allow switching tabs via context menu in the tabs area
This change allows you to switch tabs via the context menu. The context
menu only shows up if you click on the empty area beside the tabs.

Can be tested with `--allow-switch-tabs-via-menu` option in the example.

Fixes #232
Signed-off-by: Waqar Ahmed <waqar.ahmed@kdab.com>
2021-09-11 12:46:23 +01:00
Waqar Ahmed
8307598d5d tests: Fix tests, only repro in some distros 2021-09-11 12:17:50 +01:00
Waqar Ahmed
13fe276dbe Fix possible division by zero 2021-09-11 12:05:00 +01:00
Sergio Martins
13a5a472cd Fix build 2021-09-08 23:17:39 +01:00
Sergio Martins
b5c11ce199 example: Add an example about using stylesheets 2021-09-08 23:14:47 +01:00
Sergio Martins
83c8c22736 Add a TitleBar::isFocused property so we can use with qss
This has nothing to do with QWidget::hasFocus, but regarding our
focus scope support
2021-09-08 22:31:51 +01:00
Sergio Martins
c8ca7bf9e1 Allow TitleBarWidget to honour the stylesheet background color 2021-09-08 20:22:20 +01:00
Milian Wolff
0184deb54d Don't set CMAKE_MODULE/SHARED_LINKER_FLAGS in PARENT_SCOPE 2021-09-08 18:01:47 +02:00
Milian Wolff
389042f3cc Unbreak clang+asan build
Don't set -Wl,--no-undefined in such a configuration as it's not
supported, contrary to gcc+asan.
2021-09-08 16:13:03 +01:00
Sergio Martins
736358a71f cmake: Introduce KDDockWidgets_X11EXTRAS option, default ON
Use -DKDDockWidgets_X11EXTRAS=OFF to disable it, if you don't want
to link to Qt5X11Extras.

I've added a new option instead of relying on auto-detection, because
I want to make it difficult to disable it when on X11, it's opt-out.

X11Extras is needed when window managers don't have compositors, in
that case we use icons without transparency.
2021-09-07 12:19:20 +01:00
Sergio Martins
bffe671679 Fix QtQuick build 2021-09-04 20:11:35 +01:00
Sergio Martins
fafc0b7946 Fix "normal geometry" not being restored
When restoring a maximized window, calling QWidget::showNormal()
on it wouldn't set it's previous non-maximized size.

QWidget::normalGeometry() doesn't have a setter, so use private API.
2021-09-04 19:59:03 +01:00
Sergio Martins
3574feea98 Added isNormalWindowState()
As QWidget doesn't have it.
2021-09-04 13:38:06 +01:00
Sergio Martins
25b48920bb Make FloatingWindow::normalGeometry() virtual
So it can be overridden by QtQuick, since there's no "normal geometry"
for QWindow.

Also useful to workaround window manager bugs in a class derived from FloatingWindow.
2021-09-03 15:33:46 +01:00
Sergio Martins
e22ca48674 Fix QtQuick build 2021-09-03 00:18:42 +01:00
Sergio Martins
3b9773f872 Add support for restoring minimized/maximized floating window state 2021-09-02 18:32:35 +01:00
Sergio Martins
3e3cf10fff Allow to override FloatingWindow maximization/minimization
So users can workaround bugs in window managers / Qt, such as QTBUG-95478

The custom behavior needs to be done in a FloatingWindow sub-class,
as a generic workaround which doesn't break other window managers isn't
possible
2021-09-02 18:08:13 +01:00
Sergio Martins
421b401b4f qtquick: Added QWidgetAdapter::isMinimized() 2021-09-02 17:31:05 +01:00
Sergio Martins
a0c97e3388 Fix layout save restore when using MainWindowOption_HasCentralWidget
Those checks don't make sense anymore
2021-09-02 11:05:57 +01:00
Sergio Martins
d2a3968897 tests: Add tests for MainWindowOption_HasCentralWidget 2021-09-02 10:53:08 +01:00
Sergio Martins
4ea7953a76 Don't allow to overlay central widget 2021-09-02 10:52:56 +01:00
Sergio Martins
0cc0972eea Don't allow to close/float/tab persistent central widget
Fixes corner cases with MainWindowOption_HasCentralWidget
2021-09-02 10:30:34 +01:00
Sergio Martins
77b5d1630d Added DockWidget::isPersistentCentralDockWidget() 2021-09-02 10:24:43 +01:00
Sergio Martins
f962989484 Fix MainWindow::addDockWidgetAsTab with MainWindowOption_HasCentralWidget
When using central widget no tabs are supported
2021-09-02 10:17:37 +01:00
Sergio Martins
1ccdf445eb Introduce MainWindowOption_HasCentralWidget
You can now set an arbitrary widget as "central widget".
It's similar to MainWindowOption_HasCentralFrame, however the widget
won't be detachable and won't show tabs.

Similar to what you'd get with QMainWindow central widget concept.

Example:
    QWidget *myWidget = new MyWidget();
    mainWindow->setPersistentCentralWidget(myWidget);

Fixes #225
2021-08-30 10:12:46 +01:00
Sergio Martins
3fb8861eee Remove "EXPERIMENTAL" comment from MDI option
MDI doesn't have known bugs
2021-08-29 17:43:21 +01:00
Allen Winter
78381badd1 docs/api/Doxyfile.cmake - not generating latex
hard-code LATEX_CMD_NAME to latex since we won't
be generating the latex documentation; else we
have an ununitialized variable for @LATEX_COMPILER@
2021-08-25 15:26:32 -04:00
Allen Winter
8b1a9f2a41 README.md - Add info about Using in Qt6 projects 2021-08-24 09:24:30 -04:00
Sergio Martins
9ee52a0011 Merge branch '1.4' 2021-08-22 16:34:25 +01:00
Sergio Martins
240169ce23 Fix bug where the central frame would be detached
We don't allow detaching the central frame.
Fixes #228
2021-08-22 16:33:19 +01:00
Allen Winter
97a431f367 docs/api/Doxyfile.cmake - set PAPER_TYPE to a4
a4wide is no longer supported
2021-08-19 12:29:44 -04:00
Allen Winter
3769ad9615 python/PyKDDockWidgets/CMakeLists.txt - link to Python3 dev libs 2021-08-19 11:28:18 -04:00
Allen Winter
8332ab3ddc CMakeLists.txt - add LINKER_FLAGS fo various platforms
set CMAKE_SHARED_LINKER_FLAGS and CMAKE_SHARED_LINKER_FLAGS
- Linker warnings should be treated as errors
- Do not allow undefined symbols, even in non-symbolic shared libraries
2021-08-19 11:23:54 -04:00
Allen Winter
3b4a2f134f docs/api/Doxyfile.cmake - don't use fullpaths to makeindex
@MAKEINDEX@ expands to the fullpath /usr/bin/makeindex
breaks 'make pdf' in build/docs/api/latex
2021-08-19 11:23:34 -04:00
Allen Winter
5899e3716c CMakeLists.txt - Enable hidden visibility by default
"It's just good practice, catching some problems with missing
export macros that would otherwise only affect Windows,
and reducing the number of exported symbols on Unix."
2021-08-16 17:34:08 -04:00
Allen Winter
25bc05ae40 docs/api/CMakeLists.txt - introduce user variable QCH_INSTALL_DIR
provide a user settable variable (as in -DQCH_INSTALL_DIR=/path)
to override the qch file default installation location.
2021-08-16 17:29:48 -04:00
Allen Winter
f42629a6e5 docs/api/CMakeLists.txt - install the doxygen tagsfile 2021-08-16 17:28:58 -04:00
Allen Winter
192cb2daaa buildsystem - a bit of re-organizing the docs/api CMake 2021-08-16 17:28:09 -04:00
Allen Winter
63cc87af2d docs/api/Doxyfile.cmake - update and consistency 2021-08-16 17:25:31 -04:00
Allen Winter
3e1ea3ec67 Changelog - mention Qt6 co-installability 2021-08-16 17:21:26 -04:00
Allen Winter
c27a09c13c Merge branch '1.4' 2021-08-16 13:28:02 -04:00
Allen Winter
b3486ebca8 CONTRIBUTORS.txt - update 2021-08-16 13:27:43 -04:00
Albert Astals Cid
6a7230e546 Update qt6-kddockwidgets.spec for new paths 2021-08-12 15:39:43 +02:00
Allen Winter
ca173de71d CMakeLists.txt - fix typo "set(d fault_build_type)" 2021-08-12 07:35:40 -04:00
Allen Winter
5732e8ed14 CMakeLists.txt - minor reorganizing 2021-08-11 19:49:19 -04:00
Albert Astals Cid
5cc7a0864b Fix KDDockWidgetsConfig to require the proper Qt version
And for Qt5X11Extras we only require it if building the Qt5 one
2021-08-11 16:26:10 +02:00
Albert Astals Cid
e4671f175c Install the qt6 cmake targets in prefix lib/cmake/KDDockWidgets-qt6
So it does not collide with the qt5 files
2021-08-11 16:19:05 +02:00
Albert Astals Cid
17fd6b2454 Make Make qt5/qt6 documentation coinstallable 2021-08-11 15:44:19 +02:00
Albert Astals Cid
7ed3945d58 Make qt5/qt6 includes coinstallable
Even if they are "the same file" it's always good to not have packages
trying to install over the same files.

Since we don't want users to have to change their existing
  #include <kddockwidgets/DockWidget.h>

We install the qt6 includes in include/kddockwidgets-qt6/kddockwidgets
and change the cmake target INTERFACE_INCLUDE_DIRECTORIES to be
   "${_IMPORT_PREFIX}/include/kddockwidgets-qt6"
so everything is transparent for the user
2021-08-11 15:22:29 +02:00
Allen Winter
35de0a2fef python/examples-qt6 - PySide6 and PyKDDockWidgetsQt6 version 2021-08-10 08:52:54 -04:00
Allen Winter
8a0e475f21 python/examples - "PySide" => "PySide2" 2021-08-10 08:43:12 -04:00
Allen Winter
63d14f2345 python/CMakeLists.txt - fix typo 2021-08-10 08:35:40 -04:00
Allen Winter
e91849759c python/CMakeLists.txt - use PyKDDockWidgetsQt6 namespace for Qt6
follow PySide6 naming convention
2021-08-10 08:29:50 -04:00
Allen Winter
ee3a3af408 Merge branch '1.4' 2021-08-10 08:21:11 -04:00
Allen Winter
c470c89fc6 PySide6ModuleBuild.cmake - sync 2021-08-10 08:20:32 -04:00
Allen Winter
73cfa64ebb python/PyKDDockWidgets/__init__.py.cmake - minor comment fix 2021-08-10 08:18:48 -04:00
Sergio Martins
ffe5d5f6cb Merge branch '1.4' 2021-08-10 10:05:13 +01:00
Sergio Martins
aff4450b42 cmake: Install QWidgetAdapter_quick_p.h too
Fixes #224
2021-08-10 10:04:11 +01:00
Allen Winter
d40580c550 buildsystem - rename QT_MAJOR_VERSION to Qt_VERSION_MAJOR
as this is consistent with CMake style and other projects
2021-08-04 16:18:31 -04:00
Allen Winter
8e19b81eb9 cmake/KDAB/modules/KDQtInstallPaths.cmake - sync 2021-08-04 16:17:27 -04:00
Kevin Funk
d5191696e1 cmake: Remove explicit policy version settings
These are NEW by default already for the required CMake version
2021-08-04 07:55:54 +02:00
Allen Winter
1d01466181 Merge branch '1.4' 2021-08-03 07:18:37 -04:00
Allen Winter
1cead0e2b8 python/CMakeLists.txt - adapt to new upstream FindPySide 2021-08-03 07:17:50 -04:00
Allen Winter
aff4d426b8 Merge branch '1.4' 2021-08-02 19:15:00 -04:00
Allen Winter
4597cdeda8 cmake/Python - sync 2021-08-02 19:13:46 -04:00
Allen Winter
2e7f0bf51d cmake/KDAB/module - sync 2021-08-02 19:11:39 -04:00
Allen Winter
fa551b84f6 Merge branch '1.4' 2021-08-01 11:19:17 -04:00
Allen Winter
ce105212ab Doxyfile.cmake - more setting consistency 2021-08-01 11:18:21 -04:00
Allen Winter
31d4b62181 cmake/KDAB/modules/KDQtInstallPaths.cmake - sync 2021-07-30 13:04:12 -04:00
Allen Winter
7ec542a211 post-merge cleaning
rearrange top-level CMakeLists.txt
2021-07-29 17:04:45 -04:00
Allen Winter
e615d1c618 Merge branch '1.4' 2021-07-29 16:47:45 -04:00
Allen Winter
ce349d0fcd buildsystem - improve installing to non-KDAB location 2021-07-29 16:42:07 -04:00
Allen Winter
c86813b1cb CMakeLists.txt - remove CMake option KDDockWidgets_UNINSTALL
no longer needed since the uninstall target is created
only for "rooted" projects (ie. non-submodules)
2021-07-29 12:59:15 -04:00
Allen Winter
1fe651aaa7 CMakeLists.txt - re-organize. implement PROJECT_IS_ROOT
set KDDockWidget_IS_ROOT for detecting if this project
is being used inside another parent-parent (eg. submodule)
If not IS_ROOT then we don't build tests, examples, etc.
2021-07-29 12:56:39 -04:00
Allen Winter
ba7809236b CMakeLists.txt - follow using PYSIDE_CUSTOM_PREFIX 2021-07-29 12:55:09 -04:00
Allen Winter
84814b3c59 FindPySide2.cmake,FindPySide6.cmake - sync 2021-07-29 12:54:09 -04:00
Allen Winter
73ca6e6671 buildsystem - install the Python bindings into standard "site-packages"
Follow Python standards and install the bindings into
<prefix>/lib/pythonX.Y/site-packages

sync the Python cmake files with KDAB repository
2021-07-23 12:05:02 -04:00
Sergio Martins
a26759f340 Remove .uncrustify file, as we use clang-format now 2021-07-22 10:13:32 -07:00
Sérgio Martins
200ef12b4a Fix close icon being too dark
Fixes #208
2021-07-22 18:11:53 +01:00
Allen Winter
990fac9a0a open for 1.5 - new features 2021-07-16 13:02:05 -04:00
Allen Winter
31ec4cdecb Merge branch '1.4' 2021-07-16 12:59:32 -04:00
Allen Winter
1d968bd902 CMakeLists.txt, Changelog - open for 1.4.1 2021-07-16 12:59:12 -04:00
Allen Winter
69a632cfc2 conan/conanfile.py - Qt5.12 is required since 1.4.0 2021-07-16 12:53:21 -04:00
Allen Winter
e32aaccaac Merge branch '1.4' 2021-07-15 13:30:58 -04:00
Sergio Martins
3302401a36 Merge branch '1.4' 2021-07-13 17:34:58 +01:00
Renato Araujo Oliveira Filho
c0c1383254 Python: Create bindings for InitialOption
Added bindings for missing enums
Added InitialOption as value type

Task-Id: #198
2021-07-13 17:33:50 +01:00
Sergio Martins
13a7d27046 vscode: Fix the build dir paths
They changed in the cmake preset
2021-07-13 08:27:21 +01:00
77 changed files with 1724 additions and 1345 deletions

2
.krazy
View File

@@ -19,5 +19,5 @@ SKIP /KDDockWidgetsConfig.cmake.in
#skip more files
SKIP CMakePresets.json
#skip the borrowed code in the cmake subdir
SKIP /cmake/Qt5Portability.cmake|/cmake/ECM/|/cmake/InstallLocation.cmake
SKIP /cmake/InstallLocation.cmake|/cmake/ECM/|/cmake/KDAB/

View File

@@ -1,635 +0,0 @@
align_asm_colon = false
align_assign_span = 0
align_assign_thresh = 0
align_enum_equ_span = 0
align_enum_equ_thresh = 0
align_func_params = false
align_func_params_gap = 0
align_func_params_span = 0
align_func_params_thresh = 0
align_func_proto_gap = 0
align_func_proto_span = 0
align_keep_extra_space = false
align_keep_tabs = false
align_left_shift = true
align_mix_var_proto = false
align_nl_cont = false
align_number_right = false
align_oc_decl_colon = false
align_oc_msg_colon_first = false
align_oc_msg_colon_span = 0
align_oc_msg_spec_span = 0
align_on_operator = false
align_on_tabstop = false
align_pp_define_gap = 0
align_pp_define_span = 0
align_pp_define_together = false
align_right_cmt_at_col = 0
align_right_cmt_gap = 0
align_right_cmt_mix = false
align_right_cmt_span = 0
align_same_func_call_params = false
align_single_line_brace = false
align_single_line_brace_gap = 0
align_single_line_func = false
align_struct_init_span = 0
align_typedef_amp_style = 0
align_typedef_func = 0
align_typedef_gap = 0
align_typedef_span = 0
align_typedef_star_style = 0
align_var_class_gap = 0
align_var_class_span = 0
align_var_class_thresh = 0
align_var_def_amp_style = 0
align_var_def_attribute = false
align_var_def_colon = false
align_var_def_colon_gap = 0
align_var_def_gap = 0
align_var_def_inline = false
align_var_def_span = 0
align_var_def_star_style = 0
align_var_def_thresh = 0
align_var_struct_gap = 0
align_var_struct_span = 0
align_var_struct_thresh = 0
align_with_tabs = false
cmt_c_group = false
cmt_c_nl_end = false
cmt_c_nl_start = false
cmt_convert_tab_to_spaces = false
cmt_cpp_group = false
cmt_cpp_nl_end = false
cmt_cpp_nl_start = false
cmt_cpp_to_c = false
cmt_indent_multi = false
cmt_insert_before_ctor_dtor = false
cmt_insert_before_inlines = true
cmt_insert_before_preproc = false
cmt_insert_class_header = ""
cmt_insert_file_footer = ""
cmt_insert_file_header = ""
cmt_insert_func_header = ""
cmt_insert_oc_msg_header = ""
cmt_multi_check_last = true
cmt_multi_first_len_minimum = 4
cmt_reflow_mode = 0
cmt_sp_after_star_cont = 0
cmt_sp_before_star_cont = 0
cmt_star_cont = false
cmt_width = 0
code_width = 0
disable_processing_cmt = ""
eat_blanks_after_open_brace = false
eat_blanks_before_close_brace = false
enable_digraphs = false
enable_processing_cmt = ""
force_tab_after_define = false
include_category_0 = ""
include_category_1 = ""
include_category_2 = ""
indent_access_spec = -4
indent_access_spec_body = false
indent_align_assign = true
indent_align_paren = true
indent_align_string = false
indent_bool_paren = false
indent_brace = 0
indent_brace_parent = false
indent_braces = false
indent_braces_no_class = false
indent_braces_no_func = false
indent_braces_no_struct = false
indent_case_brace = 0
indent_case_shift = 0
indent_class_colon = false
indent_class_on_colon = false
indent_class = true
indent_cmt_with_tabs = false
indent_col1_comment = false
indent_columns = 4
indent_comma_paren = false
indent_constr_colon = false
indent_continue = 0
indent_cpp_lambda_body = false
indent_cpp_lambda_only_once = true
indent_ctor_init = 0
indent_ctor_init_leading = 2
indent_else_if = false
indent_extern = false
indent_first_bool_expr = false
indent_first_for_expr = false
indent_func_call_param = false
indent_func_class_param = false
indent_func_const = 0
indent_func_ctor_var_param = false
indent_func_def_force_col1 = false
indent_func_def_param = false
indent_func_param_double = false
indent_func_proto_param = false
indent_func_throw = 0
indent_ignore_asm_block = false
indent_label = 1
indent_member = 0
indent_member_single = false
indent_min_vbrace_open = 0
indent_namespace = false
indent_namespace_level = 0
indent_namespace_limit = 0
indent_namespace_single_indent = false
indent_oc_block = false
indent_oc_block_msg = 0
indent_oc_block_msg_from_brace = false
indent_oc_block_msg_from_caret = false
indent_oc_block_msg_from_colon = false
indent_oc_block_msg_from_keyword = false
indent_oc_block_msg_xcode_style = false
indent_oc_msg_colon = 0
indent_oc_msg_prioritize_first_colon = true
indent_off_after_return_new = false
indent_param = 0
indent_paren_after_func_call = false
indent_paren_after_func_decl = false
indent_paren_after_func_def = false
indent_paren_close = 0
indent_paren_nl = false
indent_paren_open_brace = false
indent_preserve_sql = false
indent_relative_single_line_comments = false
indent_semicolon_for_paren = false
indent_shift = false
indent_single_after_return = false
indent_single_newlines = false
indent_sing_line_comments = 0
indent_square_nl = false
indent_switch_case = 0
indent_switch_pp = true
indent_template_param = false
indent_ternary_operator = 2
indent_token_after_brace = true
indent_var_def_blk = 0
indent_var_def_cont = false
indent_vbrace_open_on_tabstop = false
indent_with_tabs = 0
indent_xml_string = 0
input_tab_size = 4
ls_code_width = false
ls_for_split_full = false
ls_func_split_full = false
mod_add_long_class_closebrace_comment = 0
mod_add_long_function_closebrace_comment = 0
mod_add_long_ifdef_else_comment = 0
mod_add_long_ifdef_endif_comment = 0
mod_add_long_namespace_closebrace_comment = 0
mod_add_long_switch_closebrace_comment = 0
mod_case_brace = ignore
mod_full_brace_do = ignore
mod_full_brace_for = ignore
mod_full_brace_function = ignore
mod_full_brace_if_chain = false
mod_full_brace_if_chain_only = false
mod_full_brace_if = ignore
mod_full_brace_nl = 0
mod_full_brace_nl_block_rem_mlcond = false
mod_full_brace_using = ignore
mod_full_brace_while = ignore
mod_full_paren_if_bool = false
mod_move_case_break = false
mod_paren_on_return = ignore
mod_pawn_semicolon = false
mod_remove_empty_return = false
mod_remove_extra_semicolon = false
mod_sort_import = false
mod_sort_include = false
mod_sort_oc_properties = false
mod_sort_oc_property_class_weight = 0
mod_sort_oc_property_getter_weight = 0
mod_sort_oc_property_nullability_weight = 0
mod_sort_oc_property_readwrite_weight = 0
mod_sort_oc_property_reference_weight = 0
mod_sort_oc_property_setter_weight = 0
mod_sort_oc_property_thread_safe_weight = 0
mod_sort_using = false
newlines = auto
nl_after_access_spec = 0
nl_after_annotation = ignore
nl_after_brace_close = false
nl_after_brace_open_cmt = false
nl_after_brace_open = false
nl_after_case = false
nl_after_class = 0
nl_after_do = ignore
nl_after_for = ignore
nl_after_func_body = 0
nl_after_func_body_class = 0
nl_after_func_body_one_liner = 0
nl_after_func_class_proto = 0
nl_after_func_class_proto_group = 0
nl_after_func_proto = 0
nl_after_func_proto_group = 0
nl_after_if = ignore
nl_after_label_colon = false
nl_after_multiline_comment = false
nl_after_return = false
nl_after_semicolon = false
nl_after_square_assign = ignore
nl_after_struct = 0
nl_after_switch = ignore
nl_after_synchronized = ignore
nl_after_try_catch_finally = 0
nl_after_vbrace_close = false
nl_after_vbrace_open_empty = false
nl_after_vbrace_open = false
nl_after_while = ignore
nl_around_cs_property = 0
nl_assign_brace = ignore
nl_assign_leave_one_liners = false
nl_assign_square = ignore
nl_before_access_spec = 0
nl_before_block_comment = 0
nl_before_case = false
nl_before_c_comment = 0
nl_before_class = 0
nl_before_cpp_comment = 0
nl_before_do = ignore
nl_before_for = ignore
nl_before_func_body_def = 0
nl_before_func_body_proto = 0
nl_before_func_class_def = 0
nl_before_func_class_proto = 0
nl_before_if_closing_paren = ignore
nl_before_if = ignore
nl_before_return = false
nl_before_switch = ignore
nl_before_synchronized = ignore
nl_before_throw = ignore
nl_before_while = ignore
nl_between_annotation = ignore
nl_between_get_set = 0
nl_brace_brace = ignore
nl_brace_catch = ignore
nl_brace_else = ignore
nl_brace_finally = ignore
nl_brace_fparen = ignore
nl_brace_square = ignore
nl_brace_struct_var = ignore
nl_brace_while = ignore
nl_case_colon_brace = ignore
nl_catch_brace = ignore
nl_class_brace = ignore
nl_class_colon = remove
nl_class_init_args = add
nl_class_leave_one_liners = false
nl_collapse_empty_body = false
nl_comment_func_def = 0
nl_constr_colon = ignore
nl_constr_init_args = ignore
nl_cpp_lambda_leave_one_liners = true
nl_cpp_ldef_brace = remove
nl_create_for_one_liner = false
nl_create_func_def_one_liner = false
nl_create_if_one_liner = false
nl_create_while_one_liner = false
nl_cs_property_leave_one_liners = false
nl_define_macro = false
nl_do_brace = ignore
nl_ds_struct_enum_close_brace = false
nl_ds_struct_enum_cmt = false
nl_else_brace = ignore
nl_elseif_brace = ignore
nl_else_if = ignore
nl_end_of_file = ignore
nl_end_of_file_min = 0
nl_enum_brace = ignore
nl_enum_class_identifier = ignore
nl_enum_class = ignore
nl_enum_colon_type = ignore
nl_enum_identifier_colon = ignore
nl_enum_leave_one_liners = false
nl_enum_own_lines = ignore
nl_fcall_brace = ignore
nl_fdef_brace = ignore
nl_finally_brace = ignore
nl_for_brace = ignore
nl_func_call_args_multi_line = false
nl_func_call_empty = ignore
nl_func_call_end_multi_line = false
nl_func_call_paren_empty = ignore
nl_func_call_paren = ignore
nl_func_call_start_multi_line = false
nl_func_class_scope = ignore
nl_func_decl_args = ignore
nl_func_decl_args_multi_line = false
nl_func_decl_empty = ignore
nl_func_decl_end = ignore
nl_func_decl_end_multi_line = false
nl_func_decl_end_single = ignore
nl_func_decl_start = ignore
nl_func_decl_start_multi_line = false
nl_func_decl_start_single = ignore
nl_func_def_args = ignore
nl_func_def_args_multi_line = false
nl_func_def_empty = ignore
nl_func_def_end = ignore
nl_func_def_end_multi_line = false
nl_func_def_end_single = ignore
nl_func_def_paren_empty = ignore
nl_func_def_paren = ignore
nl_func_def_start = ignore
nl_func_def_start_multi_line = false
nl_func_def_start_single = ignore
nl_func_leave_one_liners = true
nl_func_paren_empty = ignore
nl_func_paren = ignore
nl_func_proto_type_name = ignore
nl_func_scope_name = ignore
nl_func_type_name_class = ignore
nl_func_type_name = ignore
nl_func_var_def_blk = 0
nl_getset_brace = ignore
nl_getset_leave_one_liners = false
nl_if_brace = ignore
nl_if_leave_one_liners = false
nl_max = 0
nl_max_blank_in_func = 0
nl_multi_line_cond = false
nl_multi_line_define = false
nl_namespace_brace = ignore
nl_namespace_two_to_one_liner = false
nl_oc_block_brace = ignore
nl_oc_brace_catch = ignore
nl_oc_catch_brace = ignore
nl_oc_implementation_brace = ignore
nl_oc_interface_brace = ignore
nl_oc_msg_args = false
nl_oc_msg_leave_one_liner = false
nl_paren_dbrace_open = ignore
nl_property_brace = ignore
nl_remove_extra_newlines = 0
nl_return_expr = ignore
nl_scope_brace = ignore
nl_split_for_one_liner = false
nl_split_if_one_liner = false
nl_split_while_one_liner = false
nl_squeeze_ifdef = false
nl_squeeze_ifdef_top_level = false
nl_squeeze_paren_close = false
nl_start_of_file = ignore
nl_start_of_file_min = 0
nl_struct_brace = ignore
nl_switch_brace = ignore
nl_synchronized_brace = ignore
nl_template_class = ignore
nl_try_brace = ignore
nl_tsquare_brace = ignore
nl_type_brace_init_lst_close = ignore
nl_type_brace_init_lst = ignore
nl_type_brace_init_lst_open = ignore
nl_typedef_blk_end = 0
nl_typedef_blk_in = 0
nl_typedef_blk_start = 0
nl_union_brace = ignore
nl_unittest_brace = ignore
nl_using_brace = ignore
nl_var_def_blk_end = 0
nl_var_def_blk_in = 0
nl_var_def_blk_start = 0
nl_version_brace = ignore
nl_while_brace = ignore
nl_while_leave_one_liners = false
output_tab_size = 4
pos_arith = ignore
pos_assign = ignore
pos_bool = ignore
pos_class_colon = lead
pos_class_comma = lead
pos_comma = ignore
pos_compare = ignore
pos_conditional = ignore
pos_constr_colon = ignore
pos_constr_comma = ignore
pos_enum_comma = ignore
pp_define_at_level = false
pp_if_indent_code = false
pp_ignore_define_body = false
pp_indent_at_level = false
pp_indent_brace = true
pp_indent_case = true
pp_indent_count = 1
pp_indent_extern = true
pp_indent_func_def = true
pp_indent_if = 0
pp_indent = ignore
pp_indent_region = 0
pp_region_indent_code = false
pp_space_count = 0
pp_space = ignore
sp_addr = remove
sp_after_angle = ignore
sp_after_assign = ignore
sp_after_byref_func = remove
sp_after_byref = remove
sp_after_cast = ignore
sp_after_class_colon = add
sp_after_comma = add
sp_after_constr_colon = ignore
sp_after_dc = ignore
sp_after_for_colon = ignore
sp_after_invariant_paren = ignore
sp_after_mdatype_commas = ignore
sp_after_new = ignore
sp_after_newop_paren = ignore
sp_after_noexcept = ignore
sp_after_oc_at_sel = ignore
sp_after_oc_block_caret = ignore
sp_after_oc_colon = ignore
sp_after_oc_dict_colon = ignore
sp_after_oc_msg_receiver = ignore
sp_after_oc_property = ignore
sp_after_oc_return_type = ignore
sp_after_oc_scope = ignore
sp_after_oc_synchronized = ignore
sp_after_oc_type = ignore
sp_after_operator = ignore
sp_after_operator_sym_empty = ignore
sp_after_operator_sym = ignore
sp_after_ptr_block_caret = ignore
sp_after_ptr_star_func = remove
sp_after_ptr_star = remove
sp_after_ptr_star_qualifier = ignore
sp_after_semi = add
sp_after_semi_for_empty = ignore
sp_after_semi_for = force
sp_after_send_oc_colon = ignore
sp_after_sparen = ignore
sp_after_tag = ignore
sp_after_throw = ignore
sp_after_tparen_close = remove
sp_after_type_brace_init_lst_open = ignore
sp_after_type = force
sp_angle_colon = ignore
sp_angle_paren_empty = ignore
sp_angle_paren = ignore
sp_angle_shift = remove
sp_angle_word = ignore
sp_annotation_paren = ignore
sp_arith_additive = ignore
sp_arith = ignore
sp_assign_default = ignore
sp_assign = ignore
sp_attribute_paren = ignore
sp_balance_nested_parens = false
sp_before_angle = ignore
sp_before_assign = ignore
sp_before_byref_func = ignore
sp_before_byref = add
sp_before_case_colon = remove
sp_before_class_colon = add
sp_before_comma = remove
sp_before_constr_colon = ignore
sp_before_dc = ignore
sp_before_ellipsis = ignore
sp_before_for_colon = ignore
sp_before_mdatype_commas = ignore
sp_before_nl_cont = add
sp_before_oc_block_caret = ignore
sp_before_oc_colon = ignore
sp_before_oc_dict_colon = ignore
sp_before_pp_stringify = ignore
sp_before_ptr_star_func = ignore
sp_before_ptr_star = add
sp_before_semi_for_empty = ignore
sp_before_semi_for = ignore
sp_before_semi = remove
sp_before_send_oc_colon = ignore
sp_before_sparen = ignore
sp_before_square = ignore
sp_before_squares = ignore
sp_before_template_paren = ignore
sp_before_tr_emb_cmt = ignore
sp_before_type_brace_init_lst_close = ignore
sp_before_unnamed_byref = ignore
sp_before_unnamed_ptr_star = ignore
sp_between_mdatype_commas = ignore
sp_between_new_paren = ignore
sp_between_ptr_star = ignore
sp_bool = ignore
sp_brace_catch = ignore
sp_brace_else = ignore
sp_brace_finally = ignore
sp_brace_typedef = ignore
sp_case_label = ignore
sp_catch_brace = ignore
sp_catch_paren = ignore
sp_cmt_cpp_doxygen = false
sp_cmt_cpp_qttr = false
sp_cmt_cpp_start = ignore
sp_compare = ignore
sp_cond_colon_after = ignore
sp_cond_colon_before = ignore
sp_cond_colon = ignore
sp_cond_question_after = ignore
sp_cond_question_before = ignore
sp_cond_question = ignore
sp_cond_ternary_short = ignore
sp_cparen_oparen = ignore
sp_cpp_before_struct_binding = ignore
sp_cpp_cast_paren = ignore
sp_cpp_lambda_assign = ignore
sp_cpp_lambda_paren = ignore
sp_d_array_colon = ignore
sp_defined_paren = ignore
sp_deref = remove
sp_else_brace = ignore
sp_endif_cmt = ignore
sp_enum_after_assign = ignore
sp_enum_assign = ignore
sp_enum_before_assign = ignore
sp_enum_colon = ignore
sp_enum_paren = ignore
sp_extern_paren = ignore
sp_finally_brace = ignore
sp_fparen_brace = ignore
sp_fparen_brace_initializer = ignore
sp_fparen_dbrace = ignore
sp_func_call_paren_empty = ignore
sp_func_call_paren = ignore
sp_func_call_user_inside_fparen = ignore
sp_func_call_user_paren = ignore
sp_func_call_user_paren_paren = remove
sp_func_class_paren_empty = ignore
sp_func_class_paren = ignore
sp_func_def_paren_empty = ignore
sp_func_def_paren = ignore
sp_func_proto_paren_empty = ignore
sp_func_proto_paren = ignore
sp_getset_brace = ignore
sp_incdec = remove
sp_inside_angle = ignore
sp_inside_braces_empty = remove
sp_inside_braces_enum = ignore
sp_inside_braces = ignore
sp_inside_braces_oc_dict = ignore
sp_inside_braces_struct = ignore
sp_inside_fparen = ignore
sp_inside_fparens = remove
sp_inside_newop_paren_close = ignore
sp_inside_newop_paren = ignore
sp_inside_newop_paren_open = ignore
sp_inside_oc_at_sel_parens = ignore
sp_inside_paren_cast = ignore
sp_inside_paren = ignore
sp_inside_sparen_close = ignore
sp_inside_sparen = ignore
sp_inside_sparen_open = ignore
sp_inside_square = ignore
sp_inside_square_oc_array = ignore
sp_inside_tparen = ignore
sp_inside_type_brace_init_lst = ignore
sp_invariant_paren = ignore
sp_inv = remove
sp_macro_func = ignore
sp_macro = ignore
sp_member = remove
sp_not = remove
sp_num_before_tr_emb_cmt = 0
sp_oc_brace_catch = ignore
sp_oc_catch_brace = ignore
sp_oc_catch_paren = ignore
sp_paren_brace = remove
sp_paren_comma = force
sp_paren_paren = remove
sp_permit_cpp11_shift = true
sp_pp_concat = add
sp_pp_stringify = ignore
sp_ptr_star_paren = ignore
sp_range = ignore
sp_return_paren = ignore
sp_scope_paren = ignore
sp_sign = remove
sp_sizeof_paren = ignore
sp_skip_vbrace_tokens = false
sp_sparen_brace = add
sp_special_semi = ignore
sp_square_fparen = ignore
sp_super_paren = remove
sp_template_angle = ignore
sp_this_paren = remove
sp_throw_paren = ignore
sp_try_brace = ignore
sp_type_brace_init_lst = ignore
sp_type_func = ignore
sp_version_paren = ignore
sp_word_brace = add
sp_word_brace_ns = add
string_escape_char2 = 0
string_escape_char = 92
string_replace_tab_chars = false
tok_split_gte = false
use_indent_continue_only_once = false
use_indent_func_call_param = true
use_options_overriding_for_qt_macros = true
utf8_bom = ignore
utf8_byte = false
utf8_force = false
warn_level_tabs_found_in_verbatim_string_literals = 2

View File

@@ -19,12 +19,6 @@
# Build static versions of the libraries
# Default=false
#
# -DKDDockWidgets_UNINSTALL=[true|false]
# Setup the uninstall target.
# You may want to disable the uninstall target when you are using KDDockWidgets
# as a submodule directly and have a custom uninstall target of your own.
# Default=true
#
# -DKDDockWidgets_TESTS=[true|false]
# Build the test harness.
# Currently ignored unless you also set KDDockWidgets_DEVELOPER_MODE=True
@@ -45,7 +39,7 @@
# -DKDDockWidgets_PYTHON_BINDINGS=[true|false]
# Build/Generate python bindings. Always false for Debug builds
# (If your shiboken or pyside is installed in a non-standard locations
# try passing the SHIBOKEN_CUSTOM_PREFIX and PYSIDE2_CUSTOM_PREFIX variables.)
# try passing the SHIBOKEN_CUSTOM_PREFIX and PYSIDE_CUSTOM_PREFIX variables.)
# Default=false
#
# -DKDDockWidgets_PYTHON_BINDINGS_INSTALL_PREFIX=[path]
@@ -76,37 +70,13 @@
# Default=true
cmake_minimum_required(VERSION 3.7)
if(POLICY CMP0020)
cmake_policy(SET CMP0020 NEW)
endif()
if(POLICY CMP0042)
cmake_policy(SET CMP0042 NEW)
endif()
# Just to fix warnings with --warn-uninitialized
if(NOT DEFINED USE_DEFAULT_INSTALL_LOCATION)
set(USE_DEFAULT_INSTALL_LOCATION FALSE)
endif()
if(NOT DEFINED CMAKE_INSTALL_PREFIX)
set(CMAKE_INSTALL_PREFIX "")
endif()
if(NOT DEFINED SHIBOKEN_CUSTOM_PREFIX) #look for shiboken in a custom location
set(SHIBOKEN_CUSTOM_PREFIX "")
endif()
if(NOT DEFINED PYSIDE2_CUSTOM_PREFIX) #look for pyside in a custom location
set(PYSIDE2_CUSTOM_PREFIX "")
endif()
if(NOT DEFINED PYSIDE6_CUSTOM_PREFIX) #look for pyside in a custom location
set(PYSIDE6_CUSTOM_PREFIX "")
endif()
# Allow using a non-KDAB install location
set(KDAB_INSTALL True)
if(NOT ${USE_DEFAULT_INSTALL_LOCATION})
# Allow using a non-KDAB install location.
set(KDAB_INSTALL True CACHE INTERNAL "Install to default KDAB Location")
if(DEFINED CMAKE_INSTALL_PREFIX)
if(NOT "${CMAKE_INSTALL_PREFIX}" STREQUAL "")
set(KDAB_INSTALL False)
set(KDAB_INSTALL False CACHE INTERNAL "Install to non-KDAB Location")
endif()
set(USE_DEFAULT_INSTALL_LOCATION ${KDAB_INSTALL} CACHE INTERNAL "Install to default KDAB Location" FORCE)
endif()
if(${CMAKE_VERSION} VERSION_LESS "3.12.0")
@@ -120,64 +90,27 @@ endif()
set(${PROJECT_NAME}_VERSION_MAJOR 1)
set(${PROJECT_NAME}_VERSION_MINOR 4)
set(${PROJECT_NAME}_VERSION_PATCH 0)
set(${PROJECT_NAME}_VERSION_PATCH 95)
set(${PROJECT_NAME}_VERSION ${${PROJECT_NAME}_VERSION_MAJOR}.${${PROJECT_NAME}_VERSION_MINOR}.${${PROJECT_NAME}_VERSION_PATCH})
set(PROJECT_VERSION ${${PROJECT_NAME}_VERSION}) #PROJECT_VERSION is needed by some ECM modules
set(${PROJECT_NAME}_SOVERSION "1.4")
set(${PROJECT_NAME}_SOVERSION "1.5")
include(FeatureSummary)
option(${PROJECT_NAME}_QT6 "Build against Qt 6" OFF)
option(${PROJECT_NAME}_DEVELOPER_MODE "Developer Mode" OFF)
option(${PROJECT_NAME}_PYTHON_BINDINGS "Build python bindings" OFF)
option(${PROJECT_NAME}_UNINSTALL "Enable the uninstall target" ON)
option(${PROJECT_NAME}_QTQUICK "Build for QtQuick instead of QtWidgets" OFF)
option(${PROJECT_NAME}_STATIC "Build statically" OFF)
option(${PROJECT_NAME}_TESTS "Build the tests" OFF)
option(${PROJECT_NAME}_EXAMPLES "Build the examples" ON)
option(${PROJECT_NAME}_DOCS "Build the API documentation" OFF)
option(${PROJECT_NAME}_WERROR "Use -Werror (will be true for developer-mode unconditionally)" OFF)
option(${PROJECT_NAME}_X11EXTRAS "On Linux, link against QtX11Extras so we can detect if the compositor supports transparency. Not applicable to other platforms or Qt6." ON)
list(APPEND CMAKE_MODULE_PATH "${CMAKE_CURRENT_LIST_DIR}/cmake")
list(APPEND CMAKE_MODULE_PATH "${CMAKE_CURRENT_LIST_DIR}/cmake/ECM/modules")
list(APPEND CMAKE_MODULE_PATH "${CMAKE_CURRENT_LIST_DIR}/cmake/KDAB/modules")
list(APPEND CMAKE_MODULE_PATH "${CMAKE_CURRENT_LIST_DIR}/cmake/Python")
#Always build the test harness in developer-mode
if(${PROJECT_NAME}_DEVELOPER_MODE)
set(${PROJECT_NAME}_TESTS ON)
set(${PROJECT_NAME}_WERROR ON)
include(ECMEnableSanitizers)
endif()
option(${PROJECT_NAME}_QTQUICK "Build for QtQuick instead of QtWidgets" OFF)
if("${CMAKE_CXX_COMPILER_ID}" STREQUAL "Clang")
set(IS_CLANG_BUILD TRUE)
else()
set(IS_CLANG_BUILD FALSE)
endif()
if(${PROJECT_NAME}_QT6)
find_package(Qt6Widgets REQUIRED)
find_package(Qt6Test REQUIRED)
set(QT_MAJOR_VERSION 6)
set(KDDockWidgets_LIBRARY_QTID "-qt6")
else()
find_package(Qt5Widgets 5.12 REQUIRED)
find_package(Qt5Test 5.12 REQUIRED)
set(QT_MAJOR_VERSION 5)
set(KDDockWidgets_LIBRARY_QTID "")
endif()
if(${PROJECT_NAME}_QTQUICK)
set(CMAKE_CXX_STANDARD 17)
set(CMAKE_CXX_STANDARD_REQUIRED ON)
endif()
set(CMAKE_AUTOMOC ON)
set(CMAKE_AUTORCC ON)
set(CMAKE_RUNTIME_OUTPUT_DIRECTORY ${CMAKE_BINARY_DIR}/bin)
# Set a default build type if none was specified
set(default_build_type "Release")
@@ -191,10 +124,61 @@ if(NOT CMAKE_BUILD_TYPE AND NOT CMAKE_CONFIGURATION_TYPES)
set_property(CACHE CMAKE_BUILD_TYPE PROPERTY STRINGS "Debug" "Release" "MinSizeRel" "RelWithDebInfo")
endif()
# setup default install locations
include(InstallLocation)
if(${PROJECT_NAME}_QT6)
set(Qt_VERSION_MAJOR 6)
set(QT_MIN_VERSION "6.0.0")
find_package(Qt6Widgets ${QT_MIN_VERSION} REQUIRED)
find_package(Qt6Test ${QT_MIN_VERSION} REQUIRED)
set(${PROJECT_NAME}_LIBRARY_QTID "-qt6")
else()
set(Qt_VERSION_MAJOR 5)
set(QT_MIN_VERSION "5.12")
find_package(Qt5Widgets ${QT_MIN_VERSION} REQUIRED)
find_package(Qt5Test ${QT_MIN_VERSION} REQUIRED)
set(${PROJECT_NAME}_LIBRARY_QTID "")
endif()
include(KDQtInstallPaths) #to set QT_INSTALL_FOO variables
set(${PROJECT_NAME}_DEPS "widgets")
if(${PROJECT_NAME}_QTQUICK)
find_package(Qt${Qt_VERSION_MAJOR}Quick)
find_package(Qt${Qt_VERSION_MAJOR}QuickControls2)
add_definitions(-DKDDOCKWIDGETS_QTQUICK)
set(${PROJECT_NAME}_DEPS "${${PROJECT_NAME}_DEPS} quick quickcontrols2")
else()
add_definitions(-DKDDOCKWIDGETS_QTWIDGETS)
endif()
if(NOT WIN32 AND NOT APPLE AND NOT EMSCRIPTEN AND NOT ${PROJECT_NAME}_QT6 AND ${PROJECT_NAME}_X11EXTRAS)
set(${PROJECT_NAME}_DEPS "${${PROJECT_NAME}_DEPS} x11extras")
endif()
#Always build the test harness in developer-mode
if(${PROJECT_NAME}_DEVELOPER_MODE)
set(${PROJECT_NAME}_TESTS ON)
set(${PROJECT_NAME}_WERROR ON)
include(ECMEnableSanitizers)
endif()
if("${CMAKE_CXX_COMPILER_ID}" STREQUAL "Clang")
set(IS_CLANG_BUILD TRUE)
else()
set(IS_CLANG_BUILD FALSE)
endif()
if(${PROJECT_NAME}_QTQUICK)
set(CMAKE_CXX_STANDARD 17)
set(CMAKE_CXX_STANDARD_REQUIRED ON)
endif()
set(CMAKE_AUTOMOC ON)
set(CMAKE_AUTORCC ON)
# Default to hidden visibility for symbols
set(CMAKE_C_VISIBILITY_PRESET hidden)
set(CMAKE_CXX_VISIBILITY_PRESET hidden)
set(CMAKE_VISIBILITY_INLINES_HIDDEN 1)
macro(set_compiler_flags targetName)
if(${PROJECT_NAME}_DEVELOPER_MODE)
target_compile_definitions(${targetName} PUBLIC DOCKS_DEVELOPER_MODE PRIVATE QT_FORCE_ASSERTS)
@@ -212,22 +196,28 @@ macro(set_compiler_flags targetName)
if(${PROJECT_NAME}_WERROR AND (NOT MSVC OR IS_CLANG_BUILD)) # clang-cl accepts these too
target_compile_options(${targetName} PRIVATE -Werror -Wundef -Wno-error=deprecated-declarations)
endif()
endmacro()
set(${PROJECT_NAME}_DEPS "widgets")
if((CMAKE_CXX_COMPILER_ID STREQUAL "GNU" AND NOT APPLE) OR
(CMAKE_CXX_COMPILER_ID MATCHES "Clang" AND NOT APPLE) OR
(CMAKE_CXX_COMPILER_ID STREQUAL "Intel" AND NOT WIN32))
# Linker warnings should be treated as errors
set(CMAKE_SHARED_LINKER_FLAGS "-Wl,--fatal-warnings ${CMAKE_SHARED_LINKER_FLAGS}")
set(CMAKE_MODULE_LINKER_FLAGS "-Wl,--fatal-warnings ${CMAKE_MODULE_LINKER_FLAGS}")
if(${PROJECT_NAME}_QTQUICK)
find_package(Qt${QT_MAJOR_VERSION}Quick)
find_package(Qt${QT_MAJOR_VERSION}QuickControls2)
add_definitions(-DKDDOCKWIDGETS_QTQUICK)
set(${PROJECT_NAME}_DEPS "${${PROJECT_NAME}_DEPS} quick quickcontrols2")
else()
add_definitions(-DKDDOCKWIDGETS_QTWIDGETS)
endif()
string(TOUPPER "CMAKE_CXX_FLAGS_${CMAKE_BUILD_TYPE}" compileflags)
if("${CMAKE_CXX_FLAGS} ${${compileflags}}" MATCHES "-fsanitize")
set(sanitizers_enabled TRUE)
else()
set(sanitizers_enabled FALSE)
endif()
if(NOT WIN32 AND NOT APPLE AND NOT EMSCRIPTEN AND NOT ${PROJECT_NAME}_QT6)
set(${PROJECT_NAME}_DEPS "${${PROJECT_NAME}_DEPS} x11extras")
# cannot enable this for clang + sanitizers
if (NOT sanitizers_enabled OR NOT CMAKE_CXX_COMPILER_ID MATCHES "Clang")
# 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_MODULE_LINKER_FLAGS "-Wl,--no-undefined ${CMAKE_MODULE_LINKER_FLAGS}")
endif()
endif()
if(${PROJECT_NAME}_STATIC)
@@ -236,26 +226,33 @@ else()
set(${PROJECT_NAME}_LIBRARY_MODE "SHARED")
endif()
if(USE_DEFAULT_INSTALL_LOCATION)
if(KDAB_INSTALL)
if(UNIX)
set(CMAKE_INSTALL_PREFIX "/usr/local/KDAB/${PROJECT_NAME}-${${PROJECT_NAME}_VERSION}")
set(CMAKE_INSTALL_PREFIX "/usr/local/KDAB/${PROJECT_NAME}-${${PROJECT_NAME}_VERSION}" CACHE INTERNAL "Install to default KDAB Location")
elseif(WIN32)
set(CMAKE_INSTALL_PREFIX "C:\\KDAB\\${PROJECT_NAME}-${${PROJECT_NAME}_VERSION}")
set(CMAKE_INSTALL_PREFIX "C:\\KDAB\\${PROJECT_NAME}-$$VERSION" CACHE INTERNAL "Install to default KDAB Location")
endif()
endif()
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()
# setup default install locations
include(InstallLocation)
# Generate .pri file for qmake users
if(CMAKE_VERSION VERSION_GREATER "3.11.99" AND NOT CMAKE_CONFIGURATION_TYPES) # Not working with VS generator or older cmake versions
if(CMAKE_SOURCE_DIR STREQUAL PROJECT_SOURCE_DIR)
set(${PROJECT_NAME}_IS_ROOT_PROJECT TRUE)
message(STATUS "Building ${PROJECT_NAME} ${${PROJECT_NAME}_VERSION} in ${CMAKE_BUILD_TYPE} mode. Installing to ${CMAKE_INSTALL_PREFIX}")
set(CMAKE_RUNTIME_OUTPUT_DIRECTORY "${CMAKE_CURRENT_BINARY_DIR}/bin")
set(CMAKE_LIBRARY_OUTPUT_DIRECTORY "${CMAKE_CURRENT_BINARY_DIR}/lib")
set(CMAKE_ARCHIVE_OUTPUT_DIRECTORY "${CMAKE_CURRENT_BINARY_DIR}/lib")
install(FILES LICENSE.txt README.md DESTINATION ${INSTALL_DOC_DIR})
install(DIRECTORY LICENSES DESTINATION ${INSTALL_DOC_DIR})
# Generate .pri file for qmake users
#TODO: ECM does not support Qt6 yet
if(QT_MAJOR_VERSION EQUAL 5)
if(Qt_VERSION_MAJOR EQUAL 5 AND
CMAKE_VERSION VERSION_GREATER "3.11.99" AND NOT CMAKE_CONFIGURATION_TYPES) # Not working with VS generator or older cmake versions
include(ECMGeneratePriFile)
set(PROJECT_VERSION_STRING ${${PROJECT_NAME}_VERSION})
ecm_generate_pri_file(BASE_NAME KDDockWidgets
@@ -266,75 +263,78 @@ if(CMAKE_VERSION VERSION_GREATER "3.11.99" AND NOT CMAKE_CONFIGURATION_TYPES) #
)
install(FILES ${pri_filename} DESTINATION ${ECM_MKSPECS_INSTALL_DIR})
endif()
else()
message(WARNING "Unable to generate the pri file for qmake users. Try updating CMake.")
endif()
install(FILES LICENSE.txt README.md DESTINATION ${INSTALL_DOC_DIR})
install(DIRECTORY LICENSES DESTINATION ${INSTALL_DOC_DIR})
add_subdirectory(src)
if(${PROJECT_NAME}_EXAMPLES)
if(${PROJECT_NAME}_QTQUICK)
add_subdirectory(examples/qtquick)
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}_EXAMPLES)
if(${PROJECT_NAME}_QTQUICK)
add_subdirectory(examples/qtquick)
else()
add_subdirectory(examples/dockwidgets)
add_subdirectory(examples/minimal)
add_subdirectory(examples/minimal-mdi)
set_compiler_flags(kddockwidgets_example)
set_compiler_flags(kddockwidgets_minimal_example)
endif()
endif()
if(${PROJECT_NAME}_DEVELOPER_MODE)
if(${PROJECT_NAME}_TESTS)
enable_testing()
add_subdirectory(tests)
# Require Qt5.15.1 or higher to run the tests_launcher tests on Mac
if(NOT APPLE OR Qt5Widgets_VERSION VERSION_GREATER 5.15.0)
# tst_docks.exe is pretty big (160 tests), so split it in more runs so we can use threads.
add_test(NAME tst_docks0 COMMAND tests_launcher 0 5)
add_test(NAME tst_docks1 COMMAND tests_launcher 1 5)
add_test(NAME tst_docks2 COMMAND tests_launcher 2 5)
add_test(NAME tst_docks3 COMMAND tests_launcher 3 5)
add_test(NAME tst_docks4 COMMAND tests_launcher 4 5)
add_test(NAME tst_docks5 COMMAND tests_launcher 5 5)
add_test(NAME tst_docks6 COMMAND tests_launcher 6 5)
add_test(NAME tst_docks7 COMMAND tests_launcher 7 5)
add_test(NAME tst_docks8 COMMAND tests_launcher 8 5)
add_test(NAME tst_docks9 COMMAND tests_launcher 9 5)
add_test(NAME tst_docks10 COMMAND tests_launcher 10 5)
add_test(NAME tst_docks11 COMMAND tests_launcher 10 5)
add_test(NAME tst_docks12 COMMAND tests_launcher 11 5)
add_test(NAME tst_docks13 COMMAND tests_launcher 12 5)
add_test(NAME tst_docks14 COMMAND tests_launcher 13 5)
add_test(NAME tst_docks15 COMMAND tests_launcher 14 5)
add_test(NAME tst_docks16 COMMAND tests_launcher 15 5)
add_test(NAME tst_docks17 COMMAND tests_launcher 16 5)
add_test(NAME tst_docks18 COMMAND tests_launcher 17 5)
add_test(NAME tst_docks19 COMMAND tests_launcher 18 5)
add_test(NAME tst_docks20 COMMAND tests_launcher 19 5)
add_test(NAME tst_docks21 COMMAND tests_launcher 20 5) # one more for rounding leftovers
endif()
if(NOT ${PROJECT_NAME}_QTQUICK)
# tst_multisplitter depends on QWidget
add_test(NAME tst_multisplitter COMMAND tst_multisplitter)
endif()
endif()
endif()
if(${PROJECT_NAME}_DOCS)
add_subdirectory(docs) # needs to go last, in case there are build source files
else()
add_subdirectory(examples/dockwidgets)
add_subdirectory(examples/minimal)
add_subdirectory(examples/minimal-mdi)
set_compiler_flags(kddockwidgets_example)
set_compiler_flags(kddockwidgets_minimal_example)
add_custom_target(docs
COMMAND ${CMAKE_COMMAND} -E echo "Sorry, there is no docs target since KDDockWidgets_DOCS=OFF."
"Re-run cmake with the -DKDDockWidgets_DOCS=True option if you want to generate the documentation.")
endif()
endif()
if(${PROJECT_NAME}_DEVELOPER_MODE)
if(${PROJECT_NAME}_TESTS)
enable_testing()
add_subdirectory(tests)
# Require Qt5.15.1 or higher to run the tests_launcher tests on Mac
if(NOT APPLE OR Qt5Widgets_VERSION VERSION_GREATER 5.15.0)
# tst_docks.exe is pretty big (160 tests), so split it in more runs so we can use threads.
add_test(NAME tst_docks0 COMMAND tests_launcher 0 5)
add_test(NAME tst_docks1 COMMAND tests_launcher 1 5)
add_test(NAME tst_docks2 COMMAND tests_launcher 2 5)
add_test(NAME tst_docks3 COMMAND tests_launcher 3 5)
add_test(NAME tst_docks4 COMMAND tests_launcher 4 5)
add_test(NAME tst_docks5 COMMAND tests_launcher 5 5)
add_test(NAME tst_docks6 COMMAND tests_launcher 6 5)
add_test(NAME tst_docks7 COMMAND tests_launcher 7 5)
add_test(NAME tst_docks8 COMMAND tests_launcher 8 5)
add_test(NAME tst_docks9 COMMAND tests_launcher 9 5)
add_test(NAME tst_docks10 COMMAND tests_launcher 10 5)
add_test(NAME tst_docks11 COMMAND tests_launcher 10 5)
add_test(NAME tst_docks12 COMMAND tests_launcher 11 5)
add_test(NAME tst_docks13 COMMAND tests_launcher 12 5)
add_test(NAME tst_docks14 COMMAND tests_launcher 13 5)
add_test(NAME tst_docks15 COMMAND tests_launcher 14 5)
add_test(NAME tst_docks16 COMMAND tests_launcher 15 5)
add_test(NAME tst_docks17 COMMAND tests_launcher 16 5)
add_test(NAME tst_docks18 COMMAND tests_launcher 17 5)
add_test(NAME tst_docks19 COMMAND tests_launcher 18 5)
add_test(NAME tst_docks20 COMMAND tests_launcher 19 5)
add_test(NAME tst_docks21 COMMAND tests_launcher 20 5) # one more for rounding leftovers
endif()
if(NOT ${PROJECT_NAME}_QTQUICK)
# tst_multisplitter depends on QWidget
add_test(NAME tst_multisplitter COMMAND tst_multisplitter)
endif()
endif()
endif()
if(${PROJECT_NAME}_DOCS)
add_subdirectory(docs) # needs to go last, in case there are build source files
#don't create the dummy docs target as it can conflict when used as a submodule
#else()
# add_custom_target(docs
# COMMAND ${CMAKE_COMMAND} -E echo "Sorry, there is no docs target since KDDockWidgets_DOCS=OFF."
# "Re-run cmake with the -DKDDockWidgets_DOCS=True option if you want to generate the documentation.")
endif()
if(${PROJECT_NAME}_UNINSTALL)
# Add uninstall target
include(ECMUninstallTarget)
endif()

View File

@@ -74,6 +74,17 @@
"CMAKE_UNITY_BUILD" : "ON"
}
},
{
"name": "release-no-x11extras",
"displayName": "release-no-x11extras",
"generator": "Ninja",
"binaryDir": "${sourceDir}/build-release-no-x11extras",
"cacheVariables": {
"CMAKE_BUILD_TYPE": "Release",
"CMAKE_UNITY_BUILD" : "ON",
"KDDockWidgets_X11EXTRAS" : "OFF"
}
},
{
"name": "release-qtquick",
"displayName": "release-qtquick",

View File

@@ -5,3 +5,4 @@ Jacob Young <amazingjacob@gmail.com>
Matthew Waltz <matthewwaltzis@gmail.com>
Roman Pudashkin <r.pudashkin@gmail.com>
Elnur Ismailzada <eismailzada@gmail.com>
Daniel Price <danielp@nvidia.com>

View File

@@ -1,3 +1,12 @@
* v1.5.0 (unreleased)
- Install the Python bindings to "site-packages"
- The Python bindings for Qt6 use the "PyKDDockWidgetsQt6" namespace
- Co-installable with Qt6
- Adds support for non-detachable central widget, MainWindowOption_HasCentralWidget. (#225)
* v1.4.1 (unreleased)
-
* v1.4.0 (16 July 2021)
- No longer supports Qt versions less than 5.12
- Experimental MDI support. By using MainWindowMDI you can now have "docked" dock widgets

View File

@@ -106,12 +106,18 @@ You can change the installation location by passing the option `-DCMAKE_INSTALL_
Using
=====
From your CMake project, add
From your CMake Qt5 project, add
```
find_package(KDDockWidgets CONFIG)
```
or for Qt6
```
find_package(KDDockWidgets-qt6 CONFIG)
```
and link to the imported target `KDAB::kddockwidgets`.
That's all you need to do (the imported target also brings in the include directories)

View File

@@ -24,7 +24,7 @@ if(NOT INSTALL_DATADIR)
set(INSTALL_DATADIR ${CMAKE_INSTALL_DATADIR})
endif()
if(NOT INSTALL_DOC_DIR)
set(INSTALL_DOC_DIR ${CMAKE_INSTALL_DOCDIR})
set(INSTALL_DOC_DIR ${CMAKE_INSTALL_DOCDIR}${KDDockWidgets_LIBRARY_QTID})
endif()
set(CMAKE_INSTALL_RPATH_USE_LINK_PATH TRUE)

View File

@@ -0,0 +1,154 @@
#
# SPDX-FileCopyrightText: 2019-2021 Klarälvdalens Datakonsult AB, a KDAB Group company <info@kdab.com>
# Author: Renato Araujo Oliveira Filho <renato.araujo@kdab.com>
#
# SPDX-License-Identifier: BSD-3-Clause
#
# PYSIDE_BASEDIR - Top of the PySide2 installation
# PYSIDE_INCLUDE_DIR - Directories to include to use PySide2
# PYSIDE_LIBRARY - Files to link against to use PySide2
# PYSIDE_TYPESYSTEMS - Type system files that should be used by other bindings extending PySide2
#
# You can install PySide2 from Qt repository with
# pip3 install --index-url=https://download.qt.io/official_releases/QtForPython --trusted-host download.qt.io pyside2
find_package(PkgConfig)
if(PKG_CONFIG_FOUND)
pkg_check_modules(PYSIDE2_PRIV QUIET pyside2)
endif()
set(PYSIDE2_FOUND FALSE)
if(PYSIDE2_PRIV_FOUND)
set(PYSIDE2_FOUND TRUE)
message(STATUS "Using PySide2 found in the system!")
pkg_get_variable(SHIBOKEN_BINARY
pyside2
generator_location
)
pkg_get_variable(PYSIDE2_BASEDIR
pyside2
typesystemdir
)
pkg_get_variable(PYSIDE_INCLUDE_DIR
pyside2
includedir
)
set(PYSIDE_TYPESYSTEMS ${PYSIDE2_BASEDIR})
set(PYSIDE2_SO_VERSION ${PYSIDE2_PRIV_VERSION})
set(PYSIDE_LIBRARY ${PYSIDE2_PRIV_LINK_LIBRARIES})
list(GET PYSIDE_LIBRARY 0 PYSIDE_LIBRARY)
else()
# extract python library basename
list(GET Python3_LIBRARIES 0 PYTHON_LIBRARY_FILENAME)
get_filename_component(PYTHON_LIBRARY_FILENAME ${PYTHON_LIBRARY_FILENAME} NAME)
execute_process(
COMMAND ${Python3_EXECUTABLE} -c "if True:
import os, sys
try:
import PySide2.QtCore as QtCore
print(os.path.dirname(QtCore.__file__))
except Exception as error:
print(error, file=sys.stderr)
exit()
"
OUTPUT_VARIABLE PYSIDE2_BASEDIR
OUTPUT_STRIP_TRAILING_WHITESPACE
)
if(NOT PYSIDE2_BASEDIR)
message(FATAL_ERROR "The PySide2 module could not be imported. Make sure you have it installed by checking the output of \"pip${Python3_VERSION_MAJOR}.${Python3_VERSION_MINOR} list\"")
endif()
set(PYSIDE_BASEDIR ${PYSIDE2_BASEDIR} CACHE PATH "Top level install of PySide2" FORCE)
execute_process(
COMMAND ${Python3_EXECUTABLE} -c "if True:
import os
import PySide2.QtCore as QtCore
print(os.path.basename(QtCore.__file__).split('.', 1)[1])
"
OUTPUT_VARIABLE PYSIDE2_SUFFIX
OUTPUT_STRIP_TRAILING_WHITESPACE
)
execute_process(
COMMAND ${Python3_EXECUTABLE} -c "if True:
import os
import PySide2.QtCore as QtCore
print(';'.join(map(str, QtCore.__version_info__)))
"
OUTPUT_VARIABLE PYSIDE2_SO_VERSION
OUTPUT_STRIP_TRAILING_WHITESPACE
)
list(GET PYSIDE2_SO_VERSION 0 PYSIDE2_SO_MACRO_VERSION)
list(GET PYSIDE2_SO_VERSION 1 PYSIDE2_SO_MICRO_VERSION)
list(GET PYSIDE2_SO_VERSION 2 PYSIDE2_SO_MINOR_VERSION)
string(REPLACE ";" "." PYSIDE2_SO_VERSION "${PYSIDE2_SO_VERSION}")
if(NOT APPLE)
set(PYSIDE2_SUFFIX "${PYSIDE2_SUFFIX}.${PYSIDE2_SO_MACRO_VERSION}.${PYSIDE2_SO_MICRO_VERSION}")
else()
string(REPLACE ".so" "" PYSIDE2_SUFFIX ${PYSIDE2_SUFFIX})
set(PYSIDE2_SUFFIX "${PYSIDE2_SUFFIX}.${PYSIDE2_SO_MACRO_VERSION}.${PYSIDE2_SO_MICRO_VERSION}.dylib")
endif()
set(PYSIDE2_FOUND TRUE)
message(STATUS "PySide2 base dir: ${PYSIDE2_BASEDIR}")
message(STATUS "PySide2 suffix: ${PYSIDE2_SUFFIX}")
#PySide
#===============================================================================
find_path(PYSIDE_INCLUDE_DIR
pyside.h
PATHS ${PYSIDE2_BASEDIR}/include ${PYSIDE_CUSTOM_PREFIX}/include/PySide2
NO_DEFAULT_PATH)
# Platform specific library names
if(MSVC)
set(PYSIDE_LIBRARY_BASENAMES "pyside2.abi3.lib")
elseif(CYGWIN)
set(PYSIDE_LIBRARY_BASENAMES "")
elseif(WIN32)
set(PYSIDE_LIBRARY_BASENAMES "libpyside2.${PYSIDE2_SUFFIX}")
else()
set(PYSIDE_LIBRARY_BASENAMES "libpyside2.${PYSIDE2_SUFFIX}")
endif()
find_file(PYSIDE_LIBRARY
${PYSIDE_LIBRARY_BASENAMES}
PATHS ${PYSIDE2_BASEDIR} ${PYSIDE_CUSTOM_PREFIX}/lib
NO_DEFAULT_PATH)
find_path(PYSIDE_TYPESYSTEMS
typesystem_core.xml
PATHS ${PYSIDE2_BASEDIR}/typesystems ${PYSIDE_CUSTOM_PREFIX}/share/PySide2/typesystems
NO_DEFAULT_PATH)
endif()
if(PYSIDE2_FOUND)
message(STATUS "PySide include dir: ${PYSIDE_INCLUDE_DIR}")
message(STATUS "PySide library: ${PYSIDE_LIBRARY}")
message(STATUS "PySide typesystems: ${PYSIDE_TYPESYSTEMS}")
message(STATUS "PySide2 version: ${PYSIDE2_SO_VERSION}")
# Create PySide2 target
add_library(PySide2::pyside2 SHARED IMPORTED GLOBAL)
if(MSVC)
set_property(TARGET PySide2::pyside2 PROPERTY IMPORTED_IMPLIB ${PYSIDE_LIBRARY})
endif()
set_property(TARGET PySide2::pyside2 PROPERTY IMPORTED_LOCATION ${PYSIDE_LIBRARY})
set_property(TARGET PySide2::pyside2 APPEND PROPERTY
INTERFACE_INCLUDE_DIRECTORIES
${PYSIDE_INCLUDE_DIR}
${PYSIDE_INCLUDE_DIR}/QtCore/
${PYSIDE_INCLUDE_DIR}/QtGui/
${PYSIDE_INCLUDE_DIR}/QtWidgets/
${Python3_INCLUDE_DIRS}
)
endif()
find_package_handle_standard_args(PySide2
REQUIRED_VARS PYSIDE2_BASEDIR PYSIDE_INCLUDE_DIR PYSIDE_LIBRARY PYSIDE_TYPESYSTEMS
VERSION_VAR PYSIDE2_SO_VERSION
)

View File

@@ -2,9 +2,7 @@
# 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.
# SPDX-License-Identifier: BSD-3-Clause
#
# PYSIDE_BASEDIR - Top of the PySide6 installation
@@ -23,25 +21,28 @@ get_filename_component(PYTHON_LIBRARY_FILENAME ${PYTHON_LIBRARY_FILENAME} NAME)
execute_process(
COMMAND ${Python3_EXECUTABLE} -c "if True:
import os, sys
try:
import PySide6.QtCore as QtCore
print(os.path.dirname(QtCore.__file__))
except Exception as error:
print(error, file=sys.stderr)
exit()
import os, sys
try:
import PySide6.QtCore as QtCore
print(os.path.dirname(QtCore.__file__))
except Exception as error:
print(error, file=sys.stderr)
exit()
"
OUTPUT_VARIABLE PYSIDE6_BASEDIR
OUTPUT_STRIP_TRAILING_WHITESPACE
)
if(NOT PYSIDE6_BASEDIR)
message(FATAL_ERROR "The PySide6 module could not be imported. Make sure you have it installed by checking the output of \"pip${Python3_VERSION_MAJOR}.${Python3_VERSION_MINOR} list\"")
endif()
if(PYSIDE6_BASEDIR)
set(PYSIDE_BASEDIR ${PYSIDE6_BASEDIR} CACHE PATH "Top level install of PySide6" FORCE)
execute_process(
COMMAND ${Python3_EXECUTABLE} -c "if True:
import os
import PySide6.QtCore as QtCore
print(os.path.basename(QtCore.__file__).split('.', 1)[1])
import os
import PySide6.QtCore as QtCore
print(os.path.basename(QtCore.__file__).split('.', 1)[1])
"
OUTPUT_VARIABLE PYSIDE6_SUFFIX
OUTPUT_STRIP_TRAILING_WHITESPACE
@@ -49,9 +50,9 @@ if(PYSIDE6_BASEDIR)
execute_process(
COMMAND ${Python3_EXECUTABLE} -c "if True:
import os
import PySide6.QtCore as QtCore
print(';'.join(map(str, QtCore.__version_info__)))
import os
import PySide6.QtCore as QtCore
print(';'.join(map(str, QtCore.__version_info__)))
"
OUTPUT_VARIABLE PYSIDE6_SO_VERSION
OUTPUT_STRIP_TRAILING_WHITESPACE
@@ -63,43 +64,43 @@ if(PYSIDE6_BASEDIR)
if(NOT APPLE)
set(PYSIDE6_SUFFIX "${PYSIDE6_SUFFIX}.${PYSIDE6_SO_MACRO_VERSION}.${PYSIDE6_SO_MICRO_VERSION}")
else()
else()
string(REPLACE ".so" "" PYSIDE6_SUFFIX ${PYSIDE6_SUFFIX})
set(PYSIDE6_SUFFIX "${PYSIDE6_SUFFIX}.${PYSIDE6_SO_MACRO_VERSION}.${PYSIDE6_SO_MICRO_VERSION}.dylib")
endif()
set(PYSIDE6_FOUND TRUE)
message(STATUS "PySide6 base dir: ${PYSIDE6_BASEDIR}" )
message(STATUS "PySide6 base dir: ${PYSIDE6_BASEDIR}")
message(STATUS "PySide6 suffix: ${PYSIDE6_SUFFIX}")
endif()
if (PYSIDE6_FOUND)
if(PYSIDE6_FOUND)
#PySide
#===============================================================================
find_path(PYSIDE_INCLUDE_DIR
pyside.h
PATHS ${PYSIDE6_BASEDIR}/include ${PYSIDE6_CUSTOM_PREFIX}/include/PySide6
PATHS ${PYSIDE6_BASEDIR}/include ${PYSIDE_CUSTOM_PREFIX}/include/PySide6
NO_DEFAULT_PATH)
# Platform specific library names
if(MSVC)
SET(PYSIDE_LIBRARY_BASENAMES "pyside6.abi3.lib")
set(PYSIDE_LIBRARY_BASENAMES "pyside6.abi3.lib")
elseif(CYGWIN)
SET(PYSIDE_LIBRARY_BASENAMES "")
set(PYSIDE_LIBRARY_BASENAMES "")
elseif(WIN32)
SET(PYSIDE_LIBRARY_BASENAMES "libpyside6.${PYSIDE6_SUFFIX}")
set(PYSIDE_LIBRARY_BASENAMES "libpyside6.${PYSIDE6_SUFFIX}")
else()
SET(PYSIDE_LIBRARY_BASENAMES "libpyside6.${PYSIDE6_SUFFIX}")
set(PYSIDE_LIBRARY_BASENAMES "libpyside6.${PYSIDE6_SUFFIX}")
endif()
find_file(PYSIDE_LIBRARY
${PYSIDE_LIBRARY_BASENAMES}
PATHS ${PYSIDE6_BASEDIR} ${PYSIDE6_CUSTOM_PREFIX}/lib
PATHS ${PYSIDE6_BASEDIR} ${PYSIDE_CUSTOM_PREFIX}/lib
NO_DEFAULT_PATH)
find_path(PYSIDE_TYPESYSTEMS
typesystem_core.xml
PATHS ${PYSIDE6_BASEDIR}/typesystems ${PYSIDE6_CUSTOM_PREFIX}/share/PySide6/typesystems
PATHS ${PYSIDE6_BASEDIR}/typesystems ${PYSIDE_CUSTOM_PREFIX}/share/PySide6/typesystems
NO_DEFAULT_PATH)
endif()
@@ -112,11 +113,9 @@ if(PYSIDE6_FOUND)
# Create PySide6 target
add_library(PySide6::pyside6 SHARED IMPORTED GLOBAL)
if(MSVC)
set_property(TARGET PySide6::pyside6 PROPERTY
IMPORTED_IMPLIB ${PYSIDE_LIBRARY})
set_property(TARGET PySide6::pyside6 PROPERTY IMPORTED_IMPLIB ${PYSIDE_LIBRARY})
endif()
set_property(TARGET PySide6::pyside6 PROPERTY
IMPORTED_LOCATION ${PYSIDE_LIBRARY})
set_property(TARGET PySide6::pyside6 PROPERTY IMPORTED_LOCATION ${PYSIDE_LIBRARY})
set_property(TARGET PySide6::pyside6 APPEND PROPERTY
INTERFACE_INCLUDE_DIRECTORIES
${PYSIDE_INCLUDE_DIR}
@@ -127,7 +126,6 @@ if(PYSIDE6_FOUND)
)
endif()
find_package_handle_standard_args(PySide6
REQUIRED_VARS PYSIDE6_BASEDIR PYSIDE_INCLUDE_DIR PYSIDE_LIBRARY PYSIDE_TYPESYSTEMS
VERSION_VAR PYSIDE6_SO_VERSION

View File

@@ -1,10 +1,8 @@
#
# SPDX-FileCopyrightText: 2020-2021 Klarälvdalens Datakonsult AB, a KDAB Group company <info@kdab.com>
# SPDX-FileCopyrightText: 2019-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.
# SPDX-License-Identifier: BSD-3-Clause
#
# SHIBOKEN_INCLUDE_DIR - Directories to include to use SHIBOKEN
@@ -17,7 +15,7 @@
find_package(PkgConfig)
if(PKG_CONFIG_FOUND)
pkg_check_modules(SHIBOKEN2_PRIV QUIET shiboken2)
pkg_check_modules(SHIBOKEN2_PRIV QUIET shiboken2)
endif()
set(SHIBOKEN_FOUND FALSE)
@@ -42,33 +40,39 @@ if(SHIBOKEN2_PRIV_FOUND)
else()
execute_process(
COMMAND ${Python3_EXECUTABLE} -c "if True:
import os
try:
import shiboken2_generator
print(shiboken2_generator.__path__[0])
except:
exit()
import os
try:
import shiboken2_generator
print(shiboken2_generator.__path__[0])
except:
exit()
"
OUTPUT_VARIABLE SHIBOKEN_GENERATOR_BASEDIR
OUTPUT_STRIP_TRAILING_WHITESPACE
)
if(NOT SHIBOKEN_GENERATOR_BASEDIR)
message(FATAL_ERROR "The shiboken2_generator module could not be imported. Make sure you have it installed by checking the output of \"pip${Python3_VERSION_MAJOR}.${Python3_VERSION_MINOR} list\"")
endif()
execute_process(
COMMAND ${Python3_EXECUTABLE} -c "if True:
import os
try:
import shiboken2
print(shiboken2.__path__[0])
except:
exit()
import os
try:
import shiboken2
print(shiboken2.__path__[0])
except:
exit()
"
OUTPUT_VARIABLE SHIBOKEN_BASEDIR
OUTPUT_STRIP_TRAILING_WHITESPACE
)
if(NOT SHIBOKEN_BASEDIR)
message(FATAL_ERROR "The shiboken2 module could not be imported. Make sure you have it installed by checking the output of \"pip${Python3_VERSION_MAJOR}.${Python3_VERSION_MINOR} list\"")
endif()
execute_process(
COMMAND ${Python3_EXECUTABLE} -c "if True:
import os
import shiboken2
print(';'.join(filter(None, map(str, shiboken2.__version_info__))))
import os
import shiboken2
print(';'.join(filter(None, map(str, shiboken2.__version_info__))))
"
OUTPUT_VARIABLE SHIBOKEN_VERSION
OUTPUT_STRIP_TRAILING_WHITESPACE
@@ -84,32 +88,33 @@ else()
if(SHIBOKEN_BASEDIR)
find_path(SHIBOKEN_INCLUDE_DIR
shiboken.h
PATHS ${SHIBOKEN_CUSTOM_PREFIX} ${SHIBOKEN_GENERATOR_BASEDIR}/include
NO_DEFAULT_PATH)
shiboken.h
PATHS ${SHIBOKEN_CUSTOM_PREFIX} ${SHIBOKEN_GENERATOR_BASEDIR}/include
NO_DEFAULT_PATH
)
if(MSVC)
SET(SHIBOKEN_LIBRARY_BASENAMES "shiboken2.abi3.lib")
set(SHIBOKEN_LIBRARY_BASENAMES "shiboken2.abi3.lib")
elseif(CYGWIN)
SET(SHIBOKEN_LIBRARY_BASENAMES "")
set(SHIBOKEN_LIBRARY_BASENAMES "")
elseif(WIN32)
SET(SHIBOKEN_LIBRARY_BASENAMES "libshiboken2.${PYSIDE2_SUFFIX}")
set(SHIBOKEN_LIBRARY_BASENAMES "libshiboken2.${PYSIDE2_SUFFIX}")
elseif(APPLE)
SET(SHIBOKEN_LIBRARY_BASENAMES
libshiboken2.abi3.dylib
libshiboken2.abi3.${SHIBOKEN_MACRO_VERSION}.dylib
libshiboken2.abi3.${SHIBOKEN_MACRO_VERSION}.${SHIBOKEN_MICRO_VERSION}.dylib
libshiboken2.abi3.${SHIBOKEN_VERSION}.dylib
set(SHIBOKEN_LIBRARY_BASENAMES
libshiboken2.abi3.dylib
libshiboken2.abi3.${SHIBOKEN_MACRO_VERSION}.dylib
libshiboken2.abi3.${SHIBOKEN_MACRO_VERSION}.${SHIBOKEN_MICRO_VERSION}.dylib
libshiboken2.abi3.${SHIBOKEN_VERSION}.dylib
)
else()
SET(SHIBOKEN_LIBRARY_BASENAMES
libshiboken2.abi3.so
libshiboken2.abi3.so.${SHIBOKEN_MACRO_VERSION}
libshiboken2.abi3.so.${SHIBOKEN_MACRO_VERSION}.${SHIBOKEN_MICRO_VERSION}
libshiboken2.abi3.so.${SHIBOKEN_VERSION}
set(SHIBOKEN_LIBRARY_BASENAMES
libshiboken2.abi3.so
libshiboken2.abi3.so.${SHIBOKEN_MACRO_VERSION}
libshiboken2.abi3.so.${SHIBOKEN_MACRO_VERSION}.${SHIBOKEN_MICRO_VERSION}
libshiboken2.abi3.so.${SHIBOKEN_VERSION}
)
endif()
if (NOT SHIBOKEN_INCLUDE_DIR)
if(NOT SHIBOKEN_INCLUDE_DIR)
return()
endif()
set(SHIBOKEN_SEARCH_PATHS ${SHIBOKEN_CUSTOM_PREFIX})
@@ -126,14 +131,13 @@ else()
NO_DEFAULT_PATH
)
endif()
if (SHIBOKEN_INCLUDE_DIR AND SHIBOKEN_LIBRARY AND SHIBOKEN_BINARY)
if(SHIBOKEN_INCLUDE_DIR AND SHIBOKEN_LIBRARY AND SHIBOKEN_BINARY)
set(SHIBOKEN_FOUND TRUE)
endif()
if(SHIBOKEN_FOUND)
endif()
if(MSVC)
# On Windows we must link to python3.dll that is a small library that links against python3x.dll
# that allow us to choose any python3x.dll at runtime
@@ -150,12 +154,12 @@ else()
OUTPUT_STRIP_TRAILING_WHITESPACE
)
else()
# On Linux and MacOs our modules should not link with any python library
# that must be handled by the main process
# On Linux and MacOs our modules should not link with any python library
# that must be handled by the main process
set(PYTHON_LIMITED_LIBRARIES "")
endif()
endif()
if (SHIBOKEN_FOUND)
if(SHIBOKEN_FOUND)
message(STATUS "Shiboken include dir: ${SHIBOKEN_INCLUDE_DIR}")
message(STATUS "Shiboken library: ${SHIBOKEN_LIBRARY}")
message(STATUS "Shiboken binary: ${SHIBOKEN_BINARY}")
@@ -167,17 +171,17 @@ if (SHIBOKEN_FOUND)
set_property(TARGET Shiboken2::libshiboken PROPERTY
IMPORTED_IMPLIB ${SHIBOKEN_LIBRARY})
endif()
set_property(TARGET Shiboken2::libshiboken PROPERTY
IMPORTED_LOCATION ${SHIBOKEN_LIBRARY})
set_property(TARGET Shiboken2::libshiboken PROPERTY IMPORTED_LOCATION ${SHIBOKEN_LIBRARY})
set_property(TARGET Shiboken2::libshiboken APPEND PROPERTY
INTERFACE_INCLUDE_DIRECTORIES ${SHIBOKEN_INCLUDE_DIR} ${Python3_INCLUDE_DIRS})
INTERFACE_INCLUDE_DIRECTORIES ${SHIBOKEN_INCLUDE_DIR} ${Python3_INCLUDE_DIRS}
)
set_property(TARGET Shiboken2::libshiboken APPEND PROPERTY
INTERFACE_LINK_LIBRARIES ${PYTHON_LIMITED_LIBRARIES})
INTERFACE_LINK_LIBRARIES ${PYTHON_LIMITED_LIBRARIES}
)
# Generator target
add_executable(Shiboken2::shiboken IMPORTED GLOBAL)
set_property(TARGET Shiboken2::shiboken PROPERTY
IMPORTED_LOCATION ${SHIBOKEN_BINARY})
set_property(TARGET Shiboken2::shiboken PROPERTY IMPORTED_LOCATION ${SHIBOKEN_BINARY})
endif()
find_package_handle_standard_args(Shiboken2

View File

@@ -2,9 +2,7 @@
# 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.
# SPDX-License-Identifier: BSD-3-Clause
#
# SHIBOKEN_INCLUDE_DIR - Directories to include to use SHIBOKEN
@@ -15,38 +13,43 @@
# You can install Shiboken from Qt repository with
# pip3 install --index-url=https://download.qt.io/official_releases/QtForPython --trusted-host download.qt.io shiboken6-generator
set(SHIBOKEN_FOUND FALSE)
execute_process(
COMMAND ${Python3_EXECUTABLE} -c "if True:
import os
try:
import shiboken6_generator
print(shiboken6_generator.__path__[0])
except:
exit()
import os
try:
import shiboken6_generator
print(shiboken6_generator.__path__[0])
except:
exit()
"
OUTPUT_VARIABLE SHIBOKEN_GENERATOR_BASEDIR
OUTPUT_STRIP_TRAILING_WHITESPACE
)
if(NOT SHIBOKEN_GENERATOR_BASEDIR)
message(FATAL_ERROR "The shiboken6_generator module could not be imported. Make sure you have it installed by checking the output of \"pip${Python3_VERSION_MAJOR}.${Python3_VERSION_MINOR} list\"")
endif()
execute_process(
COMMAND ${Python3_EXECUTABLE} -c "if True:
import os
try:
import shiboken6
print(shiboken6.__path__[0])
except:
exit()
import os
try:
import shiboken6
print(shiboken6.__path__[0])
except:
exit()
"
OUTPUT_VARIABLE SHIBOKEN_BASEDIR
OUTPUT_STRIP_TRAILING_WHITESPACE
)
if(NOT SHIBOKEN_BASEDIR)
message(FATAL_ERROR "The shiboken6 module could not be imported. Make sure you have it installed by checking the output of \"pip${Python3_VERSION_MAJOR}.${Python3_VERSION_MINOR} list\"")
endif()
execute_process(
COMMAND ${Python3_EXECUTABLE} -c "if True:
import os
import shiboken6
print(';'.join(filter(None, map(str, shiboken6.__version_info__))))
import os
import shiboken6
print(';'.join(filter(None, map(str, shiboken6.__version_info__))))
"
OUTPUT_VARIABLE SHIBOKEN_VERSION
OUTPUT_STRIP_TRAILING_WHITESPACE
@@ -62,32 +65,33 @@ message(STATUS "Shiboken custom path: ${SHIBOKEN_CUSTOM_PREFIX}")
if(SHIBOKEN_BASEDIR)
find_path(SHIBOKEN_INCLUDE_DIR
shiboken.h
PATHS ${SHIBOKEN_CUSTOM_PREFIX} ${SHIBOKEN_GENERATOR_BASEDIR}/include
NO_DEFAULT_PATH)
shiboken.h
PATHS ${SHIBOKEN_CUSTOM_PREFIX} ${SHIBOKEN_GENERATOR_BASEDIR}/include
NO_DEFAULT_PATH
)
if(MSVC)
SET(SHIBOKEN_LIBRARY_BASENAMES "shiboken6.abi3.lib")
set(SHIBOKEN_LIBRARY_BASENAMES "shiboken6.abi3.lib")
elseif(CYGWIN)
SET(SHIBOKEN_LIBRARY_BASENAMES "")
set(SHIBOKEN_LIBRARY_BASENAMES "")
elseif(WIN32)
SET(SHIBOKEN_LIBRARY_BASENAMES "libshiboken6.${PYSIDE2_SUFFIX}")
set(SHIBOKEN_LIBRARY_BASENAMES "libshiboken6.${PYSIDE2_SUFFIX}")
elseif(APPLE)
SET(SHIBOKEN_LIBRARY_BASENAMES
libshiboken6.abi3.dylib
libshiboken6.abi3.${SHIBOKEN_MACRO_VERSION}.dylib
libshiboken6.abi3.${SHIBOKEN_MACRO_VERSION}.${SHIBOKEN_MICRO_VERSION}.dylib
libshiboken6.abi3.${SHIBOKEN_VERSION}.dylib
set(SHIBOKEN_LIBRARY_BASENAMES
libshiboken6.abi3.dylib
libshiboken6.abi3.${SHIBOKEN_MACRO_VERSION}.dylib
libshiboken6.abi3.${SHIBOKEN_MACRO_VERSION}.${SHIBOKEN_MICRO_VERSION}.dylib
libshiboken6.abi3.${SHIBOKEN_VERSION}.dylib
)
else()
SET(SHIBOKEN_LIBRARY_BASENAMES
libshiboken6.abi3.so
libshiboken6.abi3.so.${SHIBOKEN_MACRO_VERSION}
libshiboken6.abi3.so.${SHIBOKEN_MACRO_VERSION}.${SHIBOKEN_MICRO_VERSION}
libshiboken6.abi3.so.${SHIBOKEN_VERSION}
set(SHIBOKEN_LIBRARY_BASENAMES
libshiboken6.abi3.so
libshiboken6.abi3.so.${SHIBOKEN_MACRO_VERSION}
libshiboken6.abi3.so.${SHIBOKEN_MACRO_VERSION}.${SHIBOKEN_MICRO_VERSION}
libshiboken6.abi3.so.${SHIBOKEN_VERSION}
)
endif()
if (NOT SHIBOKEN_INCLUDE_DIR)
if(NOT SHIBOKEN_INCLUDE_DIR)
return()
endif()
set(SHIBOKEN_SEARCH_PATHS ${SHIBOKEN_CUSTOM_PREFIX})
@@ -104,14 +108,13 @@ if(SHIBOKEN_BASEDIR)
NO_DEFAULT_PATH
)
endif()
if (SHIBOKEN_INCLUDE_DIR AND SHIBOKEN_LIBRARY AND SHIBOKEN_BINARY)
if(SHIBOKEN_INCLUDE_DIR AND SHIBOKEN_LIBRARY AND SHIBOKEN_BINARY)
set(SHIBOKEN_FOUND TRUE)
endif()
if(SHIBOKEN_FOUND)
endif()
if(MSVC)
# On Windows we must link to python3.dll that is a small library that links against python3x.dll
# that allow us to choose any python3x.dll at runtime
@@ -128,12 +131,12 @@ if(MSVC)
OUTPUT_STRIP_TRAILING_WHITESPACE
)
else()
# On Linux and MacOs our modules should not link with any python library
# that must be handled by the main process
# On Linux and MacOs our modules should not link with any python library
# that must be handled by the main process
set(PYTHON_LIMITED_LIBRARIES "")
endif()
if (SHIBOKEN_FOUND)
if(SHIBOKEN_FOUND)
message(STATUS "Shiboken include dir: ${SHIBOKEN_INCLUDE_DIR}")
message(STATUS "Shiboken library: ${SHIBOKEN_LIBRARY}")
message(STATUS "Shiboken binary: ${SHIBOKEN_BINARY}")
@@ -145,17 +148,17 @@ if (SHIBOKEN_FOUND)
set_property(TARGET Shiboken6::libshiboken PROPERTY
IMPORTED_IMPLIB ${SHIBOKEN_LIBRARY})
endif()
set_property(TARGET Shiboken6::libshiboken PROPERTY
IMPORTED_LOCATION ${SHIBOKEN_LIBRARY})
set_property(TARGET Shiboken6::libshiboken PROPERTY IMPORTED_LOCATION ${SHIBOKEN_LIBRARY})
set_property(TARGET Shiboken6::libshiboken APPEND PROPERTY
INTERFACE_INCLUDE_DIRECTORIES ${SHIBOKEN_INCLUDE_DIR} ${Python3_INCLUDE_DIRS})
INTERFACE_INCLUDE_DIRECTORIES ${SHIBOKEN_INCLUDE_DIR} ${Python3_INCLUDE_DIRS}
)
set_property(TARGET Shiboken6::libshiboken APPEND PROPERTY
INTERFACE_LINK_LIBRARIES ${PYTHON_LIMITED_LIBRARIES})
INTERFACE_LINK_LIBRARIES ${PYTHON_LIMITED_LIBRARIES}
)
# Generator target
add_executable(Shiboken6::shiboken IMPORTED GLOBAL)
set_property(TARGET Shiboken6::shiboken PROPERTY
IMPORTED_LOCATION ${SHIBOKEN_BINARY})
set_property(TARGET Shiboken6::shiboken PROPERTY IMPORTED_LOCATION ${SHIBOKEN_BINARY})
endif()
find_package_handle_standard_args(Shiboken6

View File

@@ -5,43 +5,48 @@
# SPDX-License-Identifier: BSD-3-Clause
#
# Assumes you've already found Qt and Qt_VERSION_MAJOR is set
#
# Create variables for all the various install paths for the Qt version in use
# Make sure to have found Qt before using this.
# sets variables like QT_INSTALL_PREFIX, QT_INSTALL_DATA, QT_INSTALL_DOCS, etc.
# run qmake -query to see a full list
if(TARGET Qt${QT_MAJOR_VERSION}::qmake)
get_target_property(QT_QMAKE_EXECUTABLE Qt${QT_MAJOR_VERSION}::qmake LOCATION)
if(NOT DEFINED Qt_VERSION_MAJOR)
message(FATAL_ERROR "Please set Qt_VERSION_MAJOR first (ie. set(Qt_VERSION_MAJOR 5))")
endif()
if(TARGET Qt${Qt_VERSION_MAJOR}::qmake)
get_target_property(QT_QMAKE_EXECUTABLE Qt${Qt_VERSION_MAJOR}::qmake LOCATION)
else()
message(FATAL_ERROR "No supported Qt version found. Make sure you find Qt before calling this")
message(FATAL_ERROR "No supported Qt version found. Make sure you find Qt before calling this")
endif()
execute_process(
COMMAND ${QT_QMAKE_EXECUTABLE} -query
RESULT_VARIABLE return_code
OUTPUT_VARIABLE ALL_VARS
COMMAND ${QT_QMAKE_EXECUTABLE} -query
RESULT_VARIABLE return_code
OUTPUT_VARIABLE ALL_VARS
)
if(NOT return_code EQUAL 0)
message(WARNING "Failed call: ${QMAKE_EXECUTABLE} -query")
message(FATAL_ERROR "QMake call failed: ${return_code}")
message(WARNING "Failed call: ${QMAKE_EXECUTABLE} -query")
message(FATAL_ERROR "QMake call failed: ${return_code}")
endif()
string(REPLACE "\n" ";" VARS_LIST ${ALL_VARS})
foreach(QVAL ${VARS_LIST})
if(QVAL MATCHES "QT_INSTALL_")
string(REPLACE ":" ";" QVAL_LIST ${QVAL})
list(LENGTH QVAL_LIST listlen)
list(GET QVAL_LIST 0 var)
if(WIN32 AND ${listlen} GREATER 2)
list(GET QVAL_LIST 2 path)
list(GET QVAL_LIST 1 drive)
set(path "${drive}:${path}")
else()
list(GET QVAL_LIST 1 path)
if(QVAL MATCHES "QT_INSTALL_")
string(REPLACE ":" ";" QVAL_LIST ${QVAL})
list(LENGTH QVAL_LIST listlen)
list(GET QVAL_LIST 0 var)
if(WIN32 AND ${listlen} GREATER 2)
list(GET QVAL_LIST 2 path)
list(GET QVAL_LIST 1 drive)
set(path "${drive}:${path}")
else()
list(GET QVAL_LIST 1 path)
endif()
if(NOT ${var}) #if set already on the command line for example
set(${var} ${path} CACHE PATH "Qt install path for ${var}")
endif()
endif()
if(NOT ${var}) #if set already on the command line for example
set(${var} ${path} CACHE PATH "Qt install path for ${var}")
endif()
endif()
endforeach()

View File

@@ -1,30 +1,28 @@
#
# SPDX-FileCopyrightText: 2020-2021 Klarälvdalens Datakonsult AB, a KDAB Group company <info@kdab.com>
# SPDX-FileCopyrightText: 2019-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.
# SPDX-License-Identifier: BSD-3-Clause
#
if (NOT ${PROJECT_NAME}_PYTHON_BINDINGS_INSTALL_PREFIX)
SET(${PROJECT_NAME}_PYTHON_BINDINGS_INSTALL_PREFIX ${CMAKE_INSTALL_PREFIX} CACHE FILEPATH "Custom path to install python bindings.")
if(NOT ${PROJECT_NAME}_PYTHON_BINDINGS_INSTALL_PREFIX)
set(${PROJECT_NAME}_PYTHON_BINDINGS_INSTALL_PREFIX ${CMAKE_INSTALL_PREFIX} CACHE FILEPATH "Custom path to install python bindings.")
endif()
message(STATUS "PYTHON INSTALL PREFIX ${${PROJECT_NAME}_PYTHON_BINDINGS_INSTALL_PREFIX}")
if (WIN32)
if(WIN32)
set(PATH_SEP "\;")
else()
set(PATH_SEP ":")
endif()
if (NOT CMAKE_CXX_STANDARD)
set(CMAKE_CXX_STANDARD 17)
endif()
#Qt5 requires C++14
set(CMAKE_CXX_STANDARD 14)
set(CMAKE_CXX_STANDARD_REQUIRED ON)
# On macOS, check if Qt is a framework build. This affects how include paths should be handled.
get_target_property(QtCore_is_framework Qt5::Core FRAMEWORK)
if (QtCore_is_framework)
if(QtCore_is_framework)
# Get the path to the framework dir.
list(GET Qt5Core_INCLUDE_DIRS 0 QT_INCLUDE_DIR)
get_filename_component(QT_FRAMEWORK_INCLUDE_DIR "${QT_INCLUDE_DIR}/../" ABSOLUTE)
@@ -46,12 +44,14 @@ endif()
# --use-isnull-as-nb_nonzero: If a class have an isNull() const method, it will be used to compute
# the value of boolean casts.
# Example, QImage::isNull() will be used when on python side you do `if (myQImage)`
set(GENERATOR_EXTRA_FLAGS --generator-set=shiboken
--enable-parent-ctor-heuristic
--enable-pyside-extensions
--enable-return-value-heuristic
--use-isnull-as-nb_nonzero
-std=c++${CMAKE_CXX_STANDARD})
set(GENERATOR_EXTRA_FLAGS
--generator-set=shiboken
--enable-parent-ctor-heuristic
--enable-pyside-extensions
--enable-return-value-heuristic
--use-isnull-as-nb_nonzero
-std=c++${CMAKE_CXX_STANDARD}
)
# 2017-04-24 The protected hack can unfortunately not be disabled, because
# Clang does produce linker errors when we disable the hack.
@@ -62,8 +62,8 @@ if(WIN32 OR DEFINED AVOID_PROTECTED_HACK)
endif()
macro(make_path varname)
# accepts any number of path variables
string(REPLACE ";" "${PATH_SEP}" ${varname} "${ARGN}")
# accepts any number of path variables
string(REPLACE ";" "${PATH_SEP}" ${varname} "${ARGN}")
endmacro()
# Creates a PySide module target based on the arguments
@@ -84,16 +84,16 @@ endmacro()
# trigger if one of these files changes
# MODULE_OUTPUT_DIR - Where the library file should be stored
macro(CREATE_PYTHON_BINDINGS
LIBRARY_NAME
TYPESYSTEM_PATHS
INCLUDE_PATHS
OUTPUT_SOURCES
TARGET_INCLUDE_DIRS
TARGET_LINK_LIBRARIES
GLOBAL_INCLUDE
TYPESYSTEM_XML
DEPENDS
MODULE_OUTPUT_DIR)
LIBRARY_NAME
TYPESYSTEM_PATHS
INCLUDE_PATHS
OUTPUT_SOURCES
TARGET_INCLUDE_DIRS
TARGET_LINK_LIBRARIES
GLOBAL_INCLUDE
TYPESYSTEM_XML
DEPENDS
MODULE_OUTPUT_DIR)
# Transform the path separators into something shiboken understands.
make_path(shiboken_include_dirs ${INCLUDE_PATHS})
@@ -129,6 +129,7 @@ macro(CREATE_PYTHON_BINDINGS
PREFIX ""
OUTPUT_NAME ${MODULE_NAME}
LIBRARY_OUTPUT_DIRECTORY ${MODULE_OUTPUT_DIR}
INSTALL_RPATH "$ORIGIN"
)
if(WIN32)
@@ -152,5 +153,5 @@ macro(CREATE_PYTHON_BINDINGS
LINK_FLAGS "-undefined dynamic_lookup")
endif()
install(TARGETS ${TARGET_NAME}
LIBRARY DESTINATION ${${PROJECT_NAME}_PYTHON_BINDINGS_INSTALL_PREFIX}/${TARGET_NAME})
LIBRARY DESTINATION ${${PROJECT_NAME}_PYTHON_BINDINGS_INSTALL_PREFIX})
endmacro()

View File

@@ -2,29 +2,27 @@
# 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.
# SPDX-License-Identifier: BSD-3-Clause
#
if (NOT ${PROJECT_NAME}_PYTHON_BINDINGS_INSTALL_PREFIX)
SET(${PROJECT_NAME}_PYTHON_BINDINGS_INSTALL_PREFIX ${CMAKE_INSTALL_PREFIX} CACHE FILEPATH "Custom path to install python bindings.")
if(NOT ${PROJECT_NAME}_PYTHON_BINDINGS_INSTALL_PREFIX)
set(${PROJECT_NAME}_PYTHON_BINDINGS_INSTALL_PREFIX ${CMAKE_INSTALL_PREFIX} CACHE FILEPATH "Custom path to install python bindings.")
endif()
message(STATUS "PYTHON INSTALL PREFIX ${${PROJECT_NAME}_PYTHON_BINDINGS_INSTALL_PREFIX}")
if (WIN32)
if(WIN32)
set(PATH_SEP "\;")
else()
set(PATH_SEP ":")
endif()
if (NOT CMAKE_CXX_STANDARD)
set(CMAKE_CXX_STANDARD 17)
endif()
#Qt6 requires C++17
set(CMAKE_CXX_STANDARD 17)
set(CMAKE_CXX_STANDARD_REQUIRED ON)
# On macOS, check if Qt is a framework build. This affects how include paths should be handled.
get_target_property(QtCore_is_framework Qt6::Core FRAMEWORK)
if (QtCore_is_framework)
if(QtCore_is_framework)
# Get the path to the framework dir.
list(GET Qt6Core_INCLUDE_DIRS 0 QT_INCLUDE_DIR)
get_filename_component(QT_FRAMEWORK_INCLUDE_DIR "${QT_INCLUDE_DIR}/../" ABSOLUTE)
@@ -46,12 +44,14 @@ endif()
# --use-isnull-as-nb_nonzero: If a class have an isNull() const method, it will be used to compute
# the value of boolean casts.
# Example, QImage::isNull() will be used when on python side you do `if (myQImage)`
set(GENERATOR_EXTRA_FLAGS --generator-set=shiboken
--enable-parent-ctor-heuristic
--enable-pyside-extensions
--enable-return-value-heuristic
--use-isnull-as-nb_nonzero
-std=c++${CMAKE_CXX_STANDARD})
set(GENERATOR_EXTRA_FLAGS
--generator-set=shiboken
--enable-parent-ctor-heuristic
--enable-pyside-extensions
--enable-return-value-heuristic
--use-isnull-as-nb_nonzero
-std=c++${CMAKE_CXX_STANDARD}
)
# 2017-04-24 The protected hack can unfortunately not be disabled, because
# Clang does produce linker errors when we disable the hack.
@@ -62,8 +62,8 @@ if(WIN32 OR DEFINED AVOID_PROTECTED_HACK)
endif()
macro(make_path varname)
# accepts any number of path variables
string(REPLACE ";" "${PATH_SEP}" ${varname} "${ARGN}")
# accepts any number of path variables
string(REPLACE ";" "${PATH_SEP}" ${varname} "${ARGN}")
endmacro()
# Creates a PySide module target based on the arguments
@@ -84,16 +84,16 @@ endmacro()
# trigger if one of these files changes
# MODULE_OUTPUT_DIR - Where the library file should be stored
macro(CREATE_PYTHON_BINDINGS
LIBRARY_NAME
TYPESYSTEM_PATHS
INCLUDE_PATHS
OUTPUT_SOURCES
TARGET_INCLUDE_DIRS
TARGET_LINK_LIBRARIES
GLOBAL_INCLUDE
TYPESYSTEM_XML
DEPENDS
MODULE_OUTPUT_DIR)
LIBRARY_NAME
TYPESYSTEM_PATHS
INCLUDE_PATHS
OUTPUT_SOURCES
TARGET_INCLUDE_DIRS
TARGET_LINK_LIBRARIES
GLOBAL_INCLUDE
TYPESYSTEM_XML
DEPENDS
MODULE_OUTPUT_DIR)
# Transform the path separators into something shiboken understands.
make_path(shiboken_include_dirs ${INCLUDE_PATHS})
@@ -152,5 +152,5 @@ macro(CREATE_PYTHON_BINDINGS
LINK_FLAGS "-undefined dynamic_lookup")
endif()
install(TARGETS ${TARGET_NAME}
LIBRARY DESTINATION ${${PROJECT_NAME}_PYTHON_BINDINGS_INSTALL_PREFIX}/${TARGET_NAME})
LIBRARY DESTINATION ${${PROJECT_NAME}_PYTHON_BINDINGS_INSTALL_PREFIX})
endmacro()

View File

@@ -1,160 +0,0 @@
#
# 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.
#
# PYSIDE_BASEDIR - Top of the PySide2 installation
# PYSIDE_INCLUDE_DIR - Directories to include to use PySide2
# PYSIDE_LIBRARY - Files to link against to use PySide2
# PYSIDE_TYPESYSTEMS - Type system files that should be used by other bindings extending PySide2
#
# You can install PySide2 from Qt repository with
# pip3 install --index-url=https://download.qt.io/official_releases/QtForPython --trusted-host download.qt.io pyside2
find_package(PkgConfig)
if(PKG_CONFIG_FOUND)
pkg_check_modules(PYSIDE2_PRIV QUIET pyside2)
endif()
set(PYSIDE2_FOUND FALSE)
if(PYSIDE2_PRIV_FOUND)
set(PYSIDE2_FOUND TRUE)
message(STATUS "Using PySide2 found in the system!")
pkg_get_variable(SHIBOKEN_BINARY
pyside2
generator_location
)
pkg_get_variable(PYSIDE2_BASEDIR
pyside2
typesystemdir
)
pkg_get_variable(PYSIDE_INCLUDE_DIR
pyside2
includedir
)
set(PYSIDE_TYPESYSTEMS ${PYSIDE2_BASEDIR})
set(PYSIDE2_SO_VERSION ${PYSIDE2_PRIV_VERSION})
set(PYSIDE_LIBRARY ${PYSIDE2_PRIV_LINK_LIBRARIES})
list(GET PYSIDE_LIBRARY 0 PYSIDE_LIBRARY)
else()
# extract python library basename
list(GET Python3_LIBRARIES 0 PYTHON_LIBRARY_FILENAME)
get_filename_component(PYTHON_LIBRARY_FILENAME ${PYTHON_LIBRARY_FILENAME} NAME)
execute_process(
COMMAND ${Python3_EXECUTABLE} -c "if True:
import os, sys
try:
import PySide2.QtCore as QtCore
print(os.path.dirname(QtCore.__file__))
except Exception as error:
print(error, file=sys.stderr)
exit()
"
OUTPUT_VARIABLE PYSIDE2_BASEDIR
OUTPUT_STRIP_TRAILING_WHITESPACE
)
if(PYSIDE2_BASEDIR)
set(PYSIDE_BASEDIR ${PYSIDE2_BASEDIR} CACHE PATH "Top level install of PySide2" FORCE)
execute_process(
COMMAND ${Python3_EXECUTABLE} -c "if True:
import os
import PySide2.QtCore as QtCore
print(os.path.basename(QtCore.__file__).split('.', 1)[1])
"
OUTPUT_VARIABLE PYSIDE2_SUFFIX
OUTPUT_STRIP_TRAILING_WHITESPACE
)
execute_process(
COMMAND ${Python3_EXECUTABLE} -c "if True:
import os
import PySide2.QtCore as QtCore
print(';'.join(map(str, QtCore.__version_info__)))
"
OUTPUT_VARIABLE PYSIDE2_SO_VERSION
OUTPUT_STRIP_TRAILING_WHITESPACE
)
list(GET PYSIDE2_SO_VERSION 0 PYSIDE2_SO_MACRO_VERSION)
list(GET PYSIDE2_SO_VERSION 1 PYSIDE2_SO_MICRO_VERSION)
list(GET PYSIDE2_SO_VERSION 2 PYSIDE2_SO_MINOR_VERSION)
string(REPLACE ";" "." PYSIDE2_SO_VERSION "${PYSIDE2_SO_VERSION}")
if(NOT APPLE)
set(PYSIDE2_SUFFIX "${PYSIDE2_SUFFIX}.${PYSIDE2_SO_MACRO_VERSION}.${PYSIDE2_SO_MICRO_VERSION}")
else()
string(REPLACE ".so" "" PYSIDE2_SUFFIX ${PYSIDE2_SUFFIX})
set(PYSIDE2_SUFFIX "${PYSIDE2_SUFFIX}.${PYSIDE2_SO_MACRO_VERSION}.${PYSIDE2_SO_MICRO_VERSION}.dylib")
endif()
set(PYSIDE2_FOUND TRUE)
message(STATUS "PySide2 base dir: ${PYSIDE2_BASEDIR}" )
message(STATUS "PySide2 suffix: ${PYSIDE2_SUFFIX}")
endif()
if (PYSIDE2_FOUND)
#PySide
#===============================================================================
find_path(PYSIDE_INCLUDE_DIR
pyside.h
PATHS ${PYSIDE2_BASEDIR}/include ${PYSIDE2_CUSTOM_PREFIX}/include/PySide2
NO_DEFAULT_PATH)
# Platform specific library names
if(MSVC)
SET(PYSIDE_LIBRARY_BASENAMES "pyside2.abi3.lib")
elseif(CYGWIN)
SET(PYSIDE_LIBRARY_BASENAMES "")
elseif(WIN32)
SET(PYSIDE_LIBRARY_BASENAMES "libpyside2.${PYSIDE2_SUFFIX}")
else()
SET(PYSIDE_LIBRARY_BASENAMES "libpyside2.${PYSIDE2_SUFFIX}")
endif()
find_file(PYSIDE_LIBRARY
${PYSIDE_LIBRARY_BASENAMES}
PATHS ${PYSIDE2_BASEDIR} ${PYSIDE2_CUSTOM_PREFIX}/lib
NO_DEFAULT_PATH)
find_path(PYSIDE_TYPESYSTEMS
typesystem_core.xml
PATHS ${PYSIDE2_BASEDIR}/typesystems ${PYSIDE2_CUSTOM_PREFIX}/share/PySide2/typesystems
NO_DEFAULT_PATH)
endif()
endif()
if(PYSIDE2_FOUND)
message(STATUS "PySide include dir: ${PYSIDE_INCLUDE_DIR}")
message(STATUS "PySide library: ${PYSIDE_LIBRARY}")
message(STATUS "PySide typesystems: ${PYSIDE_TYPESYSTEMS}")
message(STATUS "PySide2 version: ${PYSIDE2_SO_VERSION}")
# Create PySide2 target
add_library(PySide2::pyside2 SHARED IMPORTED GLOBAL)
if(MSVC)
set_property(TARGET PySide2::pyside2 PROPERTY
IMPORTED_IMPLIB ${PYSIDE_LIBRARY})
endif()
set_property(TARGET PySide2::pyside2 PROPERTY
IMPORTED_LOCATION ${PYSIDE_LIBRARY})
set_property(TARGET PySide2::pyside2 APPEND PROPERTY
INTERFACE_INCLUDE_DIRECTORIES
${PYSIDE_INCLUDE_DIR}
${PYSIDE_INCLUDE_DIR}/QtCore/
${PYSIDE_INCLUDE_DIR}/QtGui/
${PYSIDE_INCLUDE_DIR}/QtWidgets/
${Python3_INCLUDE_DIRS}
)
endif()
find_package_handle_standard_args(PySide2
REQUIRED_VARS PYSIDE2_BASEDIR PYSIDE_INCLUDE_DIR PYSIDE_LIBRARY PYSIDE_TYPESYSTEMS
VERSION_VAR PYSIDE2_SO_VERSION
)

View File

@@ -32,7 +32,7 @@ class KDDockWidgetsConan(ConanFile):
}
default_options = {
"qt_version": "qt/[>5.9.0]@kdab/stable",
"qt_version": "qt/[>5.12.0]@kdab/stable",
"build_static": False,
"build_examples": True,
"build_tests": False,

View File

@@ -74,15 +74,15 @@ cmake . -DCMAKE_INSTALL_PREFIX=/usr -DKDDockWidgets_QT6=True -DCMAKE_BUILD_TYPE=
%files
%defattr(-,root,root)
%{_prefix}/share/doc/KDDockWidgets
%{_prefix}/share/doc/KDDockWidgets-qt6
%{_libdir}/libkddockwidgets-qt6.so.*
%files devel
%defattr(-,root,root,-)
%dir %{_includedir}/kddockwidgets
%{_includedir}/kddockwidgets/*
%dir %{_libdir}/cmake/KDDockWidgets
%{_libdir}/cmake/KDDockWidgets/*
%dir %{_includedir}/kddockwidgets-qt6
%{_includedir}/kddockwidgets-qt6/kddockwidgets/*
%dir %{_libdir}/cmake/KDDockWidgets-qt6
%{_libdir}/cmake/KDDockWidgets-qt6/*
%{_libdir}/libkddockwidgets-qt6.so
#%{_prefix}/mkspecs/modules/* ECMGeneratePriFile isn't ported to Qt6 yet

View File

@@ -9,17 +9,6 @@
# Contact KDAB at <info@kdab.com> for commercial licensing options.
#
# qhelpgenerator
find_program(QHELPGEN_EXECUTABLE qhelpgenerator
HINTS ${QT_INSTALL_BINS}
)
if(QHELPGEN_EXECUTABLE)
set(HAVE_QHELPGEN "YES")
else()
set(HAVE_QHELPGEN "NO")
message(STATUS "Unable to generate the API documentation in qch format. To fix, install the qthelpgenerator program which comes with Qt5.")
endif()
# Doxygen
find_package(Doxygen)
set_package_properties(Doxygen PROPERTIES
@@ -28,12 +17,6 @@ set_package_properties(Doxygen PROPERTIES
URL "https://www.doxygen.org"
PURPOSE "Needed to build the API documentation."
)
if(DOXYGEN_DOT_EXECUTABLE)
set(HAVE_DOT "YES")
else()
set(HAVE_DOT "NO")
message(STATUS "Unable to provide inheritance diagrams for the API documentation. To fix, install the graphviz project from https://www.graphviz.org")
endif()
if(DOXYGEN_FOUND)
add_subdirectory(api)

View File

@@ -9,6 +9,25 @@
# Contact KDAB at <info@kdab.com> for commercial licensing options.
#
# dot should come with Doxygen find_package(Doxygen)
if(DOXYGEN_DOT_EXECUTABLE)
set(HAVE_DOT "YES")
else()
set(HAVE_DOT "NO")
message(STATUS "Unable to provide inheritance diagrams for the API documentation. To fix, install the graphviz project from https://www.graphviz.org")
endif()
# qhelpgenerator
find_program(QHELPGEN_EXECUTABLE qhelpgenerator
HINTS ${QT_INSTALL_BINS}
)
if(QHELPGEN_EXECUTABLE)
set(HAVE_QHELPGEN "YES")
else()
set(HAVE_QHELPGEN "NO")
message(STATUS "Unable to generate the API documentation in qch format. To fix, install the qthelpgenerator program which comes with Qt.")
endif()
find_file(QDOC_QTCORE_TAG qtcore.tags
HINTS ${QT_INSTALL_DOCS}/qtcore
HINTS ${QT_INSTALL_DATA}/doc/qtcore
@@ -47,4 +66,6 @@ add_custom_command(
add_custom_target(kddockwidgets-api.qch ALL DEPENDS ${DOXYGEN_OUTPUT_DIR}/qch/kddockwidgets-api.qch)
add_custom_target(docs DEPENDS kddockwidgets-api.qch)
install(FILES ${DOXYGEN_OUTPUT_DIR}/qch/kddockwidgets-api.qch DESTINATION ${INSTALL_DOC_DIR})
set(QCH_INSTALL_DIR ${INSTALL_DOC_DIR} CACHE STRING "Install location of Qt Assistant help files.")
install(FILES ${DOXYGEN_OUTPUT_DIR}/qch/kddockwidgets-api.qch DESTINATION ${QCH_INSTALL_DIR})
install(FILES ${DOXYGEN_OUTPUT_DIR}/kddockwidgets.tags DESTINATION ${INSTALL_DOC_DIR})

View File

@@ -1,4 +1,4 @@
# Doxyfile 1.8.18
# Doxyfile 1.8.20
# This file describes the settings to be used by the documentation system
# doxygen (www.doxygen.org) for a project.
@@ -32,7 +32,7 @@ DOXYFILE_ENCODING = UTF-8
# title of most generated pages and in a few other places.
# The default value is: My Project.
PROJECT_NAME = "KDDockWidgets API Documentation"
PROJECT_NAME = "@PROJECT_NAME@ API Documentation"
# The PROJECT_NUMBER tag can be used to enter a project or revision number. This
# could be handy for archiving the generated documentation or if some version
@@ -99,7 +99,7 @@ OUTPUT_LANGUAGE = English
# Possible values are: None, LTR, RTL and Context.
# The default value is: None.
#TOO NEW OUTPUT_TEXT_DIRECTION = None
OUTPUT_TEXT_DIRECTION = None
# If the BRIEF_MEMBER_DESC tag is set to YES, doxygen will include brief member
# descriptions after the members that are listed in the file and class
@@ -205,7 +205,7 @@ JAVADOC_AUTOBRIEF = NO
# interpreted by doxygen.
# The default value is: NO.
#TOO NEW JAVADOC_BANNER = NO
JAVADOC_BANNER = NO
# If the QT_AUTOBRIEF tag is set to YES then doxygen will interpret the first
# line (until the first dot) of a Qt-style comment as the brief description. If
@@ -227,6 +227,14 @@ QT_AUTOBRIEF = YES
MULTILINE_CPP_IS_BRIEF = NO
# By default Python docstrings are displayed as preformatted text and doxygen's
# special commands cannot be used. By setting PYTHON_DOCSTRING to NO the
# doxygen's special commands can be used and the contents of the docstring
# documentation blocks is shown as doxygen documentation.
# The default value is: YES.
PYTHON_DOCSTRING = YES
# If the INHERIT_DOCS tag is set to YES then an undocumented member inherits the
# documentation from any documented member that it re-implements.
# The default value is: YES.
@@ -297,7 +305,7 @@ OPTIMIZE_OUTPUT_VHDL = NO
# separated into more groups, etc.
# The default value is: NO.
#TOO NEW: OPTIMIZE_OUTPUT_SLICE = NO
OPTIMIZE_OUTPUT_SLICE = NO
# Doxygen selects the parser to use depending on the extension of the files it
# parses. With this tag you can assign which parser to use for a given
@@ -336,7 +344,7 @@ MARKDOWN_SUPPORT = YES
# Minimum value: 0, maximum value: 99, default value: 5.
# This tag requires that the tag MARKDOWN_SUPPORT is set to YES.
#TOO NEW TOC_INCLUDE_HEADINGS = 5
TOC_INCLUDE_HEADINGS = 5
# When enabled doxygen tries to link words that correspond to documented
# classes, or namespaces to their corresponding documentation. Such a link can
@@ -449,6 +457,19 @@ TYPEDEF_HIDES_STRUCT = NO
LOOKUP_CACHE_SIZE = 0
# The NUM_PROC_THREADS specifies the number threads doxygen is allowed to use
# during processing. When set to 0 doxygen will based this on the number of
# cores available in the system. You can set it explicitly to a value larger
# than 0 to get more control over the balance between CPU load and processing
# speed. At this moment only the input processing can be done using multiple
# threads. Since this is still an experimental feature the default is set to 1,
# which efficively disables parallel processing. Please report any issues you
# encounter. Generating dot graphs in parallel is controlled by the
# DOT_NUM_THREADS setting.
# Minimum value: 0, maximum value: 32, default value: 1.
NUM_PROC_THREADS = 1
#---------------------------------------------------------------------------
# Build related configuration options
#---------------------------------------------------------------------------
@@ -461,7 +482,7 @@ LOOKUP_CACHE_SIZE = 0
# normally produced when WARNINGS is set to YES.
# The default value is: NO.
EXTRACT_ALL = NO
EXTRACT_ALL = YES
# If the EXTRACT_PRIVATE tag is set to YES, all private members of a class will
# be included in the documentation.
@@ -473,7 +494,7 @@ EXTRACT_PRIVATE = NO
# methods of a class will be included in the documentation.
# The default value is: NO.
#TOO NEW EXTRACT_PRIV_VIRTUAL = NO
EXTRACT_PRIV_VIRTUAL = NO
# If the EXTRACT_PACKAGE tag is set to YES, all members with package or internal
# scope will be included in the documentation.
@@ -547,13 +568,13 @@ HIDE_IN_BODY_DOCS = YES
# will be excluded. Set it to YES to include the internal documentation.
# The default value is: NO.
INTERNAL_DOCS = YES
INTERNAL_DOCS = NO
# If the CASE_SENSE_NAMES tag is set to NO then doxygen will only generate file
# names in lower-case letters. If set to YES, upper-case letters are also
# allowed. This is useful if you have classes or files whose names only differ
# in case and if your file system supports case sensitive file names. Windows
# (including Cygwin) ands Mac users are advised to set this option to NO.
# (including Cygwin) and Mac users are advised to set this option to NO.
# The default value is: system dependent.
CASE_SENSE_NAMES = YES
@@ -698,14 +719,14 @@ MAX_INITIALIZER_LINES = 30
# list will mention the files that were used to generate the documentation.
# The default value is: YES.
SHOW_USED_FILES = NO
SHOW_USED_FILES = YES
# Set the SHOW_FILES tag to NO to disable the generation of the Files page. This
# will remove the Files entry from the Quick Index and from the Folder Tree View
# (if specified).
# The default value is: YES.
SHOW_FILES = NO
SHOW_FILES = YES
# Set the SHOW_NAMESPACES tag to NO to disable the generation of the Namespaces
# page. This will remove the Namespaces entry from the Quick Index and from the
@@ -823,7 +844,8 @@ WARN_LOGFILE = doxygen.log
# spaces. See also FILE_PATTERNS and EXTENSION_MAPPING
# Note: If this tag is empty the current directory is searched.
INPUT = @CMAKE_SOURCE_DIR@
INPUT = "@CMAKE_SOURCE_DIR@/README.md" \
"@CMAKE_SOURCE_DIR@/src"
# This tag can be used to specify the character encoding of the source files
# that doxygen parses. Internally doxygen uses the UTF-8 encoding. Doxygen uses
@@ -851,12 +873,7 @@ INPUT_ENCODING = UTF-8
# *.vhdl, *.ucf, *.qsf and *.ice.
FILE_PATTERNS = *.cpp \
*.cc \
*.cxx \
*.h \
*.hh \
*.hxx \
*.hpp \
*.dox \
*.md \
*.gif
@@ -874,8 +891,7 @@ RECURSIVE = YES
# Note that relative paths are relative to the directory from which doxygen is
# run.
EXCLUDE = @CMAKE_SOURCE_DIR@/examples \
@CMAKE_SOURCE_DIR@/src/private
EXCLUDE =
# The EXCLUDE_SYMLINKS tag can be used to select whether or not files or
# directories that are symbolic links (a Unix file system feature) are excluded
@@ -901,7 +917,9 @@ EXCLUDE_PATTERNS = */.svn/* \
*/test/* \
*/tests/* \
*_p.cpp \
*_export.h
*_p.h \
*_export.h \
*/fwd_headers/*
# The EXCLUDE_SYMBOLS tag can be used to specify one or more symbol names
# (namespaces, classes, functions, etc.) that should be excluded from the
@@ -925,7 +943,7 @@ EXAMPLE_PATH =
# *.h) to filter out the source-files in the directories. If left blank all
# files are included.
EXAMPLE_PATTERNS = *
EXAMPLE_PATTERNS =
# If the EXAMPLE_RECURSIVE tag is set to YES then subdirectories will be
# searched for input files to be used with the \include or \dontinclude commands
@@ -938,7 +956,8 @@ EXAMPLE_RECURSIVE = NO
# that contain images that are to be included in the documentation (see the
# \image command).
IMAGE_PATH = "@CMAKE_CURRENT_SOURCE_DIR@" \
IMAGE_PATH = "@CMAKE_SOURCE_DIR@/images" \
"@CMAKE_CURRENT_SOURCE_DIR@" \
"@CMAKE_SOURCE_DIR@/screencap.gif"
# The INPUT_FILTER tag can be used to specify a program that doxygen should
@@ -1008,7 +1027,7 @@ USE_MDFILE_AS_MAINPAGE = "@CMAKE_SOURCE_DIR@/README.md"
# also VERBATIM_HEADERS is set to NO.
# The default value is: NO.
SOURCE_BROWSER = NO
SOURCE_BROWSER = YES
# Setting the INLINE_SOURCES tag to YES will include the body of functions,
# classes and enums directly into the documentation.
@@ -1027,13 +1046,13 @@ STRIP_CODE_COMMENTS = YES
# entity all documented functions referencing it will be listed.
# The default value is: NO.
REFERENCED_BY_RELATION = NO
REFERENCED_BY_RELATION = YES
# If the REFERENCES_RELATION tag is set to YES then for each documented function
# all documented entities called/used by that function will be listed.
# The default value is: NO.
REFERENCES_RELATION = NO
REFERENCES_RELATION = YES
# If the REFERENCES_LINK_SOURCE tag is set to YES and SOURCE_BROWSER tag is set
# to YES then the hyperlinks from functions in REFERENCES_RELATION and
@@ -1081,7 +1100,39 @@ USE_HTAGS = NO
# See also: Section \class.
# The default value is: YES.
VERBATIM_HEADERS = NO
VERBATIM_HEADERS = YES
# If the CLANG_ASSISTED_PARSING tag is set to YES then doxygen will use the
# clang parser (see: http://clang.llvm.org/) for more accurate parsing at the
# cost of reduced performance. This can be particularly helpful with template
# rich C++ code for which doxygen's built-in parser lacks the necessary type
# information.
# Note: The availability of this option depends on whether or not doxygen was
# generated with the -Duse_libclang=ON option for CMake.
# The default value is: NO.
CLANG_ASSISTED_PARSING = NO
# If clang assisted parsing is enabled you can provide the compiler with command
# line options that you would normally use when invoking the compiler. Note that
# the include paths will already be set by doxygen for the files and directories
# specified with INPUT and INCLUDE_PATH.
# This tag requires that the tag CLANG_ASSISTED_PARSING is set to YES.
CLANG_OPTIONS =
# If clang assisted parsing is enabled you can provide the clang parser with the
# path to the directory containing a file called compile_commands.json. This
# file is the compilation database (see:
# http://clang.llvm.org/docs/HowToSetupToolingForLLVM.html) containing the
# options used when the source files were built. This is equivalent to
# specifying the "-p" option to a clang tool, such as clang-check. These options
# will then be passed to the parser. Any options specified with CLANG_OPTIONS
# will be added as well.
# Note: The availability of this option depends on whether or not doxygen was
# generated with the -Duse_libclang=ON option for CMake.
CLANG_DATABASE_PATH =
#---------------------------------------------------------------------------
# Configuration options related to the alphabetical class index
@@ -1099,7 +1150,7 @@ ALPHABETICAL_INDEX = YES
# Minimum value: 1, maximum value: 20, default value: 5.
# This tag requires that the tag ALPHABETICAL_INDEX is set to YES.
COLS_IN_ALPHA_INDEX = 3
COLS_IN_ALPHA_INDEX = 5
# In case all classes in a project start with a common prefix, all classes will
# be put under the same header in the alphabetical index. The IGNORE_PREFIX tag
@@ -1247,7 +1298,7 @@ HTML_TIMESTAMP = YES
# The default value is: YES.
# This tag requires that the tag GENERATE_HTML is set to YES.
#TOO NEW HTML_DYNAMIC_MENUS = YES
HTML_DYNAMIC_MENUS = YES
# If the HTML_DYNAMIC_SECTIONS tag is set to YES then the generated HTML
# documentation will contain sections that can be hidden and shown after the
@@ -1348,7 +1399,7 @@ CHM_FILE =
HHC_LOCATION =
# The GENERATE_CHI flag controls if a separate .chi index file is generated
# (YES) or that it should be included in the master .chm file (NO).
# (YES) or that it should be included in the main .chm file (NO).
# The default value is: NO.
# This tag requires that the tag GENERATE_HTMLHELP is set to YES.
@@ -1389,7 +1440,7 @@ GENERATE_QHP = @HAVE_QHELPGEN@
# the HTML output folder.
# This tag requires that the tag GENERATE_QHP is set to YES.
QCH_FILE = @DOXYGEN_OUTPUT_DIR@/qch/kddockwidgets-api.qch
QCH_FILE = "@DOXYGEN_OUTPUT_DIR@/qch/kddockwidgets-api.qch"
# The QHP_NAMESPACE tag specifies the namespace to use when generating Qt Help
# Project output. For more information please see Qt Help Project / Namespace
@@ -1397,7 +1448,7 @@ QCH_FILE = @DOXYGEN_OUTPUT_DIR@/qch/kddockwidgets-api.qch
# The default value is: org.doxygen.Project.
# This tag requires that the tag GENERATE_QHP is set to YES.
QHP_NAMESPACE = com.kdab.KDDockWidgets.api.@KDDockWidgets_VERSION@
QHP_NAMESPACE = com.kdab.@PROJECT_NAME@.api.@KDDockWidgets_VERSION@
# The QHP_VIRTUAL_FOLDER tag specifies the namespace to use when generating Qt
# Help Project output. For more information please see Qt Help Project / Virtual
@@ -1406,7 +1457,7 @@ QHP_NAMESPACE = com.kdab.KDDockWidgets.api.@KDDockWidgets_VERSION@
# The default value is: doc.
# This tag requires that the tag GENERATE_QHP is set to YES.
QHP_VIRTUAL_FOLDER = KDDockWidgets-@KDDockWidgets_VERSION@
QHP_VIRTUAL_FOLDER = @PROJECT_NAME@-@KDDockWidgets_VERSION@
# If the QHP_CUST_FILTER_NAME tag is set, it specifies the name of a custom
# filter to add. For more information please see Qt Help Project / Custom
@@ -1436,7 +1487,7 @@ QHP_SECT_FILTER_ATTRS =
# generated .qhp file.
# This tag requires that the tag GENERATE_QHP is set to YES.
QHG_LOCATION = @QHELPGEN_EXECUTABLE@
QHG_LOCATION = "@QHELPGEN_EXECUTABLE@"
# If the GENERATE_ECLIPSEHELP tag is set to YES, additional index files will be
# generated, together with the HTML files, they form an Eclipse help plugin. To
@@ -1514,12 +1565,12 @@ EXT_LINKS_IN_WINDOW = NO
# tool (see https://github.com/dawbarton/pdf2svg) or inkscape (see
# https://inkscape.org) to generate formulas as SVG images instead of PNGs for
# the HTML output. These images will generally look nicer at scaled resolutions.
# Possible values are: png The default and svg Looks nicer but requires the
# pdf2svg tool.
# Possible values are: png (the default) and svg (looks nicer but requires the
# pdf2svg or inkscape tool).
# The default value is: png.
# This tag requires that the tag GENERATE_HTML is set to YES.
#TOO NEW HTML_FORMULA_FORMAT = png
HTML_FORMULA_FORMAT = png
# Use this tag to change the font size of LaTeX formulas included as images in
# the HTML documentation. When you change the font size after a successful
@@ -1545,7 +1596,7 @@ FORMULA_TRANSPARENT = YES
# to create new LaTeX commands to be used in formulas as building blocks. See
# the section "Including formulas" for details.
#TOO NEW FORMULA_MACROFILE =
FORMULA_MACROFILE =
# Enable the USE_MATHJAX option to render LaTeX formulas using MathJax (see
# https://www.mathjax.org) which uses client side JavaScript for the rendering
@@ -1709,7 +1760,7 @@ LATEX_OUTPUT = latex
# the output language.
# This tag requires that the tag GENERATE_LATEX is set to YES.
LATEX_CMD_NAME =
LATEX_CMD_NAME = latex
# The MAKEINDEX_CMD_NAME tag can be used to specify the command name to generate
# index for LaTeX.
@@ -1729,7 +1780,7 @@ MAKEINDEX_CMD_NAME = makeindex
# The default value is: makeindex.
# This tag requires that the tag GENERATE_LATEX is set to YES.
#TOO NEW LATEX_MAKEINDEX_CMD = makeindex
LATEX_MAKEINDEX_CMD = makeindex
# If the COMPACT_LATEX tag is set to YES, doxygen generates more compact LaTeX
# documents. This may be useful for small projects and may help to save some
@@ -1815,13 +1866,15 @@ LATEX_EXTRA_FILES =
PDF_HYPERLINKS = YES
# If the USE_PDFLATEX tag is set to YES, doxygen will use pdflatex to generate
# the PDF file directly from the LaTeX files. Set this option to YES, to get a
# higher quality PDF documentation.
# If the USE_PDFLATEX tag is set to YES, doxygen will use the engine as
# specified with LATEX_CMD_NAME to generate the PDF file directly from the LaTeX
# files. Set this option to YES, to get a higher quality PDF documentation.
#
# See also section LATEX_CMD_NAME for selecting the engine.
# The default value is: YES.
# This tag requires that the tag GENERATE_LATEX is set to YES.
USE_PDFLATEX = YES
USE_PDFLATEX = NO
# If the LATEX_BATCHMODE tag is set to YES, doxygen will add the \batchmode
# command to the generated LaTeX files. This will instruct LaTeX to keep running
@@ -1871,7 +1924,7 @@ LATEX_TIMESTAMP = NO
# LATEX_OUTPUT directory will be used.
# This tag requires that the tag GENERATE_LATEX is set to YES.
#TOO NEW LATEX_EMOJI_DIRECTORY =
LATEX_EMOJI_DIRECTORY =
#---------------------------------------------------------------------------
# Configuration options related to the RTF output
@@ -2015,7 +2068,7 @@ XML_PROGRAMLISTING = YES
# The default value is: NO.
# This tag requires that the tag GENERATE_XML is set to YES.
#TOO NEW XML_NS_MEMB_FILE_SCOPE = NO
XML_NS_MEMB_FILE_SCOPE = NO
#---------------------------------------------------------------------------
# Configuration options related to the DOCBOOK output
@@ -2111,7 +2164,7 @@ ENABLE_PREPROCESSING = YES
# The default value is: NO.
# This tag requires that the tag ENABLE_PREPROCESSING is set to YES.
MACRO_EXPANSION = YES
MACRO_EXPANSION = NO
# If the EXPAND_ONLY_PREDEF and MACRO_EXPANSION tags are both set to YES then
# the macro expansion is limited to the macros specified with the PREDEFINED and
@@ -2177,7 +2230,7 @@ EXPAND_AS_DEFINED =
SKIP_FUNCTION_MACROS = YES
#---------------------------------------------------------------------------O
#---------------------------------------------------------------------------
# Configuration options related to external references
#---------------------------------------------------------------------------
@@ -2194,15 +2247,17 @@ SKIP_FUNCTION_MACROS = YES
# the path). If a tag file is not located in the directory in which doxygen is
# run, you must also specify the path to the tagfile here.
TAGFILES = @QDOC_TAG_DIR@/qtcore/qtcore.tags=https://doc.qt.io/qt-5/ \
@QDOC_TAG_DIR@/qtgui/qtgui.tags=https://doc.qt.io/qt-5/ \
@QDOC_TAG_DIR@/qtwidgets/qtwidgets.tags=https://doc.qt.io/qt-5/
TAGFILES = "@QDOC_TAG_DIR@/qtcore/qtcore.tags=https://doc.qt.io/qt-5/" \
"@QDOC_TAG_DIR@/qtgui/qtgui.tags=https://doc.qt.io/qt-5/" \
"@QDOC_TAG_DIR@/qtwidgets/qtwidgets.tags=https://doc.qt.io/qt-5/" \
"@QDOC_TAG_DIR@/qtprintsupport/qtprintsupport.tags=https://doc.qt.io/qt-5/" \
"@QDOC_TAG_DIR@/qtxml/qtxml.tags=https://doc.qt.io/qt-5/"
# When a file name is specified after GENERATE_TAGFILE, doxygen will create a
# tag file that is based on the input files it reads. See section "Linking to
# external documentation" for more information about the usage of tag files.
GENERATE_TAGFILE = kddockwidgets.tag
GENERATE_TAGFILE = "@DOXYGEN_OUTPUT_DIR@/kddockwidgets.tags"
# If the ALLEXTERNALS tag is set to YES, all external class will be listed in
# the class index. If set to NO, only the inherited external classes will be
@@ -2403,7 +2458,7 @@ GRAPHICAL_HIERARCHY = YES
# The default value is: YES.
# This tag requires that the tag HAVE_DOT is set to YES.
DIRECTORY_GRAPH = NO
DIRECTORY_GRAPH = YES
# The DOT_IMAGE_FORMAT tag can be used to set the image format of the images
# generated by dot. For an explanation of the image formats see the section
@@ -2468,7 +2523,7 @@ PLANTUML_JAR_PATH =
# When using plantuml, the PLANTUML_CFG_FILE tag can be used to specify a
# configuration file for plantuml.
#TOO NEW PLANTUML_CFG_FILE =
PLANTUML_CFG_FILE =
# When using plantuml, the specified paths are searched for files specified by
# the !include statement in a plantuml block.

View File

@@ -10,6 +10,7 @@
*/
#include "MyFrameworkWidgetFactory.h"
#include "MyTitleBar_CSS.h"
#include <kddockwidgets/FrameworkWidgetFactory.h>
@@ -89,11 +90,13 @@ MySeparator::~MySeparator() = default;
KDDockWidgets::TitleBar * CustomWidgetFactory::createTitleBar(KDDockWidgets::Frame *frame) const
{
// Feel free to return MyTitleBar_CSS here instead, but just for education purposes!
return new MyTitleBar(frame);
}
KDDockWidgets::TitleBar * CustomWidgetFactory::createTitleBar(KDDockWidgets::FloatingWindow *fw) const
{
// Feel free to return MyTitleBar_CSS here instead, but just for education purposes!
return new MyTitleBar(fw);
}
@@ -101,4 +104,3 @@ Layouting::Separator * CustomWidgetFactory::createSeparator(Layouting::Widget *p
{
return new MySeparator(parent);
}

View File

@@ -56,9 +56,9 @@ MyMainWindow::MyMainWindow(const QString &uniqueName, KDDockWidgets::MainWindowO
, m_dockwidget5DoesntCloseBeforeRestore(dockwidget5DoesntCloseBeforeRestore)
{
auto menubar = menuBar();
auto fileMenu = new QMenu(QStringLiteral("File"));
m_toggleMenu = new QMenu(QStringLiteral("Toggle"));
auto miscMenu = new QMenu(QStringLiteral("Misc"));
auto fileMenu = new QMenu(QStringLiteral("File"), this);
m_toggleMenu = new QMenu(QStringLiteral("Toggle"), this);
auto miscMenu = new QMenu(QStringLiteral("Misc"), this);
menubar->addMenu(fileMenu);
menubar->addMenu(m_toggleMenu);
@@ -115,6 +115,10 @@ MyMainWindow::MyMainWindow(const QString &uniqueName, KDDockWidgets::MainWindowO
setAffinities({ affinityName });
createDockWidgets();
if (options & KDDockWidgets::MainWindowOption_HasCentralWidget) {
setPersistentCentralWidget(new MyWidget1());
}
}
MyMainWindow::~MyMainWindow()

View File

@@ -0,0 +1,79 @@
/*
This file is part of KDDockWidgets.
SPDX-FileCopyrightText: 2019-2021 Klarälvdalens Datakonsult AB, a KDAB Group company <info@kdab.com>
Author: Sérgio Martins <sergio.martins@kdab.com>
SPDX-License-Identifier: GPL-2.0-only OR GPL-3.0-only
Contact KDAB at <info@kdab.com> for commercial licensing options.
*/
#include <kddockwidgets/private/widgets/TitleBarWidget_p.h>
/**
* @brief Shows how to implement a custom titlebar which uses "Qt StyleSheets".
*
* Derive from KDDockWidgets::DefaultWidgetFactory and override the two createTitleBar() methods.
*
* To try it out, modify examples/dockwidgets/MyFrameworkWidgetFactory.cpp to return a MyTitleBar_CSS instance.
* Run the example with: ./bin/kddockwidgets_example -p
*
* WARNINGS:
* - Qt StyleSheets are not recommended for new applications. Often you are able to style 90% of
* the application but then hit a road block. QStyle is much more powerful and flexible.
* - The Qt maintainers have manifested intention to deprecated stylesheets.
* - Stylesheets are supported for built-in QWidgets (QPushButton, QComboBox, etc.), any widget
* that's not in Qt needs to be crafted by the user, that includes, for example, having to paint
* your background manually. KDDockWidget::TitleBarWidget does this for your convenience though.
* - Qt stylesheets don't react to property changes (known old bug in Qt), for example:
* QLineEdit[readOnly="true"] { color: gray }
* this won't trigger when readOnly changes to false, you need to set/unset. This is QTBUG-51236
* - KDDockWidgets::TitleBarWidget::isFocused is a property, there for needs to workaround the
* above bug by unsetting the sheet and setting it again.
*/
class MyTitleBar_CSS : public KDDockWidgets::TitleBarWidget
{
public:
explicit MyTitleBar_CSS(KDDockWidgets::Frame *frame)
: KDDockWidgets::TitleBarWidget(frame)
{
init();
}
explicit MyTitleBar_CSS(KDDockWidgets::FloatingWindow *fw)
: KDDockWidgets::TitleBarWidget(fw)
{
init();
}
~MyTitleBar_CSS() override;
void initStyleSheet()
{
// Or use qApp->setStyleSheet(), as you prefer
setStyleSheet(QStringLiteral("KDDockWidgets--TitleBarWidget {"
"background: blue"
"}"
"KDDockWidgets--TitleBarWidget:hover {"
"background: red"
"}"
"KDDockWidgets--TitleBarWidget[isFocused=true] {"
"background: green"
"}"));
}
void init()
{
initStyleSheet();
connect(this, &KDDockWidgets::TitleBar::isFocusedChanged, this, [this] {
// Workaround QTBUG-51236, this makes the [isFocused=true] syntax useful
setStyleSheet(QString());
initStyleSheet();
});
}
};
MyTitleBar_CSS::~MyTitleBar_CSS()
{
}

View File

@@ -120,9 +120,17 @@ int main(int argc, char **argv)
parser.addOption(dontCloseBeforeRestore);
QCommandLineOption showButtonsInTabBarIfTitleBarHidden("show-buttons-in-tabbar-if-titlebar-hidden",
QCoreApplication::translate("main", "If we're not using title bars we'll still show the close and float button in the tab bar"));
QCoreApplication::translate("main", "If we're not using title bars we'll still show the close and float button in the tab bar"));
parser.addOption(showButtonsInTabBarIfTitleBarHidden);
QCommandLineOption centralWidget("central-widget",
QCoreApplication::translate("main", "The main window will have a non-detachable central widget"));
parser.addOption(centralWidget);
QCommandLineOption ctxtMenuOnTabs("allow-switch-tabs-via-menu",
QCoreApplication::translate("main", "Allow switching tabs via context menu in tabs area"));
parser.addOption(ctxtMenuOnTabs);
#if defined(DOCKS_DEVELOPER_MODE)
parser.addOption(centralFrame);
@@ -164,6 +172,9 @@ int main(int argc, char **argv)
options = parser.isSet(centralFrame) ? MainWindowOption_HasCentralFrame
: MainWindowOption_None;
if (parser.isSet(centralWidget))
options |= MainWindowOption_HasCentralWidget;
if (parser.isSet(noQtTool))
internalFlags |= KDDockWidgets::Config::InternalFlag_DontUseQtToolWindowsForFloatingWindows;
@@ -230,6 +241,9 @@ int main(int argc, char **argv)
if (parser.isSet(tabsHaveCloseButton))
flags |= KDDockWidgets::Config::Flag_TabsHaveCloseButton;
if (parser.isSet(ctxtMenuOnTabs))
flags |= KDDockWidgets::Config::Flag_AllowSwitchingTabsViaMenu;
if (parser.isSet(doubleClickMaximize))
flags |= KDDockWidgets::Config::Flag_DoubleClickMaximizes;

View File

@@ -8,20 +8,34 @@
#
# Contact KDAB at <info@kdab.com> for commercial licensing options.
#
set(PYTHON_BINDING_NAMESPACE "PyKDDockWidgets")
set(PYTHON_VERSION "3.7" CACHE STRING "Use specific python version to build the project.")
find_package(Python3 ${PYTHON_VERSION} REQUIRED COMPONENTS Interpreter Development)
if(${PROJECT_NAME}_QT6)
find_package(Shiboken6 REQUIRED)
find_package(PySide6 ${Qt6Widgets_VERSION} EXACT REQUIRED)
include(PySide6ModuleBuild)
set(PYSIDE_MAJOR_VERSION "6")
else()
find_package(Shiboken2 REQUIRED)
find_package(PySide2 ${Qt5Widgets_VERSION} EXACT REQUIRED)
include(PySide2ModuleBuild)
set(PYSIDE_MAJOR_VERSION "2")
# Just to fix warnings with --warn-uninitialized
if(NOT DEFINED SHIBOKEN_CUSTOM_PREFIX) #look for shiboken in a custom location
set(SHIBOKEN_CUSTOM_PREFIX "")
endif()
if(NOT DEFINED PYSIDE_CUSTOM_PREFIX) #look for pyside in a custom location
set(PYSIDE_CUSTOM_PREFIX "")
endif()
if(${PROJECT_NAME}_QT6)
set(PYSIDE_MAJOR_VERSION "6")
set(PYTHON_BINDING_NAMESPACE "${PYTHON_BINDING_NAMESPACE}Qt${PYSIDE_MAJOR_VERSION}")
set(QtWidgets_VERSION ${Qt6Widgets_VERSION})
else()
set(PYSIDE_MAJOR_VERSION "2")
set(QtWidgets_VERSION ${Qt5Widgets_VERSION})
endif()
find_package(Python3 3.7 REQUIRED COMPONENTS Interpreter Development)
find_package(Shiboken${PYSIDE_MAJOR_VERSION} REQUIRED)
find_package(PySide${PYSIDE_MAJOR_VERSION} ${QtWidgets_VERSION} EXACT REQUIRED)
if(NOT ${PROJECT_NAME}_PYTHON_BINDINGS_INSTALL_PREFIX)
set(${PROJECT_NAME}_PYTHON_BINDINGS_INSTALL_PREFIX "${CMAKE_INSTALL_PREFIX}")
endif()
set(BINDINGS_DIR "${INSTALL_LIBRARY_DIR}/python${Python3_VERSION_MAJOR}.${Python3_VERSION_MINOR}/site-packages/${PYTHON_BINDING_NAMESPACE}")
set(${PROJECT_NAME}_PYTHON_BINDINGS_INSTALL_PREFIX "${${PROJECT_NAME}_PYTHON_BINDINGS_INSTALL_PREFIX}/${BINDINGS_DIR}")
include(PySide${PYSIDE_MAJOR_VERSION}ModuleBuild)
add_subdirectory(PyKDDockWidgets)

View File

@@ -48,9 +48,10 @@ set(PyKDDockWidgets_target_include_directories
# Libraries that will be necessary to link the target, this will used in the command 'target_link_libraries'
set(PyKDDockWidgets_target_link_libraries
KDAB::kddockwidgets
Qt${QT_MAJOR_VERSION}::Core
Qt${QT_MAJOR_VERSION}::Gui
Qt${QT_MAJOR_VERSION}::Widgets
Qt${Qt_VERSION_MAJOR}::Core
Qt${Qt_VERSION_MAJOR}::Gui
Qt${Qt_VERSION_MAJOR}::Widgets
${Python3_LIBRARIES}
)
# changes on these files should trigger a new generation
@@ -80,4 +81,11 @@ create_python_bindings(
configure_file(${CMAKE_CURRENT_SOURCE_DIR}/__init__.py.cmake ${CMAKE_CURRENT_BINARY_DIR}/__init__.py @ONLY)
# install
install(FILES ${CMAKE_CURRENT_BINARY_DIR}/__init__.py DESTINATION ${${PROJECT_NAME}_PYTHON_BINDINGS_INSTALL_PREFIX}/PyKDDockWidgets)
install(
FILES
${CMAKE_CURRENT_BINARY_DIR}/__init__.py
$<TARGET_LINKER_FILE:KDAB::kddockwidgets>
$<TARGET_SONAME_FILE:KDAB::kddockwidgets>
$<TARGET_FILE:KDAB::kddockwidgets>
DESTINATION
${${PROJECT_NAME}_PYTHON_BINDINGS_INSTALL_PREFIX})

View File

@@ -10,10 +10,16 @@
#
import sys
import os
__all__ = ['KDDockWidgets']
# Preload PySide2 libraries to avoid missing libraries while loading KDDockWidgets
def setupLibraryPath():
package_dir = os.path.abspath(os.path.dirname(__file__))
if sys.platform == 'win32':
os.add_dll_directory(package_dir)
# Preload PySide libraries to avoid missing libraries while loading KDDockWidgets
try:
from PySide@PYSIDE_MAJOR_VERSION@ import QtCore
# Create a alias for PySide module so we can use a single import in source files
@@ -22,3 +28,5 @@ try:
except Exception:
print("Failed to load PySide")
raise
setupLibraryPath()

View File

@@ -0,0 +1,163 @@
#
# 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.
#
from PyKDDockWidgetsQt6 import KDDockWidgets
from PySide6 import QtCore, QtWidgets, QtGui
from MyWidget1 import MyWidget1
from MyWidget2 import MyWidget2
from MyWidget3 import MyWidget3
def newMyWidget(parent = None):
randomNumber = QtCore.QRandomGenerator.global_().bounded(0, 100) + 1
if (randomNumber < 50):
if (randomNumber < 33):
return MyWidget1(parent)
else:
return MyWidget3(parent)
else:
return MyWidget2(parent)
class MyMainWindow(KDDockWidgets.MainWindow):
s_count = 0
s_menuCount = 0
def __init__(self, uniqueName, options = KDDockWidgets.MainWindowOption_None, dockWidget0IsNonClosable = False, nonDockableDockWidget9 = False, restoreIsRelative = False, maxSizeForDockWidget8 = False, affinityName = "", parent = None):
super().__init__(uniqueName, options, parent)
self.m_dockWidget0IsNonClosable = dockWidget0IsNonClosable
self.m_dockWidget9IsNonDockable = nonDockableDockWidget9
self.m_restoreIsRelative = restoreIsRelative
self.m_maxSizeForDockWidget8 = maxSizeForDockWidget8
self.m_dockwidgets = []
menubar = self.menuBar()
fileMenu = QtWidgets.QMenu("File")
self.m_toggleMenu = QtWidgets.QMenu("Toggle")
menubar.addMenu(fileMenu)
menubar.addMenu(self.m_toggleMenu)
newAction = fileMenu.addAction("New DockWidget")
newAction.triggered.connect(self._newDockWidget)
saveLayoutAction = fileMenu.addAction("Save Layout")
saveLayoutAction.triggered.connect(self._saveLayout)
restoreLayoutAction = fileMenu.addAction("Restore Layout")
restoreLayoutAction.triggered.connect(self._restoreLayout)
closeAllAction = fileMenu.addAction("Close All")
closeAllAction.triggered.connect(self._closeAll)
layoutEqually = fileMenu.addAction("Layout Equally")
layoutEqually.triggered.connect(self.layoutEqually)
quitAction = fileMenu.addAction("Quit")
quitAction.triggered.connect(QtWidgets.QApplication.instance().quit)
self.setAffinities([ affinityName ])
self.createDockWidgets()
def _newDockWidget(self):
MyMainWindow.s_menuCount += 1
w = newMyWidget(self)
w.setGeometry(100, 100, 400, 400)
dock = KDDockWidgets.DockWidget("new dock %d"%(MyMainWindow.s_menuCount))
dock.setWidget(w)
dock.resize(600, 600)
dock.show()
self.m_dockwidgets.append(dock)
def _saveLayout(self):
#saver = KDDockWidgets.LayoutSaver()
#result = saver.saveToFile("mylayout.json")
#print("Saving layout to disk. Result=", result)
print("Not available")
def _restoreLayout(self):
#options = KDDockWidgets.RestoreOption_None
#if self.m_restoreIsRelative:
# options |= KDDockWidgets.RestoreOption_RelativeToMainWindow
#saver = KDDockWidgets.LayoutSaver(options)
#saver.restoreFromFile("mylayout.json")
print("Not available")
def _closeAll(self):
for dw in self.m_dockwidgets:
dw.close()
def createDockWidgets(self):
if self.m_dockWidget9IsNonDockable:
numDockWidgets = 10
else:
numDockWidgets = 9
# numDockWidgets = 2
# Create 9 KDDockWidget::DockWidget and the respective widgets they're hosting (MyWidget instances)
for i in range(numDockWidgets):
self.m_dockwidgets.append(self.newDockWidget())
# MainWindow::addDockWidget() attaches a dock widget to the main window:
initialOpts = KDDockWidgets.InitialOption(KDDockWidgets.InitialVisibilityOption.StartHidden, QtCore.QSize(500, 500))
self.addDockWidget(self.m_dockwidgets[0], KDDockWidgets.Location_OnBottom, None, initialOpts)
# Here, for finer granularity we specify right of dockwidgets[0]:
self.addDockWidget(self.m_dockwidgets[1], KDDockWidgets.Location_OnRight, self.m_dockwidgets[0])
self.addDockWidget(self.m_dockwidgets[2], KDDockWidgets.Location_OnLeft)
self.addDockWidget(self.m_dockwidgets[3], KDDockWidgets.Location_OnBottom)
self.addDockWidget(self.m_dockwidgets[4], KDDockWidgets.Location_OnBottom)
# Tab two dock widgets together
self.m_dockwidgets[3].addDockWidgetAsTab(self.m_dockwidgets[5])
# 6 is floating, as it wasn't added to the main window via MainWindow::addDockWidget().
# and we tab 7 with it.
self.m_dockwidgets[6].addDockWidgetAsTab(self.m_dockwidgets[7])
# Floating windows also support nesting, here we add 8 to the bottom of the group
self.m_dockwidgets[6].addDockWidgetToContainingWindow(self.m_dockwidgets[8], KDDockWidgets.Location_OnBottom)
floatingWindow = self.m_dockwidgets[6].window()
floatingWindow.move(100, 100)
def newDockWidget(self):
# Passing options is optional, we just want to illustrate Option_NotClosable here
options = KDDockWidgets.DockWidget.Option_None
if (MyMainWindow.s_count == 0) and self.m_dockWidget0IsNonClosable:
options |= KDDockWidgets.DockWidget.Option_NotClosable
if (MyMainWindow.s_count == 9) and self.m_dockWidget9IsNonDockable:
options |= KDDockWidgets.DockWidget.Option_NotDockable
dock = KDDockWidgets.DockWidget("DockWidget #%d"%(MyMainWindow.s_count), options)
dock.setAffinities(self.affinities()); # optional, just to show the feature. Pass -mi to the example to see incompatible dock widgets
if MyMainWindow.s_count == 1:
dock.setIcon(QtGui.QIcon.fromTheme("mail-message"))
myWidget = newMyWidget(self)
if (MyMainWindow.s_count == 8) and self.m_maxSizeForDockWidget8:
# Set a maximum size on dock #8
myWidget.setMaximumSize(200, 200)
dock.setWidget(myWidget)
if dock.options() & KDDockWidgets.DockWidget.Option_NotDockable:
dock.setTitle("DockWidget #%d (%s)" %(MyMainWindow.s_count, "non dockable"))
else:
dock.setTitle("DockWidget #%d"%(MyMainWindow.s_count))
dock.resize(600, 600)
self.m_toggleMenu.addAction(dock.toggleAction())
MyMainWindow.s_count += 1
return dock

View File

@@ -0,0 +1,51 @@
#
# 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.
#
import PyKDDockWidgetsQt6
from PySide6 import QtWidgets, QtGui, QtCore
class MyWidget(QtWidgets.QWidget):
s_images = {}
def __init__(self, backgroundFile, logoFile, parent = None):
super().__init__(parent)
self.m_background = self._lookupImage(backgroundFile)
self.m_logo = self._lookupImage(logoFile)
def _lookupImage(self, imageName):
if imageName == "":
return None
if imageName not in MyWidget.s_images:
MyWidget.s_images[imageName] = QtGui.QImage(imageName)
return MyWidget.s_images[imageName]
def drawLogo(self, p):
if not self.m_logo:
return
ratio = self.m_logo.height() / (self.m_logo.width() * 1.0)
maxWidth = int(0.80 * self.size().width())
maxHeight = int(0.80 * self.size().height())
proposedHeight = int(maxWidth * ratio)
if (proposedHeight <= maxHeight):
width = maxWidth
else:
width = int(maxHeight / ratio)
height = int(width * ratio)
targetLogoRect = QtCore.QRect(0,0, width, height)
targetLogoRect.moveCenter(self.rect().center() + QtCore.QPoint(0, -int(self.size().height() * 0.00)))
p.drawImage(targetLogoRect, self.m_logo, self.m_logo.rect());

View File

@@ -0,0 +1,29 @@
#
# 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.
#
import PyKDDockWidgetsQt6
from PySide6 import QtWidgets, QtGui
from MyWidget import MyWidget
class MyWidget1(MyWidget):
def __init__(self, parent = None):
super().__init__(":/assets/triangles.png", ":/assets/KDAB_bubble_white.png", parent)
def paintEvent(self, ev):
p = QtGui.QPainter(self)
p.fillRect(self.rect(), QtGui.QColor(0xCC, 0xCC, 0xCC))
p.drawImage(self.m_background.rect(), self.m_background, self.m_background.rect())
self.drawLogo(p)

View File

@@ -0,0 +1,27 @@
#
# 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.
#
import PyKDDockWidgetsQt6
from PySide6 import QtWidgets, QtGui, QtCore
from MyWidget import MyWidget
class MyWidget2(MyWidget):
def __init__(self, parent = None):
super().__init__("", ":/assets/KDAB_bubble_blue.png", parent)
def paintEvent(self, ev):
p = QtGui.QPainter(self)
p.fillRect(self.rect(), QtCore.Qt.white);
self.drawLogo(p)

View File

@@ -0,0 +1,32 @@
#
# 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.
#
import PyKDDockWidgetsQt6
from PySide6 import QtWidgets, QtGui, QtCore
from MyWidget import MyWidget
class MyWidget3(MyWidget):
def __init__(self, parent = None):
super().__init__(":/assets/base.png", ":/assets/KDAB_bubble_fulcolor.png", parent)
self.m_triangle = QtGui.QImage(":/assets/tri.png")
def paintEvent(self, ev):
p = QtGui.QPainter(self)
p.fillRect(self.rect(), QtGui.QColor(0xD5, 0xD5, 0xD5))
p.drawImage(self.m_background.rect(), self.m_background, self.m_background.rect())
targetRect = QtCore.QRect(QtCore.QPoint(self.width() - self.m_triangle.width(), self.height() - self.m_triangle.height()), self.m_triangle.size())
self.drawLogo(p)

View File

@@ -0,0 +1,8 @@
Running python example
======================
Generate resource file with:
~# rcc -g python -o rc_assets.py ../../examples/dockwidgets/resources_example.qrc
Run the app:
~# python3 main.py

View File

@@ -0,0 +1,35 @@
#
# 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.
#
from PyKDDockWidgetsQt6 import KDDockWidgets
from MyMainWindow import MyMainWindow
from PySide6 import QtWidgets, QtCore
import sys
import rc_assets
if __name__ == "__main__":
QtWidgets.QApplication.setAttribute(QtCore.Qt.AA_EnableHighDpiScaling)
QtWidgets.QApplication.setAttribute(QtCore.Qt.AA_UseHighDpiPixmaps)
app = QtWidgets.QApplication(sys.argv)
app.setOrganizationName("KDAB")
app.setApplicationName("Test app")
app.setStyle(QtWidgets.QStyleFactory.create("Fusion"))
mainWindow = MyMainWindow("MyMainWindow", )
mainWindow.setWindowTitle("Main Window 1")
mainWindow.resize(1200, 1200)
mainWindow.show()
app.exec_()

View File

@@ -11,7 +11,7 @@
from PyKDDockWidgets import KDDockWidgets
from PySide import QtCore, QtWidgets, QtGui
from PySide2 import QtCore, QtWidgets, QtGui
from MyWidget1 import MyWidget1
from MyWidget2 import MyWidget2

View File

@@ -11,7 +11,7 @@
import PyKDDockWidgets
from PySide import QtWidgets, QtGui, QtCore
from PySide2 import QtWidgets, QtGui, QtCore
class MyWidget(QtWidgets.QWidget):
s_images = {}

View File

@@ -11,7 +11,7 @@
import PyKDDockWidgets
from PySide import QtWidgets, QtGui
from PySide2 import QtWidgets, QtGui
from MyWidget import MyWidget

View File

@@ -11,7 +11,7 @@
import PyKDDockWidgets
from PySide import QtWidgets, QtGui, QtCore
from PySide2 import QtWidgets, QtGui, QtCore
from MyWidget import MyWidget

View File

@@ -11,7 +11,7 @@
import PyKDDockWidgets
from PySide import QtWidgets, QtGui, QtCore
from PySide2 import QtWidgets, QtGui, QtCore
from MyWidget import MyWidget

View File

@@ -12,7 +12,7 @@
from PyKDDockWidgets import KDDockWidgets
from MyMainWindow import MyMainWindow
from PySide import QtWidgets, QtCore
from PySide2 import QtWidgets, QtCore
import sys
import rc_assets

View File

@@ -137,6 +137,10 @@ set(DOCKS_INSTALLABLE_PRIVATE_WIDGET_INCLUDES
private/widgets/TabWidgetWidget_p.h
)
set(DOCKS_INSTALLABLE_PRIVATE_QUICK_INCLUDES
private/quick/QWidgetAdapter_quick_p.h
)
if(${PROJECT_NAME}_QTQUICK)
set(DOCKSLIBS_SRCS ${DOCKSLIBS_SRCS}
DockWidgetQuick.cpp
@@ -241,9 +245,16 @@ add_library(KDAB::kddockwidgets ALIAS kddockwidgets)
set_target_properties(kddockwidgets PROPERTIES OUTPUT_NAME "kddockwidgets${KDDockWidgets_LIBRARY_QTID}")
set_compiler_flags(kddockwidgets)
if(${PROJECT_NAME}_QT6)
set(DOCKS_INCLUDES_INSTALL_PATH "include/kddockwidgets-qt6")
else()
set(DOCKS_INCLUDES_INSTALL_PATH "include/")
endif()
target_include_directories(kddockwidgets
PUBLIC
$<INSTALL_INTERFACE:include>
$<INSTALL_INTERFACE:${DOCKS_INCLUDES_INSTALL_PATH}>
$<BUILD_INTERFACE:${CMAKE_CURRENT_SOURCE_DIR}/fwd_headers>
PRIVATE
${CMAKE_CURRENT_SOURCE_DIR}
@@ -283,16 +294,16 @@ if(CMAKE_COMPILER_IS_GNUCXX OR IS_CLANG_BUILD)
endif()
if(${PROJECT_NAME}_QTQUICK)
target_link_libraries(kddockwidgets PUBLIC Qt${QT_MAJOR_VERSION}::Widgets Qt${QT_MAJOR_VERSION}::Quick Qt${QT_MAJOR_VERSION}::QuickControls2)
target_link_libraries(kddockwidgets PUBLIC Qt${Qt_VERSION_MAJOR}::Widgets Qt${Qt_VERSION_MAJOR}::Quick Qt${Qt_VERSION_MAJOR}::QuickControls2)
else()
target_link_libraries(kddockwidgets PUBLIC Qt${QT_MAJOR_VERSION}::Widgets)
target_link_libraries(kddockwidgets PUBLIC Qt${Qt_VERSION_MAJOR}::Widgets PRIVATE Qt${Qt_VERSION_MAJOR}::WidgetsPrivate)
endif()
if(WIN32)
target_link_libraries(kddockwidgets PRIVATE Qt${QT_MAJOR_VERSION}::GuiPrivate dwmapi)
elseif(NOT APPLE AND NOT EMSCRIPTEN AND NOT ${PROJECT_NAME}_QT6)
find_package(Qt${QT_MAJOR_VERSION}X11Extras)
target_link_libraries(kddockwidgets PUBLIC Qt${QT_MAJOR_VERSION}::X11Extras)
target_link_libraries(kddockwidgets PRIVATE Qt${Qt_VERSION_MAJOR}::GuiPrivate dwmapi)
elseif(NOT APPLE AND NOT EMSCRIPTEN AND NOT ${PROJECT_NAME}_QT6 AND ${PROJECT_NAME}_X11EXTRAS)
find_package(Qt${Qt_VERSION_MAJOR}X11Extras)
target_link_libraries(kddockwidgets PUBLIC Qt${Qt_VERSION_MAJOR}::X11Extras)
endif()
set_target_properties(kddockwidgets PROPERTIES
@@ -327,22 +338,23 @@ if(MSVC AND NOT ${PROJECT_NAME}_STATIC)
install(FILES "$<TARGET_PDB_FILE_DIR:kddockwidgets>/$<TARGET_PDB_FILE_NAME:kddockwidgets>" DESTINATION ${INSTALL_LIBRARY_DIR} CONFIGURATIONS Debug RelWithDebInfo)
endif()
install(FILES ${camelcase_HEADERS} DESTINATION include/kddockwidgets)
install(FILES ${DOCKS_INSTALLABLE_INCLUDES} DESTINATION include/kddockwidgets)
install(FILES ${DOCKS_INSTALLABLE_PRIVATE_INCLUDES} DESTINATION include/kddockwidgets/private)
install(FILES private/multisplitter/Item_p.h DESTINATION include/kddockwidgets/private/multisplitter)
install(FILES private/multisplitter/Widget.h DESTINATION include/kddockwidgets/private/multisplitter)
install(FILES private/multisplitter/Separator_p.h DESTINATION include/kddockwidgets/private/multisplitter)
install(FILES private/indicators/ClassicIndicators_p.h DESTINATION include/kddockwidgets/private/indicators)
install(FILES private/indicators/SegmentedIndicators_p.h DESTINATION include/kddockwidgets/private/indicators)
install(FILES ${camelcase_HEADERS} DESTINATION ${DOCKS_INCLUDES_INSTALL_PATH}/kddockwidgets)
install(FILES ${DOCKS_INSTALLABLE_INCLUDES} DESTINATION ${DOCKS_INCLUDES_INSTALL_PATH}/kddockwidgets)
install(FILES ${DOCKS_INSTALLABLE_PRIVATE_INCLUDES} DESTINATION ${DOCKS_INCLUDES_INSTALL_PATH}/kddockwidgets/private)
install(FILES private/multisplitter/Item_p.h DESTINATION ${DOCKS_INCLUDES_INSTALL_PATH}/kddockwidgets/private/multisplitter)
install(FILES private/multisplitter/Widget.h DESTINATION ${DOCKS_INCLUDES_INSTALL_PATH}/kddockwidgets/private/multisplitter)
install(FILES private/multisplitter/Separator_p.h DESTINATION ${DOCKS_INCLUDES_INSTALL_PATH}/kddockwidgets/private/multisplitter)
install(FILES private/indicators/ClassicIndicators_p.h DESTINATION ${DOCKS_INCLUDES_INSTALL_PATH}/kddockwidgets/private/indicators)
install(FILES private/indicators/SegmentedIndicators_p.h DESTINATION ${DOCKS_INCLUDES_INSTALL_PATH}/kddockwidgets/private/indicators)
if(KDDockWidgets_QTQUICK)
install(FILES private/multisplitter/Separator_quick.h DESTINATION include/kddockwidgets/private/multisplitter)
install(FILES private/multisplitter/Widget_quick.h DESTINATION include/kddockwidgets/private/multisplitter)
install(FILES ${DOCKS_INSTALLABLE_PRIVATE_QUICK_INCLUDES} DESTINATION ${DOCKS_INCLUDES_INSTALL_PATH}/kddockwidgets/private/quick)
install(FILES private/multisplitter/Separator_quick.h DESTINATION ${DOCKS_INCLUDES_INSTALL_PATH}/kddockwidgets/private/multisplitter)
install(FILES private/multisplitter/Widget_quick.h DESTINATION ${DOCKS_INCLUDES_INSTALL_PATH}/kddockwidgets/private/multisplitter)
else()
install(FILES ${DOCKS_INSTALLABLE_PRIVATE_WIDGET_INCLUDES} DESTINATION include/kddockwidgets/private/widgets)
install(FILES private/multisplitter/Separator_qwidget.h DESTINATION include/kddockwidgets/private/multisplitter)
install(FILES private/multisplitter/Widget_qwidget.h DESTINATION include/kddockwidgets/private/multisplitter)
install(FILES ${DOCKS_INSTALLABLE_PRIVATE_WIDGET_INCLUDES} DESTINATION ${DOCKS_INCLUDES_INSTALL_PATH}/kddockwidgets/private/widgets)
install(FILES private/multisplitter/Separator_qwidget.h DESTINATION ${DOCKS_INCLUDES_INSTALL_PATH}/kddockwidgets/private/multisplitter)
install(FILES private/multisplitter/Widget_qwidget.h DESTINATION ${DOCKS_INCLUDES_INSTALL_PATH}/kddockwidgets/private/multisplitter)
endif()
# Generate library version files
@@ -351,21 +363,21 @@ ecm_setup_version(
${${PROJECT_NAME}_VERSION}
VARIABLE_PREFIX KDDOCKWIDGETS
VERSION_HEADER "${CMAKE_CURRENT_BINARY_DIR}/kddockwidgets_version.h"
PACKAGE_VERSION_FILE "${CMAKE_CURRENT_BINARY_DIR}/KDDockWidgetsConfigVersion.cmake"
PACKAGE_VERSION_FILE "${CMAKE_CURRENT_BINARY_DIR}/KDDockWidgets${KDDockWidgets_LIBRARY_QTID}ConfigVersion.cmake"
SOVERSION ${${PROJECT_NAME}_SOVERSION}
COMPATIBILITY AnyNewerVersion
)
install(FILES "${CMAKE_CURRENT_BINARY_DIR}/kddockwidgets_version.h" DESTINATION include/kddockwidgets)
install(FILES "${CMAKE_CURRENT_BINARY_DIR}/kddockwidgets_version.h" DESTINATION ${DOCKS_INCLUDES_INSTALL_PATH}/kddockwidgets)
install(EXPORT kddockwidgetsTargets
FILE KDDockWidgetsTargets.cmake
FILE KDDockWidgets${KDDockWidgets_LIBRARY_QTID}Targets.cmake
NAMESPACE KDAB::
DESTINATION ${INSTALL_LIBRARY_DIR}/cmake/KDDockWidgets
DESTINATION ${INSTALL_LIBRARY_DIR}/cmake/KDDockWidgets${KDDockWidgets_LIBRARY_QTID}
)
configure_file(KDDockWidgetsConfig.cmake.in KDDockWidgetsConfig.cmake @ONLY)
install(FILES "${CMAKE_CURRENT_BINARY_DIR}/KDDockWidgetsConfig.cmake"
"${CMAKE_CURRENT_BINARY_DIR}/KDDockWidgetsConfigVersion.cmake"
DESTINATION ${INSTALL_LIBRARY_DIR}/cmake/KDDockWidgets
configure_file(KDDockWidgetsConfig.cmake.in KDDockWidgets${KDDockWidgets_LIBRARY_QTID}Config.cmake @ONLY)
install(FILES "${CMAKE_CURRENT_BINARY_DIR}/KDDockWidgets${KDDockWidgets_LIBRARY_QTID}Config.cmake"
"${CMAKE_CURRENT_BINARY_DIR}/KDDockWidgets${KDDockWidgets_LIBRARY_QTID}ConfigVersion.cmake"
DESTINATION ${INSTALL_LIBRARY_DIR}/cmake/KDDockWidgets${KDDockWidgets_LIBRARY_QTID}
)
if(${PROJECT_NAME}_DEVELOPER_MODE)
@@ -376,7 +388,7 @@ if(${PROJECT_NAME}_DEVELOPER_MODE)
if(NOT ${PROJECT_NAME}_QTQUICK AND KDDockWidgets_LINTER) # TODO: We can support it
add_executable(kddockwidgets_linter layoutlinter_main.cpp)
target_link_libraries(kddockwidgets_linter kddockwidgets Qt${QT_MAJOR_VERSION}::Widgets)
target_link_libraries(kddockwidgets_linter kddockwidgets Qt${Qt_VERSION_MAJOR}::Widgets)
endif()
endif()

View File

@@ -83,6 +83,7 @@ public:
Flag_KeepAboveIfNotUtilityWindow = 0x10000, ///< Only meaningful if Flag_DontUseUtilityFloatingWindows is set. If floating windows are normal windows, you might still want them to keep above and not minimize when you focus the main window.
Flag_CloseOnlyCurrentTab = 0x20000, ///< The TitleBar's close button will only close the current tab, instead of all of them
Flag_ShowButtonsOnTabBarIfTitleBarHidden = 0x40000, ///< When using Flag_HideTitleBarWhenTabsVisible the close/float buttons disappear with the title bar. With Flag_ShowButtonsOnTabBarIfHidden they'll be shown in the tab bar.
Flag_AllowSwitchingTabsViaMenu = 0x80000, ///< Allow switching tabs via a context menu when right clicking on the tab area
Flag_Default = Flag_AeroSnapWithClientDecos ///< The defaults
};
Q_DECLARE_FLAGS(Flags, Flag)

View File

@@ -83,6 +83,13 @@ void DockWidgetBase::addDockWidgetAsTab(DockWidgetBase *other, InitialOption opt
return;
}
if (isPersistentCentralDockWidget()) {
qWarning() << Q_FUNC_INFO << "Not supported with MainWindowOption_HasCentralWidget."
<< "MainWindowOption_HasCentralWidget can only have 1 widget in the center."
<< "Use MainWindowOption_HasCentralFrame instead, which is similar but supports tabbing.";
return;
}
Frame *frame = d->frame();
if (frame) {
@@ -182,6 +189,9 @@ bool DockWidgetBase::setFloating(bool floats)
return false;
}
if (floats && isPersistentCentralDockWidget())
return false;
if (floats) {
d->saveTabIndex();
if (isTabbed()) {
@@ -620,6 +630,9 @@ void DockWidgetBase::Private::close()
return;
}
if (m_isPersistentCentralDockWidget)
return;
// If it's overlayed and we're closing, we need to close the overlay
if (SideBar *sb = DockRegistry::self()->sideBarForDockWidget(q)) {
auto mainWindow = sb->mainWindow();
@@ -837,6 +850,11 @@ void DockWidgetBase::setMDIZ(int z)
#endif
}
bool DockWidgetBase::isPersistentCentralDockWidget() const
{
return d->m_isPersistentCentralDockWidget;
}
LayoutSaver::DockWidget::Ptr DockWidgetBase::Private::serialize() const
{
auto ptr = LayoutSaver::DockWidget::dockWidgetForName(q->uniqueName());

View File

@@ -450,6 +450,10 @@ public:
/// only implemented for QtQuick
void setMDIZ(int z);
///@brief Returns whether this dock widget is the main window persistent central widget
///This only applies when using MainWindowOption_HasCentralWidget
bool isPersistentCentralDockWidget() const;
Q_SIGNALS:
#ifdef KDDOCKWIDGETS_QTWIDGETS
///@brief signal emitted when the parent changed

View File

@@ -55,7 +55,9 @@ enum MainWindowOption
{
MainWindowOption_None = 0, ///> No option set
MainWindowOption_HasCentralFrame = 1, ///> Makes the MainWindow always have a central frame, for tabbing documents
MainWindowOption_MDI = 2 ///> EXPERIMENTAL!!1 The layout will be MDI. DockWidgets can have arbitrary positions, not restricted by any layout
MainWindowOption_MDI = 2, ///> The layout will be MDI. DockWidgets can have arbitrary positions, not restricted by any layout
MainWindowOption_HasCentralWidget = 4 | MainWindowOption_HasCentralFrame, ///> Similar to MainWindowOption_HasCentralFrame but
///> you'll have a central widget which can't be detached (Similar to regular QMainWindow).
};
Q_DECLARE_FLAGS(MainWindowOptions, MainWindowOption)
Q_ENUM_NS(MainWindowOptions)
@@ -258,7 +260,8 @@ enum FrameOption
FrameOption_None = 0,
FrameOption_AlwaysShowsTabs = 1,
FrameOption_IsCentralFrame = 2,
FrameOption_IsOverlayed = 4
FrameOption_IsOverlayed = 4,
FrameOption_NonDockable = 8 ///> You can't DND and tab things into this Frame
};
Q_DECLARE_FLAGS(FrameOptions, FrameOption)
Q_ENUM_NS(FrameOptions)

View File

@@ -11,14 +11,14 @@
include(CMakeFindDependencyMacro)
find_dependency(Qt5Widgets REQUIRED)
find_dependency(Qt@Qt_VERSION_MAJOR@Widgets REQUIRED)
if (@KDDockWidgets_QTQUICK@)
find_dependency(Qt5Quick REQUIRED)
find_dependency(Qt@Qt_VERSION_MAJOR@Quick REQUIRED)
endif()
if (NOT WIN32 AND NOT APPLE AND NOT EMSCRIPTEN)
if (NOT WIN32 AND NOT APPLE AND NOT EMSCRIPTEN AND NOT @KDDockWidgets_QT6@)
find_dependency(Qt5X11Extras REQUIRED)
endif()
# Add the targets file
include("${CMAKE_CURRENT_LIST_DIR}/KDDockWidgetsTargets.cmake")
include("${CMAKE_CURRENT_LIST_DIR}/KDDockWidgets@KDDockWidgets_LIBRARY_QTID@Targets.cmake")

View File

@@ -608,11 +608,6 @@ bool LayoutSaver::Frame::isValid() const
return false;
}
if (options > 3) {
qWarning() << Q_FUNC_INFO << "Invalid options" << options;
return false;
}
if (!dockWidgets.isEmpty()) {
if (currentTabIndex >= dockWidgets.size() || currentTabIndex < 0) {
qWarning() << Q_FUNC_INFO << "Invalid tab index" << currentTabIndex << dockWidgets.size();
@@ -657,7 +652,7 @@ QVariantMap LayoutSaver::Frame::toVariantMap() const
map.insert(QStringLiteral("geometry"), Layouting::rectToMap(geometry));
map.insert(QStringLiteral("options"), options);
map.insert(QStringLiteral("currentTabIndex"), currentTabIndex);
map.insert(QStringLiteral("mainWindowUniqueName"), mainWindowUniqueName);
map.insert(QStringLiteral("dockWidgets"), dockWidgetNames(dockWidgets));
return map;
@@ -674,6 +669,7 @@ void LayoutSaver::Frame::fromVariantMap(const QVariantMap &map)
id = map.value(QStringLiteral("id")).toString();
isNull = map.value(QStringLiteral("isNull")).toBool();
objectName = map.value(QStringLiteral("objectName")).toString();
mainWindowUniqueName = map.value(QStringLiteral("mainWindowUniqueName")).toString();
geometry = Layouting::mapToRect(map.value(QStringLiteral("geometry")).toMap());
options = static_cast<QFlags<FrameOption>::Int>(map.value(QStringLiteral("options")).toUInt());
currentTabIndex = map.value(QStringLiteral("currentTabIndex")).toInt();
@@ -770,9 +766,11 @@ QVariantMap LayoutSaver::FloatingWindow::toVariantMap() const
map.insert(QStringLiteral("multiSplitterLayout"), multiSplitterLayout.toVariantMap());
map.insert(QStringLiteral("parentIndex"), parentIndex);
map.insert(QStringLiteral("geometry"), Layouting::rectToMap(geometry));
map.insert(QStringLiteral("normalGeometry"), Layouting::rectToMap(normalGeometry));
map.insert(QStringLiteral("screenIndex"), screenIndex);
map.insert(QStringLiteral("screenSize"), Layouting::sizeToMap(screenSize));
map.insert(QStringLiteral("isVisible"), isVisible);
map.insert(QStringLiteral("windowState"), windowState);
if (!affinities.isEmpty())
map.insert(QStringLiteral("affinities"), stringListToVariant(affinities));
@@ -785,10 +783,12 @@ void LayoutSaver::FloatingWindow::fromVariantMap(const QVariantMap &map)
multiSplitterLayout.fromVariantMap(map.value(QStringLiteral("multiSplitterLayout")).toMap());
parentIndex = map.value(QStringLiteral("parentIndex")).toInt();
geometry = Layouting::mapToRect(map.value(QStringLiteral("geometry")).toMap());
normalGeometry = Layouting::mapToRect(map.value(QStringLiteral("normalGeometry")).toMap());
screenIndex = map.value(QStringLiteral("screenIndex")).toInt();
screenSize = Layouting::mapToSize(map.value(QStringLiteral("screenSize")).toMap());
isVisible = map.value(QStringLiteral("isVisible")).toBool();
affinities = variantToStringList(map.value(QStringLiteral("affinities")).toList());
windowState = Qt::WindowState(map.value(QStringLiteral("windowState"), Qt::WindowNoState).toInt());
// Compatibility hack. Old json format had a single "affinityName" instead of an "affinities" list:
const QString affinityName = map.value(QStringLiteral("affinityName")).toString();
@@ -802,11 +802,6 @@ bool LayoutSaver::MainWindow::isValid() const
if (!multiSplitterLayout.isValid())
return false;
if (options != MainWindowOption_None && options != MainWindowOption_HasCentralFrame) {
qWarning() << Q_FUNC_INFO << "Invalid option" << options;
return false;
}
return true;
}

View File

@@ -31,6 +31,13 @@
#include "private/LayoutSaver_p.h"
#include "private/DockWidgetBase_p.h"
// Or we can have a createDockWidget() in the factory
#ifdef KDDOCKWIDGETS_QTQUICK
# include "DockWidgetQuick.h"
#else
# include "DockWidget.h"
#endif
using namespace KDDockWidgets;
static LayoutWidget *createLayoutWidget(MainWindowBase *mainWindow, MainWindowOptions options)
@@ -44,10 +51,11 @@ static LayoutWidget *createLayoutWidget(MainWindowBase *mainWindow, MainWindowOp
class MainWindowBase::Private
{
public:
explicit Private(MainWindowBase *mainWindow, MainWindowOptions options)
explicit Private(MainWindowBase *mainWindow, const QString &uniqueName, MainWindowOptions options)
: m_options(options)
, q(mainWindow)
, m_layoutWidget(createLayoutWidget(mainWindow, options))
, m_persistentCentralDockWidget(createPersistentCentralDockWidget(uniqueName))
{
}
@@ -56,6 +64,38 @@ public:
return m_options & MainWindowOption_HasCentralFrame;
}
bool supportsPersistentCentralWidget() const
{
if (!dropArea()) {
// This is the MDI case
return false;
}
return (m_options & MainWindowOption_HasCentralWidget) == MainWindowOption_HasCentralWidget;
}
DockWidgetBase* createPersistentCentralDockWidget(const QString &uniqueName) const
{
if (!supportsPersistentCentralWidget())
return nullptr;
auto dw = new DockWidgetType(QStringLiteral("%1-persistentCentralDockWidget").arg(uniqueName));
dw->dptr()->m_isPersistentCentralDockWidget = true;
Frame *frame = dropArea()->m_centralFrame;
if (!frame) {
qWarning() << Q_FUNC_INFO << "Expected central frame";
return nullptr;
}
frame->addWidget(dw);
return dw;
}
DropAreaWithCentralFrame *dropArea() const
{
return qobject_cast<DropAreaWithCentralFrame *>(m_layoutWidget);
}
CursorPositions allowedResizeSides(SideBarLocation loc) const;
QRect rectForOverlay(Frame *, SideBarLocation) const;
@@ -69,12 +109,13 @@ public:
MainWindowBase *const q;
QPointer<DockWidgetBase> m_overlayedDockWidget;
LayoutWidget *const m_layoutWidget;
DockWidgetBase *const m_persistentCentralDockWidget;
};
MainWindowBase::MainWindowBase(const QString &uniqueName, KDDockWidgets::MainWindowOptions options,
WidgetType *parent, Qt::WindowFlags flags)
: QMainWindowOrQuick(parent, flags)
, d(new Private(this, options))
, d(new Private(this, uniqueName, options))
{
setUniqueName(uniqueName);
@@ -109,7 +150,11 @@ void MainWindowBase::addDockWidgetAsTab(DockWidgetBase *widget)
return;
}
if (d->supportsCentralFrame()) {
if (d->supportsPersistentCentralWidget()) {
qWarning() << Q_FUNC_INFO << "Not supported with MainWindowOption_HasCentralWidget."
<< "MainWindowOption_HasCentralWidget can only have 1 widget in the center."
<< "Use MainWindowOption_HasCentralFrame instead, which is similar but supports tabbing";
} else if (d->supportsCentralFrame()) {
dropArea()->m_centralFrame->addWidget(widget);
} else {
qWarning() << Q_FUNC_INFO << "Not supported without MainWindowOption_HasCentralFrame";
@@ -327,7 +372,7 @@ SideBarLocation MainWindowBase::Private::preferredSideBar(DockWidgetBase *dw) co
}
const Layouting::LayoutBorderLocations borders = item->adjacentLayoutBorders();
const qreal aspectRatio = dw->width() / (dw->height() * 1.0);
const qreal aspectRatio = dw->width() / (std::max(1, dw->height()) * 1.0);
/// 1. It's touching all borders
if (borders == Layouting::LayoutBorderLocation_All) {
@@ -450,6 +495,9 @@ void MainWindowBase::moveToSideBar(DockWidgetBase *dw)
void MainWindowBase::moveToSideBar(DockWidgetBase *dw, SideBarLocation location)
{
if (dw->isPersistentCentralDockWidget())
return;
if (SideBar *sb = sideBar(location)) {
QScopedValueRollback<bool> rollback(dw->d->m_isMovingToSideBar, true);
dw->forceClose();
@@ -479,7 +527,7 @@ void MainWindowBase::restoreFromSideBar(DockWidgetBase *dw)
void MainWindowBase::overlayOnSideBar(DockWidgetBase *dw)
{
if (!dw)
if (!dw || dw->isPersistentCentralDockWidget())
return;
const SideBar *sb = sideBarForDockWidget(dw);
@@ -718,3 +766,26 @@ QRect MainWindowBase::windowGeometry() const
return window()->geometry();
}
void MainWindowBase::setPersistentCentralWidget(QWidgetOrQuick *widget)
{
if (!d->supportsPersistentCentralWidget()) {
qWarning() << "MainWindow::setPersistentCentralWidget() requires MainWindowOption_HasCentralWidget";
return;
}
auto dw = d->m_persistentCentralDockWidget;
if (dw) {
dw->setWidget(widget);
} else {
qWarning() << Q_FUNC_INFO << "Unexpected null central dock widget";
}
}
QWidgetOrQuick *MainWindowBase::persistentCentralWidget() const
{
if (auto dw = d->m_persistentCentralDockWidget)
return dw->widget();
return nullptr;
}

View File

@@ -89,6 +89,21 @@ public:
KDDockWidgets::DockWidgetBase *relativeTo = nullptr,
KDDockWidgets::InitialOption initialOption = {});
/**
* @brief Sets a persistent central widget. It can't be detached.
*
* Requires passing MainWindowOption_HasCentralWidget in the CTOR.
* This is similar to the central frame concept of MainWindowOption_HasCentralFrame,
* with the difference that it won't show a tabs.
*
* @param widget The QWidget (or QQuickItem if built with QtQuick support) that you
* want to set.
*
* Example: kddockwidgets_example --central-widget
*/
Q_INVOKABLE void setPersistentCentralWidget(QWidgetOrQuick *widget);
QWidgetOrQuick *persistentCentralWidget() const;
/**
* @brief Returns the unique name that was passed via constructor.
* Used internally by the save/restore mechanism.

Binary file not shown.

Before

Width:  |  Height:  |  Size: 496 B

After

Width:  |  Height:  |  Size: 487 B

Binary file not shown.

Before

Width:  |  Height:  |  Size: 543 B

After

Width:  |  Height:  |  Size: 550 B

Binary file not shown.

Before

Width:  |  Height:  |  Size: 405 B

After

Width:  |  Height:  |  Size: 387 B

View File

@@ -148,6 +148,7 @@ public:
QAction *const toggleAction;
QAction *const floatAction;
LastPositions m_lastPositions;
bool m_isPersistentCentralDockWidget = false;
bool m_processingToggleAction = false;
bool m_updatingToggleAction = false;
bool m_updatingFloatAction = false;

View File

@@ -31,7 +31,16 @@ Frame *DropAreaWithCentralFrame::createCentralFrame(MainWindowOptions options)
{
Frame *frame = nullptr;
if (options & MainWindowOption_HasCentralFrame) {
frame = Config::self().frameworkWidgetFactory()->createFrame(nullptr, FrameOptions() | FrameOption_IsCentralFrame | FrameOption_AlwaysShowsTabs);
FrameOptions frameOptions = FrameOption_IsCentralFrame;
const bool hasPersistentCentralWidget = (options & MainWindowOption_HasCentralWidget) == MainWindowOption_HasCentralWidget;
if (hasPersistentCentralWidget) {
frameOptions |= FrameOption_NonDockable;
} else {
// With a persistent central widget we don't allow detaching it
frameOptions |= FrameOption_AlwaysShowsTabs;
}
frame = Config::self().frameworkWidgetFactory()->createFrame(nullptr, frameOptions);
frame->setObjectName(QStringLiteral("central frame"));
}

View File

@@ -28,6 +28,7 @@ public:
private:
friend class MainWindowBase;
friend class Frame;
Frame *const m_centralFrame = nullptr;
};

View File

@@ -369,6 +369,18 @@ void FloatingWindow::onVisibleFrameCountChanged(int count)
setVisible(count > 0);
}
Qt::WindowState FloatingWindow::windowStateOverride() const
{
Qt::WindowState state = Qt::WindowNoState;
if (isMaximizedOverride())
state = Qt::WindowMaximized;
else if (isMinimizedOverride())
state = Qt::WindowMinimized;
return state;
}
void FloatingWindow::updateTitleBarVisibility()
{
if (m_updatingTitleBarVisibility)
@@ -446,7 +458,21 @@ bool FloatingWindow::deserialize(const LayoutSaver::FloatingWindow &fw)
{
if (dropArea()->deserialize(fw.multiSplitterLayout)) {
updateTitleBarVisibility();
show();
if (fw.normalGeometry.isValid() && !isNormalWindowState(fw.windowState)) {
// Restore QWidgetPrivate's normalGeometry (no public API in QWidget)
setNormalGeometry(fw.normalGeometry);
}
// And show it:
if (fw.windowState & Qt::WindowMaximized) {
showMaximized();
} else if (fw.windowState & Qt::WindowMinimized) {
showMinimized();
} else {
showNormal();
}
return true;
} else {
return false;
@@ -458,11 +484,13 @@ LayoutSaver::FloatingWindow FloatingWindow::serialize() const
LayoutSaver::FloatingWindow fw;
fw.geometry = geometry();
fw.normalGeometry = normalGeometry();
fw.isVisible = isVisible();
fw.multiSplitterLayout = dropArea()->serialize();
fw.screenIndex = screenNumberForWidget(this);
fw.screenSize = screenSizeForWidget(this);
fw.affinities = affinities();
fw.windowState = windowStateOverride();
auto mainWindow = qobject_cast<MainWindowBase *>(parentWidget());
fw.parentIndex = mainWindow ? DockRegistry::self()->mainwindows().indexOf(mainWindow)
@@ -559,6 +587,36 @@ QMargins FloatingWindow::contentMargins() const
return { 4, 4, 4, 4 };
}
bool FloatingWindow::isMaximizedOverride() const
{
return QWidgetAdapter::isMaximized();
}
bool FloatingWindow::isMinimizedOverride() const
{
return QWidgetAdapter::isMinimized();
}
void FloatingWindow::showMaximized()
{
QWidgetAdapter::showMaximized();
}
void FloatingWindow::showNormal()
{
QWidgetAdapter::showNormal();
}
void FloatingWindow::showMinimized()
{
QWidgetAdapter::showMinimized();
}
QRect FloatingWindow::normalGeometry() const
{
return QWidgetAdapter::normalGeometry();
}
int FloatingWindow::userType() const
{
if (Frame *f = singleFrame())

View File

@@ -176,6 +176,40 @@ public:
///@brief Returns the contents margins
QMargins contentMargins() const;
///@brief Allows the user to override QWindow::isMaximized()
/// Needed to workaround window managers that don't support maximizing/minimizing Qt::Tool windows.
/// By default this just calls QWindow::isMaximized()
/// @sa QTBUG-95478
virtual bool isMaximizedOverride() const;
///@brief Allows the user to override QWindow::isMinimized()
/// Needed to workaround window managers that don't support maximizing/minimizing Qt::Tool windows.
/// By default this just calls QWindow::isMinimized()
/// @sa QTBUG-95478
virtual bool isMinimizedOverride() const;
///@brief By default equivalent to QWindow::showMaximized()
/// But allows the user to override it and workaround exotic window manager bugs
/// @sa QTBUG-95478
virtual void showMaximized();
///@brief By default equivalent to QWindow::showNormal()
/// But allows the user to override it and workaround exotic window manager bugs
/// @sa QTBUG-95478
virtual void showNormal();
///@brief By default equivalent to QWindow::showMinimized()
/// But allows the user to override it and workaround exotic window manager bugs
/// @sa QTBUG-95478
virtual void showMinimized();
///@brief By default equivalent to QWidget::normalGeometry()
/// 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
/// QWindow has no notion of normal geometry, so we need to implement it here.
/// @sa QTBUG-95478
virtual QRect normalGeometry() const;
///@brief Allows the user app to specify which window flags to use, instead of KDDWs default ones
///Bugs caused by this won't be supported, as the amount of combinations that could go wrong can
///be open ended
@@ -211,6 +245,7 @@ private:
bool m_updatingTitleBarVisibility = false;
QMetaObject::Connection m_layoutDestroyedConnection;
QAbstractNativeEventFilter *m_nchittestFilter = nullptr;
Qt::WindowState windowStateOverride() const;
#ifdef Q_OS_WIN
int m_lastHitTest = 0;
#endif

View File

@@ -31,6 +31,7 @@
#include "Utils_p.h"
#include "WidgetResizeHandler_p.h"
#include "MDILayoutWidget_p.h"
#include "DropAreaWithCentralFrame_p.h"
#include <QCloseEvent>
#include <QTimer>
@@ -147,7 +148,8 @@ void Frame::insertWidget(DockWidgetBase *dockWidget, int index, InitialOption ad
{
Q_ASSERT(dockWidget);
if (containsDockWidget(dockWidget)) {
qWarning() << "Frame::addWidget dockWidget already exists. this=" << this << "; dockWidget=" << dockWidget;
if (!dockWidget->isPersistentCentralDockWidget())
qWarning() << "Frame::addWidget dockWidget already exists. this=" << this << "; dockWidget=" << dockWidget;
return;
}
if (m_layoutItem)
@@ -652,7 +654,37 @@ Frame *Frame::deserialize(const LayoutSaver::Frame &f)
if (!f.isValid())
return nullptr;
auto frame = Config::self().frameworkWidgetFactory()->createFrame(/*parent=*/nullptr, FrameOptions(f.options));
const FrameOptions options = FrameOptions(f.options);
Frame *frame = nullptr;
const bool isPersistentCentralFrame = options & FrameOption::FrameOption_IsCentralFrame;
auto widgetFactory = Config::self().frameworkWidgetFactory();
if (isPersistentCentralFrame) {
// Don't create a new Frame if we're restoring the Persistent Central frame (the one created
// by MainWindowOption_HasCentralFrame). It already exists.
if (f.mainWindowUniqueName.isEmpty()) {
// Can happen with older serialization formats
qWarning() << Q_FUNC_INFO << "Frame is the persistent central frame but doesn't have"
<< "an associated window name";
} else {
if (MainWindowBase *mw = DockRegistry::self()->mainWindowByName(f.mainWindowUniqueName)) {
frame = mw->dropArea()->m_centralFrame;
if (!frame) {
// Doesn't happen...
qWarning() << "Main window" << f.mainWindowUniqueName << "doesn't have central frame";
}
} else {
// Doesn't happen...
qWarning() << Q_FUNC_INFO << "Couldn't find main window"
<< f.mainWindowUniqueName;
}
}
}
if (!frame)
frame = widgetFactory->createFrame(/*parent=*/nullptr, options);
frame->setObjectName(f.objectName);
for (const auto &savedDock : qAsConst(f.dockWidgets)) {
@@ -680,6 +712,9 @@ LayoutSaver::Frame Frame::serialize() const
frame.currentTabIndex = currentTabIndex();
frame.id = id(); // for coorelation purposes
if (MainWindowBase *mw = mainWindow())
frame.mainWindowUniqueName = mw->uniqueName();
for (DockWidgetBase *dock : docks)
frame.dockWidgets.push_back(dock->d->serialize());

View File

@@ -166,6 +166,12 @@ public:
return m_options & FrameOption_IsCentralFrame;
}
/// @brief Returns whether you can DND dock widgets over this frame and tab into it
bool isDockable() const
{
return !(m_options & FrameOption_NonDockable);
}
/**
* @brief whether the tab widget will always show tabs, even if there's only 1 dock widget
*

View File

@@ -212,6 +212,10 @@ struct LayoutSaver::Frame
int currentTabIndex;
QString id; // for coorelation purposes
/// Might be empty if not in a main window. Used so we don't create a frame when restoring
/// the persistent central frame, that's never deleted when restoring
QString mainWindowUniqueName;
LayoutSaver::DockWidget::List dockWidgets;
};
@@ -250,12 +254,14 @@ struct LayoutSaver::FloatingWindow
QStringList affinities;
int parentIndex = -1;
QRect geometry;
QRect normalGeometry;
int screenIndex;
QSize screenSize; // for relative-size restoring
bool isVisible = true;
// The instance that was created during a restore:
KDDockWidgets::FloatingWindow *floatingWindowInstance = nullptr;
Qt::WindowState windowState = Qt::WindowNoState;
};
struct LayoutSaver::MainWindow

View File

@@ -291,6 +291,10 @@ bool TabWidget::onMouseDoubleClick(QPoint localPos)
Frame *frame = this->frame();
// When using MainWindowOption_HasCentralFrame. The central frame is never detachable.
if (frame->isCentralFrame())
return false;
if (FloatingWindow *fw = frame->floatingWindow()) {
if (!fw->hasSingleFrame()) {
makeWindow();

View File

@@ -130,7 +130,7 @@ void TitleBar::toggleMaximized()
if (!m_floatingWindow)
return;
if (m_floatingWindow->isMaximized())
if (m_floatingWindow->isMaximizedOverride())
m_floatingWindow->showNormal();
else
m_floatingWindow->showMaximized();

View File

@@ -43,6 +43,7 @@ class DOCKS_EXPORT TitleBar : public QWidgetAdapter, public Draggable
Q_PROPERTY(bool closeButtonEnabled READ closeButtonEnabled WRITE setCloseButtonEnabled NOTIFY closeButtonEnabledChanged)
Q_PROPERTY(bool floatButtonVisible READ floatButtonVisible WRITE setFloatButtonVisible NOTIFY floatButtonVisibleChanged)
Q_PROPERTY(QString floatButtonToolTip READ floatButtonToolTip NOTIFY floatButtonToolTipChanged)
Q_PROPERTY(bool isFocused READ isFocused NOTIFY isFocusedChanged)
public:
typedef QVector<TitleBar *> List;

View File

@@ -110,6 +110,11 @@ inline bool usesUtilityWindows()
return !dontUse;
}
inline bool isNormalWindowState(Qt::WindowStates states)
{
return !(states & Qt::WindowMaximized) && !(states & Qt::WindowFullScreen);
}
inline bool usesFallbackMouseGrabber()
{
#ifdef KDDOCKWIDGETS_QTWIDGETS

View File

@@ -108,7 +108,7 @@ void ClassicIndicators::updateIndicatorsVisibility(bool visible)
// Only allow to dock to center if the affinities match
auto tabbingAllowedFunc = Config::self().tabbingAllowedFunc();
m_tabIndicatorVisible = m_innerIndicatorsVisible && windowBeingDragged && DockRegistry::self()->affinitiesMatch(m_hoveredFrame->affinities(), windowBeingDragged->affinities());
m_tabIndicatorVisible = m_innerIndicatorsVisible && windowBeingDragged && DockRegistry::self()->affinitiesMatch(m_hoveredFrame->affinities(), windowBeingDragged->affinities()) && m_hoveredFrame->isDockable();
if (m_tabIndicatorVisible && tabbingAllowedFunc) {
const DockWidgetBase::List source = windowBeingDragged->dockWidgets();
const DockWidgetBase::List target = m_hoveredFrame->dockWidgets();

View File

@@ -257,7 +257,6 @@ QSize QWidgetAdapter::minimumSize() const
QSize QWidgetAdapter::maximumSize() const
{
if (m_isWrapper) {
const auto children = childItems();
if (!children.isEmpty()) {
@@ -299,6 +298,27 @@ QRect QWidgetAdapter::geometry() const
return KDDockWidgets::Private::geometry(this);
}
QRect QWidgetAdapter::normalGeometry() const
{
// TODO: There's no such concept in QWindow, do we need to workaround for QtQuick ?
return QWidgetAdapter::geometry();
}
void QWidgetAdapter::setNormalGeometry(QRect geo)
{
if (!isTopLevel())
return;
if (QWindow *w = windowHandle()) {
if (isNormalWindowState(w->windowStates())) {
w->setGeometry(geo);
} else {
// Nothing better at this point, as QWindow doesn't have this concept
qDebug() << Q_FUNC_INFO << "TODO";
}
}
}
QRect QWidgetAdapter::rect() const
{
return QRectF(0, 0, width(), height()).toRect();
@@ -418,6 +438,14 @@ bool QWidgetAdapter::isMaximized() const
return false;
}
bool QWidgetAdapter::isMinimized() const
{
if (QWindow *w = windowHandle())
return w->windowStates() & Qt::WindowMinimized;
return false;
}
bool KDDockWidgets::QWidgetAdapter::isActiveWindow() const
{
if (QWindow *w = windowHandle())

View File

@@ -122,6 +122,8 @@ public:
virtual void setGeometry(QRect);
QRect frameGeometry() const;
QRect geometry() const;
QRect normalGeometry() const;
void setNormalGeometry(QRect);
QRect rect() const;
QPoint pos() const;
void show();
@@ -184,6 +186,7 @@ public:
return isWindow();
}
bool isMaximized() const;
bool isMinimized() const;
bool isActiveWindow() const;
Q_INVOKABLE void showMaximized();
Q_INVOKABLE void showMinimized();

View File

@@ -27,6 +27,8 @@
#include <QMouseEvent>
#include <QWindow>
#include <QtWidgets/private/qwidget_p.h>
using namespace KDDockWidgets;
QWidgetAdapter::QWidgetAdapter(QWidget *parent, Qt::WindowFlags f)
@@ -129,4 +131,18 @@ QWidget *KDDockWidgets::Private::widgetForWindow(QWindow *window)
return window->property("kddockwidgets_qwidget").value<QWidget *>();
}
void QWidgetAdapter::setNormalGeometry(QRect geo)
{
if (isNormalWindowState(windowState())) {
setGeometry(geo);
} else {
QWidgetPrivate *priv = QWidgetPrivate::get(this);
if (priv->extra && priv->extra->topextra) {
priv->topData()->normalGeometry = geo;
} else {
qWarning() << Q_FUNC_INFO << "Failing to set normal geometry";
}
}
}
LayoutGuestWidget::~LayoutGuestWidget() = default;

View File

@@ -103,6 +103,7 @@ protected:
void mouseMoveEvent(QMouseEvent *) override;
void mouseReleaseEvent(QMouseEvent *) override;
void closeEvent(QCloseEvent *) override;
virtual void setNormalGeometry(QRect);
virtual bool onResize(QSize newSize);
virtual void onLayoutRequest();

View File

@@ -27,6 +27,7 @@
#include <QTabBar>
#include <QHBoxLayout>
#include <QAbstractButton>
#include <QMenu>
using namespace KDDockWidgets;
@@ -38,6 +39,9 @@ TabWidgetWidget::TabWidgetWidget(Frame *parent)
setTabBar(static_cast<QTabBar *>(m_tabBar->asWidget()));
setTabsClosable(Config::self().flags() & Config::Flag_TabsHaveCloseButton);
setContextMenuPolicy(Qt::CustomContextMenu);
connect(this, &QTabWidget::customContextMenuRequested, this, &TabWidgetWidget::showContextMenu);
// In case tabs closable is set by the factory, a tabClosedRequested() is emitted when the user presses [x]
connect(this, &QTabWidget::tabCloseRequested, this, [this](int index) {
if (DockWidgetBase *dw = dockwidgetAt(index)) {
@@ -201,3 +205,34 @@ void TabWidgetWidget::updateMargins()
m_cornerWidgetLayout->setContentsMargins(QMargins(0, 0, 2, 0) * factor);
m_cornerWidgetLayout->setSpacing(int(2 * factor));
}
void TabWidgetWidget::showContextMenu(QPoint pos)
{
if (!(Config::self().flags() & Config::Flag_AllowSwitchingTabsViaMenu))
return;
QTabBar *tabBar = QTabWidget::tabBar();
// We dont want context menu if there is only one tab
if (tabBar->count() <= 1)
return;
// Click on a tab => No menu
if (tabBar->tabAt(pos) >= 0)
return;
// Right click is allowed only on the tabs area
QRect tabAreaRect = tabBar->rect();
tabAreaRect.setWidth(this->width());
if (!tabAreaRect.contains(pos))
return;
QMenu menu(this);
for (int i = 0; i < tabBar->count(); ++i) {
QAction *action = menu.addAction(tabText(i), this, [this, i] {
setCurrentIndex(i);
});
if (i == currentIndex())
action->setDisabled(true);
}
menu.exec(mapToGlobal(pos));
}

View File

@@ -65,6 +65,10 @@ protected:
DockWidgetBase *dockwidgetAt(int index) const override;
int currentIndex() const override;
/// @brief Shows the context menu. Override to implement your own context menu.
/// By default it's used to honour Config::Flag_AllowSwitchingTabsViaMenu
virtual void showContextMenu(QPoint pos);
private:
void updateMargins();
void setupTabBarButtons();

View File

@@ -236,6 +236,8 @@ void TitleBarWidget::paintEvent(QPaintEvent *)
QPainter p(this);
QStyleOptionDockWidget titleOpt;
titleOpt.initFrom(this);
style()->drawPrimitive(QStyle::PE_Widget, &titleOpt, &p, this);
titleOpt.title = title();
titleOpt.rect = iconRect().isEmpty() ? rect().adjusted(2, 0, -buttonAreaWidth(), 0)
: rect().adjusted(iconRect().right(), 0, -buttonAreaWidth(), 0);
@@ -275,12 +277,12 @@ void TitleBarWidget::updateMaximizeButton()
{
if (auto fw = floatingWindow()) {
auto factory = Config::self().frameworkWidgetFactory();
const TitleBarButtonType iconType = fw->isMaximized() ? TitleBarButtonType::Normal
: TitleBarButtonType::Maximize;
const TitleBarButtonType iconType = fw->isMaximizedOverride() ? TitleBarButtonType::Normal
: TitleBarButtonType::Maximize;
m_maximizeButton->setIcon(factory->iconForButtonType(iconType, devicePixelRatioF()));
m_maximizeButton->setVisible(supportsMaximizeButton());
m_maximizeButton->setToolTip(fw->isMaximized() ? tr("Restore") : tr("Maximize"));
m_maximizeButton->setToolTip(fw->isMaximizedOverride() ? tr("Restore") : tr("Maximize"));
} else {
m_maximizeButton->setVisible(false);
}

View File

@@ -33,12 +33,12 @@ option(KDDockWidgets_FUZZER "Builds the fuzzer" ON)
# tst_docks
set(TESTING_RESOURCES ${CMAKE_CURRENT_SOURCE_DIR}/test_resources.qrc)
add_executable(tst_docks tst_docks.cpp ${TESTING_SRCS} ${TESTING_RESOURCES})
target_link_libraries(tst_docks kddockwidgets Qt${QT_MAJOR_VERSION}::Test)
target_link_libraries(tst_docks kddockwidgets Qt${Qt_VERSION_MAJOR}::Test)
set_compiler_flags(tst_docks)
if(NOT ${PROJECT_NAME}_QTQUICK)
add_executable(tst_multisplitter tst_multisplitter.cpp)
target_link_libraries(tst_multisplitter kddockwidgets Qt${QT_MAJOR_VERSION}::Test)
target_link_libraries(tst_multisplitter kddockwidgets Qt${Qt_VERSION_MAJOR}::Test)
set_compiler_flags(tst_multisplitter)
if(KDDockWidgets_FUZZER)
add_subdirectory(fuzzer)
@@ -47,4 +47,4 @@ endif()
# tests_launcher
add_executable(tests_launcher tests_launcher.cpp)
target_link_libraries(tests_launcher Qt${QT_MAJOR_VERSION}::Core)
target_link_libraries(tests_launcher Qt${Qt_VERSION_MAJOR}::Core)

View File

@@ -12,5 +12,5 @@
add_executable(fuzzer main.cpp Fuzzer.cpp Operations.cpp ../Testing.cpp)
set_property(TARGET fuzzer PROPERTY CXX_STANDARD 17)
target_link_libraries(fuzzer kddockwidgets Qt${QT_MAJOR_VERSION}::Widgets Qt${QT_MAJOR_VERSION}::Test)
target_link_libraries(fuzzer kddockwidgets Qt${Qt_VERSION_MAJOR}::Widgets Qt${Qt_VERSION_MAJOR}::Test)
set_compiler_flags(fuzzer)

View File

@@ -619,6 +619,43 @@ void TestDocks::tst_restoreMaximizedState()
QCOMPARE(m->windowHandle()->windowState(), Qt::WindowMaximized);
}
void TestDocks::tst_restoreFloatingMaximizedState()
{
EnsureTopLevelsDeleted e;
KDDockWidgets::Config::self().setFlags(KDDockWidgets::Config::Flag_TitleBarHasMaximizeButton);
auto dock1 = createDockWidget("dock1", new MyWidget("one"));
const QRect originalNormalGeometry = dock1->floatingWindow()->normalGeometry();
dock1->floatingWindow()->showMaximized();
qDebug() << originalNormalGeometry;
QCOMPARE(dock1->floatingWindow()->windowHandle()->windowState(), Qt::WindowMaximized);
LayoutSaver saver;
const QByteArray saved = saver.serializeLayout();
saver.restoreLayout(saved);
QCOMPARE(dock1->floatingWindow()->windowHandle()->windowState(), Qt::WindowMaximized);
QCOMPARE(dock1->floatingWindow()->normalGeometry(), originalNormalGeometry);
dock1->floatingWindow()->showNormal();
QCOMPARE(dock1->floatingWindow()->normalGeometry(), originalNormalGeometry);
}
void TestDocks::tst_restoreFloatingMinimizedState()
{
EnsureTopLevelsDeleted e;
auto dock1 = createDockWidget("dock1", new MyWidget("one"));
dock1->floatingWindow()->showMinimized();
QCOMPARE(dock1->floatingWindow()->windowHandle()->windowState(), Qt::WindowMinimized);
LayoutSaver saver;
const QByteArray saved = saver.serializeLayout();
saver.restoreLayout(saved);
QCOMPARE(dock1->floatingWindow()->windowHandle()->windowState(), Qt::WindowMinimized);
}
void TestDocks::tst_setFloatingSimple()
{
EnsureTopLevelsDeleted e;
@@ -3709,6 +3746,23 @@ void TestDocks::tst_restoreSideBySide()
}
}
void TestDocks::tst_restoreWithCentralFrameWithTabs()
{
auto m = createMainWindow(QSize(500, 500), MainWindowOption_HasCentralFrame, "tst_restoreTwice");
auto dock1 = createDockWidget("1", new QPushButton("1"));
auto dock2 = createDockWidget("2", new QPushButton("2"));
m->addDockWidgetAsTab(dock1);
m->addDockWidgetAsTab(dock2);
QCOMPARE(DockRegistry::self()->frames().size(), 1);
LayoutSaver saver;
const QByteArray saved = saver.serializeLayout();
QVERIFY(saver.restoreLayout(saved));
QCOMPARE(DockRegistry::self()->frames().size(), 1);
}
void TestDocks::tst_restoreWithPlaceholder()
{
// Float dock1, save and restore, then unfloat and see if dock2 goes back to where it was
@@ -5083,6 +5137,7 @@ void TestDocks::tst_restoreSideBar()
serialized = saver.serializeLayout();
m1.reset();
delete fw1;
}
@@ -5199,6 +5254,7 @@ void TestDocks::tst_sidebarOverlayGetsHiddenOnClick()
Tests::clickOn(widget2->mapToGlobal(widget2->rect().bottomLeft() + QPoint(5, -5)), widget2);
QVERIFY(!dw1->isOverlayed());
m1.reset();
delete dw1;
}
@@ -5218,8 +5274,6 @@ void TestDocks::tst_sidebarOverlayGetsHiddenOnClick()
const QPoint localPt(100, 250);
Tests::clickOn(m1->mapToGlobal(m1->rect().topLeft() + localPt), m1->childAt(localPt));
QVERIFY(!dw1->isOverlayed());
delete dw1;
}
}
@@ -7322,3 +7376,25 @@ void TestDocks::tst_closeTabOfCentralFrame()
dock1->close();
QVERIFY(frame->QWidgetAdapter::isVisible());
}
void TestDocks::tst_persistentCentralWidget()
{
EnsureTopLevelsDeleted e;
auto m = createMainWindow(QSize(500, 500), MainWindowOption_HasCentralWidget);
auto dockwidgets = m->dropArea()->dockWidgets();
QCOMPARE(dockwidgets.size(), 1);
auto dw = dockwidgets.constFirst();
dw->close();
QVERIFY(dw->isOpen());
QVERIFY(dw->isPersistentCentralDockWidget());
dw->setFloating(true);
QVERIFY(!dw->isFloating());
LayoutSaver saver;
const QByteArray saved = saver.serializeLayout();
QVERIFY(!saved.isEmpty());
QVERIFY(saver.restoreLayout(saved));
}

View File

@@ -91,6 +91,8 @@ private Q_SLOTS:
void tst_restoreEmpty();
void tst_restoreCentralFrame();
void tst_restoreMaximizedState();
void tst_restoreFloatingMaximizedState();
void tst_restoreFloatingMinimizedState();
void tst_shutdown();
void tst_closeDockWidgets();
void tst_layoutEqually();
@@ -104,6 +106,7 @@ private Q_SLOTS:
void tst_restoreNestedAndTabbed();
void tst_restoreCrash();
void tst_restoreSideBySide();
void tst_restoreWithCentralFrameWithTabs();
void tst_restoreWithPlaceholder();
void tst_restoreWithAffinity();
void tst_marginsAfterRestore();
@@ -238,6 +241,7 @@ private Q_SLOTS:
void tst_addMDIDockWidget();
void tst_redockToMDIRestoresPosition();
void tst_persistentCentralWidget();
#ifdef KDDOCKWIDGETS_QTWIDGETS
// TODO: Port these to QtQuick