MCPcopy Create free account
hub / github.com/TeXworks/texworks / PDFDocumentScene

Method PDFDocumentScene

modules/QtPDF/src/PDFDocumentScene.cpp:31–106  ·  view source on GitHub ↗

PDFDocumentScene ================ A large canvas that manages the layout of QGraphicsItem subclasses. The primary items we are concerned with are PDFPageGraphicsItem and PDFLinkGraphicsItem.

Source from the content-addressed store, hash-verified

29// primary items we are concerned with are PDFPageGraphicsItem and
30// PDFLinkGraphicsItem.
31PDFDocumentScene::PDFDocumentScene(QSharedPointer<Backend::Document> a_doc, QObject *parent /* = nullptr */, const double dpiX /* = -1 */, const double dpiY /* = -1 */):
32 Super(parent),
33 _shownPageIdx(-2),
34 _doc(a_doc),
35 _lastPage(-1)
36{
37 Q_ASSERT(a_doc != nullptr);
38 // We need to register a QList<PDFLinkGraphicsItem *> meta-type so we can
39 // pass it through inter-thread (i.e., queued) connections
40 qRegisterMetaType< QList<PDFLinkGraphicsItem *> >();
41
42#if QT_VERSION < QT_VERSION_CHECK(5, 14, 0)
43 _dpiX = (dpiX > 0 ? dpiX : QApplication::desktop()->physicalDpiX());
44 _dpiY = (dpiY > 0 ? dpiY : QApplication::desktop()->physicalDpiY());
45#else
46 // FIXME: The QGraphicsScene should be independent of the hardware it is shown
47 // on
48 const QList<QGraphicsView *> & v = views();
49 if (dpiX > 0)
50 _dpiX = dpiX;
51 else if (!v.isEmpty())
52 _dpiX = v.first()->screen()->physicalDotsPerInchX();
53 else
54 _dpiX = 72;
55
56 if (dpiY > 0)
57 _dpiY = dpiY;
58 else if (!v.isEmpty())
59 _dpiY = v.first()->screen()->physicalDotsPerInchY();
60 else
61 _dpiY = 72;
62#endif
63
64 connect(&_pageLayout, &PDFPageLayout::layoutChanged, this, static_cast<void (PDFDocumentScene::*)(const QRectF&)>(&PDFDocumentScene::pageLayoutChanged));
65
66 // Initialize the unlock widget
67 {
68 _unlockWidget = new QWidget();
69 QVBoxLayout * layout = new QVBoxLayout();
70
71 _unlockWidgetLockIcon = new QLabel(_unlockWidget);
72 _unlockWidgetLockIcon->setPixmap(QIcon::fromTheme(QStringLiteral("status-locked")).pixmap(48));
73 _unlockWidgetLockText = new QLabel(_unlockWidget);
74 _unlockWidgetUnlockButton = new QPushButton(_unlockWidget);
75
76 connect(_unlockWidgetUnlockButton, &QPushButton::clicked, this, &PDFDocumentScene::doUnlockDialog);
77
78 layout->addWidget(_unlockWidgetLockIcon);
79 layout->addWidget(_unlockWidgetLockText);
80 layout->addSpacing(20);
81 layout->addWidget(_unlockWidgetUnlockButton);
82
83 layout->setAlignment(_unlockWidgetLockIcon, Qt::AlignHCenter);
84 layout->setAlignment(_unlockWidgetLockText, Qt::AlignHCenter);
85 layout->setAlignment(_unlockWidgetUnlockButton, Qt::AlignHCenter);
86
87 _unlockWidget->setLayout(layout);
88 _unlockProxy = new QGraphicsProxyWidget();

Callers

nothing calls this directly

Calls

no outgoing calls

Tested by

no test coverage detected