mirror of
https://github.com/githubuser0xFFFF/Qt-Advanced-Docking-System.git
synced 2024-11-15 13:15:43 +08:00
Fixed showing of dock area when inserting a dock widget into a hidden dock area
fixed setting of DockAreaTabBar index to prevent showing of tab 0 when inserting a dock widget into an area with no current index tab
This commit is contained in:
parent
eee9ebb41d
commit
36bcbded54
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 = \
|
||||
simple \
|
||||
sidebar
|
||||
sidebar \
|
||||
deleteonclose
|
||||
|
@ -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();
|
||||
}
|
||||
|
@ -429,6 +429,12 @@ void CDockAreaWidget::insertDockWidget(int index, CDockWidget* DockWidget,
|
||||
setCurrentIndex(index);
|
||||
}
|
||||
DockWidget->setDockArea(this);
|
||||
// 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);
|
||||
|
@ -570,7 +570,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);
|
||||
}
|
||||
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user