Fixed hiding and showing of close button for tab group, added support for removing perspectives

This commit is contained in:
Uwe Kindler 2018-12-02 12:09:31 +01:00
parent 71f66ea6dc
commit 87e3777e37
4 changed files with 61 additions and 4 deletions

View File

@ -9,11 +9,15 @@ CONFIG *= c++14
SOURCES += \
main.cpp \
MainWindow.cpp
MainWindow.cpp \
mhtabbar.cpp \
mhtabwidget.cpp
HEADERS += \
MainWindow.h
MainWindow.h \
mhtabbar.h \
mhtabwidget.h
FORMS += \
mainwindow.ui

View File

@ -261,10 +261,12 @@ void DockContainerWidgetPrivate::onVisibleDockAreaCountChanged()
{
this->TopLevelDockArea = TopLevelDockArea;
TopLevelDockArea->titleBarButton(TitleBarButtonUndock)->setVisible(false || !_this->isFloating());
TopLevelDockArea->titleBarButton(TitleBarButtonClose)->setVisible(false || !_this->isFloating());
}
else if (this->TopLevelDockArea)
{
this->TopLevelDockArea->titleBarButton(TitleBarButtonUndock)->setVisible(true);
this->TopLevelDockArea->titleBarButton(TitleBarButtonClose)->setVisible(true);
this->TopLevelDockArea = nullptr;
}
}
@ -416,6 +418,7 @@ void DockContainerWidgetPrivate::addDockAreasToList(const QList<CDockAreaWidget*
for (auto DockArea : NewDockAreas)
{
DockArea->titleBarButton(TitleBarButtonUndock)->setVisible(true);
DockArea->titleBarButton(TitleBarButtonClose)->setVisible(true);
}
// We need to ensure, that the dock area title bar is visible. The title bar

View File

@ -515,6 +515,7 @@ QByteArray CDockManager::saveState(eXmlMode XmlMode, int version) const
//============================================================================
bool CDockManager::restoreState(const QByteArray &state, int version)
{
std::cout << "CDockManager::restoreState-----------------------" << std::endl;
QElapsedTimer Timer;
Timer.start();
@ -586,12 +587,19 @@ CDockAreaWidget* CDockManager::addDockWidgetTabToArea(CDockWidget* Dockwidget,
//============================================================================
CDockWidget* CDockManager::findDockWidget(const QString& ObjectName)
CDockWidget* CDockManager::findDockWidget(const QString& ObjectName) const
{
return d->DockWidgetsMap.value(ObjectName, nullptr);
}
//============================================================================
QMap<QString, CDockWidget*> CDockManager::dockWidgetsMap() const
{
return d->DockWidgetsMap;
}
//============================================================================
void CDockManager::addPerspective(const QString& UniquePrespectiveName)
{
@ -600,6 +608,32 @@ void CDockManager::addPerspective(const QString& UniquePrespectiveName)
}
//============================================================================
void CDockManager::removePerspective(const QString& Name)
{
if (d->Perspectives.remove(Name))
{
emit perspectiveListChanged();
}
}
//============================================================================
void CDockManager::removePerspectives(const QStringList& Names)
{
int Count = 0;
for (auto Name : Names)
{
Count += d->Perspectives.remove(Name);
}
if (Count)
{
emit perspectiveListChanged();
}
}
//============================================================================
QStringList CDockManager::perspectiveNames() const
{

View File

@ -189,7 +189,13 @@ public:
* \return Return the found dock widget or nullptr if a dock widget with the
* given name is not registered
*/
CDockWidget* findDockWidget(const QString& ObjectName);
CDockWidget* findDockWidget(const QString& ObjectName) const;
/**
* This function returns a readable reference to the internal dock
* widgets map so that it is possible to iterate over all dock widgets
*/
QMap<QString, CDockWidget*> dockWidgetsMap() const;
/**
* Returns the list of all active and visible dock containers
@ -237,6 +243,16 @@ public:
*/
void addPerspective(const QString& UniquePrespectiveName);
/**
* Removes the perspective with the given name from the list of perspectives
*/
void removePerspective(const QString& Name);
/**
* Removes the given perspectives from the dock manager
*/
void removePerspectives(const QStringList& Names);
/**
* Returns the names of all available perspectives
*/