/* This file is part of the KDE libraries Copyright (C) 1998 Mark Donohoe Copyright (C) 1997 Nicolas Hadacek Copyright (C) 1998 Matthias Ettrich Copyright (C) 2001 Ellis Whitehead Copyright (C) 2006 Hamish Rodda Copyright (C) 2007 Roberto Raggi Copyright (C) 2007 Andreas Hartmetz Copyright (C) 2008 Michael Jansen Copyright (C) 2008 Alexander Dymo Copyright (C) 2009 Chani Armitage This library is free software; you can redistribute it and/or modify it under the terms of the GNU Library General Public License as published by the Free Software Foundation; either version 2 of the License, or (at your option) any later version. This library is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Library General Public License for more details. You should have received a copy of the GNU Library General Public License along with this library; see the file COPYING.LIB. If not, write to the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. */ #include "kshortcutsdialog.h" #include "kdebug.h" #include "klocale.h" #include #include #include #include #include #include /************************************************************************/ /* KShortcutsDialog */ /* */ /* Originally by Nicolas Hadacek */ /* */ /* Substantially revised by Mark Donohoe */ /* */ /* And by Espen Sand 1999-10-19 */ /* (by using KDialog there is almost no code left ;) */ /* */ /************************************************************************/ class KShortcutsDialog::KShortcutsDialogPrivate { public: KShortcutsDialogPrivate(KShortcutsDialog *q) : q(q), m_keyChooser(0) { } QList m_collections; void save() { m_keyChooser->exportConfiguration(); emit q->saved(); } KShortcutsDialog *q; KShortcutsEditor* m_keyChooser; }; KShortcutsDialog::KShortcutsDialog(KShortcutsEditor::ActionTypes types, KShortcutsEditor::LetterShortcuts allowLetterShortcuts, QWidget *parent) : KDialog(parent), d(new KShortcutsDialogPrivate(this)) { setCaption(i18n("Configure Shortcuts")); setButtons(KDialog::Reset | KDialog::Ok | KDialog::Cancel); setModal(true); d->m_keyChooser = new KShortcutsEditor(this, types, allowLetterShortcuts); setMainWidget(d->m_keyChooser); setButtonText(Reset, i18n("Reset to Defaults")); connect(this, SIGNAL(resetClicked()), d->m_keyChooser, SLOT(allDefault())); connect(this, SIGNAL(okClicked()), this, SLOT(save())); KConfigGroup group(KGlobal::config(), "KShortcutsDialog Settings"); resize(group.readEntry("Dialog Size", sizeHint())); } KShortcutsDialog::~KShortcutsDialog() { KConfigGroup group(KGlobal::config(), "KShortcutsDialog Settings"); group.writeEntry("Dialog Size", size(), KConfigGroup::Persistent | KConfigGroup::Global); delete d; } void KShortcutsDialog::addCollection(KActionCollection *collection, const QString &title) { d->m_keyChooser->addCollection(collection, title); d->m_keyChooser->importConfiguration(); d->m_collections << collection; } QList KShortcutsDialog::actionCollections() const { return d->m_collections; } bool KShortcutsDialog::configure() { if (isModal()) { int retcode = exec(); return retcode; } show(); return false; } QSize KShortcutsDialog::sizeHint() const { return QSize(600, 480); } int KShortcutsDialog::configure(KActionCollection *collection, KShortcutsEditor::LetterShortcuts allowLetterShortcuts, QWidget *parent) { kDebug(125) << "KShortcutsDialog::configure()" << collection; KShortcutsDialog dlg(KShortcutsEditor::AllActions, allowLetterShortcuts, parent); dlg.addCollection(collection); return dlg.configure(); } #include "moc_kshortcutsdialog.cpp"