forked from qt-creator/qt-creator
Recent Sessions/Projects/Files: Clean up accelerators
Don't show them for sessions on macOS, don't show any numbers > 9, and don't use colons. Change-Id: I34a60631e5d11a98f22cfcf374f8cec1a2964658 Reviewed-by: Orgad Shaneh <orgads@gmail.com>
This commit is contained in:
@@ -359,6 +359,13 @@ bool ActionManager::isPresentationModeEnabled()
|
|||||||
return d->m_presentationModeEnabled;
|
return d->m_presentationModeEnabled;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
QString ActionManager::withNumberAccelerator(const QString &text, const int number)
|
||||||
|
{
|
||||||
|
if (Utils::HostOsInfo::isMacHost() || number > 9)
|
||||||
|
return text;
|
||||||
|
return QString("&%1 | %2").arg(number).arg(text);
|
||||||
|
}
|
||||||
|
|
||||||
void ActionManager::saveSettings()
|
void ActionManager::saveSettings()
|
||||||
{
|
{
|
||||||
d->saveSettings();
|
d->saveSettings();
|
||||||
|
@@ -73,6 +73,8 @@ public:
|
|||||||
static void setPresentationModeEnabled(bool enabled);
|
static void setPresentationModeEnabled(bool enabled);
|
||||||
static bool isPresentationModeEnabled();
|
static bool isPresentationModeEnabled();
|
||||||
|
|
||||||
|
static QString withNumberAccelerator(const QString &text, const int number);
|
||||||
|
|
||||||
signals:
|
signals:
|
||||||
void commandListChanged();
|
void commandListChanged();
|
||||||
void commandAdded(Core::Id id);
|
void commandAdded(Core::Id id);
|
||||||
|
@@ -1070,12 +1070,8 @@ void MainWindow::aboutToShowRecentFiles()
|
|||||||
for (int i = 0; i < recentFiles.count(); ++i) {
|
for (int i = 0; i < recentFiles.count(); ++i) {
|
||||||
const DocumentManager::RecentFile file = recentFiles[i];
|
const DocumentManager::RecentFile file = recentFiles[i];
|
||||||
|
|
||||||
const int acceleratorKey = i + 1;
|
|
||||||
const QString textPattern = acceleratorKey < 10 ? QStringLiteral("&%1: %2") : QStringLiteral("%1: %2");
|
|
||||||
const QString filePath = QDir::toNativeSeparators(withTildeHomePath(file.first));
|
const QString filePath = QDir::toNativeSeparators(withTildeHomePath(file.first));
|
||||||
const QString actionText = HostOsInfo::isMacHost()
|
const QString actionText = ActionManager::withNumberAccelerator(filePath, i + 1);
|
||||||
? filePath
|
|
||||||
: textPattern.arg(acceleratorKey).arg(filePath);
|
|
||||||
QAction *action = menu->addAction(actionText);
|
QAction *action = menu->addAction(actionText);
|
||||||
connect(action, &QAction::triggered, this, [file] {
|
connect(action, &QAction::triggered, this, [file] {
|
||||||
EditorManager::openEditor(file.first, file.second);
|
EditorManager::openEditor(file.first, file.second);
|
||||||
|
@@ -2830,10 +2830,8 @@ void ProjectExplorerPluginPrivate::updateRecentProjectMenu()
|
|||||||
if (fileName.endsWith(QLatin1String(".qws")))
|
if (fileName.endsWith(QLatin1String(".qws")))
|
||||||
continue;
|
continue;
|
||||||
|
|
||||||
const QString textTemplate = acceleratorKey < 10 ? QStringLiteral("&%1: %2") : QStringLiteral("%1: %2");
|
const QString actionText = ActionManager::withNumberAccelerator(
|
||||||
const QString actionText = Utils::HostOsInfo::isMacHost()
|
Utils::withTildeHomePath(fileName), acceleratorKey);
|
||||||
? Utils::withTildeHomePath(fileName)
|
|
||||||
: textTemplate.arg(acceleratorKey).arg(Utils::withTildeHomePath(fileName));
|
|
||||||
QAction *action = menu->addAction(actionText);
|
QAction *action = menu->addAction(actionText);
|
||||||
connect(action, &QAction::triggered, this, [this, fileName] {
|
connect(action, &QAction::triggered, this, [this, fileName] {
|
||||||
openRecentProject(fileName);
|
openRecentProject(fileName);
|
||||||
@@ -3310,9 +3308,7 @@ void ProjectExplorerPluginPrivate::updateSessionMenu()
|
|||||||
for (int i = 0; i < sessions.size(); ++i) {
|
for (int i = 0; i < sessions.size(); ++i) {
|
||||||
const QString &session = sessions[i];
|
const QString &session = sessions[i];
|
||||||
|
|
||||||
const int acceleratorKey = i + 1;
|
const QString actionText = ActionManager::withNumberAccelerator(session, i + 1);
|
||||||
QString textTemplate = acceleratorKey < 10 ? QStringLiteral("&%1: %2") : QStringLiteral("%1: %2");
|
|
||||||
QString actionText = textTemplate.arg(acceleratorKey).arg(session);
|
|
||||||
QAction *act = ag->addAction(actionText);
|
QAction *act = ag->addAction(actionText);
|
||||||
act->setData(session);
|
act->setData(session);
|
||||||
act->setCheckable(true);
|
act->setCheckable(true);
|
||||||
|
Reference in New Issue
Block a user