78 lines
2.6 KiB
C++
78 lines
2.6 KiB
C++
#include "keystrokeeditorwindow.h"
|
|
#include "ui_keystrokeeditorwindow.h"
|
|
|
|
#include "QtImprovements/qsettingsplus.h"
|
|
|
|
KeystrokeEditorWindow::KeystrokeEditorWindow(const quint8 &row, const quint8 &column, const bool &dial, QWidget *parent)
|
|
: QDialog(parent)
|
|
, ui(new Ui::KeystrokeEditorWindow)
|
|
, row(row)
|
|
, column(column)
|
|
{
|
|
ui->setupUi(this);
|
|
|
|
if (!dial) {
|
|
ui->labelRotateLeft->setVisible(false);
|
|
ui->kseRotateLeft->setVisible(false);
|
|
ui->kseRotateLeft->setEnabled(false);
|
|
ui->labelRotateRight->setVisible(false);
|
|
ui->kseRotateRight->setVisible(false);
|
|
ui->kseRotateRight->setEnabled(false);
|
|
} else {
|
|
ui->kseRotateLeft->setEnabled(true);
|
|
ui->kseRotateRight->setEnabled(true);
|
|
}
|
|
|
|
QSettings settings = QSettingsPlus::createQSettings();
|
|
settings.beginGroup("ButtonMacros");
|
|
const QString &keyPress = QString("KeyPress-%1-%2").arg(this->row).arg(this->column);
|
|
ui->kseKeyPress->setKeySequence(settings.value(keyPress).toString());
|
|
const QString &keyRotateLeft = QString("RotateLeft-%1-%2").arg(this->row).arg(this->column);
|
|
ui->kseRotateLeft->setKeySequence(settings.value(keyRotateLeft).toString());
|
|
const QString &keyRotateRight = QString("RotateRight-%1-%2").arg(this->row).arg(this->column);
|
|
ui->kseRotateRight->setKeySequence(settings.value(keyRotateRight).toString());
|
|
|
|
QObject::connect(ui->kseKeyPress,
|
|
&QKeySequenceEdit::editingFinished,
|
|
this,
|
|
&KeystrokeEditorWindow::saveNewKeyPressMacro);
|
|
QObject::connect(ui->kseRotateLeft,
|
|
&QKeySequenceEdit::editingFinished,
|
|
this,
|
|
&KeystrokeEditorWindow::saveNewRotateLeftMacro);
|
|
QObject::connect(ui->kseRotateRight,
|
|
&QKeySequenceEdit::editingFinished,
|
|
this,
|
|
&KeystrokeEditorWindow::saveNewRotateRightMacro);
|
|
}
|
|
|
|
KeystrokeEditorWindow::~KeystrokeEditorWindow()
|
|
{
|
|
delete ui;
|
|
}
|
|
|
|
|
|
void KeystrokeEditorWindow::saveNewKeyPressMacro()
|
|
{
|
|
QSettings settings = QSettingsPlus::createQSettings();
|
|
settings.beginGroup("ButtonMacros");
|
|
const QString &key = QString("KeyPress-%1-%2").arg(this->row).arg(this->column);
|
|
settings.setValue(key, ui->kseKeyPress->keySequence());
|
|
}
|
|
|
|
void KeystrokeEditorWindow::saveNewRotateLeftMacro()
|
|
{
|
|
QSettings settings = QSettingsPlus::createQSettings();
|
|
settings.beginGroup("ButtonMacros");
|
|
const QString &key = QString("RotateLeft-%1-%2").arg(this->row).arg(this->column);
|
|
settings.setValue(key, ui->kseRotateLeft->keySequence());
|
|
}
|
|
|
|
void KeystrokeEditorWindow::saveNewRotateRightMacro()
|
|
{
|
|
QSettings settings = QSettingsPlus::createQSettings();
|
|
settings.beginGroup("ButtonMacros");
|
|
const QString &key = QString("RotateRight-%1-%2").arg(this->row).arg(this->column);
|
|
settings.setValue(key, ui->kseRotateRight->keySequence());
|
|
}
|