Commit c5b23318 authored by Albert Astals Cid's avatar Albert Astals Cid

Error notyfing when not able to open a file

WindowTitle settign for remote files

svn path=/trunk/KDE/kdegraphics/okular/; revision=671944
parent b883cbcf
......@@ -103,6 +103,11 @@ m_searchStarted(false), m_cliPresentation(false)
// connect the started signal to tell the job the mimetypes we like
connect(this, SIGNAL(started(KIO::Job *)), this, SLOT(setMimeTypes(KIO::Job *)));
// connect the completed signal so we can put the window caption when loading remote files
connect(this, SIGNAL(completed()), this, SLOT(setWindowTitleFromDocument()));
connect(this, SIGNAL(canceled(const QString &)), this, SLOT(loadCancelled(const QString &)));
// load catalog for translation
KGlobal::locale()->insertCatalog("okular");
......@@ -525,6 +530,33 @@ void Part::readMimeType(KIO::Job *, const QString &mime)
m_jobMime = mime;
}
void Part::loadCancelled(const QString &reason)
{
emit setWindowCaption( QString() );
if (!reason.isEmpty())
{
KMessageBox::error( widget(), i18n("Could not open %1. Reason: %2", url().prettyUrl(), reason ) );
}
else
{
KMessageBox::error( widget(), i18n("Could not open %1", url().prettyUrl() ) );
}
}
void Part::setWindowTitleFromDocument()
{
// if the document have a 'DocumentTitle' flag set (and it is not empty), set it as title
QString title = m_document->metaData( "DocumentTitle" ).toString();
if ( !title.isEmpty() && !title.trimmed().isEmpty() )
{
emit setWindowCaption( title );
}
else
{
emit setWindowCaption( url().fileName() );
}
}
void Part::slotGeneratorPreferences( )
{
// an instance the dialog could be already created and could be cached,
......@@ -772,16 +804,7 @@ bool Part::openUrl(const KUrl &url)
{
m_viewportDirty.pageNumber = -1;
// if the document have a 'DocumentTitle' flag set (and it is not empty), set it as title
QString title = m_document->metaData( "DocumentTitle" ).toString();
if ( !title.isEmpty() && !title.trimmed().isEmpty() )
{
emit setWindowCaption( title );
}
else
{
emit setWindowCaption( url.fileName() );
}
setWindowTitleFromDocument();
}
emit enablePrintAction(openOk);
......
......@@ -148,6 +148,8 @@ class Part : public KParts::ReadOnlyPart, public Okular::DocumentObserver, publi
void slotHideFindBar();
void setMimeTypes(KIO::Job *job);
void readMimeType(KIO::Job *job, const QString &mime);
void loadCancelled(const QString &reason);
void setWindowTitleFromDocument();
void saveSplitterSize();
// can be connected to widget elements
void updateViewActions();
......
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