Commit be9d329d authored by Scott Wheeler's avatar Scott Wheeler

CVS_SILENT formatting

svn path=/trunk/kdemultimedia/juk/; revision=292426
parent 7ba070ee
/***************************************************************************
keydialog.cpp - description
key-dialog.cpp - description
-------------------
begin : Tue Mar 11 19:00:00 CET 2003
copyright : (C) 2003 by Stefan Asserhall
......@@ -26,51 +26,54 @@
// Table of shortcut keys for each action, key group and three or four button modifier
const KeyDialog::KeyInfo KeyDialog::keyInfo[] = {
{"PlayPause",
{{KShortcut::null(), KShortcut::null()},
{Qt::CTRL+Qt::ALT+Qt::Key_P, KKey::QtWIN+Qt::ALT+Qt::Key_P},
{Qt::Key_MediaPlay, Qt::Key_MediaPlay}}},
{"Stop",
{{KShortcut::null(), KShortcut::null()},
{Qt::CTRL+Qt::ALT+Qt::Key_S, KKey::QtWIN+Qt::ALT+Qt::Key_S},
{Qt::Key_MediaStop, Qt::Key_MediaStop}}},
{"Back",
{{KShortcut::null(), KShortcut::null()},
{Qt::CTRL+Qt::ALT+Qt::Key_Left, KKey::QtWIN+Qt::ALT+Qt::Key_Left},
{Qt::Key_MediaPrev, Qt::Key_MediaPrev}}},
{"Forward",
{{KShortcut::null(), KShortcut::null()},
{Qt::CTRL+Qt::ALT+Qt::Key_Right, KKey::QtWIN+Qt::ALT+Qt::Key_Right},
{Qt::Key_MediaNext, Qt::Key_MediaNext}}},
{"SeekBack",
{{KShortcut::null(), KShortcut::null()},
{Qt::CTRL+Qt::SHIFT+Qt::ALT+Qt::Key_Left, KKey::QtWIN+Qt::SHIFT+Qt::ALT+Qt::Key_Left},
{Qt::SHIFT+Qt::Key_MediaPrev, Qt::SHIFT+Qt::Key_MediaPrev}}},
{"SeekForward",
{{KShortcut::null(), KShortcut::null()},
{Qt::CTRL+Qt::SHIFT+Qt::ALT+Qt::Key_Right,KKey::QtWIN+Qt::SHIFT+Qt::ALT+Qt::Key_Right},
{Qt::SHIFT+Qt::Key_MediaNext, Qt::SHIFT+Qt::Key_MediaNext}}},
{"VolumeUp",
{{KShortcut::null(), KShortcut::null()},
{Qt::CTRL+Qt::ALT+Qt::SHIFT+Qt::Key_Up, KKey::QtWIN+Qt::ALT+Qt::SHIFT+Qt::Key_Up},
{Qt::Key_VolumeUp, Qt::Key_VolumeUp}}},
{"VolumeDown",
{{KShortcut::null(), KShortcut::null()},
{Qt::CTRL+Qt::ALT+Qt::SHIFT+Qt::Key_Down, KKey::QtWIN+Qt::ALT+Qt::SHIFT+Qt::Key_Down},
{Qt::Key_VolumeDown, Qt::Key_VolumeDown}}},
{"Mute",
{{KShortcut::null(), KShortcut::null()},
{Qt::CTRL+Qt::ALT+Qt::Key_M, KKey::QtWIN+Qt::ALT+Qt::Key_M},
{Qt::Key_VolumeMute, Qt::Key_VolumeMute}}}
{ "PlayPause",
{ { KShortcut::null(), KShortcut::null() },
{ Qt::CTRL+Qt::ALT+Qt::Key_P, KKey::QtWIN+Qt::ALT+Qt::Key_P },
{ Qt::Key_MediaPlay, Qt::Key_MediaPlay } } },
{ "Stop",
{ { KShortcut::null(), KShortcut::null() },
{ Qt::CTRL+Qt::ALT+Qt::Key_S, KKey::QtWIN+Qt::ALT+Qt::Key_S },
{ Qt::Key_MediaStop, Qt::Key_MediaStop } } },
{ "Back",
{ { KShortcut::null(), KShortcut::null() },
{ Qt::CTRL+Qt::ALT+Qt::Key_Left, KKey::QtWIN+Qt::ALT+Qt::Key_Left },
{ Qt::Key_MediaPrev, Qt::Key_MediaPrev } } },
{ "Forward",
{ { KShortcut::null(), KShortcut::null() },
{ Qt::CTRL+Qt::ALT+Qt::Key_Right, KKey::QtWIN+Qt::ALT+Qt::Key_Right },
{ Qt::Key_MediaNext, Qt::Key_MediaNext } } },
{ "SeekBack",
{ { KShortcut::null(), KShortcut::null() },
{ Qt::CTRL+Qt::SHIFT+Qt::ALT+Qt::Key_Left, KKey::QtWIN+Qt::SHIFT+Qt::ALT+Qt::Key_Left },
{ Qt::SHIFT+Qt::Key_MediaPrev, Qt::SHIFT+Qt::Key_MediaPrev } } },
{ "SeekForward",
{ { KShortcut::null(), KShortcut::null() },
{ Qt::CTRL+Qt::SHIFT+Qt::ALT+Qt::Key_Right, KKey::QtWIN+Qt::SHIFT+Qt::ALT+Qt::Key_Right },
{ Qt::SHIFT+Qt::Key_MediaNext, Qt::SHIFT+Qt::Key_MediaNext } } },
{ "VolumeUp",
{ { KShortcut::null(), KShortcut::null() },
{ Qt::CTRL+Qt::ALT+Qt::SHIFT+Qt::Key_Up, KKey::QtWIN+Qt::ALT+Qt::SHIFT+Qt::Key_Up },
{ Qt::Key_VolumeUp, Qt::Key_VolumeUp } } },
{ "VolumeDown",
{ { KShortcut::null(), KShortcut::null() },
{ Qt::CTRL+Qt::ALT+Qt::SHIFT+Qt::Key_Down, KKey::QtWIN+Qt::ALT+Qt::SHIFT+Qt::Key_Down },
{ Qt::Key_VolumeDown, Qt::Key_VolumeDown } } },
{ "Mute",
{ { KShortcut::null(), KShortcut::null() },
{ Qt::CTRL+Qt::ALT+Qt::Key_M, KKey::QtWIN+Qt::ALT+Qt::Key_M },
{ Qt::Key_VolumeMute, Qt::Key_VolumeMute } } }
};
const uint KeyDialog::keyInfoCount = sizeof(KeyDialog::keyInfo) / sizeof(KeyDialog::keyInfo[0]);
KeyDialog::KeyDialog(KGlobalAccel *keys, KActionCollection *actionCollection, QWidget *parent, const char* name)
KeyDialog::KeyDialog(KGlobalAccel *keys, KActionCollection *actionCollection,
QWidget *parent, const char *name)
: KDialogBase(parent, name, true, i18n("Configure Shortcuts"), Default | Ok | Cancel, Ok)
{
// Read key group from configuration
int selectedButton;
KConfig *config = KGlobal::config();
{
......@@ -79,29 +82,34 @@ KeyDialog::KeyDialog(KGlobalAccel *keys, KActionCollection *actionCollection, QW
}
// Create widgets for key chooser - widget stack used to replace key chooser
QVBox *vbox = new QVBox(this);
vbox->setSpacing(KDialog::spacingHint());
m_widgetStack = new QWidgetStack(vbox);
// Create buttons to select key group
m_group = new QHButtonGroup(i18n("Global Shortcuts"), vbox);
new QRadioButton(i18n("&No keys"), m_group);
new QRadioButton(i18n("&Standard keys"), m_group);
new QRadioButton(i18n("&No keys"), m_group);
new QRadioButton(i18n("&Standard keys"), m_group);
new QRadioButton(i18n("&Multimedia keys"), m_group);
connect(m_group, SIGNAL(clicked(int)), this, SLOT(slotKeys(int)));
QWhatsThis::add( m_group,
i18n("Here you can select the keys used as global shortcuts to control the player"));
// Create the key chooser
setMainWidget(vbox);
newDialog(keys, actionCollection, selectedButton);
}
KeyDialog::~KeyDialog()
{
}
void KeyDialog::newDialog(KGlobalAccel* keys, KActionCollection* actionCollection, int selectedButton)
void KeyDialog::newDialog(KGlobalAccel *keys, KActionCollection *actionCollection,
int selectedButton)
{
m_keys = keys;
m_actionCollection = actionCollection;
......@@ -119,6 +127,7 @@ void KeyDialog::newDialog(KGlobalAccel* keys, KActionCollection* actionCollectio
int KeyDialog::configure()
{
// Show the dialog and save configuration if accepted
int retcode = exec();
if(retcode == Accepted) {
KConfig *config = KGlobal::config();
......@@ -137,10 +146,12 @@ void KeyDialog::slotKeys(int group)
bool fourModKeys = KGlobalAccel::useFourModifierKeys();
// Set modifier keys according to key group and modifier keys
for (uint i = 0; i < keyInfoCount; i++)
for(uint i = 0; i < keyInfoCount; i++)
m_keys->setShortcut(keyInfo[i].action, keyInfo[i].shortcut[group][fourModKeys]);
// Create a new key chooser to show the keys, and delete the old one
QWidget *w = m_widgetStack->visibleWidget();
newDialog(m_keys, m_actionCollection, group);
m_widgetStack->removeWidget(w);
......@@ -150,33 +161,38 @@ void KeyDialog::slotKeys(int group)
void KeyDialog::slotDefault()
{
// Select default keys - standard key group
m_group->setButton(StandardKeys);
m_pKeyChooser->allDefault();
}
int KeyDialog::configure(KGlobalAccel *keys, KActionCollection *actionCollection, QWidget* parent)
int KeyDialog::configure(KGlobalAccel *keys, KActionCollection *actionCollection,
QWidget *parent)
{
// Create and show dialog - update connections if accepted
KeyDialog dlg(keys, actionCollection, parent);
int retcode = dlg.configure();
if (retcode == Accepted)
int retcode = KeyDialog(keys, actionCollection, parent).configure();
if(retcode == Accepted)
keys->updateConnections();
return retcode;
}
void KeyDialog::insert(KGlobalAccel* keys, const QString& action, const QString& label,
const QObject* objSlot, const char* methodSlot)
void KeyDialog::insert(KGlobalAccel *keys, const QString &action, const QString &label,
const QObject *objSlot, const char *methodSlot)
{
KShortcut def3 = KShortcut::null();
KShortcut def4 = KShortcut::null();
// Find and insert a standard key
for (uint i = 0; i < keyInfoCount; i++)
if (keyInfo[i].action == action) {
for(uint i = 0; i < keyInfoCount; i++) {
if(keyInfo[i].action == action) {
def3 = keyInfo[i].shortcut[StandardKeys][0];
def4 = keyInfo[i].shortcut[StandardKeys][1];
break;
}
}
keys->insert(action, label, QString::null, def3, def4, objSlot, methodSlot);
}
......
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