diff --git a/share/qtcreator/welcomescreen/develop.qml b/share/qtcreator/welcomescreen/develop.qml index 8068ca8552a..4ca13e80278 100644 --- a/share/qtcreator/welcomescreen/develop.qml +++ b/share/qtcreator/welcomescreen/develop.qml @@ -36,20 +36,32 @@ import components 1.0 as Components Item { id: root + property int margin: 10 + Components.ScrollArea { id: scrollArea anchors.fill: parent frame: false Item { - height: Math.max(recentSessions.height, recentProjects.height) + height: Math.max(recentSessions.height + manageSessionsButton.height + margin, + recentProjects.height) width: root.width Widgets.RecentSessions { id: recentSessions - width: parent.width / 3 - 10 + width: parent.width / 3 - margin } + Widgets.Button { + id: manageSessionsButton + anchors.top: recentSessions.bottom + anchors.topMargin: margin + anchors.left: recentSessions.left + text: qsTr("Manage Sessions...") + onClicked: projectWelcomePage.manageSessions() + } + Widgets.RecentProjects { id: recentProjects - x: parent.width / 3 + 10 + x: parent.width / 3 + margin width: parent.width - x } } diff --git a/share/qtcreator/welcomescreen/widgets/RecentSessions.qml b/share/qtcreator/welcomescreen/widgets/RecentSessions.qml index c9fbfde771e..664085023bd 100644 --- a/share/qtcreator/welcomescreen/widgets/RecentSessions.qml +++ b/share/qtcreator/welcomescreen/widgets/RecentSessions.qml @@ -44,8 +44,10 @@ HeaderItemView { function fullSessionName() { var newSessionName = sessionName - if (model.currentSession) - newSessionName = qsTr("%1 (current session)").arg(newSessionName); + if (model.lastSession && sessionList.isDefaultVirgin()) + newSessionName = qsTr("%1 (last session)").arg(sessionName); + else if (model.activeSession && !sessionList.isDefaultVirgin()) + newSessionName = qsTr("%1 (current session)").arg(sessionName); return newSessionName; } @@ -60,7 +62,6 @@ HeaderItemView { Components.QStyleItem { id: styleItem; cursor: "pointinghandcursor"; anchors.fill: parent } id: fileNameText text: parent.fullSessionName() - font.italic: model.defaultSession elide: Text.ElideMiddle anchors.left: arrowImage.right anchors.verticalCenter: parent.verticalCenter diff --git a/src/plugins/projectexplorer/projectexplorer.cpp b/src/plugins/projectexplorer/projectexplorer.cpp index 315817e164b..15f866c2bb3 100644 --- a/src/plugins/projectexplorer/projectexplorer.cpp +++ b/src/plugins/projectexplorer/projectexplorer.cpp @@ -1304,12 +1304,7 @@ Project *ProjectExplorerPlugin::startupProject() const void ProjectExplorerPlugin::updateWelcomePage() { - WelcomePageData welcomePageData; - welcomePageData.sessionList = d->m_session->sessions(); - welcomePageData.activeSession = d->m_session->activeSession(); - welcomePageData.previousSession = d->m_session->lastSession(); - welcomePageData.projectList = d->m_recentProjects; - d->m_welcomePage->setWelcomePageData(welcomePageData); + d->m_welcomePage->reloadWelcomeScreenData(); } void ProjectExplorerPlugin::currentModeChanged(Core::IMode *mode, Core::IMode *oldMode) diff --git a/src/plugins/projectexplorer/projectwelcomepage.cpp b/src/plugins/projectexplorer/projectwelcomepage.cpp index e24c7a22ca3..30c08caedb2 100644 --- a/src/plugins/projectexplorer/projectwelcomepage.cpp +++ b/src/plugins/projectexplorer/projectwelcomepage.cpp @@ -51,7 +51,8 @@ SessionModel::SessionModel(SessionManager *manager, QObject *parent) QHash roleNames; roleNames[Qt::DisplayRole] = "sessionName"; roleNames[DefaultSessionRole] = "defaultSession"; - roleNames[CurrentSessionRole] = "currentSession"; + roleNames[ActiveSessionRole] = "activeSession"; + roleNames[LastSessionRole] = "lastSession"; setRoleNames(roleNames); connect(manager, SIGNAL(sessionLoaded()), SLOT(resetSessions())); } @@ -63,18 +64,25 @@ int SessionModel::rowCount(const QModelIndex &) const QVariant SessionModel::data(const QModelIndex &index, int role) const { - if (role == Qt::DisplayRole || role == DefaultSessionRole || role == CurrentSessionRole) { + if (role == Qt::DisplayRole || role == DefaultSessionRole || + role == LastSessionRole || role == ActiveSessionRole) { QString sessionName = m_manager->sessions().at(index.row()); if (role == Qt::DisplayRole) return sessionName; else if (role == DefaultSessionRole) return m_manager->isDefaultSession(sessionName); - else if (role == CurrentSessionRole) - return sessionName == m_manager->currentSession(); + else if (role == LastSessionRole) + return m_manager->lastSession() == sessionName; + else if (role == ActiveSessionRole) + return m_manager->activeSession() == sessionName; } return QVariant(); } +bool SessionModel::isDefaultVirgin() const +{ + return m_manager->isDefaultVirgin(); +} void SessionModel::resetSessions() { @@ -123,7 +131,8 @@ void ProjectModel::resetProjects() /////////////////// -ProjectWelcomePage::ProjectWelcomePage() +ProjectWelcomePage::ProjectWelcomePage() : + m_sessionModel(0), m_projectModel(0) { } @@ -131,10 +140,13 @@ void ProjectWelcomePage::facilitateQml(QDeclarativeEngine *engine) { static const char feedGroupName[] = "Feeds"; - QDeclarativeContext *ctx = engine->rootContext(); ProjectExplorerPlugin *pePlugin = ProjectExplorer::ProjectExplorerPlugin::instance(); - ctx->setContextProperty("sessionList", new SessionModel(pePlugin->session(), this)); - ctx->setContextProperty("projectList", new ProjectModel(pePlugin, this)); + m_sessionModel = new SessionModel(pePlugin->session(), this); + m_projectModel = new ProjectModel(pePlugin, this); + + QDeclarativeContext *ctx = engine->rootContext(); + ctx->setContextProperty("sessionList", m_sessionModel); + ctx->setContextProperty("projectList", m_projectModel); Core::MultiFeedRssModel *rssModel = new Core::MultiFeedRssModel(this); QSettings *settings = Core::ICore::instance()->settings(); if (settings->childGroups().contains(feedGroupName)) { @@ -154,9 +166,12 @@ void ProjectWelcomePage::facilitateQml(QDeclarativeEngine *engine) ctx->setContextProperty("projectWelcomePage", this); } -void ProjectWelcomePage::setWelcomePageData(const WelcomePageData &welcomePageData) +void ProjectWelcomePage::reloadWelcomeScreenData() { - m_welcomePageData = welcomePageData; + if (m_sessionModel) + m_sessionModel->resetSessions(); + if (m_projectModel) + m_projectModel->resetProjects(); } } // namespace Internal diff --git a/src/plugins/projectexplorer/projectwelcomepage.h b/src/plugins/projectexplorer/projectwelcomepage.h index f63009f8988..50e3ef68597 100644 --- a/src/plugins/projectexplorer/projectwelcomepage.h +++ b/src/plugins/projectexplorer/projectwelcomepage.h @@ -50,27 +50,18 @@ class SessionManager; namespace Internal { -struct WelcomePageData { - bool operator==(const WelcomePageData &rhs) const; - bool operator!=(const WelcomePageData &rhs) const; - - QString previousSession; - QString activeSession; - QStringList sessionList; - QList > projectList; // pair of filename, displayname -}; - - class SessionModel : public QAbstractListModel { Q_OBJECT public: - enum { DefaultSessionRole = Qt::UserRole+1, CurrentSessionRole }; + enum { DefaultSessionRole = Qt::UserRole+1, LastSessionRole, ActiveSessionRole }; SessionModel(SessionManager* manager, QObject* parent = 0); int rowCount(const QModelIndex &parent) const; QVariant data(const QModelIndex &index, int role) const; + Q_SCRIPTABLE bool isDefaultVirgin() const; + public slots: void resetSessions(); @@ -108,15 +99,15 @@ public: QString title() const { return tr("Develop"); } int priority() const { return 20; } - void setWelcomePageData(const WelcomePageData &welcomePageData); + void reloadWelcomeScreenData(); signals: void requestProject(const QString &project); void requestSession(const QString &session); void manageSessions(); - private: - WelcomePageData m_welcomePageData; + SessionModel *m_sessionModel; + ProjectModel *m_projectModel; }; } // namespace Internal diff --git a/src/plugins/projectexplorer/session.cpp b/src/plugins/projectexplorer/session.cpp index 9699943ec5a..6a2929ff281 100644 --- a/src/plugins/projectexplorer/session.cpp +++ b/src/plugins/projectexplorer/session.cpp @@ -834,7 +834,7 @@ void SessionManager::configureEditor(Core::IEditor *editor, const QString &fileN QString SessionManager::currentSession() const { - return m_file->fileName(); + return QFileInfo(m_file->fileName()).completeBaseName(); } void SessionManager::updateWindowTitle() diff --git a/src/plugins/projectexplorer/session.h b/src/plugins/projectexplorer/session.h index 709dd5d394b..c63689946f4 100644 --- a/src/plugins/projectexplorer/session.h +++ b/src/plugins/projectexplorer/session.h @@ -104,6 +104,7 @@ public: void removeDependency(Project *project, Project *depProject); QString currentSession() const; + QString sessionNameToFileName(const QString &session) const; Project *startupProject() const; const QList &projects() const; @@ -154,7 +155,6 @@ private slots: private: bool loadImpl(const QString &fileName); bool createImpl(const QString &fileName); - QString sessionNameToFileName(const QString &session) const; bool projectContainsFile(Project *p, const QString &fileName) const; bool recursiveDependencyCheck(const QString &newDep, const QString &checkDep) const; diff --git a/src/plugins/projectexplorer/sessionnodeimpl.cpp b/src/plugins/projectexplorer/sessionnodeimpl.cpp index e718bf05f30..96327f79605 100644 --- a/src/plugins/projectexplorer/sessionnodeimpl.cpp +++ b/src/plugins/projectexplorer/sessionnodeimpl.cpp @@ -37,7 +37,9 @@ namespace ProjectExplorer { namespace Internal { SessionNodeImpl::SessionNodeImpl(SessionManager *manager) - : ProjectExplorer::SessionNode(manager->currentSession(), manager) + : ProjectExplorer::SessionNode( + manager->sessionNameToFileName(manager->currentSession()), + manager) { setFileName(QLatin1String("session")); }