Commit db13de2b authored by Wilco Greven's avatar Wilco Greven

- Cleaned up the rc files.

- Moved file related actions to the shell.
- Added a browserextension.
- Renamed libkpdfpart to kparts_kpdf.

svn path=/trunk/kdegraphics/kpdf/; revision=175379
parent 40484ffe
......@@ -40,12 +40,12 @@ shellrc_DATA = kpdf_shell.rc
#########################################################################
# KPART SECTION
#########################################################################
kde_module_LTLIBRARIES = libkpdfpart.la
kde_module_LTLIBRARIES = kparts_kpdf.la
# the Part's source, library search path, and link libraries
libkpdfpart_la_SOURCES = kpdf_canvas.cpp kpdf_part.cpp kpdf_pagewidget.cc
libkpdfpart_la_LDFLAGS = -module $(KDE_PLUGIN) $(all_libraries)
libkpdfpart_la_LIBADD = ../xpdf/libxpdf.la $(LIB_KPARTS) $(LIB_KFILE) $(LIB_KDEPRINT)
kparts_kpdf_la_SOURCES = kpdf_canvas.cpp kpdf_part.cpp kpdf_pagewidget.cc
kparts_kpdf_la_LDFLAGS = -module $(KDE_PLUGIN) $(all_libraries)
kparts_kpdf_la_LIBADD = ../xpdf/libxpdf.la $(LIB_KPARTS) $(LIB_KFILE) $(LIB_KDEPRINT)
# this is where the desktop file will go
partdesktopdir = $(kde_servicesdir)
......
......@@ -6,7 +6,6 @@
#include <kaction.h>
#include <kdebug.h>
#include <kfiledialog.h>
#include <kinstance.h>
#include <kprinter.h>
#include <kstdaction.h>
......@@ -22,7 +21,7 @@
#include "kpdf_pagewidget.h"
typedef KParts::GenericFactory<KPDF::Part> KPDFPartFactory;
K_EXPORT_COMPONENT_FACTORY(libkpdfpart, KPDFPartFactory);
K_EXPORT_COMPONENT_FACTORY(kparts_kpdf, KPDFPartFactory);
using namespace KPDF;
......@@ -36,6 +35,8 @@ Part::Part(QWidget *parentWidget, const char *widgetName,
m_zoomMode(FixedFactor),
m_zoomFactor(1.0)
{
new BrowserExtension(this);
globalParams = new GlobalParams("");
// we need an instance
......@@ -59,9 +60,6 @@ Part::Part(QWidget *parentWidget, const char *widgetName,
WhitePixel(display, screen), false, 5);
// create our actions
KStdAction::open (this, SLOT(fileOpen()), actionCollection());
KStdAction::saveAs(this, SLOT(fileSaveAs()), actionCollection());
KStdAction::print (this, SLOT(filePrint()), actionCollection());
KStdAction::prior (this, SLOT(displayPreviousPage()),
actionCollection(), "previous_page");
KStdAction::next (this, SLOT(displayNextPage()),
......@@ -265,31 +263,8 @@ Part::displayDestination(LinkDest* dest)
*/
}
void
Part::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
QString file_name = KFileDialog::getOpenFileName();
if (file_name.isEmpty() == false)
openURL(file_name);
}
void
Part::fileSaveAs()
{
// this slot is called whenever the File->Save As menu is selected,
/*
QString file_name = KFileDialog::getSaveFileName();
if (file_name.isEmpty() == false)
saveAs(file_name);
*/
}
void
Part::filePrint()
Part::print()
{
if (m_doc == 0)
return;
......@@ -408,6 +383,22 @@ Part::fitWidthToggled()
displayPage(m_currentPage);
}
BrowserExtension::BrowserExtension(Part* parent)
: KParts::BrowserExtension( parent, "KPDF::BrowserExtension" )
{
emit enableAction("print", true);
setURLDropHandlingEnabled(true);
}
void
BrowserExtension::print()
{
static_cast<Part*>(parent())->print();
}
#include "kpdf_part.moc"
// vim:ts=2:sw=2:tw=78:et
[Desktop Entry]
Encoding=UTF-8
Name=KPDFPart
Name[af]=KPDFdeel
Name[de]=KPDF-Objekt
Name[es]=Parte
Name[et]=KPDF komponent
Name[id]=KPDFbagian
Name[ko]=KPDF 부분
Name[lt]=KPDFDalis
Name[nb]=KPDF
Name[ro]=Componenta KPDF
Name[sv]=KPDF-del
Name[xh]=KPDFIqela
Name[xx]=xx
Name[zu]=KPDFIngxenye
MimeType=application/pdf
InitialPreference=4
ServiceTypes=KParts/ReadOnlyPart
X-KDE-Library=libkpdfpart
X-KDE-Library=kparts_kpdf
Type=Service
......@@ -5,6 +5,7 @@
#include <qpixmap.h>
#include <qwidget.h>
#include <kparts/browserextension.h>
#include <kparts/part.h>
class QPainter;
......@@ -23,6 +24,7 @@ class XOutputDev;
namespace KPDF
{
class BrowserExtension;
class Canvas;
class PageWidget;
......@@ -58,6 +60,8 @@ namespace KPDF
bool closeURL();
void print();
void displayPage(int pageNumber, float zoomFactor = 1.0);
void displayDestination(LinkDest*);
......@@ -68,10 +72,6 @@ namespace KPDF
virtual bool openFile();
protected slots:
void fileOpen();
void fileSaveAs();
void filePrint();
void displayNextPage();
void displayPreviousPage();
......@@ -94,6 +94,19 @@ namespace KPDF
private slots:
void fitWidthToggled();
};
class BrowserExtension : public KParts::BrowserExtension
{
Q_OBJECT
public:
BrowserExtension(Part*);
public slots:
// Automatically detected by the host.
void print();
};
}
#endif
......
<!DOCTYPE kpartgui SYSTEM "kpartgui.dtd">
<kpartgui name="kpdf_part" version="1">
<kpartgui name="kpdf_part" version="2">
<MenuBar>
<Menu name="file">
<Action name="file_open"/>
<Separator/>
<Action name="file_save_as"/>
<Separator/>
<Action name="file_print"/>
</Menu>
<Menu name="view">
<Menu name="view"><text>&amp;View</text>
<Action name="fit_width"/>
</Menu>
</MenuBar>
<ToolBar name="mainToolBar">
<Action name="file_open"/>
<Action name="file_print"/>
<Action name="previous_page"/>
<Action name="next_page"/>
......
......@@ -6,18 +6,16 @@
#include "kpdf_shell.h"
#include "kpdf_shell.moc"
#include <kkeydialog.h>
#include <kaction.h>
#include <kconfig.h>
#include <kurl.h>
#include <kedittoolbar.h>
#include <kaction.h>
#include <kstdaction.h>
#include <kfiledialog.h>
#include <kkeydialog.h>
#include <klibloader.h>
#include <kmessagebox.h>
#include <kstatusbar.h>
#include <kstdaction.h>
#include <kurl.h>
using namespace KPDF;
......@@ -36,7 +34,7 @@ Shell::Shell()
// 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
KLibFactory *factory = KLibLoader::self()->factory("libkpdfpart");
KLibFactory *factory = KLibLoader::self()->factory("kparts_kpdf");
if (factory)
{
// now that the Part is loaded, we cast it to a Part to get
......@@ -78,6 +76,8 @@ Shell::load(const KURL& url)
void
Shell::setupActions()
{
KStdAction::open(this, SLOT(fileOpen()), actionCollection());
KStdAction::saveAs(this, SLOT(fileSaveAs()), actionCollection());
KStdAction::quit(kapp, SLOT(quit()), actionCollection());
m_toolbarAction = KStdAction::showToolbar(this, SLOT(optionsShowToolbar()), actionCollection());
......@@ -104,6 +104,29 @@ Shell::readProperties(KConfig* /*config*/)
// in 'saveProperties'
}
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
QString file_name = KFileDialog::getOpenFileName();
if (file_name.isEmpty() == false)
load(file_name);
}
void
Shell::fileSaveAs()
{
// this slot is called whenever the File->Save As menu is selected,
/*
QString file_name = KFileDialog::getSaveFileName();
if (file_name.isEmpty() == false)
saveAs(file_name);
*/
}
void
Shell::optionsShowToolbar()
{
......
......@@ -56,6 +56,9 @@ namespace KPDF
void readProperties(KConfig*);
private slots:
void fileOpen();
void fileSaveAs();
void optionsShowToolbar();
void optionsShowStatusbar();
void optionsConfigureKeys();
......
<!DOCTYPE kpartgui SYSTEM "kpartgui.dtd">
<kpartgui name="kpdf_shell" version="1">
<kpartgui name="kpdf_shell" version="2">
<MenuBar>
<Menu noMerge="1" name="file"><text>&amp;File</text>
<Merge/>
<Separator/>
<Action name="file_quit"/>
</Menu>
<Menu noMerge="1" name="view"><text>&amp;View</text>
<Merge/>
</Menu>
<Menu noMerge="1" name="settings"><text>&amp;Settings</text>
<Action name="options_show_toolbar"/>
<Action name="options_show_statusbar"/>
<Merge name="show_merge"/>
<Separator/>
<Action name="options_configure_keybinding"/>
<Action name="options_configure_toolbars"/>
<Action name="options_configure"/>
<Merge name="configure_merge"/>
<Separator/>
<Merge/>
<Menu name="file"><text>&amp;File</text>
<DefineGroup name="file_save" append="save_merge"/>
<DefineGroup name="file_print" append="print_merge"/>
</Menu>
</MenuBar>
<ToolBar noMerge="1" name="mainToolBar"><text>Main Toolbar</text>
<Action name="file_new"/>
<Merge/>
<Action name="help"/>
</ToolBar>
</kpartgui>
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment