Debugger: Re-organize registration of sub-perspective switcher

Change-Id: Ia3559e5c4793bb297c9bdfbdf32a56d285ee0700
Reviewed-by: Eike Ziller <eike.ziller@qt.io>
This commit is contained in:
hjk
2018-09-11 11:24:19 +02:00
parent 51adb199ab
commit 375791ec58
4 changed files with 24 additions and 17 deletions

View File

@@ -667,7 +667,7 @@ void DebuggerEnginePrivate::setupViews()
m_breakWindow->setObjectName(DOCKWIDGET_BREAK);
m_breakWindow->setWindowTitle(tr("&Breakpoints"));
m_perspective->addToolBarSwitcher(EngineManager::engineChooser(), false);
m_perspective->useSubPerspectiveSwitcher(EngineManager::engineChooser());
m_perspective->addToolBarAction(&m_continueAction);
m_perspective->addToolBarAction(&m_interruptAction);

View File

@@ -122,7 +122,7 @@ public:
Perspective *m_currentPerspective = nullptr;
QComboBox *m_perspectiveChooser = nullptr;
QStackedWidget *m_centralWidgetStack = nullptr;
QHBoxLayout *m_subToolsSwitcherLayout = nullptr;
QHBoxLayout *m_subPerspectiveSwitcherLayout = nullptr;
QHBoxLayout *m_innerToolsLayout = nullptr;
QWidget *m_editorPlaceHolder = nullptr;
Utils::StatusLabel *m_statusLabel = nullptr;
@@ -165,10 +165,10 @@ DebuggerMainWindowPrivate::DebuggerMainWindowPrivate(DebuggerMainWindow *parent)
toolbar->setProperty("topBorder", true);
// "Engine switcher" style comboboxes
auto subToolsSwitcher = new QWidget;
m_subToolsSwitcherLayout = new QHBoxLayout(subToolsSwitcher);
m_subToolsSwitcherLayout->setMargin(0);
m_subToolsSwitcherLayout->setSpacing(0);
auto subPerspectiveSwitcher = new QWidget;
m_subPerspectiveSwitcherLayout = new QHBoxLayout(subPerspectiveSwitcher);
m_subPerspectiveSwitcherLayout->setMargin(0);
m_subPerspectiveSwitcherLayout->setSpacing(0);
// All perspective toolbars will get inserted here, but only
// the current perspective's toolbar is set visible.
@@ -181,7 +181,7 @@ DebuggerMainWindowPrivate::DebuggerMainWindowPrivate(DebuggerMainWindow *parent)
hbox->setMargin(0);
hbox->setSpacing(0);
hbox->addWidget(m_perspectiveChooser);
hbox->addWidget(subToolsSwitcher);
hbox->addWidget(subPerspectiveSwitcher);
hbox->addWidget(innerTools);
hbox->addWidget(m_statusLabel);
hbox->addStretch(1);
@@ -332,6 +332,13 @@ QWidget *DebuggerMainWindow::centralWidgetStack()
return theMainWindow ? theMainWindow->d->m_centralWidgetStack : nullptr;
}
void DebuggerMainWindow::setSubPerspectiveSwitcher(QWidget *widget)
{
widget->setVisible(false);
widget->setProperty("panelwidget", true);
d->m_subPerspectiveSwitcherLayout->addWidget(widget);
}
DebuggerMainWindow *DebuggerMainWindow::instance()
{
return theMainWindow;
@@ -393,8 +400,10 @@ void DebuggerMainWindowPrivate::selectPerspective(Perspective *perspective)
}
}
QWidget *createModeWindow(const Core::Id &mode)
QWidget *createModeWindow(const Core::Id &mode, QWidget *switcher)
{
theMainWindow->setSubPerspectiveSwitcher(switcher);
auto editorHolderLayout = new QVBoxLayout;
editorHolderLayout->setMargin(0);
editorHolderLayout->setSpacing(0);
@@ -633,13 +642,9 @@ void Perspective::addToolBarWidget(QWidget *widget)
d->m_innerToolBarLayout->addWidget(widget);
}
void Perspective::addToolBarSwitcher(QWidget *widget, bool owner)
void Perspective::useSubPerspectiveSwitcher(QWidget *widget)
{
d->m_switcher = widget;
d->m_switcher->setProperty("panelwidget", true);
d->m_switcher->setVisible(false);
if (owner)
theMainWindow->d->m_subToolsSwitcherLayout->addWidget(d->m_switcher);
}
void Perspective::addToolbarSeparator()

View File

@@ -79,9 +79,10 @@ public:
void addToolBarAction(QAction *action);
void addToolBarAction(OptionalAction *action);
void addToolBarWidget(QWidget *widget);
void addToolBarSwitcher(QWidget *widget, bool owner);
void addToolbarSeparator();
void useSubPerspectiveSwitcher(QWidget *widget);
using ShouldPersistChecker = std::function<bool()>;
void setShouldPersistChecker(const ShouldPersistChecker &checker);
@@ -127,6 +128,7 @@ public:
static void onModeChanged(Core::Id mode);
static QWidget *centralWidgetStack();
void setSubPerspectiveSwitcher(QWidget *widget);
private:
DebuggerMainWindow();
@@ -137,6 +139,6 @@ private:
class DebuggerMainWindowPrivate *d = nullptr;
};
DEBUGGER_EXPORT QWidget *createModeWindow(const Core::Id &mode);
DEBUGGER_EXPORT QWidget *createModeWindow(const Core::Id &mode, QWidget *);
} // Utils

View File

@@ -1296,7 +1296,7 @@ bool DebuggerPluginPrivate::initialize(const QStringList &arguments,
// Debug mode setup
m_mode = new DebugMode;
m_modeWindow = createModeWindow(Constants::MODE_DEBUG);
m_modeWindow = createModeWindow(Constants::MODE_DEBUG, EngineManager::engineChooser());
m_mode->setWidget(m_modeWindow);
m_debugModeContext.setContext(Context(CC::C_EDITORMANAGER));
@@ -1339,7 +1339,7 @@ bool DebuggerPluginPrivate::initialize(const QStringList &arguments,
connect(action(SettingsDialog), &QAction::triggered,
[] { ICore::showOptionsDialog(DEBUGGER_COMMON_SETTINGS_ID); });
m_perspective.addToolBarSwitcher(EngineManager::engineChooser(), true);
m_perspective.useSubPerspectiveSwitcher(EngineManager::engineChooser());
m_perspective.addToolBarAction(&m_startAction);
// QAction *operateByInstructionAction = action(OperateByInstruction);