mirror of
https://github.com/githubuser0xFFFF/Qt-Advanced-Docking-System.git
synced 2024-12-24 07:21:32 +08:00
Added setFloating function to CDockWidget to support making a dock widget floating with from code
This commit is contained in:
parent
aee9fb1c95
commit
f497944d2c
@ -229,9 +229,14 @@ void MainWindowPrivate::createContent()
|
||||
DockManager->addDockWidget(ads::CenterDockWidgetArea, createLongTextLabelDockWidget(ViewMenu), BottomDockArea);
|
||||
|
||||
// Test creation of floating dock widgets
|
||||
auto FloatingWidget = DockManager->addDockWidgetFloating(createFileSystemTreeDockWidget(ViewMenu));
|
||||
DockWidget = createFileSystemTreeDockWidget(ViewMenu);
|
||||
auto FloatingWidget = DockManager->addDockWidgetFloating(DockWidget);
|
||||
FloatingWidget->move(QPoint(0,0));
|
||||
DockManager->addDockWidgetFloating(createLongTextLabelDockWidget(ViewMenu));
|
||||
FloatingWidget = DockManager->addDockWidgetFloating(createLongTextLabelDockWidget(ViewMenu));
|
||||
|
||||
auto Action = ui.menuView->addAction(QString("Set %1 floating").arg(DockWidget->windowTitle()));
|
||||
DockWidget->connect(Action, SIGNAL(triggered()), SLOT(setFloating()));
|
||||
|
||||
|
||||
for (auto DockWidget : DockManager->dockWidgetsMap())
|
||||
{
|
||||
|
@ -726,6 +726,17 @@ QSize CDockWidget::minimumSizeHint() const
|
||||
}
|
||||
|
||||
|
||||
//============================================================================
|
||||
void CDockWidget::setFloating()
|
||||
{
|
||||
if (isClosed())
|
||||
{
|
||||
return;
|
||||
}
|
||||
d->TabWidget->detachDockWidget();
|
||||
}
|
||||
|
||||
|
||||
} // namespace ads
|
||||
|
||||
//---------------------------------------------------------------------------
|
||||
|
@ -414,6 +414,11 @@ public slots:
|
||||
*/
|
||||
void toggleView(bool Open = true);
|
||||
|
||||
/**
|
||||
* This function will make a docked widget floating
|
||||
*/
|
||||
void setFloating();
|
||||
|
||||
signals:
|
||||
/**
|
||||
* This signal is emitted if the dock widget is opened or closed
|
||||
|
@ -371,7 +371,7 @@ void CDockWidgetTab::contextMenuEvent(QContextMenuEvent* ev)
|
||||
|
||||
d->DragStartMousePosition = ev->pos();
|
||||
QMenu Menu(this);
|
||||
auto Action = Menu.addAction(tr("Detach"), this, SLOT(onDetachActionTriggered()));
|
||||
auto Action = Menu.addAction(tr("Detach"), this, SLOT(detachDockWidget()));
|
||||
Action->setEnabled(d->DockWidget->features().testFlag(CDockWidget::DockWidgetFloatable));
|
||||
Menu.addSeparator();
|
||||
Action = Menu.addAction(tr("Close"), this, SIGNAL(closeRequested()));
|
||||
@ -526,7 +526,7 @@ bool CDockWidgetTab::isClosable() const
|
||||
|
||||
|
||||
//===========================================================================
|
||||
void CDockWidgetTab::onDetachActionTriggered()
|
||||
void CDockWidgetTab::detachDockWidget()
|
||||
{
|
||||
if (!d->DockWidget->features().testFlag(CDockWidget::DockWidgetFloatable))
|
||||
{
|
||||
|
@ -57,7 +57,7 @@ private:
|
||||
void onDockWidgetFeaturesChanged();
|
||||
|
||||
private slots:
|
||||
void onDetachActionTriggered();
|
||||
void detachDockWidget();
|
||||
|
||||
protected:
|
||||
virtual void mousePressEvent(QMouseEvent* ev) override;
|
||||
|
Loading…
Reference in New Issue
Block a user