File indexing completed on 2024-05-05 16:39:02
0001 /* This file is part of the KDE project 0002 Copyright (C) 1998-2002 Carsten Pfeiffer <pfeiffer@kde.org> 0003 0004 This program is free software; you can redistribute it and/or 0005 modify it under the terms of the GNU General Public 0006 License as published by the Free Software Foundation, version 2. 0007 0008 This program is distributed in the hope that it will be useful, 0009 but WITHOUT ANY WARRANTY; without even the implied warranty of 0010 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 0011 General Public License for more details. 0012 0013 You should have received a copy of the GNU General Public License 0014 along with this program; see the file COPYING. If not, write to 0015 the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, 0016 Boston, MA 02110-1301, USA. 0017 */ 0018 0019 #include "kuickconfigdlg.h" 0020 0021 #include <QDialogButtonBox> 0022 #include <KLocalizedString> 0023 #include <KSharedConfig> 0024 #include <KShortcutsDialog> 0025 0026 #include <QPushButton> 0027 0028 #include "defaultswidget.h" 0029 #include "generalwidget.h" 0030 #include "imagewindow.h" 0031 #include "kuickdata.h" 0032 #include "slideshowwidget.h" 0033 0034 0035 KuickConfigDialog::KuickConfigDialog( KActionCollection *_coll, QWidget *parent, bool modal ) 0036 : KPageDialog( parent ) 0037 { 0038 setStandardButtons(QDialogButtonBox::Ok | QDialogButtonBox::Apply | QDialogButtonBox::Cancel | QDialogButtonBox::RestoreDefaults | QDialogButtonBox::Help); 0039 setModal( modal ); 0040 setWindowTitle( i18n("Configure") ); 0041 setFaceType( Tabbed ); 0042 coll = _coll; 0043 0044 generalWidget = new GeneralWidget( this ); 0045 generalWidget->setObjectName( QString::fromLatin1( "general widget" ) ); 0046 addPage( generalWidget, i18n("&General") ); 0047 0048 defaultsWidget = new DefaultsWidget( this ); 0049 defaultsWidget->setObjectName( QString::fromLatin1( "defaults widget" ) ); 0050 addPage( defaultsWidget, i18n("&Modifications") ); 0051 0052 slideshowWidget = new SlideShowWidget( this ); 0053 slideshowWidget->setObjectName( QString::fromLatin1( "slideshow widget" ) ); 0054 addPage( slideshowWidget, i18n("&Slideshow") ); 0055 0056 imageWindow = new ImageWindow(); // just to get the accel... 0057 imageWindow->hide(); 0058 imageKeyChooser = new KShortcutsEditor( imageWindow->actionCollection(), this ); 0059 addPage( imageKeyChooser, i18n("&Viewer Shortcuts") ); 0060 0061 browserKeyChooser = new KShortcutsEditor( coll, this ); 0062 addPage( browserKeyChooser, i18n("Bro&wser Shortcuts") ); 0063 0064 connect(buttonBox()->button(QDialogButtonBox::RestoreDefaults), SIGNAL(clicked()), SLOT(resetDefaults())); 0065 connect(buttonBox()->button(QDialogButtonBox::Ok), SIGNAL(clicked()), SIGNAL(okClicked())); 0066 connect(buttonBox()->button(QDialogButtonBox::Apply), SIGNAL(clicked()), SIGNAL(applyClicked())); 0067 } 0068 0069 KuickConfigDialog::~KuickConfigDialog() 0070 { 0071 delete imageWindow; 0072 } 0073 0074 void KuickConfigDialog::applyConfig() 0075 { 0076 generalWidget->applySettings( *kdata ); 0077 defaultsWidget->applySettings( *kdata ); 0078 slideshowWidget->applySettings( *kdata ); 0079 0080 imageKeyChooser->save(); 0081 browserKeyChooser->save(); 0082 0083 KSharedConfig::openConfig()->sync(); 0084 } 0085 0086 0087 void KuickConfigDialog::resetDefaults() 0088 { 0089 KuickData data; 0090 generalWidget->loadSettings( data ); 0091 defaultsWidget->loadSettings( data ); 0092 slideshowWidget->loadSettings( data ); 0093 //TODO port it 0094 //imageKeyChooser->allDefault(); 0095 //browserKeyChooser->allDefault(); 0096 }