Members of the KDE Community are recommended to subscribe to the kde-community mailing list at https://mail.kde.org/mailman/listinfo/kde-community to allow them to participate in important discussions and receive other important announcements

Commit 9b564150 authored by Michael Pyne's avatar Michael Pyne

Port the shortcut key dialog away from KDialog.

parent fac3391a
......@@ -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()
......
......@@ -22,8 +22,6 @@
#include <klocale.h>
#include <kshortcutseditor.h>
#include <kglobal.h>
#include <QAction>
#include <kvbox.h>
#include <kconfiggroup.h>
#include <KGlobalAccel>
......@@ -31,9 +29,12 @@
#include <QKeySequence>
#include <QList>
#include <QHBoxLayout>
#include <QVBoxLayout>
#include <QTimer>
#include <QDialogButtonBox>
#include <QButtonGroup>
#include <QRadioButton>
#include <QPushButton>
#include <QGroupBox>
#include <QString>
......@@ -94,10 +95,10 @@ const KeyDialog::KeyInfo KeyDialog::keyInfo[] = {
const uint KeyDialog::keyInfoCount = 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 *actionCollection, QWidget *parent)
// Create widgets for key chooser
KVBox *vbox = new KVBox(this);
vbox->setSpacing(KDialog::spacingHint());
auto vboxLayout = new QVBoxLayout(this);
m_pKeyChooser = new KShortcutsEditor(actionCollection, vbox);
m_pKeyChooser = new KShortcutsEditor(actionCollection, this);
vboxLayout->addWidget(m_pKeyChooser);
// Create buttons to select key group
QGroupBox *buttonBox = new QGroupBox(i18n("Global Shortcuts"), vbox);
QGroupBox *buttonBox = new QGroupBox(i18n("Global Shortcuts"), this);
vboxLayout->addWidget(buttonBox);
m_group = new QButtonGroup(buttonBox);
QHBoxLayout *buttonLayout = new QHBoxLayout;
buttonBox->setLayout(buttonLayout);
QHBoxLayout *buttonLayout = new QHBoxLayout(buttonBox);
QRadioButton *radioButton = new QRadioButton(i18n("&No keys"), buttonBox);
m_group->addButton(radioButton, NoKeys);
......@@ -130,19 +132,23 @@ KeyDialog::KeyDialog(KActionCollection *actionCollection, 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 the player"));
i18n("Here you can select the keys used as global shortcuts to control 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 = new QDialogButtonBox(
QDialogButtonBox::Ok | QDialogButtonBox::Cancel | QDialogButtonBox::RestoreDefaults,
this);
vboxLayout->addWidget(dlgButtonBox);
KeyDialog::~KeyDialog()
{
connect(dlgButtonBox, &QDialogButtonBox::accepted, this, &QDialog::accept);
connect(dlgButtonBox, &QDialogButtonBox::rejected, this, &QDialog::reject);
connect(dlgButtonBox->button(QDialogButtonBox::RestoreDefaults), &QAbstractButton::clicked,
this, &KeyDialog::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 *parent)
{
// 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
......
......@@ -15,36 +15,25 @@
* this program. If not, see <http://www.gnu.org/licenses/>.
*/
#ifndef KEYDIALOG_H
#define KEYDIALOG_H
#ifndef JUK_KEYDIALOG_H
#define JUK_KEYDIALOG_H
#include <KDialog>
#include <QDialog>
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 *parent = 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 *parent = 0);
explicit KeyDialog(KActionCollection *actionCollection, QWidget *parent = 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 = 0, StandardKeys = 1, MultimediaKeys = 2 };
int configure();
private slots:
void slotKeys(int group);
void slotDefault();
private:
KActionCollection *m_actionCollection;
KShortcutsEditor *m_pKeyChooser;
QButtonGroup *m_group;
KActionCollection *m_actionCollection = nullptr;
KShortcutsEditor *m_pKeyChooser = nullptr;
QButtonGroup *m_group = nullptr;
struct KeyInfo;
......@@ -78,6 +68,6 @@ private:
static const uint keyInfoCount;
};
#endif // KEYDIALOG_H
#endif // JUK_KEYDIALOG_H
// vim: set et sw=4 tw=0 sta:
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment