Compare commits

...

26 Commits

Author SHA1 Message Date
Allen Winter
cbedc06e97 various - prep for 1.1.1 release 2020-12-11 16:56:04 -05:00
Sergio Martins
b5c2757874 Updated Changelog with v1.1.1 2020-12-11 16:36:37 +00:00
Sergio Martins
fb6e2afd7b Windows: Don't start a drag when it's a resize
There were a few pixels where you could click where, very near the
border where it would start a drag while it shouldn't.

The drag state machine then was in an invalid state which could lead to
a crash.

Fixes issue #110
2020-12-10 21:16:42 +00:00
Sergio Martins
80bf6032f3 Fix FloatingWindow's title when shown in the taskbar
The window title isn't only important when using native title bar,
it's also important for showing the correct title in the taskbar
or alt-tab.

For example, if using "minimize support", they'll show in the task bar

Fixes issue #101
2020-11-23 15:52:50 +00:00
Allen Winter
ece7b22bec apidox - fix doc for enum KDDockWidgets::Config::Flag
doxygen likes "///<"  (not "///>")

Issue#106
2020-11-22 12:17:38 -05:00
Sergio Martins
72605292b7 Don't show dock/undock icon when dockwidget is not dockable
Fixes issue #99
2020-11-13 15:51:26 +00:00
Sergio Martins
7318675e84 Clarify comment about fractionaly scalling factors
The problem can happen on Windows too.

Fixes issue #94

Nothing more we can do here, it's fixed for Qt 5.15.2.
2020-11-02 11:36:24 +00:00
Allen Winter
8a51c31663 OBS - update for 1.1.0 release 2020-10-26 12:14:46 -04:00
Sergio Martins
a586a7894b cmake: Qt5::GuiPrivate is only needed on Windows 2020-10-26 16:14:07 +00:00
Sergio Martins
31fcbebaff ChangeLog: Add the date of 1.1 release 2020-10-26 15:29:47 +00:00
Sergio Martins
392dac5691 Use Qt::WA_PendingMoveEvent instead of Qt::WA_Moved
We check if the user provided position before putting a floating
window in a default position. Qt::WA_Moved however has the problem
that it's not cleared, so second time you show a window, it will
have it, even if user didn't set geometry.

Use Qt::WA_PendingMoveEvent instead, which was made for tracking
moves made before the first show.
2020-10-23 17:07:14 +01:00
Sergio Martins
29744c01c6 ChangeLog: Added Config::setTabbingAllowedFunc 2020-10-23 10:33:37 +01:00
Sergio Martins
49e488df24 remove roadmap from 1.1 ChangeLog
We only have it for master
2020-10-23 10:29:57 +01:00
Sergio Martins
1a3f00eac8 ChangeLog: Added HDPI improvements 2020-10-23 10:29:00 +01:00
Sérgio Martins
c6ea8d5525 ChangeLog: Remove mention to 1.0.1 release
We're releasing 1.1 asap
2020-10-23 10:23:52 +01:00
Sergio Martins
8f62004f5b cmake: Remove QTQUICK option for 1.1
Leave it in master only.
2020-10-19 21:23:44 +01:00
Sergio Martins
f698b56dad relax test
Seems to happen with 5.15 static. It's benign anyway
2020-10-16 22:02:45 +01:00
Sergio Martins
4ed18fdf1d Introduce Config::setTabbingAllowedFunc(<lambda>)
This gives a lot of power to the user to disallow tabbing two dock
widgets, while still allowing them to be docked side by side. As
this can't be achieved with affinities.

Instead of adding API which might not be enough soon, just allow
the user to pass a lambda and implement his very custom requirement.

Fixes #91
2020-10-16 21:56:33 +01:00
Sergio Martins
6e05f13c77 Added FloatingWindow::dockWidgets() 2020-10-16 21:48:47 +01:00
Sergio Martins
a146cd81b2 Fix mac tests build 2020-10-16 20:52:22 +01:00
Sergio Martins
ac6d845c8d Skip tests on macOS+offscreen if Qt <= 5.15.0
There's a bug in Qt qpa only fixed in 5.15.1
2020-10-16 20:35:04 +01:00
Allen Winter
77f259a435 README.md - contact info 2020-10-15 16:06:26 -04:00
Allen Winter
7ebc3f3533 src/DockWidgetBase.h - fix compile after merge from master 2020-10-15 12:43:29 -04:00
Renato Araujo Oliveira Filho
0ee94b425e Fixed python bindings generation 2020-10-15 12:38:32 -04:00
Allen Winter
e57b46979d buildsystem - fix installation path for Python bindings 2020-10-14 16:27:18 -04:00
Allen Winter
683b67abb0 buildsystem - install libs with symlinks for the major vers 2020-10-14 15:59:53 -04:00
26 changed files with 218 additions and 70 deletions

View File

@@ -33,10 +33,6 @@
# Forces the test harness to be built.
# Default=false
#
# -DKDDockWidgets_QTQUICK == IN DEVELOPMENT. DO NOT USE! ==
# Build for QtQuick instead of QtWidgets
# Default=false
#
# -DKDDockWidgets_PYTHON_BINDINGS=[true|false]
# Build/Generate python bindings. Always false for Debug builds
# Default=false
@@ -73,7 +69,7 @@ endif()
set(${PROJECT_NAME}_VERSION_MAJOR 1)
set(${PROJECT_NAME}_VERSION_MINOR 1)
set(${PROJECT_NAME}_VERSION_PATCH 0)
set(${PROJECT_NAME}_VERSION_PATCH 1)
set(${PROJECT_NAME}_VERSION ${${PROJECT_NAME}_VERSION_MAJOR}.${${PROJECT_NAME}_VERSION_MINOR}.${${PROJECT_NAME}_VERSION_PATCH})
set(${PROJECT_NAME}_SOVERSION "1.1")
@@ -93,8 +89,6 @@ if(${PROJECT_NAME}_DEVELOPER_MODE)
set(${PROJECT_NAME}_TESTS ON)
endif()
#option(${PROJECT_NAME}_QTQUICK "Build for QtQuick instead of QtWidgets" OFF)
find_package(Qt5Widgets 5.9 REQUIRED)
set(CMAKE_AUTOMOC ON)
@@ -120,13 +114,7 @@ macro(set_compiler_flags targetName)
endif()
endmacro()
if(${PROJECT_NAME}_QTQUICK)
find_package(Qt5Quick)
find_package(Qt5QuickControls2)
add_definitions(-DKDDOCKWIDGETS_QTQUICK)
else()
add_definitions(-DKDDOCKWIDGETS_QTWIDGETS)
endif()
add_definitions(-DKDDOCKWIDGETS_QTWIDGETS)
if(${PROJECT_NAME}_STATIC)
set(${PROJECT_NAME}_LIBRARY_MODE "STATIC")

View File

@@ -1,7 +1,8 @@
* v1.2.0 (unreleased)
- QtQuick support
* v1.1.1 (11 December 2020)
- Windows: Fixed a crash when clicking on the close button for floating windows in some situations (#110)
- Don't show dock/undock icon when dockwidget is not dockable (#99)
* v1.1.0 (unreleased)
* v1.1.0 (26 October 2020)
- New drop indicator style type: Segmented Indicators
- Windows: Drop Shadow for floating windows
- Added AutoHide / SideBar support
@@ -12,6 +13,8 @@
- Added Config::Flag_TitleBarHasMinimizeButton
- Added Config::Flag_TitleBarNoFloatButton
- Added Config::Flag_AutoHideSupport
- Added Config::setTabbingAllowedFunc(TabbingAllowedFunc func)
- HDPI improvements, new high-res icons
- Bugfixes:
- Windows: Fixed windows not having proper minimum size.
- Windows: Fixed moving windows across screens with different DPI (#72)
@@ -19,9 +22,7 @@
- Fixed floating window's title not being correct (#74)
- Fixed focus scope not reacting when clicking on current tab (#71)
- Fixed floating window borders not being rendered correctly on HDPI due to rounding errors.
* v1.0.1 (unreleased)
- cmake/Python - don't require pkg-config, only use if available (#68)
- cmake/Python - don't require pkg-config, only use if available (#68)
* v1.0.0 (2 September 2020)
- PySide2 bindings

View File

@@ -170,3 +170,8 @@ to the Qt Project. We can give advanced or standard trainings anywhere
around the globe on Qt as well as C++, OpenGL, 3D and more.
Please visit https://www.kdab.com to meet the people who write code like this.
Stay up-to-date with KDAB product announcements:
* [KDAB Newsletter](https://news.kdab.com)
* [KDAB Blogs](https://www.kdab.com/category/blogs)

View File

@@ -11,7 +11,7 @@ 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}")
message(STATUS "PYTHON INSTALL PREFIX ${${PROJECT_NAME}_PYTHON_BINDINGS_INSTALL_PREFIX}")
if (WIN32)
set(PATH_SEP "\;")
@@ -153,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}/${TARGET_NAME})
endmacro()

View File

@@ -11,7 +11,7 @@ from conans import ConanFile, CMake, tools
class KDDockWidgetsConan(ConanFile):
name = "kddockwidgets"
version = "1.1.0"
version = "1.1.1"
default_user = "kdab"
default_channel = "stable"
license = ("https://raw.githubusercontent.com/KDAB/KDDockWidgets/master/LICENSES/GPL-2.0-only.txt",

View File

@@ -1,3 +1,15 @@
kddockwidgets (1.1.1) release candidate; urgency=high
* 1.1.1 final
-- Allen Winter <allen.winter@kdab.com> Fri, 11 Dec 2020 12:00:00 -0500
kddockwidgets (1.1.0) release candidate; urgency=high
* 1.1.0 final
-- Allen Winter <allen.winter@kdab.com> Mon, 26 Oct 2020 12:00:00 -0500
kddockwidgets (1.0.0) release candidate; urgency=high
* 1.0.0 final

View File

@@ -1,10 +1,10 @@
Format: 1.0
Source: kddockwidgets
Version: 1.0.0
Version: 1.1.1-1
Binary: kddockwidgets
Maintainer: Allen Winter <allen.winter@kdab.com>
Architecture: any
Build-Depends: debhelper (>=9), cdbs, cmake, qt5-default, qtbase5-dev, libqt5x11extras5-dev
Files:
00000000000000000000000000000000 00000 kddockwidgets-1.0.0.tar.gz
00000000000000000000000000000000 00000 kddockwidgets-1.1.1.tar.gz

View File

@@ -1,5 +1,5 @@
Name: kddockwidgets
Version: 1.0.0
Version: 1.1.1
Release: 1
Summary: KDAB's Dock Widget Framework for Qt
Source0: %{name}-%{version}.tar.gz
@@ -88,7 +88,11 @@ cmake . -DCMAKE_INSTALL_PREFIX=/usr -DCMAKE_BUILD_TYPE=Release
%{_libdir}/libkddockwidgets_multisplitter.so
%changelog
* Wed Sep 02 2020 Allen Winter <allen.winter@kdb.com> 1.0.0
* Fri Dec 11 2020 Allen Winter <allen.winter@kdab.com> 1.1.1
1.1.1 final
* Mon Oct 26 2020 Allen Winter <allen.winter@kdab.com> 1.1.0
1.1.0 final
* Wed Sep 02 2020 Allen Winter <allen.winter@kdab.com> 1.0.0
1.0.0 final
* Thu Aug 06 2020 Allen Winter <allen.winter@kdb.com> 0.99.9
* Thu Aug 06 2020 Allen Winter <allen.winter@kdab.com> 0.99.9
1.0.0 release candidate

View File

@@ -74,8 +74,8 @@ create_python_bindings(
${CMAKE_CURRENT_BINARY_DIR}
)
# Make moduled import from build dir works
# Make module import from build dir work
configure_file(${CMAKE_CURRENT_SOURCE_DIR}/__init__.py ${CMAKE_CURRENT_BINARY_DIR}/__init__.py)
# install
install(FILES ${CMAKE_CURRENT_SOURCE_DIR}/__init__.py DESTINATION ${PROJECT_NAME}_PYTHON_BINDINGS_INSTALL_PREFIX}/PyKDDockWidgets)
install(FILES ${CMAKE_CURRENT_SOURCE_DIR}/__init__.py DESTINATION ${${PROJECT_NAME}_PYTHON_BINDINGS_INSTALL_PREFIX}/PyKDDockWidgets)

View File

@@ -11,6 +11,7 @@
<!-- this is used in a public virtual pure function we need to declare it
otherwise shiboken will ignore the function and will fail to create a wrapper -->
<primitive-type name="DropAreaWithCentralFrame"/>
<primitive-type name="SideBar"/>
<!-- Some plublic enum and flags -->
<enum-type name="Location"/>
@@ -19,6 +20,9 @@
<enum-type name="RestoreOption" flags="RestoreOptions"/>
<enum-type name="DefaultSizeMode"/>
<enum-type name="FrameOption" flags="FrameOptions"/>
<enum-type name="DropIndicatorType"/>
<enum-type name="SideBarLocation"/>
<enum-type name="TitleBarButtonType"/>
<!-- our classes
For class we can use two types:
@@ -32,6 +36,7 @@
<!-- this class contains a internal enum, so it should be declared
inside of the object-type -->
<enum-type name="Option" flags="Options" />
<enum-type name="IconPlace" flags="IconPlaces" />
</object-type>
<object-type name="DockWidget" />

View File

@@ -168,19 +168,23 @@ if(CMAKE_COMPILER_IS_GNUCXX OR IS_CLANG_BUILD)
endif()
if(${PROJECT_NAME}_QTQUICK)
target_link_libraries(kddockwidgets PUBLIC Qt5::Widgets Qt5::Quick Qt5::QuickControls2 kddockwidgets_multisplitter PRIVATE Qt5::GuiPrivate)
target_link_libraries(kddockwidgets PUBLIC Qt5::Widgets Qt5::Quick Qt5::QuickControls2 kddockwidgets_multisplitter)
else()
target_link_libraries(kddockwidgets PUBLIC Qt5::Widgets kddockwidgets_multisplitter PRIVATE Qt5::GuiPrivate)
target_link_libraries(kddockwidgets PUBLIC Qt5::Widgets kddockwidgets_multisplitter)
endif()
if (WIN32)
target_link_libraries(kddockwidgets PRIVATE Dwmapi)
target_link_libraries(kddockwidgets PRIVATE Qt5::GuiPrivate Dwmapi)
elseif(NOT APPLE)
find_package(Qt5X11Extras)
target_link_libraries(kddockwidgets PUBLIC Qt5::X11Extras)
endif()
set_target_properties(kddockwidgets PROPERTIES VERSION ${${PROJECT_NAME}_SOVERSION})
set_target_properties(kddockwidgets PROPERTIES
SOVERSION ${${PROJECT_NAME}_SOVERSION}
VERSION ${${PROJECT_NAME}_VERSION}
)
#version libraries on Windows
if(WIN32)
set(postfix ${${PROJECT_NAME}_VERSION_MAJOR})

View File

@@ -47,6 +47,7 @@ public:
QQmlEngine *m_qmlEngine = nullptr;
DockWidgetFactoryFunc m_dockWidgetFactoryFunc = nullptr;
MainWindowFactoryFunc m_mainWindowFactoryFunc = nullptr;
TabbingAllowedFunc m_tabbingAllowedFunc = nullptr;
FrameworkWidgetFactory *m_frameworkWidgetFactory;
Flags m_flags = Flag_Default;
qreal m_draggedWindowOpacity = Q_QNAN;
@@ -153,6 +154,16 @@ qreal Config::draggedWindowOpacity() const
return d->m_draggedWindowOpacity;
}
void Config::setTabbingAllowedFunc(TabbingAllowedFunc func)
{
d->m_tabbingAllowedFunc = func;
}
TabbingAllowedFunc Config::tabbingAllowedFunc() const
{
return d->m_tabbingAllowedFunc;
}
void Config::setQmlEngine(QQmlEngine *qmlEngine)
{
if (d->m_qmlEngine) {

View File

@@ -35,6 +35,14 @@ class FrameworkWidgetFactory;
typedef KDDockWidgets::DockWidgetBase* (*DockWidgetFactoryFunc)(const QString &name);
typedef KDDockWidgets::MainWindowBase* (*MainWindowFactoryFunc)(const QString &name);
/// @brief Function to allow the user more granularity to disallow dock widgets to tab together
/// @param source The dock widgets being dragged
/// @param target The dock widgets within an existing docked tab group
/// @return true if the docking is allowed.
/// @sa setTabbingAllowedFunc
typedef bool (*TabbingAllowedFunc)(const QVector<DockWidgetBase*> &source,
const QVector<DockWidgetBase*> &target);
/**
* @brief Singleton to allow to choose certain behaviours of the framework.
*
@@ -53,29 +61,29 @@ public:
///@brief Flag enum to tune certain behaviours, the defaults are Flag_Default
enum Flag {
Flag_None = 0, ///> No option set
Flag_NativeTitleBar = 1, ///> Enables the Native OS title bar on OSes that support it (Windows 10, macOS), ignored otherwise. This is mutually exclusive with Flag_AeroSnap
Flag_AeroSnapWithClientDecos = 2, ///> Deprecated. This is now default and cannot be turned off. Moving a window on Windows 10 uses native moving, as that works well across screens with different HDPI settings. There's no reason to use manual client/Qt window moving.
Flag_AlwaysTitleBarWhenFloating = 4, ///> Floating windows will have a title bar even if Flag_HideTitleBarWhenTabsVisible is specified. Unneeded if Flag_HideTitleBarWhenTabsVisible isn't specified, as that's the default already.
Flag_HideTitleBarWhenTabsVisible = 8, ///> Hides the title bar if there's tabs visible. The empty space in the tab bar becomes draggable.
Flag_AlwaysShowTabs = 16, ///> Always show tabs, even if there's only one,
Flag_AllowReorderTabs = 32, /// Allows user to re-order tabs by dragging them
Flag_TabsHaveCloseButton = 64, /// Tabs will have a close button. Equivalent to QTabWidget::setTabsClosable(true).
Flag_DoubleClickMaximizes = 128, /// Double clicking the titlebar will maximize a floating window instead of re-docking it
Flag_TitleBarHasMaximizeButton = 256, /// The title bar will have a maximize/restore button when floating. This is mutually-exclusive with the floating button (since many apps behave that way).
Flag_TitleBarIsFocusable = 512, /// You can click the title bar and it will focus the last focused widget in the focus scope. If no previously focused widget then it focuses the user's dock widget guest, which should accept focus or use a focus proxy.
Flag_LazyResize = 1024, /// The dock widgets are resized in a lazy manner. The actual resize only happens when you release the mouse button.
Flag_None = 0, ///< No option set
Flag_NativeTitleBar = 1, ///< Enables the Native OS title bar on OSes that support it (Windows 10, macOS), ignored otherwise. This is mutually exclusive with Flag_AeroSnap
Flag_AeroSnapWithClientDecos = 2, ///< Deprecated. This is now default and cannot be turned off. Moving a window on Windows 10 uses native moving, as that works well across screens with different HDPI settings. There's no reason to use manual client/Qt window moving.
Flag_AlwaysTitleBarWhenFloating = 4, ///< Floating windows will have a title bar even if Flag_HideTitleBarWhenTabsVisible is specified. Unneeded if Flag_HideTitleBarWhenTabsVisible isn't specified, as that's the default already.
Flag_HideTitleBarWhenTabsVisible = 8, ///< Hides the title bar if there's tabs visible. The empty space in the tab bar becomes draggable.
Flag_AlwaysShowTabs = 16, ///< Always show tabs, even if there's only one,
Flag_AllowReorderTabs = 32, ///< Allows user to re-order tabs by dragging them
Flag_TabsHaveCloseButton = 64, ///< Tabs will have a close button. Equivalent to QTabWidget::setTabsClosable(true).
Flag_DoubleClickMaximizes = 128, ///< Double clicking the titlebar will maximize a floating window instead of re-docking it
Flag_TitleBarHasMaximizeButton = 256, ///< The title bar will have a maximize/restore button when floating. This is mutually-exclusive with the floating button (since many apps behave that way).
Flag_TitleBarIsFocusable = 512, ///< You can click the title bar and it will focus the last focused widget in the focus scope. If no previously focused widget then it focuses the user's dock widget guest, which should accept focus or use a focus proxy.
Flag_LazyResize = 1024, ///< The dock widgets are resized in a lazy manner. The actual resize only happens when you release the mouse button.
// These two are internal, for testing purposes across platforms. Use Flag_DontUseUtilityFloatingWindows instead.
Flag_internal_DontUseQtToolWindowsForFloatingWindows = 0x800, ///> FloatingWindows will use Qt::Window instead of Qt::Tool. Internal, use Flag_DontUseUtilityFloatingWindows instead.
Flag_internal_DontUseParentForFloatingWindows = 0x1000, ///> FloatingWindows won't have a parent top-level. Internal, use Flag_DontUseUtilityFloatingWindows instead.
Flag_internal_DontUseQtToolWindowsForFloatingWindows = 0x800, ///< FloatingWindows will use Qt::Window instead of Qt::Tool. Internal, use Flag_DontUseUtilityFloatingWindows instead.
Flag_internal_DontUseParentForFloatingWindows = 0x1000, ///< FloatingWindows won't have a parent top-level. Internal, use Flag_DontUseUtilityFloatingWindows instead.
Flag_DontUseUtilityFloatingWindows = Flag_internal_DontUseQtToolWindowsForFloatingWindows | Flag_internal_DontUseParentForFloatingWindows,
Flag_TitleBarHasMinimizeButton = 0x2000 | Flag_DontUseUtilityFloatingWindows, ///> The title bar will have a minimize button when floating. This implies Flag_DontUseUtilityFloatingWindows too, otherwise they wouldn't appear in the task bar.
Flag_TitleBarNoFloatButton = 0x4000, ///> The TitleBar won't show the float button
Flag_AutoHideSupport = 0x8000 | Flag_TitleBarNoFloatButton, ///> Supports minimizing dock widgets to the side-bar.
///> By default it also turns off the float button, but you can remove Flag_TitleBarNoFloatButton to have both.
Flag_Default = Flag_AeroSnapWithClientDecos ///> The defaults
Flag_TitleBarHasMinimizeButton = 0x2000 | Flag_DontUseUtilityFloatingWindows, ///< The title bar will have a minimize button when floating. This implies Flag_DontUseUtilityFloatingWindows too, otherwise they wouldn't appear in the task bar.
Flag_TitleBarNoFloatButton = 0x4000, ///< The TitleBar won't show the float button
Flag_AutoHideSupport = 0x8000 | Flag_TitleBarNoFloatButton, ///< Supports minimizing dock widgets to the side-bar.
///< By default it also turns off the float button, but you can remove Flag_TitleBarNoFloatButton to have both.
Flag_Default = Flag_AeroSnapWithClientDecos ///< The defaults
};
Q_DECLARE_FLAGS(Flags, Flag)
@@ -150,6 +158,33 @@ public:
///By default it's 1.0, fully opaque
qreal draggedWindowOpacity() const;
/**
* @brief Allows the user to intercept a docking attempt to center (tabbed) and disallow it.
*
* Whenever the user tries to tab two widgets together, the framework will call @p func. If
* it returns true, then tabbing is allowed, otherwise not.
*
* Example:
* @code
* #include <kddockwidgets/Config.h>
* (...)
*
* auto func = [] (const KDDockWidgets::DockWidgetBase::List &source,
* const KDDockWidgets::DockWidgetBase::List &target)
* {
* // disallows dockFoo to be tabbed with dockBar.
* return !(source.contains(dockFoo) && target.contains(dockBar));
* }
* @endcode
* KDDockWidgets::Config::self()->setTabbingAllowedFunc(func);
*/
void setTabbingAllowedFunc(TabbingAllowedFunc func);
///@brief Used internally by the framework. Returns the function which was passed to setTabbingAllowedFunc()
///By default it's nullptr.
///@sa setTabbingAllowedFunc().
TabbingAllowedFunc tabbingAllowedFunc() const;
///@brief Sets the QQmlEngine to use. Applicable only when using QtQuick.
void setQmlEngine(QQmlEngine *);
QQmlEngine* qmlEngine() const;

View File

@@ -146,6 +146,8 @@ DockWidgetBase::DockWidgetBase(const QString &name, Options options)
if (name.isEmpty())
qWarning() << Q_FUNC_INFO << "Name can't be null";
setAttribute(Qt::WA_PendingMoveEvent, false);
}
DockWidgetBase::~DockWidgetBase()
@@ -528,7 +530,7 @@ FloatingWindow *DockWidgetBase::morphIntoFloatingWindow()
if (geo.isNull()) {
geo = geometry();
if (!testAttribute(Qt::WA_Moved)) { // If user already moved it, we don't interfere
if (!testAttribute(Qt::WA_PendingMoveEvent)) { // If user already moved it, we don't interfere
const QPoint center = d->defaultCenterPosForFloating();
if (!center.isNull())
geo.moveCenter(center);

View File

@@ -233,10 +233,11 @@ QIcon DefaultWidgetFactory::iconForButtonType(TitleBarButtonType type, qreal dpr
const bool isFractional = int(dpr) != dpr;
if (isFractional) {
// We don't support 1.5x yet.
// Linux is the only one affected as Windows and macOS use integral factors.
// Problem with Linux is that rendering is off due to a rounding bug only fixed in 5.15.2
// Will enable for fractional later.
// QTBUG-86170
// Mostly affects Linux. Unless you're using Qt::HighDpiScaleFactorRoundingPolicy::PassThrough, in which case it will
// affect other OSes too.
return icon;
}
#else

View File

@@ -134,7 +134,7 @@ public:
#ifdef KDDOCKWIDGETS_QTWIDGETS
///@brief Called internally by the framework to create a title bar button
///@parent the button's parent
///@p parent the button's parent
virtual QAbstractButton* createTitleBarButton(QWidget *parent, TitleBarButtonType) const = 0;
#else
// QtQuick will have some other base class for buttons

View File

@@ -228,6 +228,11 @@ DockWidgetBase *FloatingWindow::singleDockWidget() const
return nullptr;
}
const DockWidgetBase::List FloatingWindow::dockWidgets() const
{
return m_dropArea->dockWidgets();
}
const Frame::List FloatingWindow::frames() const
{
Q_ASSERT(m_dropArea);
@@ -270,6 +275,14 @@ MultiSplitter *FloatingWindow::multiSplitter() const
bool FloatingWindow::isInDragArea(QPoint globalPoint) const
{
#ifdef Q_OS_WIN
// A click near the border will still send a Qt::NonClientMousePressEvent. We shouldn't
// interpret that as a drag, as it's for a native resize.
// Keep track of how we handled the WM_NCHITTEST
if (m_lastHitTest != 0 && m_lastHitTest != HTCAPTION)
return false;
#endif
return dragRect().contains(globalPoint);
}
@@ -387,10 +400,10 @@ void FloatingWindow::updateTitleAndIcon()
m_titleBar->setTitle(title);
m_titleBar->setIcon(icon);
if (KDDockWidgets::usesNativeTitleBar()) {
setWindowTitle(title);
setWindowIcon(icon);
}
// Even without a native title bar it's nice to set the window title/icon, so it shows
// in the taskbar (when minimization is supported), or Alt-Tab (in supporting Window Managers)
setWindowTitle(title);
setWindowIcon(icon);
}
void FloatingWindow::onCloseEvent(QCloseEvent *e)

View File

@@ -49,9 +49,15 @@ public:
std::unique_ptr<WindowBeingDragged> makeWindow() override;
DockWidgetBase *singleDockWidget() const override;
const QVector<DockWidgetBase*> dockWidgets() const;
const Frame::List frames() const;
DropArea *dropArea() const { return m_dropArea; }
#ifdef Q_OS_WIN
void setLastHitTest(int hitTest) {
m_lastHitTest = hitTest;
}
#endif
/**
* @brief Returns the title bar.
*
@@ -148,6 +154,9 @@ private:
bool m_updatingTitleBarVisibility = false;
QMetaObject::Connection m_layoutDestroyedConnection;
QAbstractNativeEventFilter *m_nchittestFilter = nullptr;
#ifdef Q_OS_WIN
int m_lastHitTest = 0;
#endif
};
}

View File

@@ -198,6 +198,12 @@ bool TitleBar::supportsFloatingButton() const
return false;
}
if (DockWidgetBase *dw = singleDockWidget()) {
// Don't show the dock/undock button if the window is not dockable
if (dw->options() & DockWidgetBase::Option_NotDockable)
return false;
}
// If we have a floating window with nested dock widgets we can't re-attach, because we don't
// know where to
return !m_floatingWindow || m_floatingWindow->hasSingleFrame();

View File

@@ -27,6 +27,8 @@ class QHBoxLayout;
class QLabel;
QT_END_NAMESPACE
class TestCommon;
namespace KDDockWidgets {
class DockWidgetBase;
@@ -127,6 +129,7 @@ protected:
private:
friend class TestDocks;
friend class ::TestCommon;
void init();

View File

@@ -262,6 +262,7 @@ bool WidgetResizeHandler::handleWindowsNativeEvent(FloatingWindow *w, const QByt
}
}
w->setLastHitTest(*result);
return *result != 0;
} else if (msg->message == WM_NCLBUTTONDBLCLK) {
if ((Config::self().flags() & Config::Flag_DoubleClickMaximizes)) {

View File

@@ -99,8 +99,14 @@ void ClassicIndicators::updateIndicatorsVisibility(bool visible)
// Only allow to dock to center if the affinities match
auto tabbingAllowedFunc = Config::self().tabbingAllowedFunc();
m_tabIndicatorVisible = m_innerIndicatorsVisible && m_windowBeingDragged &&
DockRegistry::self()->affinitiesMatch(m_hoveredFrame->affinities(), m_windowBeingDragged->affinities());
if (m_tabIndicatorVisible && tabbingAllowedFunc) {
const DockWidgetBase::List source = m_windowBeingDragged->floatingWindow()->dockWidgets();
const DockWidgetBase::List target = m_hoveredFrame->dockWidgets();
m_tabIndicatorVisible = tabbingAllowedFunc(source, target);
}
Q_EMIT innerIndicatorsVisibleChanged();
Q_EMIT outterIndicatorsVisibleChanged();

View File

@@ -98,7 +98,11 @@ target_include_directories(kddockwidgets_multisplitter
${CMAKE_CURRENT_SOURCE_DIR}
)
set_target_properties(kddockwidgets_multisplitter PROPERTIES VERSION ${${PROJECT_NAME}_SOVERSION})
set_target_properties(kddockwidgets_multisplitter PROPERTIES
SOVERSION ${${PROJECT_NAME}_SOVERSION}
VERSION ${${PROJECT_NAME}_VERSION}
)
#version libraries on Windows
if(WIN32)
set(postfix ${${PROJECT_NAME}_VERSION_MAJOR})

View File

@@ -27,6 +27,8 @@
#ifdef KDDOCKWIDGETS_QTQUICK
# include <QQmlEngine>
# include <QQuickStyle>
#else
# include "DockWidget.h"
#endif
using namespace KDDockWidgets;
@@ -67,6 +69,7 @@ private Q_SLOTS:
void tst_ghostSeparator();
void tst_detachFromMainWindow();
void tst_detachPos();
void tst_nonDockable();
};
void TestCommon::tst_simple1()
@@ -221,6 +224,32 @@ void TestCommon::tst_detachPos()
delete dock1->window();
}
void TestCommon::tst_nonDockable()
{
{ // First test without Option_NotDockable
auto dock = new DockWidgetType("1");
dock->show();
TitleBar *tb = dock->titleBar();
QVERIFY(tb->isVisible());
QVERIFY(tb->isFloatButtonVisible());
delete dock->window();
}
{
// Test that when using Option_NotDockable we don't get a dock/undock icon
auto dock = new DockWidgetType("1", DockWidgetBase::Option_NotDockable);
dock->show();
TitleBar *tb = dock->titleBar();
QVERIFY(tb->isVisible());
QVERIFY(!tb->isFloatButtonVisible());
delete dock->window();
}
}
int main(int argc, char *argv[])
{
if (!qpaPassedAsArgument(argc, argv)) {
@@ -229,10 +258,11 @@ int main(int argc, char *argv[])
}
QApplication app(argc, argv);
TestCommon test;
if (shouldSkipTests())
return 0;
TestCommon test;
return QTest::qExec(&test, argc, argv);
}
#include "tst_common.moc"

View File

@@ -5370,16 +5370,10 @@ void TestDocks::tst_floatingAction()
QCOMPARE(spy1.count(), 1);
#if QT_VERSION >= QT_VERSION_CHECK(5, 15, 0)
QCOMPARE(spy2.count(), 1);
QCOMPARE(spy21.count(), 1);
#else
// On earlier Qt versions this is flaky, but technically correct.
// Windows can get hidden while being reparented and floating changes momentarily.
// This works well on 5.15 though.
QVERIFY(spy2.count() == 1 || spy2.count() == 3);
QVERIFY(spy21.count() == 1 || spy21.count() == 3);
#endif
QCOMPARE(spy11.count(), 1);
QVERIFY(!dock1->isFloating());
@@ -6047,6 +6041,7 @@ void TestDocks::tst_honourUserGeometry()
EnsureTopLevelsDeleted e;
auto m1 = createMainWindow(QSize(1000, 1000), MainWindowOption_None);
auto dw1 = new DockWidget(QStringLiteral("1"));
QVERIFY(!dw1->testAttribute(Qt::WA_PendingMoveEvent));
const QPoint pt(10, 10);
dw1->move(pt);
@@ -6227,8 +6222,10 @@ int main(int argc, char *argv[])
}
QApplication app(argc, argv);
KDDockWidgets::TestDocks test;
if (shouldSkipTests())
return 0;
KDDockWidgets::TestDocks test;
return QTest::qExec(&test, argc, argv);
}

View File

@@ -51,6 +51,17 @@ struct DockDescriptor {
KDDockWidgets::AddingOption option;
};
inline bool shouldSkipTests()
{
// Skip mac+offscreen on Qt <= 5.15.0 due to a QPA crash, fixed in 5.15.1
#if defined(Q_OS_MACOS) && QT_VERSION <= QT_VERSION_CHECK(5, 15, 0)
if (qApp->platformName() == QLatin1String("offscreen"))
return true;
#endif
return false;
}
struct EnsureTopLevelsDeleted
{
EnsureTopLevelsDeleted()