diff options
author | Jake Petroules <jake.petroules@qt.io> | 2017-01-30 04:45:57 -0800 |
---|---|---|
committer | Michal Klocek <michal.klocek@qt.io> | 2019-11-25 12:01:39 +0100 |
commit | 0f07c791c64c7f914bd07be70dbbf50501c862f4 (patch) | |
tree | 2a7244794d94aef2c83648319407773433b40a82 /examples | |
parent | f8d12697a3830d331589229aec6d83e6686f77fc (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>
Diffstat (limited to 'examples')
-rw-r--r-- | examples/pdfwidgets/pdfviewer/mainwindow.cpp | 2 | ||||
-rw-r--r-- | examples/pdfwidgets/pdfviewer/mainwindow.ui | 44 |
2 files changed, 39 insertions, 7 deletions
diff --git a/examples/pdfwidgets/pdfviewer/mainwindow.cpp b/examples/pdfwidgets/pdfviewer/mainwindow.cpp index d865a8bdd..8ef7a075e 100644 --- a/examples/pdfwidgets/pdfviewer/mainwindow.cpp +++ b/examples/pdfwidgets/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/pdfwidgets/pdfviewer/mainwindow.ui b/examples/pdfwidgets/pdfviewer/mainwindow.ui index 7070619b9..251591d9a 100644 --- a/examples/pdfwidgets/pdfviewer/mainwindow.ui +++ b/examples/pdfwidgets/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> |