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;
|
||||
}
|
||||
|
||||
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()
|
||||
{
|
||||
d->saveSettings();
|
||||
|
@@ -73,6 +73,8 @@ public:
|
||||
static void setPresentationModeEnabled(bool enabled);
|
||||
static bool isPresentationModeEnabled();
|
||||
|
||||
static QString withNumberAccelerator(const QString &text, const int number);
|
||||
|
||||
signals:
|
||||
void commandListChanged();
|
||||
void commandAdded(Core::Id id);
|
||||
|
@@ -1070,12 +1070,8 @@ void MainWindow::aboutToShowRecentFiles()
|
||||
for (int i = 0; i < recentFiles.count(); ++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 actionText = HostOsInfo::isMacHost()
|
||||
? filePath
|
||||
: textPattern.arg(acceleratorKey).arg(filePath);
|
||||
const QString actionText = ActionManager::withNumberAccelerator(filePath, i + 1);
|
||||
QAction *action = menu->addAction(actionText);
|
||||
connect(action, &QAction::triggered, this, [file] {
|
||||
EditorManager::openEditor(file.first, file.second);
|
||||
|
@@ -2830,10 +2830,8 @@ void ProjectExplorerPluginPrivate::updateRecentProjectMenu()
|
||||
if (fileName.endsWith(QLatin1String(".qws")))
|
||||
continue;
|
||||
|
||||
const QString textTemplate = acceleratorKey < 10 ? QStringLiteral("&%1: %2") : QStringLiteral("%1: %2");
|
||||
const QString actionText = Utils::HostOsInfo::isMacHost()
|
||||
? Utils::withTildeHomePath(fileName)
|
||||
: textTemplate.arg(acceleratorKey).arg(Utils::withTildeHomePath(fileName));
|
||||
const QString actionText = ActionManager::withNumberAccelerator(
|
||||
Utils::withTildeHomePath(fileName), acceleratorKey);
|
||||
QAction *action = menu->addAction(actionText);
|
||||
connect(action, &QAction::triggered, this, [this, fileName] {
|
||||
openRecentProject(fileName);
|
||||
@@ -3310,9 +3308,7 @@ void ProjectExplorerPluginPrivate::updateSessionMenu()
|
||||
for (int i = 0; i < sessions.size(); ++i) {
|
||||
const QString &session = sessions[i];
|
||||
|
||||
const int acceleratorKey = i + 1;
|
||||
QString textTemplate = acceleratorKey < 10 ? QStringLiteral("&%1: %2") : QStringLiteral("%1: %2");
|
||||
QString actionText = textTemplate.arg(acceleratorKey).arg(session);
|
||||
const QString actionText = ActionManager::withNumberAccelerator(session, i + 1);
|
||||
QAction *act = ag->addAction(actionText);
|
||||
act->setData(session);
|
||||
act->setCheckable(true);
|
||||
|
Reference in New Issue
Block a user