Git commit 9b56415011e72cb22020cf612ee0c1a017aa77c0 by Michael Pyne. Committed on 30/09/2017 at 19:49. Pushed by mpyne into branch 'frameworks'. Port the shortcut key dialog away from KDialog. M +1 -1 juk.cpp M +25 -26 keydialog.cpp M +15 -25 keydialog.h https://commits.kde.org/juk/9b56415011e72cb22020cf612ee0c1a017aa77c0 diff --git a/juk.cpp b/juk.cpp index 66797b6..295e0bc 100644 --- a/juk.cpp +++ b/juk.cpp @@ -552,7 +552,7 @@ void JuK::slotToggleSystemTray(bool enabled) = void JuK::slotEditKeys() { - KeyDialog::configure(ActionCollection::actions(), this); + KeyDialog(ActionCollection::actions(), this).configure(); } = void JuK::slotConfigureTagGuesser() diff --git a/keydialog.cpp b/keydialog.cpp index 3a6efb8..90b9956 100644 --- a/keydialog.cpp +++ b/keydialog.cpp @@ -22,8 +22,6 @@ #include #include #include -#include -#include #include #include = @@ -31,9 +29,12 @@ #include #include #include +#include #include +#include #include #include +#include #include #include = @@ -94,10 +95,10 @@ const KeyDialog::KeyInfo KeyDialog::keyInfo[] =3D { const uint KeyDialog::keyInfoCount =3D sizeof(KeyDialog::keyInfo) / sizeof= (KeyDialog::keyInfo[0]); = KeyDialog::KeyDialog(KActionCollection *actionCollection, QWidget *parent) - : KDialog(parent), m_actionCollection(actionCollection) + : QDialog(parent) + , m_actionCollection(actionCollection) { - setCaption(i18n("Configure Shortcuts")); - setButtons(Default | Ok | Cancel); + setWindowTitle(i18n("Configure Shortcuts")); = // Read key group from configuration = @@ -106,17 +107,18 @@ KeyDialog::KeyDialog(KActionCollection *actionCollect= ion, QWidget *parent) = // Create widgets for key chooser = - KVBox *vbox =3D new KVBox(this); - vbox->setSpacing(KDialog::spacingHint()); + auto vboxLayout =3D new QVBoxLayout(this); = - m_pKeyChooser =3D new KShortcutsEditor(actionCollection, vbox); + m_pKeyChooser =3D new KShortcutsEditor(actionCollection, this); + vboxLayout->addWidget(m_pKeyChooser); = // Create buttons to select key group = - QGroupBox *buttonBox =3D new QGroupBox(i18n("Global Shortcuts"), vbox); + QGroupBox *buttonBox =3D new QGroupBox(i18n("Global Shortcuts"), this); + vboxLayout->addWidget(buttonBox); + m_group =3D new QButtonGroup(buttonBox); - QHBoxLayout *buttonLayout =3D new QHBoxLayout; - buttonBox->setLayout(buttonLayout); + QHBoxLayout *buttonLayout =3D new QHBoxLayout(buttonBox); = QRadioButton *radioButton =3D new QRadioButton(i18n("&No keys"), butto= nBox); m_group->addButton(radioButton, NoKeys); @@ -130,19 +132,23 @@ KeyDialog::KeyDialog(KActionCollection *actionCollect= ion, QWidget *parent) m_group->addButton(radioButton, MultimediaKeys); buttonLayout->addWidget(radioButton); = - connect(m_group, SIGNAL(buttonClicked(int)), this, SLOT(slotKeys(int))= ); + connect(m_group, SIGNAL(buttonClicked(int)), SLOT(slotKeys(int))); buttonBox->setWhatsThis( - i18n("Here you can select the keys used as global shortcuts to control th= e player")); + i18n("Here you can select the keys used as global shortcuts to con= trol the player")); = m_group->button(selectedButton)->setChecked(true); - connect(this, SIGNAL(defaultClicked()), this, SLOT(slotDefault())); = - setMainWidget(vbox); - resize(400, 500); // Make it bigger! -} + auto dlgButtonBox =3D new QDialogButtonBox( + QDialogButtonBox::Ok | QDialogButtonBox::Cancel | QDialogButto= nBox::RestoreDefaults, + this); + vboxLayout->addWidget(dlgButtonBox); = -KeyDialog::~KeyDialog() -{ + connect(dlgButtonBox, &QDialogButtonBox::accepted, this, &QDialog::acc= ept); + connect(dlgButtonBox, &QDialogButtonBox::rejected, this, &QDialog::rej= ect); + connect(dlgButtonBox->button(QDialogButtonBox::RestoreDefaults), &QAbs= tractButton::clicked, + this, &KeyD= ialog::slotDefault); + + resize(400, 500); // TODO: Make it bigger! } = int KeyDialog::configure() @@ -200,13 +206,6 @@ void KeyDialog::slotDefault() m_pKeyChooser->allDefault(); } = -int KeyDialog::configure(KActionCollection *actionCollection, QWidget *par= ent) -{ - // Create and show dialog - update connections if accepted - - return KeyDialog(actionCollection, parent).configure(); -} - void KeyDialog::setupActionShortcut(const QString &actionName) { // Find and insert a standard key diff --git a/keydialog.h b/keydialog.h index 317ac6d..6574a93 100644 --- a/keydialog.h +++ b/keydialog.h @@ -15,36 +15,25 @@ * this program. If not, see . */ = -#ifndef KEYDIALOG_H -#define KEYDIALOG_H +#ifndef JUK_KEYDIALOG_H +#define JUK_KEYDIALOG_H = -#include +#include = class QButtonGroup; = class KActionCollection; class KShortcutsEditor; = -class KeyDialog : public KDialog +/** + * For keyboard shortcut management. + */ +class KeyDialog : public QDialog { Q_OBJECT = public: - /** - * Constructs a KeyDialog called @p name as a child of @p parent. - */ - explicit KeyDialog(KActionCollection *actionCollection, QWidget *paren= t =3D 0); - - /** - * Destructor. Deletes all resources used by a KeyDialog object. - */ - virtual ~KeyDialog(); - - /** - * This is a member function, provided to allow inserting both global - * accelerators and actions. - */ - static int configure(KActionCollection *actionCollection, QWidget *par= ent =3D 0); + explicit KeyDialog(KActionCollection *actionCollection, QWidget *paren= t =3D nullptr); = /** * This is a member function, provided to create a global accelerator = with @@ -52,6 +41,9 @@ public: */ static void setupActionShortcut(const QString &actionName); = + // Does exec() and auto-saves any changed config + int configure(); + private: = /** @@ -61,16 +53,14 @@ private: */ enum KeyGroup { NoKeys =3D 0, StandardKeys =3D 1, MultimediaKeys =3D 2= }; = - int configure(); - private slots: void slotKeys(int group); void slotDefault(); = private: - KActionCollection *m_actionCollection; - KShortcutsEditor *m_pKeyChooser; - QButtonGroup *m_group; + KActionCollection *m_actionCollection =3D nullptr; + KShortcutsEditor *m_pKeyChooser =3D nullptr; + QButtonGroup *m_group =3D nullptr; = struct KeyInfo; = @@ -78,6 +68,6 @@ private: static const uint keyInfoCount; }; = -#endif // KEYDIALOG_H +#endif // JUK_KEYDIALOG_H = // vim: set et sw=3D4 tw=3D0 sta: