Compare commits

...

28 Commits
3.8.0 ... 3.8.2

Author SHA1 Message Date
kzl
d5fefaa35f while dockManager.removeDockWidget , the dockManager() returns null (#399) 2022-02-18 19:33:55 +01:00
Ben Hetherington
3c4af9c6af Add method to add dock widget to dock container (#398)
This adds a `addDockWidgetToContainer()` method to `CDockManager`, which allows a dock widget to be registered with the dock manager, and added to a specific container, even if that container doesn't currently have any `DockAreaWidget`s.

This is pretty much just a clone of `addDockWidget()`, but with the ability to specify a container widget instead of a dock area.
2022-02-06 08:21:43 +01:00
githubuser0xFFFF
12ec819aeb Update README.md
Updated CETONI Elements showcase
2022-01-02 21:55:00 +01:00
Uwe Kindler
e6fc1c14bd Added NotepadNext to the showcase section 2021-12-22 07:47:24 +01:00
SleepProgger
6fb45c055c Removed ContentMargin in DockContainer (#387) 2021-12-20 07:46:26 +01:00
Ralph Minderhoud
535b926095 CMake: Allow version to be explicitly set without requiring git (#384)
The main CMakeLists.txt was updated to allow explicitly setting the
version for the project by setting the `ADS_VERSION` variable (e.g.
cmake .. -DADS_VERSION=1.0.0).

The default behavior is to determine the version by reading the
information from git. Adding the option to override this variable at
configure time allows the library to be built outside of its git
repository, such as when the code is vendored directly into another
project and added using `add_subdirectory`.
2021-12-13 08:36:53 +01:00
Uwe Kindler
b15bc26a63 Some small coding style fixes 2021-12-12 17:28:11 +01:00
Uwe Kindler
1d90e8e823 Merge branch 'fix_issue_380' of https://github.com/jporcher/Qt-Advanced-Docking-System into jporcher-fix_issue_380 2021-12-12 17:19:27 +01:00
Jean Porcherot
6b3027401d Fix issue #380 and add example 2021-12-09 10:11:05 +01:00
githubuser0xFFFF
e35bd65a91 Update README.md 2021-12-07 11:01:26 +01:00
githubuser0xFFFF
8888f6800b Update README.md 2021-12-07 11:00:52 +01:00
Uwe Kindler
2afe62ec77 Fixed issue #378 - Don't show empty floating containers on startup 2021-12-06 09:42:12 +01:00
jporcher
4b27af959b Merge branch 'githubuser0xFFFF:master' into master 2021-12-06 07:57:29 +01:00
Ben Hetherington
0df1a41a1d Fix potential crash when restoring container state (#381)
This fixes a crash which could occur when restoring the state of a floating container to a non-floating container.

This was because `ads::CDockContainerWidget::RestoreState()` will unconditionally assume this is floating if the XML has the `Floating` boolean set, and will dereference `floatingWidget()`. If this isn't floating, `floatingWidget()` will return `nullptr`, leading to a crash when it's subsequently used.

Fixes #379.
2021-12-03 17:01:16 +01:00
anoy
21badd592e add QFlag operators (#376) 2021-11-26 19:09:09 +01:00
Uwe Kindler
a110d53a53 Fixed crash in DockFocusController
DockWidget pointers are now wrapped into QPointer to detect deleted
DockWidgets
2021-11-18 22:10:11 +01:00
Uwe Kindler
0270993782 Fixed error caused by broken merge request 2021-11-17 07:51:14 +01:00
Uwe Kindler
2c0d899b2a Fixed pixmap warning in ElidingLabel 2021-11-17 07:50:46 +01:00
Ben Hetherington
1abe101ef7 Prevent middle-click from closing unclosable tabs (#372)
This fixes a bug whereby you could close a dock widget by middle-clicking its tab, even if its `CDockWidget::DockWidgetClosable` flag is set to `false`.
2021-11-16 06:24:39 +01:00
Uwe Kindler
0ebc170cfa Fixed doc link to issue 365 2021-10-29 10:36:09 +02:00
Uwe Kindler
ee6ddfadc3 Documented DockWidget feature flags 2021-10-29 10:32:58 +02:00
Uwe Kindler
720b5f0c72 Added Plot Juggler to the showcase section 2021-10-29 10:02:09 +02:00
Uwe Kindler
aceabd8455 Added new and noteworthy for 3.8 release 2021-10-28 10:30:49 +02:00
Jean Porcherot
d0c100995e Fix crash when dockindock example is closed. Due to code in dockindock supposed to fix memory leaks: now leaks were fixed in CDockManager (https://github.com/githubuser0xFFFF/Qt-Advanced-Docking-System/issues/307), the code from dockindock ends up deleting objects already deleted by parent. 2021-04-27 10:05:07 +02:00
Jean Porcherot
f54e4c8ac2 Merge remote-tracking branch 'upstream/master' 2021-04-27 09:12:56 +02:00
Jean Porcherot
2c7b5982b5 Replace dockdepth1 by dockindock 2021-04-14 15:36:00 +02:00
Jean Porcherot
bac0698581 Fix compilation (include assert.h) 2021-04-09 13:36:51 +02:00
Jean Porcherot
be3180df6f Add dockdepth1 example 2021-04-07 16:51:46 +02:00
30 changed files with 571 additions and 36 deletions

View File

@@ -1,20 +1,41 @@
cmake_minimum_required(VERSION 3.5)
set(CMAKE_MODULE_PATH ${CMAKE_CURRENT_SOURCE_DIR}/cmake/modules ${CMAKE_MODULE_PATH})
include(GetGitRevisionDescription)
git_describe(GitTagVersion --tags)
string(REGEX REPLACE "^([0-9]+)\\..*" "\\1" VERSION_MAJOR "${GitTagVersion}")
string(REGEX REPLACE "^[0-9]+\\.([0-9]+).*" "\\1" VERSION_MINOR "${GitTagVersion}")
string(REGEX REPLACE "^[0-9]+\\.[0-9]+\\.([0-9]+).*" "\\1" VERSION_PATCH "${GitTagVersion}")
set(VERSION_SHORT "${VERSION_MAJOR}.${VERSION_MINOR}.${VERSION_PATCH}")
# By default, the version information is extracted from the git index. However,
# we can override this behavior by explicitly setting ADS_VERSION and
# skipping the git checks. This is useful for cases where this project is being
# used independently of its original git repo (e.g. vendored in another project)
if(NOT ADS_VERSION)
set(CMAKE_MODULE_PATH ${CMAKE_CURRENT_SOURCE_DIR}/cmake/modules ${CMAKE_MODULE_PATH})
include(GetGitRevisionDescription)
git_describe(GitTagVersion --tags)
string(REGEX REPLACE "^([0-9]+)\\..*" "\\1" VERSION_MAJOR "${GitTagVersion}")
string(REGEX REPLACE "^[0-9]+\\.([0-9]+).*" "\\1" VERSION_MINOR "${GitTagVersion}")
string(REGEX REPLACE "^[0-9]+\\.[0-9]+\\.([0-9]+).*" "\\1" VERSION_PATCH "${GitTagVersion}")
set(VERSION_SHORT "${VERSION_MAJOR}.${VERSION_MINOR}.${VERSION_PATCH}")
else()
string(REGEX MATCHALL "[\.]" VERSION_DOT_MATCHES ${ADS_VERSION})
list(LENGTH VERSION_DOT_MATCHES VERSION_DOT_COUNT)
if(VERSION_DOT_COUNT EQUAL 2)
set(VERSION_SHORT ${ADS_VERSION})
else()
message(FATAL_ERROR "ADS_VERSION must be in major.minor.patch format, e.g. 3.8.1. Got ${ADS_VERSION}")
endif()
endif()
project(QtADS LANGUAGES CXX VERSION ${VERSION_SHORT})
option(BUILD_STATIC "Build the static library" OFF)
option(BUILD_EXAMPLES "Build the examples" ON)
if("${CMAKE_SIZEOF_VOID_P}" STREQUAL "4")
set(ads_PlatformDir "x86")
else()
set(ads_PlatformDir "x64")
endif()
add_subdirectory(src)
if(BUILD_EXAMPLES)
add_subdirectory(examples)
add_subdirectory(demo)

View File

@@ -15,13 +15,20 @@ integrated development environments (IDEs) such as Visual Studio.
## New and Noteworthy
The [release 3.7](https://github.com/githubuser0xFFFF/Qt-Advanced-Docking-System/releases/tag/3.7.0)
The [release 3.8](https://github.com/githubuser0xFFFF/Qt-Advanced-Docking-System/releases/tag/3.8.1)
adds the following features:
- option to close tabs with the middle mouse button
- `DeleteContentOnClose` flag for dynamic deletion and creation of dock widget
content
The [release 3.7](https://github.com/githubuser0xFFFF/Qt-Advanced-Docking-System/releases/tag/3.7.2)
adds the following features:
- support for **Qt6.**
- support for [empty dock area](doc/user-guide.md#empty-dock-area)
The [release 3.6](https://github.com/githubuser0xFFFF/Qt-Advanced-Docking-System/releases/tag/3.6.0)
The [release 3.6](https://github.com/githubuser0xFFFF/Qt-Advanced-Docking-System/releases/tag/3.6.3)
adds some nice new features:
- support for [central widget](doc/user-guide.md#central-widget) concept
@@ -82,6 +89,8 @@ know it from Visual Studio.
- [D-Tect X](#d-tect-x)
- [HiveWE](#hivewe)
- [Ramses Composer](#ramses-composer)
- [Plot Juggler](#plot-juggler)
- [Notepad Next](#notepad-next)
### Docking everywhere - no central widget
@@ -363,13 +372,13 @@ Taken from the [Qt Blog](https://www.qt.io/blog/qt-design-studio-1.5-beta-releas
[![Qt Design Studio](doc/showcase_qt_design_studio_video.png)](https://youtu.be/za9KBWcFXEw?t=84)
### [QmixElements](https://www.cetoni.com/products/qmixelements/)
### [CETONI Elements](https://www.cetoni.com/products/qmixelements/)
The QmixElements software from [CETONI](https://www.cetoni.com) is a comprehensive,
The CETONI Elements software from [CETONI](https://www.cetoni.com) is a comprehensive,
plugin-based and modular laboratory automation software for controlling CETONI devices using a joint graphical user interface. The software features a powerful script system to automate processes. This [blog post](https://www.cetoni.com/blog/qmixelements-advanced-docking-system/) gives a nice overview about the use of the Qt
Advanced Docking System in the QmixElements sofware.
Advanced Docking System in the CETONI Elements sofware.
![QmixElements](doc/showcase_qmix_elements.png)
![CETONI_Elements](doc/showcase_qmix_elements.png)
### [ezEditor](https://github.com/ezEngine/ezEngine)
@@ -413,3 +422,32 @@ and digital portfolio.
[learn more...](https://github.com/GENIVI/ramses-composer)
![RamsesComposer](doc/showcase_ramses_composer.png)
### [Plot Juggler](https://github.com/facontidavide/PlotJuggler)
PlotJuggler is a fast, powerful and intuitive tool to visualize time series.
It makes it easy to visualize data but also to analyze it. You can manipulate
your time series using a simple and extendable Transform Editor. Some of the
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.
- 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…
- PlotJuggler can be easily extended using plugins.
[read more...](https://github.com/facontidavide/PlotJuggler)
[![Plot Juggler](doc/showcase_plot_juggler.png)](https://vimeo.com/480588113#t=46s)
### [Notepad Next](https://github.com/dail8859/NotepadNext)
Notepad Next is a cross-platform reimplementation of Notepad++ that uses the
Advanced Docking System to arrange the open source files on the screen.
[learn more...](https://github.com/dail8859/NotepadNext)
![NotepadNext](doc/showcase_notepad_next.png)

View File

@@ -466,6 +466,15 @@ void MainWindowPrivate::createContent()
Action = ui.menuTests->addAction(QString("Raise %1").arg(DockWidget->windowTitle()));
DockWidget->connect(Action, SIGNAL(triggered()), SLOT(raise()));
// Test hidden floating dock widget
DockWidget = createLongTextLabelDockWidget();
DockManager->addDockWidgetFloating(DockWidget);
DockWidget->toggleView(false);
// Test visible floating dock widget
DockWidget = createCalendarDockWidget();
DockManager->addDockWidgetFloating(DockWidget);
#ifdef Q_OS_WIN
#if (QT_VERSION < QT_VERSION_CHECK(6, 0, 0))

Binary file not shown.

After

Width:  |  Height:  |  Size: 257 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 92 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 264 KiB

View File

@@ -27,6 +27,17 @@
- [`EqualSplitOnInsertion`](#equalsplitoninsertion)
- [`FloatingContainerForceNativeTitleBar` (Linux only)](#floatingcontainerforcenativetitlebar-linux-only)
- [`FloatingContainerForceQWidgetTitleBar` (Linux only)](#floatingcontainerforceqwidgettitlebar-linux-only)
- [`MiddleMouseButtonClosesTab`](#middlemousebuttonclosestab)
- [DockWidget Feature Flags](#dockwidget-feature-flags)
- [`DockWidgetClosable`](#dockwidgetclosable)
- [`DockWidgetMovable`](#dockwidgetmovable)
- [`DockWidgetFloatable`](#dockwidgetfloatable)
- [`DockWidgetDeleteOnClose`](#dockwidgetdeleteonclose)
- [`CustomCloseHandling`](#customclosehandling)
- [`DockWidgetFocusable`](#dockwidgetfocusable)
- [`DockWidgetForceCloseWithArea`](#dockwidgetforceclosewitharea)
- [`NoTab`](#notab)
- [`DeleteContentOnClose`](#deletecontentonclose)
- [Central Widget](#central-widget)
- [Empty Dock Area](#empty-dock-area)
- [Custom Close Handling](#custom-close-handling)
@@ -464,6 +475,69 @@ If you would like to overwrite autodetection, then you can activate this flag
to force QWidget based title bars. You can overwrite autodetection and this
flag, if you set the environment variable `ADS_UseNativeTitle` to 0 or 1.
### `MiddleMouseButtonClosesTab`
If the flag is set, the user can use the mouse middle button to close the tab
under the mouse. So you do not need to exactly hit the tab close button to
close tab. Just click with the middle mouse button on a tab like this is
possible in various web browsers.
![MiddleMouseButtonClosesTab true](cfg_flag_MiddleMouseButtonClosesTab.gif)
## DockWidget Feature Flags
### `DockWidgetClosable`
If set, the dock widget will have a close button.
### `DockWidgetMovable`
If a dock widget is movable, then it and can be moved to a new position in the
current dock container. Disable this flag to prevent moving of a dock widget
via mouse. If the `OpaqueUndocking` configuration flag is set, then dock widgets
are immediately undocked into floating widgets. That means, moving is only
possible in this case, if the dock widget is also floatable (feature flag
`DockWidgetFloatable` is set).
### `DockWidgetFloatable`
If set, a dock widget can be dragged into a floating window.
### `DockWidgetDeleteOnClose`
Deletes the dock widget and its content when it is closed.
### `CustomCloseHandling`
Clicking the close button will not close the dock widget but emits the
`closeRequested()` signal instead. This allows the application to implement
a custom close handling.
### `DockWidgetFocusable`
If this is enabled, a dock widget can get focus highlighting.
### `DockWidgetForceCloseWithArea`
A dock widget will be closed when the dock area hosting it is closed. If the
`DockWidgetDeleteOnClose` feature is enabled for a dock widget, then it will
be deleted, if the user clicks the close button of this dock widget. If the
user clicks the close button of the dock area that contains this widget,
then only the visibility of the dock widget is toggled. If this feature flag
is set, the closing the dock area also closes the dock widget. That means, if
the dock widget feature `DockWidgetDeleteOnClose` is set for the dock widgets
in a dock area, then all dock widgets will be deleted if the dock area is closed.
### `NoTab`
A dock widget tab will never be shown if this flag is set.
### `DeleteContentOnClose`
Deletes only the contained widget on close, keeping the dock widget intact and
in place. Attempts to rebuild the contents widget on show if there is a widget
factory set. See [issue #365](https://github.com/githubuser0xFFFF/Qt-Advanced-Docking-System/pull/365) for more details.
## Central Widget
The Advanced Docking System has been developed to overcome the limitations of

View File

@@ -1,6 +1,7 @@
cmake_minimum_required(VERSION 3.5)
project(QtADSExamples LANGUAGES CXX VERSION ${VERSION_SHORT})
add_subdirectory(simple)
add_subdirectory(hideshow)
add_subdirectory(sidebar)
add_subdirectory(deleteonclose)
add_subdirectory(centralwidget)

View File

@@ -3,6 +3,7 @@ TEMPLATE = subdirs
SUBDIRS = \
centralwidget \
simple \
hideshow \
sidebar \
deleteonclose \
emptydockarea \

View File

@@ -0,0 +1,28 @@
cmake_minimum_required(VERSION 3.5)
project(ads_example_hideshow VERSION ${VERSION_SHORT})
find_package(QT NAMES Qt6 Qt5 COMPONENTS Core REQUIRED)
find_package(Qt${QT_VERSION_MAJOR} 5.5 COMPONENTS Core Gui Widgets REQUIRED)
set(CMAKE_INCLUDE_CURRENT_DIR ON)
add_executable(HideShowExample WIN32
main.cpp
MainWindow.cpp
MainWindow.ui
)
target_include_directories(HideShowExample PRIVATE "${CMAKE_CURRENT_SOURCE_DIR}/../../src")
target_link_libraries(HideShowExample PRIVATE qtadvanceddocking)
target_link_libraries(HideShowExample PUBLIC Qt${QT_VERSION_MAJOR}::Core
Qt${QT_VERSION_MAJOR}::Gui
Qt${QT_VERSION_MAJOR}::Widgets)
set_target_properties(HideShowExample PROPERTIES
AUTOMOC ON
AUTORCC ON
AUTOUIC ON
CXX_STANDARD 14
CXX_STANDARD_REQUIRED ON
CXX_EXTENSIONS OFF
VERSION ${VERSION_SHORT}
EXPORT_NAME "Qt Advanced Docking System Hide,Show Example"
ARCHIVE_OUTPUT_DIRECTORY "${CMAKE_BINARY_DIR}/${ads_PlatformDir}/lib"
LIBRARY_OUTPUT_DIRECTORY "${CMAKE_BINARY_DIR}/${ads_PlatformDir}/lib"
RUNTIME_OUTPUT_DIRECTORY "${CMAKE_BINARY_DIR}/${ads_PlatformDir}/bin"
)

View File

@@ -0,0 +1,78 @@
#include "../../examples/hideshow/MainWindow.h"
#include "ui_MainWindow.h"
#include <QLabel>
#include <QPushButton>
MainWindow::MainWindow(QWidget *parent) :
QMainWindow(parent),
ui(new Ui::MainWindow)
{
ui->setupUi(this);
ui->centralWidget->setLayout( m_layout = new QStackedLayout() );
m_welcomeWidget = new QWidget(this);
auto welcomeLayout = new QVBoxLayout(m_welcomeWidget);
welcomeLayout->addStretch();
QPushButton* openButton = new QPushButton("Open project");
welcomeLayout->addWidget( openButton );
welcomeLayout->addStretch();
connect( openButton, SIGNAL(clicked()), this, SLOT(openProject()) );
m_DockManager = new ads::CDockManager(ui->centralWidget);
// Create example content label - this can be any application specific
// widget
QLabel* l = new QLabel();
l->setWordWrap(true);
l->setAlignment(Qt::AlignTop | Qt::AlignLeft);
l->setText("Lorem ipsum dolor sit amet, consectetuer adipiscing elit. ");
// 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");
DockWidget->setWidget(l);
// Add the toggleViewAction of the dock widget to the menu to give
// the user the possibility to show the dock widget if it has been closed
ui->menuView->addAction(DockWidget->toggleViewAction());
connect( ui->actionOpen, SIGNAL(triggered()), this, SLOT(openProject()) );
connect( ui->actionClose, SIGNAL(triggered()), this, SLOT(closeProject()) );
// Add the dock widget to the top dock widget area
m_DockManager->addDockWidget(ads::TopDockWidgetArea, DockWidget);
ui->centralWidget->layout()->addWidget( m_welcomeWidget );
ui->centralWidget->layout()->addWidget( m_DockManager );
closeProject();
}
MainWindow::~MainWindow()
{
delete ui;
}
void MainWindow::openProject()
{
ui->actionOpen->setEnabled(false);
ui->actionClose->setEnabled(true);
ui->menuView->setEnabled(true);
m_layout->setCurrentWidget( m_DockManager );
}
void MainWindow::closeProject()
{
ui->actionOpen->setEnabled(true);
ui->actionClose->setEnabled(false);
ui->menuView->setEnabled(false);
m_DockManager->hideManagerAndFloatingWidgets();
m_layout->setCurrentWidget( m_welcomeWidget );
}

View File

@@ -0,0 +1,33 @@
#ifndef MAINWINDOW_H
#define MAINWINDOW_H
#include <QMainWindow>
#include <QStackedLayout>
#include "DockManager.h"
QT_BEGIN_NAMESPACE
namespace Ui {
class MainWindow;
}
QT_END_NAMESPACE
class MainWindow : public QMainWindow
{
Q_OBJECT
public:
explicit MainWindow(QWidget *parent = 0);
~MainWindow();
private slots:
void openProject();
void closeProject();
private:
Ui::MainWindow *ui;
QWidget* m_welcomeWidget;
ads::CDockManager* m_DockManager;
QStackedLayout* m_layout;
};
#endif // MAINWINDOW_H

View File

@@ -0,0 +1,56 @@
<?xml version="1.0" encoding="UTF-8"?>
<ui version="4.0">
<class>MainWindow</class>
<widget class="QMainWindow" name="MainWindow">
<property name="geometry">
<rect>
<x>0</x>
<y>0</y>
<width>400</width>
<height>300</height>
</rect>
</property>
<property name="windowTitle">
<string>MainWindow</string>
</property>
<widget class="QWidget" name="centralWidget"/>
<widget class="QMenuBar" name="menuBar">
<property name="geometry">
<rect>
<x>0</x>
<y>0</y>
<width>400</width>
<height>26</height>
</rect>
</property>
<widget class="QMenu" name="menuView">
<property name="title">
<string>View</string>
</property>
</widget>
<widget class="QMenu" name="menuFile">
<property name="title">
<string>File</string>
</property>
<addaction name="actionOpen"/>
<addaction name="actionClose"/>
</widget>
<addaction name="menuFile"/>
<addaction name="menuView"/>
</widget>
<widget class="QStatusBar" name="statusBar"/>
<action name="actionOpen">
<property name="text">
<string>Open project</string>
</property>
</action>
<action name="actionClose">
<property name="text">
<string>Close project</string>
</property>
</action>
</widget>
<layoutdefault spacing="6" margin="11"/>
<resources/>
<connections/>
</ui>

View File

@@ -0,0 +1,31 @@
ADS_OUT_ROOT = $${OUT_PWD}/../..
QT += core gui widgets
TARGET = HideShowExample
DESTDIR = $${ADS_OUT_ROOT}/lib
TEMPLATE = app
CONFIG += c++14
CONFIG += debug_and_release
adsBuildStatic {
DEFINES += ADS_STATIC
}
DEFINES += QT_DEPRECATED_WARNINGS
SOURCES += \
main.cpp \
MainWindow.cpp
HEADERS += \
MainWindow.h
FORMS += \
MainWindow.ui
LIBS += -L$${ADS_OUT_ROOT}/lib
include(../../ads.pri)
INCLUDEPATH += ../../src
DEPENDPATH += ../../src

View File

@@ -0,0 +1,11 @@
#include <QApplication>
#include "../../examples/hideshow/MainWindow.h"
int main(int argc, char *argv[])
{
QApplication a(argc, argv);
MainWindow w;
w.show();
return a.exec();
}

View File

@@ -367,7 +367,8 @@ Q_SIGNALS:
*/
void viewToggled(bool Open);
}; // class DockAreaWidget
}
// namespace ads
} // namespace ads
Q_DECLARE_OPERATORS_FOR_FLAGS(ads::CDockAreaWidget::DockAreaFlags)
//-----------------------------------------------------------------------------
#endif // DockAreaWidgetH

View File

@@ -1286,7 +1286,7 @@ CDockContainerWidget::CDockContainerWidget(CDockManager* DockManager, QWidget *p
d->isFloating = floatingWidget() != nullptr;
d->Layout = new QGridLayout();
d->Layout->setContentsMargins(0, 1, 0, 1);
d->Layout->setContentsMargins(0, 0, 0, 0);
d->Layout->setSpacing(0);
setLayout(d->Layout);
@@ -1625,6 +1625,21 @@ QList<CDockAreaWidget*> CDockContainerWidget::openedDockAreas() const
}
//============================================================================
bool CDockContainerWidget::hasOpenDockAreas() const
{
for (auto DockArea : d->DockAreas)
{
if (!DockArea->isHidden())
{
return true;
}
}
return false;
}
//============================================================================
void CDockContainerWidget::saveState(QXmlStreamWriter& s) const
{
@@ -1680,7 +1695,10 @@ bool CDockContainerWidget::restoreState(CDockingStateReader& s, bool Testing)
if (!Testing)
{
CFloatingDockContainer* FloatingWidget = floatingWidget();
FloatingWidget->restoreGeometry(Geometry);
if (FloatingWidget)
{
FloatingWidget->restoreGeometry(Geometry);
}
}
}

View File

@@ -216,6 +216,13 @@ public:
*/
QList<CDockAreaWidget*> openedDockAreas() const;
/**
* This function returns true, if the container has open dock areas.
* This functions is a little bit faster than calling openedDockAreas().isEmpty()
* because it returns as soon as it finds an open dock area
*/
bool hasOpenDockAreas() const;
/**
* This function returns true if this dock area has only one single
* visible dock widget.

View File

@@ -32,6 +32,8 @@
namespace ads
{
static const char* const FocusedDockWidgetProperty = "FocusedDockWidget";
/**
* Private data class of CDockFocusController class (pimpl)
*/
@@ -57,8 +59,8 @@ struct DockFocusControllerPrivate
* the dock area that it belongs to
*/
void updateDockWidgetFocus(CDockWidget* DockWidget);
};
// struct DockFocusControllerPrivate
}; // struct DockFocusControllerPrivate
//===========================================================================
@@ -125,7 +127,7 @@ void DockFocusControllerPrivate::updateDockWidgetFocus(CDockWidget* DockWidget)
if (Window)
{
Window->setProperty("FocusedDockWidget", QVariant::fromValue<CDockWidget*>(DockWidget));
Window->setProperty(FocusedDockWidgetProperty, QVariant::fromValue(QPointer<CDockWidget>(DockWidget)));
}
CDockAreaWidget* NewFocusedDockArea = nullptr;
if (FocusedDockWidget)
@@ -161,7 +163,7 @@ void DockFocusControllerPrivate::updateDockWidgetFocus(CDockWidget* DockWidget)
if (NewFloatingWidget)
{
NewFloatingWidget->setProperty("FocusedDockWidget", QVariant::fromValue(DockWidget));
NewFloatingWidget->setProperty(FocusedDockWidgetProperty, QVariant::fromValue(QPointer<CDockWidget>(DockWidget)));
}
@@ -243,13 +245,13 @@ void CDockFocusController::onFocusWindowChanged(QWindow *focusWindow)
return;
}
auto vDockWidget = focusWindow->property("FocusedDockWidget");
auto vDockWidget = focusWindow->property(FocusedDockWidgetProperty);
if (!vDockWidget.isValid())
{
return;
}
auto DockWidget = vDockWidget.value<CDockWidget*>();
auto DockWidget = vDockWidget.value<QPointer<CDockWidget>>();
if (!DockWidget)
{
return;
@@ -376,13 +378,13 @@ void CDockFocusController::notifyFloatingWidgetDrop(CFloatingDockContainer* Floa
return;
}
auto vDockWidget = FloatingWidget->property("FocusedDockWidget");
auto vDockWidget = FloatingWidget->property(FocusedDockWidgetProperty);
if (!vDockWidget.isValid())
{
return;
}
auto DockWidget = vDockWidget.value<CDockWidget*>();
auto DockWidget = vDockWidget.value<QPointer<CDockWidget>>();
if (DockWidget)
{
DockWidget->dockAreaWidget()->setCurrentDockWidget(DockWidget);

View File

@@ -98,6 +98,7 @@ struct DockManagerPrivate
{
CDockManager* _this;
QList<CFloatingDockContainer*> FloatingWidgets;
QList<CFloatingDockContainer*> HiddenFloatingWidgets;
QList<CDockContainerWidget*> Containers;
CDockOverlay* ContainerOverlay;
CDockOverlay* DockAreaOverlay;
@@ -755,6 +756,9 @@ CFloatingDockContainer* CDockManager::addDockWidgetFloating(CDockWidget* Dockwid
void CDockManager::showEvent(QShowEvent *event)
{
Super::showEvent(event);
// Fix Issue #380
restoreHiddenFloatingWidgets();
if (d->UninitializedFloatingWidgets.empty())
{
return;
@@ -762,12 +766,52 @@ void CDockManager::showEvent(QShowEvent *event)
for (auto FloatingWidget : d->UninitializedFloatingWidgets)
{
FloatingWidget->show();
// Check, if someone closed a floating dock widget before the dock
// manager is shown
if (FloatingWidget->dockContainer()->hasOpenDockAreas())
{
FloatingWidget->show();
}
}
d->UninitializedFloatingWidgets.clear();
}
//============================================================================
void CDockManager::restoreHiddenFloatingWidgets()
{
if (d->HiddenFloatingWidgets.isEmpty())
{
return;
}
// Restore floating widgets that were hidden upon hideManagerAndFloatingWidgets
for (auto FloatingWidget : d->HiddenFloatingWidgets)
{
bool hasDockWidgetVisible = false;
// Needed to prevent CFloatingDockContainer being shown empty
// Could make sense to move this to CFloatingDockContainer::showEvent(QShowEvent *event)
// if experiencing CFloatingDockContainer being shown empty in other situations, but let's keep
// it here for now to make sure changes to fix Issue #380 does not impact existing behaviours
for (auto dockWidget : FloatingWidget->dockWidgets())
{
if (dockWidget->toggleViewAction()->isChecked())
{
dockWidget->toggleView(true);
hasDockWidgetVisible = true;
}
}
if (hasDockWidgetVisible)
{
FloatingWidget->show();
}
}
d->HiddenFloatingWidgets.clear();
}
//============================================================================
CDockAreaWidget* CDockManager::addDockWidget(DockWidgetArea area,
CDockWidget* Dockwidget, CDockAreaWidget* DockAreaWidget)
@@ -779,6 +823,16 @@ CDockAreaWidget* CDockManager::addDockWidget(DockWidgetArea area,
return AreaOfAddedDockWidget;
}
//============================================================================
CDockAreaWidget* CDockManager::addDockWidgetToContainer(DockWidgetArea area,
CDockWidget* Dockwidget, CDockContainerWidget* DockContainerWidget)
{
d->DockWidgetsMap.insert(Dockwidget->objectName(), Dockwidget);
auto AreaOfAddedDockWidget = DockContainerWidget->addDockWidget(area, Dockwidget);
Q_EMIT dockWidgetAdded(Dockwidget);
return AreaOfAddedDockWidget;
}
//============================================================================
CDockAreaWidget* CDockManager::addDockWidgetTab(DockWidgetArea area,
@@ -1097,6 +1151,38 @@ void CDockManager::setDockWidgetFocused(CDockWidget* DockWidget)
}
}
//===========================================================================
void CDockManager::hideManagerAndFloatingWidgets()
{
hide();
d->HiddenFloatingWidgets.clear();
// Hide updates of floating widgets from user
for (auto FloatingWidget : d->FloatingWidgets)
{
if ( FloatingWidget->isVisible() )
{
QList<CDockWidget*> VisibleWidgets;
for ( auto dockWidget : FloatingWidget->dockWidgets() )
{
if ( dockWidget->toggleViewAction()->isChecked() )
VisibleWidgets.push_back( dockWidget );
}
// save as floating widget to be shown when CDockManager will be shown back
d->HiddenFloatingWidgets.push_back( FloatingWidget );
FloatingWidget->hide();
// hidding floating widget automatically marked contained CDockWidgets as hidden
// but they must remain marked as visible as we want them to be restored visible
// when CDockManager will be shown back
for ( auto dockWidget : VisibleWidgets )
{
dockWidget->toggleViewAction()->setChecked(true);
}
}
}
}
//===========================================================================
CDockWidget* CDockManager::focusedDockWidget() const

View File

@@ -147,6 +147,11 @@ protected:
*/
CDockFocusController* dockFocusController() const;
/**
* Restore floating widgets hidden by an earlier call to hideManagerAndFloatingWidgets.
*/
void restoreHiddenFloatingWidgets();
public:
using Super = CDockContainerWidget;
@@ -278,6 +283,15 @@ public:
CDockAreaWidget* addDockWidget(DockWidgetArea area, CDockWidget* Dockwidget,
CDockAreaWidget* DockAreaWidget = nullptr);
/**
* Adds dockwidget into the given container.
* This allows you to place the dock widget into a container, even if that
* container does not yet contain a DockAreaWidget.
* \return Returns the dock area widget that contains the new DockWidget
*/
CDockAreaWidget* addDockWidgetToContainer(DockWidgetArea area, CDockWidget* Dockwidget,
CDockContainerWidget* DockContainerWidget);
/**
* This function will add the given Dockwidget to the given dock area as
* a new tab.
@@ -527,6 +541,12 @@ public Q_SLOTS:
*/
void setDockWidgetFocused(CDockWidget* DockWidget);
/**
* hide CDockManager and all floating widgets (See Issue #380). Calling regular QWidget::hide()
* hides the CDockManager but not the floating widgets;
*/
void hideManagerAndFloatingWidgets();
Q_SIGNALS:
/**
* This signal is emitted if the list of perspectives changed.
@@ -617,5 +637,7 @@ Q_SIGNALS:
void focusedDockWidgetChanged(ads::CDockWidget* old, ads::CDockWidget* now);
}; // class DockManager
} // namespace ads
Q_DECLARE_OPERATORS_FOR_FLAGS(ads::CDockManager::ConfigFlags)
//-----------------------------------------------------------------------------
#endif // DockManagerH

View File

@@ -893,7 +893,10 @@ void CDockWidget::setFloating()
//============================================================================
void CDockWidget::deleteDockWidget()
{
dockManager()->removeDockWidget(this);
auto manager=dockManager();
if(manager){
manager->removeDockWidget(this);
}
deleteLater();
d->Closed = true;
}

View File

@@ -600,7 +600,8 @@ Q_SIGNALS:
*/
void featuresChanged(ads::CDockWidget::DockWidgetFeatures features);
}; // class DockWidget
}
// namespace ads
} // namespace ads
Q_DECLARE_OPERATORS_FOR_FLAGS(ads::CDockWidget::DockWidgetFeatures)
//-----------------------------------------------------------------------------
#endif // DockWidgetH

View File

@@ -407,7 +407,7 @@ void CDockWidgetTab::mouseReleaseEvent(QMouseEvent* ev)
}
else if (ev->button() == Qt::MiddleButton)
{
if (CDockManager::testConfigFlag(CDockManager::MiddleMouseButtonClosesTab))
if (CDockManager::testConfigFlag(CDockManager::MiddleMouseButtonClosesTab) && d->DockWidget->features().testFlag(CDockWidget::DockWidgetClosable))
{
// Only attempt to close if the mouse is still
// on top of the widget, to allow the user to cancel.

View File

@@ -163,8 +163,8 @@ void CElidingLabel::resizeEvent(QResizeEvent *event)
//============================================================================
QSize CElidingLabel::minimumSizeHint() const
{
#if (QT_VERSION >= QT_VERSION_CHECK(6, 0, 0))
bool HasPixmap = !pixmap().isNull();
#if (QT_VERSION >= QT_VERSION_CHECK(5, 15, 0))
bool HasPixmap = !pixmap(Qt::ReturnByValue).isNull();
#else
bool HasPixmap = (pixmap() != nullptr);
#endif
@@ -185,8 +185,8 @@ QSize CElidingLabel::minimumSizeHint() const
//============================================================================
QSize CElidingLabel::sizeHint() const
{
#if (QT_VERSION >= QT_VERSION_CHECK(6, 0, 0))
bool HasPixmap = !pixmap().isNull();
#if (QT_VERSION >= QT_VERSION_CHECK(5, 15, 0))
bool HasPixmap = !pixmap(Qt::ReturnByValue).isNull();
#else
bool HasPixmap = (pixmap() != nullptr);
#endif

View File

@@ -308,5 +308,6 @@ void repolishStyle(QWidget* w, eRepolishChildOptions Options = RepolishIgnoreChi
} // namespace internal
} // namespace ads
Q_DECLARE_OPERATORS_FOR_FLAGS(ads::DockWidgetAreas)
//---------------------------------------------------------------------------
#endif // ads_globalsH

View File

@@ -4,6 +4,9 @@
ads--CDockContainerWidget {
background: palette(dark);
}
ads--CDockContainerWidget > QSplitter{
padding: 1 0 1 0;
}
ads--CDockContainerWidget ads--CDockSplitter::handle {
background: palette(dark);

View File

@@ -4,6 +4,9 @@
ads--CDockContainerWidget {
background: palette(dark);
}
ads--CDockContainerWidget > QSplitter{
padding: 1 0 1 0;
}
ads--CDockContainerWidget ads--CDockSplitter::handle {
background: palette(dark);

View File

@@ -4,6 +4,9 @@
ads--CDockContainerWidget {
background: palette(dark);
}
ads--CDockContainerWidget > QSplitter{
padding: 1 0 1 0;
}
ads--CDockAreaWidget {
background: palette(window);

View File

@@ -4,6 +4,10 @@
ads--CDockContainerWidget {
background: palette(dark);
}
ads--CDockContainerWidget > QSplitter{
padding: 1 0 1 0;
}
ads--CDockContainerWidget ads--CDockSplitter::handle {
background: palette(dark);