diff --git a/Changelog b/Changelog index 0de0801a..fe335b8e 100644 --- a/Changelog +++ b/Changelog @@ -12,6 +12,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) 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 {