Welcome: Reimplement session and project shortcuts

Got disabled in 16944277d2 during
refactoring.

Delegates and models are not the right places for registering commands,
since there can be multiple instances. Do registration in project
welcome page, and let delegates retrieve shortcut string from the
models.

Task-number: QTCREATORBUG-17881
Change-Id: I06e3c29e57ee893865bf108a2f13bdb385c26d70
Reviewed-by: hjk <hjk@qt.io>
This commit is contained in:
Eike Ziller
2017-03-21 09:47:55 +01:00
parent 551efd9199
commit 7da34ce33a
4 changed files with 71 additions and 47 deletions

View File

@@ -28,6 +28,9 @@
#include "sessiondialog.h"
#include <coreplugin/actionmanager/actionmanager.h>
#include <coreplugin/id.h>
#include <utils/algorithm.h>
#include <utils/fileutils.h>
#include <utils/stringutils.h>
@@ -35,6 +38,8 @@
#include <QFileInfo>
#include <QDir>
using namespace Core;
namespace ProjectExplorer {
namespace Internal {
@@ -146,6 +151,11 @@ QVariant SessionModel::data(const QModelIndex &index, int role) const
case ProjectsDisplayRole:
result = pathsToBaseNames(SessionManager::projectsForSessionName(sessionName));
break;
case ShortcutRole: {
const Id sessionBase = SESSION_BASE_ID;
if (Command *cmd = ActionManager::command(sessionBase.withSuffix(index.row() + 1)))
result = cmd->keySequence().toString(QKeySequence::NativeText);
} break;
} // switch (role)
}