summaryrefslogtreecommitdiffstats
path: root/kcontrol/kfontinst/kcmfontinst
diff options
context:
space:
mode:
authortoma <toma@283d02a7-25f6-0310-bc7c-ecb5cbfe19da>2009-11-25 17:56:58 +0000
committertoma <toma@283d02a7-25f6-0310-bc7c-ecb5cbfe19da>2009-11-25 17:56:58 +0000
commit4aed2c8219774f5d797760606b8489a92ddc5163 (patch)
tree3f8c130f7d269626bf6a9447407ef6c35954426a /kcontrol/kfontinst/kcmfontinst
downloadtdebase-4aed2c8219774f5d797760606b8489a92ddc5163.tar.gz
tdebase-4aed2c8219774f5d797760606b8489a92ddc5163.zip
Copy the KDE 3.5 branch to branches/trinity for new KDE 3.5 features.
BUG:215923 git-svn-id: svn://anonsvn.kde.org/home/kde/branches/trinity/kdebase@1054174 283d02a7-25f6-0310-bc7c-ecb5cbfe19da
Diffstat (limited to 'kcontrol/kfontinst/kcmfontinst')
-rw-r--r--kcontrol/kfontinst/kcmfontinst/KCmFontInst.cpp647
-rw-r--r--kcontrol/kfontinst/kcmfontinst/KCmFontInst.h116
-rw-r--r--kcontrol/kfontinst/kcmfontinst/KFileFontIconView.cpp88
-rw-r--r--kcontrol/kfontinst/kcmfontinst/KFileFontIconView.h55
-rw-r--r--kcontrol/kfontinst/kcmfontinst/KFileFontView.cpp645
-rw-r--r--kcontrol/kfontinst/kcmfontinst/KFileFontView.h219
-rw-r--r--kcontrol/kfontinst/kcmfontinst/Makefile.am31
-rw-r--r--kcontrol/kfontinst/kcmfontinst/PrintDialog.cpp74
-rw-r--r--kcontrol/kfontinst/kcmfontinst/PrintDialog.h56
-rw-r--r--kcontrol/kfontinst/kcmfontinst/SettingsDialog.cpp99
-rw-r--r--kcontrol/kfontinst/kcmfontinst/SettingsDialog.h57
-rw-r--r--kcontrol/kfontinst/kcmfontinst/cr16-action-newfont.pngbin0 -> 613 bytes
-rw-r--r--kcontrol/kfontinst/kcmfontinst/cr22-action-newfont.pngbin0 -> 951 bytes
-rw-r--r--kcontrol/kfontinst/kcmfontinst/cr32-action-newfont.pngbin0 -> 1821 bytes
-rw-r--r--kcontrol/kfontinst/kcmfontinst/kcmfontinst.desktop235
15 files changed, 2322 insertions, 0 deletions
diff --git a/kcontrol/kfontinst/kcmfontinst/KCmFontInst.cpp b/kcontrol/kfontinst/kcmfontinst/KCmFontInst.cpp
new file mode 100644
index 000000000..4a6b0b3ee
--- /dev/null
+++ b/kcontrol/kfontinst/kcmfontinst/KCmFontInst.cpp
@@ -0,0 +1,647 @@
+////////////////////////////////////////////////////////////////////////////////
+//
+// Class Name : KFI::CKCmFontInst
+// Author : Craig Drummond
+// Project : K Font Installer
+// Creation Date : 26/04/2003
+// Version : $Revision$ $Date$
+//
+////////////////////////////////////////////////////////////////////////////////
+//
+// This program is free software; you can redistribute it and/or
+// modify it under the terms of the GNU General Public License
+// as published by the Free Software Foundation; either version 2
+// of the License, or (at your option) any later version.
+//
+// This program is distributed in the hope that it will be useful,
+// but WITHOUT ANY WARRANTY; without even the implied warranty of
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+// GNU General Public License for more details.
+//
+// You should have received a copy of the GNU General Public License
+// along with this program; if not, write to the Free Software
+// Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
+//
+////////////////////////////////////////////////////////////////////////////////
+// (C) Craig Drummond, 2003, 2004
+////////////////////////////////////////////////////////////////////////////////
+
+#include "KCmFontInst.h"
+#include "KfiConstants.h"
+#include "PrintDialog.h"
+#include "SettingsDialog.h"
+#ifdef HAVE_XFT
+#include "KfiPrint.h"
+#include "FcEngine.h"
+#endif
+#include <qlayout.h>
+#include <qlabel.h>
+#include <qpainter.h>
+#include <qpaintdevicemetrics.h>
+#include <qsettings.h>
+#include <kaboutdata.h>
+#include <kgenericfactory.h>
+#include <kdiroperator.h>
+#include <kprinter.h>
+#include "Misc.h"
+#include "KFileFontIconView.h"
+#include "KFileFontView.h"
+#include <kpopupmenu.h>
+#include <ktoolbar.h>
+#include <ktoolbarbutton.h>
+#include <kstdaccel.h>
+#include <kfiledialog.h>
+#include <kmessagebox.h>
+#include <kcmdlineargs.h>
+#include <kapplication.h>
+#include <kio/job.h>
+#include <kio/netaccess.h>
+#include <kdirlister.h>
+#include <kpushbutton.h>
+#include <kguiitem.h>
+#include <qsplitter.h>
+
+#define CFG_GROUP "Main Settings"
+#define CFG_LISTVIEW "ListView"
+#define CFG_PATH "Path"
+#define CFG_SPLITTER_SIZES "SplitterSizes"
+#define CFG_SHOW_BITMAP "ShowBitmap"
+#define CFG_FONT_SIZE "FontSize"
+
+typedef KGenericFactory<KFI::CKCmFontInst, QWidget> FontInstallFactory;
+K_EXPORT_COMPONENT_FACTORY(kcm_fontinst, FontInstallFactory("kcmfontinst"))
+
+namespace KFI
+{
+
+CKCmFontInst::CKCmFontInst(QWidget *parent, const char *, const QStringList&)
+ : KCModule(parent, "kfontinst"),
+#ifdef HAVE_XFT
+ itsPreview(NULL),
+#endif
+ itsConfig(KFI_UI_CFG_FILE)
+{
+ KGlobal::locale()->insertCatalogue(KFI_CATALOGUE);
+
+ KAboutData* about = new KAboutData("kcmfontinst",
+ I18N_NOOP("KDE Font Installer"),
+ 0, 0,
+ KAboutData::License_GPL,
+ I18N_NOOP("GUI front end to the fonts:/ ioslave.\n"
+ "(c) Craig Drummond, 2000 - 2004"));
+ about->addAuthor("Craig Drummond", I18N_NOOP("Developer and maintainer"), "craig@kde.org");
+ setAboutData(about);
+
+ const char *appName=KCmdLineArgs::appName();
+
+ itsEmbeddedAdmin=Misc::root() && (NULL==appName || strcmp("kcontrol", appName) &&
+ KCmdLineArgs::parsedArgs()->isSet("embed"));
+
+ itsStatusLabel = new QLabel(this);
+ itsStatusLabel->setFrameShape(QFrame::Panel);
+ itsStatusLabel->setFrameShadow(QFrame::Sunken);
+ itsStatusLabel->setLineWidth(1);
+
+ itsConfig.setGroup(CFG_GROUP);
+
+ QFrame *fontsFrame;
+#ifdef HAVE_XFT
+ KLibFactory *factory=KLibLoader::self()->factory("libkfontviewpart");
+
+ if(factory)
+ {
+ itsSplitter=new QSplitter(this);
+ fontsFrame=new QFrame(itsSplitter),
+ itsPreview=(KParts::ReadOnlyPart *)factory->create(itsSplitter, "kcmfontinst", "KParts::ReadOnlyPart");
+ itsSplitter->setSizePolicy(QSizePolicy::MinimumExpanding, QSizePolicy::MinimumExpanding);
+
+ QValueList<int> sizes(itsConfig.readIntListEntry(CFG_SPLITTER_SIZES));
+
+ if(2!=sizes.count())
+ {
+ sizes.clear();
+ sizes+=250;
+ sizes+=150;
+ }
+ itsSplitter->setSizes(sizes);
+ }
+ else
+ {
+#endif
+ fontsFrame=new QFrame(this);
+ fontsFrame->setSizePolicy(QSizePolicy::MinimumExpanding, QSizePolicy::MinimumExpanding);
+#ifdef HAVE_XFT
+ }
+#endif
+
+ QGridLayout *fontsLayout=new QGridLayout(fontsFrame, 1, 1, 0, 1);
+ QVBoxLayout *layout=new QVBoxLayout(this, 0, KDialog::spacingHint());
+ KToolBar *toolbar=new KToolBar(this);
+ bool showBitmap(itsConfig.readBoolEntry(CFG_SHOW_BITMAP, false));
+
+ fontsFrame->setLineWidth(0);
+ toolbar->setSizePolicy(QSizePolicy::MinimumExpanding, QSizePolicy::Minimum);
+ toolbar->setMovingEnabled(false);
+
+ QString previousPath=itsConfig.readEntry(CFG_PATH);
+
+ itsDirOp = new KDirOperator(Misc::root() ? QString("fonts:/") : QString("fonts:/")+i18n(KFI_KIO_FONTS_USER),
+ fontsFrame);
+ itsDirOp->setViewConfig(&itsConfig, "ListView Settings");
+ itsDirOp->setMinimumSize(QSize(96, 64));
+ setMimeTypes(showBitmap);
+ itsDirOp->dirLister()->setMainWindow(this);
+ itsDirOp->setSizePolicy(QSizePolicy::MinimumExpanding, QSizePolicy::MinimumExpanding);
+ fontsLayout->addMultiCellWidget(itsDirOp, 0, 0, 0, 1);
+
+ KPushButton *button=new KPushButton(KGuiItem(i18n("Add Fonts..."), "newfont"), fontsFrame);
+ connect(button, SIGNAL(clicked()), SLOT(addFonts()));
+ button->setSizePolicy(QSizePolicy::Minimum, QSizePolicy::Minimum);
+ fontsLayout->addWidget(button, 1, 0);
+ fontsLayout->addItem(new QSpacerItem(4, 4, QSizePolicy::Expanding, QSizePolicy::Minimum));
+
+ layout->addWidget(toolbar);
+#ifdef HAVE_XFT
+ layout->addWidget(itsPreview ? itsSplitter : fontsFrame);
+#else
+ layout->addWidget(fontsFrame);
+#endif
+ layout->addWidget(itsStatusLabel);
+
+ setButtons(0);
+ setRootOnlyMsg(i18n("<b>The fonts shown are your personal fonts.</b><br>To see (and install) "
+ "system-wide fonts, click on the \"Administrator Mode\" button below."));
+ setUseRootOnlyMsg(true);
+ itsDirOp->setMode(KFile::Files);
+
+ //
+ // Now for the hack!
+ KAction *act;
+ KActionMenu *topMnu=dynamic_cast<KActionMenu *>(itsDirOp->actionCollection()->action("popupMenu"));
+
+ itsViewMenuAct=dynamic_cast<KActionMenu *>(itsDirOp->actionCollection()->action("view menu"));
+ topMnu->popupMenu()->clear();
+ connect(topMnu->popupMenu(), SIGNAL(aboutToShow()), SLOT(setupMenu()));
+ if((act=itsDirOp->actionCollection()->action("up")))
+ act->disconnect(SIGNAL(activated()), itsDirOp, SLOT(cdUp()));
+ if((act=itsDirOp->actionCollection()->action("home")))
+ act->disconnect(SIGNAL(activated()), itsDirOp, SLOT(home()));
+ if((act=itsDirOp->actionCollection()->action("back")))
+ act->disconnect(SIGNAL(activated()), itsDirOp, SLOT(back()));
+ if((act=itsDirOp->actionCollection()->action("forward")))
+ act->disconnect(SIGNAL(activated()), itsDirOp, SLOT(forward()));
+
+ if((act=itsDirOp->actionCollection()->action("reload")))
+ act->plug(toolbar);
+
+ topMnu->insert(itsViewMenuAct);
+
+ if((itsIconAct=dynamic_cast<KRadioAction *>(itsDirOp->actionCollection()->action("short view"))))
+ {
+ disconnect(itsIconAct, SIGNAL(activated()), itsDirOp, SLOT(slotSimpleView()));
+ connect(itsIconAct, SIGNAL(activated()), SLOT(iconView()));
+ itsIconAct->plug(toolbar);
+ }
+
+ if((itsListAct=dynamic_cast<KRadioAction *>(itsDirOp->actionCollection()->action("detailed view"))))
+ {
+ disconnect(itsListAct, SIGNAL(activated()), itsDirOp, SLOT(slotDetailedView()));
+ connect(itsListAct, SIGNAL(activated()), SLOT(listView()));
+ itsListAct->plug(toolbar);
+ }
+
+ itsShowBitmapAct=new KToggleAction(i18n("Show Bitmap Fonts"), "font_bitmap", 0, this, SLOT(filterFonts()),
+ itsDirOp->actionCollection(), "showbitmap");
+ itsShowBitmapAct->setChecked(showBitmap);
+ itsShowBitmapAct->plug(toolbar);
+
+ toolbar->insertLineSeparator();
+
+ act=new KAction(i18n("Add Fonts..."), "newfont", 0, this, SLOT(addFonts()), itsDirOp->actionCollection(), "addfonts");
+ act->plug(toolbar);
+ topMnu->insert(act);
+
+ if((itsDeleteAct=itsDirOp->actionCollection()->action("delete")))
+ {
+ itsDeleteAct->plug(toolbar);
+ itsDeleteAct->setEnabled(false);
+ topMnu->insert(itsDeleteAct);
+ disconnect(itsDeleteAct, SIGNAL(activated()), itsDirOp, SLOT(deleteSelected()));
+ connect(itsDeleteAct, SIGNAL(activated()), this, SLOT(removeFonts()));
+ }
+
+ toolbar->insertLineSeparator();
+ act=new KAction(i18n("Configure..."), "configure", 0, this, SLOT(configure()), itsDirOp->actionCollection(), "configure");
+ act->plug(toolbar);
+#ifdef HAVE_XFT
+ toolbar->insertLineSeparator();
+ act=new KAction(i18n("Print..."), "fileprint", 0, this, SLOT(print()), itsDirOp->actionCollection(), "print");
+ act->plug(toolbar);
+#endif
+
+ if( (itsSepDirsAct=itsDirOp->actionCollection()->action("separate dirs")) &&
+ (itsShowHiddenAct=itsDirOp->actionCollection()->action("show hidden")))
+ {
+ //disconnect(itsViewMenuAct->popupMenu(), SIGNAL(aboutToShow()), itsDirOp, SLOT(insertViewDependentActions()));
+ connect(itsViewMenuAct->popupMenu(), SIGNAL(aboutToShow()), SLOT(setupViewMenu()));
+ setupViewMenu();
+ }
+
+#ifdef HAVE_XFT
+ if(itsPreview)
+ {
+ KActionCollection *previewCol=itsPreview->actionCollection();
+
+ if(previewCol && previewCol->count()>0 && (act=previewCol->action("changeText")))
+ act->plug(toolbar);
+ }
+#endif
+
+ //
+ // Set view...
+ if(itsConfig.readBoolEntry(CFG_LISTVIEW, true))
+ listView();
+ else
+ iconView();
+
+ itsDirOp->dirLister()->setShowingDotFiles(true);
+
+ connect(itsDirOp, SIGNAL(fileHighlighted(const KFileItem *)), SLOT(fileHighlighted(const KFileItem *)));
+ connect(itsDirOp, SIGNAL(finishedLoading()), SLOT(loadingFinished()));
+ connect(itsDirOp, SIGNAL(dropped(const KFileItem *, QDropEvent *, const KURL::List &)),
+ SLOT(dropped(const KFileItem *, QDropEvent *, const KURL::List &)));
+ connect(itsDirOp->dirLister(), SIGNAL(infoMessage(const QString &)), SLOT(infoMessage(const QString &)));
+ connect(itsDirOp, SIGNAL(updateInformation(int, int)), SLOT(updateInformation(int, int)));
+}
+
+CKCmFontInst::~CKCmFontInst()
+{
+#ifdef HAVE_XFT
+ if(itsPreview)
+ {
+ itsConfig.setGroup(CFG_GROUP);
+ itsConfig.writeEntry(CFG_SPLITTER_SIZES, itsSplitter->sizes());
+ }
+#endif
+ delete itsDirOp;
+}
+
+void CKCmFontInst::setMimeTypes(bool showBitmap)
+{
+ QStringList mimeTypes;
+
+ mimeTypes << "application/x-font-ttf"
+ << "application/x-font-otf"
+ << "application/x-font-ttc"
+ << "application/x-font-type1";
+ if(showBitmap)
+ mimeTypes << "application/x-font-pcf"
+ << "application/x-font-bdf";
+
+ itsDirOp->setMimeFilter(mimeTypes);
+}
+
+void CKCmFontInst::filterFonts()
+{
+ setMimeTypes(itsShowBitmapAct->isChecked());
+ itsDirOp->rereadDir();
+ itsConfig.setGroup(CFG_GROUP);
+ itsConfig.writeEntry(CFG_SHOW_BITMAP, itsShowBitmapAct->isChecked());
+ if(itsEmbeddedAdmin)
+ itsConfig.sync();
+}
+
+QString CKCmFontInst::quickHelp() const
+{
+ return Misc::root()
+ ? i18n("<h1>Font Installer</h1><p> This module allows you to"
+ //" install TrueType, Type1, Speedo, and Bitmap"
+ " install TrueType, Type1, and Bitmap"
+ " fonts.</p><p>You may also install fonts using Konqueror:"
+ " type fonts:/ into Konqueror's location bar"
+ " and this will display your installed fonts. To install a"
+ " font, simply copy one into the folder.</p>")
+ : i18n("<h1>Font Installer</h1><p> This module allows you to"
+ //" install TrueType, Type1, Speedo, and Bitmap"
+ " install TrueType, Type1, and Bitmap"
+ " fonts.</p><p>You may also install fonts using Konqueror:"
+ " type fonts:/ into Konqueror's location bar"
+ " and this will display your installed fonts. To install a"
+ " font, simply copy it into the appropriate folder - "
+ " \"Personal\" for fonts available to just yourself, or "
+ " \"System\" for system-wide fonts (available to all).</p>"
+ "<p><b>NOTE:</b> As you are not logged in as \"root\", any"
+ " fonts installed will only be available to you. To install"
+ " fonts system-wide, use the \"Administrator Mode\""
+ " button to run this module as \"root\".</p>");
+}
+
+void CKCmFontInst::listView()
+{
+ CKFileFontView *newView=new CKFileFontView(itsDirOp, "detailed view");
+
+ itsDirOp->setView(newView);
+ itsListAct->setChecked(true);
+ itsConfig.setGroup(CFG_GROUP);
+ itsConfig.writeEntry(CFG_LISTVIEW, true);
+ if(itsEmbeddedAdmin)
+ itsConfig.sync();
+ itsDirOp->setAcceptDrops(true);
+}
+
+void CKCmFontInst::iconView()
+{
+ CKFileFontIconView *newView=new CKFileFontIconView(itsDirOp, "simple view");
+
+ itsDirOp->setView(newView);
+ itsIconAct->setChecked(true);
+ itsConfig.setGroup(CFG_GROUP);
+ itsConfig.writeEntry(CFG_LISTVIEW, false);
+ if(itsEmbeddedAdmin)
+ itsConfig.sync();
+ itsDirOp->setAcceptDrops(true);
+}
+
+void CKCmFontInst::setupMenu()
+{
+ itsDirOp->setupMenu(KDirOperator::SortActions|/*KDirOperator::FileActions|*/KDirOperator::ViewActions);
+}
+
+void CKCmFontInst::setupViewMenu()
+{
+ itsViewMenuAct->remove(itsSepDirsAct);
+ itsViewMenuAct->remove(itsShowHiddenAct);
+}
+
+void CKCmFontInst::fileHighlighted(const KFileItem *item)
+{
+ const KFileItemList *list=itsDirOp->selectedItems();
+
+ itsDeleteAct->setEnabled(list && list->count());
+
+#ifdef HAVE_XFT
+ if(itsPreview)
+ {
+ //
+ // Generate preview...
+ const KFileItem *previewItem=item
+ ? item
+ : list && 1==list->count()
+ ? list->getFirst()
+ : NULL;
+
+ if(previewItem && list && list->contains(previewItem)) // OK, check its been selected - not deselected!!!
+ itsPreview->openURL(previewItem->url());
+ }
+#endif
+}
+
+void CKCmFontInst::loadingFinished()
+{
+ QListView *lView=dynamic_cast<QListView *>(itsDirOp->view());
+
+ if(lView)
+ lView->sort();
+ else
+ {
+ QIconView *iView=dynamic_cast<QIconView *>(itsDirOp->view());
+
+ if(iView)
+ iView->sort();
+ }
+ fileHighlighted(NULL);
+}
+
+void CKCmFontInst::addFonts()
+{
+ KURL::List list=KFileDialog::getOpenURLs(QString::null, "application/x-font-ttf application/x-font-otf "
+ "application/x-font-ttc application/x-font-type1 "
+ "application/x-font-pcf application/x-font-bdf",
+ //"application/x-font-snf application/x-font-speedo",
+ this, i18n("Add Fonts"));
+
+ if(list.count())
+ addFonts(list, itsDirOp->url());
+}
+
+void CKCmFontInst::removeFonts()
+{
+ if(itsDirOp->selectedItems()->isEmpty())
+ KMessageBox::information(this, i18n("You did not select anything to delete."), i18n("Nothing to Delete"));
+ else
+ {
+ KURL::List urls;
+ QStringList files;
+ KFileItemListIterator it(*(itsDirOp->selectedItems()));
+
+ for(; it.current(); ++it)
+ {
+ KURL url((*it)->url());
+
+ url.setQuery(KFI_KIO_NO_CLEAR);
+ files.append((*it)->text());
+ urls.append(url);
+ }
+
+ bool doIt=false;
+
+ switch(files.count())
+ {
+ case 0:
+ break;
+ case 1:
+ doIt = KMessageBox::Continue==KMessageBox::warningContinueCancel(this,
+ i18n("<qt>Do you really want to delete\n <b>'%1'</b>?</qt>").arg(files.first()),
+ i18n("Delete Font"), KStdGuiItem::del());
+ break;
+ default:
+ doIt = KMessageBox::Continue==KMessageBox::warningContinueCancelList(this,
+ i18n("Do you really want to delete this font?", "Do you really want to delete these %n fonts?",
+ files.count()),
+ files, i18n("Delete Fonts"), KStdGuiItem::del());
+ }
+
+ if(doIt)
+ {
+ KIO::DeleteJob *job = KIO::del(urls, false, true);
+ connect(job, SIGNAL(result(KIO::Job *)), this, SLOT(delResult(KIO::Job *)));
+ job->setWindow(this);
+ job->setAutoErrorHandlingEnabled(true, this);
+ }
+ }
+}
+
+void CKCmFontInst::configure()
+{
+ CSettingsDialog(this).exec();
+}
+
+void CKCmFontInst::print()
+{
+#ifdef HAVE_XFT
+ KFileItemList list;
+ bool ok=false;
+
+ for (KFileItem *item=itsDirOp->view()->firstFileItem(); item && !ok; item=itsDirOp->view()->nextItem(item))
+ if(Print::printable(item->mimetype()))
+ ok=true;
+
+ if(ok)
+ {
+ const KFileItemList *list=itsDirOp->selectedItems();
+ bool select=false;
+
+ if(list)
+ {
+ KFileItemList::Iterator it(list->begin()),
+ end(list->end());
+
+ for(; it!=end && !select; ++it)
+ if(Print::printable((*it)->mimetype()))
+ select=true;
+ }
+
+ CPrintDialog dlg(this);
+
+ itsConfig.setGroup(CFG_GROUP);
+ if(dlg.exec(select, itsConfig.readNumEntry(CFG_FONT_SIZE, 1)))
+ {
+ static const int constSizes[]={0, 12, 18, 24, 36, 48};
+
+ QStringList items;
+ QValueVector<int> sizes;
+ CFcEngine engine;
+
+ if(dlg.outputAll())
+ {
+ for (KFileItem *item=itsDirOp->view()->firstFileItem(); item; item=itsDirOp->view()->nextItem(item))
+ items.append(item->name());
+ }
+ else
+ {
+ KFileItemList::Iterator it(list->begin()),
+ end(list->end());
+
+ for(; it!=end; ++it)
+ items.append((*it)->name());
+ }
+ Print::printItems(items, constSizes[dlg.chosenSize()], this, engine);
+ itsConfig.writeEntry(CFG_FONT_SIZE, dlg.chosenSize());
+ if(itsEmbeddedAdmin)
+ itsConfig.sync();
+ }
+ }
+ else
+ KMessageBox::information(this, i18n("There are no printable fonts.\nYou can only print non-bitmap fonts."),
+ i18n("Cannot Print"));
+#endif
+}
+
+void CKCmFontInst::dropped(const KFileItem *i, QDropEvent *, const KURL::List &urls)
+{
+ if(urls.count())
+ addFonts(urls, i && i->isDir() ? i->url() : itsDirOp->url());
+}
+
+void CKCmFontInst::infoMessage(const QString &msg)
+{
+ itsStatusLabel->setText(msg);
+}
+
+static QString family(const QString &name)
+{
+ int commaPos=name.find(',');
+
+ return -1==commaPos ? name : name.left(commaPos);
+}
+
+void CKCmFontInst::updateInformation(int, int fonts)
+{
+ KIO::filesize_t size=0;
+ QString text(i18n("One Font", "%n Fonts", fonts));
+ QStringList families;
+
+ if(fonts>0)
+ {
+ KFileItem *item=NULL;
+
+ for (item=itsDirOp->view()->firstFileItem(); item; item=itsDirOp->view()->nextItem(item))
+ {
+ QString fam(family(item->text()));
+
+ size+=item->size();
+ if(-1==families.findIndex(fam))
+ families+=fam;
+ }
+ }
+
+ if(fonts>0)
+ {
+ text+=" ";
+ text+=i18n("(%1 Total)").arg(KIO::convertSize(size));
+ }
+ text+=" - ";
+ text+=i18n("One Family", "%n Families", families.count());
+ itsStatusLabel->setText(text);
+}
+
+void CKCmFontInst::delResult(KIO::Job *job)
+{
+ //
+ // To speed up font deletion, we dont rescan font list each time - so after this has completed, we need
+ // to refresh font list before updating the directory listing...
+ QByteArray packedArgs;
+ QDataStream stream(packedArgs, IO_WriteOnly);
+
+ stream << KFI::SPECIAL_RESCAN;
+
+ KIO::NetAccess::synchronousRun(KIO::special(KFI_KIO_FONTS_PROTOCOL ":/", packedArgs), this);
+ jobResult(job);
+}
+
+void CKCmFontInst::jobResult(KIO::Job *job)
+{
+ //
+ // Force an update of the view. For some reason the view is not automatically updated when
+ // run in embedded mode - e.g. from the "Admin" mode button on KControl.
+ itsDirOp->dirLister()->updateDirectory(itsDirOp->url());
+ if(job && 0==job->error())
+ KMessageBox::information(this,
+#ifdef HAVE_XFT
+ i18n("<p>Please note that any open applications will need to be restarted in order "
+ "for any changes to be noticed.<p><p>(You will also have to restart this application "
+ "in order to use its print function on any newly installed fonts.)</p>"),
+#else
+ i18n("Please note that any open applications will need to be restarted in order "
+ "for any changes to be noticed."),
+#endif
+ i18n("Success"), "KFontinst_WarnAboutFontChangesAndOpenApps");
+}
+
+void CKCmFontInst::addFonts(const KURL::List &src, const KURL &dest)
+{
+ if(src.count())
+ {
+ KURL::List copy(src);
+ KURL::List::ConstIterator it;
+
+ //
+ // Check if font has any associated AFM or PFM file...
+ for(it=src.begin(); it!=src.end(); ++it)
+ {
+ KURL::List associatedUrls;
+
+ Misc::getAssociatedUrls(*it, associatedUrls, false, this);
+ copy+=associatedUrls;
+ }
+
+ KIO::CopyJob *job=KIO::copy(copy, dest, true);
+ connect(job, SIGNAL(result(KIO::Job *)), this, SLOT(jobResult(KIO::Job *)));
+ job->setWindow(this);
+ job->setAutoErrorHandlingEnabled(true, this);
+ }
+}
+
+}
+
+#include "KCmFontInst.moc"
diff --git a/kcontrol/kfontinst/kcmfontinst/KCmFontInst.h b/kcontrol/kfontinst/kcmfontinst/KCmFontInst.h
new file mode 100644
index 000000000..add6c4c36
--- /dev/null
+++ b/kcontrol/kfontinst/kcmfontinst/KCmFontInst.h
@@ -0,0 +1,116 @@
+#ifndef __KCM_FONT_INST_H__
+#define __KCM_FONT_INST_H__
+
+////////////////////////////////////////////////////////////////////////////////
+//
+// Class Name : KFI::CKCmFontInst
+// Author : Craig Drummond
+// Project : K Font Installer
+// Creation Date : 26/04/2003
+// Version : $Revision$ $Date$
+//
+////////////////////////////////////////////////////////////////////////////////
+//
+// This program is free software; you can redistribute it and/or
+// modify it under the terms of the GNU General Public License
+// as published by the Free Software Foundation; either version 2
+// of the License, or (at your option) any later version.
+//
+// This program is distributed in the hope that it will be useful,
+// but WITHOUT ANY WARRANTY; without even the implied warranty of
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+// GNU General Public License for more details.
+//
+// You should have received a copy of the GNU General Public License
+// along with this program; if not, write to the Free Software
+// Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
+//
+////////////////////////////////////////////////////////////////////////////////
+// (C) Craig Drummond, 2003, 2004
+////////////////////////////////////////////////////////////////////////////////
+
+#ifdef HAVE_CONFIG_H
+#include "config.h"
+#endif
+
+#include <qstringlist.h>
+#include <kcmodule.h>
+#include <kurl.h>
+#include <kconfig.h>
+#include <kio/job.h>
+#ifdef HAVE_XFT
+#include <kparts/part.h>
+#endif
+
+class KDirOperator;
+class KAction;
+class KRadioAction;
+class KActionMenu;
+class KToggleAction;
+class KFileItem;
+class QLabel;
+class QSplitter;
+class QDropEvent;
+class KFileItem;
+
+namespace KFI
+{
+
+class CKCmFontInst : public KCModule
+{
+ Q_OBJECT
+
+ public:
+
+ CKCmFontInst(QWidget *parent=NULL, const char *name=NULL, const QStringList &list=QStringList());
+ virtual ~CKCmFontInst();
+
+ void setMimeTypes(bool showBitmap);
+
+ public slots:
+
+ void filterFonts();
+ QString quickHelp() const;
+ void listView();
+ void iconView();
+ void setupMenu();
+ void setupViewMenu();
+ void fileHighlighted(const KFileItem *item);
+ void loadingFinished();
+ void addFonts();
+ void removeFonts();
+ void configure();
+ void print();
+ void dropped(const KFileItem *i, QDropEvent *e, const KURL::List &urls);
+ void infoMessage(const QString &msg);
+ void updateInformation(int dirs, int fonts);
+ void delResult(KIO::Job *job);
+ void jobResult(KIO::Job *job);
+
+ private:
+
+ void addFonts(const KURL::List &src, const KURL &dest);
+
+ private:
+
+ KDirOperator *itsDirOp;
+ KURL itsTop;
+ KToggleAction *itsShowBitmapAct;
+ KAction *itsSepDirsAct,
+ *itsShowHiddenAct,
+ *itsDeleteAct;
+ KRadioAction *itsListAct,
+ *itsIconAct;
+ KActionMenu *itsViewMenuAct;
+#ifdef HAVE_XFT
+ KParts::ReadOnlyPart *itsPreview;
+#endif
+ QSplitter *itsSplitter;
+ KConfig itsConfig;
+ bool itsEmbeddedAdmin;
+ QLabel *itsStatusLabel;
+};
+
+}
+
+#endif
diff --git a/kcontrol/kfontinst/kcmfontinst/KFileFontIconView.cpp b/kcontrol/kfontinst/kcmfontinst/KFileFontIconView.cpp
new file mode 100644
index 000000000..d814d0c6b
--- /dev/null
+++ b/kcontrol/kfontinst/kcmfontinst/KFileFontIconView.cpp
@@ -0,0 +1,88 @@
+////////////////////////////////////////////////////////////////////////////////
+//
+// Class Name : KFI::CKFileFontIconView
+// Author : Craig Drummond
+// Project : K Font Installer
+// Creation Date : 31/05/2003
+// Version : $Revision$ $Date$
+//
+////////////////////////////////////////////////////////////////////////////////
+//
+// This program is free software; you can redistribute it and/or
+// modify it under the terms of the GNU General Public License
+// as published by the Free Software Foundation; either version 2
+// of the License, or (at your option) any later version.
+//
+// This program is distributed in the hope that it will be useful,
+// but WITHOUT ANY WARRANTY; without even the implied warranty of
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+// GNU General Public License for more details.
+//
+// You should have received a copy of the GNU General Public License
+// along with this program; if not, write to the Free Software
+// Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
+//
+////////////////////////////////////////////////////////////////////////////////
+// (C) Craig Drummond, 2003, 2004
+////////////////////////////////////////////////////////////////////////////////
+
+#include <qevent.h>
+#include <kfileitem.h>
+#include <kurldrag.h>
+#include "KFileFontIconView.h"
+
+namespace KFI
+{
+
+// CPD: KDE4 should make acceptDrag() virtual there fore can get rid of all these ::contentsX functions...
+void CKFileFontIconView::contentsDragEnterEvent(QDragEnterEvent *e)
+{
+ if(acceptDrag(e))
+ KFileIconView::contentsDragEnterEvent(e);
+ else
+ e->ignore();
+}
+
+void CKFileFontIconView::contentsDragMoveEvent(QDragMoveEvent *e)
+{
+ if(acceptDrag(e))
+ KFileIconView::contentsDragMoveEvent(e);
+ else
+ e->ignore();
+}
+
+void CKFileFontIconView::contentsDropEvent(QDropEvent *e)
+{
+ contentsDragLeaveEvent(NULL);
+
+ if(acceptDrag(e))
+ KFileIconView::contentsDropEvent(e);
+ else
+ e->ignore();
+}
+
+bool CKFileFontIconView::acceptDrag(QDropEvent *e) const
+{
+#if 0 // Crashes - seems to be called to quick???
+ bool ok=false;
+ KURL::List urls;
+
+ if(KURLDrag::canDecode(e) && (e->source()!=const_cast<CKFileFontIconView *>(this)) &&
+ (QDropEvent::Copy==e->action() || QDropEvent::Move==e->action()) &&
+ KURLDrag::decode(e, urls) && !urls.isEmpty())
+ {
+ KURL::List::Iterator it;
+
+ ok=true;
+ for(it=urls.begin(); ok && it!=urls.end(); ++it)
+ if(!CFontEngine::isAFontOrAfm(QFile::encodeName((*it).path())))
+ ok=false;
+ }
+
+ return ok;
+#endif
+ return KURLDrag::canDecode(e) && (e->source()!= const_cast<CKFileFontIconView*>(this)) &&
+ (QDropEvent::Copy==e->action() || QDropEvent::Move==e->action());
+}
+
+}
diff --git a/kcontrol/kfontinst/kcmfontinst/KFileFontIconView.h b/kcontrol/kfontinst/kcmfontinst/KFileFontIconView.h
new file mode 100644
index 000000000..936bb5bca
--- /dev/null
+++ b/kcontrol/kfontinst/kcmfontinst/KFileFontIconView.h
@@ -0,0 +1,55 @@
+#ifndef __KFILE_FONT_ICON_VIEW_H__
+#define __KFILE_FONT_ICON_VIEW_H__
+
+////////////////////////////////////////////////////////////////////////////////
+//
+// Class Name : KFI::CKFileFontIconView
+// Author : Craig Drummond
+// Project : K Font Installer
+// Creation Date : 01/08/2003
+// Version : $Revision$ $Date$
+//
+////////////////////////////////////////////////////////////////////////////////
+//
+// This program is free software; you can redistribute it and/or
+// modify it under the terms of the GNU General Public License
+// as published by the Free Software Foundation; either version 2
+// of the License, or (at your option) any later version.
+//
+// This program is distributed in the hope that it will be useful,
+// but WITHOUT ANY WARRANTY; without even the implied warranty of
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+// GNU General Public License for more details.
+//
+// You should have received a copy of the GNU General Public License
+// along with this program; if not, write to the Free Software
+// Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
+//
+////////////////////////////////////////////////////////////////////////////////
+// (C) Craig Drummond, 2003, 2004
+////////////////////////////////////////////////////////////////////////////////
+
+#include <kfileiconview.h>
+
+namespace KFI
+{
+
+class CKFileFontIconView : public KFileIconView
+{
+ public:
+
+ CKFileFontIconView(QWidget *parent, const char *name) : KFileIconView(parent, name) {}
+ virtual ~CKFileFontIconView() {}
+
+ protected:
+
+ // DND support
+ void contentsDragEnterEvent(QDragEnterEvent *e);
+ void contentsDragMoveEvent(QDragMoveEvent *e);
+ void contentsDropEvent(QDropEvent *e);
+ bool acceptDrag(QDropEvent *e) const;
+};
+
+}
+
+#endif
diff --git a/kcontrol/kfontinst/kcmfontinst/KFileFontView.cpp b/kcontrol/kfontinst/kcmfontinst/KFileFontView.cpp
new file mode 100644
index 000000000..7346ca6c8
--- /dev/null
+++ b/kcontrol/kfontinst/kcmfontinst/KFileFontView.cpp
@@ -0,0 +1,645 @@
+////////////////////////////////////////////////////////////////////////////////
+//
+// Class Name : CKFileFontView
+// Author : Craig Drummond
+// Project : K Font Installer
+// Creation Date : 31/05/2003
+// Version : $Revision$ $Date$
+//
+////////////////////////////////////////////////////////////////////////////////
+//
+// This program is free software; you can redistribute it and/or
+// modify it under the terms of the GNU General Public License
+// as published by the Free Software Foundation; either version 2
+// of the License, or (at your option) any later version.
+//
+// This program is distributed in the hope that it will be useful,
+// but WITHOUT ANY WARRANTY; without even the implied warranty of
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+// GNU General Public License for more details.
+//
+// You should have received a copy of the GNU General Public License
+// along with this program; if not, write to the Free Software
+// Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
+//
+////////////////////////////////////////////////////////////////////////////////
+// (C) Craig Drummond, 2003
+////////////////////////////////////////////////////////////////////////////////
+
+//
+// NOTE: HEAVILY copied from kfiledetailview.cpp...
+//
+// Copyright (C) 1997 Stephan Kulow <coolo@kde.org>
+// 2000, 2001 Carsten Pfeiffer <pfeiffer@kde.org>
+//
+
+#include <qevent.h>
+#include <qkeycode.h>
+#include <qheader.h>
+#include <qpainter.h>
+#include <qpixmap.h>
+#include <kapplication.h>
+#include <kfileitem.h>
+#include <kglobal.h>
+#include <kglobalsettings.h>
+#include <kicontheme.h>
+#include <klocale.h>
+#include <kiconloader.h>
+#include <kdebug.h>
+#include <kurldrag.h>
+#include "KFileFontView.h"
+
+#define COL_NAME 0
+#define COL_SIZE 1
+#define COL_TYPE 2
+
+class CKFileFontView::CKFileFontViewPrivate
+{
+ public:
+
+ CKFileFontViewPrivate() : itsDropItem(0) {}
+
+ CFontListViewItem *itsDropItem;
+ QTimer itsAutoOpenTimer;
+};
+
+CKFileFontView::CKFileFontView(QWidget *parent, const char *name)
+ : KListView(parent, name),
+ KFileView(),
+ d(new CKFileFontViewPrivate())
+{
+ itsSortingCol = COL_NAME;
+ itsBlockSortingSignal = false;
+ setViewName(i18n("Detailed View"));
+
+ addColumn(i18n("Name"));
+ addColumn(i18n("Size"));
+ addColumn(i18n("Type"));
+ setShowSortIndicator(true);
+ setAllColumnsShowFocus(true);
+ setDragEnabled(false);
+
+ connect(header(), SIGNAL(sectionClicked(int)), SLOT(slotSortingChanged(int)));
+ connect(this, SIGNAL(returnPressed(QListViewItem *)), SLOT(slotActivate(QListViewItem *)));
+ connect(this, SIGNAL(clicked(QListViewItem *, const QPoint&, int)), SLOT(selected( QListViewItem *)));
+ connect(this, SIGNAL(doubleClicked(QListViewItem *, const QPoint &, int)), SLOT(slotActivate(QListViewItem *)));
+ connect(this, SIGNAL(contextMenuRequested(QListViewItem *, const QPoint &, int)),
+ this, SLOT(slotActivateMenu(QListViewItem *, const QPoint &)));
+
+ // DND
+ connect(&(d->itsAutoOpenTimer), SIGNAL(timeout()), this, SLOT(slotAutoOpen()));
+ setSelectionMode(KFileView::selectionMode());
+ itsResolver = new KMimeTypeResolver<CFontListViewItem, CKFileFontView>(this);
+}
+
+CKFileFontView::~CKFileFontView()
+{
+ delete itsResolver;
+ delete d;
+}
+
+void CKFileFontView::setSelected(const KFileItem *info, bool enable)
+{
+ if (info)
+ {
+ // we can only hope that this casts works
+ CFontListViewItem *item = (CFontListViewItem*)info->extraData(this);
+
+ if (item)
+ KListView::setSelected(item, enable);
+ }
+}
+
+void CKFileFontView::setCurrentItem(const KFileItem *item)
+{
+ if (item)
+ {
+ CFontListViewItem *it = (CFontListViewItem*) item->extraData(this);
+
+ if (it)
+ KListView::setCurrentItem(it);
+ }
+}
+
+KFileItem * CKFileFontView::currentFileItem() const
+{
+ CFontListViewItem *current = static_cast<CFontListViewItem*>(currentItem());
+
+ return current ? current->fileInfo() : NULL;
+}
+
+void CKFileFontView::clearSelection()
+{
+ KListView::clearSelection();
+}
+
+void CKFileFontView::selectAll()
+{
+ if (KFile::NoSelection!=KFileView::selectionMode() && KFile::Single!=KFileView::selectionMode())
+ KListView::selectAll(true);
+}
+
+void CKFileFontView::invertSelection()
+{
+ KListView::invertSelection();
+}
+
+void CKFileFontView::slotActivateMenu(QListViewItem *item,const QPoint& pos)
+{
+ if (!item)
+ sig->activateMenu(0, pos);
+ else
+ {
+ CFontListViewItem *i = (CFontListViewItem*) item;
+ sig->activateMenu(i->fileInfo(), pos);
+ }
+}
+
+void CKFileFontView::clearView()
+{
+ itsResolver->m_lstPendingMimeIconItems.clear();
+ KListView::clear();
+}
+
+void CKFileFontView::insertItem(KFileItem *i)
+{
+ KFileView::insertItem(i);
+
+ CFontListViewItem *item = new CFontListViewItem((QListView*) this, i);
+
+ setSortingKey(item, i);
+
+ i->setExtraData(this, item);
+
+ if (!i->isMimeTypeKnown())
+ itsResolver->m_lstPendingMimeIconItems.append(item);
+}
+
+void CKFileFontView::slotActivate(QListViewItem *item)
+{
+ if (item)
+ {
+ const KFileItem *fi = ((CFontListViewItem*)item)->fileInfo();
+
+ if (fi)
+ sig->activate(fi);
+ }
+}
+
+void CKFileFontView::selected(QListViewItem *item)
+{
+ if (item && !(KApplication::keyboardMouseState() & (ShiftButton|ControlButton)) &&
+ KGlobalSettings::singleClick())
+ {
+ const KFileItem *fi = ((CFontListViewItem*)item)->fileInfo();
+
+ if (fi && (fi->isDir() || !onlyDoubleClickSelectsFiles()))
+ sig->activate(fi);
+ }
+}
+
+void CKFileFontView::highlighted( QListViewItem *item )
+{
+ if (item)
+ {
+ const KFileItem *fi = ((CFontListViewItem*)item)->fileInfo();
+
+ if (fi)
+ sig->highlightFile(fi);
+ }
+}
+
+void CKFileFontView::setSelectionMode(KFile::SelectionMode sm)
+{
+ disconnect(SIGNAL(selectionChanged()), this);
+ disconnect(SIGNAL(selectionChanged(QListViewItem *)), this);
+
+ switch (sm)
+ {
+ case KFile::Multi:
+ QListView::setSelectionMode(QListView::Multi);
+ break;
+ case KFile::Extended:
+ QListView::setSelectionMode(QListView::Extended);
+ break;
+ case KFile::NoSelection:
+ QListView::setSelectionMode(QListView::NoSelection);
+ break;
+ default: // fall through
+ case KFile::Single:
+ QListView::setSelectionMode(QListView::Single);
+ break;
+ }
+
+ // for highlighting
+ if (KFile::Multi==sm || KFile::Extended==sm)
+ connect(this, SIGNAL(selectionChanged()), SLOT(slotSelectionChanged()));
+ else
+ connect(this, SIGNAL(selectionChanged(QListViewItem *)), SLOT(highlighted(QListViewItem * )));
+}
+
+bool CKFileFontView::isSelected(const KFileItem *i) const
+{
+ if (!i)
+ return false;
+ else
+ {
+ CFontListViewItem *item = (CFontListViewItem*) i->extraData(this);
+
+ return (item && item->isSelected());
+ }
+}
+
+void CKFileFontView::updateView(bool b)
+{
+ if (b)
+ {
+ QListViewItemIterator it((QListView*)this);
+
+ for (; it.current(); ++it)
+ {
+ CFontListViewItem *item=static_cast<CFontListViewItem *>(it.current());
+
+ item->setPixmap(0, item->fileInfo()->pixmap(KIcon::SizeSmall));
+ }
+ }
+}
+
+void CKFileFontView::updateView(const KFileItem *i)
+{
+ if (i)
+ {
+ CFontListViewItem *item = (CFontListViewItem*) i->extraData(this);
+
+ if (item)
+ {
+ item->init();
+ setSortingKey(item, i);
+ }
+ }
+}
+
+void CKFileFontView::setSortingKey(CFontListViewItem *item, const KFileItem *i)
+{
+ QDir::SortSpec spec = KFileView::sorting();
+
+ if (spec&QDir::Size)
+ item->setKey(sortingKey(i->size(), i->isDir(), spec));
+ else
+ item->setKey(sortingKey(i->text(), i->isDir(), spec));
+}
+
+void CKFileFontView::removeItem(const KFileItem *i)
+{
+ if (i)
+ {
+ CFontListViewItem *item = (CFontListViewItem*) i->extraData(this);
+
+ itsResolver->m_lstPendingMimeIconItems.remove(item);
+ delete item;
+
+ KFileView::removeItem(i);
+ }
+}
+
+void CKFileFontView::slotSortingChanged(int col)
+{
+ QDir::SortSpec sort = sorting();
+ int sortSpec = -1;
+ bool reversed = col == itsSortingCol && (sort & QDir::Reversed) == 0;
+ itsSortingCol = col;
+
+ switch(col)
+ {
+ case COL_NAME:
+ sortSpec = (sort & ~QDir::SortByMask | QDir::Name);
+ break;
+ case COL_SIZE:
+ sortSpec = (sort & ~QDir::SortByMask | QDir::Size);
+ break;
+ // the following columns have no equivalent in QDir, so we set it
+ // to QDir::Unsorted and remember the column (itsSortingCol)
+ case COL_TYPE:
+ sortSpec = (sort & ~QDir::SortByMask | QDir::Time);
+ break;
+ default:
+ break;
+ }
+
+ if (reversed)
+ sortSpec|=QDir::Reversed;
+ else
+ sortSpec&=~QDir::Reversed;
+
+ if (sort & QDir::IgnoreCase)
+ sortSpec|=QDir::IgnoreCase;
+ else
+ sortSpec&=~QDir::IgnoreCase;
+
+ KFileView::setSorting(static_cast<QDir::SortSpec>(sortSpec));
+
+ KFileItem *item;
+ KFileItemListIterator it(*items());
+
+ if ( sortSpec & QDir::Size )
+ {
+ for (; (item = it.current()); ++it )
+ {
+ CFontListViewItem *i = viewItem(item);
+ i->setKey(sortingKey(item->size(), item->isDir(), sortSpec));
+ }
+ }
+ else
+ for (; (item = it.current()); ++it )
+ {
+ CFontListViewItem *i = viewItem(item);
+
+ i->setKey(sortingKey(i->text(itsSortingCol), item->isDir(), sortSpec));
+ }
+
+ KListView::setSorting(itsSortingCol, !reversed);
+ KListView::sort();
+
+ if (!itsBlockSortingSignal)
+ sig->changeSorting( static_cast<QDir::SortSpec>( sortSpec ) );
+}
+
+void CKFileFontView::setSorting(QDir::SortSpec spec)
+{
+ if (spec & QDir::Size)
+ itsSortingCol=COL_SIZE;
+ else
+ itsSortingCol=COL_NAME;
+
+ // inversed, because slotSortingChanged will reverse it
+ if (spec & QDir::Reversed)
+ spec = (QDir::SortSpec) (spec & ~QDir::Reversed);
+ else
+ spec = (QDir::SortSpec) (spec | QDir::Reversed);
+
+ KFileView::setSorting((QDir::SortSpec) spec);
+
+ // don't emit sortingChanged() when called via setSorting()
+ itsBlockSortingSignal = true; // can't use blockSignals()
+ slotSortingChanged(itsSortingCol);
+ itsBlockSortingSignal = false;
+}
+
+void CKFileFontView::ensureItemVisible(const KFileItem *i)
+{
+ if (i)
+ {
+ CFontListViewItem *item = (CFontListViewItem*) i->extraData(this);
+
+ if ( item )
+ KListView::ensureItemVisible(item);
+ }
+}
+
+// we're in multiselection mode
+void CKFileFontView::slotSelectionChanged()
+{
+ sig->highlightFile(NULL);
+}
+
+KFileItem * CKFileFontView::firstFileItem() const
+{
+ CFontListViewItem *item = static_cast<CFontListViewItem*>(firstChild());
+
+ return item ? item->fileInfo() : NULL;
+}
+
+KFileItem * CKFileFontView::nextItem(const KFileItem *fileItem) const
+{
+ if (fileItem)
+ {
+ CFontListViewItem *item = viewItem(fileItem);
+
+ return item && item->itemBelow() ? ((CFontListViewItem*) item->itemBelow())->fileInfo() : NULL;
+ }
+
+ return firstFileItem();
+}
+
+KFileItem * CKFileFontView::prevItem(const KFileItem *fileItem) const
+{
+ if (fileItem)
+ {
+ CFontListViewItem *item = viewItem(fileItem);
+
+ return item && item->itemAbove() ? ((CFontListViewItem*) item->itemAbove())->fileInfo() : NULL;
+ }
+
+ return firstFileItem();
+}
+
+void CKFileFontView::keyPressEvent(QKeyEvent *e)
+{
+ KListView::keyPressEvent(e);
+
+ if (Key_Return==e->key() || Key_Enter==e->key())
+ if (e->state() & ControlButton)
+ e->ignore();
+ else
+ e->accept();
+}
+
+//
+// mimetype determination on demand
+//
+void CKFileFontView::mimeTypeDeterminationFinished()
+{
+ // anything to do?
+}
+
+void CKFileFontView::determineIcon(CFontListViewItem *item)
+{
+ item->fileInfo()->determineMimeType();
+ updateView(item->fileInfo());
+}
+
+void CKFileFontView::listingCompleted()
+{
+ itsResolver->start();
+}
+
+QDragObject *CKFileFontView::dragObject()
+{
+ // create a list of the URL:s that we want to drag
+ KURL::List urls;
+ KFileItemListIterator it(* KFileView::selectedItems());
+ QPixmap pixmap;
+ QPoint hotspot;
+
+ for ( ; it.current(); ++it )
+ urls.append( (*it)->url() );
+
+ if(urls.count()> 1)
+ pixmap = DesktopIcon("kmultiple", KIcon::SizeSmall);
+ if(pixmap.isNull())
+ pixmap = currentFileItem()->pixmap(KIcon::SizeSmall);
+
+ hotspot.setX(pixmap.width() / 2);
+ hotspot.setY(pixmap.height() / 2);
+
+ QDragObject *dragObject=new KURLDrag(urls, widget());
+
+ if(dragObject)
+ dragObject->setPixmap(pixmap, hotspot);
+
+ return dragObject;
+}
+
+void CKFileFontView::slotAutoOpen()
+{
+ d->itsAutoOpenTimer.stop();
+
+ if(d->itsDropItem)
+ {
+ KFileItem *fileItem = d->itsDropItem->fileInfo();
+
+ if (fileItem && !fileItem->isFile() && (fileItem->isDir() || fileItem->isLink()))
+ sig->activate(fileItem);
+ }
+}
+
+bool CKFileFontView::acceptDrag(QDropEvent *e) const
+{
+#if 0 // Following doesn't seem to work, why???
+ bool ok=false;
+ KURL::List urls;
+
+
+ if((e->source()!=const_cast<CKFileFontView *>(this)) &&
+ (QDropEvent::Copy==e->action() || QDropEvent::Move==e->action()) &&
+ KURLDrag::decode(e, urls) && !urls.isEmpty())
+ {
+ KURL::List::Iterator it;
+
+ ok=true;
+ for(it=urls.begin(); ok && it!=urls.end(); ++it)
+ if(!CFontEngine::isAFontOrAfm(QFile::encodeName((*it).path())))
+ ok=false;
+ }
+
+ return ok;
+#endif
+
+ return KURLDrag::canDecode(e) && (e->source()!= const_cast<CKFileFontView*>(this)) &&
+ (QDropEvent::Copy==e->action() || QDropEvent::Move==e->action());
+}
+
+void CKFileFontView::contentsDragEnterEvent(QDragEnterEvent *e)
+{
+ if (!acceptDrag(e)) // can we decode this ?
+ e->ignore(); // No
+ else
+ {
+ e->acceptAction(); // Yes
+
+ if((dropOptions() & AutoOpenDirs))
+ {
+ CFontListViewItem *item = dynamic_cast<CFontListViewItem*>(itemAt(contentsToViewport(e->pos())));
+ if (item) // are we over an item ?
+ {
+ d->itsDropItem = item;
+ d->itsAutoOpenTimer.start(autoOpenDelay()); // restart timer
+ }
+ else
+ {
+ d->itsDropItem = 0;
+ d->itsAutoOpenTimer.stop();
+ }
+ }
+ }
+}
+
+void CKFileFontView::contentsDragMoveEvent(QDragMoveEvent *e)
+{
+ if (!acceptDrag(e)) // can we decode this ?
+ e->ignore(); // No
+ else
+ {
+ e->acceptAction(); // Yes
+
+ if ((dropOptions() & AutoOpenDirs))
+ {
+ CFontListViewItem *item = dynamic_cast<CFontListViewItem*>(itemAt(contentsToViewport(e->pos())));
+
+ if (item) // are we over an item ?
+ {
+ if (d->itsDropItem != item)
+ {
+ d->itsDropItem = item;
+ d->itsAutoOpenTimer.start(autoOpenDelay()); // restart timer
+ }
+ }
+ else
+ {
+ d->itsDropItem = 0;
+ d->itsAutoOpenTimer.stop();
+ }
+ }
+ }
+}
+
+void CKFileFontView::contentsDragLeaveEvent(QDragLeaveEvent *)
+{
+ d->itsDropItem = 0;
+ d->itsAutoOpenTimer.stop();
+}
+
+void CKFileFontView::contentsDropEvent(QDropEvent *e)
+{
+ d->itsDropItem = 0;
+ d->itsAutoOpenTimer.stop();
+
+ if (!acceptDrag(e)) // can we decode this ?
+ e->ignore(); // No
+ else
+ {
+ e->acceptAction(); // Yes
+
+ CFontListViewItem *item = dynamic_cast<CFontListViewItem*>(itemAt(contentsToViewport(e->pos())));
+ KFileItem *fileItem = item ? item->fileInfo() : 0;
+ KURL::List urls;
+
+ emit dropped(e, fileItem);
+
+ if(KURLDrag::decode(e, urls) && !urls.isEmpty())
+ {
+ emit dropped(e, urls, fileItem ? fileItem->url() : KURL());
+ sig->dropURLs(fileItem, e, urls);
+ }
+ }
+}
+
+void CKFileFontView::readConfig(KConfig *kc, const QString &group)
+{
+ restoreLayout(kc, group.isEmpty() ? QString("CFileFontView") : group);
+ slotSortingChanged(sortColumn());
+}
+
+void CKFileFontView::writeConfig(KConfig *kc, const QString &group)
+{
+ saveLayout(kc, group.isEmpty() ? QString("CFileFontView") : group);
+}
+
+/////////////////////////////////////////////////////////////////
+
+void CFontListViewItem::init()
+{
+ CFontListViewItem::setPixmap(COL_NAME, itsInf->pixmap(KIcon::SizeSmall));
+
+ setText(COL_NAME, itsInf->text());
+ setText(COL_SIZE, itsInf->isDir() ? "" : KGlobal::locale()->formatNumber(itsInf->size(), 0));
+ setText(COL_TYPE, itsInf->mimeComment());
+}
+
+void CKFileFontView::virtual_hook(int id, void *data)
+{
+ KListView::virtual_hook(id, data);
+ KFileView::virtual_hook(id, data);
+}
+
+#include "KFileFontView.moc"
diff --git a/kcontrol/kfontinst/kcmfontinst/KFileFontView.h b/kcontrol/kfontinst/kcmfontinst/KFileFontView.h
new file mode 100644
index 000000000..a58f9d908
--- /dev/null
+++ b/kcontrol/kfontinst/kcmfontinst/KFileFontView.h
@@ -0,0 +1,219 @@
+#ifndef __KFILE_FONT_VIEW_H__
+#define __KFILE_FONT_VIEW_H__
+
+////////////////////////////////////////////////////////////////////////////////
+//
+// Class Name : CKFileFontView
+// Author : Craig Drummond
+// Project : K Font Installer
+// Creation Date : 31/05/2003
+// Version : $Revision$ $Date$
+//
+////////////////////////////////////////////////////////////////////////////////
+//
+// This program is free software; you can redistribute it and/or
+// modify it under the terms of the GNU General Public License
+// as published by the Free Software Foundation; either version 2
+// of the License, or (at your option) any later version.
+//
+// This program is distributed in the hope that it will be useful,
+// but WITHOUT ANY WARRANTY; without even the implied warranty of
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+// GNU General Public License for more details.
+//
+// You should have received a copy of the GNU General Public License
+// along with this program; if not, write to the Free Software
+// Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
+//
+////////////////////////////////////////////////////////////////////////////////
+// (C) Craig Drummond, 2003
+////////////////////////////////////////////////////////////////////////////////
+
+//
+// NOTE: HEAVILY copied from kfiledetailview.cpp...
+//
+// Copyright (C) 1997 Stephan Kulow <coolo@kde.org>
+// 2000, 2001 Carste
+
+class KFileItem;
+class QWidget;
+class QKeyEvent;
+
+#include <klistview.h>
+#include <kmimetyperesolver.h>
+
+#include "kfileview.h"
+
+/**
+ * An item for the listiew, that has a reference to its corresponding
+ * @ref KFileItem.
+ */
+class CFontListViewItem : public KListViewItem
+{
+ public:
+
+ CFontListViewItem(QListView *parent, const QString &text, const QPixmap &icon, KFileItem *fi)
+ : KListViewItem(parent, text),
+ itsInf(fi)
+ {
+ setPixmap(0, icon);
+ setText(0, text);
+ }
+
+ CFontListViewItem(QListView *parent, KFileItem *fi)
+ : KListViewItem(parent),
+ itsInf(fi)
+ {
+ init();
+ }
+
+ CFontListViewItem(QListView *parent, const QString &text, const QPixmap &icon, KFileItem *fi, QListViewItem *after)
+ : KListViewItem(parent, after),
+ itsInf(fi)
+ {
+ setPixmap(0, icon);
+ setText(0, text);
+ }
+
+ ~CFontListViewItem() { itsInf->removeExtraData(listView()); }
+
+ /**
+ * @returns the corresponding KFileItem
+ */
+ KFileItem *fileInfo() const { return itsInf; }
+
+ virtual QString key( int /*column*/, bool /*ascending*/ ) const { return itsKey; }
+
+ void setKey( const QString& key ) { itsKey = key; }
+
+ QRect rect() const
+ {
+ QRect r = listView()->itemRect(this);
+
+ return QRect(listView()->viewportToContents(r.topLeft()), QSize(r.width(), r.height()));
+ }
+
+ void init();
+
+ private:
+
+ KFileItem *itsInf;
+ QString itsKey;
+
+ class CFontListViewItemPrivate;
+
+ CFontListViewItemPrivate *d;
+};
+
+/**
+ * A list-view capable of showing @ref KFileItem'. Used in the filedialog
+ * for example. Most of the documentation is in @ref KFileView class.
+ *
+ * @see KDirOperator
+ * @see KCombiView
+ * @see KFileIconView
+ */
+class CKFileFontView : public KListView, public KFileView
+{
+ Q_OBJECT
+
+ public:
+
+ CKFileFontView(QWidget *parent, const char *name);
+ virtual ~CKFileFontView();
+
+ virtual QWidget * widget() { return this; }
+ virtual void clearView();
+ virtual void setAutoUpdate(bool) {} // ### unused. remove in KDE4
+ virtual void setSelectionMode( KFile::SelectionMode sm );
+ virtual void updateView(bool b);
+ virtual void updateView(const KFileItem *i);
+ virtual void removeItem(const KFileItem *i);
+ virtual void listingCompleted();
+ virtual void setSelected(const KFileItem *i, bool b);
+ virtual bool isSelected(const KFileItem *i) const;
+ virtual void clearSelection();
+ virtual void selectAll();
+ virtual void invertSelection();
+ virtual void setCurrentItem( const KFileItem *i);
+ virtual KFileItem * currentFileItem() const;
+ virtual KFileItem * firstFileItem() const;
+ virtual KFileItem * nextItem(const KFileItem *i) const;
+ virtual KFileItem * prevItem(const KFileItem *i) const;
+ virtual void insertItem( KFileItem *i);
+
+ void readConfig(KConfig *kc, const QString &group);
+ void writeConfig(KConfig *kc, const QString &group);
+
+ // implemented to get noticed about sorting changes (for sortingIndicator)
+ virtual void setSorting(QDir::SortSpec s);
+ void ensureItemVisible(const KFileItem *i);
+
+ // for KMimeTypeResolver
+ void mimeTypeDeterminationFinished();
+ void determineIcon(CFontListViewItem *item);
+ QScrollView * scrollWidget() const { return (QScrollView*) this; }
+
+ signals:
+ // The user dropped something.
+ // fileItem points to the item dropped on or can be 0 if the
+ // user dropped on empty space.
+ void dropped(QDropEvent *event, KFileItem *fileItem);
+ // The user dropped the URLs urls.
+ // url points to the item dropped on or can be empty if the
+ // user dropped on empty space.
+ void dropped(QDropEvent *event, const KURL::List &urls, const KURL &url);
+
+ protected:
+
+ virtual void keyPressEvent(QKeyEvent *e);
+ // DND support
+ QDragObject * dragObject();
+ void contentsDragEnterEvent(QDragEnterEvent *e);
+ void contentsDragMoveEvent(QDragMoveEvent *e);
+ void contentsDragLeaveEvent(QDragLeaveEvent *e);
+ void contentsDropEvent(QDropEvent *e);
+ bool acceptDrag(QDropEvent *e) const;
+
+ int itsSortingCol;
+
+ protected slots:
+
+ void slotSelectionChanged();
+
+ private slots:
+
+ void slotSortingChanged(int c);
+ void selected(QListViewItem *item);
+ void slotActivate(QListViewItem *item);
+ void highlighted(QListViewItem *item);
+ void slotActivateMenu(QListViewItem *item, const QPoint& pos);
+ void slotAutoOpen();
+
+ private:
+
+ virtual void insertItem(QListViewItem *i) { KListView::insertItem(i); }
+ virtual void setSorting(int i, bool b) { KListView::setSorting(i, b); }
+ virtual void setSelected(QListViewItem *i, bool b) { KListView::setSelected(i, b); }
+
+ inline CFontListViewItem * viewItem( const KFileItem *item ) const
+ {
+ return item ? (CFontListViewItem *) item->extraData(this) : NULL;
+ }
+
+ void setSortingKey( CFontListViewItem *item, const KFileItem *i);
+
+ bool itsBlockSortingSignal;
+ KMimeTypeResolver<CFontListViewItem,CKFileFontView> *itsResolver;
+
+ protected:
+
+ virtual void virtual_hook(int id, void *data);
+
+ private:
+
+ class CKFileFontViewPrivate;
+ CKFileFontViewPrivate *d;
+};
+
+#endif
diff --git a/kcontrol/kfontinst/kcmfontinst/Makefile.am b/kcontrol/kfontinst/kcmfontinst/Makefile.am
new file mode 100644
index 000000000..7a4c78920
--- /dev/null
+++ b/kcontrol/kfontinst/kcmfontinst/Makefile.am
@@ -0,0 +1,31 @@
+if include_fontinst_tn
+FONTINST_PRINT_INC=-I$(srcdir)/../viewpart
+FONTINST_PRINT_LIB=../viewpart/libkfontinstprint.la
+endif
+
+kde_module_LTLIBRARIES = kcm_fontinst.la
+kcm_fontinst_la_LIBADD = $(LIB_KIO) $(FONTINST_PRINT_LIB) $(LIBFREETYPE_LIBS) $(LIBFONTCONFIG_LIBS) ../lib/libkfontinst.la
+METASOURCES = AUTO
+kcm_fontinst_la_LDFLAGS = $(KDE_PLUGIN) $(all_libraries) $(KDE_RPATH) -module -avoid-version -no-undefined
+AM_CPPFLAGS = -I$(srcdir)/../lib $(FONTINST_PRINT_INC) -I$(srcdir)/../../fonts $(all_includes) $(LIBFREETYPE_CFLAGS) $(LIBFONTCONFIG_CFLAGS)
+
+xdg_apps_DATA = kcmfontinst.desktop
+
+kcm_fontinst_la_SOURCES = \
+ KCmFontInst.cpp \
+ KFileFontIconView.cpp \
+ KFileFontView.cpp \
+ PrintDialog.cpp \
+ SettingsDialog.cpp
+
+EXTRA_DIST = \
+ $(xdg_apps_DATA) \
+ KCmFontInst.h \
+ KFileFontIconView.h \
+ KFileFontView.h \
+ PrintDialog.h \
+ SettingsDialog.h
+
+noinst_HEADERS = $(EXTRA_DIST)
+
+KDE_ICON = AUTO
diff --git a/kcontrol/kfontinst/kcmfontinst/PrintDialog.cpp b/kcontrol/kfontinst/kcmfontinst/PrintDialog.cpp
new file mode 100644
index 000000000..e902fa1e1
--- /dev/null
+++ b/kcontrol/kfontinst/kcmfontinst/PrintDialog.cpp
@@ -0,0 +1,74 @@
+////////////////////////////////////////////////////////////////////////////////
+//
+// Class Name : KFI::CPrintDialog
+// Author : Craig Drummond
+// Project : K Font Installer
+// Creation Date : 12/05/2005
+// Version : $Revision$ $Date$
+//
+////////////////////////////////////////////////////////////////////////////////
+//
+// This program is free software; you can redistribute it and/or
+// modify it under the terms of the GNU General Public License
+// as published by the Free Software Foundation; either version 2
+// of the License, or (at your option) any later version.
+//
+// This program is distributed in the hope that it will be useful,
+// but WITHOUT ANY WARRANTY; without even the implied warranty of
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+// GNU General Public License for more details.
+//
+// You should have received a copy of the GNU General Public License
+// along with this program; if not, write to the Free Software
+// Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
+//
+////////////////////////////////////////////////////////////////////////////////
+// (C) Craig Drummond, 2005
+////////////////////////////////////////////////////////////////////////////////
+
+#include "PrintDialog.h"
+#include <qlayout.h>
+#include <qframe.h>
+#include <qlabel.h>
+#include <klocale.h>
+
+namespace KFI
+{
+
+CPrintDialog::CPrintDialog(QWidget *parent)
+ : KDialogBase(Plain, i18n("Print Font Samples"), Ok|Cancel, Ok, parent, NULL, true, false)
+{
+ QFrame *page=plainPage();
+ QGridLayout *layout=new QGridLayout(page, 1, 1, 0, spacingHint());
+
+ layout->addWidget(new QLabel(i18n("Output:"), page), 0, 0);
+ itsOutput=new QComboBox(page);
+ itsOutput->insertItem(i18n("All Fonts"), 0);
+ itsOutput->insertItem(i18n("Selected Fonts"), 1);
+ layout->addWidget(itsOutput, 0, 1);
+ layout->addWidget(new QLabel(i18n("Font size:"), page), 1, 0);
+ itsSize=new QComboBox(page);
+ itsSize->insertItem(i18n("Waterfall"), 0);
+ itsSize->insertItem(i18n("12pt"), 1);
+ itsSize->insertItem(i18n("18pt"), 2);
+ itsSize->insertItem(i18n("24pt"), 3);
+ itsSize->insertItem(i18n("36pt"), 4);
+ itsSize->insertItem(i18n("48pt"), 5);
+ layout->addWidget(itsSize, 1, 1);
+ layout->addItem(new QSpacerItem(2, 2), 2, 1);
+}
+
+bool CPrintDialog::exec(bool select, int size)
+{
+ if(!select)
+ {
+ itsOutput->setCurrentItem(0);
+ itsOutput->setEnabled(false);
+ }
+ else
+ itsOutput->setCurrentItem(1);
+ itsSize->setCurrentItem(size);
+ return QDialog::Accepted==QDialog::exec();
+}
+
+}
diff --git a/kcontrol/kfontinst/kcmfontinst/PrintDialog.h b/kcontrol/kfontinst/kcmfontinst/PrintDialog.h
new file mode 100644
index 000000000..9be67f6d4
--- /dev/null
+++ b/kcontrol/kfontinst/kcmfontinst/PrintDialog.h
@@ -0,0 +1,56 @@
+#ifndef __PRINT_DIALOG_H__
+#define __PRINT_DIALOG_H__
+
+////////////////////////////////////////////////////////////////////////////////
+//
+// Class Name : KFI::CPrintDialog
+// Author : Craig Drummond
+// Project : K Font Installer
+// Creation Date : 12/05/2005
+// Version : $Revision$ $Date$
+//
+////////////////////////////////////////////////////////////////////////////////
+//
+// This program is free software; you can redistribute it and/or
+// modify it under the terms of the GNU General Public License
+// as published by the Free Software Foundation; either version 2
+// of the License, or (at your option) any later version.
+//
+// This program is distributed in the hope that it will be useful,
+// but WITHOUT ANY WARRANTY; without even the implied warranty of
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+// GNU General Public License for more details.
+//
+// You should have received a copy of the GNU General Public License
+// along with this program; if not, write to the Free Software
+// Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
+//
+////////////////////////////////////////////////////////////////////////////////
+// (C) Craig Drummond, 2005
+////////////////////////////////////////////////////////////////////////////////
+
+#include <kdialogbase.h>
+#include <qcombobox.h>
+
+namespace KFI
+{
+
+class CPrintDialog : public KDialogBase
+{
+ public:
+
+ CPrintDialog(QWidget *parent);
+
+ bool exec(bool select, int size);
+ int chosenSize() { return itsSize->currentItem(); }
+ bool outputAll() { return 0==itsOutput->currentItem(); }
+
+ private:
+
+ QComboBox *itsOutput,
+ *itsSize;
+};
+
+}
+
+#endif
diff --git a/kcontrol/kfontinst/kcmfontinst/SettingsDialog.cpp b/kcontrol/kfontinst/kcmfontinst/SettingsDialog.cpp
new file mode 100644
index 000000000..255fca709
--- /dev/null
+++ b/kcontrol/kfontinst/kcmfontinst/SettingsDialog.cpp
@@ -0,0 +1,99 @@
+////////////////////////////////////////////////////////////////////////////////
+//
+// Class Name : KFI::CSettingsDialog
+// Author : Craig Drummond
+// Project : K Font Installer
+// Creation Date : 10/05/2005
+// Version : $Revision$ $Date$
+//
+////////////////////////////////////////////////////////////////////////////////
+//
+// This program is free software; you can redistribute it and/or
+// modify it under the terms of the GNU General Public License
+// as published by the Free Software Foundation; either version 2
+// of the License, or (at your option) any later version.
+//
+// This program is distributed in the hope that it will be useful,
+// but WITHOUT ANY WARRANTY; without even the implied warranty of
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+// GNU General Public License for more details.
+//
+// You should have received a copy of the GNU General Public License
+// along with this program; if not, write to the Free Software
+// Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
+//
+////////////////////////////////////////////////////////////////////////////////
+// (C) Craig Drummond, 2005
+////////////////////////////////////////////////////////////////////////////////
+
+#include "SettingsDialog.h"
+#include "KfiConstants.h"
+#include "Misc.h"
+#include <qlayout.h>
+#include <qcheckbox.h>
+#include <qvbox.h>
+#include <qwhatsthis.h>
+#include <klocale.h>
+#include <kconfig.h>
+#include <kmessagebox.h>
+#include <kio/job.h>
+#include <kio/netaccess.h>
+
+namespace KFI
+{
+
+CSettingsDialog::CSettingsDialog(QWidget *parent)
+ : KDialogBase(parent, "settingsdialog", true, i18n("Settings"),
+ KDialogBase::Ok|KDialogBase::Cancel, KDialogBase::Ok, true)
+{
+ QVBox *page = makeVBoxMainWidget();
+
+ itsDoX=new QCheckBox(i18n("Configure fonts for legacy X applications"), page);
+ QWhatsThis::add(itsDoX, i18n("<p>Modern applications use a system called \"FontConfig\" to obtain the list of fonts. "
+ "Older applications, such as OpenOffice 1.x, GIMP 1.x, etc. use the previous \"core X fonts\" mechanism for "
+ "this.</p><p>Selecting this option will inform the installer to create the necessary files so that these "
+ "older applications can use the fonts you install.</p><p>Please note, however, that this will slow down "
+ "the installation process.<p>"));
+ itsDoGs=new QCheckBox(i18n("Configure fonts for Ghostscript"), page);
+ QWhatsThis::add(itsDoGs, i18n("<p>When printing, most applications create what is know as PostScript. This is then sent to a special "
+ "application, named Ghostscript, which can interpret the PostScript and send the appropriate instructions "
+ "to your printer. If your application does not embed whatever fonts it uses into the PostScript, then "
+ "Ghostscript needs to be informed as to which fonts you have installed, and where they are located.</p>"
+ "<p>Selecting this option will create the necessary Ghostscript config files.</p><p>Please note, however, "
+ "that this will also slow down the installation process.</p><p>As most applications can, and do, embed "
+ "the fonts into the PostScript before sending this to Ghostscript, this option can safely be disabled."));
+
+ KConfig cfg(Misc::root() ? KFI_ROOT_CFG_FILE : KFI_CFG_FILE);
+
+ itsDoX->setChecked(cfg.readBoolEntry(KFI_CFG_X_KEY, KFI_DEFAULT_CFG_X));
+ itsDoGs->setChecked(cfg.readBoolEntry(KFI_CFG_GS_KEY, KFI_DEFAULT_CFG_GS));
+}
+
+void CSettingsDialog::slotOk()
+{
+ KConfig cfg(Misc::root() ? KFI_ROOT_CFG_FILE : KFI_CFG_FILE);
+
+ bool oldDoX=cfg.readBoolEntry(KFI_CFG_X_KEY, KFI_DEFAULT_CFG_X),
+ oldDoGs=cfg.readBoolEntry(KFI_CFG_GS_KEY, KFI_DEFAULT_CFG_GS);
+
+ cfg.writeEntry(KFI_CFG_X_KEY, itsDoX->isChecked());
+ cfg.writeEntry(KFI_CFG_GS_KEY, itsDoGs->isChecked());
+ cfg.sync();
+
+ if( ((!oldDoX && itsDoX->isChecked()) || (!oldDoGs && itsDoGs->isChecked())) &&
+ KMessageBox::Yes==KMessageBox::questionYesNo(this, i18n("You have enabled a previously disabled option. Would you like the config "
+ "files updated now? (Normally they are only updated upon installing, or "
+ "removing, a font.)"), QString::null, i18n("Update"),i18n("Do Not Update")))
+ {
+ QByteArray packedArgs;
+ QDataStream stream(packedArgs, IO_WriteOnly);
+
+ stream << KFI::SPECIAL_RECONFIG;
+
+ KIO::NetAccess::synchronousRun(KIO::special(KFI_KIO_FONTS_PROTOCOL ":/", packedArgs), this);
+ }
+
+ hide();
+}
+
+}
diff --git a/kcontrol/kfontinst/kcmfontinst/SettingsDialog.h b/kcontrol/kfontinst/kcmfontinst/SettingsDialog.h
new file mode 100644
index 000000000..b41820e38
--- /dev/null
+++ b/kcontrol/kfontinst/kcmfontinst/SettingsDialog.h
@@ -0,0 +1,57 @@
+#ifndef __SETTINGS_DIALOG_H__
+#define __SETTINGS_DIALOG_H__
+
+////////////////////////////////////////////////////////////////////////////////
+//
+// Class Name : KFI::CSettingsDialog
+// Author : Craig Drummond
+// Project : K Font Installer
+// Creation Date : 10/05/2005
+// Version : $Revision$ $Date$
+//
+////////////////////////////////////////////////////////////////////////////////
+//
+// This program is free software; you can redistribute it and/or
+// modify it under the terms of the GNU General Public License
+// as published by the Free Software Foundation; either version 2
+// of the License, or (at your option) any later version.
+//
+// This program is distributed in the hope that it will be useful,
+// but WITHOUT ANY WARRANTY; without even the implied warranty of
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+// GNU General Public License for more details.
+//
+// You should have received a copy of the GNU General Public License
+// along with this program; if not, write to the Free Software
+// Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
+//
+////////////////////////////////////////////////////////////////////////////////
+// (C) Craig Drummond, 2005
+////////////////////////////////////////////////////////////////////////////////
+
+#include <kdialogbase.h>
+
+class QCheckBox;
+
+namespace KFI
+{
+
+class CSettingsDialog : public KDialogBase
+{
+ public:
+
+ CSettingsDialog(QWidget *parent);
+
+ private slots:
+
+ void slotOk();
+
+ private:
+
+ QCheckBox *itsDoX,
+ *itsDoGs;
+};
+
+}
+
+#endif
diff --git a/kcontrol/kfontinst/kcmfontinst/cr16-action-newfont.png b/kcontrol/kfontinst/kcmfontinst/cr16-action-newfont.png
new file mode 100644
index 000000000..61eef357e
--- /dev/null
+++ b/kcontrol/kfontinst/kcmfontinst/cr16-action-newfont.png
Binary files differ
diff --git a/kcontrol/kfontinst/kcmfontinst/cr22-action-newfont.png b/kcontrol/kfontinst/kcmfontinst/cr22-action-newfont.png
new file mode 100644
index 000000000..049197a35
--- /dev/null
+++ b/kcontrol/kfontinst/kcmfontinst/cr22-action-newfont.png
Binary files differ
diff --git a/kcontrol/kfontinst/kcmfontinst/cr32-action-newfont.png b/kcontrol/kfontinst/kcmfontinst/cr32-action-newfont.png
new file mode 100644
index 000000000..9cd3d57bc
--- /dev/null
+++ b/kcontrol/kfontinst/kcmfontinst/cr32-action-newfont.png
Binary files differ
diff --git a/kcontrol/kfontinst/kcmfontinst/kcmfontinst.desktop b/kcontrol/kfontinst/kcmfontinst/kcmfontinst.desktop
new file mode 100644
index 000000000..e8460ab49
--- /dev/null
+++ b/kcontrol/kfontinst/kcmfontinst/kcmfontinst.desktop
@@ -0,0 +1,235 @@
+[Desktop Entry]
+Exec=kcmshell kcmfontinst
+Icon=fonts
+Type=Application
+DocPath=kcontrol/kcmfontinst/index.html
+
+
+X-KDE-Library=fontinst
+X-KDE-FactoryName=fontinst
+X-KDE-RootOnly=true
+
+X-KDE-ParentApp=kcontrol
+
+Name=Font Installer
+Name[af]=Skrif tipe Installeerder
+Name[ar]=مثبت المحارف
+Name[az]=Yazı Növü Qurucusu
+Name[be]=Устаноўка шрыфтоў
+Name[bg]=Шрифтове
+Name[bn]=ফন্ট ইনস্টলার
+Name[br]=Stalianer an nodrezhoù
+Name[bs]=Dodavanje fontova
+Name[ca]=Instal·lador de lletres
+Name[cs]=Instalátor písem
+Name[csb]=Instalownik fòntów
+Name[cy]=Gosodydd Ffontiau
+Name[da]=Skrifttype-installering
+Name[de]=Schriftarteninstallation
+Name[el]=Εγκαταστάτης γραμματοσειρών
+Name[eo]=Tiparinstalilo
+Name[es]=Instalador de tipos de letra
+Name[et]=Fontide paigaldaja
+Name[eu]=Letra tipoak instalatzeko tresna
+Name[fa]=نصب‌کنندۀ قلم
+Name[fi]=Kirjasinasentaja
+Name[fr]=Installateur de polices
+Name[fy]=Lettertype-Ynstalaasje
+Name[ga]=Suiteálaí Clófhoirne
+Name[gl]=Instalador de Fontes
+Name[he]=מתקין הגופנים
+Name[hi]=फ़ॉन्ट संस्थापक
+Name[hr]=Instaliranje fontova
+Name[hu]=Betűtípus-telepítő
+Name[is]=KDE letursækir
+Name[it]=Installatore dei tipi di carattere
+Name[ja]=フォントインストーラ
+Name[ka]=ფონტების დაყენება
+Name[kk]=Қаріптерді орнату
+Name[km]=កម្មវិធី​ដំឡើង​ពុម្ពអក្សរ
+Name[ko]=글꼴 설치기
+Name[lo]=ຕິດຕັ້ງຮູບແບບຕົວອັກສອນ
+Name[lt]=Šriftų diegiklis
+Name[lv]=Fontu Instalators
+Name[mk]=Инсталатор на фонтови
+Name[mn]=Бичиг-Суулгалт
+Name[ms]=Pemasang Fon
+Name[mt]=Installatur ta' fonts
+Name[nb]=Skriftinstallering
+Name[nds]=Schriftoorden installeren
+Name[ne]=फन्ट स्थापक
+Name[nl]=Lettertype-installatie
+Name[nn]=Skriftinstallering
+Name[nso]=Motsenyi wa Fonto
+Name[pa]=ਫੋਂਟ ਇੰਸਟਾਲਰ
+Name[pl]=Instalator czcionek
+Name[pt]=Instalador de Tipos de Letra
+Name[pt_BR]=Instalador de Fontes
+Name[ro]=Instalare fonturi
+Name[ru]=Установка шрифтов
+Name[rw]=Mwinjizaporogaramu Imyandikire
+Name[se]=Fontasajáiduhttejeaddji
+Name[sk]=Inštalátor písiem
+Name[sl]=Namestilnik pisav
+Name[sr]=Инсталатор фонтова
+Name[sr@Latn]=Instalator fontova
+Name[sv]=Installation av teckensnitt
+Name[ta]=எழுத்துரு நிறுவுதல்
+Name[tg]=Барпо кардани ҳарфҳо
+Name[th]=ตัวติดตั้งแบบอักษร
+Name[tr]=Yazıtipi Kurucusu
+Name[tt]=Yazu Quydırğıç
+Name[uk]=Встановлення шрифтів
+Name[uz]=Shrift oʻrnatgich
+Name[uz@cyrillic]=Шрифт ўрнатгич
+Name[ven]=Mudzhenisi wa Fontu
+Name[vi]=Cài đặt Phông chữ
+Name[wa]=Astaleu di fontes
+Name[xh]=Umfaki Wohlobo lwegama
+Name[zh_CN]=字体安装程序
+Name[zh_TW]=字型安裝程式
+Name[zu]=Umfakeli Wohlobo lwamagama
+
+Comment=Install & preview fonts
+Comment[af]=Installeer & voorskou skriftipes
+Comment[ar]=تثبيت و معاينة المحارف
+Comment[az]=Yazı növü qur & nümayiş et
+Comment[be]=Устаноўка і прагляд шрыфтоў
+Comment[bg]=Инсталиране и преглед на шрифтове
+Comment[bn]=ফন্ট ইনস্টল এবং প্রাক্‌দর্শন করুন
+Comment[br]=Staliañ ha rakgwel an nodrezhoù
+Comment[bs]=Dodavanje i pregledanje fontova
+Comment[ca]=Instal·la i previsualitza lletres
+Comment[cs]=Instalace a náhled písem
+Comment[csb]=Instalacëjô ë pòdzérk fòntów
+Comment[cy]=Gosod a rhagolygu ffontiau
+Comment[da]=Installér og forhåndsvis skrifttyper
+Comment[de]=Schriftarten installieren und betrachten
+Comment[el]=Εγκατάσταση & προεπισκόπηση γραμματοσειρών
+Comment[eo]=Instalas kaj prezentas tiparojn
+Comment[es]=Instalar y previsualizar tipos de letra
+Comment[et]=Fontide paigaldamine ja eelvaatlus
+Comment[eu]=Instalatu eta aurreikusi letra tipoak
+Comment[fa]=نصب و پیش‌نمایش قلمها
+Comment[fi]=Asenna ja esikatsele kirjasimia
+Comment[fr]=Pour installer et afficher des polices de caractères
+Comment[fy]=Lettertypen ynstallearje en besjen
+Comment[ga]=Suiteáil & Réamhamharc na gClónna
+Comment[gl]=Instalar e antever fontes
+Comment[he]=התקנה ותצוגה מקדימה של גופנים
+Comment[hi]=फ़ॉन्ट्स संस्थापित व पूर्वावलोकन करें
+Comment[hr]=Instaliranje i pregled fontova
+Comment[hu]=Betűtípusok telepítése, áttekintése
+Comment[is]=Setja inn & forskoða letur
+Comment[it]=Installa e mostra anteprime dei caratteri
+Comment[ja]=フォントのインストールとプレビュー
+Comment[ka]=ფონტების დაყენება და დათვალიერება
+Comment[kk]=Қаріптерді орнату және қарап-шығу
+Comment[km]=ដំឡើង & មើល​ពុម្ពអក្សរ​ជា​មុន
+Comment[ko]=글꼴 설치, 미리보기, 관리
+Comment[lo]=ຕິດຕັ້ງແລະສະແດງຕົວຢ່າງຮູບແບບຕົວອັກສອນ
+Comment[lt]=Instaliuoja ir peržiūri šriftus
+Comment[lv]=Instalē un apskata fontus
+Comment[mk]=Инсталирај и прегледај фонтови
+Comment[mn]=Бичиг суулгах ба харах
+Comment[ms]=Pasang & prapapar fon
+Comment[mt]=Installa u ara fonts
+Comment[nb]=Installer og forhåndsvis skrifttyper
+Comment[nds]=Schriftoorden installeren & ankieken
+Comment[ne]=फन्ट स्थापना र पूर्वावलोकन गर्नुहोस्
+Comment[nl]=Lettertypen installeren en bekijken
+Comment[nn]=Installer og vis skrifter
+Comment[nso]=Tsenya & Bonelapele difonto
+Comment[pa]=ਫੋਂਟ ਝਲਕ ਤੇ ਇੰਸਟਾਲ
+Comment[pl]=Instalacja i podgląd czcionek
+Comment[pt]=Instalar e antever tipos de letra
+Comment[pt_BR]=Instalar & pré-visualizar fontes
+Comment[ro]=Instalează și previzualizează fonturi
+Comment[ru]=Установка и просмотр шрифтов
+Comment[rw]=Kwinjiza & kugaragazambere imyandikire
+Comment[se]=Sajáiduhtte ja čájet fonttaid
+Comment[sk]=Inštaluje a zobrazuje písma
+Comment[sl]=Namesti in prikaže pisave
+Comment[sr]=Инсталација и преглед фонтова
+Comment[sr@Latn]=Instalacija i pregled fontova
+Comment[sv]=Installera och förhandsgranska teckensnitt
+Comment[ta]=எழுத்துருக்களை நிறுவி காட்டு
+Comment[tg]=Барпо кардан ва тамошои ҳарфҳо
+Comment[th]=ติดตั้งและแสดงตัวอย่างแบบอักษร
+Comment[tr]=Yazıtiplerini kur ve önizle
+Comment[tt]=Yazu şäkellären quyu/tikşerü urını
+Comment[uk]=Встановлення та перегляд шрифтів
+Comment[uz]=Shriftlarni oʻrnatish va koʻrib chiqish
+Comment[uz@cyrillic]=Шрифтларни ўрнатиш ва кўриб чиқиш
+Comment[ven]=Dzhenisani & vhonelani phanda dzifontu
+Comment[vi]=Cài đặt & xem trước phông chữ
+Comment[wa]=Astalaedje et håynaedje des fontes
+Comment[xh]=Faka & yenza imboniso yohlobo lwamagama
+Comment[zh_CN]=安装和预览字体
+Comment[zh_TW]=安裝並預覽字型
+Comment[zu]=Fakela & buka ngaphambili izinhlobo zamagama
+
+Keywords=font,fonts,installer,truetype,type1,speedo,bitmap
+Keywords[be]=Шрыфт,Шрыфты,Устаноўка,font,fonts,installer,truetype,type1,speedo,bitmap
+Keywords[bg]=шрифт, шрифтове, преглед, печат, font, fonts, installer, truetype, type1, speedo, bitmap
+Keywords[br]=nodrezh,nodrezhoù,stalier,truetype,type1,speedo,bitmap
+Keywords[bs]=font,fonts,installer,truetype,type1,speedo,bitmap,fontovi,instalacija
+Keywords[ca]=lletra,lletres,instal·lador,truetype,type1,speedo,bitmap
+Keywords[cs]=písmo,písma,instalátor,truetype,type1,speedo,bitmap
+Keywords[csb]=fòntë,font,instalownik,truetype,type1,speedo
+Keywords[cy]=ffont,ffontiau,wynebfath, wynebfathau,arsefydlydd,truetype,type1,math 1,speedo,didfap
+Keywords[da]=skrifttype,skrifttyper,installatør,truetype,type1,speedo,bitmap
+Keywords[de]=Fonts,Schriftarten,Installation,TrueType,Type1,Speedo,Bitmapschriften
+Keywords[el]=γραμματοσειρά,γραμματοσειρές,εγκαταστάτης,truetype,type1,speedo,bitmap
+Keywords[eo]=tiparo,tiparoj,instalilo,ŝangebla,neŝangebla
+Keywords[es]=tipo de letra,tipos de letra,instalador,truetype,type1,speedo,bitmap
+Keywords[et]=font,fondid,paigaldaja,truetype,type1,speedo,bitmap
+Keywords[eu]=letra-tipoa,letra-tipoak,instalatzailea,truetype,type1,speedo,bitmap
+Keywords[fa]=قلم، قلمها، نصب‌کننده، قلم حقیقی، نوع۱ ،speedo، نگاشت بیت،
+Keywords[fi]=kirjasin,kirjasimet,fontti,fontit,asentaja,truetype,type1,speedo,bitmap
+Keywords[fr]=police,polices,installeur,installateur,truetype,type1,speedo,bitmap
+Keywords[fy]=letters,lettertypen,fonts,Ynstalaasje,truetype,type1,speedo,bitmap
+Keywords[ga]=cló,clónna,clófhoirne,suiteálaí,truetype,type1,speedo,mapa giotán,giotánmhapach
+Keywords[gl]=fonte,fontes,instalador,truetype,type1,speedo,bitmap
+Keywords[he]=גופנים,גופן, מתקין, TrueType, Type1, speedo, מפת סיביות, bitmap, font,fonts,installer,truetype,type1,speedo,bitmap
+Keywords[hi]=फ़ॉन्ट,फ़ॉन्ट्स,संस्थापक,ट्रू-टाइप,टाइप-1,स्पीडो,बिटमैप
+Keywords[hr]=font,fonts,installer,truetype,type1,speedo,bitmap,fontovi,instaliranje,TTF
+Keywords[hu]=betűtípus,betűtípusok,telepítő,TrueType,Type1,Speedo,bittérkép
+Keywords[is]=font,fonts,installer,truetype,type1,speedo,bitmap,letur
+Keywords[it]=font,caratteri,installatore,truetype,type1,speedo,bitmap,tipi di carattere
+Keywords[ja]=フォント,インストーラ,truetype,type1,speedo,bitmap,ビットマップ
+Keywords[ka]=ფონტი,ფონტები,დასაყენებელი,truetype,type1,speedo,bitmap
+Keywords[km]=ពុម្ពអក្សរ,កម្មវិធី​ដំឡើង,truetype,type1,speedo,bitmap
+Keywords[lt]=šriftas,šriftai,įdiegimas,truetype,type1,speedo,bitmap
+Keywords[lv]=fonti,fonts,instalēt,truetype,type1,speedo,bitmap
+Keywords[mk]=font,fonts,installer,truetype,type1,speedo,bitmap,фонт,фонтови,инсталатор
+Keywords[nb]=skrift,skrifter,skrifttype,skrifttyper,installer,truetype,type1,speedo,bitmap
+Keywords[nds]=Schriftoort,Schriftoorden,Installeren,TrueType,Type1,Speedo,Bitmap
+Keywords[ne]=फन्ट, फन्टहरू, स्थापक, ट्रु टाइप, टाइप १, स्पेडो, बिटम्याप
+Keywords[nl]=letters,lettertypen,fonts,installatie,truetype,type1,speedo,bitmap
+Keywords[nn]=skrift,skrifter,installering,truetype,type1,speedo,bitmap
+Keywords[pa]=font,fonts,installer,truetype,type1,speedo,bitmap, ਫੋਂਟ, ਇੰਸਟਾਲਰ
+Keywords[pl]=czcionka,czcionki,font,instalator,truetype,type1,speedo
+Keywords[pt]=tipo de letra,tipos de letra,instalador,truetype,type1,speedo,imagem
+Keywords[pt_BR]=fonte,fontes,instalador,truetype,type1,speedo,bitmap
+Keywords[ro]=font,fonturi,instalator,truetype,type1,speedo,bitmap
+Keywords[ru]=font,fonts,installer,truetype,type1,speedo,bitmap,шрифты
+Keywords[rw]=Imyandikire,imyandikire,mwinjiza,ubwokonyabwo,ubwoko1,umuvuduko,bitimapu
+Keywords[se]=fonta,fonttat,sajáiduhttejeaddji,truetype,type1,speedo,bitmap
+Keywords[sk]=písmo,písma,inštalátor,truetype,type1,speedo,bitmap
+Keywords[sl]=pisava,pisave,namestilnik,truetype,type1,speedo,bitmap
+Keywords[sr]=font,fonts,installer,truetype,type1,speedo,bitmap,фонт,фонтови,инсталер,битмапа
+Keywords[sr@Latn]=font,fonts,installer,truetype,type1,speedo,bitmap,font,fontovi,instaler,bitmapa
+Keywords[sv]=teckensnitt,installation,truetype,type1,speedo,bitmap
+Keywords[ta]=எழுத்துரு,எழுத்துருக்கள்,அமர்வர்,மெய்வகை,வகை1,speedo,பிட்படம்
+Keywords[th]=แบบอักษร,ตัวติดตั้ง,ทรูไทป์,ไทป์1,speedo,บิตแมป
+Keywords[tr]=yazıtipi,yazıtipleri,kurucu,truetype,type1,speedo,bitmap
+Keywords[uk]=шрифт, шрифти,встановлення,векторний,растровий,truetype,type1,speedo
+Keywords[uz]=shrift,shriftlar,oʻrnatuvchi,bitmap,truetype,type1,speedo
+Keywords[uz@cyrillic]=шрифт,шрифтлар,ўрнатувчи,битмап,truetype,type1,speedo
+Keywords[vi]=phông chữ,các phông chữ,trình cài đặt,truetype,kiểu 1,tốc độ gõ,mảng ảnh
+Keywords[wa]=fonte,fontes,astaleu,truetype,type1,speedo,bitmap
+Keywords[zh_CN]=font,fonts,installer,truetype,type1,speedo,bitmap,字体,安装程序,位图字体
+Keywords[zh_TW]=font,fonts,installer,truetype,type1,speedo,bitmap,字型,安裝程式,點陣
+
+Categories=Qt;KDE;X-KDE-settings-system;