Skip to content

Commit

Permalink
fix #288679 and #269262: ensure a used QStandardKey is supported on
Browse files Browse the repository at this point in the history
given platform and replace 'Save As' StandardKey with KeySequence to
enable it on all platforms by default.

Signed-off-by: Patrick <my_web_spam_address@web.de>
  • Loading branch information
malaka712 committed May 9, 2019
1 parent 8e1b944 commit 56a1147
Show file tree
Hide file tree
Showing 3 changed files with 16 additions and 7 deletions.
2 changes: 1 addition & 1 deletion mscore/data/shortcuts.xml
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@
</SC>
<SC>
<key>file-save-as</key>
<std>63</std>
<seq>Ctrl+Shift+S</seq>
</SC>
<SC>
<key>file-close</key>
Expand Down
2 changes: 1 addition & 1 deletion mscore/data/shortcuts_AZERTY.xml
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@
</SC>
<SC>
<key>file-save-as</key>
<std>63</std>
<seq>Ctrl+Shift+S</seq>
</SC>
<SC>
<key>file-close</key>
Expand Down
19 changes: 14 additions & 5 deletions mscore/shortcut.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -3812,6 +3812,9 @@ void Shortcut::setKeys(const QList<QKeySequence>& ks)

void Shortcut::setStandardKey(QKeySequence::StandardKey k)
{
if (QKeySequence::keyBindings(k).empty()) // make sure key binding is set for OS
return;

_standardKey = k;
if (_action && k != QKeySequence::UnknownKey)
_action->setShortcuts(_standardKey);
Expand Down Expand Up @@ -4109,8 +4112,11 @@ void Shortcut::read(XmlReader& e)
const QStringRef& tag(e.name());
if (tag == "key")
_key = e.readElementText().toLocal8Bit();
else if (tag == "std")
_standardKey = QKeySequence::StandardKey(e.readInt());
else if (tag == "std") {
int i = e.readInt();
if (!QKeySequence::keyBindings((QKeySequence::StandardKey(i))).empty()) // make sure key binding is set for OS
_standardKey = QKeySequence::StandardKey(i);
}
else if (tag == "seq") {
QKeySequence seq = Shortcut::keySeqFromString(e.readElementText(), QKeySequence::PortableText);
#ifndef NDEBUG
Expand Down Expand Up @@ -4163,7 +4169,7 @@ void Shortcut::load()
}
else if (tag == "std") {
int i = e.readInt();
if(sc)
if(sc && !QKeySequence::keyBindings((QKeySequence::StandardKey(i))).empty()) // make sure key binding is set for OS
sc->_standardKey = QKeySequence::StandardKey(i);
}
else if (tag == "seq") {
Expand Down Expand Up @@ -4220,8 +4226,11 @@ static QList<Shortcut1> loadShortcuts(QString fileLocation)
const QStringRef& tag(e.name());
if (tag == "key")
sc.key = e.readElementText().toLocal8Bit();
else if (tag == "std")
sc.standardKey = QKeySequence::StandardKey(e.readInt());
else if (tag == "std") {
int i = e.readInt();
if (!QKeySequence::keyBindings(QKeySequence::StandardKey(i)).empty()) // make sure key binding is set for OS
sc.standardKey = QKeySequence::StandardKey(i);
}
else if (tag == "seq")
sc.keys.append(Shortcut::keySeqFromString(e.readElementText(), QKeySequence::PortableText));
else
Expand Down

0 comments on commit 56a1147

Please sign in to comment.