summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorJake Petroules <jake.petroules@qt.io>2017-01-30 04:45:57 -0800
committerJake Petroules <jake.petroules@qt.io>2017-01-30 13:26:42 +0000
commitac92363d10e4e3a3b205f9cea1e038eed204c365 (patch)
treee2e31bc1784060aefa9214647c9f8f5cf2aada24
parent43cebeadbe8d0550aeee4aa35f3c93a9e7e14a34 (diff)
Improve the PDF viewer example aesthetics
Sets the window title as the title of the PDF document, enlarges the default window size, uses unified toolbars on macOS, extends the viewer area to the edges of the containing window, and removes the Windows 95 style shrunken frame around the PDF viewer. Change-Id: I38753a2b5492ac0cc0d2a11ae62011ac595a0e70 Reviewed-by: Shawn Rutledge <shawn.rutledge@qt.io> Reviewed-by: Tobias Koenig <tobias.koenig@kdab.com>
-rw-r--r--examples/pdf/pdfviewer/mainwindow.cpp2
-rw-r--r--examples/pdf/pdfviewer/mainwindow.ui44
2 files changed, 39 insertions, 7 deletions
diff --git a/examples/pdf/pdfviewer/mainwindow.cpp b/examples/pdf/pdfviewer/mainwindow.cpp
index d865a8b..8ef7a07 100644
--- a/examples/pdf/pdfviewer/mainwindow.cpp
+++ b/examples/pdf/pdfviewer/mainwindow.cpp
@@ -87,6 +87,8 @@ void MainWindow::open(const QUrl &docLocation)
{
if (docLocation.isLocalFile()) {
m_document->load(docLocation.toLocalFile());
+ const auto documentTitle = m_document->metaData(QPdfDocument::Title).toString();
+ setWindowTitle(!documentTitle.isEmpty() ? documentTitle : QStringLiteral("PDF Viewer"));
} else {
qCDebug(lcExample) << docLocation << "is not a valid local file";
QMessageBox::critical(this, tr("Failed to open"), tr("%1 is not a valid local file").arg(docLocation.toString()));
diff --git a/examples/pdf/pdfviewer/mainwindow.ui b/examples/pdf/pdfviewer/mainwindow.ui
index 7070619..251591d 100644
--- a/examples/pdf/pdfviewer/mainwindow.ui
+++ b/examples/pdf/pdfviewer/mainwindow.ui
@@ -6,17 +6,41 @@
<rect>
<x>0</x>
<y>0</y>
- <width>400</width>
- <height>300</height>
+ <width>700</width>
+ <height>600</height>
</rect>
</property>
<property name="windowTitle">
- <string>MainWindow</string>
+ <string>PDF Viewer</string>
+ </property>
+ <property name="unifiedTitleAndToolBarOnMac">
+ <bool>true</bool>
</property>
<widget class="QWidget" name="centralWidget">
<layout class="QVBoxLayout" name="verticalLayout">
+ <property name="spacing">
+ <number>0</number>
+ </property>
+ <property name="leftMargin">
+ <number>0</number>
+ </property>
+ <property name="topMargin">
+ <number>0</number>
+ </property>
+ <property name="rightMargin">
+ <number>0</number>
+ </property>
+ <property name="bottomMargin">
+ <number>0</number>
+ </property>
<item>
<widget class="QScrollArea" name="scrollArea">
+ <property name="frameShape">
+ <enum>QFrame::NoFrame</enum>
+ </property>
+ <property name="lineWidth">
+ <number>0</number>
+ </property>
<property name="widgetResizable">
<bool>true</bool>
</property>
@@ -25,8 +49,8 @@
<rect>
<x>0</x>
<y>0</y>
- <width>380</width>
- <height>200</height>
+ <width>700</width>
+ <height>517</height>
</rect>
</property>
<layout class="QVBoxLayout" name="verticalLayout_2"/>
@@ -40,8 +64,8 @@
<rect>
<x>0</x>
<y>0</y>
- <width>400</width>
- <height>19</height>
+ <width>700</width>
+ <height>22</height>
</rect>
</property>
<widget class="QMenu" name="menuFile">
@@ -72,6 +96,12 @@
<addaction name="menuHelp"/>
</widget>
<widget class="QToolBar" name="mainToolBar">
+ <property name="movable">
+ <bool>false</bool>
+ </property>
+ <property name="floatable">
+ <bool>false</bool>
+ </property>
<attribute name="toolBarArea">
<enum>TopToolBarArea</enum>
</attribute>