bug-fix: use platform-specific text of QKeySequence in context menu

This commit is contained in:
Le Tan 2017-09-08 21:40:31 +08:00
parent d6ca4245d9
commit d2ef9608fc
4 changed files with 18 additions and 9 deletions

View File

@ -20,6 +20,7 @@
#include <QValidator>
#include <QRegExpValidator>
#include <QRegExp>
#include <QKeySequence>
#include "vfile.h"
#include "vnote.h"
@ -696,3 +697,8 @@ void VUtils::decodeUrl(QString &p_url)
p_url.replace(it.key(), it.value());
}
}
QString VUtils::getShortcutText(const QString &p_keySeq)
{
return QKeySequence(p_keySeq).toString(QKeySequence::NativeText);
}

View File

@ -121,6 +121,9 @@ public:
// Decode URL by simply replacing meta-characters.
static void decodeUrl(QString &p_url);
// Returns the shortcut text.
static QString getShortcutText(const QString &p_keySeq);
// Regular expression for image link.
// ![image title]( http://github.com/tamlok/vnote.jpg "alt \" text" )
// Captured texts (need to be trimmed):

View File

@ -88,25 +88,25 @@ void VDirectoryTree::initActions()
this, &VDirectoryTree::deleteDirectory);
dirInfoAct = new QAction(QIcon(":/resources/icons/dir_info.svg"),
tr("&Info\t%1").arg(QKeySequence(c_infoShortcutSequence).toString()), this);
tr("&Info\t%1").arg(VUtils::getShortcutText(c_infoShortcutSequence)), this);
dirInfoAct->setToolTip(tr("View and edit current folder's information"));
connect(dirInfoAct, &QAction::triggered,
this, &VDirectoryTree::editDirectoryInfo);
copyAct = new QAction(QIcon(":/resources/icons/copy.svg"),
tr("&Copy\t%1").arg(QKeySequence(c_copyShortcutSequence).toString()), this);
tr("&Copy\t%1").arg(VUtils::getShortcutText(c_copyShortcutSequence)), this);
copyAct->setToolTip(tr("Copy selected folders"));
connect(copyAct, &QAction::triggered,
this, &VDirectoryTree::copySelectedDirectories);
cutAct = new QAction(QIcon(":/resources/icons/cut.svg"),
tr("C&ut\t%1").arg(QKeySequence(c_cutShortcutSequence).toString()), this);
tr("C&ut\t%1").arg(VUtils::getShortcutText(c_cutShortcutSequence)), this);
cutAct->setToolTip(tr("Cut selected folders"));
connect(cutAct, &QAction::triggered,
this, &VDirectoryTree::cutSelectedDirectories);
pasteAct = new QAction(QIcon(":/resources/icons/paste.svg"),
tr("&Paste\t%1").arg(QKeySequence(c_pasteShortcutSequence).toString()), this);
tr("&Paste\t%1").arg(VUtils::getShortcutText(c_pasteShortcutSequence)), this);
pasteAct->setToolTip(tr("Paste folders in this folder"));
connect(pasteAct, &QAction::triggered,
this, &VDirectoryTree::pasteDirectoriesInCurDir);

View File

@ -85,7 +85,7 @@ void VFileList::initActions()
{
newFileAct = new QAction(QIcon(":/resources/icons/create_note.svg"),
tr("&New Note"), this);
QString shortcutStr = QKeySequence(g_config->getShortcutKeySequence("NewNote")).toString();
QString shortcutStr = VUtils::getShortcutText(g_config->getShortcutKeySequence("NewNote"));
if (!shortcutStr.isEmpty()) {
newFileAct->setText(tr("&New Note\t%1").arg(shortcutStr));
}
@ -101,25 +101,25 @@ void VFileList::initActions()
this, SLOT(deleteFile()));
fileInfoAct = new QAction(QIcon(":/resources/icons/note_info.svg"),
tr("&Info\t%1").arg(QKeySequence(c_infoShortcutSequence).toString()), this);
tr("&Info\t%1").arg(VUtils::getShortcutText(c_infoShortcutSequence)), this);
fileInfoAct->setToolTip(tr("View and edit current note's information"));
connect(fileInfoAct, SIGNAL(triggered(bool)),
this, SLOT(fileInfo()));
copyAct = new QAction(QIcon(":/resources/icons/copy.svg"),
tr("&Copy\t%1").arg(QKeySequence(c_copyShortcutSequence).toString()), this);
tr("&Copy\t%1").arg(VUtils::getShortcutText(c_copyShortcutSequence)), this);
copyAct->setToolTip(tr("Copy selected notes"));
connect(copyAct, &QAction::triggered,
this, &VFileList::copySelectedFiles);
cutAct = new QAction(QIcon(":/resources/icons/cut.svg"),
tr("C&ut\t%1").arg(QKeySequence(c_cutShortcutSequence).toString()), this);
tr("C&ut\t%1").arg(VUtils::getShortcutText(c_cutShortcutSequence)), this);
cutAct->setToolTip(tr("Cut selected notes"));
connect(cutAct, &QAction::triggered,
this, &VFileList::cutSelectedFiles);
pasteAct = new QAction(QIcon(":/resources/icons/paste.svg"),
tr("&Paste\t%1").arg(QKeySequence(c_pasteShortcutSequence).toString()), this);
tr("&Paste\t%1").arg(VUtils::getShortcutText(c_pasteShortcutSequence)), this);
pasteAct->setToolTip(tr("Paste notes in current folder"));
connect(pasteAct, &QAction::triggered,
this, &VFileList::pasteFilesInCurDir);