mirror of
https://github.com/githubuser0xFFFF/Qt-Advanced-Docking-System.git
synced 2025-01-14 00:52:05 +08:00
Implemented proper updating of floating widget title
This commit is contained in:
parent
81523b0346
commit
6617cf6f19
@ -177,13 +177,13 @@ void MainWindowPrivate::createContent()
|
|||||||
DockWidget->setFeature(ads::CDockWidget::DockWidgetClosable, false);
|
DockWidget->setFeature(ads::CDockWidget::DockWidgetClosable, false);
|
||||||
DockManager->addDockWidget(ads::LeftDockWidgetArea, DockWidget);
|
DockManager->addDockWidget(ads::LeftDockWidgetArea, DockWidget);
|
||||||
DockManager->addDockWidget(ads::LeftDockWidgetArea, createLongTextLabelDockWidget(ViewMenu));
|
DockManager->addDockWidget(ads::LeftDockWidgetArea, createLongTextLabelDockWidget(ViewMenu));
|
||||||
auto FileSystemWidget = createFileSystemTreeDockWidget(ViewMenu);
|
/*auto FileSystemWidget = createFileSystemTreeDockWidget(ViewMenu);
|
||||||
auto ToolBar = FileSystemWidget->toolBar();
|
auto ToolBar = FileSystemWidget->toolBar();
|
||||||
ToolBar->addAction(ui.actionSaveState);
|
ToolBar->addAction(ui.actionSaveState);
|
||||||
ToolBar->addAction(ui.actionRestoreState);
|
ToolBar->addAction(ui.actionRestoreState);
|
||||||
DockManager->addDockWidget(ads::BottomDockWidgetArea, FileSystemWidget);
|
DockManager->addDockWidget(ads::BottomDockWidgetArea, FileSystemWidget);*/
|
||||||
|
|
||||||
FileSystemWidget = createFileSystemTreeDockWidget(ViewMenu);
|
/*FileSystemWidget = createFileSystemTreeDockWidget(ViewMenu);
|
||||||
ToolBar = FileSystemWidget->toolBar();
|
ToolBar = FileSystemWidget->toolBar();
|
||||||
ToolBar->addAction(ui.actionSaveState);
|
ToolBar->addAction(ui.actionSaveState);
|
||||||
ToolBar->addAction(ui.actionRestoreState);
|
ToolBar->addAction(ui.actionRestoreState);
|
||||||
@ -198,7 +198,7 @@ void MainWindowPrivate::createContent()
|
|||||||
DockManager->addDockWidget(ads::TopDockWidgetArea, createLongTextLabelDockWidget(ViewMenu), RighDockArea);
|
DockManager->addDockWidget(ads::TopDockWidgetArea, createLongTextLabelDockWidget(ViewMenu), RighDockArea);
|
||||||
auto BottomDockArea = DockManager->addDockWidget(ads::BottomDockWidgetArea, createLongTextLabelDockWidget(ViewMenu), RighDockArea);
|
auto BottomDockArea = DockManager->addDockWidget(ads::BottomDockWidgetArea, createLongTextLabelDockWidget(ViewMenu), RighDockArea);
|
||||||
DockManager->addDockWidget(ads::RightDockWidgetArea, 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()
|
void CMainWindow::savePerspective()
|
||||||
{
|
{
|
||||||
std::cout << "savePerspective" << std::endl;
|
|
||||||
QString PerspectiveName = QInputDialog::getText(this, "Save Perspective", "Enter unique name:");
|
QString PerspectiveName = QInputDialog::getText(this, "Save Perspective", "Enter unique name:");
|
||||||
if (PerspectiveName.isEmpty())
|
if (PerspectiveName.isEmpty())
|
||||||
{
|
{
|
||||||
|
@ -38,7 +38,7 @@ int main(int argc, char *argv[])
|
|||||||
std::shared_ptr<int> b;
|
std::shared_ptr<int> b;
|
||||||
QApplication a(argc, argv);
|
QApplication a(argc, argv);
|
||||||
a.setQuitOnLastWindowClosed(true);
|
a.setQuitOnLastWindowClosed(true);
|
||||||
qInstallMessageHandler(myMessageOutput);
|
//qInstallMessageHandler(myMessageOutput);
|
||||||
qDebug() << "Message handler test";
|
qDebug() << "Message handler test";
|
||||||
|
|
||||||
CMainWindow mw;
|
CMainWindow mw;
|
||||||
|
@ -136,7 +136,6 @@ void CDockAreaTabBar::wheelEvent(QWheelEvent* Event)
|
|||||||
//============================================================================
|
//============================================================================
|
||||||
void CDockAreaTabBar::mousePressEvent(QMouseEvent* ev)
|
void CDockAreaTabBar::mousePressEvent(QMouseEvent* ev)
|
||||||
{
|
{
|
||||||
std::cout << "CDockAreaTabBar::mousePressEvent" << std::endl;
|
|
||||||
if (ev->button() == Qt::LeftButton)
|
if (ev->button() == Qt::LeftButton)
|
||||||
{
|
{
|
||||||
ev->accept();
|
ev->accept();
|
||||||
@ -232,7 +231,6 @@ void CDockAreaTabBar::startFloating(const QPoint& Pos)
|
|||||||
//============================================================================
|
//============================================================================
|
||||||
void CDockAreaTabBar::setCurrentIndex(int index)
|
void CDockAreaTabBar::setCurrentIndex(int index)
|
||||||
{
|
{
|
||||||
std::cout << "CDockAreaTabBar::setCurrentIndex " << index << std::endl;
|
|
||||||
if (index == d->CurrentIndex)
|
if (index == d->CurrentIndex)
|
||||||
{
|
{
|
||||||
return;
|
return;
|
||||||
|
@ -11,6 +11,7 @@
|
|||||||
#include "DockAreaTitleBar.h"
|
#include "DockAreaTitleBar.h"
|
||||||
|
|
||||||
#include <QPushButton>
|
#include <QPushButton>
|
||||||
|
#include <QToolButton>
|
||||||
#include <QBoxLayout>
|
#include <QBoxLayout>
|
||||||
#include <QStyle>
|
#include <QStyle>
|
||||||
#include <QMenu>
|
#include <QMenu>
|
||||||
@ -31,14 +32,15 @@
|
|||||||
|
|
||||||
namespace ads
|
namespace ads
|
||||||
{
|
{
|
||||||
|
using tTileBarButton = QPushButton;
|
||||||
/**
|
/**
|
||||||
* Private data class of CDockAreaTitleBar class (pimpl)
|
* Private data class of CDockAreaTitleBar class (pimpl)
|
||||||
*/
|
*/
|
||||||
struct DockAreaTitleBarPrivate
|
struct DockAreaTitleBarPrivate
|
||||||
{
|
{
|
||||||
CDockAreaTitleBar* _this;
|
CDockAreaTitleBar* _this;
|
||||||
QPushButton* TabsMenuButton;
|
tTileBarButton* TabsMenuButton;
|
||||||
QPushButton* CloseButton;
|
tTileBarButton* CloseButton;
|
||||||
QBoxLayout* TopLayout;
|
QBoxLayout* TopLayout;
|
||||||
CDockAreaWidget* DockArea;
|
CDockAreaWidget* DockArea;
|
||||||
CDockAreaTabBar* TabBar;
|
CDockAreaTabBar* TabBar;
|
||||||
@ -74,7 +76,7 @@ DockAreaTitleBarPrivate::DockAreaTitleBarPrivate(CDockAreaTitleBar* _public) :
|
|||||||
//============================================================================
|
//============================================================================
|
||||||
void DockAreaTitleBarPrivate::createButtons()
|
void DockAreaTitleBarPrivate::createButtons()
|
||||||
{
|
{
|
||||||
TabsMenuButton = new QPushButton();
|
TabsMenuButton = new tTileBarButton();
|
||||||
TabsMenuButton->setObjectName("tabsMenuButton");
|
TabsMenuButton->setObjectName("tabsMenuButton");
|
||||||
TabsMenuButton->setFlat(true);
|
TabsMenuButton->setFlat(true);
|
||||||
TabsMenuButton->setIcon(_this->style()->standardIcon(QStyle::SP_TitleBarUnshadeButton));
|
TabsMenuButton->setIcon(_this->style()->standardIcon(QStyle::SP_TitleBarUnshadeButton));
|
||||||
@ -88,10 +90,18 @@ void DockAreaTitleBarPrivate::createButtons()
|
|||||||
_this->connect(TabsMenuButton->menu(), SIGNAL(triggered(QAction*)),
|
_this->connect(TabsMenuButton->menu(), SIGNAL(triggered(QAction*)),
|
||||||
SLOT(onTabsMenuActionTriggered(QAction*)));
|
SLOT(onTabsMenuActionTriggered(QAction*)));
|
||||||
|
|
||||||
CloseButton = new QPushButton();
|
CloseButton = new tTileBarButton();
|
||||||
CloseButton->setObjectName("closeButton");
|
CloseButton->setObjectName("closeButton");
|
||||||
CloseButton->setFlat(true);
|
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->setToolTip(QObject::tr("Close"));
|
||||||
CloseButton->setSizePolicy(QSizePolicy::Fixed, QSizePolicy::Expanding);
|
CloseButton->setSizePolicy(QSizePolicy::Fixed, QSizePolicy::Expanding);
|
||||||
TopLayout->addWidget(CloseButton, 0);
|
TopLayout->addWidget(CloseButton, 0);
|
||||||
@ -201,7 +211,7 @@ void CDockAreaTitleBar::onTabsMenuActionTriggered(QAction* Action)
|
|||||||
void CDockAreaTitleBar::onCurrentTabChanged(int Index)
|
void CDockAreaTitleBar::onCurrentTabChanged(int Index)
|
||||||
{
|
{
|
||||||
CDockWidget* DockWidget = d->TabBar->tab(Index)->dockWidget();
|
CDockWidget* DockWidget = d->TabBar->tab(Index)->dockWidget();
|
||||||
d->CloseButton->setVisible(DockWidget->features().testFlag(CDockWidget::DockWidgetClosable));
|
d->CloseButton->setEnabled(DockWidget->features().testFlag(CDockWidget::DockWidgetClosable));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@ -132,12 +132,10 @@ public:
|
|||||||
|
|
||||||
void setCurrentIndex(int index)
|
void setCurrentIndex(int index)
|
||||||
{
|
{
|
||||||
std::cout << "CDockAreaLayout::setCurrentIndex " << index << std::endl;
|
|
||||||
QWidget *prev = currentWidget();
|
QWidget *prev = currentWidget();
|
||||||
QWidget *next = widget(index);
|
QWidget *next = widget(index);
|
||||||
if (!next || (next == prev && !m_CurrentWidget))
|
if (!next || (next == prev && !m_CurrentWidget))
|
||||||
{
|
{
|
||||||
std::cout << "return" << std::endl;
|
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -150,7 +148,6 @@ public:
|
|||||||
parent->setUpdatesEnabled(false);
|
parent->setUpdatesEnabled(false);
|
||||||
}
|
}
|
||||||
|
|
||||||
std::cout << "m_ParentLayout->addWidget(next)" << std::endl;
|
|
||||||
auto LayoutItem = m_ParentLayout->takeAt(1);
|
auto LayoutItem = m_ParentLayout->takeAt(1);
|
||||||
if (LayoutItem)
|
if (LayoutItem)
|
||||||
{
|
{
|
||||||
|
@ -927,7 +927,7 @@ int CDockContainerWidget::visibleDockAreaCount() const
|
|||||||
int Result = 0;
|
int Result = 0;
|
||||||
for (auto DockArea : d->DockAreas)
|
for (auto DockArea : d->DockAreas)
|
||||||
{
|
{
|
||||||
Result += DockArea->isVisibleTo(this) ? 1 : 0;
|
Result += DockArea->isHidden() ? 0 : 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
return Result;
|
return Result;
|
||||||
@ -982,9 +982,6 @@ void CDockContainerWidget::dropFloatingWidget(CFloatingDockContainer* FloatingWi
|
|||||||
{
|
{
|
||||||
TopLevelDockWidget->emitTopLevelChanged(false);
|
TopLevelDockWidget->emitTopLevelChanged(false);
|
||||||
}
|
}
|
||||||
|
|
||||||
std::cout << "CDockContainerWidget::dropFloatingWidget " <<
|
|
||||||
Timer.restart() << std::endl;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@ -994,7 +991,7 @@ QList<CDockAreaWidget*> CDockContainerWidget::openedDockAreas() const
|
|||||||
QList<CDockAreaWidget*> Result;
|
QList<CDockAreaWidget*> Result;
|
||||||
for (auto DockArea : d->DockAreas)
|
for (auto DockArea : d->DockAreas)
|
||||||
{
|
{
|
||||||
if (DockArea->isVisibleTo(this))
|
if (!DockArea->isHidden())
|
||||||
{
|
{
|
||||||
Result.append(DockArea);
|
Result.append(DockArea);
|
||||||
}
|
}
|
||||||
|
@ -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
|
// 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 areas because the previous toggleView() action has changed
|
||||||
// the dock area index
|
// the dock area index
|
||||||
std::cout << "Restoring dock container indexes" << std::endl;
|
|
||||||
int Count = 0;
|
int Count = 0;
|
||||||
for (auto DockContainer : Containers)
|
for (auto DockContainer : Containers)
|
||||||
{
|
{
|
||||||
Count++;
|
Count++;
|
||||||
std::cout << "Restoring container " << Count << " floating: "
|
|
||||||
<< DockContainer->isFloating() << " DockAreaCount " << DockContainer->dockAreaCount() << std::endl;
|
|
||||||
for (int i = 0; i < DockContainer->dockAreaCount(); ++i)
|
for (int i = 0; i < DockContainer->dockAreaCount(); ++i)
|
||||||
{
|
{
|
||||||
CDockAreaWidget* DockArea = DockContainer->dockArea(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
|
// dock manager. Because there will be no processing of application
|
||||||
// events until this function is finished, the user will not see this
|
// events until this function is finished, the user will not see this
|
||||||
// hiding
|
// hiding
|
||||||
bool IsVisible = this->isVisibleTo(parentWidget());
|
bool IsHidden = this->isHidden();
|
||||||
if (IsVisible)
|
if (!IsHidden)
|
||||||
{
|
{
|
||||||
hide();
|
hide();
|
||||||
}
|
}
|
||||||
@ -491,12 +488,11 @@ bool CDockManager::restoreState(const QByteArray &state, int version)
|
|||||||
bool Result = d->restoreState(state, version);
|
bool Result = d->restoreState(state, version);
|
||||||
d->RestoringState = false;
|
d->RestoringState = false;
|
||||||
emit stateRestored();
|
emit stateRestored();
|
||||||
if (IsVisible)
|
if (!IsHidden)
|
||||||
{
|
{
|
||||||
show();
|
show();
|
||||||
}
|
}
|
||||||
|
|
||||||
std::cout << "CDockManager::restoreState " << Timer.restart() << std::endl;
|
|
||||||
return Result;
|
return Result;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -435,14 +435,16 @@ void CDockWidget::toggleViewInternal(bool Open)
|
|||||||
{
|
{
|
||||||
CDockContainerWidget* DockContainer = dockContainer();
|
CDockContainerWidget* DockContainer = dockContainer();
|
||||||
CDockWidget* TopLevelDockWidget = nullptr;
|
CDockWidget* TopLevelDockWidget = nullptr;
|
||||||
|
CDockWidget* TopLevelDockWidgetBefore = nullptr;
|
||||||
|
|
||||||
if (Open && DockContainer)
|
if (DockContainer)
|
||||||
{
|
{
|
||||||
TopLevelDockWidget = DockContainer->topLevelDockWidget();
|
TopLevelDockWidgetBefore = DockContainer->topLevelDockWidget();
|
||||||
}
|
}
|
||||||
|
|
||||||
if (Open)
|
if (Open)
|
||||||
{
|
{
|
||||||
|
TopLevelDockWidget = TopLevelDockWidgetBefore;
|
||||||
d->showDockWidget();
|
d->showDockWidget();
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
@ -468,6 +470,22 @@ void CDockWidget::toggleViewInternal(bool Open)
|
|||||||
CDockWidget::emitTopLevelEventForWidget(TopLevelDockWidget, !Open);
|
CDockWidget::emitTopLevelEventForWidget(TopLevelDockWidget, !Open);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
CDockWidget* TopLevelDockWidgetAfter = nullptr;
|
||||||
|
if (DockContainer)
|
||||||
|
{
|
||||||
|
TopLevelDockWidgetAfter = DockContainer->topLevelDockWidget();
|
||||||
|
}
|
||||||
|
|
||||||
|
if (TopLevelDockWidgetAfter != TopLevelDockWidgetBefore)
|
||||||
|
{
|
||||||
|
CFloatingDockContainer* FloatingContainer = qobject_cast<CFloatingDockContainer*>(DockContainer->parentWidget());
|
||||||
|
if (FloatingContainer)
|
||||||
|
{
|
||||||
|
FloatingContainer->updateWindowTitle(TopLevelDockWidgetAfter ? TopLevelDockWidgetAfter->windowTitle() : "");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
if (!Open)
|
if (!Open)
|
||||||
{
|
{
|
||||||
emit closed();
|
emit closed();
|
||||||
|
@ -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)
|
void CFloatingDockContainer::onDockAreaCurrentChanged(int Index)
|
||||||
{
|
{
|
||||||
|
@ -68,6 +68,7 @@ private:
|
|||||||
friend class CDockWidgetTab;
|
friend class CDockWidgetTab;
|
||||||
friend class CDockAreaTitleBar;
|
friend class CDockAreaTitleBar;
|
||||||
friend struct DockAreaTitleBarPrivate;
|
friend struct DockAreaTitleBarPrivate;
|
||||||
|
friend class CDockWidget;
|
||||||
|
|
||||||
private slots:
|
private slots:
|
||||||
void onDockAreasAddedOrRemoved();
|
void onDockAreasAddedOrRemoved();
|
||||||
@ -95,6 +96,11 @@ protected:
|
|||||||
*/
|
*/
|
||||||
bool restoreState(QXmlStreamReader& Stream, bool Testing);
|
bool restoreState(QXmlStreamReader& Stream, bool Testing);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Call this function to update the window title
|
||||||
|
*/
|
||||||
|
void updateWindowTitle(const QString& Title ="");
|
||||||
|
|
||||||
|
|
||||||
protected: // reimplements QWidget
|
protected: // reimplements QWidget
|
||||||
virtual void changeEvent(QEvent *event) override;
|
virtual void changeEvent(QEvent *event) override;
|
||||||
|
@ -1,5 +1,6 @@
|
|||||||
<RCC>
|
<RCC>
|
||||||
<qresource prefix="/ads">
|
<qresource prefix="/ads">
|
||||||
<file>stylesheets/default.css</file>
|
<file>stylesheets/default.css</file>
|
||||||
|
<file>close.svg</file>
|
||||||
</qresource>
|
</qresource>
|
||||||
</RCC>
|
</RCC>
|
||||||
|
Loading…
Reference in New Issue
Block a user