mirror of
https://github.com/Cockatrice/Cockatrice.git
synced 2026-06-12 09:04:53 -07:00
Shortcuts preference pane (#3641)
* Shortcuts preference pane * Honor and glory to the hypnoclangifier * clanfigy: exclude deleted files from being checked * keep the olf translation context to be able to reuse old translations * Fix gcc; extract translations * Moved generic buttons after the groupbox * Update current item on "clear/reset all" * Sequenceedit: make buttons larger and translatable, add text * Event filter * Don't filter arrow keys; added placeholder text * group counters
This commit is contained in:
parent
11b2942d09
commit
389f7fdc25
13 changed files with 1606 additions and 3123 deletions
|
|
@ -4,6 +4,11 @@
|
|||
#include <QStringList>
|
||||
#include <utility>
|
||||
|
||||
ShortcutKey::ShortcutKey(const QString &_name, QList<QKeySequence> _sequence, ShortcutGroup::Groups _group)
|
||||
: QList<QKeySequence>(_sequence), name(_name), group(_group)
|
||||
{
|
||||
}
|
||||
|
||||
ShortcutsSettings::ShortcutsSettings(const QString &settingsPath, QObject *parent) : QObject(parent)
|
||||
{
|
||||
shortCuts = defaultShortCuts;
|
||||
|
|
@ -23,8 +28,8 @@ ShortcutsSettings::ShortcutsSettings(const QString &settingsPath, QObject *paren
|
|||
QString stringSequence = shortCutsFile.value(*it).toString();
|
||||
// check whether shortcut is forbidden
|
||||
if (isKeyAllowed(*it, stringSequence)) {
|
||||
QList<QKeySequence> SequenceList = parseSequenceString(stringSequence);
|
||||
shortCuts.insert(*it, SequenceList);
|
||||
auto shortcut = getShortcut(*it);
|
||||
shortcut.setSequence(parseSequenceString(stringSequence));
|
||||
} else {
|
||||
invalidItems.insert(*it, stringSequence);
|
||||
}
|
||||
|
|
@ -45,21 +50,16 @@ ShortcutsSettings::ShortcutsSettings(const QString &settingsPath, QObject *paren
|
|||
}
|
||||
msgBox.setDetailedText(detailedMessage);
|
||||
msgBox.exec();
|
||||
|
||||
// set default shortcut where stored value was invalid
|
||||
for (const QString &key : invalidItems.keys()) {
|
||||
setShortcuts(key, getDefaultShortcutString(key));
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
QList<QKeySequence> ShortcutsSettings::getDefaultShortcut(const QString &name) const
|
||||
ShortcutKey ShortcutsSettings::getDefaultShortcut(const QString &name) const
|
||||
{
|
||||
return defaultShortCuts.value(name, QList<QKeySequence>());
|
||||
return defaultShortCuts.value(name, ShortcutKey());
|
||||
}
|
||||
|
||||
QList<QKeySequence> ShortcutsSettings::getShortcut(const QString &name) const
|
||||
ShortcutKey ShortcutsSettings::getShortcut(const QString &name) const
|
||||
{
|
||||
if (shortCuts.contains(name)) {
|
||||
return shortCuts.value(name);
|
||||
|
|
@ -105,7 +105,7 @@ QList<QKeySequence> ShortcutsSettings::parseSequenceString(const QString &string
|
|||
|
||||
void ShortcutsSettings::setShortcuts(const QString &name, const QList<QKeySequence> &Sequence)
|
||||
{
|
||||
shortCuts[name] = Sequence;
|
||||
shortCuts[name].setSequence(Sequence);
|
||||
|
||||
QSettings shortCutsFile(settingsFilePath, QSettings::IniFormat);
|
||||
shortCutsFile.beginGroup(custom);
|
||||
|
|
@ -132,7 +132,6 @@ void ShortcutsSettings::resetAllShortcuts()
|
|||
shortCutsFile.remove("");
|
||||
shortCutsFile.endGroup();
|
||||
emit shortCutChanged();
|
||||
emit allShortCutsReset();
|
||||
}
|
||||
|
||||
void ShortcutsSettings::clearAllShortcuts()
|
||||
|
|
@ -140,12 +139,11 @@ void ShortcutsSettings::clearAllShortcuts()
|
|||
QSettings shortCutsFile(settingsFilePath, QSettings::IniFormat);
|
||||
shortCutsFile.beginGroup(custom);
|
||||
for (auto it = shortCuts.begin(); it != shortCuts.end(); ++it) {
|
||||
it.value() = parseSequenceString("");
|
||||
it.value().setSequence(parseSequenceString(""));
|
||||
shortCutsFile.setValue(it.key(), "");
|
||||
}
|
||||
shortCutsFile.endGroup();
|
||||
emit shortCutChanged();
|
||||
emit allShortCutsClear();
|
||||
}
|
||||
|
||||
bool ShortcutsSettings::isKeyAllowed(const QString &name, const QString &Sequences) const
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue