From 244651902423c54abd78ca9d4c9db145337367fe Mon Sep 17 00:00:00 2001 From: Albert Astals Cid Date: Tue, 3 May 2022 09:41:30 +0200 Subject: [PATCH 1/2] SideBar_p.h: Fix includes to make it usable from external projects --- src/private/SideBar_p.h | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/private/SideBar_p.h b/src/private/SideBar_p.h index d6336a32..88e27585 100644 --- a/src/private/SideBar_p.h +++ b/src/private/SideBar_p.h @@ -14,8 +14,8 @@ #include "kddockwidgets/docks_export.h" -#include "KDDockWidgets.h" -#include "QWidgetAdapter.h" +#include "kddockwidgets/KDDockWidgets.h" +#include "kddockwidgets/QWidgetAdapter.h" namespace KDDockWidgets { From a743eafca1ae75e53794cb71162612294507b17a Mon Sep 17 00:00:00 2001 From: Sergio Martins Date: Thu, 5 May 2022 10:39:52 +0100 Subject: [PATCH 2/2] Added DockWidgetBase::currentTabIndex() --- Changelog | 1 + src/DockWidgetBase.cpp | 8 ++++++++ src/DockWidgetBase.h | 10 ++++++++-- 3 files changed, 17 insertions(+), 2 deletions(-) diff --git a/Changelog b/Changelog index 6c63fad9..83d432c9 100644 --- a/Changelog +++ b/Changelog @@ -9,6 +9,7 @@ - Fixed MainWindow not propagating close events to docked widgets - X11: Improved detecting which window is under the cursor, by using native X11 API - X11: Fixed dragging a maximized floating window. Its size is now restored to normal size when the drag starts. + - Added DockWidgetBase::currentTabIndex() * v1.5.0 (24 November 2021) - Install the Python bindings to "site-packages" diff --git a/src/DockWidgetBase.cpp b/src/DockWidgetBase.cpp index 357dd606..547db71c 100644 --- a/src/DockWidgetBase.cpp +++ b/src/DockWidgetBase.cpp @@ -328,6 +328,14 @@ int DockWidgetBase::tabIndex() const return 0; } +int DockWidgetBase::currentTabIndex() const +{ + if (Frame *frame = d->frame()) + return frame->currentTabIndex(); + + return 0; +} + void DockWidgetBase::setIcon(const QIcon &icon, IconPlaces places) { if (places & IconPlace::TitleBar) diff --git a/src/DockWidgetBase.h b/src/DockWidgetBase.h index 8ba4bef9..79a376d7 100644 --- a/src/DockWidgetBase.h +++ b/src/DockWidgetBase.h @@ -266,12 +266,18 @@ public: */ Q_INVOKABLE void setAsCurrentTab(); - /** - * @brief Returns which tab index this dock widget occupies in the tab widget it's contained in + * @brief Returns the tab index this dock widget occupies + * Note that dock widgets are almost always tabbed, even if you don't see the tab bar. + * A single floating dock widget is still tabbed on a tab widget with a single tab. */ int tabIndex() const; + /** + * @brief Returns the index of the current tab of the tab group this dock widget is in. + */ + int currentTabIndex() const; + /** * @brief Sets an icon to show on title bars and tab bars. * @param places Specifies where the icon will be shown (TitleBar, TabBar, ToggleAction, or All)