diff options
Diffstat (limited to 'kpdf/shell')
-rw-r--r-- | kpdf/shell/Makefile.am | 15 | ||||
-rw-r--r-- | kpdf/shell/kpdf.desktop | 82 | ||||
-rw-r--r-- | kpdf/shell/main.cpp | 82 | ||||
-rw-r--r-- | kpdf/shell/shell.cpp | 262 | ||||
-rw-r--r-- | kpdf/shell/shell.h | 112 | ||||
-rw-r--r-- | kpdf/shell/shell.rc | 21 |
6 files changed, 574 insertions, 0 deletions
diff --git a/kpdf/shell/Makefile.am b/kpdf/shell/Makefile.am new file mode 100644 index 00000000..e8416ef1 --- /dev/null +++ b/kpdf/shell/Makefile.am @@ -0,0 +1,15 @@ +INCLUDES = -I$(srcdir)/xpdf -I$(srcdir)/xpdf/goo -I$(top_builddir)/kpdf $(all_includes) $(FREETYPE_CFLAGS) + +METASOURCES = AUTO + +bin_PROGRAMS = kpdf + +kpdf_SOURCES = main.cpp shell.cpp +kpdf_LDFLAGS = $(KDE_RPATH) $(all_libraries) +kpdf_LDADD = $(LIB_KPARTS) + +EXTRA_DIST = kpdf.desktop +xdg_apps_DATA = kpdf.desktop + +shellrcdir = $(kde_datadir)/kpdf +shellrc_DATA = shell.rc diff --git a/kpdf/shell/kpdf.desktop b/kpdf/shell/kpdf.desktop new file mode 100644 index 00000000..a276611d --- /dev/null +++ b/kpdf/shell/kpdf.desktop @@ -0,0 +1,82 @@ +[Desktop Entry] +MimeType=application/pdf; +Terminal=false +Name=KPDF +Name[ar]=برنامج KPDF +Name[hi]=के-पीडीएफ +Name[zh_TW]=KPDF 檢視器 +GenericName=PDF Viewer +GenericName[ar]=عارض ملفات PDF +GenericName[az]=PDF Nümayişçisi +GenericName[bg]=Преглед на документи PDF +GenericName[br]=Gweler PDF +GenericName[bs]=Preglednik PDF dokumenata +GenericName[ca]=Visualitzador de PDF +GenericName[cs]=Prohlížeč PDF souborů +GenericName[cy]=Gwelydd PDF +GenericName[da]=PDF-fremviser +GenericName[de]=PDF-Betrachter +GenericName[el]=Προβολέας PDF +GenericName[eo]=PDF-rigardilo +GenericName[es]=Visor de PDF +GenericName[et]=PDF-failide näitaja +GenericName[eu]=PDF ikustailua +GenericName[fa]=مشاهدهگر PDF +GenericName[fi]=PDF-näytin +GenericName[fr]=Afficheur PDF +GenericName[ga]=Amharcán PDF +GenericName[gl]=Visor PDF +GenericName[he]=מציג PDF +GenericName[hi]=पीडीएफ प्रदर्शक +GenericName[hr]=Preglednik PDF dokumenata +GenericName[hu]=PDF-nézegető +GenericName[id]=Viewer PDF +GenericName[is]=PDF sjá +GenericName[it]=Visore PDF +GenericName[ja]=PDF ビューア +GenericName[kk]=PDF файлдарын қарау +GenericName[km]=កម្មវិធីមើល PDF +GenericName[lt]=PDF Žiūriklis +GenericName[lv]=PDF Skatītājs +GenericName[mk]=Прикажувач на PDF датотеки +GenericName[ms]=Pemapar PDF +GenericName[mt]=Werrej PDF +GenericName[nb]=PDF-fremviser +GenericName[nds]=PDF-Kieker +GenericName[ne]=PDF दर्शक +GenericName[nl]=PDF-weergaveprogramma +GenericName[nn]=PDF-lesar +GenericName[pa]=PDF ਦਰਸ਼ਕ +GenericName[pl]=Przeglądarka plików PDF +GenericName[pt]=Visualizador de PDFs +GenericName[pt_BR]=Visualizador de arquivos PDF +GenericName[ro]=Vizualizor PDF +GenericName[ru]=Просмотр PDF +GenericName[rw]=Mugaragaza PDF +GenericName[se]=PDF-čájeheaddji +GenericName[sk]=Prehliadač PDF +GenericName[sl]=Pregledovalnik datotek PDF +GenericName[sr]=PDF приказивач +GenericName[sr@Latn]=PDF prikazivač +GenericName[sv]=PDF-visare +GenericName[ta]=PS/PDF காட்சி +GenericName[tg]=Хондани санадоти PDF +GenericName[th]=ตัวแสดงผล PDF +GenericName[tr]=PDF Görüntüleyici +GenericName[uk]=Переглядач PDF +GenericName[uz]=PDF koʻruvchi +GenericName[uz@cyrillic]=PDF кўрувчи +GenericName[ven]=Tshivhoni tsha PDF +GenericName[wa]=Håyneu di documints PDF +GenericName[xh]=Umboniseli we PDF +GenericName[zh_CN]=PDF 查看器 +GenericName[zh_HK]=PDF 檢視器 +GenericName[zh_TW]=PDF 檢視器 +GenericName[zu]=Umboniseli we PDF +Exec=kpdf %U %i -caption "%c" +Icon=kpdf +Type=Application +DocPath=kpdf/index.html +InitialPreference=7 +Categories=Qt;KDE;Graphics;Viewer; + diff --git a/kpdf/shell/main.cpp b/kpdf/shell/main.cpp new file mode 100644 index 00000000..20aa3eee --- /dev/null +++ b/kpdf/shell/main.cpp @@ -0,0 +1,82 @@ +/*************************************************************************** + * Copyright (C) 2002 by Wilco Greven <greven@kde.org> * + * Copyright (C) 2003 by Christophe Devriese * + * <Christophe.Devriese@student.kuleuven.ac.be> * + * Copyright (C) 2003 by Laurent Montel <montel@kde.org> * + * Copyright (C) 2003-2004 by Albert Astals Cid <tsdgeos@terra.es> * + * Copyright (C) 2004 by Andy Goossens <andygoossens@telenet.be> * + * * + * 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. * + ***************************************************************************/ + +#include "shell.h" +#include <kapplication.h> +#include <kaboutdata.h> +#include <kcmdlineargs.h> +#include <klocale.h> + +static const char description[] = +I18N_NOOP("kpdf, a kde pdf viewer based on xpdf"); + +static const char version[] = "0.5.10"; + +static KCmdLineOptions options[] = +{ + { "+[URL]", I18N_NOOP("Document to open"), 0 }, + KCmdLineLastOption +}; + +int main(int argc, char** argv) +{ + KAboutData about( + "kpdf", + I18N_NOOP("KPDF"), + version, + description, + KAboutData::License_GPL, + "(C) 2002 Wilco Greven, Christophe Devriese\n(C) 2004-2005 Albert Astals Cid, Enrico Ros"); + + about.addAuthor("Wilco Greven", 0, "greven@kde.org"); + about.addAuthor("Christophe Devriese", 0, "oelewapperke@oelewapperke.org"); + about.addAuthor("Laurent Montel", 0, "montel@kde.org"); + about.addAuthor("Albert Astals Cid", I18N_NOOP("Current mantainer"), "astals11@terra.es"); + about.addAuthor("Enrico Ros", 0, "eros.kde@email.it"); + + about.addCredit("Derek Noonburg", I18N_NOOP("Xpdf author"), 0, "http://www.foolabs.com/xpdf/"); + about.addCredit("Marco Martin", I18N_NOOP("Icon"), 0, "m4rt@libero.it"); + + KCmdLineArgs::init(argc, argv, &about); + KCmdLineArgs::addCmdLineOptions( options ); + KApplication app; + + // see if we are starting with session management + if (app.isRestored()) + { + RESTORE(KPDF::Shell); + } else { + // no session.. just start up normally + KCmdLineArgs* args = KCmdLineArgs::parsedArgs(); + + if (args->count() == 0) + { + KPDF::Shell* widget = new KPDF::Shell; + widget->show(); + } + else + { + for (int i = 0; i < args->count(); ++i) + { + KPDF::Shell* widget = new KPDF::Shell(args->url(i)); + widget->show(); + } + } + args->clear(); + } + + return app.exec(); +} + +// vim:ts=2:sw=2:tw=78:et diff --git a/kpdf/shell/shell.cpp b/kpdf/shell/shell.cpp new file mode 100644 index 00000000..82b18fa6 --- /dev/null +++ b/kpdf/shell/shell.cpp @@ -0,0 +1,262 @@ +/*************************************************************************** + * Copyright (C) 2002 by Wilco Greven <greven@kde.org> * + * Copyright (C) 2002 by Chris Cheney <ccheney@cheney.cx> * + * Copyright (C) 2003 by Benjamin Meyer <benjamin@csh.rit.edu> * + * Copyright (C) 2003-2004 by Christophe Devriese * + * <Christophe.Devriese@student.kuleuven.ac.be> * + * Copyright (C) 2003 by Laurent Montel <montel@kde.org> * + * Copyright (C) 2003-2004 by Albert Astals Cid <tsdgeos@terra.es> * + * Copyright (C) 2003 by Luboš Luňák <l.lunak@kde.org> * + * Copyright (C) 2003 by Malcolm Hunter <malcolm.hunter@gmx.co.uk> * + * Copyright (C) 2004 by Dominique Devriese <devriese@kde.org> * + * Copyright (C) 2004 by Dirk Mueller <mueller@kde.org> * + * * + * 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. * + ***************************************************************************/ + +// qt/kde includes +#include <qcursor.h> +#include <qtimer.h> +#include <kaction.h> +#include <kapplication.h> +#include <kedittoolbar.h> +#include <kfiledialog.h> +#include <klibloader.h> +#include <kmessagebox.h> +#include <kstdaction.h> +#include <kurl.h> +#include <kdebug.h> +#include <klocale.h> +#include <kmenubar.h> +#include <kparts/componentfactory.h> +#include <kio/netaccess.h> +#include <kmainwindowiface.h> + +// local includes +#include "shell.h" + +using namespace KPDF; + +Shell::Shell() + : KParts::MainWindow(0, "KPDF::Shell"), m_menuBarWasShown(true), m_toolBarWasShown(true) +{ + init(); +} + +Shell::Shell(const KURL &url) + : KParts::MainWindow(0, "KPDF::Shell"), m_menuBarWasShown(true), m_toolBarWasShown(true) +{ + m_openUrl = url; + init(); +} + +void Shell::init() +{ + // set the shell's ui resource file + setXMLFile("shell.rc"); + + // this routine will find and load our Part. it finds the Part by + // name which is a bad idea usually.. but it's alright in this + // case since our Part is made for this Shell + KParts::Factory *factory = (KParts::Factory *) KLibLoader::self()->factory("libkpdfpart"); + if (factory) + { + // now that the Part is loaded, we cast it to a Part to get + // our hands on it + m_part = (KParts::ReadOnlyPart*) factory->createPart(this, "kpdf_part", this, 0, "KParts::ReadOnlyPart"); + if (m_part) + { + // then, setup our actions + setupActions(); + // tell the KParts::MainWindow that this is indeed the main widget + setCentralWidget(m_part->widget()); + // and integrate the part's GUI with the shell's + setupGUI(Keys | Save); + createGUI(m_part); + m_showToolBarAction = static_cast<KToggleAction*>(toolBarMenuAction()); + } + } + else + { + // if we couldn't find our Part, we exit since the Shell by + // itself can't do anything useful + KMessageBox::error(this, i18n("Unable to find kpdf part.")); + m_part = 0; + return; + } + connect( this, SIGNAL( restoreDocument(KConfig*) ),m_part, SLOT( restoreDocument(KConfig*))); + connect( this, SIGNAL( saveDocumentRestoreInfo(KConfig*) ), m_part, SLOT( saveDocumentRestoreInfo(KConfig*))); + connect( m_part, SIGNAL( enablePrintAction(bool) ), m_printAction, SLOT( setEnabled(bool))); + + readSettings(); + if (!KGlobal::config()->hasGroup("MainWindow")) + { + KMainWindowInterface kmwi(this); + kmwi.maximize(); + } + setAutoSaveSettings(); + + if (m_openUrl.isValid()) QTimer::singleShot(0, this, SLOT(delayedOpen())); +} + +void Shell::delayedOpen() +{ + openURL(m_openUrl); +} + +Shell::~Shell() +{ + if(m_part) writeSettings(); +} + +void Shell::openURL( const KURL & url ) +{ + if ( m_part ) + { + bool openOk = m_part->openURL( url ); + if ( openOk ) + m_recent->addURL( url ); + else + m_recent->removeURL( url ); + } +} + + +void Shell::readSettings() +{ + m_recent->loadEntries( KGlobal::config() ); + m_recent->setEnabled( true ); // force enabling + m_recent->setToolTip( i18n("Click to open a file\nClick and hold to open a recent file") ); + + KGlobal::config()->setDesktopGroup(); + bool fullScreen = KGlobal::config()->readBoolEntry( "FullScreen", false ); + setFullScreen( fullScreen ); +} + +void Shell::writeSettings() +{ + m_recent->saveEntries( KGlobal::config() ); + KGlobal::config()->setDesktopGroup(); + KGlobal::config()->writeEntry( "FullScreen", m_fullScreenAction->isChecked()); + KGlobal::config()->sync(); +} + +void Shell::setupActions() +{ + KAction * openAction = KStdAction::open(this, SLOT(fileOpen()), actionCollection()); + m_recent = KStdAction::openRecent( this, SLOT( openURL( const KURL& ) ), actionCollection() ); + connect( m_recent, SIGNAL( activated() ), openAction, SLOT( activate() ) ); + m_recent->setWhatsThis( i18n( "<b>Click</b> to open a file or <b>Click and hold</b> to select a recent file" ) ); + m_printAction = KStdAction::print( m_part, SLOT( slotPrint() ), actionCollection() ); + m_printAction->setEnabled( false ); + KStdAction::quit(this, SLOT(slotQuit()), actionCollection()); + + setStandardToolBarMenuEnabled(true); + + m_showMenuBarAction = KStdAction::showMenubar( this, SLOT( slotShowMenubar() ), actionCollection()); + KStdAction::configureToolbars(this, SLOT(optionsConfigureToolbars()), actionCollection()); + m_fullScreenAction = KStdAction::fullScreen( this, SLOT( slotUpdateFullScreen() ), actionCollection(), this ); +} + +void Shell::saveProperties(KConfig* config) +{ + // the 'config' object points to the session managed + // config file. anything you write here will be available + // later when this app is restored + emit saveDocumentRestoreInfo(config); +} + +void Shell::readProperties(KConfig* config) +{ + // the 'config' object points to the session managed + // config file. this function is automatically called whenever + // the app is being restored. read in here whatever you wrote + // in 'saveProperties' + if(m_part) + { + emit restoreDocument(config); + } +} + + void +Shell::fileOpen() +{ + // this slot is called whenever the File->Open menu is selected, + // the Open shortcut is pressed (usually CTRL+O) or the Open toolbar + // button is clicked + KURL url = KFileDialog::getOpenURL( QString::null, "application/pdf application/postscript" );//getOpenFileName(); + + if (!url.isEmpty()) + openURL(url); +} + + void +Shell::optionsConfigureToolbars() +{ + KEditToolbar dlg(factory()); + connect(&dlg, SIGNAL(newToolbarConfig()), this, SLOT(applyNewToolbarConfig())); + dlg.exec(); +} + + void +Shell::applyNewToolbarConfig() +{ + applyMainWindowSettings(KGlobal::config(), "MainWindow"); +} + +void Shell::slotQuit() +{ + kapp->closeAllWindows(); +} + +// only called when starting the program +void Shell::setFullScreen( bool useFullScreen ) +{ + if( useFullScreen ) + showFullScreen(); + else + showNormal(); +} + +void Shell::slotUpdateFullScreen() +{ + if(m_fullScreenAction->isChecked()) + { + m_menuBarWasShown = m_showMenuBarAction->isChecked(); + m_showMenuBarAction->setChecked(false); + menuBar()->hide(); + + m_toolBarWasShown = m_showToolBarAction->isChecked(); + m_showToolBarAction->setChecked(false); + toolBar()->hide(); + + showFullScreen(); + } + else + { + if (m_menuBarWasShown) + { + m_showMenuBarAction->setChecked(true); + menuBar()->show(); + } + if (m_toolBarWasShown) + { + m_showToolBarAction->setChecked(true); + toolBar()->show(); + } + showNormal(); + } +} + +void Shell::slotShowMenubar() +{ + if ( m_showMenuBarAction->isChecked() ) + menuBar()->show(); + else + menuBar()->hide(); +} + +#include "shell.moc" diff --git a/kpdf/shell/shell.h b/kpdf/shell/shell.h new file mode 100644 index 00000000..f92df5ce --- /dev/null +++ b/kpdf/shell/shell.h @@ -0,0 +1,112 @@ +/*************************************************************************** + * Copyright (C) 2002 by Wilco Greven <greven@kde.org> * + * Copyright (C) 2003 by Benjamin Meyer <benjamin@csh.rit.edu> * + * Copyright (C) 2003 by Laurent Montel <montel@kde.org> * + * Copyright (C) 2003 by Luboš Luňák <l.lunak@kde.org> * + * Copyright (C) 2004 by Christophe Devriese * + * <Christophe.Devriese@student.kuleuven.ac.be> * + * Copyright (C) 2004 by Albert Astals Cid <tsdgeos@terra.es> * + * * + * 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. * + ***************************************************************************/ + +#ifndef _KPDF_SHELL_H_ +#define _KPDF_SHELL_H_ + +#ifdef HAVE_CONFIG_H +#include <config.h> +#endif + +#include <kparts/mainwindow.h> + +namespace KPDF +{ + class Part; + /** + * This is the application "Shell". It has a menubar and a toolbar + * but relies on the "Part" to do all the real work. + * + * @short Application Shell + * @author Wilco Greven <greven@kde.org> + * @version 0.1 + */ + class Shell : public KParts::MainWindow + { + Q_OBJECT + + public: + /** + * Default Constructor + */ + Shell(); + + /** + * Open an url + */ + Shell(const KURL &url); + + /** + * Default Destructor + */ + virtual ~Shell(); + + protected: + /** + * This method is called when it is time for the app to save its + * properties for session management purposes. + */ + void saveProperties(KConfig*); + + /** + * This method is called when this app is restored. The KConfig + * object points to the session management config file that was saved + * with @ref saveProperties + */ + void readProperties(KConfig*); + void readSettings(); + void writeSettings(); + void setFullScreen( bool ); + + public slots: + void slotQuit(); + + private slots: + void fileOpen(); + + void optionsConfigureToolbars(); + void applyNewToolbarConfig(); + void slotUpdateFullScreen(); + void slotShowMenubar(); + + void openURL( const KURL & url ); + void delayedOpen(); + + signals: + void restoreDocument(KConfig* config); + void saveDocumentRestoreInfo(KConfig* config); + + + private: + void setupAccel(); + void setupActions(); + void init(); + + private: + KParts::ReadOnlyPart* m_part; + KRecentFilesAction* m_recent; + KAction* m_printAction; + KToggleAction* m_fullScreenAction; + KToggleAction* m_showMenuBarAction; + KToggleAction* m_showToolBarAction; + bool m_menuBarWasShown, m_toolBarWasShown; + KURL m_openUrl; + }; + +} + +#endif + +// vim:ts=2:sw=2:tw=78:et diff --git a/kpdf/shell/shell.rc b/kpdf/shell/shell.rc new file mode 100644 index 00000000..134d34c7 --- /dev/null +++ b/kpdf/shell/shell.rc @@ -0,0 +1,21 @@ +<!DOCTYPE kpartgui SYSTEM "kpartgui.dtd"> +<kpartgui version="7" name="kpdf_shell" > + <MenuBar> + <Menu name="file" > + <DefineGroup append="save_merge" name="file_save" /> + <DefineGroup append="print_merge" name="file_print" /> + </Menu> + <!--Menu name="view" > + <Action name="fullscreen" /> + </Menu--> + <Menu name="settings" > + <DefineGroup append="show_merge" name="show_merge" /> + </Menu> + <Merge/> + </MenuBar> + <ToolBar noMerge="1" name="mainToolBar" > + <text>Main Toolbar</text> + <Action name="file_open_recent" /> + <!--Action name="file_print" /--> + </ToolBar> +</kpartgui> |