Commit 09316279 authored by Daniel Teske's avatar Daniel Teske Committed by Daniel Molkentin
Browse files

Overhaul mini project selector



This makes the mini project selector keyboard friendly.
Also adds the deployconfiguration. Arguable it looks less neat now.

Change-Id: I761502df0bca72afdc2e56ef9b5abe4f9521a2f7
Reviewed-by: default avatarDaniel Molkentin <daniel.molkentin@nokia.com>
parent 3053e572
...@@ -34,7 +34,7 @@ ...@@ -34,7 +34,7 @@
#define MINIPROJECTTARGETSELECTOR_H #define MINIPROJECTTARGETSELECTOR_H
#include <QtGui/QListWidget> #include <QtGui/QListWidget>
#include <QtCore/QDateTime>
QT_BEGIN_NAMESPACE QT_BEGIN_NAMESPACE
class QComboBox; class QComboBox;
...@@ -45,100 +45,133 @@ QT_END_NAMESPACE ...@@ -45,100 +45,133 @@ QT_END_NAMESPACE
namespace ProjectExplorer { namespace ProjectExplorer {
class Project; class Project;
class Target; class Target;
class RunConfiguration;
class Target;
class BuildConfiguration; class BuildConfiguration;
class DeployConfiguration;
class ProjectConfiguration;
class RunConfiguration;
class SessionManager;
namespace Internal { namespace Internal {
// helper classes // helper classes
class ProjectListWidget : public QListWidget class ListWidget : public QListWidget
{ {
Q_OBJECT Q_OBJECT
private:
ProjectExplorer::Project* m_project;
public: public:
explicit ProjectListWidget(ProjectExplorer::Project *project, QWidget *parent = 0); ListWidget(QWidget *parent);
QSize sizeHint() const; QSize sizeHint() const;
void keyPressEvent(QKeyEvent *event);
ProjectExplorer::Project *project() const; void keyReleaseEvent(QKeyEvent *event);
void setMaxCount(int maxCount);
private slots: private:
void setTarget(int index); int m_maxCount;
}; };
class MiniTargetWidget : public QWidget class ProjectListWidget : public ListWidget
{ {
Q_OBJECT Q_OBJECT
public: public:
explicit MiniTargetWidget(ProjectExplorer::Target *target, QWidget *parent = 0); explicit ProjectListWidget(SessionManager *sessionManager, QWidget *parent = 0);
ProjectExplorer::Target *target() const;
bool hasBuildConfiguration() const;
private slots: private slots:
void addRunConfiguration(ProjectExplorer::RunConfiguration *runConfig); void addProject(ProjectExplorer::Project *project);
void removeRunConfiguration(ProjectExplorer::RunConfiguration *runConfig); void removeProject(ProjectExplorer::Project *project);
void addBuildConfiguration(ProjectExplorer::BuildConfiguration *buildConfig); void changeStartupProject(ProjectExplorer::Project *project);
void removeBuildConfiguration(ProjectExplorer::BuildConfiguration *buildConfig); void setProject(int index);
void setActiveBuildConfiguration(int index);
void setActiveRunConfiguration(int index);
void setActiveBuildConfiguration();
void setActiveRunConfiguration();
void updateIcon();
signals:
void changed();
private: private:
QLabel *m_targetName; QListWidgetItem *itemForProject(Project *project);
QLabel *m_targetIcon; QString fullName(ProjectExplorer::Project *project);
QComboBox *m_runComboBox; SessionManager *m_sessionManager;
QComboBox *m_buildComboBox; bool m_ignoreIndexChange;
ProjectExplorer::Target *m_target; };
class GenericListWidget : public ListWidget
{
Q_OBJECT
public: public:
QComboBox *runSettingsComboBox() const { return m_runComboBox; } GenericListWidget(QWidget *parent = 0);
QComboBox *buildSettingsComboBox() const { return m_buildComboBox; } signals:
void changeActiveProjectConfiguration(ProjectExplorer::ProjectConfiguration *dc);
public:
void setProjectConfigurations(const QList<ProjectConfiguration *> &list, ProjectConfiguration *active);
void setActiveProjectConfiguration(ProjectConfiguration *active);
void addProjectConfiguration(ProjectExplorer::ProjectConfiguration *pc);
void removeProjectConfiguration(ProjectExplorer::ProjectConfiguration *pc);
private slots:
void rowChanged(int index);
void displayNameChanged();
private:
QListWidgetItem *itemForProjectConfiguration(ProjectConfiguration *pc);
bool m_ignoreIndexChange;
}; };
// main class // main class
class MiniProjectTargetSelector : public QWidget class MiniProjectTargetSelector : public QWidget
{ {
Q_OBJECT Q_OBJECT
public: public:
explicit MiniProjectTargetSelector(QAction *projectAction, QWidget *parent = 0); explicit MiniProjectTargetSelector(QAction *projectAction, SessionManager *sessionManager, QWidget *parent = 0);
void setVisible(bool visible); void setVisible(bool visible);
signals: void keyReleaseEvent(QKeyEvent *ke);
void startupProjectChanged(ProjectExplorer::Project *project); QSize sizeHint() const;
public slots:
void toggleVisible();
void nextOrShow();
private slots: private slots:
void addProject(ProjectExplorer::Project *project); void projectAdded(ProjectExplorer::Project *project);
void removeProject(ProjectExplorer::Project *project); void projectRemoved(ProjectExplorer::Project *project);
void addTarget(ProjectExplorer::Target *target, bool isActiveTarget = false); void addedTarget(ProjectExplorer::Target *target);
void removeTarget(ProjectExplorer::Target *target); void removedTarget(ProjectExplorer::Target *target);
void changeActiveTarget(ProjectExplorer::Target *target); void addedBuildConfiguration(ProjectExplorer::BuildConfiguration* bc);
void emitStartupProjectChanged(int index); void removedBuildConfiguration(ProjectExplorer::BuildConfiguration* bc);
void addedDeployConfiguration(ProjectExplorer::DeployConfiguration *dc);
void removedDeployConfiguration(ProjectExplorer::DeployConfiguration *dc);
void addedRunConfiguration(ProjectExplorer::RunConfiguration *rc);
void removedRunConfiguration(ProjectExplorer::RunConfiguration *rc);
void changeStartupProject(ProjectExplorer::Project *project); void changeStartupProject(ProjectExplorer::Project *project);
void updateAction(); void activeTargetChanged(ProjectExplorer::Target *target);
void activeBuildConfigurationChanged(ProjectExplorer::BuildConfiguration *bc);
void activeDeployConfigurationChanged(ProjectExplorer::DeployConfiguration *dc);
void activeRunConfigurationChanged(ProjectExplorer::RunConfiguration *rc);
void setActiveTarget(ProjectExplorer::ProjectConfiguration *pc);
void setActiveBuildConfiguration(ProjectExplorer::ProjectConfiguration *pc);
void setActiveDeployConfiguration(ProjectExplorer::ProjectConfiguration *pc);
void setActiveRunConfiguration(ProjectExplorer::ProjectConfiguration *pc);
void delayedHide();
void updateActionAndSummary();
private:
void updateProjectListVisible();
void updateTargetListVisible();
void updateBuildListVisible();
void updateDeployListVisible();
void updateRunListVisible();
void updateSummary();
void updateSeparatorVisible();
void paintEvent(QPaintEvent *); void paintEvent(QPaintEvent *);
void mousePressEvent(QMouseEvent *); void mousePressEvent(QMouseEvent *);
private:
QString fullName(ProjectExplorer::Project *project);
int indexFor(ProjectExplorer::Project *project) const;
QAction *m_projectAction; QAction *m_projectAction;
QComboBox *m_projectsBox; SessionManager *m_sessionManager;
QStackedWidget *m_widgetStack;
bool m_ignoreIndexChange; enum TYPES { PROJECT = 0, TARGET = 1, BUILD = 2, DEPLOY = 3, RUN = 4, LAST = 5 };
ProjectListWidget *m_projectListWidget;
QVector<GenericListWidget *> m_listWidgets;
QVector<QWidget *> m_titleWidgets;
QVector<QWidget *> m_separators;
QLabel *m_summaryLabel;
Project *m_project;
Target *m_target;
BuildConfiguration *m_buildConfiguration;
DeployConfiguration *m_deployConfiguration;
RunConfiguration *m_runConfiguration;
bool m_hideOnRelease;
QDateTime m_earliestHidetime;
}; };
} // namespace Internal } // namespace Internal
......
...@@ -83,4 +83,6 @@ PROJECTEXPLORER_EXPORT QString displayNameFromMap(const QVariantMap &map); ...@@ -83,4 +83,6 @@ PROJECTEXPLORER_EXPORT QString displayNameFromMap(const QVariantMap &map);
} // namespace ProjectExplorer } // namespace ProjectExplorer
Q_DECLARE_METATYPE(ProjectExplorer::ProjectConfiguration *)
#endif // PROJECTCONFIGURATION_H #endif // PROJECTCONFIGURATION_H
...@@ -213,6 +213,7 @@ struct ProjectExplorerPluginPrivate { ...@@ -213,6 +213,7 @@ struct ProjectExplorerPluginPrivate {
QAction *m_setStartupProjectAction; QAction *m_setStartupProjectAction;
QAction *m_projectSelectorAction; QAction *m_projectSelectorAction;
QAction *m_projectSelectorActionMenu; QAction *m_projectSelectorActionMenu;
QAction *m_projectSelectorActionQuick;
QAction *m_runSubProject; QAction *m_runSubProject;
Internal::ProjectWindow *m_proWindow; Internal::ProjectWindow *m_proWindow;
...@@ -884,27 +885,24 @@ bool ProjectExplorerPlugin::initialize(const QStringList &arguments, QString *er ...@@ -884,27 +885,24 @@ bool ProjectExplorerPlugin::initialize(const QStringList &arguments, QString *er
d->m_projectSelectorAction->setCheckable(true); d->m_projectSelectorAction->setCheckable(true);
d->m_projectSelectorAction->setEnabled(false); d->m_projectSelectorAction->setEnabled(false);
QWidget *mainWindow = Core::ICore::instance()->mainWindow(); QWidget *mainWindow = Core::ICore::instance()->mainWindow();
d->m_targetSelector = new Internal::MiniProjectTargetSelector(d->m_projectSelectorAction, mainWindow); d->m_targetSelector = new Internal::MiniProjectTargetSelector(d->m_projectSelectorAction, d->m_session, mainWindow);
connect(d->m_projectSelectorAction, SIGNAL(triggered()), d->m_targetSelector, SLOT(show())); connect(d->m_projectSelectorAction, SIGNAL(triggered()), d->m_targetSelector, SLOT(show()));
Core::ModeManager::instance()->addProjectSelector(d->m_projectSelectorAction); Core::ModeManager::instance()->addProjectSelector(d->m_projectSelectorAction);
d->m_projectSelectorActionMenu = new QAction(this); d->m_projectSelectorActionMenu = new QAction(this);
d->m_projectSelectorActionMenu->setEnabled(false); d->m_projectSelectorActionMenu->setEnabled(false);
d->m_projectSelectorActionMenu->setText(tr("Open Build/Run Target Selector...")); d->m_projectSelectorActionMenu->setText(tr("Open Build/Run Target Selector..."));
connect(d->m_projectSelectorActionMenu, SIGNAL(triggered()), d->m_targetSelector, SLOT(show())); connect(d->m_projectSelectorActionMenu, SIGNAL(triggered()), d->m_targetSelector, SLOT(toggleVisible()));
cmd = am->registerAction(d->m_projectSelectorActionMenu, ProjectExplorer::Constants::SELECTTARGET, cmd = am->registerAction(d->m_projectSelectorActionMenu, ProjectExplorer::Constants::SELECTTARGET,
globalcontext); globalcontext);
cmd->setDefaultKeySequence(QKeySequence(tr("Ctrl+T")));
mbuild->addAction(cmd, Constants::G_BUILD_RUN); mbuild->addAction(cmd, Constants::G_BUILD_RUN);
connect(d->m_session, SIGNAL(projectAdded(ProjectExplorer::Project*)), d->m_projectSelectorActionQuick = new QAction(this);
d->m_targetSelector, SLOT(addProject(ProjectExplorer::Project*))); d->m_projectSelectorActionQuick->setEnabled(false);
connect(d->m_session, SIGNAL(aboutToRemoveProject(ProjectExplorer::Project*)), d->m_projectSelectorActionQuick->setText(tr("Quick Switch Target Selector"));
d->m_targetSelector, SLOT(removeProject(ProjectExplorer::Project*))); connect(d->m_projectSelectorActionQuick, SIGNAL(triggered()), d->m_targetSelector, SLOT(nextOrShow()));
connect(d->m_targetSelector, SIGNAL(startupProjectChanged(ProjectExplorer::Project*)), cmd = am->registerAction(d->m_projectSelectorActionQuick, ProjectExplorer::Constants::SELECTTARGETQUICK, globalcontext);
this, SLOT(setStartupProject(ProjectExplorer::Project*))); cmd->setDefaultKeySequence(QKeySequence(tr("Ctrl+T")));
connect(d->m_session, SIGNAL(startupProjectChanged(ProjectExplorer::Project*)),
d->m_targetSelector, SLOT(changeStartupProject(ProjectExplorer::Project*)));
connect(core, SIGNAL(saveSettingsRequested()), connect(core, SIGNAL(saveSettingsRequested()),
this, SLOT(savePersistentSettings())); this, SLOT(savePersistentSettings()));
...@@ -1709,6 +1707,7 @@ void ProjectExplorerPlugin::updateActions() ...@@ -1709,6 +1707,7 @@ void ProjectExplorerPlugin::updateActions()
d->m_projectSelectorAction->setEnabled(!session()->projects().isEmpty()); d->m_projectSelectorAction->setEnabled(!session()->projects().isEmpty());
d->m_projectSelectorActionMenu->setEnabled(!session()->projects().isEmpty()); d->m_projectSelectorActionMenu->setEnabled(!session()->projects().isEmpty());
d->m_projectSelectorActionQuick->setEnabled(!session()->projects().isEmpty());
updateDeployActions(); updateDeployActions();
updateRunWithoutDeployMenu(); updateRunWithoutDeployMenu();
......
...@@ -91,6 +91,7 @@ const char SHOW_TASK_OUTPUT[] = "ProjectExplorer.ShowTaskOutput"; ...@@ -91,6 +91,7 @@ const char SHOW_TASK_OUTPUT[] = "ProjectExplorer.ShowTaskOutput";
// Run modes // Run modes
const char RUNMODE[] = "ProjectExplorer.RunMode"; const char RUNMODE[] = "ProjectExplorer.RunMode";
const char SELECTTARGET[] = "ProjectExplorer.SelectTarget"; const char SELECTTARGET[] = "ProjectExplorer.SelectTarget";
const char SELECTTARGETQUICK[] = "ProjectExplorer.SelectTargetQuick";
// Action priorities // Action priorities
const int P_ACTION_RUN = 100; const int P_ACTION_RUN = 100;
......
...@@ -185,4 +185,6 @@ signals: ...@@ -185,4 +185,6 @@ signals:
} // namespace ProjectExplorer } // namespace ProjectExplorer
Q_DECLARE_METATYPE(ProjectExplorer::Target *)
#endif // TARGET_H #endif // TARGET_H
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment