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 "propertiespanel.h"
|
||||
|
||||
#include <QPainter>
|
||||
#include <QVBoxLayout>
|
||||
#include <QLabel>
|
||||
@@ -122,7 +120,6 @@ PanelsWidget::PanelsWidget(QWidget *parent) :
|
||||
pal.setColor(QPalette::All, QPalette::Window, background);
|
||||
m_root->setPalette(pal);
|
||||
|
||||
|
||||
m_scroller = new QScrollArea(this);
|
||||
m_scroller->setWidget(m_root);
|
||||
m_scroller->setFrameStyle(QFrame::NoFrame);
|
||||
@@ -152,7 +149,6 @@ PanelsWidget::PanelsWidget(QWidget *parent) :
|
||||
|
||||
PanelsWidget::~PanelsWidget()
|
||||
{
|
||||
qDeleteAll(m_panels);
|
||||
}
|
||||
|
||||
/*
|
||||
@@ -168,23 +164,21 @@ PanelsWidget::~PanelsWidget()
|
||||
* | | widget (with contentsmargins adjusted!) |
|
||||
* +--------+-------------------------------------------+ 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();
|
||||
|
||||
// icon:
|
||||
if (!panel->icon().isNull()) {
|
||||
if (!icon.isNull()) {
|
||||
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);
|
||||
m_layout->addWidget(iconLabel, headerRow, 0, 3, 1, Qt::AlignTop | Qt::AlignHCenter);
|
||||
}
|
||||
|
||||
// name:
|
||||
auto nameLabel = new QLabel(m_root);
|
||||
nameLabel->setText(panel->displayName());
|
||||
nameLabel->setText(displayName);
|
||||
QPalette palette = nameLabel->palette();
|
||||
for (int i = QPalette::Active; i < QPalette::NColorGroups; ++i ) {
|
||||
// FIXME: theming
|
||||
@@ -201,23 +195,16 @@ void PanelsWidget::addPropertiesPanel(PropertiesPanel *panel)
|
||||
m_layout->addWidget(nameLabel, headerRow, 1, 1, 1, Qt::AlignVCenter | Qt::AlignLeft);
|
||||
|
||||
// line:
|
||||
const int lineRow(headerRow + 1);
|
||||
const int lineRow = headerRow + 1;
|
||||
auto line = new OnePixelBlackLine(m_root);
|
||||
m_layout->addWidget(line, lineRow, 1, 1, -1, Qt::AlignTop);
|
||||
|
||||
// add the widget:
|
||||
const int widgetRow(lineRow + 1);
|
||||
addPanelWidget(panel, widgetRow);
|
||||
}
|
||||
const int widgetRow = lineRow + 1;
|
||||
|
||||
void PanelsWidget::addPanelWidget(PropertiesPanel *panel, int row)
|
||||
{
|
||||
QWidget *widget = panel->widget();
|
||||
widget->setContentsMargins(PANEL_LEFT_MARGIN,
|
||||
ABOVE_CONTENTS_MARGIN, 0,
|
||||
BELOW_CONTENTS_MARGIN);
|
||||
widget->setParent(m_root);
|
||||
m_layout->addWidget(widget, row, 0, 1, 2);
|
||||
|
||||
m_panels.append(panel);
|
||||
m_layout->addWidget(widget, widgetRow, 0, 1, 2);
|
||||
}
|
||||
|
||||
@@ -31,25 +31,23 @@
|
||||
|
||||
QT_BEGIN_NAMESPACE
|
||||
class QGridLayout;
|
||||
class QIcon;
|
||||
QT_END_NAMESPACE
|
||||
|
||||
namespace ProjectExplorer {
|
||||
class PropertiesPanel;
|
||||
|
||||
class PROJECTEXPLORER_EXPORT PanelsWidget : public QWidget
|
||||
{
|
||||
Q_OBJECT
|
||||
|
||||
public:
|
||||
explicit PanelsWidget(QWidget *parent = nullptr);
|
||||
~PanelsWidget() override;
|
||||
|
||||
// Adds a widget
|
||||
void addPropertiesPanel(PropertiesPanel *panel);
|
||||
void addPropertiesPanel(const QString &displayName, const QIcon &icon,
|
||||
QWidget *widget);
|
||||
|
||||
private:
|
||||
void addPanelWidget(PropertiesPanel *panel, int row);
|
||||
|
||||
QList<PropertiesPanel *> m_panels;
|
||||
QGridLayout *m_layout;
|
||||
QScrollArea *m_scroller;
|
||||
QWidget *m_root;
|
||||
|
||||
@@ -142,7 +142,6 @@ HEADERS += projectexplorer.h \
|
||||
ipotentialkit.h \
|
||||
selectablefilesmodel.h \
|
||||
xcodebuildparser.h \
|
||||
propertiespanel.h \
|
||||
panelswidget.h \
|
||||
projectwelcomepage.h \
|
||||
sessionmodel.h \
|
||||
@@ -283,7 +282,6 @@ SOURCES += projectexplorer.cpp \
|
||||
customparserconfigdialog.cpp \
|
||||
selectablefilesmodel.cpp \
|
||||
xcodebuildparser.cpp \
|
||||
propertiespanel.cpp \
|
||||
panelswidget.cpp \
|
||||
projectwelcomepage.cpp \
|
||||
sessionmodel.cpp \
|
||||
|
||||
@@ -127,7 +127,6 @@ Project {
|
||||
"projecttreewidget.cpp", "projecttreewidget.h",
|
||||
"projectwindow.cpp", "projectwindow.h",
|
||||
"projectwizardpage.cpp", "projectwizardpage.h", "projectwizardpage.ui",
|
||||
"propertiespanel.cpp", "propertiespanel.h",
|
||||
"removetaskhandler.cpp", "removetaskhandler.h",
|
||||
"runnables.cpp", "runnables.h",
|
||||
"runconfiguration.cpp", "runconfiguration.h",
|
||||
|
||||
@@ -31,7 +31,6 @@
|
||||
#include "project.h"
|
||||
#include "projectexplorer.h"
|
||||
#include "projectpanelfactory.h"
|
||||
#include "propertiespanel.h"
|
||||
#include "session.h"
|
||||
#include "target.h"
|
||||
#include "targetsettingspanel.h"
|
||||
@@ -97,12 +96,10 @@ QVariant MiscSettingsPanelItem::data(int column, int role) const
|
||||
if (role == PanelWidgetRole) {
|
||||
if (!m_widget) {
|
||||
auto panelsWidget = new PanelsWidget;
|
||||
auto panel = new PropertiesPanel;
|
||||
panel->setDisplayName(m_factory->displayName());
|
||||
QWidget *widget = m_factory->createWidget(m_project);
|
||||
panel->setWidget(widget);
|
||||
panel->setIcon(QIcon(m_factory->icon()));
|
||||
panelsWidget->addPropertiesPanel(panel);
|
||||
panelsWidget->addPropertiesPanel(m_factory->displayName(),
|
||||
QIcon(m_factory->icon()),
|
||||
widget);
|
||||
panelsWidget->setFocusProxy(widget);
|
||||
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 "projecttree.h"
|
||||
#include "projectwindow.h"
|
||||
#include "propertiespanel.h"
|
||||
#include "runsettingspropertiespage.h"
|
||||
#include "session.h"
|
||||
#include "target.h"
|
||||
@@ -257,29 +256,25 @@ void TargetGroupItemPrivate::ensureWidget()
|
||||
|
||||
if (!m_configurePage) {
|
||||
auto panelsWidget = new PanelsWidget;
|
||||
auto panel = new PropertiesPanel;
|
||||
panel->setDisplayName(tr("Configure Project"));
|
||||
auto widget = new TargetSetupPageWrapper(m_project);
|
||||
panel->setWidget(widget);
|
||||
panel->setIcon(QIcon(":/projectexplorer/images/unconfigured.png"));
|
||||
panelsWidget->addPropertiesPanel(panel);
|
||||
panelsWidget->addPropertiesPanel(tr("Configure Project"),
|
||||
QIcon(":/projectexplorer/images/unconfigured.png"),
|
||||
widget);
|
||||
panelsWidget->setFocusProxy(widget);
|
||||
m_configurePage = panelsWidget;
|
||||
}
|
||||
|
||||
if (!m_configuredPage) {
|
||||
auto panelsWidget = new PanelsWidget;
|
||||
auto panel = new PropertiesPanel;
|
||||
panel->setDisplayName(tr("Configure Project"));
|
||||
auto widget = new QWidget;
|
||||
auto label = new QLabel("This project is already configured.");
|
||||
auto layout = new QVBoxLayout(widget);
|
||||
layout->setMargin(0);
|
||||
layout->addWidget(label);
|
||||
layout->addStretch(10);
|
||||
panel->setWidget(widget);
|
||||
panel->setIcon(QIcon(":/projectexplorer/images/unconfigured.png"));
|
||||
panelsWidget->addPropertiesPanel(panel);
|
||||
panelsWidget->addPropertiesPanel(tr("Configure Project"),
|
||||
QIcon(":/projectexplorer/images/unconfigured.png"),
|
||||
widget);
|
||||
m_configuredPage = panelsWidget;
|
||||
}
|
||||
}
|
||||
@@ -605,18 +600,14 @@ public:
|
||||
|
||||
static QWidget *createPanelWidget(QWidget *widget, const QString &displayName, const QString &icon)
|
||||
{
|
||||
auto panel = new PropertiesPanel;
|
||||
auto w = new QWidget();
|
||||
auto l = new QVBoxLayout(w);
|
||||
l->addWidget(widget);
|
||||
l->addSpacerItem(new QSpacerItem(0, 0, QSizePolicy::Minimum, QSizePolicy::Expanding));
|
||||
l->setContentsMargins(QMargins());
|
||||
panel->setWidget(w);
|
||||
panel->setIcon(QIcon(icon));
|
||||
panel->setDisplayName(displayName);
|
||||
|
||||
auto result = new PanelsWidget;
|
||||
result->addPropertiesPanel(panel);
|
||||
result->addPropertiesPanel(displayName, QIcon(icon), w);
|
||||
return result;
|
||||
}
|
||||
|
||||
|
||||
@@ -37,7 +37,6 @@
|
||||
#include <coreplugin/editormanager/ieditor.h>
|
||||
|
||||
#include <projectexplorer/projectpanelfactory.h>
|
||||
#include <projectexplorer/propertiespanel.h>
|
||||
|
||||
#include <QtPlugin>
|
||||
#include <QFileInfo>
|
||||
|
||||
Reference in New Issue
Block a user