mirror of
https://github.com/githubuser0xFFFF/Qt-Advanced-Docking-System.git
synced 2024-12-25 07:31:33 +08:00
Added DockWidget functions setAsCurrentTab, raise, isCurrentTab, isTabbed
This commit is contained in:
parent
a668fe2f73
commit
8aae6bf70b
@ -351,8 +351,6 @@ void MainWindowPrivate::createContent()
|
|||||||
QMenu* ViewMenu = ui.menuView;
|
QMenu* ViewMenu = ui.menuView;
|
||||||
auto DockWidget = createCalendarDockWidget(ViewMenu);
|
auto DockWidget = createCalendarDockWidget(ViewMenu);
|
||||||
DockWidget->setFeature(ads::CDockWidget::DockWidgetClosable, false);
|
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);
|
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):
|
// 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
|
// We create a calendar widget and clear all flags to prevent the dock area
|
||||||
// from closing
|
// from closing
|
||||||
DockWidget = createCalendarDockWidget(ViewMenu);
|
DockWidget = createCalendarDockWidget(ViewMenu);
|
||||||
DockWidget->setFeature(ads::CDockWidget::DockWidgetMovable, false);
|
|
||||||
DockWidget->setFeature(ads::CDockWidget::DockWidgetFloatable, false);
|
|
||||||
DockWidget->setTabToolTip(QString("Tab ToolTip\nHodie est dies magna"));
|
DockWidget->setTabToolTip(QString("Tab ToolTip\nHodie est dies magna"));
|
||||||
auto DockArea = DockManager->addDockWidget(ads::CenterDockWidgetArea, DockWidget, TopDockArea);
|
auto DockArea = DockManager->addDockWidget(ads::CenterDockWidgetArea, DockWidget, TopDockArea);
|
||||||
|
|
||||||
@ -397,6 +393,7 @@ void MainWindowPrivate::createContent()
|
|||||||
CustomButton->setToolTip(QObject::tr("Create Editor"));
|
CustomButton->setToolTip(QObject::tr("Create Editor"));
|
||||||
CustomButton->setIcon(svgIcon(":/adsdemo/images/plus.svg"));
|
CustomButton->setIcon(svgIcon(":/adsdemo/images/plus.svg"));
|
||||||
CustomButton->setAutoRaise(true);
|
CustomButton->setAutoRaise(true);
|
||||||
|
|
||||||
auto TitleBar = DockArea->titleBar();
|
auto TitleBar = DockArea->titleBar();
|
||||||
int Index = TitleBar->indexOf(TitleBar->tabBar());
|
int Index = TitleBar->indexOf(TitleBar->tabBar());
|
||||||
TitleBar->insertWidget(Index + 1, CustomButton);
|
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), RighDockArea);
|
||||||
DockManager->addDockWidget(ads::CenterDockWidgetArea, createLongTextLabelDockWidget(ViewMenu), BottomDockArea);
|
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()));
|
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
|
#ifdef Q_OS_WIN
|
||||||
if (!DockManager->configFlags().testFlag(ads::CDockManager::OpaqueUndocking))
|
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->setToolTip("Creates floating dynamic dockable editor windows that are deleted on close");
|
||||||
a->setIcon(svgIcon(":/adsdemo/images/note_add.svg"));
|
a->setIcon(svgIcon(":/adsdemo/images/note_add.svg"));
|
||||||
_this->connect(a, SIGNAL(triggered()), SLOT(createEditor()));
|
_this->connect(a, SIGNAL(triggered()), SLOT(createEditor()));
|
||||||
|
ui.menuTests->addAction(a);
|
||||||
|
|
||||||
a = ui.toolBar->addAction("Create Table");
|
a = ui.toolBar->addAction("Create Table");
|
||||||
a->setToolTip("Creates floating dynamic dockable table with millions of entries");
|
a->setToolTip("Creates floating dynamic dockable table with millions of entries");
|
||||||
a->setIcon(svgIcon(":/adsdemo/images/grid_on.svg"));
|
a->setIcon(svgIcon(":/adsdemo/images/grid_on.svg"));
|
||||||
_this->connect(a, SIGNAL(triggered()), SLOT(createTable()));
|
_this->connect(a, SIGNAL(triggered()), SLOT(createTable()));
|
||||||
|
ui.menuTests->addAction(a);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@ -45,8 +45,14 @@
|
|||||||
<string>About</string>
|
<string>About</string>
|
||||||
</property>
|
</property>
|
||||||
</widget>
|
</widget>
|
||||||
|
<widget class="QMenu" name="menuTests">
|
||||||
|
<property name="title">
|
||||||
|
<string>Tests</string>
|
||||||
|
</property>
|
||||||
|
</widget>
|
||||||
<addaction name="menuFile"/>
|
<addaction name="menuFile"/>
|
||||||
<addaction name="menuView"/>
|
<addaction name="menuView"/>
|
||||||
|
<addaction name="menuTests"/>
|
||||||
<addaction name="menuAbout"/>
|
<addaction name="menuAbout"/>
|
||||||
</widget>
|
</widget>
|
||||||
<widget class="QToolBar" name="toolBar">
|
<widget class="QToolBar" name="toolBar">
|
||||||
|
@ -55,8 +55,8 @@ class CDockingStateReader;
|
|||||||
* Container that manages a number of dock areas with single dock widgets
|
* Container that manages a number of dock areas with single dock widgets
|
||||||
* or tabyfied dock widgets in each area.
|
* or tabyfied dock widgets in each area.
|
||||||
* Each window that support docking has a DockContainerWidget. That means
|
* Each window that support docking has a DockContainerWidget. That means
|
||||||
* the main application window and all floating windows are ore contain
|
* the main application window and all floating windows contain a
|
||||||
* an DockContainerWidget.
|
* DockContainerWidget instance.
|
||||||
*/
|
*/
|
||||||
class ADS_EXPORT CDockContainerWidget : public QFrame
|
class ADS_EXPORT CDockContainerWidget : public QFrame
|
||||||
{
|
{
|
||||||
|
@ -44,6 +44,7 @@
|
|||||||
#include <QDebug>
|
#include <QDebug>
|
||||||
#include <QToolBar>
|
#include <QToolBar>
|
||||||
#include <QXmlStreamWriter>
|
#include <QXmlStreamWriter>
|
||||||
|
#include <QWindow>
|
||||||
|
|
||||||
#include <QGuiApplication>
|
#include <QGuiApplication>
|
||||||
#include <QScreen>
|
#include <QScreen>
|
||||||
@ -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
|
} // namespace ads
|
||||||
|
|
||||||
//---------------------------------------------------------------------------
|
//---------------------------------------------------------------------------
|
||||||
|
@ -455,6 +455,20 @@ public:
|
|||||||
*/
|
*/
|
||||||
bool isFullScreen() const;
|
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 -----------------------------------------------
|
public: // reimplements QFrame -----------------------------------------------
|
||||||
/**
|
/**
|
||||||
* Emits titleChanged signal if title change event occurs
|
* Emits titleChanged signal if title change event occurs
|
||||||
@ -468,6 +482,23 @@ public slots:
|
|||||||
*/
|
*/
|
||||||
void toggleView(bool Open = true);
|
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
|
* This function will make a docked widget floating
|
||||||
*/
|
*/
|
||||||
|
Loading…
Reference in New Issue
Block a user