Debugger: Add a way to notify perspective about their activation

Change-Id: I5a6189e835aa293341f357c08f1d4b8ca4dd8326
Reviewed-by: Filipe Azevedo <filipe.azevedo@kdab.com>
Reviewed-by: hjk <hjk@qt.io>
This commit is contained in:
hjk
2016-11-21 13:57:11 +01:00
parent a33b9317b8
commit 6de88f7fae
2 changed files with 17 additions and 0 deletions

View File

@@ -301,6 +301,7 @@ void DebuggerMainWindow::loadPerspectiveHelper(const QByteArray &perspectiveId,
QTC_ASSERT(m_perspectiveForPerspectiveId.contains(m_currentPerspectiveId), return); QTC_ASSERT(m_perspectiveForPerspectiveId.contains(m_currentPerspectiveId), return);
const Perspective *perspective = m_perspectiveForPerspectiveId.value(m_currentPerspectiveId); const Perspective *perspective = m_perspectiveForPerspectiveId.value(m_currentPerspectiveId);
perspective->aboutToActivate();
for (const Perspective::Operation &operation : perspective->operations()) { for (const Perspective::Operation &operation : perspective->operations()) {
QDockWidget *dock = m_dockForDockId.value(operation.dockId); QDockWidget *dock = m_dockForDockId.value(operation.dockId);
if (!dock) { if (!dock) {
@@ -405,6 +406,17 @@ void Perspective::setName(const QString &name)
m_name = name; m_name = name;
} }
void Perspective::setAboutToActivateCallback(const Perspective::Callback &cb)
{
m_aboutToActivateCallback = cb;
}
void Perspective::aboutToActivate()
{
if (m_aboutToActivateCallback)
m_aboutToActivateCallback();
}
QList<QWidget *> ToolbarDescription::widgets() const QList<QWidget *> ToolbarDescription::widgets() const
{ {
return m_widgets; return m_widgets;

View File

@@ -82,6 +82,10 @@ public:
QString name() const; QString name() const;
void setName(const QString &name); void setName(const QString &name);
using Callback = std::function<void()>;
void setAboutToActivateCallback(const Callback &cb);
void aboutToActivate();
private: private:
Perspective(const Perspective &) = delete; Perspective(const Perspective &) = delete;
void operator=(const Perspective &) = delete; void operator=(const Perspective &) = delete;
@@ -90,6 +94,7 @@ private:
QVector<QByteArray> m_docks; QVector<QByteArray> m_docks;
QVector<Operation> m_operations; QVector<Operation> m_operations;
QPointer<QWidget> m_centralWidget; QPointer<QWidget> m_centralWidget;
Callback m_aboutToActivateCallback;
}; };
class DEBUGGER_EXPORT ToolbarDescription class DEBUGGER_EXPORT ToolbarDescription