Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
S
soitool
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Container Registry
Model registry
Operate
Environments
Monitor
Incidents
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
bachelor-paa-bittet
soitool
Commits
1bdc5927
Commit
1bdc5927
authored
5 years ago
by
Anders H. Rebner
Browse files
Options
Downloads
Plain Diff
Merge branch 'pdf-preview' into 'master'
#35 pdf preview See merge request
!16
parents
cc4c5733
6fe62cd1
No related branches found
Branches containing commit
No related tags found
1 merge request
!16
#35 pdf preview
Pipeline
#72835
passed
5 years ago
Stage: lint
Stage: test
Stage: deploy
Changes
2
Pipelines
1
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
Dockerfile
+8
-0
8 additions, 0 deletions
Dockerfile
soitool/main_window.py
+32
-1
32 additions, 1 deletion
soitool/main_window.py
with
40 additions
and
1 deletion
Dockerfile
+
8
−
0
View file @
1bdc5927
...
...
@@ -41,3 +41,11 @@ ENV LC_ALL en_US.UTF-8
# From https://it.i88.ca/2016/03/how-to-fix-importerror-libgssapikrb5so2.html
# python3.7 -m unittest fails without this
RUN
apt-get
-y
install
libgssapi-krb5-2
# Necessary for import of PySide2.QtWebEngineWidgets to work
RUN
apt-get
-y
install
libnss3
\
libxcomposite-dev
\
libxcursor-dev
\
libxi-dev
\
libxtst-dev
\
libxrandr-dev
This diff is collapsed.
Click to expand it.
soitool/main_window.py
+
32
−
1
View file @
1bdc5927
...
...
@@ -6,11 +6,12 @@ out to separate modules.
"""
import
sys
import
os
from
PySide2.QtCore
import
QRectF
,
QPoint
,
QTimer
,
Qt
from
PySide2.QtCore
import
QRectF
,
QPoint
,
QTimer
,
Qt
,
QUrl
from
PySide2.QtWidgets
import
QTabWidget
,
QWidget
,
QMainWindow
,
\
QApplication
,
QHBoxLayout
,
QVBoxLayout
,
QPushButton
,
QLabel
,
\
QAbstractItemView
,
QListWidget
,
QListWidgetItem
,
QAction
,
QGraphicsScene
,
\
QGraphicsView
,
QScrollArea
,
QGraphicsRectItem
from
PySide2.QtWebEngineWidgets
import
QWebEngineView
,
QWebEngineSettings
from
PySide2.QtGui
import
QBrush
,
QIcon
,
QPalette
,
QFont
,
QPixmap
from
soitool.modules.module_table
import
TableModule
...
...
@@ -481,6 +482,36 @@ class InlineEditableSOIView(QScrollArea):
self
.
view
.
translate
(
delta
.
x
(),
delta
.
y
())
# pylint: disable=r0903
class
PDFPreviewWidget
(
QWebEngineView
):
"""
Widget to preview PDFs using QWebEngineView with PDF plugin.
Inspired by the following sources:
* https://doc.qt.io/qt-5/qtwebengine-features.html#pdf-file-viewing
* https://doc.qt.io/qt-5/qtwebengine-webenginewidgets-simplebrowser-example.html
The load method interited from QWebEngineView
'
s can be used to load a new
URL, and the inherited reload method can be used to reload the currently
opened URL.
Parameters
----------
initial_url : QUrl
URL to load by default. Used for QWebEngineView
'
s .load method
https://doc.qt.io/qtforpython/PySide2/QtWebEngineWidgets/QWebEngineView.html#detailed-description
"""
def
__init__
(
self
,
initial_url
):
super
().
__init__
()
self
.
page
().
settings
().
setAttribute
(
QWebEngineSettings
.
PluginsEnabled
,
True
)
# the following setting is the default, but explicitly enabling to be
# explicit
self
.
page
().
settings
().
setAttribute
(
QWebEngineSettings
.
PdfViewerEnabled
,
True
)
self
.
load
(
QUrl
(
initial_url
))
if
__name__
==
"
__main__
"
:
app
=
QApplication
(
sys
.
argv
)
WINDOW
=
MainWindow
()
...
...
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment