Keystrokes can now be edited per button/knob.
This commit is contained in:
parent
d418424c14
commit
02121b934d
@ -17,6 +17,7 @@ SOURCES += \
|
||||
Widgets/qprocesslistitem.cpp \
|
||||
Widgets/qratiobutton.cpp \
|
||||
WindowFinder/windowfinder.cpp \
|
||||
keystrokeeditorwindow.cpp \
|
||||
main.cpp \
|
||||
qmacrobindswindow.cpp \
|
||||
qmacrokeysmanager.cpp \
|
||||
@ -32,12 +33,14 @@ HEADERS += \
|
||||
Widgets/qratiobutton.h \
|
||||
WindowFinder/win32/windowfinderkeymap.h \
|
||||
WindowFinder/windowfinder.h \
|
||||
keystrokeeditorwindow.h \
|
||||
qmacrobindswindow.h \
|
||||
qmacrokeysmanager.h \
|
||||
windowfinderdialogue.h
|
||||
|
||||
FORMS += \
|
||||
Widgets/applicationinfowidget.ui \
|
||||
keystrokeeditorwindow.ui \
|
||||
qmacrobindswindow.ui \
|
||||
windowfinderdialogue.ui
|
||||
|
||||
|
||||
@ -10,6 +10,8 @@ class QDialButton : public QRatioButton
|
||||
|
||||
public:
|
||||
QDialButton(const quint8 &row, const quint8 &column, QWidget *parent = nullptr);
|
||||
|
||||
virtual Type type() const override { return QRatioButton::Type::DIAL; }
|
||||
};
|
||||
|
||||
#endif // QDIALBUTTON_H
|
||||
|
||||
@ -10,6 +10,8 @@ class QMacroButton : public QRatioButton
|
||||
|
||||
public:
|
||||
QMacroButton(const quint8 &row, const quint8 &column, QWidget *parent = nullptr);
|
||||
|
||||
virtual Type type() const override { return QRatioButton::Type::PUSH_BUTTON; }
|
||||
};
|
||||
|
||||
#endif // QMACROBUTTON_H
|
||||
|
||||
@ -8,10 +8,18 @@ class QRatioButton : public QPushButton
|
||||
Q_OBJECT
|
||||
|
||||
public:
|
||||
enum class Type : quint8 {
|
||||
INVALID,
|
||||
PUSH_BUTTON,
|
||||
DIAL
|
||||
};
|
||||
|
||||
QRatioButton(const quint8 &row, const quint8 &column, QWidget *parent = nullptr);
|
||||
|
||||
virtual int heightForWidth(int w) const;
|
||||
|
||||
virtual Type type() const { return Type::INVALID; }
|
||||
|
||||
private:
|
||||
void onButtonPressSignal();
|
||||
|
||||
|
||||
77
keystrokeeditorwindow.cpp
Normal file
77
keystrokeeditorwindow.cpp
Normal file
@ -0,0 +1,77 @@
|
||||
#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());
|
||||
}
|
||||
30
keystrokeeditorwindow.h
Normal file
30
keystrokeeditorwindow.h
Normal file
@ -0,0 +1,30 @@
|
||||
#ifndef KEYSTROKEEDITORWINDOW_H
|
||||
#define KEYSTROKEEDITORWINDOW_H
|
||||
|
||||
#include <QDialog>
|
||||
|
||||
namespace Ui {
|
||||
class KeystrokeEditorWindow;
|
||||
}
|
||||
|
||||
class KeystrokeEditorWindow : public QDialog
|
||||
{
|
||||
Q_OBJECT
|
||||
|
||||
public:
|
||||
explicit KeystrokeEditorWindow(const quint8 &row, const quint8 &column, const bool &dial, QWidget *parent = nullptr);
|
||||
~KeystrokeEditorWindow();
|
||||
|
||||
private slots:
|
||||
void saveNewKeyPressMacro();
|
||||
void saveNewRotateLeftMacro();
|
||||
void saveNewRotateRightMacro();
|
||||
|
||||
private:
|
||||
Ui::KeystrokeEditorWindow *ui;
|
||||
|
||||
quint8 row = 0;
|
||||
quint8 column = 0;
|
||||
};
|
||||
|
||||
#endif // KEYSTROKEEDITORWINDOW_H
|
||||
97
keystrokeeditorwindow.ui
Normal file
97
keystrokeeditorwindow.ui
Normal file
@ -0,0 +1,97 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<ui version="4.0">
|
||||
<class>KeystrokeEditorWindow</class>
|
||||
<widget class="QDialog" name="KeystrokeEditorWindow">
|
||||
<property name="geometry">
|
||||
<rect>
|
||||
<x>0</x>
|
||||
<y>0</y>
|
||||
<width>477</width>
|
||||
<height>373</height>
|
||||
</rect>
|
||||
</property>
|
||||
<property name="windowTitle">
|
||||
<string>Dialog</string>
|
||||
</property>
|
||||
<layout class="QVBoxLayout" name="verticalLayout_2">
|
||||
<item>
|
||||
<widget class="QSplitter" name="splitter">
|
||||
<property name="orientation">
|
||||
<enum>Qt::Orientation::Horizontal</enum>
|
||||
</property>
|
||||
<widget class="QListWidget" name="listApplications"/>
|
||||
<widget class="QWidget" name="">
|
||||
<layout class="QVBoxLayout" name="verticalLayout">
|
||||
<item>
|
||||
<layout class="QGridLayout" name="gridLayout">
|
||||
<item row="0" column="1">
|
||||
<widget class="QKeySequenceEdit" name="kseKeyPress"/>
|
||||
</item>
|
||||
<item row="0" column="0">
|
||||
<widget class="QLabel" name="labelKeyPress">
|
||||
<property name="text">
|
||||
<string>Key Press:</string>
|
||||
</property>
|
||||
<property name="alignment">
|
||||
<set>Qt::AlignmentFlag::AlignRight|Qt::AlignmentFlag::AlignTrailing|Qt::AlignmentFlag::AlignVCenter</set>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="1" column="1">
|
||||
<widget class="QKeySequenceEdit" name="kseRotateLeft">
|
||||
<property name="enabled">
|
||||
<bool>false</bool>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="1" column="0">
|
||||
<widget class="QLabel" name="labelRotateLeft">
|
||||
<property name="text">
|
||||
<string>Rotate Left:</string>
|
||||
</property>
|
||||
<property name="alignment">
|
||||
<set>Qt::AlignmentFlag::AlignRight|Qt::AlignmentFlag::AlignTrailing|Qt::AlignmentFlag::AlignVCenter</set>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="2" column="0">
|
||||
<widget class="QLabel" name="labelRotateRight">
|
||||
<property name="text">
|
||||
<string>Rotate Right</string>
|
||||
</property>
|
||||
<property name="alignment">
|
||||
<set>Qt::AlignmentFlag::AlignRight|Qt::AlignmentFlag::AlignTrailing|Qt::AlignmentFlag::AlignVCenter</set>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="2" column="1">
|
||||
<widget class="QKeySequenceEdit" name="kseRotateRight">
|
||||
<property name="enabled">
|
||||
<bool>false</bool>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
</layout>
|
||||
</item>
|
||||
<item>
|
||||
<spacer name="verticalSpacer">
|
||||
<property name="orientation">
|
||||
<enum>Qt::Orientation::Vertical</enum>
|
||||
</property>
|
||||
<property name="sizeHint" stdset="0">
|
||||
<size>
|
||||
<width>20</width>
|
||||
<height>40</height>
|
||||
</size>
|
||||
</property>
|
||||
</spacer>
|
||||
</item>
|
||||
</layout>
|
||||
</widget>
|
||||
</widget>
|
||||
</item>
|
||||
</layout>
|
||||
</widget>
|
||||
<resources/>
|
||||
<connections/>
|
||||
</ui>
|
||||
@ -14,7 +14,7 @@
|
||||
#include <QStandardPaths>
|
||||
#include <QUrl>
|
||||
|
||||
#include <QDebug>
|
||||
#include "keystrokeeditorwindow.h"
|
||||
|
||||
|
||||
QMacroBindsWindow::QMacroBindsWindow(QWidget *parent)
|
||||
@ -114,7 +114,12 @@ void QMacroBindsWindow::newButtonState(const quint8 &row, const quint8 &column,
|
||||
if (column < this->vButtonWidgets[row].size()) {
|
||||
this->vButtonWidgets[row][column]->setCheckable(true);
|
||||
this->vButtonWidgets[row][column]->setChecked(state);
|
||||
WindowFinder::sendInputToFrontmostWindow(QKeySequence(tr("Shift+Z")), state ? KeyEventType::PRESS : KeyEventType::RELEASE);
|
||||
|
||||
QSettings settings = QSettingsPlus::createQSettings();
|
||||
settings.beginGroup("ButtonMacros");
|
||||
const QString &key = QString("KeyPress-%1-%2").arg(row).arg(column);
|
||||
QKeySequence sequence(settings.value(key).toString());
|
||||
WindowFinder::sendInputToFrontmostWindow(sequence, state ? KeyEventType::PRESS : KeyEventType::RELEASE);
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -123,15 +128,20 @@ void QMacroBindsWindow::newEncoderRotation(const quint8 &column, const EncoderRo
|
||||
{
|
||||
const QVector<QPushButton *> &encoderButtons = this->vButtonWidgets.last();
|
||||
if (column < encoderButtons.size()) {
|
||||
WindowFinder::sendInputToFrontmostWindow(direction == EncoderRotation::CCW ? QKeySequence(tr("Shift+Y")) : QKeySequence(tr("Shift+A")), KeyEventType::PRESS_AND_RELEASE);
|
||||
QSettings settings = QSettingsPlus::createQSettings();
|
||||
settings.beginGroup("ButtonMacros");
|
||||
const QString &key = QString("%3-%1-%2").arg(this->vButtonWidgets.size() - 1).arg(column).arg(direction == EncoderRotation::CCW ? "RotateLeft" : "RotateRight");
|
||||
QKeySequence sequence(settings.value(key).toString());
|
||||
WindowFinder::sendInputToFrontmostWindow(sequence, KeyEventType::PRESS_AND_RELEASE);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
void QMacroBindsWindow::showKeyBindingWindow(const quint8 &row, const quint8 &column)
|
||||
{
|
||||
this->vButtonWidgets[row][column]->setCheckable(false);
|
||||
qDebug() << row << ":" << column;
|
||||
QRatioButton *button = qobject_cast<QRatioButton*>(this->vButtonWidgets[row][column]);
|
||||
this->diagKeystrokeEditor = new KeystrokeEditorWindow(row, column, button->type() == QRatioButton::Type::DIAL ? true : false, this);
|
||||
this->diagKeystrokeEditor->show();
|
||||
}
|
||||
|
||||
|
||||
|
||||
@ -39,6 +39,7 @@ private:
|
||||
|
||||
Ui::QMacroBindsWindow *ui;
|
||||
class WindowFinderDialogue *diagWindowFinder = nullptr;
|
||||
class KeystrokeEditorWindow *diagKeystrokeEditor = nullptr;
|
||||
class QMacroKeysManager *mkmMacroKeys = nullptr;
|
||||
QVector<QVector<class QPushButton*>> vButtonWidgets;
|
||||
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user