From e4241f84bccd893c65108de9cdbc5286d8c0cb6a Mon Sep 17 00:00:00 2001 From: Laurent Montel Date: Sun, 14 Sep 2003 17:44:18 +0000 Subject: [PATCH] add recent file (I don't know why recent file is not load) svn path=/trunk/kdegraphics/kpdf/; revision=251047 --- kpdf/kpdf_part.cpp | 1 - kpdf/kpdf_shell.cpp | 29 +++++++++++++++++++++++------ kpdf/kpdf_shell.h | 15 +++++++-------- kpdf/main.cpp | 2 +- 4 files changed, 31 insertions(+), 16 deletions(-) diff --git a/kpdf/kpdf_part.cpp b/kpdf/kpdf_part.cpp index b1f61bea6..ba10178a6 100644 --- a/kpdf/kpdf_part.cpp +++ b/kpdf/kpdf_part.cpp @@ -64,7 +64,6 @@ Part::Part(QWidget *parentWidget, const char *widgetName, actionCollection(), "find"); KStdAction::findNext(this, SLOT(findNext()), actionCollection(), "find_next"); - m_fitToWidth = new KToggleAction(i18n("Fit to Page &Width"), 0, this, SLOT(slotFitToWidthToggled()), actionCollection(), "fit_to_width"); diff --git a/kpdf/kpdf_shell.cpp b/kpdf/kpdf_shell.cpp index 5bbaaecb7..e6ef3bd43 100644 --- a/kpdf/kpdf_shell.cpp +++ b/kpdf/kpdf_shell.cpp @@ -58,22 +58,39 @@ Shell::Shell() // next time we enter the event loop... return; } + readSettings(); } Shell::~Shell() { + writeSettings(); } - void -Shell::load(const KURL& url) +void Shell::openURL( const KURL & url ) { - m_part->openURL( url ); + m_part->openURL( url ); + recent->addURL (url); } + +void Shell::readSettings() +{ + recent->loadEntries( KGlobal::config() ); +} + +void Shell::writeSettings() +{ + saveMainWindowSettings(KGlobal::config(), "MainWindow"); + recent->saveEntries( KGlobal::config() ); +} + + void Shell::setupActions() { KStdAction::open(this, SLOT(fileOpen()), actionCollection()); + recent = KStdAction::openRecent( this, SLOT( openURL( const KURL& ) ), + actionCollection() ); KStdAction::saveAs(this, SLOT(fileSaveAs()), actionCollection()); KStdAction::quit(kapp, SLOT(quit()), actionCollection()); @@ -107,10 +124,10 @@ 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(); + KURL url = KFileDialog::getOpenURL();//getOpenFileName(); - if (file_name.isEmpty() == false) - load(file_name); + if (!url.isEmpty()) + openURL(url); } void diff --git a/kpdf/kpdf_shell.h b/kpdf/kpdf_shell.h index 2b689b005..9cf3e4b5b 100644 --- a/kpdf/kpdf_shell.h +++ b/kpdf/kpdf_shell.h @@ -3,11 +3,11 @@ #ifdef HAVE_CONFIG_H #include -#endif +#endif #include #include - + namespace KPDF { @@ -34,11 +34,6 @@ namespace KPDF */ 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 @@ -52,6 +47,8 @@ namespace KPDF * with @ref saveProperties */ void readProperties(KConfig*); + void readSettings(); + void writeSettings(); private slots: void fileOpen(); @@ -61,6 +58,8 @@ namespace KPDF void optionsConfigureToolbars(); void applyNewToolbarConfig(); + public slots: + void openURL( const KURL & url ); private: void setupAccel(); @@ -68,7 +67,7 @@ namespace KPDF private: KParts::ReadOnlyPart* m_part; - + KRecentFilesAction* recent; }; } diff --git a/kpdf/main.cpp b/kpdf/main.cpp index 0cfaf5a2f..b9f986989 100644 --- a/kpdf/main.cpp +++ b/kpdf/main.cpp @@ -55,7 +55,7 @@ int main(int argc, char** argv) { KPDF::Shell* widget = new KPDF::Shell; widget->show(); - widget->load(args->url(i)); + widget->openURL(args->url(i)); } } args->clear();