Merge branch 'master' into focused_dockwidget

This commit is contained in:
Uwe Kindler 2020-05-19 20:51:19 +02:00
commit ba94ef3493
6 changed files with 96 additions and 5 deletions

View 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

View 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();
}

View File

@ -2,4 +2,5 @@ TEMPLATE = subdirs
SUBDIRS = \
simple \
sidebar
sidebar \
deleteonclose

View File

@ -205,10 +205,14 @@ void CDockAreaTabBar::insertTab(int Index, CDockWidgetTab* Tab)
connect(Tab, SIGNAL(elidedChanged(bool)), this, SIGNAL(elidedChanged(bool)));
Tab->installEventFilter(this);
emit tabInserted(Index);
if (Index <= d->CurrentIndex || d->CurrentIndex == -1)
if (Index <= d->CurrentIndex)
{
setCurrentIndex(d->CurrentIndex + 1);
}
}
else if (d->CurrentIndex == -1)
{
setCurrentIndex(Index);
}
updateGeometry();
}

View File

@ -429,6 +429,12 @@ void CDockAreaWidget::insertDockWidget(int index, CDockWidget* DockWidget,
{
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();
}
@ -448,7 +454,7 @@ void CDockAreaWidget::removeDockWidget(CDockWidget* DockWidget)
{
setCurrentDockWidget(NextOpenDockWidget);
}
else if (d->ContentsLayout->isEmpty() && DockContainer->dockAreaCount() > 1)
else if (d->ContentsLayout->isEmpty() && DockContainer->dockAreaCount() >= 1)
{
ADS_PRINT("Dock Area empty");
DockContainer->removeDockArea(this);

View File

@ -580,7 +580,7 @@ void CDockWidgetTab::mouseDoubleClickEvent(QMouseEvent *event)
void CDockWidgetTab::setVisible(bool visible)
{
// Just here for debugging to insert debug output
Super::setVisible(visible);
Super::setVisible(visible);
}