diff --git a/demo/MainWindow.cpp b/demo/MainWindow.cpp index f6c0b25..a21bd91 100644 --- a/demo/MainWindow.cpp +++ b/demo/MainWindow.cpp @@ -177,13 +177,13 @@ void MainWindowPrivate::createContent() DockWidget->setFeature(ads::CDockWidget::DockWidgetClosable, false); DockManager->addDockWidget(ads::LeftDockWidgetArea, DockWidget); DockManager->addDockWidget(ads::LeftDockWidgetArea, createLongTextLabelDockWidget(ViewMenu)); - auto FileSystemWidget = createFileSystemTreeDockWidget(ViewMenu); + /*auto FileSystemWidget = createFileSystemTreeDockWidget(ViewMenu); auto ToolBar = FileSystemWidget->toolBar(); ToolBar->addAction(ui.actionSaveState); ToolBar->addAction(ui.actionRestoreState); - DockManager->addDockWidget(ads::BottomDockWidgetArea, FileSystemWidget); + DockManager->addDockWidget(ads::BottomDockWidgetArea, FileSystemWidget);*/ - FileSystemWidget = createFileSystemTreeDockWidget(ViewMenu); + /*FileSystemWidget = createFileSystemTreeDockWidget(ViewMenu); ToolBar = FileSystemWidget->toolBar(); ToolBar->addAction(ui.actionSaveState); ToolBar->addAction(ui.actionRestoreState); @@ -198,7 +198,7 @@ void MainWindowPrivate::createContent() DockManager->addDockWidget(ads::TopDockWidgetArea, createLongTextLabelDockWidget(ViewMenu), RighDockArea); auto BottomDockArea = DockManager->addDockWidget(ads::BottomDockWidgetArea, createLongTextLabelDockWidget(ViewMenu), RighDockArea); DockManager->addDockWidget(ads::RightDockWidgetArea, createLongTextLabelDockWidget(ViewMenu), RighDockArea); - DockManager->addDockWidget(ads::CenterDockWidgetArea, createLongTextLabelDockWidget(ViewMenu), BottomDockArea); + DockManager->addDockWidget(ads::CenterDockWidgetArea, createLongTextLabelDockWidget(ViewMenu), BottomDockArea);*/ } @@ -321,7 +321,6 @@ void CMainWindow::on_actionRestoreState_triggered(bool) //============================================================================ void CMainWindow::savePerspective() { - std::cout << "savePerspective" << std::endl; QString PerspectiveName = QInputDialog::getText(this, "Save Perspective", "Enter unique name:"); if (PerspectiveName.isEmpty()) { diff --git a/demo/main.cpp b/demo/main.cpp index 1df2221..15ef7b7 100644 --- a/demo/main.cpp +++ b/demo/main.cpp @@ -38,7 +38,7 @@ int main(int argc, char *argv[]) std::shared_ptr b; QApplication a(argc, argv); a.setQuitOnLastWindowClosed(true); - qInstallMessageHandler(myMessageOutput); + //qInstallMessageHandler(myMessageOutput); qDebug() << "Message handler test"; CMainWindow mw; diff --git a/src/DockAreaTabBar.cpp b/src/DockAreaTabBar.cpp index 6b40e8f..ecf4b62 100644 --- a/src/DockAreaTabBar.cpp +++ b/src/DockAreaTabBar.cpp @@ -136,7 +136,6 @@ void CDockAreaTabBar::wheelEvent(QWheelEvent* Event) //============================================================================ void CDockAreaTabBar::mousePressEvent(QMouseEvent* ev) { - std::cout << "CDockAreaTabBar::mousePressEvent" << std::endl; if (ev->button() == Qt::LeftButton) { ev->accept(); @@ -232,7 +231,6 @@ void CDockAreaTabBar::startFloating(const QPoint& Pos) //============================================================================ void CDockAreaTabBar::setCurrentIndex(int index) { - std::cout << "CDockAreaTabBar::setCurrentIndex " << index << std::endl; if (index == d->CurrentIndex) { return; diff --git a/src/DockAreaTitleBar.cpp b/src/DockAreaTitleBar.cpp index 22c9f09..da8721c 100644 --- a/src/DockAreaTitleBar.cpp +++ b/src/DockAreaTitleBar.cpp @@ -11,6 +11,7 @@ #include "DockAreaTitleBar.h" #include +#include #include #include #include @@ -31,14 +32,15 @@ namespace ads { +using tTileBarButton = QPushButton; /** * Private data class of CDockAreaTitleBar class (pimpl) */ struct DockAreaTitleBarPrivate { CDockAreaTitleBar* _this; - QPushButton* TabsMenuButton; - QPushButton* CloseButton; + tTileBarButton* TabsMenuButton; + tTileBarButton* CloseButton; QBoxLayout* TopLayout; CDockAreaWidget* DockArea; CDockAreaTabBar* TabBar; @@ -74,7 +76,7 @@ DockAreaTitleBarPrivate::DockAreaTitleBarPrivate(CDockAreaTitleBar* _public) : //============================================================================ void DockAreaTitleBarPrivate::createButtons() { - TabsMenuButton = new QPushButton(); + TabsMenuButton = new tTileBarButton(); TabsMenuButton->setObjectName("tabsMenuButton"); TabsMenuButton->setFlat(true); TabsMenuButton->setIcon(_this->style()->standardIcon(QStyle::SP_TitleBarUnshadeButton)); @@ -88,10 +90,18 @@ void DockAreaTitleBarPrivate::createButtons() _this->connect(TabsMenuButton->menu(), SIGNAL(triggered(QAction*)), SLOT(onTabsMenuActionTriggered(QAction*))); - CloseButton = new QPushButton(); + CloseButton = new tTileBarButton(); CloseButton->setObjectName("closeButton"); CloseButton->setFlat(true); - CloseButton->setIcon(_this->style()->standardIcon(QStyle::SP_TitleBarCloseButton)); + QPixmap ClosePixmap = _this->style()->standardPixmap(QStyle::SP_TitleBarCloseButton); + QIcon CloseIcon; + QStyleOptionButton option; + option.initFrom(CloseButton); + QPixmap ClosePixmapDisabled = _this->style()->generatedIconPixmap(QIcon::Disabled, ClosePixmap, &option); + CloseIcon.addPixmap(ClosePixmap, QIcon::Active); + CloseIcon.addPixmap(ClosePixmapDisabled, QIcon::Disabled); + CloseButton->setIcon(CloseIcon); + //CloseButton->setIcon(QIcon(":/ads/close.svg")); CloseButton->setToolTip(QObject::tr("Close")); CloseButton->setSizePolicy(QSizePolicy::Fixed, QSizePolicy::Expanding); TopLayout->addWidget(CloseButton, 0); @@ -201,7 +211,7 @@ void CDockAreaTitleBar::onTabsMenuActionTriggered(QAction* Action) void CDockAreaTitleBar::onCurrentTabChanged(int Index) { CDockWidget* DockWidget = d->TabBar->tab(Index)->dockWidget(); - d->CloseButton->setVisible(DockWidget->features().testFlag(CDockWidget::DockWidgetClosable)); + d->CloseButton->setEnabled(DockWidget->features().testFlag(CDockWidget::DockWidgetClosable)); } diff --git a/src/DockAreaWidget.cpp b/src/DockAreaWidget.cpp index 9886f43..211070f 100644 --- a/src/DockAreaWidget.cpp +++ b/src/DockAreaWidget.cpp @@ -132,12 +132,10 @@ public: void setCurrentIndex(int index) { - std::cout << "CDockAreaLayout::setCurrentIndex " << index << std::endl; QWidget *prev = currentWidget(); QWidget *next = widget(index); if (!next || (next == prev && !m_CurrentWidget)) { - std::cout << "return" << std::endl; return; } @@ -150,7 +148,6 @@ public: parent->setUpdatesEnabled(false); } - std::cout << "m_ParentLayout->addWidget(next)" << std::endl; auto LayoutItem = m_ParentLayout->takeAt(1); if (LayoutItem) { diff --git a/src/DockContainerWidget.cpp b/src/DockContainerWidget.cpp index 6b10a84..87c3c28 100644 --- a/src/DockContainerWidget.cpp +++ b/src/DockContainerWidget.cpp @@ -927,7 +927,7 @@ int CDockContainerWidget::visibleDockAreaCount() const int Result = 0; for (auto DockArea : d->DockAreas) { - Result += DockArea->isVisibleTo(this) ? 1 : 0; + Result += DockArea->isHidden() ? 0 : 1; } return Result; @@ -982,9 +982,6 @@ void CDockContainerWidget::dropFloatingWidget(CFloatingDockContainer* FloatingWi { TopLevelDockWidget->emitTopLevelChanged(false); } - - std::cout << "CDockContainerWidget::dropFloatingWidget " << - Timer.restart() << std::endl; } @@ -994,7 +991,7 @@ QList CDockContainerWidget::openedDockAreas() const QList Result; for (auto DockArea : d->DockAreas) { - if (DockArea->isVisibleTo(this)) + if (!DockArea->isHidden()) { Result.append(DockArea); } diff --git a/src/DockManager.cpp b/src/DockManager.cpp index 9d046ca..81135ea 100644 --- a/src/DockManager.cpp +++ b/src/DockManager.cpp @@ -262,13 +262,10 @@ bool DockManagerPrivate::restoreState(const QByteArray &state, int version) // Now all dock areas are properly restored and we setup the index of // The dock areas because the previous toggleView() action has changed // the dock area index - std::cout << "Restoring dock container indexes" << std::endl; int Count = 0; for (auto DockContainer : Containers) { Count++; - std::cout << "Restoring container " << Count << " floating: " - << DockContainer->isFloating() << " DockAreaCount " << DockContainer->dockAreaCount() << std::endl; for (int i = 0; i < DockContainer->dockAreaCount(); ++i) { CDockAreaWidget* DockArea = DockContainer->dockArea(i); @@ -481,8 +478,8 @@ bool CDockManager::restoreState(const QByteArray &state, int version) // dock manager. Because there will be no processing of application // events until this function is finished, the user will not see this // hiding - bool IsVisible = this->isVisibleTo(parentWidget()); - if (IsVisible) + bool IsHidden = this->isHidden(); + if (!IsHidden) { hide(); } @@ -491,12 +488,11 @@ bool CDockManager::restoreState(const QByteArray &state, int version) bool Result = d->restoreState(state, version); d->RestoringState = false; emit stateRestored(); - if (IsVisible) + if (!IsHidden) { show(); } - std::cout << "CDockManager::restoreState " << Timer.restart() << std::endl; return Result; } diff --git a/src/DockWidget.cpp b/src/DockWidget.cpp index 56d6f49..1485641 100644 --- a/src/DockWidget.cpp +++ b/src/DockWidget.cpp @@ -435,14 +435,16 @@ void CDockWidget::toggleViewInternal(bool Open) { CDockContainerWidget* DockContainer = dockContainer(); CDockWidget* TopLevelDockWidget = nullptr; + CDockWidget* TopLevelDockWidgetBefore = nullptr; - if (Open && DockContainer) + if (DockContainer) { - TopLevelDockWidget = DockContainer->topLevelDockWidget(); + TopLevelDockWidgetBefore = DockContainer->topLevelDockWidget(); } if (Open) { + TopLevelDockWidget = TopLevelDockWidgetBefore; d->showDockWidget(); } else @@ -468,6 +470,22 @@ void CDockWidget::toggleViewInternal(bool Open) CDockWidget::emitTopLevelEventForWidget(TopLevelDockWidget, !Open); } + CDockWidget* TopLevelDockWidgetAfter = nullptr; + if (DockContainer) + { + TopLevelDockWidgetAfter = DockContainer->topLevelDockWidget(); + } + + if (TopLevelDockWidgetAfter != TopLevelDockWidgetBefore) + { + CFloatingDockContainer* FloatingContainer = qobject_cast(DockContainer->parentWidget()); + if (FloatingContainer) + { + FloatingContainer->updateWindowTitle(TopLevelDockWidgetAfter ? TopLevelDockWidgetAfter->windowTitle() : ""); + } + } + + if (!Open) { emit closed(); diff --git a/src/FloatingDockContainer.cpp b/src/FloatingDockContainer.cpp index ffebc86..2aa3638 100644 --- a/src/FloatingDockContainer.cpp +++ b/src/FloatingDockContainer.cpp @@ -500,6 +500,20 @@ void CFloatingDockContainer::onDockAreasAddedOrRemoved() } +//============================================================================ +void CFloatingDockContainer::updateWindowTitle(const QString& Title) +{ + if (Title.isEmpty()) + { + this->setWindowTitle(qApp->applicationDisplayName()); + } + else + { + this->setWindowTitle(Title); + } +} + + //============================================================================ void CFloatingDockContainer::onDockAreaCurrentChanged(int Index) { diff --git a/src/FloatingDockContainer.h b/src/FloatingDockContainer.h index aef853e..2729dee 100644 --- a/src/FloatingDockContainer.h +++ b/src/FloatingDockContainer.h @@ -68,6 +68,7 @@ private: friend class CDockWidgetTab; friend class CDockAreaTitleBar; friend struct DockAreaTitleBarPrivate; + friend class CDockWidget; private slots: void onDockAreasAddedOrRemoved(); @@ -95,6 +96,11 @@ protected: */ bool restoreState(QXmlStreamReader& Stream, bool Testing); + /** + * Call this function to update the window title + */ + void updateWindowTitle(const QString& Title =""); + protected: // reimplements QWidget virtual void changeEvent(QEvent *event) override; diff --git a/src/ads.qrc b/src/ads.qrc index 81aa482..9ffc7aa 100644 --- a/src/ads.qrc +++ b/src/ads.qrc @@ -1,5 +1,6 @@ stylesheets/default.css + close.svg