1/*
2 * Copyright (C) 2008 Laurent Montel <montel@kde.org>
3 *
4 * This program is free software; you can redistribute it and/or modify
5 * it under the terms of the GNU General Public License as published by
6 * the Free Software Foundation; either version 2 of the License, or
7 * (at your option) any later version.
8 *
9 * This program is distributed in the hope that it will be useful,
10 * but WITHOUT ANY WARRANTY; without even the implied warranty of
11 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12 * GNU General Public License for more details.
13 *
14 * You should have received a copy of the GNU General Public License
15 * along with this program; if not, write to the Free Software
16 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
17 *
18 */
19
20#include "preferencesdlg.h"
21
22#include <QHBoxLayout>
23#include <QCheckBox>
24
25#include <KLocale>
26#include <KConfigGroup>
27#include <sonnet/configwidget.h>
28
29PreferencesDialog::PreferencesDialog( QWidget *parent )
30 : KPageDialog( parent )
31{
32 setFaceType( List );
33 setButtons( Ok | Cancel );
34 setDefaultButton( Ok );
35
36 m_pageMisc = new MiscPage( this );
37 KPageWidgetItem *page = new KPageWidgetItem( m_pageMisc , i18n( "General" ) );
38 page->setIcon( KIcon( "kmenuedit" ) );
39 addPage(page);
40
41 m_pageSpellChecking = new SpellCheckingPage( this );
42 page = new KPageWidgetItem( m_pageSpellChecking , i18n( "Spell Checking" ) );
43 page->setHeader( i18n( "Spell checking Options" ) );
44 page->setIcon( KIcon( "tools-check-spelling" ) );
45 addPage(page);
46
47 connect( this, SIGNAL(okClicked()), this, SLOT(slotSave()) );
48}
49
50void PreferencesDialog::slotSave()
51{
52 m_pageSpellChecking->saveOptions();
53 m_pageMisc->saveOptions();
54}
55
56SpellCheckingPage::SpellCheckingPage( QWidget *parent )
57 : QWidget( parent )
58{
59 QHBoxLayout *lay = new QHBoxLayout( this );
60 m_confPage = new Sonnet::ConfigWidget(&( *KGlobal::config() ), this );
61 lay->addWidget( m_confPage );
62 setLayout( lay );
63}
64
65void SpellCheckingPage::saveOptions()
66{
67 m_confPage->save();
68}
69
70MiscPage::MiscPage( QWidget *parent )
71 : QWidget( parent )
72{
73 QVBoxLayout *lay = new QVBoxLayout( this );
74 m_showHiddenEntries = new QCheckBox( i18n( "Show hidden entries" ), this );
75 lay->addWidget( m_showHiddenEntries );
76 lay->addStretch();
77 setLayout( lay );
78
79 KConfigGroup group( KGlobal::config(), "General" );
80 m_showHiddenEntries->setChecked( group.readEntry( "ShowHidden", false ) );
81}
82
83void MiscPage::saveOptions()
84{
85 KConfigGroup group( KGlobal::config(), "General" );
86 group.writeEntry( "ShowHidden", m_showHiddenEntries->isChecked() );
87 group.sync();
88}
89
90#include "preferencesdlg.moc"
91