Commit 40484ffe authored by Wilco Greven's avatar Wilco Greven

Since kpdf.[h|cpp] hasn't any relevant history yet:

  KPDF -> KPDF::Shell

svn path=/trunk/kdegraphics/kpdf/; revision=175365
parent c09daf3f
......@@ -6,7 +6,7 @@ SUBDIRS = .
INCLUDES = -I$(top_srcdir)/kpdf/goo -I$(top_srcdir)/kpdf/xpdf $(all_includes)
# these are the headers for your project
noinst_HEADERS = kpdf.h kpdf_part.h
noinst_HEADERS = kpdf_shell.h kpdf_part.h kpdf_canvas.h kpdf_pagewidget.h
# let automoc handle all of the meta source files (moc)
METASOURCES = AUTO
......@@ -25,7 +25,7 @@ KDE_ICON = kpdf
bin_PROGRAMS = kpdf
# the application source, library search path, and link libraries
kpdf_SOURCES = main.cpp kpdf.cpp
kpdf_SOURCES = main.cpp kpdf_shell.cpp
kpdf_LDFLAGS = $(KDE_RPATH) $(all_libraries)
kpdf_LDADD = $(LIB_KPARTS)
......@@ -43,7 +43,7 @@ shellrc_DATA = kpdf_shell.rc
kde_module_LTLIBRARIES = libkpdfpart.la
# the Part's source, library search path, and link libraries
libkpdfpart_la_SOURCES = kpdf_part.cpp kpdf_pagewidget.cc
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)
......
/*
* kpdf_shell.cpp
*
* Copyright (C) 2001 <kurt@granroth.org>
*/
#include "kpdf_shell.h"
#include "kpdf_shell.moc"
#include <kkeydialog.h>
#include <kconfig.h>
#include <kurl.h>
#include <kedittoolbar.h>
#include <kaction.h>
#include <kstdaction.h>
#include <klibloader.h>
#include <kmessagebox.h>
#include <kstatusbar.h>
using namespace KPDF;
Shell::Shell()
: KParts::MainWindow(0, "KPDF::Shell")
{
// set the shell's ui resource file
setXMLFile("kpdf_shell.rc");
// then, setup our actions
setupActions();
// and a status bar
statusBar()->show();
// 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");
if (factory)
{
// now that the Part is loaded, we cast it to a Part to get
// our hands on it
m_part = static_cast<KParts::ReadOnlyPart*>(
factory->create(this, "kpdf_part", "KParts::ReadOnlyPart"));
if (m_part)
{
// 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
createGUI(m_part);
}
}
else
{
// if we couldn't find our Part, we exit since the Shell by
// itself can't do anything useful
KMessageBox::error(this, "Could not find our Part!");
kapp->quit();
// we return here, cause kapp->quit() only means "exit the
// next time we enter the event loop...
return;
}
}
Shell::~Shell()
{
}
void
Shell::load(const KURL& url)
{
m_part->openURL( url );
}
void
Shell::setupActions()
{
KStdAction::quit(kapp, SLOT(quit()), actionCollection());
m_toolbarAction = KStdAction::showToolbar(this, SLOT(optionsShowToolbar()), actionCollection());
m_statusbarAction = KStdAction::showStatusbar(this, SLOT(optionsShowStatusbar()), actionCollection());
KStdAction::keyBindings(this, SLOT(optionsConfigureKeys()), actionCollection());
KStdAction::configureToolbars(this, SLOT(optionsConfigureToolbars()), actionCollection());
}
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
}
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'
}
void
Shell::optionsShowToolbar()
{
// this is all very cut and paste code for showing/hiding the
// toolbar
if (m_toolbarAction->isChecked())
toolBar()->show();
else
toolBar()->hide();
}
void
Shell::optionsShowStatusbar()
{
// this is all very cut and paste code for showing/hiding the
// statusbar
if (m_statusbarAction->isChecked())
statusBar()->show();
else
statusBar()->hide();
}
void
Shell::optionsConfigureKeys()
{
KKeyDialog::configureKeys(actionCollection(), "kpdf_shell.rc");
}
void
Shell::optionsConfigureToolbars()
{
saveMainWindowSettings(KGlobal::config(), "MainWindow");
// use the standard toolbar editor
KEditToolbar dlg(factory());
connect(&dlg, SIGNAL(newToolbarConfig()),
this, SLOT(applyNewToolbarConfig()));
dlg.exec();
}
void
Shell::applyNewToolbarConfig()
{
applyMainWindowSettings(KGlobal::config(), "MainWindow");
}
// vim:ts=2:sw=2:tw=78:et
#ifndef _KPDF_SHELL_H_
#define _KPDF_SHELL_H_
#ifdef HAVE_CONFIG_H
#include <config.h>
#endif
#include <kapplication.h>
#include <kparts/mainwindow.h>
class KToggleAction;
namespace KPDF
{
/**
* This is the application "Shell". It has a menubar, toolbar, and
* statusbar 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();
/**
* Default Destructor
*/
virtual ~Shell();
/**
* Use this method to load whatever file/URL you have
*/
void load(const KURL& url);
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*);
private slots:
void optionsShowToolbar();
void optionsShowStatusbar();
void optionsConfigureKeys();
void optionsConfigureToolbars();
void applyNewToolbarConfig();
private:
void setupAccel();
void setupActions();
private:
KParts::ReadOnlyPart* m_part;
KToggleAction* m_toolbarAction;
KToggleAction* m_statusbarAction;
};
}
#endif
// vim:ts=2:sw=2:tw=78:et
#include "kpdf.h"
#include "kpdf_shell.h"
#include <kapplication.h>
#include <kaboutdata.h>
#include <kcmdlineargs.h>
......@@ -25,7 +25,7 @@ int main(int argc, char** argv)
// see if we are starting with session management
if (app.isRestored())
RESTORE(KPDF)
RESTORE(KPDF::Shell)
else
{
// no session.. just start up normally
......@@ -33,14 +33,14 @@ int main(int argc, char** argv)
if (args->count() == 0)
{
KPDF* widget = new KPDF;
KPDF::Shell* widget = new KPDF::Shell;
widget->show();
}
else
{
for (int i = 0; i < args->count(); ++i)
{
KPDF* widget = new KPDF;
KPDF::Shell* widget = new KPDF::Shell;
widget->show();
widget->load(args->url(i));
}
......
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