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
9
* modify it under the terms of the GNU General Public
10
* License version 2 as published by the Free Software Foundation.
12
* This program is distributed in the hope that it will be useful,
13
* but WITHOUT ANY WARRANTY; without even the implied warranty of
14
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
15
* General Public License for more details.
17
* You should have received a copy of the GNU General Public License
18
* along with this program; see the file COPYING. If not, write to
19
* the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
20
* Boston, MA 02110-1301, USA.
24
#include "KfiConstants.h"
25
#include <kcmdlineargs.h>
26
#include <kaboutdata.h>
27
#include <kapplication.h>
28
#include <klibloader.h>
31
#include <kfiledialog.h>
33
#include <kstandardaction.h>
34
#include <kactioncollection.h>
35
#include <kparts/browserextension.h>
37
#define CFG_GROUP "FontViewer Settings"
38
#define CFG_SIZE_KEY "Window Size"
45
KPluginFactory *factory=KLibLoader::self()->factory("libkfontviewpart");
49
itsPreview=factory->create<KParts::ReadOnlyPart>(this);
51
actionCollection()->addAction(KStandardAction::Open, this, SLOT(fileOpen()));
52
actionCollection()->addAction(KStandardAction::Quit, kapp, SLOT(quit()));
53
itsPrintAct=actionCollection()->addAction(KStandardAction::Print, itsPreview, SLOT(print()));
55
itsPrintAct->setEnabled(false);
57
if(itsPreview->browserExtension())
58
connect(itsPreview->browserExtension(), SIGNAL(enableAction(const char *, bool)),
59
this, SLOT(enableAction(const char *, bool)));
61
setCentralWidget(itsPreview->widget());
62
createGUI(itsPreview);
64
KCmdLineArgs *args(KCmdLineArgs::parsedArgs());
68
KUrl url(args->url(args->count() - 1));
71
itsPreview->openUrl(url);
74
QSize defSize(440, 530);
76
resize(KGlobal::config()->group(CFG_GROUP).readEntry(CFG_SIZE_KEY, defSize));
84
KGlobal::config()->group(CFG_GROUP).writeEntry(CFG_SIZE_KEY, size());
85
KGlobal::config()->sync();
88
void CViewer::fileOpen()
90
KUrl url(KFileDialog::getOpenUrl(KUrl(), "application/x-font-ttf application/x-font-otf "
91
"application/x-font-type1 "
92
"application/x-font-bdf application/x-font-pcf ",
93
this, i18n("Select Font to View")));
95
itsPreview->openUrl(url);
98
void CViewer::enableAction(const char *name, bool enable)
100
if(0==qstrcmp("print", name))
101
itsPrintAct->setEnabled(enable);
106
static KAboutData aboutData("kfontview", KFI_CATALOGUE, ki18n("Font Viewer"), "1.1", ki18n("Simple font viewer"),
107
KAboutData::License_GPL, ki18n("(C) Craig Drummond, 2004-2007"));
109
int main(int argc, char **argv)
111
KCmdLineArgs::init(argc, argv, &aboutData);
113
KCmdLineOptions options;
114
options.add("+[URL]", ki18n("URL to open"));
115
KCmdLineArgs::addCmdLineOptions(options);
119
KFI::CViewer *viewer=new KFI::CViewer;
125
#include "Viewer.moc"