diff --git a/useractions.cpp b/useractions.cpp index afb6c74a03..26ca0a5536 100755 --- a/useractions.cpp +++ b/useractions.cpp @@ -72,7 +72,9 @@ along with this program. If not, see . #include #include #include +#include #include +#include #include #include #include @@ -838,6 +840,7 @@ void UserActionsMenu::slotToggleOnActivity(QAction *action) //**************************************** ShortcutDialog::ShortcutDialog(const QKeySequence& cut) : _shortcut(cut) + , m_buttons(new QDialogButtonBox(QDialogButtonBox::Ok | QDialogButtonBox::Cancel, this)) { QWidget *vBoxContainer = new QWidget(this); vBoxContainer->setLayout(new QVBoxLayout(vBoxContainer)); @@ -857,14 +860,15 @@ ShortcutDialog::ShortcutDialog(const QKeySequence& cut) widget, SIGNAL(keySequenceChanged(QKeySequence)), SLOT(keySequenceChanged(QKeySequence))); - setMainWidget(vBoxContainer); + QVBoxLayout *mainLayout = new QVBoxLayout(this); + mainLayout->addWidget(vBoxContainer); + m_buttons->button(QDialogButtonBox::Ok)->setDefault(true); + connect(m_buttons, &QDialogButtonBox::accepted, this, &ShortcutDialog::accept); + connect(m_buttons, &QDialogButtonBox::rejected, this, &QDialog::reject); + mainLayout->addWidget(m_buttons); widget->setFocus(); - // make it a popup, so that it has the grab - XSetWindowAttributes attrs; - attrs.override_redirect = True; - XChangeWindowAttributes(display(), winId(), CWOverrideRedirect, &attrs); - setWindowFlags(Qt::Popup); + setWindowFlags(Qt::Popup | Qt::X11BypassWindowManagerHint); } void ShortcutDialog::accept() @@ -879,16 +883,16 @@ void ShortcutDialog::accept() || (seq[0] & Qt::KeyboardModifierMask) == 0) { // clear widget->clearKeySequence(); - KDialog::accept(); + QDialog::accept(); return; } } - KDialog::accept(); + QDialog::accept(); } void ShortcutDialog::done(int r) { - KDialog::done(r); + QDialog::done(r); emit dialogDone(r == Accepted); } @@ -917,7 +921,7 @@ void ShortcutDialog::keySequenceChanged(const QKeySequence &seq) widget->setKeySequence(shortcut()); } else if (seq != _shortcut) { warning->hide(); - if (QPushButton *ok = button(KDialog::Ok)) + if (QPushButton *ok = m_buttons->button(QDialogButtonBox::Ok)) ok->setFocus(); } diff --git a/useractions.h b/useractions.h index 41d809ad40..a5968b308d 100644 --- a/useractions.h +++ b/useractions.h @@ -20,14 +20,14 @@ along with this program. If not, see . #ifndef KWIN_USERACTIONS_H #define KWIN_USERACTIONS_H -// KDE -#include // Qt +#include #include #include class KKeySequenceWidget; class QAction; +class QDialogButtonBox; class QLabel; class QMenu; class QRect; @@ -261,7 +261,7 @@ private: }; class ShortcutDialog - : public KDialog + : public QDialog { Q_OBJECT public: @@ -278,6 +278,7 @@ private: KKeySequenceWidget* widget; QKeySequence _shortcut; QLabel *warning; + QDialogButtonBox *m_buttons; }; } // namespace