Commit db0a0d00 authored by Albert Astals Cid's avatar Albert Astals Cid
Browse files

Give a warning when the opened file does not exist

Remove the recent file if the user opens it and it does not exists

svn path=/trunk/kdegraphics/kpdf/; revision=347427
parent 2e8b5c76
......@@ -414,6 +414,17 @@ Part::openFile()
return true;
}
bool Part::openURL(const KURL &url)
{
bool b;
b = KParts::ReadOnlyPart::openURL(url);
if (!b)
{
KMessageBox::error(widget(), i18n("Could not open %1").arg(url.prettyURL()));
}
return b;
}
void
Part::fileSaveAs()
{
......
......@@ -91,6 +91,8 @@ namespace KPDF
*/
virtual bool openFile();
virtual bool openURL(const KURL &url);
void update();
void readSettings();
void writeSettings();
......
......@@ -92,13 +92,14 @@ Shell::~Shell()
void Shell::openURL( const KURL & url )
{
if ( m_part && m_part->openURL( url ) ) recent->addURL (url);
if ( m_part && m_part->openURL( url ) ) m_recent->addURL (url);
else m_recent->removeURL(url);
}
void Shell::readSettings()
{
recent->loadEntries( KGlobal::config() );
m_recent->loadEntries( KGlobal::config() );
KGlobal::config()->setDesktopGroup();
bool fullScreen = KGlobal::config()->readBoolEntry( "FullScreen", false );
setFullScreen( fullScreen );
......@@ -107,7 +108,7 @@ void Shell::readSettings()
void Shell::writeSettings()
{
saveMainWindowSettings(KGlobal::config(), "MainWindow");
recent->saveEntries( KGlobal::config() );
m_recent->saveEntries( KGlobal::config() );
KGlobal::config()->setDesktopGroup();
KGlobal::config()->writeEntry( "FullScreen", m_fullScreenAction->isChecked());
KGlobal::config()->sync();
......@@ -117,7 +118,7 @@ void Shell::writeSettings()
Shell::setupActions()
{
KStdAction::open(this, SLOT(fileOpen()), actionCollection());
recent = KStdAction::openRecent( this, SLOT( openURL( const KURL& ) ),
m_recent = KStdAction::openRecent( this, SLOT( openURL( const KURL& ) ),
actionCollection() );
KStdAction::print(m_part, SLOT(print()), actionCollection());
KStdAction::quit(this, SLOT(slotQuit()), actionCollection());
......
......@@ -85,7 +85,7 @@ namespace KPDF
private:
KParts::ReadOnlyPart* m_part;
KRecentFilesAction* recent;
KRecentFilesAction* m_recent;
KToggleAction* m_fullScreenAction;
bool m_isFullScreen;
KPopupMenu* m_popup;
......
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