forked from qt-creator/qt-creator
ProjectExplorer: Remove PropertiesPanel struct
Parameter structs are convenient if they get passed around a lot or are regularly changed. This isn't the case here, so make the user code more compact instead. Change-Id: Idd5e5cc1f70b1547607532cd3e6515c27983c169 Reviewed-by: Tobias Hunger <tobias.hunger@qt.io>
This commit is contained in:
@@ -25,8 +25,6 @@
|
|||||||
|
|
||||||
#include "panelswidget.h"
|
#include "panelswidget.h"
|
||||||
|
|
||||||
#include "propertiespanel.h"
|
|
||||||
|
|
||||||
#include <QPainter>
|
#include <QPainter>
|
||||||
#include <QVBoxLayout>
|
#include <QVBoxLayout>
|
||||||
#include <QLabel>
|
#include <QLabel>
|
||||||
@@ -122,7 +120,6 @@ PanelsWidget::PanelsWidget(QWidget *parent) :
|
|||||||
pal.setColor(QPalette::All, QPalette::Window, background);
|
pal.setColor(QPalette::All, QPalette::Window, background);
|
||||||
m_root->setPalette(pal);
|
m_root->setPalette(pal);
|
||||||
|
|
||||||
|
|
||||||
m_scroller = new QScrollArea(this);
|
m_scroller = new QScrollArea(this);
|
||||||
m_scroller->setWidget(m_root);
|
m_scroller->setWidget(m_root);
|
||||||
m_scroller->setFrameStyle(QFrame::NoFrame);
|
m_scroller->setFrameStyle(QFrame::NoFrame);
|
||||||
@@ -152,7 +149,6 @@ PanelsWidget::PanelsWidget(QWidget *parent) :
|
|||||||
|
|
||||||
PanelsWidget::~PanelsWidget()
|
PanelsWidget::~PanelsWidget()
|
||||||
{
|
{
|
||||||
qDeleteAll(m_panels);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/*
|
/*
|
||||||
@@ -168,23 +164,21 @@ PanelsWidget::~PanelsWidget()
|
|||||||
* | | widget (with contentsmargins adjusted!) |
|
* | | widget (with contentsmargins adjusted!) |
|
||||||
* +--------+-------------------------------------------+ BELOW_CONTENTS_MARGIN
|
* +--------+-------------------------------------------+ BELOW_CONTENTS_MARGIN
|
||||||
*/
|
*/
|
||||||
void PanelsWidget::addPropertiesPanel(PropertiesPanel *panel)
|
void PanelsWidget::addPropertiesPanel(const QString &displayName, const QIcon &icon, QWidget *widget)
|
||||||
{
|
{
|
||||||
QTC_ASSERT(panel, return);
|
|
||||||
|
|
||||||
const int headerRow = m_layout->rowCount();
|
const int headerRow = m_layout->rowCount();
|
||||||
|
|
||||||
// icon:
|
// icon:
|
||||||
if (!panel->icon().isNull()) {
|
if (!icon.isNull()) {
|
||||||
auto iconLabel = new QLabel(m_root);
|
auto iconLabel = new QLabel(m_root);
|
||||||
iconLabel->setPixmap(panel->icon().pixmap(ICON_SIZE, ICON_SIZE));
|
iconLabel->setPixmap(icon.pixmap(ICON_SIZE, ICON_SIZE));
|
||||||
iconLabel->setContentsMargins(0, ABOVE_HEADING_MARGIN, 0, 0);
|
iconLabel->setContentsMargins(0, ABOVE_HEADING_MARGIN, 0, 0);
|
||||||
m_layout->addWidget(iconLabel, headerRow, 0, 3, 1, Qt::AlignTop | Qt::AlignHCenter);
|
m_layout->addWidget(iconLabel, headerRow, 0, 3, 1, Qt::AlignTop | Qt::AlignHCenter);
|
||||||
}
|
}
|
||||||
|
|
||||||
// name:
|
// name:
|
||||||
auto nameLabel = new QLabel(m_root);
|
auto nameLabel = new QLabel(m_root);
|
||||||
nameLabel->setText(panel->displayName());
|
nameLabel->setText(displayName);
|
||||||
QPalette palette = nameLabel->palette();
|
QPalette palette = nameLabel->palette();
|
||||||
for (int i = QPalette::Active; i < QPalette::NColorGroups; ++i ) {
|
for (int i = QPalette::Active; i < QPalette::NColorGroups; ++i ) {
|
||||||
// FIXME: theming
|
// FIXME: theming
|
||||||
@@ -201,23 +195,16 @@ void PanelsWidget::addPropertiesPanel(PropertiesPanel *panel)
|
|||||||
m_layout->addWidget(nameLabel, headerRow, 1, 1, 1, Qt::AlignVCenter | Qt::AlignLeft);
|
m_layout->addWidget(nameLabel, headerRow, 1, 1, 1, Qt::AlignVCenter | Qt::AlignLeft);
|
||||||
|
|
||||||
// line:
|
// line:
|
||||||
const int lineRow(headerRow + 1);
|
const int lineRow = headerRow + 1;
|
||||||
auto line = new OnePixelBlackLine(m_root);
|
auto line = new OnePixelBlackLine(m_root);
|
||||||
m_layout->addWidget(line, lineRow, 1, 1, -1, Qt::AlignTop);
|
m_layout->addWidget(line, lineRow, 1, 1, -1, Qt::AlignTop);
|
||||||
|
|
||||||
// add the widget:
|
// add the widget:
|
||||||
const int widgetRow(lineRow + 1);
|
const int widgetRow = lineRow + 1;
|
||||||
addPanelWidget(panel, widgetRow);
|
|
||||||
}
|
|
||||||
|
|
||||||
void PanelsWidget::addPanelWidget(PropertiesPanel *panel, int row)
|
|
||||||
{
|
|
||||||
QWidget *widget = panel->widget();
|
|
||||||
widget->setContentsMargins(PANEL_LEFT_MARGIN,
|
widget->setContentsMargins(PANEL_LEFT_MARGIN,
|
||||||
ABOVE_CONTENTS_MARGIN, 0,
|
ABOVE_CONTENTS_MARGIN, 0,
|
||||||
BELOW_CONTENTS_MARGIN);
|
BELOW_CONTENTS_MARGIN);
|
||||||
widget->setParent(m_root);
|
widget->setParent(m_root);
|
||||||
m_layout->addWidget(widget, row, 0, 1, 2);
|
m_layout->addWidget(widget, widgetRow, 0, 1, 2);
|
||||||
|
|
||||||
m_panels.append(panel);
|
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -31,25 +31,23 @@
|
|||||||
|
|
||||||
QT_BEGIN_NAMESPACE
|
QT_BEGIN_NAMESPACE
|
||||||
class QGridLayout;
|
class QGridLayout;
|
||||||
|
class QIcon;
|
||||||
QT_END_NAMESPACE
|
QT_END_NAMESPACE
|
||||||
|
|
||||||
namespace ProjectExplorer {
|
namespace ProjectExplorer {
|
||||||
class PropertiesPanel;
|
|
||||||
|
|
||||||
class PROJECTEXPLORER_EXPORT PanelsWidget : public QWidget
|
class PROJECTEXPLORER_EXPORT PanelsWidget : public QWidget
|
||||||
{
|
{
|
||||||
Q_OBJECT
|
Q_OBJECT
|
||||||
|
|
||||||
public:
|
public:
|
||||||
explicit PanelsWidget(QWidget *parent = nullptr);
|
explicit PanelsWidget(QWidget *parent = nullptr);
|
||||||
~PanelsWidget() override;
|
~PanelsWidget() override;
|
||||||
|
|
||||||
// Adds a widget
|
void addPropertiesPanel(const QString &displayName, const QIcon &icon,
|
||||||
void addPropertiesPanel(PropertiesPanel *panel);
|
QWidget *widget);
|
||||||
|
|
||||||
private:
|
private:
|
||||||
void addPanelWidget(PropertiesPanel *panel, int row);
|
|
||||||
|
|
||||||
QList<PropertiesPanel *> m_panels;
|
|
||||||
QGridLayout *m_layout;
|
QGridLayout *m_layout;
|
||||||
QScrollArea *m_scroller;
|
QScrollArea *m_scroller;
|
||||||
QWidget *m_root;
|
QWidget *m_root;
|
||||||
|
|||||||
@@ -142,7 +142,6 @@ HEADERS += projectexplorer.h \
|
|||||||
ipotentialkit.h \
|
ipotentialkit.h \
|
||||||
selectablefilesmodel.h \
|
selectablefilesmodel.h \
|
||||||
xcodebuildparser.h \
|
xcodebuildparser.h \
|
||||||
propertiespanel.h \
|
|
||||||
panelswidget.h \
|
panelswidget.h \
|
||||||
projectwelcomepage.h \
|
projectwelcomepage.h \
|
||||||
sessionmodel.h \
|
sessionmodel.h \
|
||||||
@@ -283,7 +282,6 @@ SOURCES += projectexplorer.cpp \
|
|||||||
customparserconfigdialog.cpp \
|
customparserconfigdialog.cpp \
|
||||||
selectablefilesmodel.cpp \
|
selectablefilesmodel.cpp \
|
||||||
xcodebuildparser.cpp \
|
xcodebuildparser.cpp \
|
||||||
propertiespanel.cpp \
|
|
||||||
panelswidget.cpp \
|
panelswidget.cpp \
|
||||||
projectwelcomepage.cpp \
|
projectwelcomepage.cpp \
|
||||||
sessionmodel.cpp \
|
sessionmodel.cpp \
|
||||||
|
|||||||
@@ -127,7 +127,6 @@ Project {
|
|||||||
"projecttreewidget.cpp", "projecttreewidget.h",
|
"projecttreewidget.cpp", "projecttreewidget.h",
|
||||||
"projectwindow.cpp", "projectwindow.h",
|
"projectwindow.cpp", "projectwindow.h",
|
||||||
"projectwizardpage.cpp", "projectwizardpage.h", "projectwizardpage.ui",
|
"projectwizardpage.cpp", "projectwizardpage.h", "projectwizardpage.ui",
|
||||||
"propertiespanel.cpp", "propertiespanel.h",
|
|
||||||
"removetaskhandler.cpp", "removetaskhandler.h",
|
"removetaskhandler.cpp", "removetaskhandler.h",
|
||||||
"runnables.cpp", "runnables.h",
|
"runnables.cpp", "runnables.h",
|
||||||
"runconfiguration.cpp", "runconfiguration.h",
|
"runconfiguration.cpp", "runconfiguration.h",
|
||||||
|
|||||||
@@ -31,7 +31,6 @@
|
|||||||
#include "project.h"
|
#include "project.h"
|
||||||
#include "projectexplorer.h"
|
#include "projectexplorer.h"
|
||||||
#include "projectpanelfactory.h"
|
#include "projectpanelfactory.h"
|
||||||
#include "propertiespanel.h"
|
|
||||||
#include "session.h"
|
#include "session.h"
|
||||||
#include "target.h"
|
#include "target.h"
|
||||||
#include "targetsettingspanel.h"
|
#include "targetsettingspanel.h"
|
||||||
@@ -97,12 +96,10 @@ QVariant MiscSettingsPanelItem::data(int column, int role) const
|
|||||||
if (role == PanelWidgetRole) {
|
if (role == PanelWidgetRole) {
|
||||||
if (!m_widget) {
|
if (!m_widget) {
|
||||||
auto panelsWidget = new PanelsWidget;
|
auto panelsWidget = new PanelsWidget;
|
||||||
auto panel = new PropertiesPanel;
|
|
||||||
panel->setDisplayName(m_factory->displayName());
|
|
||||||
QWidget *widget = m_factory->createWidget(m_project);
|
QWidget *widget = m_factory->createWidget(m_project);
|
||||||
panel->setWidget(widget);
|
panelsWidget->addPropertiesPanel(m_factory->displayName(),
|
||||||
panel->setIcon(QIcon(m_factory->icon()));
|
QIcon(m_factory->icon()),
|
||||||
panelsWidget->addPropertiesPanel(panel);
|
widget);
|
||||||
panelsWidget->setFocusProxy(widget);
|
panelsWidget->setFocusProxy(widget);
|
||||||
m_widget = panelsWidget;
|
m_widget = panelsWidget;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,26 +0,0 @@
|
|||||||
/****************************************************************************
|
|
||||||
**
|
|
||||||
** Copyright (C) 2016 The Qt Company Ltd.
|
|
||||||
** Contact: https://www.qt.io/licensing/
|
|
||||||
**
|
|
||||||
** This file is part of Qt Creator.
|
|
||||||
**
|
|
||||||
** Commercial License Usage
|
|
||||||
** Licensees holding valid commercial Qt licenses may use this file in
|
|
||||||
** accordance with the commercial license agreement provided with the
|
|
||||||
** Software or, alternatively, in accordance with the terms contained in
|
|
||||||
** a written agreement between you and The Qt Company. For licensing terms
|
|
||||||
** and conditions see https://www.qt.io/terms-conditions. For further
|
|
||||||
** information use the contact form at https://www.qt.io/contact-us.
|
|
||||||
**
|
|
||||||
** GNU General Public License Usage
|
|
||||||
** Alternatively, this file may be used under the terms of the GNU
|
|
||||||
** General Public License version 3 as published by the Free Software
|
|
||||||
** Foundation with exceptions as appearing in the file LICENSE.GPL3-EXCEPT
|
|
||||||
** included in the packaging of this file. Please review the following
|
|
||||||
** information to ensure the GNU General Public License requirements will
|
|
||||||
** be met: https://www.gnu.org/licenses/gpl-3.0.html.
|
|
||||||
**
|
|
||||||
****************************************************************************/
|
|
||||||
|
|
||||||
#include "propertiespanel.h"
|
|
||||||
@@ -1,57 +0,0 @@
|
|||||||
/****************************************************************************
|
|
||||||
**
|
|
||||||
** Copyright (C) 2016 The Qt Company Ltd.
|
|
||||||
** Contact: https://www.qt.io/licensing/
|
|
||||||
**
|
|
||||||
** This file is part of Qt Creator.
|
|
||||||
**
|
|
||||||
** Commercial License Usage
|
|
||||||
** Licensees holding valid commercial Qt licenses may use this file in
|
|
||||||
** accordance with the commercial license agreement provided with the
|
|
||||||
** Software or, alternatively, in accordance with the terms contained in
|
|
||||||
** a written agreement between you and The Qt Company. For licensing terms
|
|
||||||
** and conditions see https://www.qt.io/terms-conditions. For further
|
|
||||||
** information use the contact form at https://www.qt.io/contact-us.
|
|
||||||
**
|
|
||||||
** GNU General Public License Usage
|
|
||||||
** Alternatively, this file may be used under the terms of the GNU
|
|
||||||
** General Public License version 3 as published by the Free Software
|
|
||||||
** Foundation with exceptions as appearing in the file LICENSE.GPL3-EXCEPT
|
|
||||||
** included in the packaging of this file. Please review the following
|
|
||||||
** information to ensure the GNU General Public License requirements will
|
|
||||||
** be met: https://www.gnu.org/licenses/gpl-3.0.html.
|
|
||||||
**
|
|
||||||
****************************************************************************/
|
|
||||||
|
|
||||||
#pragma once
|
|
||||||
|
|
||||||
#include "projectexplorer_export.h"
|
|
||||||
|
|
||||||
#include <QIcon>
|
|
||||||
#include <QWidget>
|
|
||||||
|
|
||||||
namespace ProjectExplorer {
|
|
||||||
|
|
||||||
class PROJECTEXPLORER_EXPORT PropertiesPanel
|
|
||||||
{
|
|
||||||
Q_DISABLE_COPY(PropertiesPanel)
|
|
||||||
|
|
||||||
public:
|
|
||||||
PropertiesPanel() = default;
|
|
||||||
~PropertiesPanel() { delete m_widget; }
|
|
||||||
|
|
||||||
QString displayName() const { return m_displayName; }
|
|
||||||
QIcon icon() const { return m_icon; }
|
|
||||||
QWidget *widget() const { return m_widget; }
|
|
||||||
|
|
||||||
void setDisplayName(const QString &name) { m_displayName = name; }
|
|
||||||
void setIcon(const QIcon &icon) { m_icon = icon; }
|
|
||||||
void setWidget(QWidget *widget) { m_widget = widget; }
|
|
||||||
|
|
||||||
private:
|
|
||||||
QString m_displayName;
|
|
||||||
QWidget *m_widget = nullptr;
|
|
||||||
QIcon m_icon;
|
|
||||||
};
|
|
||||||
|
|
||||||
} // namespace ProjectExplorer
|
|
||||||
@@ -39,7 +39,6 @@
|
|||||||
#include "projectimporter.h"
|
#include "projectimporter.h"
|
||||||
#include "projecttree.h"
|
#include "projecttree.h"
|
||||||
#include "projectwindow.h"
|
#include "projectwindow.h"
|
||||||
#include "propertiespanel.h"
|
|
||||||
#include "runsettingspropertiespage.h"
|
#include "runsettingspropertiespage.h"
|
||||||
#include "session.h"
|
#include "session.h"
|
||||||
#include "target.h"
|
#include "target.h"
|
||||||
@@ -257,29 +256,25 @@ void TargetGroupItemPrivate::ensureWidget()
|
|||||||
|
|
||||||
if (!m_configurePage) {
|
if (!m_configurePage) {
|
||||||
auto panelsWidget = new PanelsWidget;
|
auto panelsWidget = new PanelsWidget;
|
||||||
auto panel = new PropertiesPanel;
|
|
||||||
panel->setDisplayName(tr("Configure Project"));
|
|
||||||
auto widget = new TargetSetupPageWrapper(m_project);
|
auto widget = new TargetSetupPageWrapper(m_project);
|
||||||
panel->setWidget(widget);
|
panelsWidget->addPropertiesPanel(tr("Configure Project"),
|
||||||
panel->setIcon(QIcon(":/projectexplorer/images/unconfigured.png"));
|
QIcon(":/projectexplorer/images/unconfigured.png"),
|
||||||
panelsWidget->addPropertiesPanel(panel);
|
widget);
|
||||||
panelsWidget->setFocusProxy(widget);
|
panelsWidget->setFocusProxy(widget);
|
||||||
m_configurePage = panelsWidget;
|
m_configurePage = panelsWidget;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!m_configuredPage) {
|
if (!m_configuredPage) {
|
||||||
auto panelsWidget = new PanelsWidget;
|
auto panelsWidget = new PanelsWidget;
|
||||||
auto panel = new PropertiesPanel;
|
|
||||||
panel->setDisplayName(tr("Configure Project"));
|
|
||||||
auto widget = new QWidget;
|
auto widget = new QWidget;
|
||||||
auto label = new QLabel("This project is already configured.");
|
auto label = new QLabel("This project is already configured.");
|
||||||
auto layout = new QVBoxLayout(widget);
|
auto layout = new QVBoxLayout(widget);
|
||||||
layout->setMargin(0);
|
layout->setMargin(0);
|
||||||
layout->addWidget(label);
|
layout->addWidget(label);
|
||||||
layout->addStretch(10);
|
layout->addStretch(10);
|
||||||
panel->setWidget(widget);
|
panelsWidget->addPropertiesPanel(tr("Configure Project"),
|
||||||
panel->setIcon(QIcon(":/projectexplorer/images/unconfigured.png"));
|
QIcon(":/projectexplorer/images/unconfigured.png"),
|
||||||
panelsWidget->addPropertiesPanel(panel);
|
widget);
|
||||||
m_configuredPage = panelsWidget;
|
m_configuredPage = panelsWidget;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -605,18 +600,14 @@ public:
|
|||||||
|
|
||||||
static QWidget *createPanelWidget(QWidget *widget, const QString &displayName, const QString &icon)
|
static QWidget *createPanelWidget(QWidget *widget, const QString &displayName, const QString &icon)
|
||||||
{
|
{
|
||||||
auto panel = new PropertiesPanel;
|
|
||||||
auto w = new QWidget();
|
auto w = new QWidget();
|
||||||
auto l = new QVBoxLayout(w);
|
auto l = new QVBoxLayout(w);
|
||||||
l->addWidget(widget);
|
l->addWidget(widget);
|
||||||
l->addSpacerItem(new QSpacerItem(0, 0, QSizePolicy::Minimum, QSizePolicy::Expanding));
|
l->addSpacerItem(new QSpacerItem(0, 0, QSizePolicy::Minimum, QSizePolicy::Expanding));
|
||||||
l->setContentsMargins(QMargins());
|
l->setContentsMargins(QMargins());
|
||||||
panel->setWidget(w);
|
|
||||||
panel->setIcon(QIcon(icon));
|
|
||||||
panel->setDisplayName(displayName);
|
|
||||||
|
|
||||||
auto result = new PanelsWidget;
|
auto result = new PanelsWidget;
|
||||||
result->addPropertiesPanel(panel);
|
result->addPropertiesPanel(displayName, QIcon(icon), w);
|
||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -37,7 +37,6 @@
|
|||||||
#include <coreplugin/editormanager/ieditor.h>
|
#include <coreplugin/editormanager/ieditor.h>
|
||||||
|
|
||||||
#include <projectexplorer/projectpanelfactory.h>
|
#include <projectexplorer/projectpanelfactory.h>
|
||||||
#include <projectexplorer/propertiespanel.h>
|
|
||||||
|
|
||||||
#include <QtPlugin>
|
#include <QtPlugin>
|
||||||
#include <QFileInfo>
|
#include <QFileInfo>
|
||||||
|
|||||||
Reference in New Issue
Block a user