Compare commits

..

15 Commits

Author SHA1 Message Date
luzpaz
a16d17a8bf Fix various typos (#692)
* Fix various typos
Found via `codespell -q 3 -L te,ridiculus,varius`

* Add another typo fix
2025-01-15 09:00:47 +01:00
Uwe Kindler
faf24cd531 Implemented issue #694 - added auto hide configuration flag AutoHideCloseOnOutsideMouseClick 2025-01-15 08:37:43 +01:00
Uwe Kindler
979d76aa47 Imporved user guide - added documentation for some undocumented flags. 2024-12-20 11:09:11 +01:00
Uwe Kindler
0a55bcd586 Updated README.md to use the new factory function CDockManager::createDockWidget() 2024-12-20 10:35:22 +01:00
Uwe Kindler
f41a6f06fe Merge branch 'master' of https://github.com/githubuser0xFFFF/Qt-Advanced-Docking-System 2024-12-20 10:27:35 +01:00
Uwe Kindler
349d584228 Adjusted MyDockAreaTitleBar source code style 2024-12-20 10:26:59 +01:00
Uwe Kindler
fcad7763ff Add factory method to Dock manager as an alternative method to create DockWidget, supporting custom factory 2024-12-20 10:21:57 +01:00
Uwe Kindler
1bec4234c3 Added support for componentsFactory per dock manager 2024-12-20 10:12:46 +01:00
Nolan Kramer
0be5ba8cf6 Fix issue with windeployqt (#683)
* Fix issue with windeployqt

* Rename library to requested format
2024-12-13 21:57:00 +01:00
Uwe Kindler
7245dced84 Added new config flag DoubleClickUndocksWidget to configure if double clicking a DockWidget tab or titlebar undocks the widget 2024-12-12 15:38:29 +01:00
Uwe Kindler
e2f611ea9a CDockAreaTitleBar::resizeEvent function to fix issue #656 2024-12-12 14:53:24 +01:00
Ivan Ugryumov
1f21eb0200 Improved tab bar scrolling (#678)
* Improved tab bar scrolling

* Fix: tab bar scroll for mouse
2024-12-12 13:13:01 +01:00
Federico Fuga
f2378636e2 Add ability to customize the DockArea Title Bar and DockWidget Tab context menu 2024-11-20 15:38:39 +01:00
Federico Fuga
509b2356d1 Fix missing declarations 2024-11-20 15:38:21 +01:00
Uwe Kindler
30b802bd10 Fixed Qt5 build issues 2024-11-20 15:31:31 +01:00
35 changed files with 473 additions and 111 deletions

View File

@@ -462,7 +462,7 @@ MainWindow::MainWindow(QWidget *parent) :
// Create the dock manager after the ui is setup. Because the
// parent parameter is a QMainWindow the dock manager registers
// itself as the central widget as such the ui must be set up first.
m_DockManager = new ads::CDockManager(this);
DockManager = new ads::CDockManager(this);
// Create example content label - this can be any application specific
// widget
@@ -473,7 +473,7 @@ MainWindow::MainWindow(QWidget *parent) :
// Create a dock widget with the title Label 1 and set the created label
// as the dock widget content
ads::CDockWidget* DockWidget = new ads::CDockWidget("Label 1");
ads::CDockWidget* DockWidget = DockManager->createDockWidget("Label 1");
DockWidget->setWidget(l);
// Add the toggleViewAction of the dock widget to the menu to give
@@ -481,7 +481,7 @@ MainWindow::MainWindow(QWidget *parent) :
ui->menuView->addAction(DockWidget->toggleViewAction());
// Add the dock widget to the top dock widget area
m_DockManager->addDockWidget(ads::TopDockWidgetArea, DockWidget);
DockManager->addDockWidget(ads::TopDockWidgetArea, DockWidget);
}
MainWindow::~MainWindow()
@@ -582,7 +582,7 @@ highlights are:
- Simple Drag & Drop user interface.
- Load data from file.
- Connect to live streaming of data.
- Save the visualization layout and configurations to re-use them later.
- Save the visualization layout and configurations to reuse them later.
- Fast OpenGL visualization.
- Can handle thousands of timeseries and millions of data points.
- Transform your data using a simple editor: derivative, moving average, integral, etc…

View File

@@ -27,7 +27,7 @@ target_link_libraries(AdvancedDockingSystemDemo PUBLIC Qt${QT_VERSION_MAJOR}::Co
if(WIN32 AND QT_VERSION_MAJOR LESS 6)
target_link_libraries(AdvancedDockingSystemDemo PUBLIC Qt${QT_VERSION_MAJOR}::AxContainer)
endif()
target_link_libraries(AdvancedDockingSystemDemo PRIVATE qt${QT_VERSION_MAJOR}advanceddocking)
target_link_libraries(AdvancedDockingSystemDemo PRIVATE qtadvanceddocking-qt${QT_VERSION_MAJOR})
set_target_properties(AdvancedDockingSystemDemo PROPERTIES
AUTOMOC ON
AUTORCC ON

View File

@@ -75,18 +75,17 @@
#endif
#endif
#include "DockManager.h"
#include "DockWidget.h"
#include "DockAreaWidget.h"
#include "DockAreaTitleBar.h"
#include "DockAreaTabBar.h"
#include "FloatingDockContainer.h"
#include "DockAreaTitleBar.h"
#include "DockAreaWidget.h"
#include "DockComponentsFactory.h"
#include "StatusDialog.h"
#include "DockManager.h"
#include "DockSplitter.h"
#include "DockWidget.h"
#include "FloatingDockContainer.h"
#include "ImageViewer.h"
#include "MyDockAreaTitleBar.h"
#include "StatusDialog.h"
/**
* Returns a random number from 0 to highest - 1
@@ -147,7 +146,7 @@ public:
using Super = ads::CDockComponentsFactory;
ads::CDockAreaTitleBar* createDockAreaTitleBar(ads::CDockAreaWidget* DockArea) const override
{
auto TitleBar = new ads::CDockAreaTitleBar(DockArea);
auto TitleBar = new MyDockAreaTitleBar(DockArea);
auto CustomButton = new QToolButton(DockArea);
CustomButton->setToolTip(QObject::tr("Help"));
CustomButton->setIcon(svgIcon(":/adsdemo/images/help_outline.svg"));
@@ -237,7 +236,7 @@ struct MainWindowPrivate
m->setRootPath(QDir::currentPath());
w->setModel(m);
w->setRootIndex(m->index(QDir::currentPath()));
ads::CDockWidget* DockWidget = new ads::CDockWidget(QString("Filesystem %1")
ads::CDockWidget* DockWidget = DockManager->createDockWidget(QString("Filesystem %1")
.arg(FileSystemCount++));
DockWidget->setWidget(w);
DockWidget->setIcon(svgIcon(":/adsdemo/images/folder_open.svg"));
@@ -258,7 +257,7 @@ struct MainWindowPrivate
{
static int CalendarCount = 0;
QCalendarWidget* w = new QCalendarWidget();
ads::CDockWidget* DockWidget = new ads::CDockWidget(QString("Calendar %1").arg(CalendarCount++));
ads::CDockWidget* DockWidget = DockManager->createDockWidget(QString("Calendar %1").arg(CalendarCount++));
// The following lines are for testing the setWidget() and takeWidget()
// functionality
DockWidget->setWidget(w);
@@ -303,7 +302,7 @@ struct MainWindowPrivate
.arg(LabelCount)
.arg(QTime::currentTime().toString("hh:mm:ss:zzz")));
ads::CDockWidget* DockWidget = new ads::CDockWidget(QString("Label %1").arg(LabelCount++));
ads::CDockWidget* DockWidget = DockManager->createDockWidget(QString("Label %1").arg(LabelCount++));
DockWidget->setWidget(l);
DockWidget->setIcon(svgIcon(":/adsdemo/images/font_download.svg"));
ui.menuView->addAction(DockWidget->toggleViewAction());
@@ -321,7 +320,7 @@ struct MainWindowPrivate
w->setPlaceholderText("This is an editor. If you close the editor, it will be "
"deleted. Enter your text here.");
w->setStyleSheet("border: none");
ads::CDockWidget* DockWidget = new ads::CDockWidget(QString("Editor %1").arg(EditorCount++));
ads::CDockWidget* DockWidget = DockManager->createDockWidget(QString("Editor %1").arg(EditorCount++));
DockWidget->setWidget(w);
DockWidget->setIcon(svgIcon(":/adsdemo/images/edit.svg"));
DockWidget->setFeature(ads::CDockWidget::CustomCloseHandling, true);
@@ -364,7 +363,7 @@ struct MainWindowPrivate
auto Result = w->loadFile(FileName);
qDebug() << "loadFile result: " << Result;
ads::CDockWidget* DockWidget = new ads::CDockWidget(QString("Image Viewer %1").arg(ImageViewerCount++));
ads::CDockWidget* DockWidget = DockManager->createDockWidget(QString("Image Viewer %1").arg(ImageViewerCount++));
DockWidget->setIcon(svgIcon(":/adsdemo/images/photo.svg"));
DockWidget->setWidget(w,ads:: CDockWidget::ForceNoScrollArea);
auto ToolBar = DockWidget->createDefaultToolBar();
@@ -379,7 +378,7 @@ struct MainWindowPrivate
{
static int TableCount = 0;
auto w = new CMinSizeTableWidget();
ads::CDockWidget* DockWidget = new ads::CDockWidget(QString("Table %1").arg(TableCount++));
ads::CDockWidget* DockWidget = DockManager->createDockWidget(QString("Table %1").arg(TableCount++));
static int colCount = 5;
static int rowCount = 30;
w->setColumnCount(colCount);
@@ -418,7 +417,7 @@ struct MainWindowPrivate
ads::CDockWidget *createQQuickWidget()
{
QQuickWidget *widget = new QQuickWidget();
ads::CDockWidget *dockWidget = new ads::CDockWidget("Quick");
ads::CDockWidget *dockWidget = DockManager->createDockWidget("Quick");
dockWidget->setWidget(widget);
return dockWidget;
}
@@ -433,7 +432,7 @@ struct MainWindowPrivate
{
static int ActiveXCount = 0;
QAxWidget* w = new QAxWidget("{6bf52a52-394a-11d3-b153-00c04f79faa6}", parent);
ads::CDockWidget* DockWidget = new ads::CDockWidget(QString("Active X %1").arg(ActiveXCount++));
ads::CDockWidget* DockWidget = DockManager->createDockWidget(QString("Active X %1").arg(ActiveXCount++));
DockWidget->setWidget(w);
ui.menuView->addAction(DockWidget->toggleViewAction());
return DockWidget;
@@ -471,12 +470,12 @@ void MainWindowPrivate::createContent()
appendFeaturStringToWindowTitle(FileSystemWidget);
// Test custom factory - we inject a help button into the title bar
ads::CDockComponentsFactory::setFactory(new CCustomComponentsFactory());
DockManager->setComponentsFactory(new CCustomComponentsFactory());
auto TopDockArea = DockManager->addDockWidget(ads::TopDockWidgetArea, FileSystemWidget);
// Uncomment the next line if you would like to test the
// HideSingleWidgetTitleBar functionality
// TopDockArea->setDockAreaFlag(ads::CDockAreaWidget::HideSingleWidgetTitleBar, true);
ads::CDockComponentsFactory::resetDefaultFactory();
DockManager->setComponentsFactory(ads::CDockComponentsFactory::factory());
// We create a calendar widget and clear all flags to prevent the dock area
// from closing
@@ -770,6 +769,9 @@ CMainWindow::CMainWindow(QWidget *parent) :
// uncomment if you would like to enable dock widget auto hiding
CDockManager::setAutoHideConfigFlags({CDockManager::DefaultAutoHideConfig});
// uncomment if you would like to disable closing auto hide widget with mouse click outside of auto hide container
//CDockManager::setAutoHideConfigFlag(CDockManager::AutoHideCloseOnOutsideMouseClick, false);
// uncomment if you would like to enable an equal distribution of the
// available size of a splitter to all contained dock widgets
// CDockManager::setConfigFlag(CDockManager::EqualSplitOnInsertion, true);

58
demo/MyDockAreaTitleBar.h Normal file
View File

@@ -0,0 +1,58 @@
#ifndef QTADS_MYDOCKAREATITLEBAR_H
#define QTADS_MYDOCKAREATITLEBAR_H
/*******************************************************************************
** Qt Advanced Docking System
** Copyright (C) 2017 Uwe Kindler
**
** This library is free software; you can redistribute it and/or
** modify it under the terms of the GNU Lesser General Public
** License as published by the Free Software Foundation; either
** version 2.1 of the License, or (at your option) any later version.
**
** This library is distributed in the hope that it will be useful,
** but WITHOUT ANY WARRANTY; without even the implied warranty of
** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
** Lesser General Public License for more details.
**
** You should have received a copy of the GNU Lesser General Public
** License along with this library; If not, see <http://www.gnu.org/licenses/>.
******************************************************************************/
//============================================================================
// INCLUDES
//============================================================================
#include <DockAreaTitleBar.h>
/**
* Custom DockAreaTitleBar that adds a custom context menu
*/
class MyDockAreaTitleBar : public ads::CDockAreaTitleBar
{
public:
explicit MyDockAreaTitleBar(ads::CDockAreaWidget *parent) :
CDockAreaTitleBar(parent)
{
}
QMenu* buildContextMenu(QMenu*) override
{
auto menu = ads::CDockAreaTitleBar::buildContextMenu(nullptr);
menu->addSeparator();
auto action = menu->addAction(tr("Format HardDrive"));
connect(action, &QAction::triggered, this, [this]()
{
QMessageBox msgBox;
msgBox.setText("No, just kidding");
msgBox.setStandardButtons(QMessageBox::Abort);
msgBox.setDefaultButton(QMessageBox::Abort);
msgBox.exec();
});
return menu;
}
};
#endif // QTADS_MYDOCKAREATITLEBAR_H

View File

@@ -29,8 +29,8 @@
- [`MiddleMouseButtonClosesTab`](#middlemousebuttonclosestab)
- [`DisableTabTextEliding`](#disabletabtexteliding)
- [`ShowTabTextOnlyForActiveTab`](#showtabtextonlyforactivetab)
- [Auto-Hide Configuration Flags](#auto-hide-configuration-flags)
- [Auto Hide Dock Widgets](#auto-hide-dock-widgets)
- [`DoubleClickUndocksWidget`](#doubleclickundockswidget)
- [Auto Hide Dock Widgets](#auto-hide-dock-widgets)
- [Pinning Auto-Hide Widgets to a certain border](#pinning-auto-hide-widgets-to-a-certain-border)
- [Show / Hide Auto-Hide Widgets via Mouse Over](#show--hide-auto-hide-widgets-via-mouse-over)
- [Drag \& Drop to Auto-Hide](#drag--drop-to-auto-hide)
@@ -39,6 +39,7 @@
- [Auto-Hide Drag to Float / Dock](#auto-hide-drag-to-float--dock)
- [Auto-Hide Context Menu](#auto-hide-context-menu)
- [Adding Auto Hide Widgets](#adding-auto-hide-widgets)
- [Auto-Hide Configuration Flags](#auto-hide-configuration-flags)
- [Setting Auto-Hide Flags](#setting-auto-hide-flags)
- [`AutoHideFeatureEnabled`](#autohidefeatureenabled)
- [`DockAreaHasAutoHideButton`](#dockareahasautohidebutton)
@@ -50,6 +51,7 @@
- [`AutoHideHasCloseButton`](#autohidehasclosebutton)
- [`AutoHideHasMinimizeButton`](#autohidehasminimizebutton)
- [`AutoHideOpenOnDragHover`](#autohideopenondraghover)
- [`AutoHideCloseOnOutsideMouseClick`](#autohidecloseonoutsidemouseclick)
- [DockWidget Feature Flags](#dockwidget-feature-flags)
- [`DockWidgetClosable`](#dockwidgetclosable)
- [`DockWidgetMovable`](#dockwidgetmovable)
@@ -63,6 +65,8 @@
- [Central Widget](#central-widget)
- [Empty Dock Area](#empty-dock-area)
- [Custom Close Handling](#custom-close-handling)
- [Globally Lock Docking Features](#globally-lock-docking-features)
- [Dock Widget Size / Minimum Size Handling](#dock-widget-size--minimum-size-handling)
- [Styling](#styling)
- [Disabling the Internal Style Sheet](#disabling-the-internal-style-sheet)
@@ -496,9 +500,12 @@ for active tabs. Inactive tabs only show their icon:
![MShowTabTextOnlyForActiveTab true](cfg_flag_ShowTabTextOnlyForActiveTab_true.png)
## Auto-Hide Configuration Flags
### `DoubleClickUndocksWidget`
### Auto Hide Dock Widgets
If the flag is set (default), a double click on a tab undocks the dock widget.
If you would like to disable undocking, just clear this flag.
## Auto Hide Dock Widgets
The Advanced Docking System supports "Auto-Hide" functionality for **all**
dock containers. The "Auto Hide" feature allows to display more information
@@ -599,6 +606,8 @@ DockManager->addAutoHideDockWidget(SideBarLeft, TableDockWidget);
See `autohide` example or the demo application to learn how it works.
## Auto-Hide Configuration Flags
### Setting Auto-Hide Flags
The Advanced Docking System has a number of global configuration flags to
@@ -705,7 +714,6 @@ If this flag is set (disabled by default), then each auto hide widget has a mini
![AutoHideHasMinimizeButton](cfg_flag_AutoHideHasMinimizeButton.png)
### `AutoHideOpenOnDragHover`
If this flag is set (disabled by default), then holding a dragging cursor hover an auto-hide collapsed dock's tab will open said dock:
@@ -714,6 +722,12 @@ If this flag is set (disabled by default), then holding a dragging cursor hover
Said dock must be set to accept drops to hide when cursor leaves its scope. See `AutoHideDragNDropExample` for more details.
### `AutoHideCloseOnOutsideMouseClick`
If this flag is set (default), the auto hide dock container will collapse if the
user clicks outside of the container. If not set, the auto hide container can be
closed only via click on auto hide sidebar tab.
## DockWidget Feature Flags
### `DockWidgetClosable`
@@ -835,6 +849,93 @@ Normally clicking the close button of a dock widget will just hide the widget an
When an entire area is closed, the default behavior is to hide the dock widgets it contains regardless of the `DockWidgetDeleteOnClose` flag except if there is only one dock widget. In this special case, the `DockWidgetDeleteOnClose` flag is followed. This behavior can be changed by setting the `DockWidgetForceCloseWithArea` flag to all the dock widgets that needs to be closed with their area.
## Globally Lock Docking Features
It is possible to globally lock features of all dock widgets to "freeze" the
current workspace layout. That means, you can now lock your workspace
to avoid accidentally dragging a docked view. When locking wasn't possible,
users had to manually dock it back to the desired place after each accidental
undock.
You can use a combination of the following feature flags to define which features
shall get locked:
- CDockWidget::DockWidgetClosable
- CDockWidget::DockWidgetMovable
- CDockWidget::DockWidgetFloatable
- CDockWidget::DockWidgetPinable
To clear the locked features, you can use CDockWidget::NoDockWidgetFeatures
The following code shows how to lock and unlock all dock widget features
globally.
```c++
DockManager->lockDockWidgetFeaturesGlobally();
DockManager->lockDockWidgetFeaturesGlobally(CDockWidget::NoDockWidgetFeatures);
```
## Dock Widget Size / Minimum Size Handling
There are several `CDockWidget` mode enums to control how a `CDockWidget` is
resized and how the docking system handles the minimum size of a dockwidget.
The first one is the `eInsertMode` enum:
```c++
enum eInsertMode
{
AutoScrollArea,
ForceScrollArea,
ForceNoScrollArea
};
```
The InsertMode defines how the widget is inserted into the dock widget, when you
call the `CDockWidget::setWidget` method:
```c++
DockWidget->setWidget(widget, CDockWidget::AutoScrollArea);
```
The content of a dock widget should be resizable do a very small size to
prevent the dock widget from blocking the resizing. To ensure, that a
dock widget can be resized very well, it is better to insert the content
widget into a scroll area or to provide a widget that is already a scroll
area or that contains a scroll area (such as an `QAbstractItemView`)
If the InsertMode is `AutoScrollArea`, the DockWidget tries to automatically
detect how to insert the given widget. If the widget is derived from
`QScrollArea` (i.e. an `QAbstractItemView`), then the widget is inserted
directly. If the given widget is not a scroll area, the widget will be
inserted into a scroll area.
To force insertion into a scroll area, you can also provide the InsertMode
`ForceScrollArea`. In this case a scroll area will also be created for content
widgets that are derived from `QScrollArea` To prevent insertion into a scroll
area, you can provide the InsertMode `ForceNoScrollArea`. In this case, the
content widget is always inserted directly.
A second enum, the `eMinimumSizeHintMode` defines, which value will be returned
from the `CDockWidget::minimumSizeHint()` function:
```c++
enum eMinimumSizeHintMode
{
MinimumSizeHintFromDockWidget,
MinimumSizeHintFromContent,
MinimumSizeHintFromDockWidgetMinimumSize,
MinimumSizeHintFromContentMinimumSize,
};
```
To ensure, that a dock widget does not block resizing, the dock widget
reimplements `minimumSizeHint()` function to return a very small minimum
size hint. If you would like to adhere the `minimumSizeHint()` from the
content widget, then set the `minimumSizeHintMode()` to
`MinimumSizeHintFromContent`. If you would like to use the `minimumSize()`
value of the content widget or the dock widget, then you can use the
`MinimumSizeHintFromDockWidgetMinimumSize` or
`MinimumSizeHintFromContentMinimumSize` modes.
## Styling
The Advanced Docking System supports styling via [Qt Style Sheets](https://doc.qt.io/qt-5/stylesheet.html). All components like splitters, tabs, buttons, titlebar and

View File

@@ -9,7 +9,7 @@ add_executable(AutoHideExample WIN32
mainwindow.ui
)
target_include_directories(AutoHideExample PRIVATE "${CMAKE_CURRENT_SOURCE_DIR}/../../src")
target_link_libraries(AutoHideExample PRIVATE qt${QT_VERSION_MAJOR}advanceddocking)
target_link_libraries(AutoHideExample PRIVATE qtadvanceddocking-qt${QT_VERSION_MAJOR})
target_link_libraries(AutoHideExample PUBLIC Qt${QT_VERSION_MAJOR}::Core
Qt${QT_VERSION_MAJOR}::Gui
Qt${QT_VERSION_MAJOR}::Widgets)

View File

@@ -10,7 +10,7 @@ add_executable(AutoHideDragNDropExample WIN32
droppableitem.cpp
)
target_include_directories(AutoHideDragNDropExample PRIVATE "${CMAKE_CURRENT_SOURCE_DIR}/../../src")
target_link_libraries(AutoHideDragNDropExample PRIVATE qt${QT_VERSION_MAJOR}advanceddocking)
target_link_libraries(AutoHideDragNDropExample PRIVATE qtadvanceddocking-qt${QT_VERSION_MAJOR})
target_link_libraries(AutoHideDragNDropExample PUBLIC Qt${QT_VERSION_MAJOR}::Core
Qt${QT_VERSION_MAJOR}::Gui
Qt${QT_VERSION_MAJOR}::Widgets)

View File

@@ -9,7 +9,7 @@ add_executable(CentralWidgetExample WIN32
mainwindow.ui
)
target_include_directories(CentralWidgetExample PRIVATE "${CMAKE_CURRENT_SOURCE_DIR}/../../src")
target_link_libraries(CentralWidgetExample PRIVATE qt${QT_VERSION_MAJOR}advanceddocking)
target_link_libraries(CentralWidgetExample PRIVATE qtadvanceddocking-qt${QT_VERSION_MAJOR})
target_link_libraries(CentralWidgetExample PUBLIC Qt${QT_VERSION_MAJOR}::Core
Qt${QT_VERSION_MAJOR}::Gui
Qt${QT_VERSION_MAJOR}::Widgets)

View File

@@ -9,7 +9,7 @@ add_executable(configFlagsExample WIN32
mainwindow.ui
)
target_include_directories(CentralWidgetExample PRIVATE "${CMAKE_CURRENT_SOURCE_DIR}/../../src")
target_link_libraries(CentralWidgetExample PRIVATE qt${QT_VERSION_MAJOR}advanceddocking)
target_link_libraries(CentralWidgetExample PRIVATE qtadvanceddocking-qt${QT_VERSION_MAJOR})
target_link_libraries(CentralWidgetExample PUBLIC Qt${QT_VERSION_MAJOR}::Core
Qt${QT_VERSION_MAJOR}::Gui
Qt${QT_VERSION_MAJOR}::Widgets)

View File

@@ -7,7 +7,7 @@ add_executable(DeleteOnCloseTest WIN32
main.cpp
)
target_include_directories(DeleteOnCloseTest PRIVATE "${CMAKE_CURRENT_SOURCE_DIR}/../../src")
target_link_libraries(DeleteOnCloseTest PRIVATE qt${QT_VERSION_MAJOR}advanceddocking)
target_link_libraries(DeleteOnCloseTest PRIVATE qtadvanceddocking-qt${QT_VERSION_MAJOR})
target_link_libraries(DeleteOnCloseTest PUBLIC Qt${QT_VERSION_MAJOR}::Core
Qt${QT_VERSION_MAJOR}::Gui
Qt${QT_VERSION_MAJOR}::Widgets)

View File

@@ -12,7 +12,7 @@ add_executable(DockInDockExample WIN32
mainframe.cpp
)
target_include_directories(DockInDockExample PRIVATE "${CMAKE_CURRENT_SOURCE_DIR}/../../src")
target_link_libraries(DockInDockExample PRIVATE qt${QT_VERSION_MAJOR}advanceddocking)
target_link_libraries(DockInDockExample PRIVATE qtadvanceddocking-qt${QT_VERSION_MAJOR})
target_link_libraries(DockInDockExample PUBLIC Qt${QT_VERSION_MAJOR}::Core
Qt${QT_VERSION_MAJOR}::Gui
Qt${QT_VERSION_MAJOR}::Widgets)

View File

@@ -9,7 +9,7 @@ add_executable(EmptyDockAreaExample WIN32
mainwindow.ui
)
target_include_directories(EmptyDockAreaExample PRIVATE "${CMAKE_CURRENT_SOURCE_DIR}/../../src")
target_link_libraries(EmptyDockAreaExample PRIVATE qt${QT_VERSION_MAJOR}advanceddocking)
target_link_libraries(EmptyDockAreaExample PRIVATE qtadvanceddocking-qt${QT_VERSION_MAJOR})
target_link_libraries(EmptyDockAreaExample PUBLIC Qt${QT_VERSION_MAJOR}::Core
Qt${QT_VERSION_MAJOR}::Gui
Qt${QT_VERSION_MAJOR}::Widgets)

View File

@@ -32,9 +32,12 @@ CMainWindow::CMainWindow(QWidget *parent)
, ui(new Ui::CMainWindow)
{
ui->setupUi(this);
CDockManager::setConfigFlag(CDockManager::OpaqueSplitterResize, true);
CDockManager::setConfigFlag(CDockManager::XmlCompressionEnabled, false);
CDockManager::setConfigFlag(CDockManager::FocusHighlighting, true);
ads::CDockManager::setConfigFlag( ads::CDockManager::DockAreaHasCloseButton, false );
ads::CDockManager::setConfigFlag( ads::CDockManager::AllTabsHaveCloseButton, true );
ads::CDockManager::setConfigFlag( ads::CDockManager::DockAreaHasUndockButton, false );
ads::CDockManager::setConfigFlag( ads::CDockManager::DockAreaDynamicTabsMenuButtonVisibility, true );
ads::CDockManager::setConfigFlag( ads::CDockManager::DisableTabTextEliding, true );
ads::CDockManager::setConfigFlag( ads::CDockManager::DoubleClickUndocksWidget, false );
DockManager = new CDockManager(this);
// Set central widget
@@ -98,8 +101,13 @@ void CMainWindow::createPerspectiveUi()
PerspectiveComboBox = new QComboBox(this);
PerspectiveComboBox->setSizeAdjustPolicy(QComboBox::AdjustToContents);
PerspectiveComboBox->setSizePolicy(QSizePolicy::Preferred, QSizePolicy::Preferred);
#if QT_VERSION >= QT_VERSION_CHECK(6, 0, 0)
connect(PerspectiveComboBox, &QComboBox::textActivated,
DockManager, &CDockManager::openPerspective);
#else
connect(PerspectiveComboBox, SIGNAL(activated(const QString&)),
DockManager, SLOT(openPerspective(const QString&)));
#endif
PerspectiveListAction->setDefaultWidget(PerspectiveComboBox);
ui->toolBar->addSeparator();
ui->toolBar->addAction(PerspectiveListAction);

View File

@@ -9,7 +9,7 @@ add_executable(HideShowExample WIN32
MainWindow.ui
)
target_include_directories(HideShowExample PRIVATE "${CMAKE_CURRENT_SOURCE_DIR}/../../src")
target_link_libraries(HideShowExample PRIVATE qt${QT_VERSION_MAJOR}advanceddocking)
target_link_libraries(HideShowExample PRIVATE qtadvanceddocking-qt${QT_VERSION_MAJOR})
target_link_libraries(HideShowExample PUBLIC Qt${QT_VERSION_MAJOR}::Core
Qt${QT_VERSION_MAJOR}::Gui
Qt${QT_VERSION_MAJOR}::Widgets)

View File

@@ -9,7 +9,7 @@ add_executable(SidebarExample WIN32
MainWindow.ui
)
target_include_directories(SidebarExample PRIVATE "${CMAKE_CURRENT_SOURCE_DIR}/../../src")
target_link_libraries(SidebarExample PRIVATE qt${QT_VERSION_MAJOR}advanceddocking)
target_link_libraries(SidebarExample PRIVATE qtadvanceddocking-qt${QT_VERSION_MAJOR})
target_link_libraries(SidebarExample PUBLIC Qt${QT_VERSION_MAJOR}::Core
Qt${QT_VERSION_MAJOR}::Gui
Qt${QT_VERSION_MAJOR}::Widgets)

View File

@@ -9,7 +9,7 @@ add_executable(SimpleExample WIN32
MainWindow.ui
)
target_include_directories(SimpleExample PRIVATE "${CMAKE_CURRENT_SOURCE_DIR}/../../src")
target_link_libraries(SimpleExample PRIVATE qt${QT_VERSION_MAJOR}advanceddocking)
target_link_libraries(SimpleExample PRIVATE qtadvanceddocking-qt${QT_VERSION_MAJOR})
target_link_libraries(SimpleExample PUBLIC Qt${QT_VERSION_MAJOR}::Core
Qt${QT_VERSION_MAJOR}::Gui
Qt${QT_VERSION_MAJOR}::Widgets)

View File

@@ -124,6 +124,21 @@ struct AutoHideDockContainerPrivate
*/
AutoHideDockContainerPrivate(CAutoHideDockContainer *_public);
/**
* Convenience function to ease access to dock manager components factory
*/
QSharedPointer<ads::CDockComponentsFactory> componentsFactory() const
{
if (!DockWidget || !DockWidget->dockManager())
{
return CDockComponentsFactory::factory();
}
else
{
return DockWidget->dockManager()->componentsFactory();
}
}
/**
* Convenience function to get a dock widget area
*/
@@ -199,7 +214,7 @@ CAutoHideDockContainer::CAutoHideDockContainer(CDockWidget* DockWidget, SideBarL
{
hide(); // auto hide dock container is initially always hidden
d->SideTabBarArea = area;
d->SideTab = componentsFactory()->createDockWidgetSideTab(nullptr);
d->SideTab = d->componentsFactory()->createDockWidgetSideTab(nullptr);
connect(d->SideTab, &CAutoHideTab::pressed, this, &CAutoHideDockContainer::toggleCollapseState);
d->DockArea = new CDockAreaWidget(DockWidget->dockManager(), parent);
d->DockArea->setObjectName("autoHideDockArea");
@@ -587,8 +602,12 @@ bool CAutoHideDockContainer::eventFilter(QObject* watched, QEvent* event)
return Super::eventFilter(watched, event);
}
// user clicked into container - collapse the auto hide widget
collapseView(true);
// user clicked outside of autohide container - collapse the auto hide widget
if (CDockManager::testAutoHideConfigFlag(
CDockManager::AutoHideCloseOnOutsideMouseClick))
{
collapseView(true);
}
}
else if (event->type() == internal::FloatingWidgetDragStartEvent)
{

View File

@@ -613,7 +613,7 @@ void CAutoHideTab::onDragHoverDelayExpired()
auto AutoHideContainer = d->DockWidget->autoHideDockContainer();
AutoHideContainer->collapseView(false);
d->DockWidget->dockManager()->setProperty(PropertyId,
QVariant::fromValue(QPointer(AutoHideContainer)));
QVariant::fromValue(QPointer<CAutoHideDockContainer>(AutoHideContainer)));
}

View File

@@ -71,7 +71,7 @@ if (UNIX AND NOT APPLE)
set(ads_HEADERS linux/FloatingWidgetTitleBar.h ${ads_HEADERS})
endif()
set(library_name "qt${QT_VERSION_MAJOR}advanceddocking")
set(library_name "qtadvanceddocking-qt${QT_VERSION_MAJOR}")
if(BUILD_STATIC)
add_library(${library_name} STATIC ${ads_SRCS} ${ads_HEADERS})
target_compile_definitions( ${library_name} PUBLIC ADS_STATIC)

View File

@@ -160,19 +160,9 @@ CDockAreaTabBar::~CDockAreaTabBar()
//============================================================================
void CDockAreaTabBar::wheelEvent(QWheelEvent* Event)
{
Event->accept();
const int direction = Event->angleDelta().y();
if (direction < 0)
{
horizontalScrollBar()->setValue(horizontalScrollBar()->value() + 20);
}
else
{
horizontalScrollBar()->setValue(horizontalScrollBar()->value() - 20);
}
QCoreApplication::sendEvent(horizontalScrollBar(), Event);
}
//============================================================================
void CDockAreaTabBar::setCurrentIndex(int index)
{
@@ -356,7 +346,7 @@ void CDockAreaTabBar::onCloseOtherTabsRequested()
CDockWidget::DockWidgetDeleteOnClose) ? 1 : 0;
closeTab(i);
// If the the dock widget blocks closing, i.e. if the flag
// If the dock widget blocks closing, i.e. if the flag
// CustomCloseHandling is set, and the dock widget is still open,
// then we do not need to correct the index
if (Tab->dockWidget()->isClosed())

View File

@@ -65,8 +65,7 @@ private Q_SLOTS:
void onTabWidgetMoved(const QPoint& GlobalPos);
protected:
virtual void wheelEvent(QWheelEvent* Event) override;
virtual void wheelEvent(QWheelEvent* Event) override;
public:
using Super = QScrollArea;

View File

@@ -114,6 +114,14 @@ struct DockAreaTitleBarPrivate
return DockArea->dockManager();
}
/**
* Convenience function for access to dock manager components factory
*/
QSharedPointer<ads::CDockComponentsFactory> componentsFactory() const
{
return dockManager()->componentsFactory();
}
/**
* Returns true if the given config flag is set
* Convenience function to ease config flag testing
@@ -385,7 +393,10 @@ void CDockAreaTitleBar::resizeEvent(QResizeEvent *event)
if (CDockManager::testConfigFlag(CDockManager::DockAreaDynamicTabsMenuButtonVisibility)
&& CDockManager::testConfigFlag(CDockManager::DisableTabTextEliding))
{
markTabsMenuOutdated();
// Use queued connection to ensure that the resizing and relayouting has
// finished to ensure that the d->TabBar->areTabsOverflowing() function
// returns the correct value
QMetaObject::invokeMethod(this, "markTabsMenuOutdated", Qt::QueuedConnection);
}
}
@@ -730,6 +741,11 @@ void CDockAreaTitleBar::mouseDoubleClickEvent(QMouseEvent *event)
return;
}
if (!CDockManager::testConfigFlag(CDockManager::DoubleClickUndocksWidget))
{
return;
}
d->makeAreaFloating(event->pos(), DraggingInactive);
}
@@ -765,24 +781,35 @@ void CDockAreaTitleBar::contextMenuEvent(QContextMenuEvent* ev)
return;
}
const bool isAutoHide = d->DockArea->isAutoHide();
auto Menu = buildContextMenu(nullptr);
Menu->exec(ev->globalPos());
delete Menu;
}
QMenu* CDockAreaTitleBar::buildContextMenu(QMenu *Menu)
{
const bool isAutoHide = d->DockArea->isAutoHide();
const bool isTopLevelArea = d->DockArea->isTopLevelArea();
QAction* Action;
QMenu Menu(this);
if (!isTopLevelArea)
if (Menu == nullptr)
{
Menu = new QMenu(this);
}
if (!isTopLevelArea)
{
Action = Menu.addAction(isAutoHide ? tr("Detach") : tr("Detach Group"),
Action = Menu->addAction(isAutoHide ? tr("Detach") : tr("Detach Group"),
this, SLOT(onUndockButtonClicked()));
Action->setEnabled(d->DockArea->features().testFlag(CDockWidget::DockWidgetFloatable));
if (CDockManager::testAutoHideConfigFlag(CDockManager::AutoHideFeatureEnabled))
{
Action = Menu.addAction(isAutoHide ? tr("Unpin (Dock)") : tr("Pin Group"), this, SLOT(onAutoHideDockAreaActionClicked()));
Action = Menu->addAction(isAutoHide ? tr("Unpin (Dock)") : tr("Pin Group"), this, SLOT(onAutoHideDockAreaActionClicked()));
auto AreaIsPinnable = d->DockArea->features().testFlag(CDockWidget::DockWidgetPinnable);
Action->setEnabled(AreaIsPinnable);
if (!isAutoHide)
{
auto menu = Menu.addMenu(tr("Pin Group To..."));
auto menu = Menu->addMenu(tr("Pin Group To..."));
menu->setEnabled(AreaIsPinnable);
d->createAutoHideToAction(tr("Top"), SideBarTop, menu);
d->createAutoHideToAction(tr("Left"), SideBarLeft, menu);
@@ -790,28 +817,27 @@ void CDockAreaTitleBar::contextMenuEvent(QContextMenuEvent* ev)
d->createAutoHideToAction(tr("Bottom"), SideBarBottom, menu);
}
}
Menu.addSeparator();
Menu->addSeparator();
}
if (isAutoHide)
{
Action = Menu.addAction(tr("Minimize"), this, SLOT(minimizeAutoHideContainer()));
Action = Menu.addAction(tr("Close"), this, SLOT(onAutoHideCloseActionTriggered()));
Action = Menu->addAction(tr("Minimize"), this, SLOT(minimizeAutoHideContainer()));
Action = Menu->addAction(tr("Close"), this, SLOT(onAutoHideCloseActionTriggered()));
}
else
{
Action = Menu.addAction(isAutoHide ? tr("Close") : tr("Close Group"), this, SLOT(onCloseButtonClicked()));
Action = Menu->addAction(isAutoHide ? tr("Close") : tr("Close Group"), this, SLOT(onCloseButtonClicked()));
}
Action->setEnabled(d->DockArea->features().testFlag(CDockWidget::DockWidgetClosable));
if (!isAutoHide && !isTopLevelArea)
{
Action = Menu.addAction(tr("Close Other Groups"), d->DockArea, SLOT(closeOtherAreas()));
Action = Menu->addAction(tr("Close Other Groups"), d->DockArea, SLOT(closeOtherAreas()));
}
Menu.exec(ev->globalPos());
return Menu;
}
//============================================================================
void CDockAreaTitleBar::insertWidget(int index, QWidget *widget)
{

View File

@@ -249,6 +249,20 @@ public:
*/
bool isAutoHide() const;
/**
* Fills the provided menu with standard entries. If a nullptr is passed, a
* new menu is created and filled with standard entries.
* This function is called from the actual version of contextMenuEvent, but
* can be called from any code. Caller is responsible of deleting the created
* object.
*
* @param menu The QMenu to fill with standard entries. If nullptr, a new
* QMenu will be created.
* @return The filled QMenu, either the provided one or a newly created one if
* nullptr was passed.
*/
virtual QMenu *buildContextMenu(QMenu *);
Q_SIGNALS:
/**
* This signal is emitted if a tab in the tab bar is clicked by the user

View File

@@ -269,6 +269,14 @@ struct DockAreaWidgetPrivate
*/
DockAreaWidgetPrivate(CDockAreaWidget* _public);
/**
* Convenience function to ease components factory access
*/
QSharedPointer<ads::CDockComponentsFactory> componentsFactory() const
{
return DockManager->componentsFactory();
}
/**
* Creates the layout for top area with tabs and close button
*/
@@ -371,10 +379,10 @@ void DockAreaWidgetPrivate::updateTitleBarButtonStates()
if (_this->isAutoHide())
{
if (CDockManager::testAutoHideConfigFlag(CDockManager::AutoHideHasCloseButton))
{
if (CDockManager::testAutoHideConfigFlag(CDockManager::AutoHideHasCloseButton))
{
TitleBar->button(TitleBarButtonClose)->setEnabled(
_this->features().testFlag(CDockWidget::DockWidgetClosable));
_this->features().testFlag(CDockWidget::DockWidgetClosable));
}
}
else

View File

@@ -38,6 +38,7 @@
QT_FORWARD_DECLARE_CLASS(QXmlStreamWriter)
QT_FORWARD_DECLARE_CLASS(QAbstractButton)
QT_FORWARD_DECLARE_CLASS(QMenu)
namespace ads
{

View File

@@ -21,7 +21,8 @@
namespace ads
{
static std::unique_ptr<CDockComponentsFactory> DefaultFactory(new CDockComponentsFactory());
static QSharedPointer<ads::CDockComponentsFactory> DefaultFactory;
//============================================================================
@@ -52,9 +53,13 @@ CDockAreaTitleBar* CDockComponentsFactory::createDockAreaTitleBar(CDockAreaWidge
//============================================================================
const CDockComponentsFactory* CDockComponentsFactory::factory()
QSharedPointer<ads::CDockComponentsFactory> CDockComponentsFactory::factory()
{
return DefaultFactory.get();
if (!DefaultFactory)
{
DefaultFactory.reset(new CDockComponentsFactory());
}
return DefaultFactory;
}
@@ -70,6 +75,7 @@ void CDockComponentsFactory::resetDefaultFactory()
{
DefaultFactory.reset(new CDockComponentsFactory());
}
} // namespace ads
//---------------------------------------------------------------------------

View File

@@ -66,9 +66,11 @@ public:
virtual CDockAreaTitleBar* createDockAreaTitleBar(CDockAreaWidget* DockArea) const;
/**
* Returns the default components factory
* This returns the default dock components factory instance.
* If no components factory is assigned to a specific dock manager, this
* global factory instance will be used.
*/
static const CDockComponentsFactory* factory();
static QSharedPointer<ads::CDockComponentsFactory> factory();
/**
* Sets a new default factory for creation of GUI elements.
@@ -82,15 +84,6 @@ public:
static void resetDefaultFactory();
};
/**
* Convenience function to ease factory instance access
*/
inline const CDockComponentsFactory* componentsFactory()
{
return CDockComponentsFactory::factory();
}
} // namespace ads
//---------------------------------------------------------------------------

View File

@@ -60,6 +60,8 @@
#include "DockAreaTitleBar.h"
#include "DockFocusController.h"
#include "DockSplitter.h"
#include "DockComponentsFactory.h"
#if defined(Q_OS_UNIX) && !defined(Q_OS_MACOS)
#include "linux/FloatingWidgetTitleBar.h"
@@ -125,6 +127,7 @@ struct DockManagerPrivate
QSize ToolBarIconSizeDocked = QSize(16, 16);
QSize ToolBarIconSizeFloating = QSize(24, 24);
CDockWidget::DockWidgetFeatures LockedDockWidgetFeatures;
QSharedPointer<ads::CDockComponentsFactory> ComponentFactory {ads::CDockComponentsFactory::factory()};
/**
* Private data constructor
@@ -552,7 +555,7 @@ CDockManager::~CDockManager()
{
if (!area || area->dockManager() != this) continue;
// QPointer delete safety - just in case some dock wigdet in destruction
// QPointer delete safety - just in case some dock widget in destruction
// deletes another related/twin or child dock widget.
std::vector<QPointer<QWidget>> deleteWidgets;
for ( auto widget : area->dockWidgets() )
@@ -581,6 +584,35 @@ CDockManager::~CDockManager()
delete d;
}
//============================================================================
CDockWidget* CDockManager::createDockWidget(const QString &title, QWidget* parent)
{
return new CDockWidget(this, title, parent);
}
//============================================================================
QSharedPointer<ads::CDockComponentsFactory> CDockManager::componentsFactory() const
{
return d->ComponentFactory;
}
//============================================================================
void CDockManager::setComponentsFactory(ads::CDockComponentsFactory* factory)
{
setComponentsFactory(QSharedPointer<ads::CDockComponentsFactory>(factory));
}
//============================================================================
void CDockManager::setComponentsFactory(QSharedPointer<ads::CDockComponentsFactory> factory)
{
d->ComponentFactory = factory;
}
//============================================================================
#if defined(Q_OS_UNIX) && !defined(Q_OS_MACOS)
bool CDockManager::eventFilter(QObject *obj, QEvent *e)

View File

@@ -215,6 +215,8 @@ public:
MiddleMouseButtonClosesTab = 0x2000000, //! If the flag is set, the user can use the mouse middle button to close the tab under the mouse
DisableTabTextEliding = 0x4000000, //! Set this flag to disable eliding of tab texts in dock area tabs
ShowTabTextOnlyForActiveTab =0x8000000, //! Set this flag to show label texts in dock area tabs only for active tabs
DoubleClickUndocksWidget = 0x10000000, //!< If the flag is set, a double click on a tab undocks the widget
DefaultDockAreaButtons = DockAreaHasCloseButton
| DockAreaHasUndockButton
@@ -223,7 +225,8 @@ public:
DefaultBaseConfig = DefaultDockAreaButtons
| ActiveTabHasCloseButton
| XmlCompressionEnabled
| FloatingContainerHasWidgetTitle, ///< default base configuration settings
| FloatingContainerHasWidgetTitle
| DoubleClickUndocksWidget, ///< default base configuration settings
DefaultOpaqueConfig = DefaultBaseConfig
| OpaqueSplitterResize
@@ -255,10 +258,12 @@ public:
AutoHideHasCloseButton = 0x80, //< If the flag is set an auto hide title bar has a close button
AutoHideHasMinimizeButton = 0x100, ///< if this flag is set, the auto hide title bar has a minimize button to collapse the dock widget
AutoHideOpenOnDragHover = 0x200, ///< if this flag is set, dragging hover the tab bar will open the dock
AutoHideCloseOnOutsideMouseClick = 0x400, ///< if this flag is set, the auto hide dock container will collapse if the user clicks outside of the container, if not set, the auto hide container can be closed only via click on sidebar tab
DefaultAutoHideConfig = AutoHideFeatureEnabled
| DockAreaHasAutoHideButton
| AutoHideHasMinimizeButton
| AutoHideCloseOnOutsideMouseClick
};
Q_DECLARE_FLAGS(AutoHideFlags, eAutoHideFlag)
@@ -287,6 +292,39 @@ public:
*/
virtual ~CDockManager() override;
/**
* Creates a new dock widget with the specified title and optional parent
* widget.
*
* The new dock widget will be managed by the dock manager, and its lifetime
* will be tied to the dock manager. If a parent widget is provided, the dock
* widget will be created as a child of the parent widget. If no parent widget
* is provided, the dock widget will be created as a top-level widget.
*
* @param title The title of the dock widget.
* @param parent The parent widget, if any. Defaults to nullptr.
* @return Returns a pointer to the created CDockWidget.
*/
CDockWidget *createDockWidget(const QString &title, QWidget* parent = nullptr);
/**
* Returns the dock manager specific factory for creating components of
* fock widgets
*/
QSharedPointer<ads::CDockComponentsFactory> componentsFactory() const;
/**
* Sets a custom factory for creating components of dock widgets.
* The pointer is stored internally into a shared pointer so you should not
* delete the given factory object as long as it is used by the dock manager.
*/
void setComponentsFactory(ads::CDockComponentsFactory* Factory);
/**
* Sets a custom factory for creating components of dock widgets.
*/
void setComponentsFactory(QSharedPointer<ads::CDockComponentsFactory>);
/**
* This function returns the global configuration flags
*/

View File

@@ -102,6 +102,14 @@ struct DockWidgetPrivate
*/
DockWidgetPrivate(CDockWidget* _public);
/**
* Convenience function to ease components factory access
*/
QSharedPointer<ads::CDockComponentsFactory> componentsFactory() const
{
return DockManager ? DockManager->componentsFactory() : CDockComponentsFactory::factory();
}
/**
* Show dock widget
*/
@@ -358,9 +366,17 @@ void DockWidgetPrivate::setToolBarStyleFromDockManager()
//============================================================================
CDockWidget::CDockWidget(const QString &title, QWidget *parent) :
QFrame(parent),
d(new DockWidgetPrivate(this))
CDockWidget(nullptr, title, parent)
{
}
//============================================================================
CDockWidget::CDockWidget(CDockManager *manager, const QString &title, QWidget* parent)
: QFrame(parent),
d(new DockWidgetPrivate(this))
{
d->DockManager = manager;
d->Layout = new QBoxLayout(QBoxLayout::TopToBottom);
d->Layout->setContentsMargins(0, 0, 0, 0);
d->Layout->setSpacing(0);
@@ -368,7 +384,7 @@ CDockWidget::CDockWidget(const QString &title, QWidget *parent) :
setWindowTitle(title);
setObjectName(title);
d->TabWidget = componentsFactory()->createDockWidgetTab(this);
d->TabWidget = d->componentsFactory()->createDockWidgetTab(this);
d->ToggleViewAction = new QAction(title, this);
d->ToggleViewAction->setCheckable(true);
@@ -382,6 +398,7 @@ CDockWidget::CDockWidget(const QString &title, QWidget *parent) :
}
}
//============================================================================
CDockWidget::~CDockWidget()
{

View File

@@ -256,8 +256,35 @@ public:
* during runtime, you need to set a unique object name explicitly
* by calling setObjectName() after construction.
* Use the layoutFlags to configure the layout of the dock widget.
* \note If you would like to use custom TabWidget implementations, you need
* to use the constructor with the CDockManager argument.
*/
CDockWidget(const QString &title, QWidget* parent = nullptr);
Q_DECL_DEPRECATED explicit CDockWidget(const QString &title, QWidget* parent = nullptr);
/**
* This constructor creates a dock widget for the given dock manager with the
* provided title.
*
* @param manager Pointer to the dock manager that owns the dock widget.
* @param title The title is the text that is shown in the window title when
* the dock widget is floating and it is the title that is shown in the
* titlebar or the tab of this dock widget if it is tabified.
* @param parent Pointer to the parent widget, defaults to nullptr.
*
* @note The object name of the dock widget is also set to the title. The
* object name is required by the dock manager to properly save and restore
* the state of the dock widget. That means, the title needs to be unique. If
* the title is not unique or if you would like to change the title during
* runtime, you need to set a unique object name explicitly by calling
* setObjectName() after construction. Use the layoutFlags to configure the
* layout of the dock widget.
*
* @note this constructor is preferred over the two argument version, especially
* when custom factories are in use. Indeed, it will use the Dock Manager factory,
* and not the default factory. For this reason, the original constructor should
* be deprecated in favour of this version.
*/
CDockWidget(CDockManager *manager, const QString &title, QWidget* parent = nullptr);
/**
* Virtual Destructor

View File

@@ -529,26 +529,34 @@ void CDockWidgetTab::contextMenuEvent(QContextMenuEvent* ev)
return;
}
auto Menu = buildContextMenu(nullptr);
d->saveDragStartMousePosition(ev->globalPos());
Menu->exec(ev->globalPos());
}
QMenu* CDockWidgetTab::buildContextMenu(QMenu *Menu)
{
if (Menu == nullptr) {
Menu = new QMenu(this);
}
const bool isFloatable = d->DockWidget->features().testFlag(CDockWidget::DockWidgetFloatable);
const bool isNotOnlyTabInContainer = !d->DockArea->dockContainer()->hasTopLevelDockWidget();
const bool isTopLevelArea = d->DockArea->isTopLevelArea();
const bool isDetachable = isFloatable && isNotOnlyTabInContainer;
QAction* Action;
QMenu Menu(this);
if (!isTopLevelArea)
{
Action = Menu.addAction(tr("Detach"), this, SLOT(detachDockWidget()));
Action = Menu->addAction(tr("Detach"), this, SLOT(detachDockWidget()));
Action->setEnabled(isDetachable);
if (CDockManager::testAutoHideConfigFlag(CDockManager::AutoHideFeatureEnabled))
{
Action = Menu.addAction(tr("Pin"), this, SLOT(autoHideDockWidget()));
Action = Menu->addAction(tr("Pin"), this, SLOT(autoHideDockWidget()));
auto IsPinnable = d->DockWidget->features().testFlag(CDockWidget::DockWidgetPinnable);
Action->setEnabled(IsPinnable);
auto menu = Menu.addMenu(tr("Pin To..."));
auto menu = Menu->addMenu(tr("Pin To..."));
menu->setEnabled(IsPinnable);
d->createAutoHideToAction(tr("Top"), SideBarTop, menu);
d->createAutoHideToAction(tr("Left"), SideBarLeft, menu);
@@ -557,17 +565,16 @@ void CDockWidgetTab::contextMenuEvent(QContextMenuEvent* ev)
}
}
Menu.addSeparator();
Action = Menu.addAction(tr("Close"), this, SIGNAL(closeRequested()));
Menu->addSeparator();
Action = Menu->addAction(tr("Close"), this, SIGNAL(closeRequested()));
Action->setEnabled(isClosable());
if (d->DockArea->openDockWidgetsCount() > 1)
{
Action = Menu.addAction(tr("Close Others"), this, SIGNAL(closeOtherTabsRequested()));
Action = Menu->addAction(tr("Close Others"), this, SIGNAL(closeOtherTabsRequested()));
}
Menu.exec(ev->globalPos());
return Menu;
}
//============================================================================
bool CDockWidgetTab::isActiveTab() const
{
@@ -692,7 +699,7 @@ QString CDockWidgetTab::text() const
//============================================================================
void CDockWidgetTab::mouseDoubleClickEvent(QMouseEvent *event)
{
if (event->button() == Qt::LeftButton)
if (event->button() == Qt::LeftButton && CDockManager::testConfigFlag(CDockManager::DoubleClickUndocksWidget))
{
// If this is the last dock area in a dock container it does not make
// sense to move it to a new floating widget and leave this one

View File

@@ -35,6 +35,8 @@
#include "ads_globals.h"
QT_FORWARD_DECLARE_CLASS(QMenu)
namespace ads
{
class CDockWidget;
@@ -184,6 +186,20 @@ public:
*/
eDragState dragState() const;
/**
* Fills the provided menu with standard entries. If a nullptr is passed, a
* new menu is created and filled with standard entries.
* This function is called from the actual version of contextMenuEvent, but
* can be called from any code. Caller is responsible of deleting the created
* object.
*
* @param menu The QMenu to fill with standard entries. If nullptr, a new
* QMenu will be created.
* @return The filled QMenu, either the provided one or a newly created one if
* nullptr was passed.
*/
virtual QMenu *buildContextMenu(QMenu *);
public Q_SLOTS:
virtual void setVisible(bool visible) override;

View File

@@ -283,7 +283,7 @@ QString detectWindowManagerX11()
}
if(sup_windows.length() == 0)
{
ADS_PRINT("Failed to get the supporting window on non EWMH comform WM.");
ADS_PRINT("Failed to get the supporting window on non EWMH conform WM.");
return "UNKNOWN";
}
support_win = sup_windows[0];

View File

@@ -236,7 +236,7 @@ SideBarLocation toSideBarLocation(DockWidgetArea Area);
/**
* Returns true for the top or bottom side bar ansd false for the
* Returns true for the top or bottom side bar and false for the
* left and right side bar
*/
bool isHorizontalSideBarLocation(SideBarLocation Location);