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.
This commit is contained in:
dt
2009-09-29 18:06:13 +02:00
parent ce7b56f998
commit 3d62363fee
8 changed files with 169 additions and 73 deletions

View File

@@ -4,10 +4,11 @@ using namespace Utils;
DetailsButton::DetailsButton(QWidget *parent)
#ifdef Q_OS_MAC
: QPushButton(parent)
: QPushButton(parent),
#else
: QToolButton(parent)
: QToolButton(parent),
#endif
m_checked(false)
{
#ifdef Q_OS_MAC
setAttribute(Qt::WA_MacSmallSize);
@@ -15,5 +16,17 @@ DetailsButton::DetailsButton(QWidget *parent)
#else
setCheckable(true);
#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"));
}
}

View File

@@ -18,6 +18,10 @@ class QTCREATOR_UTILS_EXPORT DetailsButton
Q_OBJECT
public:
DetailsButton(QWidget *parent=0);
public slots:
void onClicked();
private:
bool m_checked;
};
}
#endif // DETAILSBUTTON_H

View File

@@ -150,13 +150,11 @@ BuildSettingsWidget::BuildSettingsWidget(Project *project)
m_addButton = new QPushButton(this);
m_addButton->setText(tr("Add"));
m_addButton->setIcon(QIcon(Core::Constants::ICON_PLUS));
m_addButton->setSizePolicy(QSizePolicy::Fixed, QSizePolicy::Fixed);
hbox->addWidget(m_addButton);
m_removeButton = new QPushButton(this);
m_removeButton->setText(tr("Remove"));
m_removeButton->setIcon(QIcon(Core::Constants::ICON_MINUS));
m_removeButton->setSizePolicy(QSizePolicy::Fixed, QSizePolicy::Fixed);
hbox->addWidget(m_removeButton);
hbox->addSpacerItem(new QSpacerItem(0, 0, QSizePolicy::Expanding, QSizePolicy::Fixed));

View File

@@ -125,7 +125,6 @@ FORMS += processstep.ui \
runsettingspropertiespage.ui \
sessiondialog.ui \
projectwizardpage.ui \
buildstepspage.ui \
removefiledialog.ui \
projectexplorersettingspage.ui \
projectwelcomepagewidget.ui

View File

@@ -44,6 +44,7 @@
#include <coreplugin/ifile.h>
#include <extensionsystem/pluginmanager.h>
#include <utils/styledbar.h>
#include <utils/stylehelper.h>
#include <QtCore/QDebug>
#include <QtGui/QApplication>
@@ -56,7 +57,8 @@
#include <QtGui/QLabel>
#include <QtGui/QPainter>
#include <QtGui/QPaintEvent>
#include <utils/stylehelper.h>
#include <QtGui/QMenu>
using namespace ProjectExplorer;
using namespace ProjectExplorer::Internal;
@@ -111,7 +113,7 @@ void PanelsWidget::addWidget(const QString &name, QWidget *widget)
p.nameLabel->setText(name);
QFont f = p.nameLabel->font();
f.setBold(true);
f.setPointSizeF(f.pointSizeF() * 1.4);
f.setPointSizeF(f.pointSizeF() * 1.2);
p.nameLabel->setFont(f);
p.panelWidget = widget;
@@ -418,16 +420,31 @@ void RunConfigurationComboBox::rebuildTree()
// BuildConfigurationComboBox
////
BuildConfigurationComboBox::BuildConfigurationComboBox(Project *p, QWidget *parent)
: QComboBox(parent), ignoreIndexChange(false), m_project(p)
: QStackedWidget(parent), ignoreIndexChange(false), m_project(p)
{
setSizeAdjustPolicy(QComboBox::AdjustToContents);
foreach(const QString &buildConfiguration, p->buildConfigurations())
addItem(p->displayNameFor(buildConfiguration), buildConfiguration);
setSizePolicy(QSizePolicy::Preferred, QSizePolicy::Fixed);
m_comboBox = new QComboBox(this);
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());
if (index != -1)
setCurrentIndex(index);
m_comboBox->setCurrentIndex(index);
connect(p, SIGNAL(buildConfigurationDisplayNameChanged(QString)),
this, SLOT(nameChanged(QString)));
@@ -437,7 +454,7 @@ BuildConfigurationComboBox::BuildConfigurationComboBox(Project *p, QWidget *pare
this, SLOT(addedBuildConfiguration(ProjectExplorer::Project *, QString)));
connect(p, SIGNAL(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)));
}
@@ -451,13 +468,16 @@ void BuildConfigurationComboBox::nameChanged(const QString &buildConfiguration)
int index = nameToIndex(buildConfiguration);
if (index == -1)
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)
{
for (int i=0; i < count(); ++i)
if (itemData(i) == buildConfiguration)
for (int i=0; i < m_comboBox->count(); ++i)
if (m_comboBox->itemData(i) == buildConfiguration)
return i;
return -1;
}
@@ -468,14 +488,17 @@ void BuildConfigurationComboBox::activeConfigurationChanged()
if (index == -1)
return;
ignoreIndexChange = true;
setCurrentIndex(index);
m_comboBox->setCurrentIndex(index);
ignoreIndexChange = false;
}
void BuildConfigurationComboBox::addedBuildConfiguration(ProjectExplorer::Project *,const QString &buildConfiguration)
{
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;
}
@@ -483,7 +506,11 @@ void BuildConfigurationComboBox::removedBuildConfiguration(ProjectExplorer::Proj
{
ignoreIndexChange = true;
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;
}
@@ -491,73 +518,108 @@ void BuildConfigurationComboBox::changedIndex(int newIndex)
{
if (newIndex == -1)
return;
m_project->setActiveBuildConfiguration(itemData(newIndex).toString());
m_project->setActiveBuildConfiguration(m_comboBox->itemData(newIndex).toString());
}
///
// ProjectComboBox
// ProjectLabel
///
ProjectComboBox::ProjectComboBox(QWidget *parent)
: QComboBox(parent), m_lastProject(0)
ProjectLabel::ProjectLabel(QWidget *parent)
: 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();
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*)),
this, SLOT(projectRemoved(ProjectExplorer::Project*)));
connect(session, SIGNAL(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));
// Comboboxes don't emit a signal
if (count() == 1)
itemActivated(0);
QAction *act = m_menu->addAction(p->name());
act->setData(QVariant::fromValue((void *) p));
connect(act, SIGNAL(triggered()),
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();
for (int i= 0; i<projects.count(); ++i)
if (itemData(i, Qt::UserRole).value<void *>() == (void *) p) {
removeItem(i);
bool needToChange = false;
foreach(QAction *act, m_menu->actions()) {
if (act->data().value<void *>() == (void *) p) {
delete act;
needToChange = true;
break;
}
}
// Comboboxes don't emit a signal if the index did't actually change
if (count() == 0) {
itemActivated(-1);
} else {
setCurrentIndex(0);
itemActivated(0);
if (m_menu->actions().isEmpty()) {
emit projectChanged(0);
setEnabled(false);
} else if (needToChange) {
emit projectChanged((ProjectExplorer::Project *) m_menu->actions().first()->data().value<void *>());
}
}
void ProjectComboBox::itemActivated(int index)
void ProjectPushButton::actionTriggered()
{
Project *p = 0;
QList<Project *> projects = ProjectExplorerPlugin::instance()->session()->projects();
if (index != -1 && index < projects.size())
p = projects.at(index);
if (p != m_lastProject) {
m_lastProject = p;
emit projectChanged(p);
}
QAction *action = qobject_cast<QAction *>(sender());
emit projectChanged((ProjectExplorer::Project *) action->data().value<void *>());
}
///
@@ -598,11 +660,20 @@ ProjectWindow::ProjectWindow(QWidget *parent)
m_projectChooser = new QWidget(m_panelsWidget);
QHBoxLayout *hbox = new QHBoxLayout(m_projectChooser);
hbox->setMargin(0);
hbox->addWidget(new QLabel(tr("Edit Configuration for Project:"), m_projectChooser));
ProjectComboBox *projectComboBox = new ProjectComboBox(m_projectChooser);
hbox->addWidget(projectComboBox);
ProjectLabel *label = new ProjectLabel(m_projectChooser);
{
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);
QVBoxLayout *vbox = new QVBoxLayout(m_spacerBetween);
@@ -614,7 +685,7 @@ ProjectWindow::ProjectWindow(QWidget *parent)
m_panelsWidget->addWidget(m_spacerBetween);
m_panelsWidget->addWidget(tr("Edit Configuration"), m_projectChooser);
m_panelsWidget->addWidget(m_projectChooser);
QVBoxLayout *topLevelLayout = new QVBoxLayout(this);
topLevelLayout->setMargin(0);
@@ -623,7 +694,7 @@ ProjectWindow::ProjectWindow(QWidget *parent)
topLevelLayout->addWidget(m_panelsWidget);
connect(projectComboBox, SIGNAL(projectChanged(ProjectExplorer::Project*)),
connect(changeProject, SIGNAL(projectChanged(ProjectExplorer::Project*)),
this, SLOT(showProperties(ProjectExplorer::Project*)));
connect(m_session, SIGNAL(sessionLoaded()), this, SLOT(restoreStatus()));
@@ -656,9 +727,9 @@ void ProjectWindow::showProperties(Project *project)
// Remove the tabs from the tab widget first
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(tr("Edit Configuration"), m_projectChooser);
m_panelsWidget->addWidget(m_projectChooser);
if (project) {
QList<IPanelFactory *> pages =

View File

@@ -34,6 +34,10 @@
#include <QtGui/QScrollArea>
#include <QtGui/QComboBox>
#include <QtCore/QPair>
#include <QtGui/QStackedWidget>
#include <QtGui/QPushButton>
#include <QtGui/QToolButton>
#include <QtGui/QLabel>
QT_BEGIN_NAMESPACE
class QLabel;
@@ -42,6 +46,7 @@ class QModelIndex;
class QTabWidget;
class QHBoxLayout;
class QComboBox;
class QMenu;
QT_END_NAMESPACE
namespace ProjectExplorer {
@@ -78,7 +83,7 @@ private:
QList<Panel> m_panels;
};
class BuildConfigurationComboBox : public QComboBox
class BuildConfigurationComboBox : public QStackedWidget
{
Q_OBJECT
public:
@@ -94,6 +99,8 @@ private:
int nameToIndex(const QString &buildConfiguration);
bool ignoreIndexChange;
ProjectExplorer::Project *m_project;
QComboBox *m_comboBox;
QLabel *m_label;
};
class ActiveConfigurationWidget : public QWidget
@@ -132,22 +139,31 @@ private:
bool m_ignoreChange;
};
class ProjectComboBox : public QComboBox
class ProjectLabel : public QLabel
{
Q_OBJECT
public:
ProjectComboBox(QWidget *parent);
~ProjectComboBox();
ProjectLabel(QWidget *parent);
~ProjectLabel();
public slots:
void setProject(ProjectExplorer::Project *);
};
class ProjectPushButton : public QPushButton
{
Q_OBJECT
public:
ProjectPushButton(QWidget *parent);
~ProjectPushButton();
signals:
void projectChanged(ProjectExplorer::Project *);
private slots:
void projectAdded(ProjectExplorer::Project*);
void projectRemoved(ProjectExplorer::Project*);
void itemActivated(int);
void actionTriggered();
private:
ProjectExplorer::Project *m_lastProject;
QMenu *m_menu;
};
class ProjectWindow : public QWidget

View File

@@ -180,10 +180,8 @@ RunSettingsWidget::RunSettingsWidget(Project *project)
m_ui = new Ui::RunSettingsPropertiesPage;
m_ui->setupUi(this);
m_addMenu = new QMenu(m_ui->addToolButton);
m_ui->addToolButton->setIcon(QIcon(Core::Constants::ICON_PLUS));
m_ui->addToolButton->setMenu(m_addMenu);
m_ui->addToolButton->setText(tr("Add"));
m_ui->removeToolButton->setIcon(QIcon(Core::Constants::ICON_MINUS));
m_ui->removeToolButton->setText(tr("Remove"));
m_ui->runConfigurationCombo->setModel(m_runConfigurationsModel);

View File

@@ -11,9 +11,6 @@
</rect>
</property>
<layout class="QFormLayout" name="formLayout">
<property name="margin">
<number>0</number>
</property>
<item row="0" column="0">
<widget class="QLabel" name="label_2">
<property name="text">