diff options
author | Eike Ziller <eike.ziller@qt.io> | 2021-09-22 11:33:01 +0200 |
---|---|---|
committer | Eike Ziller <eike.ziller@qt.io> | 2021-09-24 06:45:28 +0000 |
commit | e84bc5f81f05f306e63f86ea139a3b897d5877b1 (patch) | |
tree | dd1641c83b57a765246d9f8f1caceedc4c1e0afe | |
parent | 0e1ce368b923d91f6f1d8f6ab4f28a8a64c2efa3 (diff) |
Modes: Temporarily re-add a removeMode function
Partially reverts 6a142dfd95ab497c1fe247cd4289affa13444577
Looks like this was used by 3rdparty plugin(s) for a mode that is only
useful for some time and then should not be shown again.
Re-add removeMode from before 5.0, but do not trigger that automatically
from the mode destructor, so it doesn't interfere at shutdown.
This patch is just a binary compatible partial revert. Since removeMode
is broken in several aspects (e.g. corresponding commands are not
removed) and we don't really support adding and removing modes during
runtime, this should be replaced later on by a different way to handle
the usecase, like a "visible" property for modes, which could be useful
in other ways too.
Fixes: QTCREATORBUG-26270
Change-Id: Ief2a36d94bd09b0511a14f528b33fdbcc4c4222b
Reviewed-by: Jarek Kobus <jaroslaw.kobus@qt.io>
-rw-r--r-- | src/plugins/coreplugin/fancytabwidget.cpp | 6 | ||||
-rw-r--r-- | src/plugins/coreplugin/fancytabwidget.h | 7 | ||||
-rw-r--r-- | src/plugins/coreplugin/modemanager.cpp | 15 | ||||
-rw-r--r-- | src/plugins/coreplugin/modemanager.h | 2 |
4 files changed, 30 insertions, 0 deletions
diff --git a/src/plugins/coreplugin/fancytabwidget.cpp b/src/plugins/coreplugin/fancytabwidget.cpp index 00f5d74fcc..c72b89762d 100644 --- a/src/plugins/coreplugin/fancytabwidget.cpp +++ b/src/plugins/coreplugin/fancytabwidget.cpp @@ -551,6 +551,12 @@ void FancyTabWidget::insertTab(int index, QWidget *tab, const QIcon &icon, const m_tabBar->insertTab(index, icon, label, hasMenu); } +void FancyTabWidget::removeTab(int index) +{ + m_modesStack->removeWidget(m_modesStack->widget(index)); + m_tabBar->removeTab(index); +} + void FancyTabWidget::setBackgroundBrush(const QBrush &brush) { QPalette pal; diff --git a/src/plugins/coreplugin/fancytabwidget.h b/src/plugins/coreplugin/fancytabwidget.h index c52376c545..8c5544665d 100644 --- a/src/plugins/coreplugin/fancytabwidget.h +++ b/src/plugins/coreplugin/fancytabwidget.h @@ -109,6 +109,12 @@ public: updateGeometry(); } void setEnabled(int index, bool enabled); + void removeTab(int index) + { + FancyTab *tab = m_tabs.takeAt(index); + delete tab; + updateGeometry(); + } void setCurrentIndex(int index); int currentIndex() const { return m_currentIndex; } @@ -142,6 +148,7 @@ public: FancyTabWidget(QWidget *parent = nullptr); void insertTab(int index, QWidget *tab, const QIcon &icon, const QString &label, bool hasMenu); + void removeTab(int index); void setBackgroundBrush(const QBrush &brush); void addCornerWidget(QWidget *widget); void insertCornerWidget(int pos, QWidget *widget); diff --git a/src/plugins/coreplugin/modemanager.cpp b/src/plugins/coreplugin/modemanager.cpp index c8c33519e1..4a7e3cf369 100644 --- a/src/plugins/coreplugin/modemanager.cpp +++ b/src/plugins/coreplugin/modemanager.cpp @@ -256,6 +256,21 @@ void ModeManagerPrivate::appendMode(IMode *mode) QObject::connect(mode, &IMode::enabledStateChanged, [this, mode] { enabledStateChanged(mode); }); } +void ModeManager::removeMode(IMode *mode) +{ + const int index = d->m_modes.indexOf(mode); + if (index >= d->m_modes.size() - 1 && d->m_modes.size() > 1) + d->m_modeStack->setCurrentIndex(d->m_modes.size() - 2); + d->m_modes.remove(index); + if (d->m_startingUp) + return; + + d->m_modeCommands.remove(index); + d->m_modeStack->removeTab(index); + + d->m_mainWindow->removeContextObject(mode); +} + void ModeManagerPrivate::enabledStateChanged(IMode *mode) { int index = d->m_modes.indexOf(mode); diff --git a/src/plugins/coreplugin/modemanager.h b/src/plugins/coreplugin/modemanager.h index 7ba0393ce8..cbf963df9d 100644 --- a/src/plugins/coreplugin/modemanager.h +++ b/src/plugins/coreplugin/modemanager.h @@ -67,6 +67,8 @@ public: static void setFocusToCurrentMode(); static Style modeStyle(); + static void removeMode(IMode *mode); + public slots: static void setModeStyle(Style layout); static void cycleModeStyle(); |