parent
8eacd85d68
commit
0ce38ea88e
7 changed files with 95 additions and 3 deletions
|
@ -71,6 +71,16 @@ void SequenceEdit::restoreDefault()
|
||||||
updateSettings();
|
updateSettings();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void SequenceEdit::refreshShortcut()
|
||||||
|
{
|
||||||
|
lineEdit->setText(settingsCache->shortcuts().getShortcutString(shorcutName));
|
||||||
|
}
|
||||||
|
|
||||||
|
void SequenceEdit::clear()
|
||||||
|
{
|
||||||
|
this->lineEdit->setText("");
|
||||||
|
}
|
||||||
|
|
||||||
bool SequenceEdit::eventFilter(QObject *, QEvent * event)
|
bool SequenceEdit::eventFilter(QObject *, QEvent * event)
|
||||||
{
|
{
|
||||||
if(event->type() == QEvent::KeyPress || event->type() == QEvent::KeyRelease)
|
if(event->type() == QEvent::KeyPress || event->type() == QEvent::KeyRelease)
|
||||||
|
|
|
@ -14,11 +14,14 @@ class SequenceEdit : public QWidget
|
||||||
public:
|
public:
|
||||||
SequenceEdit(QString _shorcutName, QWidget *parent = 0);
|
SequenceEdit(QString _shorcutName, QWidget *parent = 0);
|
||||||
QString getSecuence();
|
QString getSecuence();
|
||||||
|
void refreshShortcut();
|
||||||
|
void clear();
|
||||||
signals:
|
signals:
|
||||||
|
|
||||||
private slots:
|
private slots:
|
||||||
void removeLastShortcut();
|
void removeLastShortcut();
|
||||||
void restoreDefault();
|
void restoreDefault();
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
bool eventFilter(QObject *, QEvent *event);
|
bool eventFilter(QObject *, QEvent *event);
|
||||||
private:
|
private:
|
||||||
|
|
|
@ -1,10 +1,17 @@
|
||||||
#include "shortcutstab.h"
|
#include "shortcutstab.h"
|
||||||
#include "ui_shortcutstab.h"
|
#include "ui_shortcutstab.h"
|
||||||
|
|
||||||
|
#include "../settingscache.h"
|
||||||
|
#include <QMessageBox>
|
||||||
|
|
||||||
ShortcutsTab::ShortcutsTab() :
|
ShortcutsTab::ShortcutsTab() :
|
||||||
ui(new Ui::shortcutsTab)
|
ui(new Ui::shortcutsTab)
|
||||||
{
|
{
|
||||||
ui->setupUi(this);
|
ui->setupUi(this);
|
||||||
|
connect(ui->btnResetAll,SIGNAL(clicked()),this,SLOT(resetShortcuts()));
|
||||||
|
connect(ui->btnClearAll,SIGNAL(clicked()),this,SLOT(clearShortcuts()));
|
||||||
|
connect(&settingsCache->shortcuts(),SIGNAL(allShortCutsReset()),this,SLOT(refreshEdits()));
|
||||||
|
connect(&settingsCache->shortcuts(),SIGNAL(allShortCutsClear()),this,SLOT(afterClear()));
|
||||||
}
|
}
|
||||||
|
|
||||||
void ShortcutsTab::retranslateUi()
|
void ShortcutsTab::retranslateUi()
|
||||||
|
@ -16,3 +23,33 @@ ShortcutsTab::~ShortcutsTab()
|
||||||
{
|
{
|
||||||
delete ui;
|
delete ui;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void ShortcutsTab::resetShortcuts()
|
||||||
|
{
|
||||||
|
settingsCache->shortcuts().resetAllShortcuts();
|
||||||
|
}
|
||||||
|
|
||||||
|
void ShortcutsTab::refreshEdits()
|
||||||
|
{
|
||||||
|
QList<SequenceEdit*> edits = this->findChildren<SequenceEdit*>();
|
||||||
|
for(int i= 0; i < edits.length(); ++i)
|
||||||
|
{
|
||||||
|
edits.at(i)->refreshShortcut();
|
||||||
|
}
|
||||||
|
QMessageBox::information(this,tr("Shortcuts reset"),tr("All shortcuts have been reset"));
|
||||||
|
}
|
||||||
|
|
||||||
|
void ShortcutsTab::clearShortcuts()
|
||||||
|
{
|
||||||
|
settingsCache->shortcuts().clearAllShortcuts();
|
||||||
|
}
|
||||||
|
|
||||||
|
void ShortcutsTab::afterClear()
|
||||||
|
{
|
||||||
|
QList<SequenceEdit*> edits = this->findChildren<SequenceEdit*>();
|
||||||
|
for(int i= 0; i < edits.length(); ++i)
|
||||||
|
{
|
||||||
|
edits.at(i)->clear();
|
||||||
|
}
|
||||||
|
QMessageBox::information(this,tr("Shortcuts reset"),tr("All shortcuts have been cleared"));
|
||||||
|
}
|
||||||
|
|
|
@ -17,7 +17,11 @@ public:
|
||||||
ShortcutsTab();
|
ShortcutsTab();
|
||||||
void retranslateUi();
|
void retranslateUi();
|
||||||
~ShortcutsTab();
|
~ShortcutsTab();
|
||||||
|
private slots:
|
||||||
|
void resetShortcuts();
|
||||||
|
void refreshEdits();
|
||||||
|
void clearShortcuts();
|
||||||
|
void afterClear();
|
||||||
private:
|
private:
|
||||||
Ui::shortcutsTab *ui;
|
Ui::shortcutsTab *ui;
|
||||||
};
|
};
|
||||||
|
|
|
@ -10,6 +10,7 @@
|
||||||
#include <QHBoxLayout>
|
#include <QHBoxLayout>
|
||||||
#include <QHeaderView>
|
#include <QHeaderView>
|
||||||
#include <QLabel>
|
#include <QLabel>
|
||||||
|
#include <QPushButton>
|
||||||
#include <QSpacerItem>
|
#include <QSpacerItem>
|
||||||
#include <QTabWidget>
|
#include <QTabWidget>
|
||||||
#include <QVBoxLayout>
|
#include <QVBoxLayout>
|
||||||
|
@ -270,6 +271,8 @@ public:
|
||||||
QSpacerItem *verticalSpacer_3;
|
QSpacerItem *verticalSpacer_3;
|
||||||
QWidget * tab_4;
|
QWidget * tab_4;
|
||||||
QLabel *faqLabel;
|
QLabel *faqLabel;
|
||||||
|
QPushButton *btnResetAll;
|
||||||
|
QPushButton *btnClearAll;
|
||||||
|
|
||||||
void setupUi(QWidget *shortcutsTab)
|
void setupUi(QWidget *shortcutsTab)
|
||||||
{
|
{
|
||||||
|
@ -1410,8 +1413,19 @@ public:
|
||||||
faqLabel->setTextInteractionFlags(Qt::LinksAccessibleByMouse);
|
faqLabel->setTextInteractionFlags(Qt::LinksAccessibleByMouse);
|
||||||
faqLabel->setOpenExternalLinks(true);
|
faqLabel->setOpenExternalLinks(true);
|
||||||
|
|
||||||
gridLayout_9->addWidget(tabWidget, 0, 0, 1, 1);
|
btnResetAll = new QPushButton(shortcutsTab);
|
||||||
|
btnClearAll = new QPushButton(shortcutsTab);
|
||||||
|
|
||||||
|
btnResetAll->setIcon(QPixmap("theme:icons/update"));
|
||||||
|
btnClearAll->setIcon(QPixmap("theme:icons/clearsearch"));
|
||||||
|
|
||||||
|
QHBoxLayout *buttonsLayout = new QHBoxLayout(shortcutsTab);
|
||||||
|
buttonsLayout->addWidget(btnClearAll);
|
||||||
|
buttonsLayout->addWidget(btnResetAll);
|
||||||
|
|
||||||
|
gridLayout_9->addWidget(tabWidget, 0, 0, 1, 2);
|
||||||
gridLayout_9->addWidget(faqLabel,1,0,1,1);
|
gridLayout_9->addWidget(faqLabel,1,0,1,1);
|
||||||
|
gridLayout_9->addLayout(buttonsLayout,1,1,1,1,Qt::AlignRight);
|
||||||
tabWidget->setCurrentIndex(0);
|
tabWidget->setCurrentIndex(0);
|
||||||
|
|
||||||
grid->setSpacing(3);
|
grid->setSpacing(3);
|
||||||
|
@ -1567,6 +1581,8 @@ public:
|
||||||
tabWidget->setTabText(tabWidget->indexOf(tab_3), QApplication::translate("shortcutsTab", "Draw | Move | View | Gameplay", 0));
|
tabWidget->setTabText(tabWidget->indexOf(tab_3), QApplication::translate("shortcutsTab", "Draw | Move | View | Gameplay", 0));
|
||||||
tabWidget->setTabText(tabWidget->indexOf(tab_4), QApplication::translate("shortcutsTab","Counters", 0));
|
tabWidget->setTabText(tabWidget->indexOf(tab_4), QApplication::translate("shortcutsTab","Counters", 0));
|
||||||
faqLabel->setText(QString("<a href='%1'>%2</a>").arg(WIKI).arg(QApplication::translate("shortcutsTab","How to set custom shortcuts",0)));
|
faqLabel->setText(QString("<a href='%1'>%2</a>").arg(WIKI).arg(QApplication::translate("shortcutsTab","How to set custom shortcuts",0)));
|
||||||
|
btnResetAll->setText(QApplication::translate("shortcutsTab","Reset all shortcuts",0));
|
||||||
|
btnClearAll->setText(QApplication::translate("shortcutsTab","Clear all shortcuts",0));
|
||||||
} // retranslateUi
|
} // retranslateUi
|
||||||
|
|
||||||
};
|
};
|
||||||
|
|
|
@ -119,6 +119,24 @@ bool ShortcutsSettings::isValid(QString name, QString Sequences)
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void ShortcutsSettings::resetAllShortcuts()
|
||||||
|
{
|
||||||
|
for(QMap<QString,QList<QKeySequence> >::const_iterator it = defaultShortCuts.begin();
|
||||||
|
it != defaultShortCuts.end(); ++it){
|
||||||
|
setShortcuts(it.key(), it.value());
|
||||||
|
}
|
||||||
|
emit allShortCutsReset();
|
||||||
|
}
|
||||||
|
|
||||||
|
void ShortcutsSettings::clearAllShortcuts()
|
||||||
|
{
|
||||||
|
for(QMap<QString,QList<QKeySequence> >::const_iterator it = shortCuts.begin();
|
||||||
|
it != shortCuts.end(); ++it){
|
||||||
|
setShortcuts(it.key(), "");
|
||||||
|
}
|
||||||
|
emit allShortCutsClear();
|
||||||
|
}
|
||||||
|
|
||||||
void ShortcutsSettings::fillDefaultShorcuts()
|
void ShortcutsSettings::fillDefaultShorcuts()
|
||||||
{
|
{
|
||||||
defaultShortCuts["MainWindow/aCheckCardUpdates"] = parseSequenceString("");
|
defaultShortCuts["MainWindow/aCheckCardUpdates"] = parseSequenceString("");
|
||||||
|
|
|
@ -24,9 +24,13 @@ public:
|
||||||
void setShortcuts(QString name, QString Sequences);
|
void setShortcuts(QString name, QString Sequences);
|
||||||
|
|
||||||
bool isValid(QString name, QString Sequences);
|
bool isValid(QString name, QString Sequences);
|
||||||
|
|
||||||
|
void resetAllShortcuts();
|
||||||
|
void clearAllShortcuts();
|
||||||
signals:
|
signals:
|
||||||
void shortCutchanged();
|
void shortCutchanged();
|
||||||
|
void allShortCutsReset();
|
||||||
|
void allShortCutsClear();
|
||||||
private:
|
private:
|
||||||
QString settingsFilePath;
|
QString settingsFilePath;
|
||||||
QMap<QString,QList<QKeySequence> > shortCuts;
|
QMap<QString,QList<QKeySequence> > shortCuts;
|
||||||
|
|
Loading…
Reference in a new issue