add recent file

(I don't know why recent file is not load)

svn path=/trunk/kdegraphics/kpdf/; revision=251047
This commit is contained in:
Laurent Montel 2003-09-14 17:44:18 +00:00
parent 5490bb7bb3
commit e4241f84bc
4 changed files with 31 additions and 16 deletions

View file

@ -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");

View file

@ -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

View file

@ -3,11 +3,11 @@
#ifdef HAVE_CONFIG_H
#include <config.h>
#endif
#endif
#include <kapplication.h>
#include <kparts/mainwindow.h>
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;
};
}

View file

@ -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();