• Skip to content
  • Skip to link menu
KDE 4.1 API Reference
  • KDE API Reference
  • kdelibs
  • Sitemap
  • Contact Us
 

KDEUI

kshortcutsdialog.cpp

Go to the documentation of this file.
00001 /* This file is part of the KDE libraries Copyright (C) 1998 Mark Donohoe <donohoe@kde.org>
00002     Copyright (C) 1997 Nicolas Hadacek <hadacek@kde.org>
00003     Copyright (C) 1998 Matthias Ettrich <ettrich@kde.org>
00004     Copyright (C) 2001 Ellis Whitehead <ellis@kde.org>
00005     Copyright (C) 2006 Hamish Rodda <rodda@kde.org>
00006     Copyright (C) 2007 Roberto Raggi <roberto@kdevelop.org>
00007     Copyright (C) 2007 Andreas Hartmetz <ahartmetz@gmail.com>
00008     Copyright (C) 2008 Michael Jansen <kde@michael-jansen.biz>
00009 
00010     This library is free software; you can redistribute it and/or
00011     modify it under the terms of the GNU Library General Public
00012     License as published by the Free Software Foundation; either
00013     version 2 of the License, or (at your option) any later version.
00014 
00015     This library is distributed in the hope that it will be useful,
00016     but WITHOUT ANY WARRANTY; without even the implied warranty of
00017     MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
00018     Library General Public License for more details.
00019 
00020     You should have received a copy of the GNU Library General Public License
00021     along with this library; see the file COPYING.LIB.  If not, write to
00022     the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
00023     Boston, MA 02110-1301, USA.
00024 */
00025 
00026 #include "kshortcutsdialog.h"
00027 
00028 #include "kdebug.h"
00029 #include "klocale.h"
00030 
00031 
00032 /************************************************************************/
00033 /* KShortcutsDialog                                                     */
00034 /*                                                                      */
00035 /* Originally by Nicolas Hadacek <hadacek@via.ecp.fr>                   */
00036 /*                                                                      */
00037 /* Substantially revised by Mark Donohoe <donohoe@kde.org>              */
00038 /*                                                                      */
00039 /* And by Espen Sand <espen@kde.org> 1999-10-19                         */
00040 /* (by using KDialog there is almost no code left ;)                    */
00041 /*                                                                      */
00042 /************************************************************************/
00043 
00044 class KShortcutsDialog::KShortcutsDialogPrivate
00045 {
00046 public:
00047 
00048     KShortcutsDialogPrivate(KShortcutsDialog *q): q(q), m_keyChooser(0) 
00049         {}
00050 
00051     KShortcutsDialog *q;
00052     KShortcutsEditor* m_keyChooser; // ### move
00053 };
00054 
00055 
00056 KShortcutsDialog::KShortcutsDialog( KShortcutsEditor::ActionTypes types, KShortcutsEditor::LetterShortcuts allowLetterShortcuts, QWidget *parent )
00057 : KDialog( parent ), d(new KShortcutsDialogPrivate(this))
00058 {
00059     setCaption(i18n("Configure Shortcuts"));
00060     setButtons(Default|Ok|Cancel|KDialog::User1);
00061     setButtonText(KDialog::User1, i18n("Print"));
00062     setButtonIcon(KDialog::User1, KIcon("document-print"));
00063     setModal(true);
00064     d->m_keyChooser = new KShortcutsEditor( this, types, allowLetterShortcuts );
00065     setMainWidget( d->m_keyChooser );
00066     connect( this, SIGNAL(defaultClicked()), d->m_keyChooser, SLOT(allDefault()) );
00067     connect( this, SIGNAL(user1Clicked()), d->m_keyChooser, SLOT(printShortcuts()) );
00068 
00069     KConfigGroup group( KGlobal::config(), "KShortcutsDialog Settings" );
00070     resize( group.readEntry( "Dialog Size", sizeHint() ) );
00071 }
00072 
00073 
00074 KShortcutsDialog::~KShortcutsDialog()
00075 {
00076     KConfigGroup group( KGlobal::config(), "KShortcutsDialog Settings" );
00077     group.writeEntry( "Dialog Size", size(), KConfigGroup::Global );
00078     delete d;
00079 }
00080 
00081 
00082 void KShortcutsDialog::addCollection(KActionCollection *collection, const QString &title)
00083 {
00084     d->m_keyChooser->addCollection(collection, title);
00085 }
00086 
00087 
00088 bool KShortcutsDialog::configure(bool saveSettings)
00089 {
00090     int retcode = exec();
00091     if (retcode != Accepted)
00092         d->m_keyChooser->undoChanges();
00093     else if (saveSettings)
00094         d->m_keyChooser->save();
00095 
00096     return retcode;
00097 }
00098 
00099 QSize KShortcutsDialog::sizeHint() const
00100 {
00101     return QSize(500, 400);
00102 }
00103 
00104 int KShortcutsDialog::configure(KActionCollection *collection, KShortcutsEditor::LetterShortcuts allowLetterShortcuts,
00105                           QWidget *parent, bool saveSettings)
00106 {
00107     kDebug(125) << "KShortcutsDialog::configureKeys( KActionCollection*, " << saveSettings << " )";
00108     KShortcutsDialog dlg(KShortcutsEditor::AllActions, allowLetterShortcuts, parent);
00109     dlg.d->m_keyChooser->addCollection(collection);
00110     return dlg.configure(saveSettings);
00111 }
00112 
00113 #include "kshortcutsdialog.moc"
00114 #include "kshortcutsdialog_p.moc"

KDEUI

Skip menu "KDEUI"
  • Main Page
  • Modules
  • Namespace List
  • Class Hierarchy
  • Alphabetical List
  • Class List
  • File List
  • Namespace Members
  • Class Members
  • Related Pages

kdelibs

Skip menu "kdelibs"
  • DNSSD
  • Interfaces
  •   KHexEdit
  •   KMediaPlayer
  •   KSpeech
  •   KTextEditor
  • Kate
  • kconf_update
  • KDE3Support
  •   KUnitTest
  • KDECore
  • KDED
  • KDEsu
  • KDEUI
  • KDocTools
  • KFile
  • KHTML
  • KImgIO
  • KInit
  • KIO
  • KIOSlave
  • KJS
  •   KJS-API
  •   WTF
  • kjsembed
  • KNewStuff
  • KParts
  • Kross
  • KUtils
  • Nepomuk
  • Solid
  • Sonnet
  • ThreadWeaver
Generated for kdelibs by doxygen 1.5.4
This website is maintained by Adriaan de Groot and Allen Winter.
KDE® and the K Desktop Environment® logo are registered trademarks of KDE e.V. | Legal