2019-02-16 16:19:29 +01:00
|
|
|
// Copyright 2018 Citra Emulator Project
|
|
|
|
// Licensed under GPLv2 or any later version
|
|
|
|
// Refer to the license.txt file included.
|
|
|
|
|
|
|
|
#include <QDialogButtonBox>
|
|
|
|
#include <QKeySequenceEdit>
|
|
|
|
#include <QVBoxLayout>
|
|
|
|
#include "yuzu/util/sequence_dialog/sequence_dialog.h"
|
|
|
|
|
|
|
|
SequenceDialog::SequenceDialog(QWidget* parent) : QDialog(parent) {
|
|
|
|
setWindowTitle(tr("Enter a hotkey"));
|
2019-05-25 07:11:01 +02:00
|
|
|
setWindowFlags(windowFlags() & ~Qt::WindowContextHelpButtonHint);
|
|
|
|
|
2019-02-16 16:19:29 +01:00
|
|
|
key_sequence = new QKeySequenceEdit;
|
2019-05-25 07:11:01 +02:00
|
|
|
|
|
|
|
auto* const buttons = new QDialogButtonBox(QDialogButtonBox::Ok | QDialogButtonBox::Cancel);
|
2019-02-16 16:19:29 +01:00
|
|
|
buttons->setCenterButtons(true);
|
2019-05-25 07:11:01 +02:00
|
|
|
|
|
|
|
auto* const layout = new QVBoxLayout(this);
|
|
|
|
layout->addWidget(key_sequence);
|
2019-02-16 16:19:29 +01:00
|
|
|
layout->addWidget(buttons);
|
2019-05-25 07:11:01 +02:00
|
|
|
|
2019-02-16 16:19:29 +01:00
|
|
|
connect(buttons, &QDialogButtonBox::accepted, this, &QDialog::accept);
|
|
|
|
connect(buttons, &QDialogButtonBox::rejected, this, &QDialog::reject);
|
|
|
|
}
|
|
|
|
|
|
|
|
SequenceDialog::~SequenceDialog() = default;
|
|
|
|
|
|
|
|
QKeySequence SequenceDialog::GetSequence() const {
|
|
|
|
// Only the first key is returned. The other 3, if present, are ignored.
|
|
|
|
return QKeySequence(key_sequence->keySequence()[0]);
|
|
|
|
}
|
|
|
|
|
|
|
|
bool SequenceDialog::focusNextPrevChild(bool next) {
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
|
|
|
|
void SequenceDialog::closeEvent(QCloseEvent*) {
|
|
|
|
reject();
|
|
|
|
}
|