diff --git a/demo/MainWindow.cpp b/demo/MainWindow.cpp
index 6769eab..b202b94 100644
--- a/demo/MainWindow.cpp
+++ b/demo/MainWindow.cpp
@@ -351,8 +351,6 @@ void MainWindowPrivate::createContent()
QMenu* ViewMenu = ui.menuView;
auto DockWidget = createCalendarDockWidget(ViewMenu);
DockWidget->setFeature(ads::CDockWidget::DockWidgetClosable, false);
- DockWidget->setFeature(ads::CDockWidget::DockWidgetMovable, false);
- DockWidget->setFeature(ads::CDockWidget::DockWidgetFloatable, false);
auto SpecialDockArea = DockManager->addDockWidget(ads::LeftDockWidgetArea, DockWidget);
// For this Special Dock Area we want to avoid dropping on the center of it (i.e. we don't want this widget to be ever tabbified):
@@ -386,8 +384,6 @@ void MainWindowPrivate::createContent()
// We create a calendar widget and clear all flags to prevent the dock area
// from closing
DockWidget = createCalendarDockWidget(ViewMenu);
- DockWidget->setFeature(ads::CDockWidget::DockWidgetMovable, false);
- DockWidget->setFeature(ads::CDockWidget::DockWidgetFloatable, false);
DockWidget->setTabToolTip(QString("Tab ToolTip\nHodie est dies magna"));
auto DockArea = DockManager->addDockWidget(ads::CenterDockWidgetArea, DockWidget, TopDockArea);
@@ -397,6 +393,7 @@ void MainWindowPrivate::createContent()
CustomButton->setToolTip(QObject::tr("Create Editor"));
CustomButton->setIcon(svgIcon(":/adsdemo/images/plus.svg"));
CustomButton->setAutoRaise(true);
+
auto TitleBar = DockArea->titleBar();
int Index = TitleBar->indexOf(TitleBar->tabBar());
TitleBar->insertWidget(Index + 1, CustomButton);
@@ -415,8 +412,12 @@ void MainWindowPrivate::createContent()
DockManager->addDockWidget(ads::CenterDockWidgetArea, createLongTextLabelDockWidget(ViewMenu), RighDockArea);
DockManager->addDockWidget(ads::CenterDockWidgetArea, createLongTextLabelDockWidget(ViewMenu), BottomDockArea);
- auto Action = ui.menuView->addAction(QString("Set %1 floating").arg(DockWidget->windowTitle()));
+ auto Action = ui.menuTests->addAction(QString("Set %1 Floating").arg(DockWidget->windowTitle()));
DockWidget->connect(Action, SIGNAL(triggered()), SLOT(setFloating()));
+ Action = ui.menuTests->addAction(QString("Set %1 As Current Tab").arg(DockWidget->windowTitle()));
+ DockWidget->connect(Action, SIGNAL(triggered()), SLOT(setAsCurrentTab()));
+ Action = ui.menuTests->addAction(QString("Raise %1").arg(DockWidget->windowTitle()));
+ DockWidget->connect(Action, SIGNAL(triggered()), SLOT(raise()));
#ifdef Q_OS_WIN
if (!DockManager->configFlags().testFlag(ads::CDockManager::OpaqueUndocking))
@@ -458,11 +459,13 @@ void MainWindowPrivate::createActions()
a->setToolTip("Creates floating dynamic dockable editor windows that are deleted on close");
a->setIcon(svgIcon(":/adsdemo/images/note_add.svg"));
_this->connect(a, SIGNAL(triggered()), SLOT(createEditor()));
+ ui.menuTests->addAction(a);
a = ui.toolBar->addAction("Create Table");
a->setToolTip("Creates floating dynamic dockable table with millions of entries");
a->setIcon(svgIcon(":/adsdemo/images/grid_on.svg"));
_this->connect(a, SIGNAL(triggered()), SLOT(createTable()));
+ ui.menuTests->addAction(a);
}
diff --git a/demo/mainwindow.ui b/demo/mainwindow.ui
index 3f2c89c..8f313e8 100644
--- a/demo/mainwindow.ui
+++ b/demo/mainwindow.ui
@@ -45,8 +45,14 @@
About
+
+
diff --git a/src/DockContainerWidget.h b/src/DockContainerWidget.h
index 84df642..b23e017 100644
--- a/src/DockContainerWidget.h
+++ b/src/DockContainerWidget.h
@@ -55,8 +55,8 @@ class CDockingStateReader;
* Container that manages a number of dock areas with single dock widgets
* or tabyfied dock widgets in each area.
* Each window that support docking has a DockContainerWidget. That means
- * the main application window and all floating windows are ore contain
- * an DockContainerWidget.
+ * the main application window and all floating windows contain a
+ * DockContainerWidget instance.
*/
class ADS_EXPORT CDockContainerWidget : public QFrame
{
diff --git a/src/DockWidget.cpp b/src/DockWidget.cpp
index 05f2850..85981e3 100644
--- a/src/DockWidget.cpp
+++ b/src/DockWidget.cpp
@@ -44,6 +44,7 @@
#include
#include
#include
+#include
#include
#include
@@ -918,6 +919,49 @@ bool CDockWidget::isFullScreen() const
}
+//============================================================================
+void CDockWidget::setAsCurrentTab()
+{
+ if (d->DockArea && !isClosed())
+ {
+ d->DockArea->setCurrentDockWidget(this);
+ }
+}
+
+
+//============================================================================
+bool CDockWidget::isTabbed() const
+{
+ return d->DockArea && (d->DockArea->openDockWidgetsCount() > 1);
+}
+
+
+
+//============================================================================
+bool CDockWidget::isCurrentTab() const
+{
+ return d->DockArea && (d->DockArea->currentDockWidget() == this);
+}
+
+
+//============================================================================
+void CDockWidget::raise()
+{
+ if (isClosed())
+ {
+ return;
+ }
+
+ setAsCurrentTab();
+ if (isInFloatingContainer())
+ {
+ auto FloatingWindow = window();
+ FloatingWindow->raise();
+ FloatingWindow->activateWindow();
+ }
+}
+
+
} // namespace ads
//---------------------------------------------------------------------------
diff --git a/src/DockWidget.h b/src/DockWidget.h
index 61af12e..7985ae8 100644
--- a/src/DockWidget.h
+++ b/src/DockWidget.h
@@ -455,6 +455,20 @@ public:
*/
bool isFullScreen() const;
+ /**
+ * Returns true if this dock widget is in a dock area, that contains at
+ * least 2 opened dock widgets
+ */
+ bool isTabbed() const;
+
+ /**
+ * Returns true if this dock widget is the current one in the dock
+ * area widget that contains it.
+ * If the dock widget is the only opened dock widget in a dock area,
+ * the true is returned
+ */
+ bool isCurrentTab() const;
+
public: // reimplements QFrame -----------------------------------------------
/**
* Emits titleChanged signal if title change event occurs
@@ -468,6 +482,23 @@ public slots:
*/
void toggleView(bool Open = true);
+ /**
+ * Makes this dock widget the current tab in its dock area.
+ * The function only has an effect, if the dock widget is open. A call
+ * to this function will not toggle the view, so if it is closed,
+ * nothing will happen
+ */
+ void setAsCurrentTab();
+
+ /**
+ * Brings the dock widget to the front
+ * This means:
+ * - If the dock widget is tabbed with other dock widgets but its tab is not current, it's made current.
+ * - If the dock widget is floating, QWindow::raise() is called.
+ * This only applies if the dock widget is already open. If closed, does nothing.
+ */
+ void raise();
+
/**
* This function will make a docked widget floating
*/