Skip to content

Commit 87e3777

Browse files
author
Uwe Kindler
committed
Fixed hiding and showing of close button for tab group, added support for removing perspectives
1 parent 71f66ea commit 87e3777

File tree

4 files changed

+61
-4
lines changed

4 files changed

+61
-4
lines changed

demo/demo.pro

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -9,11 +9,15 @@ CONFIG *= c++14
99

1010
SOURCES += \
1111
main.cpp \
12-
MainWindow.cpp
12+
MainWindow.cpp \
13+
mhtabbar.cpp \
14+
mhtabwidget.cpp
1315

1416

1517
HEADERS += \
16-
MainWindow.h
18+
MainWindow.h \
19+
mhtabbar.h \
20+
mhtabwidget.h
1721

1822
FORMS += \
1923
mainwindow.ui

src/DockContainerWidget.cpp

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -261,10 +261,12 @@ void DockContainerWidgetPrivate::onVisibleDockAreaCountChanged()
261261
{
262262
this->TopLevelDockArea = TopLevelDockArea;
263263
TopLevelDockArea->titleBarButton(TitleBarButtonUndock)->setVisible(false || !_this->isFloating());
264+
TopLevelDockArea->titleBarButton(TitleBarButtonClose)->setVisible(false || !_this->isFloating());
264265
}
265266
else if (this->TopLevelDockArea)
266267
{
267268
this->TopLevelDockArea->titleBarButton(TitleBarButtonUndock)->setVisible(true);
269+
this->TopLevelDockArea->titleBarButton(TitleBarButtonClose)->setVisible(true);
268270
this->TopLevelDockArea = nullptr;
269271
}
270272
}
@@ -416,6 +418,7 @@ void DockContainerWidgetPrivate::addDockAreasToList(const QList<CDockAreaWidget*
416418
for (auto DockArea : NewDockAreas)
417419
{
418420
DockArea->titleBarButton(TitleBarButtonUndock)->setVisible(true);
421+
DockArea->titleBarButton(TitleBarButtonClose)->setVisible(true);
419422
}
420423

421424
// We need to ensure, that the dock area title bar is visible. The title bar

src/DockManager.cpp

Lines changed: 35 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -515,6 +515,7 @@ QByteArray CDockManager::saveState(eXmlMode XmlMode, int version) const
515515
//============================================================================
516516
bool CDockManager::restoreState(const QByteArray &state, int version)
517517
{
518+
std::cout << "CDockManager::restoreState-----------------------" << std::endl;
518519
QElapsedTimer Timer;
519520
Timer.start();
520521

@@ -586,12 +587,19 @@ CDockAreaWidget* CDockManager::addDockWidgetTabToArea(CDockWidget* Dockwidget,
586587

587588

588589
//============================================================================
589-
CDockWidget* CDockManager::findDockWidget(const QString& ObjectName)
590+
CDockWidget* CDockManager::findDockWidget(const QString& ObjectName) const
590591
{
591592
return d->DockWidgetsMap.value(ObjectName, nullptr);
592593
}
593594

594595

596+
//============================================================================
597+
QMap<QString, CDockWidget*> CDockManager::dockWidgetsMap() const
598+
{
599+
return d->DockWidgetsMap;
600+
}
601+
602+
595603
//============================================================================
596604
void CDockManager::addPerspective(const QString& UniquePrespectiveName)
597605
{
@@ -600,6 +608,32 @@ void CDockManager::addPerspective(const QString& UniquePrespectiveName)
600608
}
601609

602610

611+
//============================================================================
612+
void CDockManager::removePerspective(const QString& Name)
613+
{
614+
if (d->Perspectives.remove(Name))
615+
{
616+
emit perspectiveListChanged();
617+
}
618+
}
619+
620+
621+
//============================================================================
622+
void CDockManager::removePerspectives(const QStringList& Names)
623+
{
624+
int Count = 0;
625+
for (auto Name : Names)
626+
{
627+
Count += d->Perspectives.remove(Name);
628+
}
629+
630+
if (Count)
631+
{
632+
emit perspectiveListChanged();
633+
}
634+
}
635+
636+
603637
//============================================================================
604638
QStringList CDockManager::perspectiveNames() const
605639
{

src/DockManager.h

Lines changed: 17 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -189,7 +189,13 @@ class ADS_EXPORT CDockManager : public CDockContainerWidget
189189
* \return Return the found dock widget or nullptr if a dock widget with the
190190
* given name is not registered
191191
*/
192-
CDockWidget* findDockWidget(const QString& ObjectName);
192+
CDockWidget* findDockWidget(const QString& ObjectName) const;
193+
194+
/**
195+
* This function returns a readable reference to the internal dock
196+
* widgets map so that it is possible to iterate over all dock widgets
197+
*/
198+
QMap<QString, CDockWidget*> dockWidgetsMap() const;
193199

194200
/**
195201
* Returns the list of all active and visible dock containers
@@ -237,6 +243,16 @@ class ADS_EXPORT CDockManager : public CDockContainerWidget
237243
*/
238244
void addPerspective(const QString& UniquePrespectiveName);
239245

246+
/**
247+
* Removes the perspective with the given name from the list of perspectives
248+
*/
249+
void removePerspective(const QString& Name);
250+
251+
/**
252+
* Removes the given perspectives from the dock manager
253+
*/
254+
void removePerspectives(const QStringList& Names);
255+
240256
/**
241257
* Returns the names of all available perspectives
242258
*/

0 commit comments

Comments
 (0)