mirror of
https://github.com/githubuser0xFFFF/Qt-Advanced-Docking-System.git
synced 2024-12-25 23:51:33 +08:00
Merge branch 'centralwidget'
This commit is contained in:
commit
5443e5f998
1
.gitignore
vendored
1
.gitignore
vendored
@ -382,3 +382,4 @@ MigrationBackup/
|
|||||||
FodyWeavers.xsd
|
FodyWeavers.xsd
|
||||||
/ build
|
/ build
|
||||||
/Settings.ini
|
/Settings.ini
|
||||||
|
.vscode/settings.json
|
||||||
|
@ -3,3 +3,4 @@ project(QtADSExamples LANGUAGES CXX VERSION ${VERSION_SHORT})
|
|||||||
add_subdirectory(simple)
|
add_subdirectory(simple)
|
||||||
add_subdirectory(sidebar)
|
add_subdirectory(sidebar)
|
||||||
add_subdirectory(deleteonclose)
|
add_subdirectory(deleteonclose)
|
||||||
|
add_subdirectory(centralwidget)
|
25
examples/centralwidget/CMakeLists.txt
Normal file
25
examples/centralwidget/CMakeLists.txt
Normal file
@ -0,0 +1,25 @@
|
|||||||
|
cmake_minimum_required(VERSION 3.5)
|
||||||
|
project(ads_example_centralwidget VERSION ${VERSION_SHORT})
|
||||||
|
find_package(Qt5 5.5 COMPONENTS Core Gui Widgets REQUIRED)
|
||||||
|
set(CMAKE_INCLUDE_CURRENT_DIR ON)
|
||||||
|
add_executable(CentralWidgetExample WIN32
|
||||||
|
main.cpp
|
||||||
|
mainwindow.cpp
|
||||||
|
mainwindow.ui
|
||||||
|
)
|
||||||
|
target_include_directories(CentralWidgetExample PRIVATE "${CMAKE_CURRENT_SOURCE_DIR}/../../src")
|
||||||
|
target_link_libraries(CentralWidgetExample PRIVATE qtadvanceddocking)
|
||||||
|
target_link_libraries(CentralWidgetExample PUBLIC Qt5::Core Qt5::Gui Qt5::Widgets)
|
||||||
|
set_target_properties(CentralWidgetExample 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 Central Widget 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"
|
||||||
|
)
|
54
examples/centralwidget/centralwidget.pro
Normal file
54
examples/centralwidget/centralwidget.pro
Normal file
@ -0,0 +1,54 @@
|
|||||||
|
ADS_OUT_ROOT = $${OUT_PWD}/../..
|
||||||
|
|
||||||
|
QT += core gui
|
||||||
|
|
||||||
|
greaterThan(QT_MAJOR_VERSION, 4): QT += widgets
|
||||||
|
|
||||||
|
TARGET = CentralWidgetExample
|
||||||
|
DESTDIR = $${ADS_OUT_ROOT}/lib
|
||||||
|
TEMPLATE = app
|
||||||
|
CONFIG += c++14
|
||||||
|
CONFIG += debug_and_release
|
||||||
|
|
||||||
|
# The following define makes your compiler emit warnings if you use
|
||||||
|
# any Qt feature that has been marked deprecated (the exact warnings
|
||||||
|
# depend on your compiler). Please consult the documentation of the
|
||||||
|
# deprecated API in order to know how to port your code away from it.
|
||||||
|
DEFINES += QT_DEPRECATED_WARNINGS
|
||||||
|
|
||||||
|
# You can also make your code fail to compile if it uses deprecated APIs.
|
||||||
|
# In order to do so, uncomment the following line.
|
||||||
|
# You can also select to disable deprecated APIs only up to a certain version of Qt.
|
||||||
|
#DEFINES += QT_DISABLE_DEPRECATED_BEFORE=0x060000 # disables all the APIs deprecated before Qt 6.0.0
|
||||||
|
|
||||||
|
SOURCES += \
|
||||||
|
main.cpp \
|
||||||
|
mainwindow.cpp
|
||||||
|
|
||||||
|
HEADERS += \
|
||||||
|
mainwindow.h
|
||||||
|
|
||||||
|
FORMS += \
|
||||||
|
mainwindow.ui
|
||||||
|
|
||||||
|
LIBS += -L$${ADS_OUT_ROOT}/lib
|
||||||
|
|
||||||
|
# Dependency: AdvancedDockingSystem (shared)
|
||||||
|
CONFIG(debug, debug|release){
|
||||||
|
win32 {
|
||||||
|
LIBS += -lqtadvanceddockingd
|
||||||
|
}
|
||||||
|
else:mac {
|
||||||
|
LIBS += -lqtadvanceddocking_debug
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
LIBS += -lqtadvanceddocking
|
||||||
|
}
|
||||||
|
}
|
||||||
|
else{
|
||||||
|
LIBS += -lqtadvanceddocking
|
||||||
|
}
|
||||||
|
|
||||||
|
INCLUDEPATH += ../../src
|
||||||
|
DEPENDPATH += ../../src
|
||||||
|
|
10
examples/centralwidget/main.cpp
Normal file
10
examples/centralwidget/main.cpp
Normal file
@ -0,0 +1,10 @@
|
|||||||
|
#include <mainwindow.h>
|
||||||
|
#include <QApplication>
|
||||||
|
|
||||||
|
int main(int argc, char *argv[])
|
||||||
|
{
|
||||||
|
QApplication a(argc, argv);
|
||||||
|
CMainWindow w;
|
||||||
|
w.show();
|
||||||
|
return a.exec();
|
||||||
|
}
|
83
examples/centralwidget/mainwindow.cpp
Normal file
83
examples/centralwidget/mainwindow.cpp
Normal file
@ -0,0 +1,83 @@
|
|||||||
|
#include "mainwindow.h"
|
||||||
|
|
||||||
|
#include "ui_mainwindow.h"
|
||||||
|
|
||||||
|
#include <QWidgetAction>
|
||||||
|
#include <QLabel>
|
||||||
|
#include <QCalendarWidget>
|
||||||
|
#include <QTreeView>
|
||||||
|
#include <QFileSystemModel>
|
||||||
|
#include <QTableWidget>
|
||||||
|
#include <QHBoxLayout>
|
||||||
|
#include <QRadioButton>
|
||||||
|
#include <QPushButton>
|
||||||
|
#include <QInputDialog>
|
||||||
|
#include <QFileDialog>
|
||||||
|
#include <QSettings>
|
||||||
|
#include <QMessageBox>
|
||||||
|
|
||||||
|
#include "DockAreaWidget.h"
|
||||||
|
#include "DockAreaTitleBar.h"
|
||||||
|
#include "DockAreaTabBar.h"
|
||||||
|
#include "FloatingDockContainer.h"
|
||||||
|
#include "DockComponentsFactory.h"
|
||||||
|
|
||||||
|
using namespace ads;
|
||||||
|
|
||||||
|
CMainWindow::CMainWindow(QWidget *parent)
|
||||||
|
: QMainWindow(parent)
|
||||||
|
, ui(new Ui::CMainWindow)
|
||||||
|
{
|
||||||
|
ui->setupUi(this);
|
||||||
|
CDockManager::setConfigFlag(CDockManager::OpaqueSplitterResize, true);
|
||||||
|
CDockManager::setConfigFlag(CDockManager::XmlCompressionEnabled, false);
|
||||||
|
DockManager = new CDockManager(this);
|
||||||
|
|
||||||
|
// Set central widget
|
||||||
|
QCalendarWidget* calendar = new QCalendarWidget();
|
||||||
|
CDockWidget* CentralDockWidget = new CDockWidget("CentralWidget");
|
||||||
|
CentralDockWidget->setWidget(calendar);
|
||||||
|
auto* CentralDockArea = DockManager->setCentralWidget(CentralDockWidget);
|
||||||
|
CentralDockArea->setAllowedAreas(DockWidgetArea::OuterDockAreas);
|
||||||
|
|
||||||
|
// create other dock widgets
|
||||||
|
QTreeView* fileTree = new QTreeView();
|
||||||
|
fileTree->setFrameShape(QFrame::NoFrame);
|
||||||
|
QFileSystemModel* fileModel = new QFileSystemModel(fileTree);
|
||||||
|
fileModel->setRootPath(QDir::currentPath());
|
||||||
|
fileTree->setModel(fileModel);
|
||||||
|
CDockWidget* DataDockWidget = new CDockWidget("File system");
|
||||||
|
DataDockWidget->setWidget(fileTree);
|
||||||
|
DataDockWidget->resize(150, 250);
|
||||||
|
DataDockWidget->setMinimumSize(100, 250);
|
||||||
|
auto* fileArea = DockManager->addDockWidget(DockWidgetArea::LeftDockWidgetArea, DataDockWidget, CentralDockArea);
|
||||||
|
ui->menuView->addAction(DataDockWidget->toggleViewAction());
|
||||||
|
|
||||||
|
QTableWidget* table = new QTableWidget();
|
||||||
|
table->setColumnCount(3);
|
||||||
|
table->setRowCount(10);
|
||||||
|
CDockWidget* TableDockWidget = new CDockWidget("Table");
|
||||||
|
TableDockWidget->setWidget(table);
|
||||||
|
TableDockWidget->setMinimumSizeHintMode(CDockWidget::MinimumSizeHintFromDockWidget);
|
||||||
|
TableDockWidget->resize(250, 150);
|
||||||
|
TableDockWidget->setMinimumSize(200,150);
|
||||||
|
DockManager->addDockWidget(DockWidgetArea::BottomDockWidgetArea, TableDockWidget, fileArea);
|
||||||
|
ui->menuView->addAction(TableDockWidget->toggleViewAction());
|
||||||
|
|
||||||
|
QTableWidget* propertiesTable = new QTableWidget();
|
||||||
|
table->setColumnCount(3);
|
||||||
|
table->setRowCount(10);
|
||||||
|
CDockWidget* PropertiesDockWidget = new CDockWidget("Properties");
|
||||||
|
PropertiesDockWidget->setWidget(propertiesTable);
|
||||||
|
PropertiesDockWidget->setMinimumSizeHintMode(CDockWidget::MinimumSizeHintFromDockWidget);
|
||||||
|
PropertiesDockWidget->resize(250, 150);
|
||||||
|
PropertiesDockWidget->setMinimumSize(200,150);
|
||||||
|
DockManager->addDockWidget(DockWidgetArea::RightDockWidgetArea, PropertiesDockWidget, CentralDockArea);
|
||||||
|
ui->menuView->addAction(PropertiesDockWidget->toggleViewAction());
|
||||||
|
}
|
||||||
|
|
||||||
|
CMainWindow::~CMainWindow()
|
||||||
|
{
|
||||||
|
delete ui;
|
||||||
|
}
|
||||||
|
|
32
examples/centralwidget/mainwindow.h
Normal file
32
examples/centralwidget/mainwindow.h
Normal file
@ -0,0 +1,32 @@
|
|||||||
|
#ifndef MAINWINDOW_H
|
||||||
|
#define MAINWINDOW_H
|
||||||
|
|
||||||
|
#include <QMainWindow>
|
||||||
|
|
||||||
|
#include "DockManager.h"
|
||||||
|
#include "DockAreaWidget.h"
|
||||||
|
#include "DockWidget.h"
|
||||||
|
|
||||||
|
QT_BEGIN_NAMESPACE
|
||||||
|
namespace Ui { class CMainWindow; }
|
||||||
|
QT_END_NAMESPACE
|
||||||
|
|
||||||
|
class CMainWindow : public QMainWindow
|
||||||
|
{
|
||||||
|
Q_OBJECT
|
||||||
|
|
||||||
|
public:
|
||||||
|
CMainWindow(QWidget *parent = nullptr);
|
||||||
|
~CMainWindow();
|
||||||
|
|
||||||
|
private:
|
||||||
|
static const QString kTableTopLayout;
|
||||||
|
static const QString kTableBottomLayout;
|
||||||
|
|
||||||
|
Ui::CMainWindow *ui;
|
||||||
|
|
||||||
|
ads::CDockManager* DockManager;
|
||||||
|
ads::CDockAreaWidget* StatusDockArea;
|
||||||
|
ads::CDockWidget* TimelineDockWidget;
|
||||||
|
};
|
||||||
|
#endif // MAINWINDOW_H
|
36
examples/centralwidget/mainwindow.ui
Normal file
36
examples/centralwidget/mainwindow.ui
Normal file
@ -0,0 +1,36 @@
|
|||||||
|
<?xml version="1.0" encoding="UTF-8"?>
|
||||||
|
<ui version="4.0">
|
||||||
|
<class>CMainWindow</class>
|
||||||
|
<widget class="QMainWindow" name="CMainWindow">
|
||||||
|
<property name="geometry">
|
||||||
|
<rect>
|
||||||
|
<x>0</x>
|
||||||
|
<y>0</y>
|
||||||
|
<width>1284</width>
|
||||||
|
<height>757</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>1284</width>
|
||||||
|
<height>21</height>
|
||||||
|
</rect>
|
||||||
|
</property>
|
||||||
|
<widget class="QMenu" name="menuView">
|
||||||
|
<property name="title">
|
||||||
|
<string>View</string>
|
||||||
|
</property>
|
||||||
|
</widget>
|
||||||
|
<addaction name="menuView"/>
|
||||||
|
</widget>
|
||||||
|
</widget>
|
||||||
|
<resources/>
|
||||||
|
<connections/>
|
||||||
|
</ui>
|
@ -1,6 +1,7 @@
|
|||||||
TEMPLATE = subdirs
|
TEMPLATE = subdirs
|
||||||
|
|
||||||
SUBDIRS = \
|
SUBDIRS = \
|
||||||
|
centralwidget \
|
||||||
simple \
|
simple \
|
||||||
sidebar \
|
sidebar \
|
||||||
deleteonclose
|
deleteonclose
|
||||||
|
@ -441,6 +441,7 @@ void CDockAreaWidget::insertDockWidget(int index, CDockWidget* DockWidget,
|
|||||||
DockWidget->toggleViewInternal(true);
|
DockWidget->toggleViewInternal(true);
|
||||||
}
|
}
|
||||||
d->updateTitleBarButtonStates();
|
d->updateTitleBarButtonStates();
|
||||||
|
updateTitleBarVisibility();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@ -955,6 +956,18 @@ CDockAreaTitleBar* CDockAreaWidget::titleBar() const
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
//============================================================================
|
||||||
|
bool CDockAreaWidget::isCentralWidgetArea() const
|
||||||
|
{
|
||||||
|
if (dockWidgetsCount()!= 1)
|
||||||
|
{
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
return dockManager()->centralWidget() == dockWidgets()[0];
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
//============================================================================
|
//============================================================================
|
||||||
QSize CDockAreaWidget::minimumSizeHint() const
|
QSize CDockAreaWidget::minimumSizeHint() const
|
||||||
{
|
{
|
||||||
|
@ -307,6 +307,11 @@ public:
|
|||||||
*/
|
*/
|
||||||
void setDockAreaFlag(eDockAreaFlag Flag, bool On);
|
void setDockAreaFlag(eDockAreaFlag Flag, bool On);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Returns true if the area contains the central widget of it's manager.
|
||||||
|
*/
|
||||||
|
bool isCentralWidgetArea() const;
|
||||||
|
|
||||||
public slots:
|
public slots:
|
||||||
/**
|
/**
|
||||||
* This activates the tab for the given tab index.
|
* This activates the tab for the given tab index.
|
||||||
|
@ -322,6 +322,18 @@ public:
|
|||||||
Splitter->setSizes(SplitterSizes);
|
Splitter->setSizes(SplitterSizes);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* This function forces the dock container widget to update handles of splitters
|
||||||
|
* based if a central widget exists.
|
||||||
|
*/
|
||||||
|
void updateSplitterHandles(QSplitter* splitter);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* If no central widget exists, the widgets resize with the container.
|
||||||
|
* If a central widget exists, the widgets surrounding the central widget
|
||||||
|
* do not resize its height or width.
|
||||||
|
*/
|
||||||
|
bool widgetResizesWithContainer(QWidget* widget);
|
||||||
|
|
||||||
// private slots: ------------------------------------------------------------
|
// private slots: ------------------------------------------------------------
|
||||||
void onDockAreaViewToggled(bool Visible)
|
void onDockAreaViewToggled(bool Visible)
|
||||||
@ -421,6 +433,7 @@ void DockContainerWidgetPrivate::dropIntoContainer(CFloatingDockContainer* Float
|
|||||||
QSplitter* NewSplitter = newSplitter(InsertParam.orientation());
|
QSplitter* NewSplitter = newSplitter(InsertParam.orientation());
|
||||||
QLayoutItem* li = Layout->replaceWidget(Splitter, NewSplitter);
|
QLayoutItem* li = Layout->replaceWidget(Splitter, NewSplitter);
|
||||||
NewSplitter->addWidget(Splitter);
|
NewSplitter->addWidget(Splitter);
|
||||||
|
updateSplitterHandles(NewSplitter);
|
||||||
Splitter = NewSplitter;
|
Splitter = NewSplitter;
|
||||||
delete li;
|
delete li;
|
||||||
}
|
}
|
||||||
@ -430,6 +443,7 @@ void DockContainerWidgetPrivate::dropIntoContainer(CFloatingDockContainer* Float
|
|||||||
if (FloatingSplitter->count() == 1)
|
if (FloatingSplitter->count() == 1)
|
||||||
{
|
{
|
||||||
insertWidgetIntoSplitter(Splitter, FloatingSplitter->widget(0), InsertParam.append());
|
insertWidgetIntoSplitter(Splitter, FloatingSplitter->widget(0), InsertParam.append());
|
||||||
|
updateSplitterHandles(Splitter);
|
||||||
}
|
}
|
||||||
else if (FloatingSplitter->orientation() == InsertParam.orientation())
|
else if (FloatingSplitter->orientation() == InsertParam.orientation())
|
||||||
{
|
{
|
||||||
@ -437,6 +451,7 @@ void DockContainerWidgetPrivate::dropIntoContainer(CFloatingDockContainer* Float
|
|||||||
while (FloatingSplitter->count())
|
while (FloatingSplitter->count())
|
||||||
{
|
{
|
||||||
Splitter->insertWidget(InsertIndex++, FloatingSplitter->widget(0));
|
Splitter->insertWidget(InsertIndex++, FloatingSplitter->widget(0));
|
||||||
|
updateSplitterHandles(Splitter);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
@ -515,6 +530,7 @@ void DockContainerWidgetPrivate::dropIntoSection(CFloatingDockContainer* Floatin
|
|||||||
QSplitter* Splitter = newSplitter(InsertParam.orientation());
|
QSplitter* Splitter = newSplitter(InsertParam.orientation());
|
||||||
Layout->replaceWidget(TargetArea, Splitter);
|
Layout->replaceWidget(TargetArea, Splitter);
|
||||||
Splitter->addWidget(TargetArea);
|
Splitter->addWidget(TargetArea);
|
||||||
|
updateSplitterHandles(Splitter);
|
||||||
TargetAreaSplitter = Splitter;
|
TargetAreaSplitter = Splitter;
|
||||||
}
|
}
|
||||||
int AreaIndex = TargetAreaSplitter->indexOf(TargetArea);
|
int AreaIndex = TargetAreaSplitter->indexOf(TargetArea);
|
||||||
@ -529,6 +545,7 @@ void DockContainerWidgetPrivate::dropIntoSection(CFloatingDockContainer* Floatin
|
|||||||
if ((FloatingSplitter->orientation() != InsertParam.orientation()) && FloatingSplitter->count() > 1)
|
if ((FloatingSplitter->orientation() != InsertParam.orientation()) && FloatingSplitter->count() > 1)
|
||||||
{
|
{
|
||||||
TargetAreaSplitter->insertWidget(AreaIndex + InsertParam.insertOffset(), Widget);
|
TargetAreaSplitter->insertWidget(AreaIndex + InsertParam.insertOffset(), Widget);
|
||||||
|
updateSplitterHandles(TargetAreaSplitter);
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
@ -537,6 +554,7 @@ void DockContainerWidgetPrivate::dropIntoSection(CFloatingDockContainer* Floatin
|
|||||||
while (FloatingSplitter->count())
|
while (FloatingSplitter->count())
|
||||||
{
|
{
|
||||||
TargetAreaSplitter->insertWidget(InsertIndex++, FloatingSplitter->widget(0));
|
TargetAreaSplitter->insertWidget(InsertIndex++, FloatingSplitter->widget(0));
|
||||||
|
updateSplitterHandles(TargetAreaSplitter);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -557,6 +575,7 @@ void DockContainerWidgetPrivate::dropIntoSection(CFloatingDockContainer* Floatin
|
|||||||
if ((FloatingSplitter->orientation() != InsertParam.orientation()) && FloatingSplitter->count() > 1)
|
if ((FloatingSplitter->orientation() != InsertParam.orientation()) && FloatingSplitter->count() > 1)
|
||||||
{
|
{
|
||||||
NewSplitter->addWidget(Widget);
|
NewSplitter->addWidget(Widget);
|
||||||
|
updateSplitterHandles(NewSplitter);
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
@ -564,6 +583,7 @@ void DockContainerWidgetPrivate::dropIntoSection(CFloatingDockContainer* Floatin
|
|||||||
while (FloatingSplitter->count())
|
while (FloatingSplitter->count())
|
||||||
{
|
{
|
||||||
NewSplitter->addWidget(FloatingSplitter->widget(0));
|
NewSplitter->addWidget(FloatingSplitter->widget(0));
|
||||||
|
updateSplitterHandles(NewSplitter);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -571,6 +591,7 @@ void DockContainerWidgetPrivate::dropIntoSection(CFloatingDockContainer* Floatin
|
|||||||
// shrinking of existing area
|
// shrinking of existing area
|
||||||
auto Sizes = TargetAreaSplitter->sizes();
|
auto Sizes = TargetAreaSplitter->sizes();
|
||||||
insertWidgetIntoSplitter(NewSplitter, TargetArea, !InsertParam.append());
|
insertWidgetIntoSplitter(NewSplitter, TargetArea, !InsertParam.append());
|
||||||
|
updateSplitterHandles(NewSplitter);
|
||||||
if (AdjustSplitterSizes)
|
if (AdjustSplitterSizes)
|
||||||
{
|
{
|
||||||
int Size = TargetAreaSize / 2;
|
int Size = TargetAreaSize / 2;
|
||||||
@ -578,6 +599,7 @@ void DockContainerWidgetPrivate::dropIntoSection(CFloatingDockContainer* Floatin
|
|||||||
}
|
}
|
||||||
TargetAreaSplitter->insertWidget(AreaIndex, NewSplitter);
|
TargetAreaSplitter->insertWidget(AreaIndex, NewSplitter);
|
||||||
TargetAreaSplitter->setSizes(Sizes);
|
TargetAreaSplitter->setSizes(Sizes);
|
||||||
|
updateSplitterHandles(TargetAreaSplitter);
|
||||||
}
|
}
|
||||||
|
|
||||||
addDockAreasToList(NewDockAreas);
|
addDockAreasToList(NewDockAreas);
|
||||||
@ -663,6 +685,7 @@ void DockContainerWidgetPrivate::moveToNewSection(QWidget* Widget, CDockAreaWidg
|
|||||||
{
|
{
|
||||||
int TargetAreaSize = (InsertParam.orientation() == Qt::Horizontal) ? TargetArea->width() : TargetArea->height();
|
int TargetAreaSize = (InsertParam.orientation() == Qt::Horizontal) ? TargetArea->width() : TargetArea->height();
|
||||||
TargetAreaSplitter->insertWidget(AreaIndex + InsertParam.insertOffset(), NewDockArea);
|
TargetAreaSplitter->insertWidget(AreaIndex + InsertParam.insertOffset(), NewDockArea);
|
||||||
|
updateSplitterHandles(TargetAreaSplitter);
|
||||||
int Size = (TargetAreaSize - TargetAreaSplitter->handleWidth()) / 2;
|
int Size = (TargetAreaSize - TargetAreaSplitter->handleWidth()) / 2;
|
||||||
Sizes[AreaIndex] = Size;
|
Sizes[AreaIndex] = Size;
|
||||||
Sizes.insert(AreaIndex, Size);
|
Sizes.insert(AreaIndex, Size);
|
||||||
@ -674,9 +697,11 @@ void DockContainerWidgetPrivate::moveToNewSection(QWidget* Widget, CDockAreaWidg
|
|||||||
QSplitter* NewSplitter = newSplitter(InsertParam.orientation());
|
QSplitter* NewSplitter = newSplitter(InsertParam.orientation());
|
||||||
NewSplitter->addWidget(TargetArea);
|
NewSplitter->addWidget(TargetArea);
|
||||||
insertWidgetIntoSplitter(NewSplitter, NewDockArea, InsertParam.append());
|
insertWidgetIntoSplitter(NewSplitter, NewDockArea, InsertParam.append());
|
||||||
|
updateSplitterHandles(NewSplitter);
|
||||||
int Size = TargetAreaSize / 2;
|
int Size = TargetAreaSize / 2;
|
||||||
NewSplitter->setSizes({Size, Size});
|
NewSplitter->setSizes({Size, Size});
|
||||||
TargetAreaSplitter->insertWidget(AreaIndex, NewSplitter);
|
TargetAreaSplitter->insertWidget(AreaIndex, NewSplitter);
|
||||||
|
updateSplitterHandles(TargetAreaSplitter);
|
||||||
}
|
}
|
||||||
TargetAreaSplitter->setSizes(Sizes);
|
TargetAreaSplitter->setSizes(Sizes);
|
||||||
|
|
||||||
@ -684,6 +709,46 @@ void DockContainerWidgetPrivate::moveToNewSection(QWidget* Widget, CDockAreaWidg
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
//============================================================================
|
||||||
|
void DockContainerWidgetPrivate::updateSplitterHandles( QSplitter* splitter )
|
||||||
|
{
|
||||||
|
if (!DockManager->centralWidget() || !splitter)
|
||||||
|
{
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
for (int i = 0; i < splitter->count(); ++i)
|
||||||
|
{
|
||||||
|
splitter->setStretchFactor(i, widgetResizesWithContainer(splitter->widget(i)) ? 1 : 0);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
//============================================================================
|
||||||
|
bool DockContainerWidgetPrivate::widgetResizesWithContainer(QWidget* widget)
|
||||||
|
{
|
||||||
|
if (!DockManager->centralWidget())
|
||||||
|
{
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
auto Area = qobject_cast<CDockAreaWidget*>(widget);
|
||||||
|
if(Area)
|
||||||
|
{
|
||||||
|
return Area->isCentralWidgetArea();
|
||||||
|
}
|
||||||
|
|
||||||
|
auto innerSplitter = qobject_cast<CDockSplitter*>(widget);
|
||||||
|
if (innerSplitter)
|
||||||
|
{
|
||||||
|
return innerSplitter->isResizingWithContainer();
|
||||||
|
}
|
||||||
|
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
//============================================================================
|
//============================================================================
|
||||||
void DockContainerWidgetPrivate::moveToContainer(QWidget* Widget, DockWidgetArea area)
|
void DockContainerWidgetPrivate::moveToContainer(QWidget* Widget, DockWidgetArea area)
|
||||||
{
|
{
|
||||||
@ -892,6 +957,10 @@ bool DockContainerWidgetPrivate::restoreSplitter(CDockingStateReader& s,
|
|||||||
Splitter->addWidget(ChildNode);
|
Splitter->addWidget(ChildNode);
|
||||||
Visible |= ChildNode->isVisibleTo(Splitter);
|
Visible |= ChildNode->isVisibleTo(Splitter);
|
||||||
}
|
}
|
||||||
|
if(!Testing)
|
||||||
|
{
|
||||||
|
updateSplitterHandles(Splitter);
|
||||||
|
}
|
||||||
|
|
||||||
if (Sizes.count() != WidgetCount)
|
if (Sizes.count() != WidgetCount)
|
||||||
{
|
{
|
||||||
@ -1069,6 +1138,7 @@ void DockContainerWidgetPrivate::addDockArea(CDockAreaWidget* NewDockArea, DockW
|
|||||||
if (Splitter->orientation() == InsertParam.orientation())
|
if (Splitter->orientation() == InsertParam.orientation())
|
||||||
{
|
{
|
||||||
insertWidgetIntoSplitter(Splitter, NewDockArea, InsertParam.append());
|
insertWidgetIntoSplitter(Splitter, NewDockArea, InsertParam.append());
|
||||||
|
updateSplitterHandles(Splitter);
|
||||||
if (Splitter->isHidden())
|
if (Splitter->isHidden())
|
||||||
{
|
{
|
||||||
Splitter->show();
|
Splitter->show();
|
||||||
@ -1082,6 +1152,7 @@ void DockContainerWidgetPrivate::addDockArea(CDockAreaWidget* NewDockArea, DockW
|
|||||||
QLayoutItem* li = Layout->replaceWidget(Splitter, NewSplitter);
|
QLayoutItem* li = Layout->replaceWidget(Splitter, NewSplitter);
|
||||||
NewSplitter->addWidget(Splitter);
|
NewSplitter->addWidget(Splitter);
|
||||||
NewSplitter->addWidget(NewDockArea);
|
NewSplitter->addWidget(NewDockArea);
|
||||||
|
updateSplitterHandles(NewSplitter);
|
||||||
delete li;
|
delete li;
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
@ -1089,6 +1160,7 @@ void DockContainerWidgetPrivate::addDockArea(CDockAreaWidget* NewDockArea, DockW
|
|||||||
NewSplitter->addWidget(NewDockArea);
|
NewSplitter->addWidget(NewDockArea);
|
||||||
QLayoutItem* li = Layout->replaceWidget(Splitter, NewSplitter);
|
QLayoutItem* li = Layout->replaceWidget(Splitter, NewSplitter);
|
||||||
NewSplitter->addWidget(Splitter);
|
NewSplitter->addWidget(Splitter);
|
||||||
|
updateSplitterHandles(NewSplitter);
|
||||||
delete li;
|
delete li;
|
||||||
}
|
}
|
||||||
RootSplitter = NewSplitter;
|
RootSplitter = NewSplitter;
|
||||||
@ -1175,6 +1247,7 @@ CDockAreaWidget* DockContainerWidgetPrivate::addDockWidgetToDockArea(DockWidgetA
|
|||||||
{
|
{
|
||||||
ADS_PRINT("TargetAreaSplitter->orientation() == InsertParam.orientation()");
|
ADS_PRINT("TargetAreaSplitter->orientation() == InsertParam.orientation()");
|
||||||
TargetAreaSplitter->insertWidget(index + InsertParam.insertOffset(), NewDockArea);
|
TargetAreaSplitter->insertWidget(index + InsertParam.insertOffset(), NewDockArea);
|
||||||
|
updateSplitterHandles(TargetAreaSplitter);
|
||||||
// do nothing, if flag is not enabled
|
// do nothing, if flag is not enabled
|
||||||
if (CDockManager::testConfigFlag(CDockManager::EqualSplitOnInsertion))
|
if (CDockManager::testConfigFlag(CDockManager::EqualSplitOnInsertion))
|
||||||
{
|
{
|
||||||
@ -1190,7 +1263,9 @@ CDockAreaWidget* DockContainerWidgetPrivate::addDockWidgetToDockArea(DockWidgetA
|
|||||||
NewSplitter->addWidget(TargetDockArea);
|
NewSplitter->addWidget(TargetDockArea);
|
||||||
|
|
||||||
insertWidgetIntoSplitter(NewSplitter, NewDockArea, InsertParam.append());
|
insertWidgetIntoSplitter(NewSplitter, NewDockArea, InsertParam.append());
|
||||||
|
updateSplitterHandles(NewSplitter);
|
||||||
TargetAreaSplitter->insertWidget(index, NewSplitter);
|
TargetAreaSplitter->insertWidget(index, NewSplitter);
|
||||||
|
updateSplitterHandles(TargetAreaSplitter);
|
||||||
if (CDockManager::testConfigFlag(CDockManager::EqualSplitOnInsertion))
|
if (CDockManager::testConfigFlag(CDockManager::EqualSplitOnInsertion))
|
||||||
{
|
{
|
||||||
TargetAreaSplitter->setSizes(TargetAreaSizes);
|
TargetAreaSplitter->setSizes(TargetAreaSizes);
|
||||||
@ -1381,8 +1456,10 @@ void CDockContainerWidget::removeDockArea(CDockAreaWidget* area)
|
|||||||
}
|
}
|
||||||
|
|
||||||
delete Splitter;
|
delete Splitter;
|
||||||
|
Splitter = nullptr;
|
||||||
|
|
||||||
emitAndExit:
|
emitAndExit:
|
||||||
|
updateSplitterHandles(Splitter);
|
||||||
CDockWidget* TopLevelWidget = topLevelDockWidget();
|
CDockWidget* TopLevelWidget = topLevelDockWidget();
|
||||||
|
|
||||||
// Updated the title bar visibility of the dock widget if there is only
|
// Updated the title bar visibility of the dock widget if there is only
|
||||||
@ -1732,6 +1809,13 @@ QList<CDockWidget*> CDockContainerWidget::dockWidgets() const
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
//============================================================================
|
||||||
|
void CDockContainerWidget::updateSplitterHandles(QSplitter* splitter)
|
||||||
|
{
|
||||||
|
d->updateSplitterHandles(splitter);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
//============================================================================
|
//============================================================================
|
||||||
CDockWidget::DockWidgetFeatures CDockContainerWidget::features() const
|
CDockWidget::DockWidgetFeatures CDockContainerWidget::features() const
|
||||||
{
|
{
|
||||||
|
@ -155,6 +155,12 @@ protected:
|
|||||||
*/
|
*/
|
||||||
QList<CDockWidget*> dockWidgets() const;
|
QList<CDockWidget*> dockWidgets() const;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* This function forces the dock container widget to update handles of splitters
|
||||||
|
* based on resize modes of dock widgets contained in the container.
|
||||||
|
*/
|
||||||
|
void updateSplitterHandles(QSplitter* splitter);
|
||||||
|
|
||||||
public:
|
public:
|
||||||
/**
|
/**
|
||||||
* Default Constructor
|
* Default Constructor
|
||||||
|
@ -108,6 +108,7 @@ struct DockManagerPrivate
|
|||||||
bool RestoringState = false;
|
bool RestoringState = false;
|
||||||
QVector<CFloatingDockContainer*> UninitializedFloatingWidgets;
|
QVector<CFloatingDockContainer*> UninitializedFloatingWidgets;
|
||||||
CDockFocusController* FocusController = nullptr;
|
CDockFocusController* FocusController = nullptr;
|
||||||
|
CDockWidget* CentralWidget = nullptr;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Private data constructor
|
* Private data constructor
|
||||||
@ -406,6 +407,7 @@ bool DockManagerPrivate::restoreState(const QByteArray& State, int version)
|
|||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
CentralWidget = nullptr;
|
||||||
// Hide updates of floating widgets from use
|
// Hide updates of floating widgets from use
|
||||||
hideFloatingWidgets();
|
hideFloatingWidgets();
|
||||||
markDockWidgetsDirty();
|
markDockWidgetsDirty();
|
||||||
@ -816,6 +818,40 @@ void CDockManager::loadPerspectives(QSettings& Settings)
|
|||||||
Settings.endArray();
|
Settings.endArray();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
//============================================================================
|
||||||
|
CDockWidget* CDockManager::centralWidget() const
|
||||||
|
{
|
||||||
|
return d->CentralWidget;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
//============================================================================
|
||||||
|
CDockAreaWidget* CDockManager::setCentralWidget(CDockWidget* widget)
|
||||||
|
{
|
||||||
|
if (!widget)
|
||||||
|
{
|
||||||
|
d->CentralWidget = nullptr;
|
||||||
|
return nullptr;
|
||||||
|
}
|
||||||
|
|
||||||
|
// Setting a new central widget is now allowed if there is alread a central
|
||||||
|
// widget
|
||||||
|
if (d->CentralWidget)
|
||||||
|
{
|
||||||
|
return nullptr;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
widget->setFeature(CDockWidget::DockWidgetClosable, false);
|
||||||
|
widget->setFeature(CDockWidget::DockWidgetMovable, false);
|
||||||
|
widget->setFeature(CDockWidget::DockWidgetFloatable, false);
|
||||||
|
d->CentralWidget = widget;
|
||||||
|
CDockAreaWidget* CentralArea = addDockWidget(CenterDockWidgetArea, widget);
|
||||||
|
CentralArea->setDockAreaFlag(CDockAreaWidget::eDockAreaFlag::HideSingleWidgetTitleBar, true);
|
||||||
|
return CentralArea;
|
||||||
|
}
|
||||||
|
|
||||||
//============================================================================
|
//============================================================================
|
||||||
QAction* CDockManager::addToggleViewActionToMenu(QAction* ToggleViewAction,
|
QAction* CDockManager::addToggleViewActionToMenu(QAction* ToggleViewAction,
|
||||||
const QString& Group, const QIcon& GroupIcon)
|
const QString& Group, const QIcon& GroupIcon)
|
||||||
|
@ -378,6 +378,27 @@ public:
|
|||||||
*/
|
*/
|
||||||
void loadPerspectives(QSettings& Settings);
|
void loadPerspectives(QSettings& Settings);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* This function returns managers central widget or nullptr if no central widget is set.
|
||||||
|
*/
|
||||||
|
CDockWidget* centralWidget() const;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Adds dockwidget widget into the central area and marks it as central widget.
|
||||||
|
* If central widget is set, it will be the only dock widget
|
||||||
|
* that will resize with the dock container. A central widget if not
|
||||||
|
* movable, floatable or closable and the titlebar of the central
|
||||||
|
* dock area is not visible.
|
||||||
|
* If the given widget could be set as central widget, the function returns
|
||||||
|
* the created cok area. If the widget could not be set, because there
|
||||||
|
* is already a central widget, this function returns a nullptr.
|
||||||
|
* To clear the central widget, pass a nullptr to the function.
|
||||||
|
* \retval != 0 The dock area that contains the central widget
|
||||||
|
* \retval nullptr Indicates that the given widget can not be set as central
|
||||||
|
* widget because there is already a central widget.
|
||||||
|
*/
|
||||||
|
CDockAreaWidget* setCentralWidget(CDockWidget* widget);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Adds a toggle view action to the the internal view menu.
|
* Adds a toggle view action to the the internal view menu.
|
||||||
* You can either manage the insertion of the toggle view actions in your
|
* You can either manage the insertion of the toggle view actions in your
|
||||||
|
@ -102,6 +102,20 @@ QWidget* CDockSplitter::lastWidget() const
|
|||||||
return (count() > 0) ? widget(count() - 1) : nullptr;
|
return (count() > 0) ? widget(count() - 1) : nullptr;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
//============================================================================
|
||||||
|
bool CDockSplitter::isResizingWithContainer() const
|
||||||
|
{
|
||||||
|
for (auto area : findChildren<CDockAreaWidget*>())
|
||||||
|
{
|
||||||
|
if(area->isCentralWidgetArea())
|
||||||
|
{
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
} // namespace ads
|
} // namespace ads
|
||||||
|
|
||||||
//---------------------------------------------------------------------------
|
//---------------------------------------------------------------------------
|
||||||
|
@ -71,6 +71,11 @@ public:
|
|||||||
* Returns last widget of nullptr is splitter is empty
|
* Returns last widget of nullptr is splitter is empty
|
||||||
*/
|
*/
|
||||||
QWidget* lastWidget() const;
|
QWidget* lastWidget() const;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Returns true if the splitter contains central widget of dock manager.
|
||||||
|
*/
|
||||||
|
bool isResizingWithContainer() const;
|
||||||
}; // class CDockSplitter
|
}; // class CDockSplitter
|
||||||
|
|
||||||
} // namespace ads
|
} // namespace ads
|
||||||
|
@ -463,6 +463,13 @@ void CDockWidget::setMinimumSizeHintMode(eMinimumSizeHintMode Mode)
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
//============================================================================
|
||||||
|
bool CDockWidget::isCentralWidget() const
|
||||||
|
{
|
||||||
|
return dockManager()->centralWidget() == this;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
//============================================================================
|
//============================================================================
|
||||||
void CDockWidget::toggleView(bool Open)
|
void CDockWidget::toggleView(bool Open)
|
||||||
{
|
{
|
||||||
|
@ -360,6 +360,11 @@ public:
|
|||||||
*/
|
*/
|
||||||
void setMinimumSizeHintMode(eMinimumSizeHintMode Mode);
|
void setMinimumSizeHintMode(eMinimumSizeHintMode Mode);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Returns true if the dock widget is set as central widget of it's dock manager
|
||||||
|
*/
|
||||||
|
bool isCentralWidget() const;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Sets the dock widget icon that is shown in tabs and in toggle view
|
* Sets the dock widget icon that is shown in tabs and in toggle view
|
||||||
* actions
|
* actions
|
||||||
|
Loading…
Reference in New Issue
Block a user