mirror of
https://invent.kde.org/graphics/okular
synced 2024-08-24 18:35:37 +00:00
use okular settings to decide document title
This commit is contained in:
parent
cbe00442f5
commit
d52118dc7e
|
@ -38,8 +38,8 @@ Image {
|
|||
|
||||
Okular.DocumentItem {
|
||||
id: documentItem
|
||||
onPathChanged: {
|
||||
application.caption = path.replace(/^.*[\\\/]/, '')
|
||||
onWindowTitleForDocumentChanged: {
|
||||
application.caption = windowTitleForDocument
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -64,6 +64,24 @@ void DocumentItem::setPath(const QString &path)
|
|||
emit pageCountChanged();
|
||||
emit openedChanged();
|
||||
emit supportsSearchingChanged();
|
||||
emit windowTitleForDocumentChanged();
|
||||
}
|
||||
|
||||
QString DocumentItem::windowTitleForDocument() const
|
||||
{
|
||||
// If 'DocumentTitle' should be used, check if the document has one. If
|
||||
// either case is false, use the file name.
|
||||
QString title = Okular::Settings::displayDocumentNameOrPath() == Okular::Settings::EnumDisplayDocumentNameOrPath::Path ? m_document->currentDocument().pathOrUrl() : m_document->currentDocument().fileName();
|
||||
|
||||
if (Okular::Settings::displayDocumentTitle()) {
|
||||
const QString docTitle = m_document->metaData( "DocumentTitle" ).toString();
|
||||
|
||||
if (!docTitle.isEmpty() && !docTitle.trimmed().isEmpty()) {
|
||||
title = docTitle;
|
||||
}
|
||||
}
|
||||
|
||||
return title;
|
||||
}
|
||||
|
||||
QString DocumentItem::path() const
|
||||
|
|
|
@ -43,6 +43,11 @@ class DocumentItem : public QObject
|
|||
*/
|
||||
Q_PROPERTY(QString path READ path WRITE setPath NOTIFY pathChanged)
|
||||
|
||||
/**
|
||||
* Suggested window title if a window represents this document. may be pathname or document title, dependeing from Okular settings.
|
||||
*/
|
||||
Q_PROPERTY(QString windowTitleForDocument READ windowTitleForDocument NOTIFY windowTitleForDocumentChanged)
|
||||
|
||||
/**
|
||||
* Current displaying page for the document
|
||||
*/
|
||||
|
@ -91,6 +96,8 @@ public:
|
|||
void setPath(const QString &path);
|
||||
QString path() const;
|
||||
|
||||
QString windowTitleForDocument() const;
|
||||
|
||||
void setCurrentPage(int page);
|
||||
int currentPage() const;
|
||||
|
||||
|
@ -134,6 +141,7 @@ Q_SIGNALS:
|
|||
void currentPageChanged();
|
||||
void supportsSearchingChanged();
|
||||
void bookmarksChanged();
|
||||
void windowTitleForDocumentChanged();
|
||||
|
||||
private Q_SLOTS:
|
||||
void searchFinished(int id, Okular::Document::SearchStatus endStatus);
|
||||
|
|
Loading…
Reference in a new issue