forked from qt-creator/qt-creator
ProjectExplorer: (Ab-)Use window title for panel tab display name
Moves the specification of the name closer to the widget itself and simplifies the overall structure, at the price of some (bearable) obscurity. Change-Id: I8c8f15175e64f8d406cbd742d158e681f67ec316 Reviewed-by: Christian Kandeler <christian.kandeler@qt.io>
This commit is contained in:
@@ -74,6 +74,8 @@ private:
|
|||||||
BuildSettingsWidget::BuildSettingsWidget(Target *target)
|
BuildSettingsWidget::BuildSettingsWidget(Target *target)
|
||||||
: m_target(target)
|
: m_target(target)
|
||||||
{
|
{
|
||||||
|
setWindowTitle(Tr::tr("Build Settings"));
|
||||||
|
|
||||||
auto vbox = new QVBoxLayout(this);
|
auto vbox = new QVBoxLayout(this);
|
||||||
vbox->setContentsMargins(0, 0, 0, 0);
|
vbox->setContentsMargins(0, 0, 0, 0);
|
||||||
|
|
||||||
|
@@ -60,6 +60,7 @@ PanelsWidget::~PanelsWidget() = default;
|
|||||||
|
|
||||||
void PanelsWidget::addWidget(QWidget *widget)
|
void PanelsWidget::addWidget(QWidget *widget)
|
||||||
{
|
{
|
||||||
|
setWindowTitle(widget->windowTitle());
|
||||||
widget->setContentsMargins(0, CONTENTS_MARGIN, 0, BELOW_CONTENTS_MARGIN);
|
widget->setContentsMargins(0, CONTENTS_MARGIN, 0, BELOW_CONTENTS_MARGIN);
|
||||||
widget->setParent(m_root);
|
widget->setParent(m_root);
|
||||||
m_layout->addWidget(widget);
|
m_layout->addWidget(widget);
|
||||||
|
@@ -99,6 +99,7 @@ public:
|
|||||||
: m_settings(project)
|
: m_settings(project)
|
||||||
{
|
{
|
||||||
setGlobalSettingsId(TextEditor::Constants::TEXT_EDITOR_COMMENTS_SETTINGS);
|
setGlobalSettingsId(TextEditor::Constants::TEXT_EDITOR_COMMENTS_SETTINGS);
|
||||||
|
|
||||||
const auto layout = new QVBoxLayout(this);
|
const auto layout = new QVBoxLayout(this);
|
||||||
layout->setContentsMargins(0, 0, 0, 0);
|
layout->setContentsMargins(0, 0, 0, 0);
|
||||||
layout->addWidget(&m_widget);
|
layout->addWidget(&m_widget);
|
||||||
|
@@ -32,8 +32,9 @@ public:
|
|||||||
|
|
||||||
// interface for users of ProjectPanelFactory
|
// interface for users of ProjectPanelFactory
|
||||||
bool supports(Project *project);
|
bool supports(Project *project);
|
||||||
|
// Widgets created by this function should use setWindowTitle() to specify
|
||||||
using WidgetCreator = std::function<ProjectSettingsWidget *(Project *)>;
|
// their tab title.
|
||||||
|
ProjectSettingsWidget *createWidget(Project *project) const;
|
||||||
|
|
||||||
// interface for "implementations" of ProjectPanelFactory
|
// interface for "implementations" of ProjectPanelFactory
|
||||||
// by default all projects are supported, only set a custom supports function
|
// by default all projects are supported, only set a custom supports function
|
||||||
@@ -45,8 +46,8 @@ public:
|
|||||||
|
|
||||||
Utils::TreeItem *createPanelItem(Project *project);
|
Utils::TreeItem *createPanelItem(Project *project);
|
||||||
|
|
||||||
|
using WidgetCreator = std::function<ProjectSettingsWidget *(Project *)>;
|
||||||
void setCreateWidgetFunction(const WidgetCreator &createWidgetFunction);
|
void setCreateWidgetFunction(const WidgetCreator &createWidgetFunction);
|
||||||
ProjectSettingsWidget *createWidget(Project *project) const;
|
|
||||||
|
|
||||||
private:
|
private:
|
||||||
Utils::Id m_id;
|
Utils::Id m_id;
|
||||||
|
@@ -219,19 +219,7 @@ void BuildSystemOutputWindow::updateFilter()
|
|||||||
0 /* after context */);
|
0 /* after context */);
|
||||||
}
|
}
|
||||||
|
|
||||||
class ProjectPanel
|
using ProjectPanels = QList<QWidget *>;
|
||||||
{
|
|
||||||
public:
|
|
||||||
ProjectPanel() = default;
|
|
||||||
ProjectPanel(const QString &displayName, QWidget *widget)
|
|
||||||
: displayName(displayName), widget(widget)
|
|
||||||
{}
|
|
||||||
|
|
||||||
QString displayName;
|
|
||||||
QWidget *widget = nullptr;
|
|
||||||
};
|
|
||||||
|
|
||||||
using ProjectPanels = QList<ProjectPanel>;
|
|
||||||
|
|
||||||
// Overall structure:
|
// Overall structure:
|
||||||
//
|
//
|
||||||
@@ -519,12 +507,10 @@ ProjectPanels MiscSettingsPanelItem::panelWidgets() const
|
|||||||
panel->addGlobalSettingsProperties(inner);
|
panel->addGlobalSettingsProperties(inner);
|
||||||
panel->addWidget(inner);
|
panel->addWidget(inner);
|
||||||
panel->setFocusProxy(inner);
|
panel->setFocusProxy(inner);
|
||||||
|
panel->setWindowTitle(m_factory->displayName());
|
||||||
m_widget = panel;
|
m_widget = panel;
|
||||||
}
|
}
|
||||||
ProjectPanel panel;
|
return {m_widget.get()};
|
||||||
panel.displayName = m_factory->displayName();
|
|
||||||
panel.widget = m_widget;
|
|
||||||
return QList{panel};
|
|
||||||
}
|
}
|
||||||
|
|
||||||
ProjectItemBase *MiscSettingsPanelItem::activeItem()
|
ProjectItemBase *MiscSettingsPanelItem::activeItem()
|
||||||
@@ -756,6 +742,8 @@ private:
|
|||||||
TargetSetupPageWrapper::TargetSetupPageWrapper(Project *project)
|
TargetSetupPageWrapper::TargetSetupPageWrapper(Project *project)
|
||||||
: m_project(project)
|
: m_project(project)
|
||||||
{
|
{
|
||||||
|
setWindowTitle(Tr::tr("Configure Project"));
|
||||||
|
|
||||||
auto box = new QDialogButtonBox(this);
|
auto box = new QDialogButtonBox(this);
|
||||||
|
|
||||||
m_configureButton = new QPushButton(this);
|
m_configureButton = new QPushButton(this);
|
||||||
@@ -892,10 +880,7 @@ public:
|
|||||||
if (!m_runSettingsWidget)
|
if (!m_runSettingsWidget)
|
||||||
m_runSettingsWidget = createRunSettingsWidget(target());
|
m_runSettingsWidget = createRunSettingsWidget(target());
|
||||||
|
|
||||||
return {
|
return { m_buildSettingsWidget.get(), m_runSettingsWidget.get() };
|
||||||
ProjectPanel(Tr::tr("Build Settings"), m_buildSettingsWidget),
|
|
||||||
ProjectPanel(Tr::tr("Run Settings"), m_runSettingsWidget)
|
|
||||||
};
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void addToMenu(QMenu *menu) const final
|
void addToMenu(QMenu *menu) const final
|
||||||
@@ -1106,11 +1091,7 @@ ProjectPanels TargetGroupItem::panelWidgets() const
|
|||||||
m_targetSetupPage = panel;
|
m_targetSetupPage = panel;
|
||||||
}
|
}
|
||||||
|
|
||||||
ProjectPanel panel;
|
return {m_targetSetupPage.get()};
|
||||||
panel.displayName = Tr::tr("Configure Project");
|
|
||||||
panel.widget = m_targetSetupPage;
|
|
||||||
|
|
||||||
return {panel};
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void TargetGroupItem::itemActivatedFromBelow(const ProjectItemBase *)
|
void TargetGroupItem::itemActivatedFromBelow(const ProjectItemBase *)
|
||||||
@@ -1290,9 +1271,9 @@ public:
|
|||||||
m_tabWidget->removeTab(pos);
|
m_tabWidget->removeTab(pos);
|
||||||
}
|
}
|
||||||
|
|
||||||
for (const ProjectPanel &panel : panels) {
|
for (QWidget *panel : panels) {
|
||||||
QTC_ASSERT(panel.widget, continue);
|
QTC_ASSERT(panel, continue);
|
||||||
m_tabWidget->addTab(panel.widget, panel.displayName);
|
m_tabWidget->addTab(panel, panel->windowTitle());
|
||||||
}
|
}
|
||||||
|
|
||||||
m_tabWidget->setCurrentIndex(oldIndex);
|
m_tabWidget->setCurrentIndex(oldIndex);
|
||||||
|
@@ -245,6 +245,8 @@ private:
|
|||||||
RunSettingsWidget::RunSettingsWidget(Target *target)
|
RunSettingsWidget::RunSettingsWidget(Target *target)
|
||||||
: m_target(target)
|
: m_target(target)
|
||||||
{
|
{
|
||||||
|
setWindowTitle(Tr::tr("Run Settings"));
|
||||||
|
|
||||||
m_deployConfigurationCombo = new QComboBox(this);
|
m_deployConfigurationCombo = new QComboBox(this);
|
||||||
setWheelScrollingWithoutFocusBlocked(m_deployConfigurationCombo);
|
setWheelScrollingWithoutFocusBlocked(m_deployConfigurationCombo);
|
||||||
m_addDeployToolButton = new QPushButton(Tr::tr("Add"), this);
|
m_addDeployToolButton = new QPushButton(Tr::tr("Add"), this);
|
||||||
|
Reference in New Issue
Block a user