Commit 65648ee1 authored by dt's avatar dt

The project pane rewrite version 2.

This splits up the edit and active settings. Let people try it and
report usability problems. I'm not 100% convinced of the layout either.
parent f52077bd
#include "detailsbutton.h"
using namespace Utils;
DetailsButton::DetailsButton(QWidget *parent)
#ifdef Q_OS_MAC
: QPushButton(parent)
#else
: QToolButton(parent)
#endif
{
#ifdef Q_OS_MAC
setAttribute(Qt::WA_MacSmallSize);
setSizePolicy(QSizePolicy::Fixed, QSizePolicy::Fixed);
s.upButton->setIconSize(QSize(10, 10));
s.downButton->setIconSize(QSize(10, 10));
#else
setCheckable(true);
#endif
setText(tr("Details"));
}
#ifndef DETAILSBUTTON_H
#define DETAILSBUTTON_H
#include <QtGui/QPushButton>
#include <QtGui/QToolButton>
#include "utils_global.h"
namespace Utils {
class QTCREATOR_UTILS_EXPORT DetailsButton
#ifdef Q_OS_MAC
: public QPushButton
#else
: public QToolButton
#endif
{
Q_OBJECT
public:
DetailsButton(QWidget *parent=0);
};
}
#endif // DETAILSBUTTON_H
......@@ -33,7 +33,8 @@ SOURCES += reloadpromptutils.cpp \
styledbar.cpp \
stylehelper.cpp \
welcomemodetreewidget.cpp \
fancymainwindow.cpp
fancymainwindow.cpp \
detailsbutton.cpp
win32 {
SOURCES += abstractprocess_win.cpp \
consoleprocess_win.cpp \
......@@ -74,7 +75,8 @@ HEADERS += utils_global.h \
styledbar.h \
stylehelper.h \
welcomemodetreewidget.h \
fancymainwindow.h
fancymainwindow.h \
detailsbutton.h
FORMS += filewizardpage.ui \
projectintropage.ui \
newclasswidget.ui \
......
......@@ -35,6 +35,7 @@
#include <projectexplorer/environment.h>
#include <projectexplorer/debugginghelper.h>
#include <utils/qtcassert.h>
#include <utils/detailsbutton.h>
#include <QtGui/QFormLayout>
#include <QtGui/QLineEdit>
#include <QtGui/QGroupBox>
......@@ -260,9 +261,21 @@ CMakeRunConfigurationWidget::CMakeRunConfigurationWidget(CMakeRunConfiguration *
fl->addRow(tr("Working Directory:"), boxlayout);
m_detailsWidget = new QWidget(this);
m_detailsWidget->setLayout(fl);
m_detailsWidget->setVisible(false);
m_summaryLabel = new QLabel(this);
m_detailsButton = new Utils::DetailsButton(this);
QHBoxLayout *hbox = new QHBoxLayout();
hbox->addWidget(m_summaryLabel);
hbox->addWidget(m_detailsButton);
QVBoxLayout *vbx = new QVBoxLayout(this);
vbx->setContentsMargins(0, -1, 0, -1);
vbx->addLayout(fl);
vbx->addLayout(hbox);
vbx->addWidget(m_detailsWidget);
QLabel *environmentLabel = new QLabel(this);
environmentLabel->setText(tr("Run Environment"));
......@@ -288,17 +301,22 @@ CMakeRunConfigurationWidget::CMakeRunConfigurationWidget(CMakeRunConfiguration *
baseEnvironmentLayout->addWidget(m_baseEnvironmentComboBox);
baseEnvironmentLayout->addStretch(10);
m_environmentWidget = new ProjectExplorer::EnvironmentWidget(this, baseEnvironmentWidget);
m_environmentWidget->setBaseEnvironment(m_cmakeRunConfiguration->baseEnvironment());
m_environmentWidget->setUserChanges(m_cmakeRunConfiguration->userEnvironmentChanges());
vbx->addWidget(m_environmentWidget);
updateSummary();
connect(m_workingDirectoryEdit, SIGNAL(changed(QString)),
this, SLOT(setWorkingDirectory()));
connect(resetButton, SIGNAL(clicked()),
this, SLOT(resetWorkingDirectory()));
m_environmentWidget = new ProjectExplorer::EnvironmentWidget(this, baseEnvironmentWidget);
m_environmentWidget->setBaseEnvironment(m_cmakeRunConfiguration->baseEnvironment());
m_environmentWidget->setUserChanges(m_cmakeRunConfiguration->userEnvironmentChanges());
vbx->addWidget(m_environmentWidget);
connect(m_detailsButton, SIGNAL(clicked()),
this, SLOT(toggleDetails()));
connect(m_environmentWidget, SIGNAL(userChangesUpdated()),
this, SLOT(userChangesUpdated()));
......@@ -312,6 +330,11 @@ CMakeRunConfigurationWidget::CMakeRunConfigurationWidget(CMakeRunConfiguration *
}
void CMakeRunConfigurationWidget::toggleDetails()
{
m_detailsWidget->setVisible(!m_detailsWidget->isVisible());
}
void CMakeRunConfigurationWidget::setWorkingDirectory()
{
if (m_ignoreChange)
......@@ -365,6 +388,15 @@ void CMakeRunConfigurationWidget::userEnvironmentChangesChanged()
void CMakeRunConfigurationWidget::setArguments(const QString &args)
{
m_cmakeRunConfiguration->setArguments(args);
updateSummary();
}
void CMakeRunConfigurationWidget::updateSummary()
{
QString text = tr("Running executable: <b>%1</b> %2")
.arg(QFileInfo(m_cmakeRunConfiguration->executable()).fileName(),
ProjectExplorer::Environment::joinArgumentList(m_cmakeRunConfiguration->commandLineArguments()));
m_summaryLabel->setText(text);
}
......
......@@ -115,13 +115,17 @@ private slots:
private slots:
void baseEnvironmentComboBoxChanged(int index);
void workingDirectoryChanged(const QString &workingDirectory);
void toggleDetails();
private:
void updateSummary();
bool m_ignoreChange;
CMakeRunConfiguration *m_cmakeRunConfiguration;
Core::Utils::PathChooser *m_workingDirectoryEdit;
QComboBox *m_baseEnvironmentComboBox;
ProjectExplorer::EnvironmentWidget *m_environmentWidget;
QWidget *m_detailsWidget;
QLabel *m_summaryLabel;
QAbstractButton *m_detailsButton;
};
class CMakeRunConfigurationFactory : public ProjectExplorer::IRunConfigurationFactory
......
......@@ -122,7 +122,7 @@ QList<QWidget *> BuildSettingsSubWidgets::widgets() const
}
BuildSettingsSubWidgets::BuildSettingsSubWidgets(QWidget *parent)
: QGroupBox(parent)
: QWidget(parent)
{
new QVBoxLayout(this);
}
......@@ -141,7 +141,7 @@ BuildSettingsWidget::BuildSettingsWidget(Project *project)
QVBoxLayout *vbox = new QVBoxLayout(this);
vbox->setContentsMargins(0, -1, 0, -1);
QHBoxLayout *hbox = new QHBoxLayout();
hbox->addWidget(new QLabel(tr("Build Configuration:"), this));
hbox->addWidget(new QLabel(tr("Edit Build Configuration:"), this));
m_buildConfigurationComboBox = new QComboBox(this);
m_buildConfigurationComboBox->setSizeAdjustPolicy(QComboBox::AdjustToContents);
hbox->addWidget(m_buildConfigurationComboBox);
......@@ -170,17 +170,14 @@ BuildSettingsWidget::BuildSettingsWidget(Project *project)
this, SLOT(cloneConfiguration()));
m_addButton->setMenu(addButtonMenu);
m_buildConfiguration = m_project->activeBuildConfiguration();
connect(m_buildConfigurationComboBox, SIGNAL(currentIndexChanged(int)),
this, SLOT(currentIndexChanged(int)));
// TODO currentIndexChanged
// needs to change active configuration
// and set widgets
connect(m_removeButton, SIGNAL(clicked()),
this, SLOT(deleteConfiguration()));
connect(m_project, SIGNAL(activeBuildConfigurationChanged()),
this, SLOT(activeBuildConfigurationChanged()));
connect(m_project, SIGNAL(buildConfigurationDisplayNameChanged(const QString &)),
this, SLOT(buildConfigurationDisplayNameChanged(const QString &)));
......@@ -189,7 +186,6 @@ BuildSettingsWidget::BuildSettingsWidget(Project *project)
void BuildSettingsWidget::buildConfigurationDisplayNameChanged(const QString &buildConfiguration)
{
for (int i=0; i<m_buildConfigurationComboBox->count(); ++i) {
if (m_buildConfigurationComboBox->itemData(i).toString() == buildConfiguration) {
m_buildConfigurationComboBox->setItemText(i, m_project->displayNameFor(buildConfiguration));
......@@ -201,11 +197,10 @@ void BuildSettingsWidget::buildConfigurationDisplayNameChanged(const QString &bu
void BuildSettingsWidget::updateBuildSettings()
{
// TODO save position, entry from combbox
// Delete old tree items
m_buildConfigurationComboBox->blockSignals(true); // TODO ...
m_buildConfigurationComboBox->blockSignals(true);
m_buildConfigurationComboBox->clear();
m_subWidgets->clear();
......@@ -224,14 +219,12 @@ void BuildSettingsWidget::updateBuildSettings()
m_subWidgets->addWidget(subConfigWidget->displayName(), subConfigWidget);
// Add tree items
QString activeBuildConfiguration = m_project->activeBuildConfiguration();
foreach (const QString &buildConfiguration, m_project->buildConfigurations()) {
m_buildConfigurationComboBox->addItem(m_project->displayNameFor(buildConfiguration), buildConfiguration);
if (buildConfiguration == activeBuildConfiguration)
if (buildConfiguration == m_buildConfiguration)
m_buildConfigurationComboBox->setCurrentIndex(m_buildConfigurationComboBox->count() - 1);
}
// TODO ...
m_buildConfigurationComboBox->blockSignals(false);
// TODO Restore position, entry from combbox
......@@ -241,22 +234,21 @@ void BuildSettingsWidget::updateBuildSettings()
void BuildSettingsWidget::currentIndexChanged(int index)
{
QString buildConfiguration = m_buildConfigurationComboBox->itemData(index).toString();
m_project->setActiveBuildConfiguration(buildConfiguration);
m_buildConfiguration = m_buildConfigurationComboBox->itemData(index).toString();
activeBuildConfigurationChanged();
}
void BuildSettingsWidget::activeBuildConfigurationChanged()
{
const QString &activeBuildConfiguration = m_project->activeBuildConfiguration();
for (int i = 0; i < m_buildConfigurationComboBox->count(); ++i) {
if (m_buildConfigurationComboBox->itemData(i).toString() == activeBuildConfiguration) {
if (m_buildConfigurationComboBox->itemData(i).toString() == m_buildConfiguration) {
m_buildConfigurationComboBox->setCurrentIndex(i);
break;
}
}
foreach (QWidget *widget, m_subWidgets->widgets()) {
if (BuildConfigWidget *buildStepWidget = qobject_cast<BuildConfigWidget*>(widget)) {
buildStepWidget->init(activeBuildConfiguration);
buildStepWidget->init(m_buildConfiguration);
}
}
}
......@@ -293,7 +285,7 @@ void BuildSettingsWidget::createConfiguration()
m_project->addBuildConfiguration(newBuildConfiguration);
m_project->setDisplayNameFor(newBuildConfiguration, newDisplayName);
m_project->newBuildConfiguration(newBuildConfiguration);
m_project->setActiveBuildConfiguration(newBuildConfiguration);
m_buildConfiguration = newBuildConfiguration;
updateBuildSettings();
}
......@@ -344,9 +336,8 @@ void BuildSettingsWidget::cloneConfiguration(const QString &sourceConfiguration)
m_project->copyBuildConfiguration(sourceConfiguration, newBuildConfiguration);
m_project->setDisplayNameFor(newBuildConfiguration, newDisplayName);
m_buildConfiguration = newBuildConfiguration;
updateBuildSettings();
m_project->setActiveBuildConfiguration(newBuildConfiguration);
}
void BuildSettingsWidget::deleteConfiguration(const QString &deleteConfiguration)
......@@ -363,6 +354,15 @@ void BuildSettingsWidget::deleteConfiguration(const QString &deleteConfiguration
}
}
if (m_buildConfiguration == deleteConfiguration) {
foreach (const QString &otherConfiguration, m_project->buildConfigurations()) {
if (otherConfiguration != deleteConfiguration) {
m_buildConfiguration = otherConfiguration;
break;
}
}
}
m_project->removeBuildConfiguration(deleteConfiguration);
updateBuildSettings();
......
......@@ -44,7 +44,7 @@ class IBuildStepFactory;
namespace Internal {
class BuildSettingsSubWidgets : public QGroupBox
class BuildSettingsSubWidgets : public QWidget
{
Q_OBJECT
public:
......@@ -99,9 +99,7 @@ private slots:
void cloneConfiguration();
void deleteConfiguration();
private:
void setActiveConfiguration(const QString &configuration);
void cloneConfiguration(const QString &toClone);
void deleteConfiguration(const QString &toDelete);
......@@ -110,6 +108,7 @@ private:
QPushButton *m_removeButton;
QComboBox *m_buildConfigurationComboBox;
BuildSettingsSubWidgets *m_subWidgets;
QString m_buildConfiguration;
};
} // namespace Internal
......
......@@ -35,6 +35,7 @@
#include <coreplugin/coreconstants.h>
#include <extensionsystem/pluginmanager.h>
#include <utils/qtcassert.h>
#include <utils/detailsbutton.h>
#include <QtGui/QLabel>
#include <QtGui/QPushButton>
......@@ -178,16 +179,10 @@ void BuildStepsPage::addBuildStepWidget(int pos, BuildStep *step)
s.downButton = new QToolButton(this);
s.downButton->setArrowType(Qt::DownArrow);
#ifdef Q_OS_MAC
s.detailsButton = new QPushButton(this);
s.detailsButton->setAttribute(Qt::WA_MacSmallSize);
s.detailsButton->setSizePolicy(QSizePolicy::Fixed, QSizePolicy::Fixed);
s.upButton->setIconSize(QSize(10, 10));
s.downButton->setIconSize(QSize(10, 10));
#else
s.detailsButton = new QToolButton(this);
#endif
s.detailsButton->setText(tr("Details"));
s.detailsButton = new Utils::DetailsButton(this);
// layout
s.hbox = new QHBoxLayout();
......
......@@ -33,6 +33,7 @@
#include <coreplugin/icore.h>
#include <projectexplorer/debugginghelper.h>
#include <utils/detailsbutton.h>
#include <QtGui/QCheckBox>
#include <QtGui/QFormLayout>
......@@ -91,7 +92,22 @@ CustomExecutableConfigurationWidget::CustomExecutableConfigurationWidget(CustomE
QVBoxLayout *vbox = new QVBoxLayout(this);
vbox->setContentsMargins(0, -1, 0, -1);
vbox->addLayout(layout);
m_summaryLabel = new QLabel(this);
m_detailsButton = new Utils::DetailsButton(this);
connect(m_detailsButton, SIGNAL(clicked()),
this, SLOT(toggleDetails()));
QHBoxLayout *hbox = new QHBoxLayout();
hbox->addWidget(m_summaryLabel);
hbox->addWidget(m_detailsButton);
vbox->addLayout(hbox);
m_detailsWidget = new QWidget(this);
m_detailsWidget->setLayout(layout);
vbox->addWidget(m_detailsWidget);
m_detailsWidget->setVisible(false);
QLabel *environmentLabel = new QLabel(this);
environmentLabel->setText(tr("Run Environment"));
......@@ -146,6 +162,11 @@ CustomExecutableConfigurationWidget::CustomExecutableConfigurationWidget(CustomE
this, SLOT(userEnvironmentChangesChanged()));
}
void CustomExecutableConfigurationWidget::toggleDetails()
{
m_detailsWidget->setVisible(!m_detailsWidget->isVisible());
}
void CustomExecutableConfigurationWidget::userChangesUpdated()
{
m_runConfiguration->setUserEnvironmentChanges(m_environmentWidget->userChanges());
......@@ -211,10 +232,18 @@ void CustomExecutableConfigurationWidget::termToggled(bool on)
void CustomExecutableConfigurationWidget::changed()
{
const QString &executable = m_runConfiguration->baseExecutable();
QString text = tr("No Executable specified.");
if (!executable.isEmpty())
text = tr("Running executable: <b>%1</b> %2").
arg(executable,
ProjectExplorer::Environment::joinArgumentList(m_runConfiguration->commandLineArguments()));
m_summaryLabel->setText(text);
// We triggered the change, don't update us
if (m_ignoreChange)
return;
m_executableChooser->setPath(m_runConfiguration->baseExecutable());
m_executableChooser->setPath(executable);
m_commandLineArgumentsLineEdit->setText(ProjectExplorer::Environment::joinArgumentList(m_runConfiguration->commandLineArguments()));
m_workingDirectory->setPath(m_runConfiguration->baseWorkingDirectory());
m_useTerminalCheck->setChecked(m_runConfiguration->runMode() == ApplicationRunConfiguration::Console);
......
......@@ -161,6 +161,7 @@ private slots:
void baseEnvironmentChanged();
void userEnvironmentChangesChanged();
void baseEnvironmentComboBoxChanged(int index);
void toggleDetails();
private:
bool m_ignoreChange;
CustomExecutableRunConfiguration *m_runConfiguration;
......@@ -171,6 +172,9 @@ private:
QCheckBox *m_useTerminalCheck;
ProjectExplorer::EnvironmentWidget *m_environmentWidget;
QComboBox *m_baseEnvironmentComboBox;
QWidget *m_detailsWidget;
QLabel *m_summaryLabel;
QAbstractButton *m_detailsButton;
};
} // namespace Internal
......
......@@ -31,6 +31,8 @@
#include "project.h"
#include "session.h"
#include <utils/detailsbutton.h>
#include <coreplugin/fileiconprovider.h>
#include <QtCore/QVector>
......@@ -230,15 +232,7 @@ DependenciesWidget::DependenciesWidget(SessionManager *session,
m_titleLabel->setText("Dummy Text");
hbox->addWidget(m_titleLabel);
QAbstractButton *detailsButton;
#ifdef Q_OS_MAC
detailsButton = new QPushButton;
detailsButton->setAttribute(Qt::WA_MacSmallSize);
detailsButton->setSizePolicy(QSizePolicy::Fixed, QSizePolicy::Fixed);
#else
detailsButton = new QToolButton(this);
#endif
detailsButton->setText(tr("Details"));
QAbstractButton *detailsButton = new Utils::DetailsButton(this);
connect(detailsButton, SIGNAL(clicked()),
this, SLOT(toggleDetails()));
......
......@@ -29,6 +29,8 @@
#include "environmenteditmodel.h"
#include <utils/detailsbutton.h>
#include <QtGui/QVBoxLayout>
#include <QtGui/QHeaderView>
#include <QtGui/QToolButton>
......@@ -438,15 +440,7 @@ EnvironmentWidget::EnvironmentWidget(QWidget *parent, QWidget *additionalDetails
m_summaryText = new QLabel(this);
m_summaryText->setText("");
QAbstractButton *detailsButton;
#ifdef Q_OS_MAC
detailsButton = new QPushButton(this);
detailsButton->setAttribute(Qt::WA_MacSmallSize);
detailsButton->setSizePolicy(QSizePolicy::Fixed, QSizePolicy::Fixed);
#else
detailsButton = new QToolButton(this);
#endif
detailsButton->setText(tr("Details"));
QAbstractButton *detailsButton = new Utils::DetailsButton(this);
connect(detailsButton, SIGNAL(clicked()),
this, SLOT(toggleDetails()));
......
......@@ -112,6 +112,7 @@ void Project::addBuildConfiguration(const QString &name)
for (int i = 0; i != m_cleanSteps.size(); ++i)
m_cleanSteps.at(i)->addBuildConfiguration(name);
emit addedBuildConfiguration(this, name);
}
void Project::removeBuildConfiguration(const QString &name)
......@@ -131,6 +132,7 @@ void Project::removeBuildConfiguration(const QString &name)
for (int i = 0; i != m_cleanSteps.size(); ++i)
m_cleanSteps.at(i)->removeBuildConfiguration(name);
emit removedBuildConfiguration(this, name);
}
void Project::copyBuildConfiguration(const QString &source, const QString &dest)
......@@ -147,6 +149,7 @@ void Project::copyBuildConfiguration(const QString &source, const QString &dest)
for (int i = 0; i != m_cleanSteps.size(); ++i)
m_cleanSteps.at(i)->copyBuildConfiguration(source, dest);
emit addedBuildConfiguration(this, dest);
}
QStringList Project::buildConfigurations() const
......@@ -453,7 +456,7 @@ void Project::addRunConfiguration(QSharedPointer<RunConfiguration> runConfigurat
return;
}
m_runConfigurations.push_back(runConfiguration);
emit addedRunConfiguration(runConfiguration->name());
emit addedRunConfiguration(this, runConfiguration->name());
}
void Project::removeRunConfiguration(QSharedPointer<RunConfiguration> runConfiguration)
......@@ -473,7 +476,7 @@ void Project::removeRunConfiguration(QSharedPointer<RunConfiguration> runConfigu
}
m_runConfigurations.removeOne(runConfiguration);
emit removedRunConfiguration(runConfiguration->name());
emit removedRunConfiguration(this, runConfiguration->name());
}
QSharedPointer<RunConfiguration> Project::activeRunConfiguration() const
......
......@@ -147,11 +147,22 @@ public:
signals:
void fileListChanged();
// TODO clean up signal names
// might be better to also have
// a aboutToRemoveRunConfiguration
// and a removedBuildConfiguration
// a runconfiguration display name changed is missing
void activeBuildConfigurationChanged();
void activeRunConfigurationChanged();
void runConfigurationsEnabledStateChanged();
void removedRunConfiguration(const QString &name);
void addedRunConfiguration(const QString &name);
void removedRunConfiguration(ProjectExplorer::Project *p, const QString &name);
void addedRunConfiguration(ProjectExplorer::Project *p, const QString &name);
void removedBuildConfiguration(ProjectExplorer::Project *p, const QString &name);
void addedBuildConfiguration(ProjectExplorer::Project *p, const QString &name);
// This signal is jut there for updating the tree list in the buildsettings wizard
void buildConfigurationDisplayNameChanged(const QString &buildConfiguration);
void environmentChanged(const QString &buildConfiguration);
......
......@@ -32,15 +32,16 @@
#include <QtGui/QWidget>
#include <QtGui/QScrollArea>
#include <QtGui/QTreeWidget>
#include <QtGui/QComboBox>
#include <QtCore/QPair>
QT_BEGIN_NAMESPACE
class QLabel;
class QVBoxLayout;
class QModelIndex;
class QTabWidget;
class QTreeWidgetItem;
class QHBoxLayout;
class QComboBox;
QT_END_NAMESPACE
namespace ProjectExplorer {
......@@ -59,7 +60,9 @@ public:
PanelsWidget(QWidget *parent);
~PanelsWidget();
// Adds a widget
void addWidget(QWidget *widget);
void addWidget(const QString &name, QWidget *widget);
void removeWidget(QWidget *widget);
// Removes all widgets and deletes them
void clear();
......@@ -75,18 +78,76 @@ private:
QList<Panel> m_panels;
};
class BuildConfigurationComboBox : public QComboBox
{
Q_OBJECT
public:
BuildConfigurationComboBox(ProjectExplorer::Project *p, QWidget *parent = 0);
~BuildConfigurationComboBox();
private slots:
void nameChanged(const QString &buildConfiguration);
void activeConfigurationChanged();
void addedBuildConfiguration(ProjectExplorer::Project *, const QString &buildConfiguration);
void removedBuildConfiguration(ProjectExplorer::Project *, const QString &buildConfiguration);
void changedIndex(int newIndex);
private:
int nameToIndex(const QString &buildConfiguration);
bool ignoreIndexChange;
ProjectExplorer::Project *m_project;
};
class ProjectView : public QTreeWidget
class ActiveConfigurationWidget : public QWidget
{
Q_OBJECT
public:
ProjectView (QWidget *parent);
~ProjectView ();
virtual QSize sizeHint() const;
ActiveConfigurationWidget(QWidget *parent = 0);
~ActiveConfigurationWidget();
private slots:
void updateSizeHint();