Commit 40e5c5e0 authored by Albert Astals Cid's avatar Albert Astals Cid

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=/branches/kpdf_experiments/kdegraphics/kpdf/; revision=347427
parent b9db06f8
...@@ -68,7 +68,7 @@ Part::Part(QWidget *parentWidget, const char *widgetName, ...@@ -68,7 +68,7 @@ Part::Part(QWidget *parentWidget, const char *widgetName,
// create browser extension (for printing when embedded into browser) // create browser extension (for printing when embedded into browser)
new BrowserExtension(this); new BrowserExtension(this);
// xpdf 'extern' global class (m_count is a static instance counter) // xpdf 'extern' global class (m_count is a static instance counter)
//if ( m_count ) TODO check if we need to insert these lines.. //if ( m_count ) TODO check if we need to insert these lines..
// delete globalParams; // delete globalParams;
globalParams = new GlobalParams(""); globalParams = new GlobalParams("");
...@@ -179,6 +179,13 @@ bool Part::openFile() ...@@ -179,6 +179,13 @@ bool Part::openFile()
return ok; return ok;
} }
bool Part::openURL(const KURL &url)
{
bool b = KParts::ReadOnlyPart::openURL(url);
if (!b) KMessageBox::error(widget(), i18n("Could not open %1").arg(url.prettyURL()));
return b;
}
bool Part::closeURL() bool Part::closeURL()
{ {
document->closeDocument(); document->closeDocument();
...@@ -205,19 +212,19 @@ void Part::updateActions() ...@@ -205,19 +212,19 @@ void Part::updateActions()
} }
} }
//BEGIN go to page dialog //BEGIN go to page dialog
class KPDFGotoPageDialog : public KDialogBase class KPDFGotoPageDialog : public KDialogBase
{ {
public: public:
KPDFGotoPageDialog(QWidget *p, int current, int max) : KDialogBase(p, 0L, true, i18n("Go to Page"), Ok | Cancel, Ok) { KPDFGotoPageDialog(QWidget *p, int current, int max) : KDialogBase(p, 0L, true, i18n("Go to Page"), Ok | Cancel, Ok) {
QWidget *w = new QWidget(this); QWidget *w = new QWidget(this);
setMainWidget(w); setMainWidget(w);
QVBoxLayout *topLayout = new QVBoxLayout( w, 0, spacingHint() ); QVBoxLayout *topLayout = new QVBoxLayout( w, 0, spacingHint() );
e1 = new KIntNumInput(current, w); e1 = new KIntNumInput(current, w);
e1->setRange(1, max); e1->setRange(1, max);
e1->setEditFocus(true); e1->setEditFocus(true);
QLabel *label = new QLabel( e1,i18n("&Page:"), w ); QLabel *label = new QLabel( e1,i18n("&Page:"), w );
topLayout->addWidget(label); topLayout->addWidget(label);
topLayout->addWidget(e1); topLayout->addWidget(e1);
...@@ -233,7 +240,7 @@ public: ...@@ -233,7 +240,7 @@ public:
protected: protected:
KIntNumInput *e1; KIntNumInput *e1;
}; };
//END go to page dialog //END go to page dialog
void Part::slotGoToPage() void Part::slotGoToPage()
{ {
...@@ -439,12 +446,12 @@ void Part::slotPrint() ...@@ -439,12 +446,12 @@ void Part::slotPrint()
double width, height; double width, height;
int landscape, portrait; int landscape, portrait;
KPrinter printer; KPrinter printer;
printer.setPageSelection(KPrinter::ApplicationSide); printer.setPageSelection(KPrinter::ApplicationSide);
printer.setMinMax(1, m_doc->getNumPages()); printer.setMinMax(1, m_doc->getNumPages());
printer.setCurrentPage(m_currentPage); printer.setCurrentPage(m_currentPage);
printer.setMargins(0, 0, 0, 0); printer.setMargins(0, 0, 0, 0);
// if some pages are landscape and others are not the most common win as kprinter does // if some pages are landscape and others are not the most common win as kprinter does
// not accept a per page setting // not accept a per page setting
landscape = 0; landscape = 0;
...@@ -458,7 +465,7 @@ void Part::slotPrint() ...@@ -458,7 +465,7 @@ void Part::slotPrint()
else portrait++; else portrait++;
} }
if (landscape > portrait) printer.setOrientation(KPrinter::Landscape); if (landscape > portrait) printer.setOrientation(KPrinter::Landscape);
if (printer.setup(widget())) if (printer.setup(widget()))
{ {
doPrint( printer ); doPrint( printer );
...@@ -475,11 +482,11 @@ void Part::slotPrintPreview() ...@@ -475,11 +482,11 @@ void Part::slotPrintPreview()
double width, height; double width, height;
int landscape, portrait; int landscape, portrait;
KPrinter printer; KPrinter printer;
printer.setMinMax(1, m_doc->getNumPages()); printer.setMinMax(1, m_doc->getNumPages());
printer.setPreviewOnly( true ); printer.setPreviewOnly( true );
printer.setMargins(0, 0, 0, 0); printer.setMargins(0, 0, 0, 0);
// if some pages are landscape and others are not the most common win as kprinter does // if some pages are landscape and others are not the most common win as kprinter does
// not accept a per page setting // not accept a per page setting
landscape = 0; landscape = 0;
...@@ -493,7 +500,7 @@ void Part::slotPrintPreview() ...@@ -493,7 +500,7 @@ void Part::slotPrintPreview()
else portrait++; else portrait++;
} }
if (landscape > portrait) printer.setOption("orientation-requested", "4"); if (landscape > portrait) printer.setOption("orientation-requested", "4");
doPrint(printer); doPrint(printer);
*/ */
} }
...@@ -507,7 +514,7 @@ void Part::doPrint( KPrinter& /*printer*/ ) ...@@ -507,7 +514,7 @@ void Part::doPrint( KPrinter& /*printer*/ )
QOutputDevKPrinter printdev( painter, paperColor, printer ); QOutputDevKPrinter printdev( painter, paperColor, printer );
printdev.startDoc(m_doc->getXRef()); printdev.startDoc(m_doc->getXRef());
QValueList<int> pages = printer.pageList(); QValueList<int> pages = printer.pageList();
for ( QValueList<int>::ConstIterator i = pages.begin(); i != pages.end();) for ( QValueList<int>::ConstIterator i = pages.begin(); i != pages.end();)
{ {
m_docMutex.lock(); m_docMutex.lock();
...@@ -520,7 +527,7 @@ void Part::doPrint( KPrinter& /*printer*/ ) ...@@ -520,7 +527,7 @@ void Part::doPrint( KPrinter& /*printer*/ )
} }
/* /*
* BrowserExtension class * BrowserExtension class
*/ */
BrowserExtension::BrowserExtension(Part* parent) BrowserExtension::BrowserExtension(Part* parent)
......
...@@ -75,6 +75,8 @@ namespace KPDF ...@@ -75,6 +75,8 @@ namespace KPDF
protected: protected:
// reimplemented from KParts::ReadOnlyPart // reimplemented from KParts::ReadOnlyPart
virtual bool openFile(); virtual bool openFile();
// reimplemented from KParts::ReadOnlyPart
virtual bool openURL(const KURL &url);
void updateAction(); void updateAction();
void doPrint( KPrinter& printer ); void doPrint( KPrinter& printer );
...@@ -95,7 +97,7 @@ namespace KPDF ...@@ -95,7 +97,7 @@ namespace KPDF
public slots: public slots:
// connected to Shell action (and browserExtension), not local one // connected to Shell action (and browserExtension), not local one
void slotPrint(); void slotPrint();
private: private:
// the document // the document
......
...@@ -88,13 +88,14 @@ Shell::~Shell() ...@@ -88,13 +88,14 @@ Shell::~Shell()
void Shell::openURL( const KURL & url ) 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() void Shell::readSettings()
{ {
recent->loadEntries( KGlobal::config() ); m_recent->loadEntries( KGlobal::config() );
KGlobal::config()->setDesktopGroup(); KGlobal::config()->setDesktopGroup();
bool fullScreen = KGlobal::config()->readBoolEntry( "FullScreen", false ); bool fullScreen = KGlobal::config()->readBoolEntry( "FullScreen", false );
setFullScreen( fullScreen ); setFullScreen( fullScreen );
...@@ -103,7 +104,7 @@ void Shell::readSettings() ...@@ -103,7 +104,7 @@ void Shell::readSettings()
void Shell::writeSettings() void Shell::writeSettings()
{ {
saveMainWindowSettings(KGlobal::config(), "MainWindow"); saveMainWindowSettings(KGlobal::config(), "MainWindow");
recent->saveEntries( KGlobal::config() ); m_recent->saveEntries( KGlobal::config() );
KGlobal::config()->setDesktopGroup(); KGlobal::config()->setDesktopGroup();
KGlobal::config()->writeEntry( "FullScreen", m_fullScreenAction->isChecked()); KGlobal::config()->writeEntry( "FullScreen", m_fullScreenAction->isChecked());
KGlobal::config()->sync(); KGlobal::config()->sync();
...@@ -113,7 +114,7 @@ void Shell::writeSettings() ...@@ -113,7 +114,7 @@ void Shell::writeSettings()
Shell::setupActions() Shell::setupActions()
{ {
KStdAction::open(this, SLOT(fileOpen()), actionCollection()); KStdAction::open(this, SLOT(fileOpen()), actionCollection());
recent = KStdAction::openRecent( this, SLOT( openURL( const KURL& ) ), m_recent = KStdAction::openRecent( this, SLOT( openURL( const KURL& ) ),
actionCollection() ); actionCollection() );
KStdAction::print(m_part, SLOT(slotPrint()), actionCollection()); KStdAction::print(m_part, SLOT(slotPrint()), actionCollection());
KStdAction::quit(this, SLOT(slotQuit()), actionCollection()); KStdAction::quit(this, SLOT(slotQuit()), actionCollection());
......
...@@ -85,7 +85,7 @@ namespace KPDF ...@@ -85,7 +85,7 @@ namespace KPDF
private: private:
KParts::ReadOnlyPart* m_part; KParts::ReadOnlyPart* m_part;
KRecentFilesAction* recent; KRecentFilesAction* m_recent;
KToggleAction* m_fullScreenAction; KToggleAction* m_fullScreenAction;
bool m_isFullScreen; bool m_isFullScreen;
KPopupMenu* m_popup; 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