This repository has been archived by the owner on Aug 23, 2021. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 15
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
2bd01bf
commit 67c8f5c
Showing
6 changed files
with
154 additions
and
8 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,37 @@ | ||
#include "hotkeyinputdialog.hpp" | ||
#include "ui_hotkeyinputdialog.h" | ||
#include <QKeyEvent> | ||
#include <QLineEdit> | ||
#include <QPushButton> | ||
|
||
HotkeyInputDialog::HotkeyInputDialog(QString hotkeyName, QKeySequence currentSeq, QWidget *parent) | ||
: QDialog(parent), ui(new Ui::HotkeyInputDialog) { | ||
ui->setupUi(this); | ||
ui->keySeq->setText(currentSeq.toString()); | ||
setWindowTitle(hotkeyName); | ||
connect(this, &QDialog::accepted, [&] { | ||
QKeySequence s(ui->keySeq->text()); | ||
if (!s.toString().isEmpty()) emit sequenceSelected(s, windowTitle()); | ||
}); | ||
} | ||
|
||
HotkeyInputDialog::~HotkeyInputDialog() { | ||
delete ui; | ||
} | ||
|
||
void HotkeyInputDialog::keyPressEvent(QKeyEvent *e) { | ||
if (e->key() == Qt::Key_Shift || e->key() == Qt::Key_Control || e->key() == Qt::Key_Alt || e->key() == Qt::Key_AltGr | ||
|| e->key() == Qt::Key_Context1 || e->key() == Qt::Key_Context2 || e->key() == Qt::Key_Context3 || e->key() == Qt::Key_Context4) | ||
return; | ||
if (recording) { | ||
QKeySequence seq(e->modifiers() + e->key()); | ||
ui->keySeq->setText(seq.toString()); | ||
recording = false; | ||
ui->recordButton->setText("Record"); | ||
} | ||
} | ||
|
||
void HotkeyInputDialog::on_recordButton_clicked() { | ||
recording = !recording; | ||
ui->recordButton->setText(recording ? "Stop recording" : "Record"); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,31 @@ | ||
#ifndef HOTKEYINPUTDIALOG_HPP | ||
#define HOTKEYINPUTDIALOG_HPP | ||
|
||
#include <QDialog> | ||
|
||
namespace Ui { | ||
class HotkeyInputDialog; | ||
} | ||
|
||
class HotkeyInputDialog : public QDialog { | ||
Q_OBJECT | ||
|
||
public: | ||
explicit HotkeyInputDialog(QString hotkeyName, QKeySequence currentSeq, QWidget *parent = 0); | ||
~HotkeyInputDialog(); | ||
|
||
signals: | ||
void sequenceSelected(QKeySequence seq, QString name); | ||
|
||
protected: | ||
void keyPressEvent(QKeyEvent *e) override; | ||
|
||
private slots: | ||
void on_recordButton_clicked(); | ||
|
||
private: | ||
bool recording = false; | ||
Ui::HotkeyInputDialog *ui; | ||
}; | ||
|
||
#endif // HOTKEYINPUTDIALOG_HPP |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,74 @@ | ||
<?xml version="1.0" encoding="UTF-8"?> | ||
<ui version="4.0"> | ||
<class>HotkeyInputDialog</class> | ||
<widget class="QDialog" name="HotkeyInputDialog"> | ||
<property name="geometry"> | ||
<rect> | ||
<x>0</x> | ||
<y>0</y> | ||
<width>255</width> | ||
<height>80</height> | ||
</rect> | ||
</property> | ||
<property name="windowTitle"> | ||
<string>Dialog</string> | ||
</property> | ||
<layout class="QGridLayout" name="gridLayout"> | ||
<item row="0" column="0"> | ||
<widget class="QLineEdit" name="keySeq"/> | ||
</item> | ||
<item row="0" column="1"> | ||
<widget class="QPushButton" name="recordButton"> | ||
<property name="text"> | ||
<string>Record</string> | ||
</property> | ||
</widget> | ||
</item> | ||
<item row="1" column="0" colspan="2"> | ||
<widget class="QDialogButtonBox" name="buttonBox"> | ||
<property name="orientation"> | ||
<enum>Qt::Horizontal</enum> | ||
</property> | ||
<property name="standardButtons"> | ||
<set>QDialogButtonBox::Cancel|QDialogButtonBox::Ok</set> | ||
</property> | ||
</widget> | ||
</item> | ||
</layout> | ||
</widget> | ||
<resources/> | ||
<connections> | ||
<connection> | ||
<sender>buttonBox</sender> | ||
<signal>accepted()</signal> | ||
<receiver>HotkeyInputDialog</receiver> | ||
<slot>accept()</slot> | ||
<hints> | ||
<hint type="sourcelabel"> | ||
<x>248</x> | ||
<y>254</y> | ||
</hint> | ||
<hint type="destinationlabel"> | ||
<x>157</x> | ||
<y>274</y> | ||
</hint> | ||
</hints> | ||
</connection> | ||
<connection> | ||
<sender>buttonBox</sender> | ||
<signal>rejected()</signal> | ||
<receiver>HotkeyInputDialog</receiver> | ||
<slot>reject()</slot> | ||
<hints> | ||
<hint type="sourcelabel"> | ||
<x>316</x> | ||
<y>260</y> | ||
</hint> | ||
<hint type="destinationlabel"> | ||
<x>286</x> | ||
<y>274</y> | ||
</hint> | ||
</hints> | ||
</connection> | ||
</connections> | ||
</ui> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters