mirror of
https://github.com/githubuser0xFFFF/Qt-Advanced-Docking-System.git
synced 2024-11-15 21:25:44 +08:00
Merge branch 'master' into focused_dockwidget
This commit is contained in:
commit
ba94ef3493
39
examples/deleteonclose/deleteonclose.pro
Normal file
39
examples/deleteonclose/deleteonclose.pro
Normal file
@ -0,0 +1,39 @@
|
|||||||
|
ADS_OUT_ROOT = $${OUT_PWD}/../..
|
||||||
|
|
||||||
|
QT += core gui widgets
|
||||||
|
|
||||||
|
TARGET = DeleteOnCloseTest
|
||||||
|
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
|
||||||
|
|
||||||
|
|
||||||
|
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
|
||||||
|
|
41
examples/deleteonclose/main.cpp
Normal file
41
examples/deleteonclose/main.cpp
Normal file
@ -0,0 +1,41 @@
|
|||||||
|
#include <QMainWindow>
|
||||||
|
#include <QAction>
|
||||||
|
#include <QTextEdit>
|
||||||
|
#include <QApplication>
|
||||||
|
#include <QMenuBar>
|
||||||
|
#include "DockManager.h"
|
||||||
|
|
||||||
|
int main(int argc, char *argv[])
|
||||||
|
{
|
||||||
|
QApplication a(argc, argv);
|
||||||
|
QMainWindow w;
|
||||||
|
|
||||||
|
auto dockManager = new ads::CDockManager(&w);
|
||||||
|
|
||||||
|
QAction *action = new QAction("New Delete On Close", &w);
|
||||||
|
w.menuBar()->addAction(action);
|
||||||
|
|
||||||
|
int i = 0;
|
||||||
|
QObject::connect(action, &QAction::triggered, [&]() {
|
||||||
|
auto dw = new ads::CDockWidget(QStringLiteral("test doc %1").arg(i++), &w);
|
||||||
|
auto editor = new QTextEdit(QStringLiteral("lorem ipsum..."), dw);
|
||||||
|
dw->setWidget(editor);
|
||||||
|
dw->setFeature(ads::CDockWidget::DockWidgetDeleteOnClose, true);
|
||||||
|
auto area = dockManager->addDockWidgetTab(ads::CenterDockWidgetArea, dw);
|
||||||
|
qDebug() << "doc dock widget created!" << dw << area;
|
||||||
|
});
|
||||||
|
|
||||||
|
action = new QAction("New", &w);
|
||||||
|
w.menuBar()->addAction(action);
|
||||||
|
QObject::connect(action, &QAction::triggered, [&]() {
|
||||||
|
auto dw = new ads::CDockWidget(QStringLiteral("test %1").arg(i++), &w);
|
||||||
|
auto editor = new QTextEdit(QStringLiteral("lorem ipsum..."), dw);
|
||||||
|
dw->setWidget(editor);
|
||||||
|
auto area = dockManager->addDockWidgetTab(ads::CenterDockWidgetArea, dw);
|
||||||
|
qDebug() << "dock widget created!" << dw << area;
|
||||||
|
});
|
||||||
|
|
||||||
|
w.show();
|
||||||
|
|
||||||
|
return a.exec();
|
||||||
|
}
|
@ -2,4 +2,5 @@ TEMPLATE = subdirs
|
|||||||
|
|
||||||
SUBDIRS = \
|
SUBDIRS = \
|
||||||
simple \
|
simple \
|
||||||
sidebar
|
sidebar \
|
||||||
|
deleteonclose
|
||||||
|
@ -205,10 +205,14 @@ void CDockAreaTabBar::insertTab(int Index, CDockWidgetTab* Tab)
|
|||||||
connect(Tab, SIGNAL(elidedChanged(bool)), this, SIGNAL(elidedChanged(bool)));
|
connect(Tab, SIGNAL(elidedChanged(bool)), this, SIGNAL(elidedChanged(bool)));
|
||||||
Tab->installEventFilter(this);
|
Tab->installEventFilter(this);
|
||||||
emit tabInserted(Index);
|
emit tabInserted(Index);
|
||||||
if (Index <= d->CurrentIndex || d->CurrentIndex == -1)
|
if (Index <= d->CurrentIndex)
|
||||||
{
|
{
|
||||||
setCurrentIndex(d->CurrentIndex + 1);
|
setCurrentIndex(d->CurrentIndex + 1);
|
||||||
}
|
}
|
||||||
|
else if (d->CurrentIndex == -1)
|
||||||
|
{
|
||||||
|
setCurrentIndex(Index);
|
||||||
|
}
|
||||||
|
|
||||||
updateGeometry();
|
updateGeometry();
|
||||||
}
|
}
|
||||||
|
@ -429,6 +429,12 @@ void CDockAreaWidget::insertDockWidget(int index, CDockWidget* DockWidget,
|
|||||||
{
|
{
|
||||||
setCurrentIndex(index);
|
setCurrentIndex(index);
|
||||||
}
|
}
|
||||||
|
// If this dock area is hidden, then we need to make it visible again
|
||||||
|
// by calling DockWidget->toggleViewInternal(true);
|
||||||
|
if (!this->isVisible() && d->ContentsLayout->count() > 1 && !dockManager()->isRestoringState())
|
||||||
|
{
|
||||||
|
DockWidget->toggleViewInternal(true);
|
||||||
|
}
|
||||||
d->updateTitleBarButtonStates();
|
d->updateTitleBarButtonStates();
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -448,7 +454,7 @@ void CDockAreaWidget::removeDockWidget(CDockWidget* DockWidget)
|
|||||||
{
|
{
|
||||||
setCurrentDockWidget(NextOpenDockWidget);
|
setCurrentDockWidget(NextOpenDockWidget);
|
||||||
}
|
}
|
||||||
else if (d->ContentsLayout->isEmpty() && DockContainer->dockAreaCount() > 1)
|
else if (d->ContentsLayout->isEmpty() && DockContainer->dockAreaCount() >= 1)
|
||||||
{
|
{
|
||||||
ADS_PRINT("Dock Area empty");
|
ADS_PRINT("Dock Area empty");
|
||||||
DockContainer->removeDockArea(this);
|
DockContainer->removeDockArea(this);
|
||||||
|
Loading…
Reference in New Issue
Block a user