Commit 3d62363f authored by dt's avatar dt
Browse files

Small tweaks to the project page again, based on mae's feedback.

Feedback welcome, some of them are not necessarily better. Some things
aren't solved.
parent ce7b56f9
...@@ -4,10 +4,11 @@ using namespace Utils; ...@@ -4,10 +4,11 @@ using namespace Utils;
DetailsButton::DetailsButton(QWidget *parent) DetailsButton::DetailsButton(QWidget *parent)
#ifdef Q_OS_MAC #ifdef Q_OS_MAC
: QPushButton(parent) : QPushButton(parent),
#else #else
: QToolButton(parent) : QToolButton(parent),
#endif #endif
m_checked(false)
{ {
#ifdef Q_OS_MAC #ifdef Q_OS_MAC
setAttribute(Qt::WA_MacSmallSize); setAttribute(Qt::WA_MacSmallSize);
...@@ -15,5 +16,17 @@ DetailsButton::DetailsButton(QWidget *parent) ...@@ -15,5 +16,17 @@ DetailsButton::DetailsButton(QWidget *parent)
#else #else
setCheckable(true); setCheckable(true);
#endif #endif
setText(tr("Details")); setText(tr("Show Details"));
connect(this, SIGNAL(clicked()),
this, SLOT(onClicked()));
}
void DetailsButton::onClicked()
{
m_checked = !m_checked;
if (m_checked) {
setText(tr("Hide Details"));
} else {
setText(tr("Show Details"));
}
} }
...@@ -18,6 +18,10 @@ class QTCREATOR_UTILS_EXPORT DetailsButton ...@@ -18,6 +18,10 @@ class QTCREATOR_UTILS_EXPORT DetailsButton
Q_OBJECT Q_OBJECT
public: public:
DetailsButton(QWidget *parent=0); DetailsButton(QWidget *parent=0);
public slots:
void onClicked();
private:
bool m_checked;
}; };
} }
#endif // DETAILSBUTTON_H #endif // DETAILSBUTTON_H
...@@ -150,13 +150,11 @@ BuildSettingsWidget::BuildSettingsWidget(Project *project) ...@@ -150,13 +150,11 @@ BuildSettingsWidget::BuildSettingsWidget(Project *project)
m_addButton = new QPushButton(this); m_addButton = new QPushButton(this);
m_addButton->setText(tr("Add")); m_addButton->setText(tr("Add"));
m_addButton->setIcon(QIcon(Core::Constants::ICON_PLUS));
m_addButton->setSizePolicy(QSizePolicy::Fixed, QSizePolicy::Fixed); m_addButton->setSizePolicy(QSizePolicy::Fixed, QSizePolicy::Fixed);
hbox->addWidget(m_addButton); hbox->addWidget(m_addButton);
m_removeButton = new QPushButton(this); m_removeButton = new QPushButton(this);
m_removeButton->setText(tr("Remove")); m_removeButton->setText(tr("Remove"));
m_removeButton->setIcon(QIcon(Core::Constants::ICON_MINUS));
m_removeButton->setSizePolicy(QSizePolicy::Fixed, QSizePolicy::Fixed); m_removeButton->setSizePolicy(QSizePolicy::Fixed, QSizePolicy::Fixed);
hbox->addWidget(m_removeButton); hbox->addWidget(m_removeButton);
hbox->addSpacerItem(new QSpacerItem(0, 0, QSizePolicy::Expanding, QSizePolicy::Fixed)); hbox->addSpacerItem(new QSpacerItem(0, 0, QSizePolicy::Expanding, QSizePolicy::Fixed));
......
...@@ -125,7 +125,6 @@ FORMS += processstep.ui \ ...@@ -125,7 +125,6 @@ FORMS += processstep.ui \
runsettingspropertiespage.ui \ runsettingspropertiespage.ui \
sessiondialog.ui \ sessiondialog.ui \
projectwizardpage.ui \ projectwizardpage.ui \
buildstepspage.ui \
removefiledialog.ui \ removefiledialog.ui \
projectexplorersettingspage.ui \ projectexplorersettingspage.ui \
projectwelcomepagewidget.ui projectwelcomepagewidget.ui
......
...@@ -44,6 +44,7 @@ ...@@ -44,6 +44,7 @@
#include <coreplugin/ifile.h> #include <coreplugin/ifile.h>
#include <extensionsystem/pluginmanager.h> #include <extensionsystem/pluginmanager.h>
#include <utils/styledbar.h> #include <utils/styledbar.h>
#include <utils/stylehelper.h>
#include <QtCore/QDebug> #include <QtCore/QDebug>
#include <QtGui/QApplication> #include <QtGui/QApplication>
...@@ -56,7 +57,8 @@ ...@@ -56,7 +57,8 @@
#include <QtGui/QLabel> #include <QtGui/QLabel>
#include <QtGui/QPainter> #include <QtGui/QPainter>
#include <QtGui/QPaintEvent> #include <QtGui/QPaintEvent>
#include <utils/stylehelper.h> #include <QtGui/QMenu>
using namespace ProjectExplorer; using namespace ProjectExplorer;
using namespace ProjectExplorer::Internal; using namespace ProjectExplorer::Internal;
...@@ -111,7 +113,7 @@ void PanelsWidget::addWidget(const QString &name, QWidget *widget) ...@@ -111,7 +113,7 @@ void PanelsWidget::addWidget(const QString &name, QWidget *widget)
p.nameLabel->setText(name); p.nameLabel->setText(name);
QFont f = p.nameLabel->font(); QFont f = p.nameLabel->font();
f.setBold(true); f.setBold(true);
f.setPointSizeF(f.pointSizeF() * 1.4); f.setPointSizeF(f.pointSizeF() * 1.2);
p.nameLabel->setFont(f); p.nameLabel->setFont(f);
p.panelWidget = widget; p.panelWidget = widget;
...@@ -418,16 +420,31 @@ void RunConfigurationComboBox::rebuildTree() ...@@ -418,16 +420,31 @@ void RunConfigurationComboBox::rebuildTree()
// BuildConfigurationComboBox // BuildConfigurationComboBox
//// ////
BuildConfigurationComboBox::BuildConfigurationComboBox(Project *p, QWidget *parent) BuildConfigurationComboBox::BuildConfigurationComboBox(Project *p, QWidget *parent)
: QComboBox(parent), ignoreIndexChange(false), m_project(p) : QStackedWidget(parent), ignoreIndexChange(false), m_project(p)
{ {
setSizeAdjustPolicy(QComboBox::AdjustToContents); setSizePolicy(QSizePolicy::Preferred, QSizePolicy::Fixed);
foreach(const QString &buildConfiguration, p->buildConfigurations()) m_comboBox = new QComboBox(this);
addItem(p->displayNameFor(buildConfiguration), buildConfiguration); m_comboBox->setSizePolicy(QSizePolicy::Preferred, QSizePolicy::Fixed);
addWidget(m_comboBox);
m_label = new QLabel(this);
m_label->setSizePolicy(QSizePolicy::Preferred, QSizePolicy::Fixed);
addWidget(m_label);
//m_comboBox->setSizeAdjustPolicy(QComboBox::AdjustToContents);
QStringList buildConfigurations = p->buildConfigurations();
foreach(const QString &buildConfiguration, buildConfigurations)
m_comboBox->addItem(p->displayNameFor(buildConfiguration), buildConfiguration);
if (buildConfigurations.count() == 1) {
m_label->setText(m_comboBox->itemText(0));
setCurrentWidget(m_label);
}
int index = p->buildConfigurations().indexOf(p->activeBuildConfiguration()); int index = p->buildConfigurations().indexOf(p->activeBuildConfiguration());
if (index != -1) if (index != -1)
setCurrentIndex(index); m_comboBox->setCurrentIndex(index);
connect(p, SIGNAL(buildConfigurationDisplayNameChanged(QString)), connect(p, SIGNAL(buildConfigurationDisplayNameChanged(QString)),
this, SLOT(nameChanged(QString))); this, SLOT(nameChanged(QString)));
...@@ -437,7 +454,7 @@ BuildConfigurationComboBox::BuildConfigurationComboBox(Project *p, QWidget *pare ...@@ -437,7 +454,7 @@ BuildConfigurationComboBox::BuildConfigurationComboBox(Project *p, QWidget *pare
this, SLOT(addedBuildConfiguration(ProjectExplorer::Project *, QString))); this, SLOT(addedBuildConfiguration(ProjectExplorer::Project *, QString)));
connect(p, SIGNAL(removedBuildConfiguration(ProjectExplorer::Project *, QString)), connect(p, SIGNAL(removedBuildConfiguration(ProjectExplorer::Project *, QString)),
this, SLOT(removedBuildConfiguration(ProjectExplorer::Project *, QString))); this, SLOT(removedBuildConfiguration(ProjectExplorer::Project *, QString)));
connect(this, SIGNAL(activated(int)), connect(m_comboBox, SIGNAL(activated(int)),
this, SLOT(changedIndex(int))); this, SLOT(changedIndex(int)));
} }
...@@ -451,13 +468,16 @@ void BuildConfigurationComboBox::nameChanged(const QString &buildConfiguration) ...@@ -451,13 +468,16 @@ void BuildConfigurationComboBox::nameChanged(const QString &buildConfiguration)
int index = nameToIndex(buildConfiguration); int index = nameToIndex(buildConfiguration);
if (index == -1) if (index == -1)
return; return;
setItemText(index, m_project->displayNameFor(buildConfiguration)); const QString &displayName = m_project->displayNameFor(buildConfiguration);
m_comboBox->setItemText(index, displayName);
if (m_comboBox->count() == 1)
m_label->setText(displayName);
} }
int BuildConfigurationComboBox::nameToIndex(const QString &buildConfiguration) int BuildConfigurationComboBox::nameToIndex(const QString &buildConfiguration)
{ {
for (int i=0; i < count(); ++i) for (int i=0; i < m_comboBox->count(); ++i)
if (itemData(i) == buildConfiguration) if (m_comboBox->itemData(i) == buildConfiguration)
return i; return i;
return -1; return -1;
} }
...@@ -468,14 +488,17 @@ void BuildConfigurationComboBox::activeConfigurationChanged() ...@@ -468,14 +488,17 @@ void BuildConfigurationComboBox::activeConfigurationChanged()
if (index == -1) if (index == -1)
return; return;
ignoreIndexChange = true; ignoreIndexChange = true;
setCurrentIndex(index); m_comboBox->setCurrentIndex(index);
ignoreIndexChange = false; ignoreIndexChange = false;
} }
void BuildConfigurationComboBox::addedBuildConfiguration(ProjectExplorer::Project *,const QString &buildConfiguration) void BuildConfigurationComboBox::addedBuildConfiguration(ProjectExplorer::Project *,const QString &buildConfiguration)
{ {
ignoreIndexChange = true; ignoreIndexChange = true;
addItem(m_project->displayNameFor(buildConfiguration), buildConfiguration); m_comboBox->addItem(m_project->displayNameFor(buildConfiguration), buildConfiguration);
if (m_comboBox->count() == 2)
setCurrentWidget(m_comboBox);
ignoreIndexChange = false; ignoreIndexChange = false;
} }
...@@ -483,7 +506,11 @@ void BuildConfigurationComboBox::removedBuildConfiguration(ProjectExplorer::Proj ...@@ -483,7 +506,11 @@ void BuildConfigurationComboBox::removedBuildConfiguration(ProjectExplorer::Proj
{ {
ignoreIndexChange = true; ignoreIndexChange = true;
int index = nameToIndex(buildConfiguration); int index = nameToIndex(buildConfiguration);
removeItem(index); m_comboBox->removeItem(index);
if (m_comboBox->count() == 1) {
m_label->setText(m_comboBox->itemText(0));
setCurrentWidget(m_label);
}
ignoreIndexChange = false; ignoreIndexChange = false;
} }
...@@ -491,73 +518,108 @@ void BuildConfigurationComboBox::changedIndex(int newIndex) ...@@ -491,73 +518,108 @@ void BuildConfigurationComboBox::changedIndex(int newIndex)
{ {
if (newIndex == -1) if (newIndex == -1)
return; return;
m_project->setActiveBuildConfiguration(itemData(newIndex).toString()); m_project->setActiveBuildConfiguration(m_comboBox->itemData(newIndex).toString());
} }
/// ///
// ProjectComboBox // ProjectLabel
/// ///
ProjectComboBox::ProjectComboBox(QWidget *parent) ProjectLabel::ProjectLabel(QWidget *parent)
: QComboBox(parent), m_lastProject(0) : QLabel(parent)
{ {
setSizeAdjustPolicy(QComboBox::AdjustToContents);
}
ProjectLabel::~ProjectLabel()
{
}
void ProjectLabel::setProject(ProjectExplorer::Project *p)
{
if (p)
setText(tr("Edit Project Settings for Project <b>%1</b>").arg(p->name()));
else
setText(tr("No Project loaded"));
}
///
// ProjectPushButton
///
ProjectPushButton::ProjectPushButton(QWidget *parent)
: QPushButton(parent)
{
setText(tr("Select Project"));
m_menu = new QMenu(this);
setMenu(m_menu);
setSizePolicy(QSizePolicy::Fixed, QSizePolicy::Fixed);
SessionManager *session = ProjectExplorerPlugin::instance()->session(); SessionManager *session = ProjectExplorerPlugin::instance()->session();
foreach(Project *p, session->projects()) { foreach(Project *p, session->projects()) {
addItem(p->name(), QVariant::fromValue((void *) p)); QAction *act = m_menu->addAction(p->name());
act->setData(QVariant::fromValue((void *) p));
connect(act, SIGNAL(triggered()),
this, SLOT(actionTriggered()));
} }
setEnabled(session->projects().count() > 1);
connect(session, SIGNAL(projectRemoved(ProjectExplorer::Project*)), connect(session, SIGNAL(projectRemoved(ProjectExplorer::Project*)),
this, SLOT(projectRemoved(ProjectExplorer::Project*))); this, SLOT(projectRemoved(ProjectExplorer::Project*)));
connect(session, SIGNAL(projectAdded(ProjectExplorer::Project*)), connect(session, SIGNAL(projectAdded(ProjectExplorer::Project*)),
this, SLOT(projectAdded(ProjectExplorer::Project*))); this, SLOT(projectAdded(ProjectExplorer::Project*)));
connect(this, SIGNAL(activated(int)),
SLOT(itemActivated(int)));
} }
ProjectComboBox::~ProjectComboBox() ProjectPushButton::~ProjectPushButton()
{ {
} }
void ProjectComboBox::projectAdded(ProjectExplorer::Project *p) void ProjectPushButton::projectAdded(ProjectExplorer::Project *p)
{ {
addItem(p->name(), QVariant::fromValue((void *) p)); QAction *act = m_menu->addAction(p->name());
// Comboboxes don't emit a signal act->setData(QVariant::fromValue((void *) p));
if (count() == 1) connect(act, SIGNAL(triggered()),
itemActivated(0); this, SLOT(actionTriggered()));
// Activate it
if (m_menu->actions().count() == 1)
emit projectChanged(p);
else if (m_menu->actions().count() > 1)
setEnabled(true);
} }
void ProjectComboBox::projectRemoved(ProjectExplorer::Project *p) void ProjectPushButton::projectRemoved(ProjectExplorer::Project *p)
{ {
QList<Project *> projects = ProjectExplorerPlugin::instance()->session()->projects(); QList<Project *> projects = ProjectExplorerPlugin::instance()->session()->projects();
for (int i= 0; i<projects.count(); ++i)
if (itemData(i, Qt::UserRole).value<void *>() == (void *) p) { bool needToChange = false;
removeItem(i); foreach(QAction *act, m_menu->actions()) {
if (act->data().value<void *>() == (void *) p) {
delete act;
needToChange = true;
break; break;
}
} }
// Comboboxes don't emit a signal if the index did't actually change // Comboboxes don't emit a signal if the index did't actually change
if (count() == 0) { if (m_menu->actions().isEmpty()) {
itemActivated(-1); emit projectChanged(0);
} else { setEnabled(false);
setCurrentIndex(0); } else if (needToChange) {
itemActivated(0); emit projectChanged((ProjectExplorer::Project *) m_menu->actions().first()->data().value<void *>());
} }
} }
void ProjectComboBox::itemActivated(int index) void ProjectPushButton::actionTriggered()
{ {
Project *p = 0; QAction *action = qobject_cast<QAction *>(sender());
QList<Project *> projects = ProjectExplorerPlugin::instance()->session()->projects(); emit projectChanged((ProjectExplorer::Project *) action->data().value<void *>());
if (index != -1 && index < projects.size())
p = projects.at(index);
if (p != m_lastProject) {
m_lastProject = p;
emit projectChanged(p);
}
} }
/// ///
...@@ -598,11 +660,20 @@ ProjectWindow::ProjectWindow(QWidget *parent) ...@@ -598,11 +660,20 @@ ProjectWindow::ProjectWindow(QWidget *parent)
m_projectChooser = new QWidget(m_panelsWidget); m_projectChooser = new QWidget(m_panelsWidget);
QHBoxLayout *hbox = new QHBoxLayout(m_projectChooser); QHBoxLayout *hbox = new QHBoxLayout(m_projectChooser);
hbox->setMargin(0); hbox->setMargin(0);
hbox->addWidget(new QLabel(tr("Edit Configuration for Project:"), m_projectChooser)); ProjectLabel *label = new ProjectLabel(m_projectChooser);
ProjectComboBox *projectComboBox = new ProjectComboBox(m_projectChooser); {
hbox->addWidget(projectComboBox); QFont f = label->font();
f.setPointSizeF(f.pointSizeF() * 1.4);
f.setBold(true);
label->setFont(f);
}
hbox->addWidget(label);
ProjectPushButton *changeProject = new ProjectPushButton(m_projectChooser);
connect(changeProject, SIGNAL(projectChanged(ProjectExplorer::Project*)),
label, SLOT(setProject(ProjectExplorer::Project*)));
hbox->addWidget(changeProject);
m_panelsWidget->addWidget(tr("Active Configuration"), m_activeConfigurationWidget); m_panelsWidget->addWidget(tr("Active Build and Run Configurations"), m_activeConfigurationWidget);
m_spacerBetween = new QWidget(this); m_spacerBetween = new QWidget(this);
QVBoxLayout *vbox = new QVBoxLayout(m_spacerBetween); QVBoxLayout *vbox = new QVBoxLayout(m_spacerBetween);
...@@ -614,7 +685,7 @@ ProjectWindow::ProjectWindow(QWidget *parent) ...@@ -614,7 +685,7 @@ ProjectWindow::ProjectWindow(QWidget *parent)
m_panelsWidget->addWidget(m_spacerBetween); m_panelsWidget->addWidget(m_spacerBetween);
m_panelsWidget->addWidget(tr("Edit Configuration"), m_projectChooser); m_panelsWidget->addWidget(m_projectChooser);
QVBoxLayout *topLevelLayout = new QVBoxLayout(this); QVBoxLayout *topLevelLayout = new QVBoxLayout(this);
topLevelLayout->setMargin(0); topLevelLayout->setMargin(0);
...@@ -623,7 +694,7 @@ ProjectWindow::ProjectWindow(QWidget *parent) ...@@ -623,7 +694,7 @@ ProjectWindow::ProjectWindow(QWidget *parent)
topLevelLayout->addWidget(m_panelsWidget); topLevelLayout->addWidget(m_panelsWidget);
connect(projectComboBox, SIGNAL(projectChanged(ProjectExplorer::Project*)), connect(changeProject, SIGNAL(projectChanged(ProjectExplorer::Project*)),
this, SLOT(showProperties(ProjectExplorer::Project*))); this, SLOT(showProperties(ProjectExplorer::Project*)));
connect(m_session, SIGNAL(sessionLoaded()), this, SLOT(restoreStatus())); connect(m_session, SIGNAL(sessionLoaded()), this, SLOT(restoreStatus()));
...@@ -656,9 +727,9 @@ void ProjectWindow::showProperties(Project *project) ...@@ -656,9 +727,9 @@ void ProjectWindow::showProperties(Project *project)
// Remove the tabs from the tab widget first // Remove the tabs from the tab widget first
m_panelsWidget->clear(); m_panelsWidget->clear();
m_panelsWidget->addWidget(tr("Active Configuration"), m_activeConfigurationWidget); m_panelsWidget->addWidget(tr("Active Build and Run Configurations"), m_activeConfigurationWidget);
m_panelsWidget->addWidget(m_spacerBetween); m_panelsWidget->addWidget(m_spacerBetween);
m_panelsWidget->addWidget(tr("Edit Configuration"), m_projectChooser); m_panelsWidget->addWidget(m_projectChooser);
if (project) { if (project) {
QList<IPanelFactory *> pages = QList<IPanelFactory *> pages =
......
...@@ -34,6 +34,10 @@ ...@@ -34,6 +34,10 @@
#include <QtGui/QScrollArea> #include <QtGui/QScrollArea>
#include <QtGui/QComboBox> #include <QtGui/QComboBox>
#include <QtCore/QPair> #include <QtCore/QPair>
#include <QtGui/QStackedWidget>
#include <QtGui/QPushButton>
#include <QtGui/QToolButton>
#include <QtGui/QLabel>
QT_BEGIN_NAMESPACE QT_BEGIN_NAMESPACE
class QLabel; class QLabel;
...@@ -42,6 +46,7 @@ class QModelIndex; ...@@ -42,6 +46,7 @@ class QModelIndex;
class QTabWidget; class QTabWidget;
class QHBoxLayout; class QHBoxLayout;
class QComboBox; class QComboBox;
class QMenu;
QT_END_NAMESPACE QT_END_NAMESPACE
namespace ProjectExplorer { namespace ProjectExplorer {
...@@ -78,7 +83,7 @@ private: ...@@ -78,7 +83,7 @@ private:
QList<Panel> m_panels; QList<Panel> m_panels;
}; };
class BuildConfigurationComboBox : public QComboBox class BuildConfigurationComboBox : public QStackedWidget
{ {
Q_OBJECT Q_OBJECT
public: public:
...@@ -94,6 +99,8 @@ private: ...@@ -94,6 +99,8 @@ private:
int nameToIndex(const QString &buildConfiguration); int nameToIndex(const QString &buildConfiguration);
bool ignoreIndexChange; bool ignoreIndexChange;
ProjectExplorer::Project *m_project; ProjectExplorer::Project *m_project;
QComboBox *m_comboBox;
QLabel *m_label;
}; };
class ActiveConfigurationWidget : public QWidget class ActiveConfigurationWidget : public QWidget
...@@ -132,22 +139,31 @@ private: ...@@ -132,22 +139,31 @@ private:
bool m_ignoreChange; bool m_ignoreChange;
}; };
class ProjectComboBox : public QComboBox class ProjectLabel : public QLabel
{ {
Q_OBJECT Q_OBJECT
public: public:
ProjectComboBox(QWidget *parent); ProjectLabel(QWidget *parent);
~ProjectComboBox(); ~ProjectLabel();
public slots:
void setProject(ProjectExplorer::Project *);
};
class ProjectPushButton : public QPushButton
{
Q_OBJECT
public:
ProjectPushButton(QWidget *parent);
~ProjectPushButton();
signals: signals:
void projectChanged(ProjectExplorer::Project *); void projectChanged(ProjectExplorer::Project *);