~ubuntu-branches/ubuntu/utopic/kde-workspace/utopic-proposed

« back to all changes in this revision

Viewing changes to kmenuedit/preferencesdlg.cpp

  • Committer: Bazaar Package Importer
  • Author(s): Michał Zając
  • Date: 2011-07-09 08:31:15 UTC
  • Revision ID: james.westby@ubuntu.com-20110709083115-ohyxn6z93mily9fc
Tags: upstream-4.6.90
Import upstream version 4.6.90

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
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
#include <QHBoxLayout>
 
22
#include <klocale.h>
 
23
#include <sonnet/configwidget.h>
 
24
#include <QCheckBox>
 
25
#include <KConfigGroup>
 
26
#include <QGroupBox>
 
27
 
 
28
PreferencesDialog::PreferencesDialog( QWidget *parent )
 
29
    : KPageDialog( parent )
 
30
{
 
31
    setFaceType( List );
 
32
    setButtons( Ok | Cancel );
 
33
    setDefaultButton( Ok );
 
34
 
 
35
    m_pageMisc = new MiscPage( this );
 
36
    KPageWidgetItem *page = new KPageWidgetItem( m_pageMisc , i18n( "General" ) );
 
37
    page->setIcon( KIcon( "kmenuedit" ) );
 
38
    addPage(page);
 
39
 
 
40
    m_pageSpellChecking = new SpellCheckingPage( this );
 
41
    page = new KPageWidgetItem( m_pageSpellChecking , i18n( "Spell Checking" ) );
 
42
    page->setHeader( i18n( "Spell checking Options" ) );
 
43
    page->setIcon( KIcon( "tools-check-spelling" ) );
 
44
    addPage(page);
 
45
 
 
46
    connect( this, SIGNAL( okClicked() ), this, SLOT( slotSave() ) );
 
47
}
 
48
 
 
49
void PreferencesDialog::slotSave()
 
50
{
 
51
    m_pageSpellChecking->saveOptions();
 
52
    m_pageMisc->saveOptions();
 
53
}
 
54
 
 
55
SpellCheckingPage::SpellCheckingPage( QWidget *parent )
 
56
    : QWidget( parent )
 
57
{
 
58
    QHBoxLayout *lay = new QHBoxLayout( this );
 
59
    m_confPage = new Sonnet::ConfigWidget(&( *KGlobal::config() ), this );
 
60
    lay->addWidget( m_confPage );
 
61
    setLayout( lay );
 
62
}
 
63
 
 
64
void SpellCheckingPage::saveOptions()
 
65
{
 
66
    m_confPage->save();
 
67
}
 
68
 
 
69
MiscPage::MiscPage( QWidget *parent )
 
70
    : QWidget( parent )
 
71
{
 
72
    QVBoxLayout *lay = new QVBoxLayout( this );
 
73
    m_showHiddenEntries = new QCheckBox( i18n( "Show hidden entries" ), this );
 
74
    lay->addWidget( m_showHiddenEntries );
 
75
    lay->addStretch();
 
76
    setLayout( lay );
 
77
 
 
78
    KConfigGroup grp( KGlobal::config(), "General" );
 
79
    m_showHiddenEntries->setChecked(  grp.readEntry( "ShowHidden", false ) );
 
80
}
 
81
 
 
82
void MiscPage::saveOptions()
 
83
{
 
84
    KConfigGroup grp( KGlobal::config(), "General" );
 
85
    grp.writeEntry( "ShowHidden", m_showHiddenEntries->isChecked() );
 
86
    grp.sync();
 
87
}
 
88
 
 
89
#include "preferencesdlg.moc"