~ubuntu-branches/ubuntu/lucid/kdebase/lucid

« back to all changes in this revision

Viewing changes to kcontrol/kfontinst/kcmfontinst/SettingsDialog.cpp

  • Committer: Bazaar Package Importer
  • Author(s): Jonathan Riddell
  • Date: 2008-05-27 12:09:48 UTC
  • mfrom: (1.1.13 upstream)
  • Revision ID: james.westby@ubuntu.com-20080527120948-dottsyd5rcwhzd36
Tags: 4:4.0.80-1ubuntu1
* Merge with Debian
 - remove 97_fix_target_link_libraries.diff
 - Add replaces/conflicts on -kde4 packages

Show diffs side-by-side

added added

removed removed

Lines of Context:
1
 
////////////////////////////////////////////////////////////////////////////////
2
 
//
3
 
// Class Name    : KFI::CSettingsDialog
4
 
// Author        : Craig Drummond
5
 
// Project       : K Font Installer
6
 
// Creation Date : 10/05/2005
7
 
// Version       : $Revision$ $Date$
8
 
//
9
 
////////////////////////////////////////////////////////////////////////////////
10
 
//
11
 
// This program is free software; you can redistribute it and/or
12
 
// modify it under the terms of the GNU General Public License
13
 
// as published by the Free Software Foundation; either version 2
14
 
// of the License, or (at your option) any later version.
15
 
//
16
 
// This program is distributed in the hope that it will be useful,
17
 
// but WITHOUT ANY WARRANTY; without even the implied warranty of
18
 
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
19
 
// GNU General Public License for more details.
20
 
//
21
 
// You should have received a copy of the GNU General Public License
22
 
// along with this program; if not, write to the Free Software
23
 
// Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301, USA.
24
 
//
25
 
////////////////////////////////////////////////////////////////////////////////
26
 
// (C) Craig Drummond, 2005
27
 
////////////////////////////////////////////////////////////////////////////////
28
 
 
29
 
#include "SettingsDialog.h"
30
 
#include "KfiConstants.h"
31
 
#include "Misc.h"
32
 
#include <qlayout.h>
33
 
#include <qcheckbox.h>
34
 
#include <qvbox.h>
35
 
#include <qwhatsthis.h>
36
 
#include <klocale.h>
37
 
#include <kconfig.h>
38
 
#include <kmessagebox.h>
39
 
#include <kio/job.h>
40
 
#include <kio/netaccess.h>
41
 
 
42
 
namespace KFI
43
 
{
44
 
 
45
 
CSettingsDialog::CSettingsDialog(QWidget *parent)
46
 
               : KDialogBase(parent, "settingsdialog", true, i18n("Settings"),
47
 
                             KDialogBase::Ok|KDialogBase::Cancel, KDialogBase::Ok, true)
48
 
{
49
 
    QVBox *page = makeVBoxMainWidget();
50
 
 
51
 
    itsDoX=new QCheckBox(i18n("Configure fonts for legacy X applications"), page);
52
 
    QWhatsThis::add(itsDoX, i18n("<p>Modern applications use a system called \"FontConfig\" to obtain the list of fonts. "
53
 
                                 "Older applications, such as OpenOffice 1.x, GIMP 1.x, etc. use the previous \"core X fonts\" mechanism for "
54
 
                                 "this.</p><p>Selecting this option will inform the installer to create the necessary files so that these "
55
 
                                 "older applications can use the fonts you install.</p><p>Please note, however, that this will slow down "
56
 
                                 "the installation process.<p>"));
57
 
    itsDoGs=new QCheckBox(i18n("Configure fonts for Ghostscript"), page);
58
 
    QWhatsThis::add(itsDoGs, i18n("<p>When printing, most applications create what is know as PostScript. This is then sent to a special "
59
 
                                  "application, named Ghostscript, which can interpret the PostScript and send the appropriate instructions "
60
 
                                  "to your printer. If your application does not embed whatever fonts it uses into the PostScript, then "
61
 
                                  "Ghostscript needs to be informed as to which fonts you have installed, and where they are located.</p>"
62
 
                                  "<p>Selecting this option will create the necessary Ghostscript config files.</p><p>Please note, however, "
63
 
                                  "that this will also slow down the installation process.</p><p>As most applications can, and do, embed "
64
 
                                  "the fonts into the PostScript before sending this to Ghostscript, this option can safely be disabled."));
65
 
 
66
 
    KConfig cfg(Misc::root() ? KFI_ROOT_CFG_FILE : KFI_CFG_FILE);
67
 
 
68
 
    itsDoX->setChecked(cfg.readBoolEntry(KFI_CFG_X_KEY, KFI_DEFAULT_CFG_X));
69
 
    itsDoGs->setChecked(cfg.readBoolEntry(KFI_CFG_GS_KEY, KFI_DEFAULT_CFG_GS));
70
 
}
71
 
 
72
 
void CSettingsDialog::slotOk()
73
 
{
74
 
    KConfig cfg(Misc::root() ? KFI_ROOT_CFG_FILE : KFI_CFG_FILE);
75
 
 
76
 
    bool oldDoX=cfg.readBoolEntry(KFI_CFG_X_KEY, KFI_DEFAULT_CFG_X),
77
 
         oldDoGs=cfg.readBoolEntry(KFI_CFG_GS_KEY, KFI_DEFAULT_CFG_GS);
78
 
 
79
 
    cfg.writeEntry(KFI_CFG_X_KEY, itsDoX->isChecked());
80
 
    cfg.writeEntry(KFI_CFG_GS_KEY, itsDoGs->isChecked());
81
 
    cfg.sync();
82
 
 
83
 
    if( ((!oldDoX && itsDoX->isChecked()) || (!oldDoGs && itsDoGs->isChecked())) &&
84
 
        KMessageBox::Yes==KMessageBox::questionYesNo(this, i18n("You have enabled a previously disabled option. Would you like the config "
85
 
                                                                "files updated now? (Normally they are only updated upon installing, or "
86
 
                                                                "removing, a font.)"), QString::null, i18n("Update"),i18n("Do Not Update")))
87
 
    {
88
 
        QByteArray  packedArgs;
89
 
        QDataStream stream(packedArgs, IO_WriteOnly);
90
 
 
91
 
        stream << KFI::SPECIAL_RECONFIG;
92
 
 
93
 
        KIO::NetAccess::synchronousRun(KIO::special(KFI_KIO_FONTS_PROTOCOL ":/", packedArgs), this);
94
 
    }
95
 
 
96
 
    hide();
97
 
}
98
 
 
99
 
}