Commit ada14295 authored by Hannah von Reth's avatar Hannah von Reth

Introduce setPerspectiveEnabled

This enables us to mark perspectives as disabled.

Change-Id: I52b2434f33f8550b6d2459f915dfd8cdb1389140
Reviewed-by: Eike Ziller's avatarEike Ziller <eike.ziller@qt.io>
Reviewed-by: default avatarhjk <hjk@qt.io>
parent 429163ea
......@@ -131,6 +131,7 @@ private:
// Register a tool for a given start mode.
DEBUGGER_EXPORT void registerAction(Core::Id actionId, const ActionDescription &desc, QAction *startAction = 0);
DEBUGGER_EXPORT void registerPerspective(const QByteArray &perspectiveId, const Utils::Perspective *perspective);
DEBUGGER_EXPORT void setPerspectiveEnabled(const QByteArray &perspectiveId, bool enable);
DEBUGGER_EXPORT void registerToolbar(const QByteArray &perspectiveId, const Utils::ToolbarDescription &desc);
DEBUGGER_EXPORT void enableMainWindow(bool on);
......
......@@ -50,6 +50,7 @@
#include <QHBoxLayout>
#include <QMenu>
#include <QStackedWidget>
#include <QStandardItemModel>
#include <QToolButton>
using namespace Debugger;
......@@ -142,6 +143,16 @@ void DebuggerMainWindow::onModeChanged(Core::Id mode)
}
}
void DebuggerMainWindow::setPerspectiveEnabled(const QByteArray &perspectiveId, bool enabled)
{
const int index = m_perspectiveChooser->findData(perspectiveId);
QTC_ASSERT(index != -1, return);
auto model = qobject_cast<QStandardItemModel*>(m_perspectiveChooser->model());
QTC_ASSERT(model, return);
QStandardItem *item = model->item(index, 0);
item->setFlags(enabled ? item->flags() | Qt::ItemIsEnabled : item->flags() & ~Qt::ItemIsEnabled );
}
void DebuggerMainWindow::resetCurrentPerspective()
{
loadPerspectiveHelper(m_currentPerspectiveId, false);
......
......@@ -136,6 +136,8 @@ public:
void onModeChanged(Core::Id mode);
void setPerspectiveEnabled(const QByteArray &perspectiveId, bool enabled);
private:
QDockWidget *registerDockWidget(const QByteArray &dockId, QWidget *widget);
void loadPerspectiveHelper(const QByteArray &perspectiveId, bool fromStoredSettings = true);
......
......@@ -3607,6 +3607,11 @@ void registerPerspective(const QByteArray &perspectiveId, const Perspective *per
dd->m_mainWindow->registerPerspective(perspectiveId, perspective);
}
void setPerspectiveEnabled(const QByteArray &perspectiveId, bool enabled)
{
dd->m_mainWindow->setPerspectiveEnabled(perspectiveId, enabled);
}
void selectPerspective(const QByteArray &perspectiveId)
{
if (dd->m_mainWindow->currentPerspective() == perspectiveId)
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment