1
////////////////////////////////////////////////////////////////////////////////
3
// Class Name : KFI::CSettingsDialog
4
// Author : Craig Drummond
5
// Project : K Font Installer
6
// Creation Date : 10/05/2005
7
// Version : $Revision$ $Date$
9
////////////////////////////////////////////////////////////////////////////////
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.
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.
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.
25
////////////////////////////////////////////////////////////////////////////////
26
// (C) Craig Drummond, 2005
27
////////////////////////////////////////////////////////////////////////////////
29
#include "SettingsDialog.h"
30
#include "KfiConstants.h"
33
#include <qcheckbox.h>
35
#include <qwhatsthis.h>
38
#include <kmessagebox.h>
40
#include <kio/netaccess.h>
45
CSettingsDialog::CSettingsDialog(QWidget *parent)
46
: KDialogBase(parent, "settingsdialog", true, i18n("Settings"),
47
KDialogBase::Ok|KDialogBase::Cancel, KDialogBase::Ok, true)
49
QVBox *page = makeVBoxMainWidget();
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."));
66
KConfig cfg(Misc::root() ? KFI_ROOT_CFG_FILE : KFI_CFG_FILE);
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));
72
void CSettingsDialog::slotOk()
74
KConfig cfg(Misc::root() ? KFI_ROOT_CFG_FILE : KFI_CFG_FILE);
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);
79
cfg.writeEntry(KFI_CFG_X_KEY, itsDoX->isChecked());
80
cfg.writeEntry(KFI_CFG_GS_KEY, itsDoGs->isChecked());
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")))
88
QByteArray packedArgs;
89
QDataStream stream(packedArgs, IO_WriteOnly);
91
stream << KFI::SPECIAL_RECONFIG;
93
KIO::NetAccess::synchronousRun(KIO::special(KFI_KIO_FONTS_PROTOCOL ":/", packedArgs), this);