sequence_dialog.cpp 1.2 KB

12345678910111213141516171819202122232425262728293031323334353637
  1. // Copyright 2018 Citra Emulator Project
  2. // Licensed under GPLv2 or any later version
  3. // Refer to the license.txt file included.
  4. #include <QDialogButtonBox>
  5. #include <QKeySequenceEdit>
  6. #include <QVBoxLayout>
  7. #include "yuzu/util/sequence_dialog/sequence_dialog.h"
  8. SequenceDialog::SequenceDialog(QWidget* parent) : QDialog(parent) {
  9. setWindowTitle(tr("Enter a hotkey"));
  10. auto* layout = new QVBoxLayout(this);
  11. key_sequence = new QKeySequenceEdit;
  12. layout->addWidget(key_sequence);
  13. auto* buttons =
  14. new QDialogButtonBox(QDialogButtonBox::Ok | QDialogButtonBox::Cancel, Qt::Horizontal);
  15. buttons->setCenterButtons(true);
  16. layout->addWidget(buttons);
  17. connect(buttons, &QDialogButtonBox::accepted, this, &QDialog::accept);
  18. connect(buttons, &QDialogButtonBox::rejected, this, &QDialog::reject);
  19. setWindowFlags(windowFlags() & ~Qt::WindowContextHelpButtonHint);
  20. }
  21. SequenceDialog::~SequenceDialog() = default;
  22. QKeySequence SequenceDialog::GetSequence() const {
  23. // Only the first key is returned. The other 3, if present, are ignored.
  24. return QKeySequence(key_sequence->keySequence()[0]);
  25. }
  26. bool SequenceDialog::focusNextPrevChild(bool next) {
  27. return false;
  28. }
  29. void SequenceDialog::closeEvent(QCloseEvent*) {
  30. reject();
  31. }