mirror of
https://github.com/githubuser0xFFFF/Qt-Advanced-Docking-System.git
synced 2024-12-24 23:31:32 +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;
|
||||
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);
|
||||
}
|
||||
|
||||
|
||||
|
@ -45,8 +45,14 @@
|
||||
<string>About</string>
|
||||
</property>
|
||||
</widget>
|
||||
<widget class="QMenu" name="menuTests">
|
||||
<property name="title">
|
||||
<string>Tests</string>
|
||||
</property>
|
||||
</widget>
|
||||
<addaction name="menuFile"/>
|
||||
<addaction name="menuView"/>
|
||||
<addaction name="menuTests"/>
|
||||
<addaction name="menuAbout"/>
|
||||
</widget>
|
||||
<widget class="QToolBar" name="toolBar">
|
||||
|
@ -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
|
||||
{
|
||||
|
@ -44,6 +44,7 @@
|
||||
#include <QDebug>
|
||||
#include <QToolBar>
|
||||
#include <QXmlStreamWriter>
|
||||
#include <QWindow>
|
||||
|
||||
#include <QGuiApplication>
|
||||
#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
|
||||
|
||||
//---------------------------------------------------------------------------
|
||||
|
@ -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
|
||||
*/
|
||||
|
Loading…
Reference in New Issue
Block a user