mirror of
https://invent.kde.org/graphics/okular
synced 2024-09-19 16:01:41 +00:00
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:
parent
5490bb7bb3
commit
e4241f84bc
|
@ -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");
|
||||
|
|
|
@ -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
|
||||
|
|
|
@ -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;
|
||||
};
|
||||
|
||||
}
|
||||
|
|
|
@ -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();
|
||||
|
|
Loading…
Reference in a new issue