2 * KFontInst - KDE Font Installer
4 * Copyright 2003-2007 Craig Drummond <craig@kde.org>
8 * This program is free software; you can redistribute it and/or modify
9 * it under the terms of the GNU General Public License as published by
10 * the Free Software Foundation; either version 2 of the License, or
11 * (at your option) any later version.
13 * This program is distributed in the hope that it will be useful,
14 * but WITHOUT ANY WARRANTY; without even the implied warranty of
15 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
16 * General Public License for more details.
18 * You should have received a copy of the GNU General Public License
19 * along with this program; see the file COPYING. If not, write to
20 * the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
21 * Boston, MA 02110-1301, USA.
24 #include "KCmFontInst.h"
25 #include "KfiConstants.h"
26 #include "PrintDialog.h"
28 #include "FontPreview.h"
31 #include "DuplicatesDialog.h"
32 #include "PreviewSelectAction.h"
33 #include "FontFilter.h"
34 #include <QtGui/QGridLayout>
35 #include <QtGui/QBoxLayout>
36 #include <QtGui/QLabel>
37 #include <QtGui/QSplitter>
38 #include <QtGui/QProgressBar>
39 #include <QtCore/QCoreApplication>
40 #include <QtGui/QApplication>
41 #include <QtCore/QTextStream>
42 #include <QtGui/QComboBox>
43 #include <QtCore/QProcess>
44 #include <QtGui/QPainter>
45 #include <KDE/KAboutData>
46 #include <KDE/KToolBar>
47 #include <KDE/KFileDialog>
48 #include <KDE/KMessageBox>
49 #include <KDE/KIO/Job>
50 #include <KDE/KIO/NetAccess>
51 #include <KDE/KPushButton>
52 #include <KDE/KGuiItem>
53 #include <KDE/KInputDialog>
54 #include <KDE/KIconLoader>
55 #include <KDE/KProgressDialog>
57 #include <KDE/KTempDir>
58 #include <KDE/KTemporaryFile>
60 #include <KDE/KActionMenu>
61 #include <KDE/KToggleAction>
62 #include <KDE/KStandardDirs>
64 #include <KDE/KPluginFactory>
65 #include <KDE/KPluginLoader>
66 #include <KDE/KStandardAction>
68 #define CFG_GROUP "Main Settings"
69 #define CFG_PREVIEW_SPLITTER_SIZES "PreviewSplitterSizes"
70 #define CFG_GROUP_SPLITTER_SIZES "GroupSplitterSizes"
71 #define CFG_FONT_SIZE "FontSize"
72 #define CFG_FONT_MGT_MODE "MgtMode"
73 #define CFG_SHOW_PREVIEW "ShowPreview"
75 K_PLUGIN_FACTORY(FontInstallFactory
,
76 registerPlugin
<KFI::CKCmFontInst
>();
78 K_EXPORT_PLUGIN(FontInstallFactory("fontinst"))
83 static int constModeList
[]=
84 {CGroupListItem::ALL
, CGroupListItem::PERSONAL
, CGroupListItem::SYSTEM
, -1};
86 inline CGroupListItem::EType
modeToGrp(int mode
)
88 return (CGroupListItem::EType
)(constModeList
[mode
]);
91 static int grpToMode(CGroupListItem::EType type
)
93 for(int i
=0; i
<3; ++i
)
94 if(constModeList
[i
]==type
)
99 class CPushButton
: public KPushButton
103 CPushButton(const KGuiItem
&item
, QWidget
*parent
)
104 : KPushButton(item
, parent
)
106 theirHeight
=qMax(theirHeight
, height());
107 setSizePolicy(QSizePolicy::Minimum
, QSizePolicy::Maximum
);
110 QSize
sizeHint() const
112 QSize
sh(KPushButton::sizeHint());
114 sh
.setHeight(theirHeight
);
115 if(sh
.width()<sh
.height())
116 sh
.setWidth(sh
.height());
117 else if(text().isEmpty())
118 sh
.setWidth(theirHeight
);
124 static int theirHeight
;
127 class CToolBar
: public KToolBar
131 CToolBar(QWidget
*parent
)
134 theirHeight
=qMax(theirHeight
, height());
137 setToolButtonStyle(Qt::ToolButtonTextBesideIcon
);
138 setFont(QApplication::font());
143 addWidget(new QLabel(" ", this));
146 void link(CToolBar
*l
)
151 QSize
sizeHint() const
153 QSize
sh(KToolBar::sizeHint());
155 sh
.setHeight(theirHeight
);
159 void paintEvent(QPaintEvent
*)
161 QColor
col(palette().color(backgroundRole()));
164 QPainter(this).fillRect(rect(), col
);
167 void resizeEvent(QResizeEvent
*ev
)
169 KToolBar::resizeEvent(ev
);
170 if(height()>theirHeight
)
172 theirHeight
=height();
173 itsLinked
->resize(itsLinked
->width(), height());
180 static int theirHeight
;
183 class CProgressBar
: public QProgressBar
187 CProgressBar(QWidget
*p
, int h
) : QProgressBar(p
), itsHeight((int)(h
*0.6))
188 { setSizePolicy(QSizePolicy::Fixed
, QSizePolicy::Fixed
); }
190 virtual ~CProgressBar() { }
192 int height() const { return itsHeight
; }
193 QSize
sizeHint() const { return QSize(100, itsHeight
); }
200 int CPushButton::theirHeight
=0;
201 int CToolBar::theirHeight
=0;
203 CKCmFontInst::CKCmFontInst(QWidget
*parent
, const QVariantList
&)
204 : KCModule(FontInstallFactory::componentData(), parent
),
206 itsConfig(KFI_UI_CFG_FILE
),
209 itsUpdateDialog(NULL
),
216 KGlobal::locale()->insertCatalog(KFI_CATALOGUE
);
217 KIconLoader::global()->addAppDir(KFI_NAME
);
218 KIconLoader::global()->reconfigure(KFI_NAME
, KGlobal::dirs());
220 KAboutData
*about
= new KAboutData("fontinst", 0, ki18n("KDE Font Installer"), 0, KLocalizedString(),
221 KAboutData::License_GPL
, ki18n("GUI front-end to the fonts:/ ioslave.\n"
222 "(c) Craig Drummond, 2000 - 2007"));
223 about
->addAuthor(ki18n("Craig Drummond"), ki18n("Developer and maintainer"), "craig@kde.org");
226 KConfigGroup
cg(&itsConfig
, CFG_GROUP
);
228 itsRunner
=new CJobRunner(this);
230 itsPreviewSplitter
=new QSplitter(this);
231 itsPreviewSplitter
->setSizePolicy(QSizePolicy::MinimumExpanding
, QSizePolicy::MinimumExpanding
);
233 QWidget
*controls
=new QWidget(itsPreviewSplitter
);
235 itsGroupSplitter
=new QSplitter(controls
);
236 itsGroupSplitter
->setSizePolicy(QSizePolicy::MinimumExpanding
, QSizePolicy::MinimumExpanding
);
239 QBoxLayout
*mainLayout
=new QBoxLayout(QBoxLayout::TopToBottom
, this),
240 *controlLayout
=new QBoxLayout(QBoxLayout::TopToBottom
, controls
);
242 itsGroupsWidget
=new QWidget(itsGroupSplitter
);
243 itsFontsWidget
=new QWidget(itsGroupSplitter
);
244 itsPreviewWidget
=new QWidget(itsPreviewSplitter
);
246 CToolBar
*toolbar
=new CToolBar(this),
247 *previewToolbar
=new CToolBar(itsPreviewWidget
);
248 QGridLayout
*groupsLayout
=new QGridLayout(itsGroupsWidget
),
249 *fontsLayout
=new QGridLayout(itsFontsWidget
);
250 QBoxLayout
*previewLayout
=new QBoxLayout(QBoxLayout::TopToBottom
, itsPreviewWidget
);
252 controlLayout
->setMargin(0);
253 controlLayout
->setSpacing(KDialog::spacingHint());
254 mainLayout
->setMargin(0);
255 mainLayout
->setSpacing(KDialog::spacingHint());
256 groupsLayout
->setMargin(0);
257 groupsLayout
->setSpacing(KDialog::spacingHint());
258 fontsLayout
->setMargin(0);
259 fontsLayout
->setSpacing(KDialog::spacingHint());
262 itsPreviewControl
=new CPreviewSelectAction(itsPreviewWidget
);
263 itsZoomInAction
=KStandardAction::zoomIn(this, SLOT(zoomIn()), this);
264 itsZoomOutAction
=KStandardAction::zoomOut(this, SLOT(zoomOut()), this);
265 previewToolbar
->addAction(itsPreviewControl
);
266 previewToolbar
->addAction(itsZoomInAction
);
267 previewToolbar
->addAction(itsZoomOutAction
);
268 previewToolbar
->setToolButtonStyle(Qt::ToolButtonIconOnly
);
270 previewLayout
->setMargin(0);
271 previewLayout
->setSpacing(KDialog::spacingHint());
273 QFrame
*previewFrame
=new QFrame(itsPreviewWidget
);
274 QBoxLayout
*previewFrameLayout
=new QBoxLayout(QBoxLayout::LeftToRight
, previewFrame
);
276 previewFrameLayout
->setMargin(0);
277 previewFrameLayout
->setSpacing(0);
278 previewFrame
->setFrameShape(QFrame::StyledPanel
);
279 previewFrame
->setFrameShadow(QFrame::Sunken
);
280 previewFrame
->setSizePolicy(QSizePolicy::Minimum
, QSizePolicy::MinimumExpanding
);
282 itsPreview
=new CFontPreview(previewFrame
);
283 itsPreview
->setWhatsThis(i18n("This displays a preview of the selected font."));
284 itsPreview
->setContextMenuPolicy(Qt::CustomContextMenu
);
285 previewFrameLayout
->addWidget(itsPreview
);
287 itsPreview
->engine()->readConfig(itsConfig
);
288 CFcEngine::setTextCol(QApplication::palette().color(QPalette::Active
, QPalette::Text
));
289 connect(itsPreview
, SIGNAL(doZoomIn()), SLOT(zoomIn()));
290 connect(itsPreview
, SIGNAL(doZoomOut()), SLOT(zoomOut()));
293 KActionMenu
*settingsMenu
=new KActionMenu(KIcon("configure"), i18n("Settings"), this);
294 KAction
*changeTextAct
=new KAction(KIcon("edit-rename"), i18n("Change Preview Text..."), this),
295 *duplicateFontsAct
=new KAction(KIcon("system-search"), i18n("Scan for Duplicate Fonts..."), this);
296 //*validateFontsAct=new KAction(KIcon("checkmark"), i18n("Validate Fonts..."), this);
297 //*downloadFontsAct=new KAction(KIcon("go-down"), i18n("Download Fonts..."), this);
299 itsToolsMenu
=new KActionMenu(KIcon("system-run"), i18n("Tools"), this);
300 itsMgtMode
=new KToggleAction(KIcon("preferences-desktop-font-installer"),
301 i18n("Font Management Mode"), this),
302 itsShowPreview
=new KToggleAction(KIcon("view-preview"), i18n("Show Large Preview"), this);
303 settingsMenu
->addAction(itsMgtMode
);
304 itsMgtMode
->setChecked(true);
305 settingsMenu
->addSeparator();
306 settingsMenu
->addAction(itsShowPreview
);
307 settingsMenu
->addAction(changeTextAct
);
308 settingsMenu
->setDelayed(false);
309 itsToolsMenu
->addAction(duplicateFontsAct
);
310 //itsToolsMenu->addAction(validateFontsAct);
311 //itsToolsMenu->addAction(downloadFontsAct);
312 itsToolsMenu
->setDelayed(false);
313 toolbar
->addAction(settingsMenu
);
314 toolbar
->addAction(itsToolsMenu
);
319 itsModeControl
=new QComboBox(toolbar
);
320 itsModeAct
=toolbar
->addWidget(itsModeControl
);
321 toolbar
->addSeparator();
324 itsFilter
=new CFontFilter(toolbar
);
325 toolbar
->addWidget(itsFilter
);
327 // Details - Groups...
328 itsGroupList
=new CGroupList(itsGroupsWidget
);
329 itsGroupListView
=new CGroupListView(itsGroupsWidget
, itsGroupList
);
332 for(int i
=0; i
<3; ++i
)
333 itsModeControl
->addItem(itsGroupList
->group(modeToGrp(i
))->name());
335 KPushButton
*createGroup
=new CPushButton(KGuiItem(QString(), "list-add",
336 i18n("Create a new group")),
339 itsDeleteGroupControl
=new CPushButton(KGuiItem(QString(), "edit-delete",
340 i18n("Remove group")),
343 itsEnableGroupControl
=new CPushButton(KGuiItem(QString(), "enablefont",
344 i18n("Enable all disabled fonts in the current group")),
347 itsDisableGroupControl
=new CPushButton(KGuiItem(QString(), "disablefont",
348 i18n("Disable all enabled fonts in the current group")),
351 groupsLayout
->addWidget(itsGroupListView
, 0, 0, 1, 5);
352 groupsLayout
->addWidget(createGroup
, 1, 0);
353 groupsLayout
->addWidget(itsDeleteGroupControl
, 1, 1);
354 groupsLayout
->addWidget(itsEnableGroupControl
, 1, 2);
355 groupsLayout
->addWidget(itsDisableGroupControl
, 1, 3);
356 groupsLayout
->addItem(new QSpacerItem(itsDisableGroupControl
->width(), KDialog::spacingHint(),
357 QSizePolicy::Expanding
, QSizePolicy::Fixed
), 1, 4);
358 // Details - Fonts...
359 itsFontList
=new CFontList(itsPreview
->engine(), itsFontsWidget
);
360 itsFontListView
=new CFontListView(itsFontsWidget
, itsFontList
);
361 itsFontListView
->setSizePolicy(QSizePolicy::MinimumExpanding
, QSizePolicy::MinimumExpanding
);
362 itsFontListView
->readConfig(cg
);
364 itsAddFontControl
=new CPushButton(KGuiItem(i18n("Add..."), "list-add",
365 i18n("Install fonts")),
368 itsDeleteFontControl
=new CPushButton(KGuiItem(i18n("Delete"), "edit-delete",
369 i18n("Delete all selected fonts")),
372 itsEnableFontControl
=new CPushButton(KGuiItem(i18n("Enable"), "enablefont",
373 i18n("Enable all selected fonts")),
376 itsDisableFontControl
=new CPushButton(KGuiItem(i18n("Disable"), "disablefont",
377 i18n("Disable all selected fonts")),
380 fontsLayout
->addWidget(itsFontListView
, 0, 0, 1, 5);
381 fontsLayout
->addWidget(itsAddFontControl
, 1, 0);
382 fontsLayout
->addWidget(itsDeleteFontControl
, 1, 1);
383 fontsLayout
->addWidget(itsEnableFontControl
, 1, 2);
384 fontsLayout
->addWidget(itsDisableFontControl
, 1, 3);
385 fontsLayout
->addItem(new QSpacerItem(KDialog::spacingHint(), KDialog::spacingHint(),
386 QSizePolicy::Expanding
, QSizePolicy::Fixed
), 1, 4);
388 // Details - Status...
389 QWidget
*statusWidget
=new QWidget(this);
390 QBoxLayout
*statusLayout
=new QBoxLayout(QBoxLayout::LeftToRight
, statusWidget
);
391 itsStatusLabel
= new QLabel(statusWidget
);
392 itsStatusLabel
->setSizePolicy(QSizePolicy::MinimumExpanding
, QSizePolicy::Fixed
);
393 itsListingProgress
=new CProgressBar(statusWidget
, itsStatusLabel
->height());
394 itsListingProgress
->setRange(0, 100);
395 statusLayout
->setMargin(0);
396 statusLayout
->setSpacing(KDialog::spacingHint());
397 statusLayout
->addWidget(itsStatusLabel
);
398 statusLayout
->addItem(new QSpacerItem(0, itsListingProgress
->height()+4,
399 QSizePolicy::Fixed
, QSizePolicy::Fixed
));
400 statusLayout
->addWidget(itsListingProgress
);
403 controlLayout
->addWidget(toolbar
);
404 controlLayout
->addWidget(itsGroupSplitter
);
405 mainLayout
->addWidget(itsPreviewSplitter
);
406 mainLayout
->addWidget(statusWidget
);
407 previewLayout
->addWidget(previewToolbar
);
408 previewLayout
->addWidget(previewFrame
);
410 // Set size of widgets...
411 itsPreviewSplitter
->setChildrenCollapsible(false);
412 itsGroupSplitter
->setChildrenCollapsible(false);
413 itsGroupSplitter
->setStretchFactor(0, 0);
414 itsGroupSplitter
->setStretchFactor(1, 1);
415 itsPreviewSplitter
->setStretchFactor(0, 1);
416 itsPreviewSplitter
->setStretchFactor(1, 0);
418 toolbar
->setSizePolicy(QSizePolicy::MinimumExpanding
, QSizePolicy::Fixed
);
420 // Set sizes for 3 views...
421 QList
<int> defaultSizes
;
426 QList
<int> sizes(cg
.readEntry(CFG_PREVIEW_SPLITTER_SIZES
, defaultSizes
));
431 itsPreviewSplitter
->setSizes(sizes
);
433 defaultSizes
=QList
<int>();
436 sizes
=cg
.readEntry(CFG_GROUP_SPLITTER_SIZES
, defaultSizes
);
441 itsGroupSplitter
->setSizes(sizes
);
443 // Connect signals...
444 connect(itsFilter
, SIGNAL(textChanged(const QString
&)), itsFontListView
, SLOT(filterText(const QString
&)));
445 connect(itsFilter
, SIGNAL(criteriaChanged(int, qulonglong
)), itsFontListView
, SLOT(filterCriteria(int, qulonglong
)));
446 connect(itsGroupListView
, SIGNAL(del()), SLOT(removeGroup()));
447 connect(itsGroupListView
, SIGNAL(print()), SLOT(printGroup()));
448 connect(itsGroupListView
, SIGNAL(enable()), SLOT(enableGroup()));
449 connect(itsGroupListView
, SIGNAL(disable()), SLOT(disableGroup()));
450 connect(itsGroupListView
, SIGNAL(copyFonts()), SLOT(copyFonts()));
451 connect(itsGroupListView
, SIGNAL(moveFonts()), SLOT(moveFonts()));
452 connect(itsGroupListView
, SIGNAL(itemSelected(const QModelIndex
&)),
453 SLOT(groupSelected(const QModelIndex
&)));
454 connect(itsGroupListView
, SIGNAL(info(const QString
&)),
455 SLOT(showInfo(const QString
&)));
456 connect(itsGroupList
, SIGNAL(refresh()), SLOT(refreshFontList()));
457 connect(itsFontList
, SIGNAL(started()), SLOT(listingStarted()));
458 connect(itsFontList
, SIGNAL(finished()), SLOT(listingCompleted()));
459 connect(itsFontList
, SIGNAL(percent(int)), itsListingProgress
, SLOT(setValue(int)));
460 connect(itsFontList
, SIGNAL(status(const QString
&)), itsStatusLabel
,
461 SLOT(setText(const QString
&)));
462 connect(itsFontListView
, SIGNAL(del()), SLOT(deleteFonts()));
463 connect(itsFontListView
, SIGNAL(print()), SLOT(print()));
464 connect(itsFontListView
, SIGNAL(enable()), SLOT(enableFonts()));
465 connect(itsFontListView
, SIGNAL(disable()), SLOT(disableFonts()));
466 connect(itsFontListView
, SIGNAL(reload()), SLOT(reload()));
467 connect(itsFontListView
, SIGNAL(fontsDropped(const QSet
<KUrl
> &)),
468 SLOT(addFonts(const QSet
<KUrl
> &)));
469 connect(itsFontListView
, SIGNAL(itemSelected(const QModelIndex
&, bool, bool)),
470 SLOT(fontSelected(const QModelIndex
&, bool, bool)));
471 connect(itsFontListView
, SIGNAL(refresh()), SLOT(setStatusBar()));
472 connect(itsGroupListView
, SIGNAL(unclassifiedChanged()), itsFontListView
, SLOT(refreshFilter()));
473 connect(createGroup
, SIGNAL(clicked()), SLOT(addGroup()));
474 connect(itsDeleteGroupControl
, SIGNAL(clicked()), SLOT(removeGroup()));
475 connect(itsEnableGroupControl
, SIGNAL(clicked()), SLOT(enableGroup()));
476 connect(itsDisableGroupControl
, SIGNAL(clicked()), SLOT(disableGroup()));
477 connect(itsAddFontControl
, SIGNAL(clicked()), SLOT(addFonts()));
478 connect(itsDeleteFontControl
, SIGNAL(clicked()), SLOT(deleteFonts()));
479 connect(itsEnableFontControl
, SIGNAL(clicked()), SLOT(enableFonts()));
480 connect(itsDisableFontControl
, SIGNAL(clicked()), SLOT(disableFonts()));
481 connect(itsMgtMode
, SIGNAL(toggled(bool)), SLOT(toggleFontManagement(bool)));
482 connect(itsShowPreview
, SIGNAL(toggled(bool)), SLOT(showPreview(bool)));
483 connect(changeTextAct
, SIGNAL(triggered(bool)), SLOT(changeText()));
484 connect(itsPreviewControl
, SIGNAL(range(const QList
<CFcEngine::TRange
> &)),
485 itsPreview
, SLOT(setUnicodeRange(const QList
<CFcEngine::TRange
> &)));
486 connect(duplicateFontsAct
, SIGNAL(triggered(bool)), SLOT(duplicateFonts()));
487 //connect(validateFontsAct, SIGNAL(triggered(bool)), SLOT(validateFonts()));
488 //connect(downloadFontsAct, SIGNAL(triggered(bool)), SLOT(downloadFonts()));
490 connect(itsModeControl
, SIGNAL(activated(int)), SLOT(selectMode(int)));
492 itsMgtMode
->setChecked(cg
.readEntry(CFG_FONT_MGT_MODE
, false));
493 itsShowPreview
->setChecked(cg
.readEntry(CFG_SHOW_PREVIEW
, false));
494 showPreview(itsShowPreview
->isChecked());
495 itsPreviewWidget
->setVisible(itsShowPreview
->isChecked());
496 toggleFontManagement(itsMgtMode
->isChecked());
500 toolbar
->link(previewToolbar
);
501 previewToolbar
->link(toolbar
);
504 CKCmFontInst::~CKCmFontInst()
506 KConfigGroup
cg(&itsConfig
, CFG_GROUP
);
508 cg
.writeEntry(CFG_PREVIEW_SPLITTER_SIZES
, itsPreviewSplitter
->sizes());
509 cg
.writeEntry(CFG_GROUP_SPLITTER_SIZES
, itsGroupSplitter
->sizes());
510 cg
.writeEntry(CFG_FONT_MGT_MODE
, itsMgtMode
->isChecked());
511 cg
.writeEntry(CFG_SHOW_PREVIEW
, itsShowPreview
->isChecked());
512 itsFontListView
->writeConfig(cg
);
514 delete itsExportFile
;
517 QString
CKCmFontInst::quickHelp() const
520 ? i18n("<h1>Font Installer</h1><p> This module allows you to"
521 " install TrueType, Type1, and Bitmap"
522 " fonts.</p><p>You may also install fonts using Konqueror:"
523 " type fonts:/ into Konqueror's location bar"
524 " and this will display your installed fonts. To install a"
525 " font, simply copy one into the folder.</p>")
526 : i18n("<h1>Font Installer</h1><p> This module allows you to"
527 " install TrueType, Type1, and Bitmap"
528 " fonts.</p><p>You may also install fonts using Konqueror:"
529 " type fonts:/ into Konqueror's location bar"
530 " and this will display your installed fonts. To install a"
531 " font, simply copy it into the appropriate folder - "
532 " \"%1\" for fonts available to just yourself, or "
533 " \"%2\" for system-wide fonts (available to all).</p>",
534 i18n(KFI_KIO_FONTS_USER
), i18n(KFI_KIO_FONTS_SYS
));
537 void CKCmFontInst::fontSelected(const QModelIndex
&index
, bool en
, bool dis
)
539 itsDeleteFontControl
->setEnabled(false);
540 itsDisableFontControl
->setEnabled(en
);
541 itsEnableFontControl
->setEnabled(dis
);
545 CFontModelItem
*mi
=static_cast<CFontModelItem
*>(index
.internalPointer());
546 CFontItem
*font
=NULL
;
549 font
=static_cast<CFontItem
*>(index
.internalPointer());
551 font
=(static_cast<CFamilyItem
*>(index
.internalPointer()))->regularFont();
555 if(itsShowPreview
->isChecked())
557 KUrl
url(font
->isEnabled()
559 : font
->fileName().isEmpty()
560 ? font
->url() : KUrl::fromPath(font
->fileName()));
562 itsPreview
->showFont(url
, font
->isEnabled() ? font
->name() : QString(),
563 font
->styleInfo(), font
->isEnabled() ? 1 : font
->index());
564 itsZoomInAction
->setEnabled(!itsPreview
->engine()->atMax());
565 itsZoomOutAction
->setEnabled(!itsPreview
->engine()->atMin());
567 itsDeleteFontControl
->setEnabled(true);
572 void CKCmFontInst::reload()
578 itsGroupList
->rescan();
582 void CKCmFontInst::addFonts()
586 QString
filter("application/x-font-ttf application/x-font-otf "
587 "application/x-font-type1");
589 if(itsMgtMode
->isChecked() && FC::bitmapsEnabled())
590 filter
+=" application/x-font-pcf application/x-font-bdf";
592 filter
+=" fonts/package";
594 KUrl::List list
=KFileDialog::getOpenUrls(KUrl(), filter
, this, i18n("Add Fonts"));
599 KUrl::List::Iterator
it(list
.begin()),
604 if(KFI_KIO_FONTS_PROTOCOL
!=(*it
).protocol()) // Do not try to install from fonts:/ !!!
606 KUrl
url(KIO::NetAccess::mostLocalUrl(*it
, this));
608 if(url
.isLocalFile())
610 QString
file(url
.path());
612 if(Misc::isPackage(file
)) // If its a package we need to unzip 1st...
614 KZip
zip(url
.path());
619 if(zip
.open(QIODevice::ReadOnly
))
621 const KArchiveDirectory
*zipDir
=zip
.directory();
625 QStringList
fonts(zipDir
->entries());
629 QStringList::ConstIterator
it(fonts
.begin()),
634 const KArchiveEntry
*entry
=zipDir
->entry(*it
);
636 if(entry
&& entry
->isFile())
640 itsTempDir
=new KTempDir(KStandardDirs::locateLocal("tmp",
641 KFI_TMP_DIR_PREFIX
));
642 itsTempDir
->setAutoRemove(true);
645 ((KArchiveFile
*)entry
)->copyTo(itsTempDir
->name());
647 QString
name(entry
->name());
650 // Cant install hidden fonts, therefore need to
652 if(Misc::isHidden(name
))
654 ::rename(QFile::encodeName(itsTempDir
->name()+name
).data(),
655 QFile::encodeName(itsTempDir
->name()+name
.mid(1)).data());
659 KUrl
url(itsTempDir
->name()+name
);
661 if(!Misc::isMetrics(name
))
669 else if(!Misc::isMetrics(url
))
672 else if(!Misc::isMetrics(url
))
682 void CKCmFontInst::groupSelected(const QModelIndex
&index
)
684 CGroupListItem
*grp
=NULL
;
687 grp
=static_cast<CGroupListItem
*>(index
.internalPointer());
689 itsFontListView
->setFilterGroup(grp
);
693 // Check fonts listed within group are still valid!
694 if(grp
&& grp
->isCustom() && !grp
->validated())
696 QSet
<QString
> remList
;
697 QSet
<QString
>::Iterator
it(grp
->families().begin()),
698 end(grp
->families().end());
701 if(!itsFontList
->hasFamily(*it
))
706 itsGroupList
->removeFromGroup(grp
, *it
);
711 void CKCmFontInst::print(bool all
)
714 // In order to support printing of newly installed/enabled fonts, the actual printing
715 // is carried out by the kfontinst helper app. This way we know Qt's font list will be
717 if(!working() && (!itsPrintProc
|| QProcess::NotRunning
==itsPrintProc
->state()))
719 QString
exe(KStandardDirs::findExe(QLatin1String(KFI_PRINTER
), KStandardDirs::installPath("libexec")));
722 KMessageBox::error(this, i18n("Failed to locate font printer."));
725 QSet
<Misc::TFont
> fonts
;
727 itsFontListView
->getPrintableFonts(fonts
, !all
);
731 CPrintDialog
dlg(this);
732 KConfigGroup
cg(&itsConfig
, CFG_GROUP
);
734 if(dlg
.exec(cg
.readEntry(CFG_FONT_SIZE
, 1)))
736 static const int constSizes
[]={0, 12, 18, 24, 36, 48};
737 QSet
<Misc::TFont
>::ConstIterator
it(fonts
.begin()),
739 KTemporaryFile tmpFile
;
740 bool useFile(fonts
.count()>16),
745 itsPrintProc
=new QProcess(this);
747 itsPrintProc
->kill();
750 // If we have lots of fonts to print, pass kfontinst a tempory groups file to print
751 // instead of passing font by font...
756 QTextStream
str(&tmpFile
);
759 str
<< (*it
).family
<< endl
760 << (*it
).styleInfo
<< endl
;
762 args
<< "--embed" << QString().sprintf("0x%x", (unsigned int)window()->winId())
763 << "--caption" << KGlobal::caption().toUtf8()
764 << "--icon" << "preferences-desktop-font-installer"
765 << "--size" << QString().setNum(constSizes
[dlg
.chosenSize() < 6 ? dlg
.chosenSize() : 2])
766 << "--listfile" << tmpFile
.fileName()
771 KMessageBox::error(this, i18n("Failed to save list of fonts to print."));
777 args
<< "--embed" << QString().sprintf("0x%x", (unsigned int)window()->winId())
778 << "--caption" << KGlobal::caption().toUtf8()
779 << "--icon" << "preferences-desktop-font-installer"
780 << "--size" << QString().setNum(constSizes
[dlg
.chosenSize()<6 ? dlg
.chosenSize() : 2]);
783 args
<< "--pfont" << QString((*it
).family
.toUtf8()+','+QString().setNum((*it
).styleInfo
));
788 itsPrintProc
->start(exe
, args
);
790 if(itsPrintProc
->waitForStarted(1000))
793 tmpFile
.setAutoRemove(false);
796 KMessageBox::error(this, i18n("Failed to start font printer."));
798 cg
.writeEntry(CFG_FONT_SIZE
, dlg
.chosenSize());
802 KMessageBox::information(this, i18n("There are no printable fonts.\n"
803 "You can only print non-bitmap and enabled fonts."),
804 i18n("Cannot Print"));
809 void CKCmFontInst::deleteFonts()
813 CJobRunner::ItemList urls
;
814 QStringList fontNames
;
815 QSet
<Misc::TFont
> fonts
;
818 itsDeletedFonts
.clear();
819 itsFontListView
->getFonts(urls
, fontNames
, &fonts
, &hasSys
, true);
822 KMessageBox::information(this, i18n("You did not select anything to delete."),
823 i18n("Nothing to Delete"));
826 QSet
<Misc::TFont
>::ConstIterator
it(fonts
.begin()),
831 itsDeletedFonts
.insert((*it
).family
);
833 switch(fontNames
.count())
838 doIt
= KMessageBox::Yes
==KMessageBox::warningYesNo(this,
839 i18n("<p>Do you really want to "
840 "delete</p><p>\'<b>%1</b>\'?</p>", fontNames
.first()),
841 i18n("Delete Font"), KStandardGuiItem::del());
844 doIt
= KMessageBox::Yes
==KMessageBox::warningYesNoList(this,
845 i18np("Do you really want to delete this font?",
846 "Do you really want to delete these %1 fonts?",
848 fontNames
, i18n("Delete Fonts"), KStandardGuiItem::del());
851 if(doIt
&& (!hasSys
|| itsRunner
->getAdminPasswd(this)))
853 itsStatusLabel
->setText(i18n("Deleting font(s)..."));
854 doCmd(CJobRunner::CMD_DELETE
, urls
, KUrl());
860 void CKCmFontInst::copyFonts()
864 CJobRunner::ItemList urls
;
865 QStringList fontNames
;
866 bool fromSys(itsGroupListView
->isSystem());
868 itsDeletedFonts
.clear();
869 itsFontListView
->getFonts(urls
, fontNames
, NULL
, NULL
, true);
872 KMessageBox::information(this, i18n("You did not select anything to copy."),
873 i18n("Nothing to Copy"));
878 switch(fontNames
.count())
883 doIt
= KMessageBox::Yes
==KMessageBox::warningYesNo(this,
884 i18n("<p>Do you really want to "
885 "copy</p><p>\'<b>%1</b>\'?</p>", fontNames
.first()),
886 i18n("Copy Font"), KGuiItem(i18n("Copy")));
889 doIt
= KMessageBox::Yes
==KMessageBox::warningYesNoList(this,
890 i18np("Do you really want to copy this font?",
891 "Do you really want to copy these %1 fonts?",
893 fontNames
, i18n("Copy Fonts"), KGuiItem(i18n("Copy")));
896 if(doIt
&& (fromSys
|| itsRunner
->getAdminPasswd(this)))
898 itsStatusLabel
->setText(i18n("Copying font(s)..."));
899 doCmd(CJobRunner::CMD_COPY
, urls
, baseUrl(!fromSys
));
905 void CKCmFontInst::moveFonts()
909 CJobRunner::ItemList urls
;
910 QStringList fontNames
;
912 itsDeletedFonts
.clear();
913 itsFontListView
->getFonts(urls
, fontNames
, NULL
, NULL
, true);
916 KMessageBox::information(this, i18n("You did not select anything to move."),
917 i18n("Nothing to Move"));
922 switch(fontNames
.count())
927 doIt
= KMessageBox::Yes
==KMessageBox::warningYesNo(this,
928 i18n("<p>Do you really want to "
929 "move</p><p>\'<b>%1</b>\'?</p>", fontNames
.first()),
930 i18n("Move Font"), KGuiItem(i18n("Move")));
933 doIt
= KMessageBox::Yes
==KMessageBox::warningYesNoList(this,
934 i18np("Do you really want to move this font?",
935 "Do you really want to move these %1 fonts?",
937 fontNames
, i18n("Move Fonts"), KGuiItem(i18n("Move")));
940 if(doIt
&& itsRunner
->getAdminPasswd(this))
942 itsStatusLabel
->setText(i18n("Moving font(s)..."));
943 doCmd(CJobRunner::CMD_MOVE
, urls
, baseUrl(!itsGroupListView
->isSystem()));
949 void CKCmFontInst::enableFonts()
954 void CKCmFontInst::disableFonts()
959 void CKCmFontInst::addGroup()
962 QString
name(KInputDialog::getText(i18n("Create New Group"),
963 i18n("Please enter the name of the new group:"),
964 i18n("New Group"), &ok
, this));
966 if(ok
&& !name
.isEmpty())
967 itsGroupList
->createGroup(name
);
970 void CKCmFontInst::removeGroup()
972 if(itsGroupList
->removeGroup(itsGroupListView
->currentIndex()))
976 void CKCmFontInst::enableGroup()
981 void CKCmFontInst::disableGroup()
986 void CKCmFontInst::changeText()
991 QRegExpValidator
validator(QRegExp(".*"), 0L);
992 QString
oldStr(itsPreview
->engine()->getPreviewString()),
993 newStr(KInputDialog::getText(i18n("Preview Text"),
994 i18n("Please enter new text:"),
995 oldStr
, &status
, this, &validator
));
997 if(status
&& oldStr
!=newStr
)
999 itsPreview
->engine()->setPreviewString(newStr
);
1000 itsFontList
->forceNewPreviews();
1002 if(itsPreview
->width()>6)
1003 itsPreview
->showFont();
1008 void CKCmFontInst::showPreview(bool s
)
1010 itsPreviewWidget
->setVisible(s
);
1013 void CKCmFontInst::duplicateFonts()
1015 CDuplicatesDialog
dlg(this, itsRunner
, itsFontList
);
1016 CJobRunner::ItemList update
;
1020 if(dlg
.modifiedUser())
1021 update
.append(baseUrl(false));
1022 if(!Misc::root() && dlg
.modifiedSys())
1023 update
.append(baseUrl(true));
1026 doCmd(CJobRunner::CMD_UPDATE
, update
, KUrl());
1029 //void CKCmFontInst::validateFonts()
1033 //void CKCmFontInst::downloadFonts()
1037 void CKCmFontInst::print()
1042 void CKCmFontInst::printGroup()
1047 void CKCmFontInst::listingStarted()
1049 showInfo(i18n("Scanning font list..."));
1050 itsListingProgress
->show();
1053 void CKCmFontInst::listingCompleted()
1055 if(itsDeletedFonts
.count())
1057 QSet
<QString
>::Iterator
it(itsDeletedFonts
.begin()),
1058 end(itsDeletedFonts
.end());
1060 for(; it
!=end
; ++it
)
1061 if(!itsFontList
->hasFamily(*it
))
1062 itsGroupList
->removeFamily(*it
);
1064 itsDeletedFonts
.clear();
1067 QSet
<QString
> foundries
;
1069 itsFontList
->getFoundries(foundries
);
1070 itsFilter
->setFoundries(foundries
);
1072 itsListingProgress
->hide();
1073 itsFontListView
->selectFirstFont();
1076 void CKCmFontInst::refreshFontList()
1078 itsFontListView
->refreshFilter();
1082 void CKCmFontInst::refreshFamilies()
1084 QSet
<QString
> enabledFamilies
,
1088 itsFontList
->getFamilyStats(enabledFamilies
, disabledFamilies
, partialFamilies
);
1089 itsGroupList
->updateStatus(enabledFamilies
, disabledFamilies
, partialFamilies
);
1093 void CKCmFontInst::showInfo(const QString
&info
)
1096 if(itsLastStatusBarMsg
.isEmpty())
1100 itsStatusLabel
->setText(itsLastStatusBarMsg
);
1101 itsLastStatusBarMsg
=QString();
1105 if(itsLastStatusBarMsg
.isEmpty())
1106 itsLastStatusBarMsg
=itsStatusLabel
->text();
1107 itsStatusLabel
->setText(info
);
1111 void CKCmFontInst::setStatusBar()
1116 bool selectedEnabled
=false,
1117 selectedDisabled
=false;
1119 if(0==itsFontList
->families().count())
1120 itsStatusLabel
->setText(i18n("No fonts"));
1123 itsFontListView
->stats(enabled
, disabled
, partial
);
1124 itsFontListView
->selectedStatus(selectedEnabled
, selectedDisabled
);
1126 QString
text(i18np("1 Font", "%1 Fonts", enabled
+disabled
+partial
));
1128 if(disabled
||partial
)
1129 text
+=i18n(" (%1 Enabled, %2 Disabled, %3 Partial)", enabled
, disabled
, partial
);
1131 itsStatusLabel
->setText(text
);
1134 CGroupListItem::EType
type(itsGroupListView
->getType());
1136 bool isStd(CGroupListItem::CUSTOM
==type
);
1138 itsAddFontControl
->setEnabled(CGroupListItem::ALL
==type
||CGroupListItem::UNCLASSIFIED
==type
||
1139 CGroupListItem::PERSONAL
==type
||CGroupListItem::SYSTEM
==type
);
1140 itsDeleteGroupControl
->setEnabled(isStd
);
1141 itsEnableGroupControl
->setEnabled(disabled
||partial
);
1142 itsDisableGroupControl
->setEnabled(isStd
&& (enabled
||partial
));
1144 itsGroupListView
->controlMenu(itsDeleteGroupControl
->isEnabled(),
1145 itsEnableGroupControl
->isEnabled(),
1146 itsDisableGroupControl
->isEnabled(), enabled
||partial
);
1148 itsEnableFontControl
->setEnabled(selectedDisabled
);
1149 itsDisableFontControl
->setEnabled(selectedEnabled
);
1150 itsDeleteFontControl
->setEnabled(selectedEnabled
||selectedDisabled
);
1153 void CKCmFontInst::addFonts(const QSet
<KUrl
> &src
)
1155 if(!working() && src
.count() && !itsGroupListView
->isCustom())
1163 switch(getCurrentGroupType())
1165 case CGroupListItem::ALL
:
1166 case CGroupListItem::UNCLASSIFIED
:
1167 switch(KMessageBox::questionYesNoCancel(this,
1168 i18n("Do you wish to install the font(s) for personal use "
1169 "(only available to you), or "
1170 "system-wide (available to all users)?"),
1171 i18n("Where to Install"), KGuiItem(i18n(KFI_KIO_FONTS_USER
)),
1172 KGuiItem(i18n(KFI_KIO_FONTS_SYS
))))
1174 case KMessageBox::Yes
:
1175 dest
=baseUrl(false);
1177 case KMessageBox::No
:
1178 if(itsRunner
->getAdminPasswd(this))
1180 else if(KMessageBox::Yes
==KMessageBox::questionYesNo(this,
1181 i18n("Would you like to install the font(s) for personal use?"),
1182 i18n("Authorization Failed")))
1183 dest
=baseUrl(false);
1188 case KMessageBox::Cancel
:
1192 case CGroupListItem::PERSONAL
:
1193 dest
=baseUrl(false);
1195 case CGroupListItem::SYSTEM
:
1196 if(itsRunner
->getAdminPasswd(this))
1198 else if(KMessageBox::Yes
==KMessageBox::questionYesNo(this,
1199 i18n("Would you like to install the font(s) for personal use?"),
1200 i18n("Authorization Failed")))
1201 dest
=baseUrl(false);
1211 QSet
<KUrl
>::ConstIterator it
,
1215 // Check if font has any associated AFM or PFM file...
1216 itsStatusLabel
->setText(i18n("Looking for any associated files..."));
1220 itsProgress
=new KProgressDialog(this, i18n("Scanning Files..."),
1221 i18n("Looking for additional files to install..."));
1222 itsProgress
->setModal(true);
1223 itsProgress
->setAutoReset(true);
1224 itsProgress
->setAutoClose(true);
1227 itsProgress
->setAllowCancel(false);
1228 itsProgress
->setMinimumDuration(500);
1229 itsProgress
->progressBar()->show();
1230 itsProgress
->progressBar()->setRange(0, src
.size());
1231 itsProgress
->progressBar()->setValue(0);
1233 int steps
=src
.count()<200 ? 1 : src
.count()/10;
1234 for(it
=src
.begin(); it
!=end
; ++it
)
1236 KUrl::List associatedUrls
;
1238 itsProgress
->setLabelText(i18n("Looking for files associated with %1", (*it
).prettyUrl()));
1239 itsProgress
->progressBar()->setValue(itsProgress
->progressBar()->value()+1);
1240 if(1==steps
|| 0==(itsProgress
->progressBar()->value()%steps
))
1242 bool dialogVisible(itsProgress
->isVisible());
1243 QCoreApplication::processEvents(QEventLoop::ExcludeUserInputEvents
);
1244 if(dialogVisible
&& !itsProgress
->isVisible()) // User closed dialog! re-open!!!
1245 itsProgress
->show();
1248 CJobRunner::getAssociatedUrls(*it
, associatedUrls
, false, this);
1251 KUrl::List::Iterator
aIt(associatedUrls
.begin()),
1252 aEnd(associatedUrls
.end());
1254 for(; aIt
!=aEnd
; ++aIt
)
1257 itsProgress
->close();
1259 CJobRunner::ItemList installUrls
;
1262 for(it
=copy
.begin(); it
!=end
; ++it
)
1263 installUrls
.append(*it
);
1265 itsStatusLabel
->setText(i18n("Installing font(s)..."));
1266 doCmd(CJobRunner::CMD_INSTALL
, installUrls
, dest
);
1270 void CKCmFontInst::toggleFontManagement(bool on
)
1273 itsMgtMode
->setChecked(!on
);
1277 itsPreviewControl
->setStd();
1278 itsPreviewControl
->setMode(on
? CPreviewSelectAction::ScriptsOnly
: CPreviewSelectAction::Basic
);
1279 itsToolsMenu
->setVisible(on
);
1280 itsFontListView
->setMgtMode(on
);
1281 itsFilter
->setMgtMode(on
);
1284 itsModeAct
->setVisible(!on
);
1285 // The setEnabled() should not be required, as the widget is hidden. But, when the kcm switches
1286 // out of management mode, and re-shows the mode combo, the combo for some reason is disabled.
1287 // Calling setEnabled() here fixes this.
1288 itsModeAct
->setEnabled(!on
);
1290 itsEnableFontControl
->setVisible(on
);
1291 itsDisableFontControl
->setVisible(on
);
1293 itsGroupsWidget
->setVisible(on
);
1298 void CKCmFontInst::selectMode(int mode
)
1300 selectGroup(modeToGrp(mode
));
1303 void CKCmFontInst::zoomIn()
1305 itsPreview
->zoomIn();
1306 itsZoomInAction
->setEnabled(!itsPreview
->engine()->atMax());
1307 itsZoomOutAction
->setEnabled(!itsPreview
->engine()->atMin());
1310 void CKCmFontInst::zoomOut()
1312 itsPreview
->zoomOut();
1313 itsZoomInAction
->setEnabled(!itsPreview
->engine()->atMax());
1314 itsZoomOutAction
->setEnabled(!itsPreview
->engine()->atMin());
1317 void CKCmFontInst::selectGroup(CGroupListItem::EType grp
)
1319 QModelIndex
current(itsGroupListView
->currentIndex());
1321 if(current
.isValid())
1323 CGroupListItem
*grpItem
=static_cast<CGroupListItem
*>(current
.internalPointer());
1325 if(grpItem
&& grp
==grpItem
->type())
1328 itsGroupListView
->selectionModel()->select(current
,
1329 QItemSelectionModel::Deselect
);
1332 QModelIndex
idx(itsGroupList
->index(grp
));
1334 itsGroupListView
->selectionModel()->select(idx
, QItemSelectionModel::Select
);
1335 itsGroupListView
->setCurrentIndex(idx
);
1337 itsFontListView
->refreshFilter();
1341 void CKCmFontInst::toggleGroup(bool enable
)
1343 QModelIndex
idx(itsGroupListView
->currentIndex());
1347 CGroupListItem
*grp
=static_cast<CGroupListItem
*>(idx
.internalPointer());
1350 toggleFonts(enable
, grp
->name());
1354 void CKCmFontInst::toggleFonts(bool enable
, const QString
&grp
)
1358 CJobRunner::ItemList urls
;
1362 itsFontListView
->getFonts(urls
, fonts
, NULL
, &hasSys
, grp
.isEmpty(), !enable
, enable
);
1365 KMessageBox::information(this,
1366 enable
? i18n("You did not select anything to enable.")
1367 : i18n("You did not select anything to disable."),
1368 enable
? i18n("Nothing to Enable") : i18n("Nothing to Disable"));
1370 toggleFonts(urls
, fonts
, enable
, grp
, hasSys
);
1374 void CKCmFontInst::toggleFonts(CJobRunner::ItemList
&urls
, const QStringList
&fonts
, bool enable
,
1375 const QString
&grp
, bool hasSys
)
1379 switch(fonts
.count())
1384 doIt
= KMessageBox::Yes
==KMessageBox::warningYesNo(this,
1386 ? enable
? i18n("<p>Do you really want to "
1387 "enable</p><p>\'<b>%1</b>\'?</p>", fonts
.first())
1388 : i18n("<p>Do you really want to "
1389 "disable</p><p>\'<b>%1</b>\'?</p>", fonts
.first())
1390 : enable
? i18n("<p>Do you really want to "
1391 "enable</p><p>\'<b>%1</b>\', "
1392 "contained within group \'<b>%2</b>\'?</p>",
1394 : i18n("<p>Do you really want to "
1395 "disable</p><p>\'<b>%1</b>\', "
1396 "contained within group \'<b>%2</b>\'?</p>",
1397 fonts
.first(), grp
),
1398 enable
? i18n("Enable Font") : i18n("Disable Font"),
1399 enable
? KGuiItem(i18n("Enable"), "enablefont", i18n("Enable Font"))
1400 : KGuiItem(i18n("Disable"), "disablefont", i18n("Disable Font")));
1403 doIt
= KMessageBox::Yes
==KMessageBox::warningYesNoList(this,
1405 ? enable
? i18np("Do you really want to enable this font?",
1406 "Do you really want to enable these %1 fonts?",
1408 : i18np("Do you really want to disable this font?",
1409 "Do you really want to disable these %1 fonts?",
1411 : enable
? i18np("<p>Do you really want to enable this font "
1412 "contained within group \'<b>%2</b>\'?</p>",
1413 "<p>Do you really want to enable these %1 fonts "
1414 "contained within group \'<b>%2</b>\'?</p>",
1416 : i18np("<p>Do you really want to disable this font "
1417 "contained within group \'<b>%2</b>\'?</p>",
1418 "<p>Do you really want to disable these %1 fonts "
1419 "contained within group \'<b>%2</b>\'?</p>",
1422 enable
? i18n("Enable Fonts") : i18n("Disable Fonts"),
1423 enable
? KGuiItem(i18n("Enable"), "enablefont", i18n("Enable Fonts"))
1424 : KGuiItem(i18n("Disable"), "disablefont", i18n("Disable Fonts")));
1427 if(doIt
&& (!hasSys
|| itsRunner
->getAdminPasswd(this)))
1430 itsStatusLabel
->setText(i18n("Enabling font(s)..."));
1432 itsStatusLabel
->setText(i18n("Disabling font(s)..."));
1434 doCmd(enable
? CJobRunner::CMD_ENABLE
: CJobRunner::CMD_DISABLE
, urls
, KUrl());
1438 bool CKCmFontInst::working(bool displayMsg
)
1441 if(NULL
!=itsJob
|| itsFontList
->active())
1444 KMessageBox::error(this, i18n("The installer is currently busy. Please wait for the "
1445 "current operation to terminate."));
1452 KUrl
CKCmFontInst::baseUrl(bool sys
)
1455 ? KUrl(KFI_KIO_FONTS_PROTOCOL
":/")
1457 ? KUrl(KFI_KIO_FONTS_PROTOCOL
":/"KFI_KIO_FONTS_SYS
"/")
1458 : KUrl(KFI_KIO_FONTS_PROTOCOL
":/"KFI_KIO_FONTS_USER
"/");
1461 void CKCmFontInst::selectMainGroup()
1463 selectGroup(/*Misc::root() || itsMgtMode->isChecked()
1464 ? */CGroupListItem::ALL
/* : CGroupListItem::PERSONAL*/);
1466 itsModeControl
->setCurrentIndex(grpToMode(/*Misc::root()
1467 ? */CGroupListItem::ALL
1468 /*: CGroupListItem::PERSONAL*/));
1471 void CKCmFontInst::doCmd(CJobRunner::ECommand cmd
, const CJobRunner::ItemList
&urls
, const KUrl
&dest
)
1473 itsFontList
->setAutoUpdate(false);
1474 itsRunner
->exec(cmd
, urls
, dest
);
1475 CFcEngine::setDirty();
1477 itsFontList
->scan();
1478 itsFontList
->setAutoUpdate(true);
1483 CGroupListItem::EType
CKCmFontInst::getCurrentGroupType()
1485 if(itsMgtMode
->isChecked())
1486 return itsGroupListView
->getType();
1487 else if(itsModeControl
&& itsModeControl
->currentIndex() >= 0)
1488 return modeToGrp(itsModeControl
->currentIndex());
1490 return CGroupListItem::ALL
;
1495 #include "KCmFontInst.moc"