diff --git a/Changelog b/Changelog index 3e261f52..984ee642 100644 --- a/Changelog +++ b/Changelog @@ -4,6 +4,7 @@ * v1.1 (, 2020) Features: - Allow tab re-ordering with mouse, via KDDockWidgets::Config::Flag_AllowReorderTabs. - - Add support for lazy resize. Resize is only done when mouse is released. + - Allow tabs to have a close button, via KDDockWidgets::Config::Flag_TabsHaveCloseButton. + - Add support for lazy resize, via KDDockWidgets::Config::Flag_LazyResize. Resize is only done when mouse is released. Fixes: - Fix dock widgets not filling their complete available space diff --git a/examples/dockwidgets/main.cpp b/examples/dockwidgets/main.cpp index af3a668e..eb948943 100644 --- a/examples/dockwidgets/main.cpp +++ b/examples/dockwidgets/main.cpp @@ -64,6 +64,9 @@ int main(int argc, char **argv) QCommandLineOption incompatibleMainWindows("i", QCoreApplication::translate("main", "Only usable with -m. Make the two main windows incompatible with each other. (Illustrates (MainWindowBase::setAffinityName))")); parser.addOption(incompatibleMainWindows); + QCommandLineOption tabsHaveCloseButton("c", QCoreApplication::translate("main", "Tabs have a close button")); + parser.addOption(tabsHaveCloseButton); + #if defined(DOCKS_DEVELOPER_MODE) QCommandLineOption noCentralFrame("c", QCoreApplication::translate("main", "No central frame")); parser.addOption(noCentralFrame); @@ -94,6 +97,9 @@ int main(int argc, char **argv) if (parser.isSet(lazyResizeOption)) flags |= KDDockWidgets::Config::Flag_LazyResize; + if (parser.isSet(tabsHaveCloseButton)) + flags |= KDDockWidgets::Config::Flag_TabsHaveCloseButton; + if (parser.isSet(incompatibleMainWindows) && !parser.isSet(multipleMainWindows)) { qWarning() << "Error: Argument -i requires -m"; return 1; diff --git a/src/Config.h b/src/Config.h index 83501bcf..6db59c29 100644 --- a/src/Config.h +++ b/src/Config.h @@ -67,6 +67,7 @@ public: 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_LazyResize = 32, /// The dock widgets are resized in a lazy manner. The actual resize only happens when you release the mouse button. + Flag_TabsHaveCloseButton = 64, /// Tabs will have a close button. Equivalent to QTabWidget::setTabsClosable(true). Flag_Default = Flag_AeroSnapWithClientDecos ///> The defaults }; Q_DECLARE_FLAGS(Flags, Flag) diff --git a/src/private/widgets/TabWidgetWidget.cpp b/src/private/widgets/TabWidgetWidget.cpp index 9a3fde1b..a0d4d69d 100644 --- a/src/private/widgets/TabWidgetWidget.cpp +++ b/src/private/widgets/TabWidgetWidget.cpp @@ -38,6 +38,7 @@ TabWidgetWidget::TabWidgetWidget(Frame *parent) , m_tabBar(Config::self().frameworkWidgetFactory()->createTabBar(this)) { setTabBar(static_cast(m_tabBar->asWidget())); + setTabsClosable(Config::self().flags() & Config::Flag_TabsHaveCloseButton); // 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) {