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

Method init

src/PDFDocumentWindow.cpp:132–359  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

130}
131
132void PDFDocumentWindow::init()
133{
134 docList.append(this);
135
136 setupUi(this);
137
138 setAttribute(Qt::WA_DeleteOnClose, true);
139
140 QIcon winIcon;
141#if defined(Q_OS_UNIX) && !defined(Q_OS_DARWIN)
142 // The Compiz window manager doesn't seem to support icons larger than
143 // 128x128, so we add a suitable one first
144 winIcon.addFile(QString::fromLatin1(":/images/images/TeXworks-doc-128.png"));
145#endif
146 winIcon.addFile(QString::fromLatin1(":/images/images/TeXworks-doc.png"));
147 setWindowIcon(winIcon);
148
149 pdfWidget = new QtPDF::PDFDocumentWidget(this);
150 pdfWidget->setSearchResultHighlightBrush(QBrush(Qt::transparent));
151 pdfWidget->setCurrentSearchResultHighlightBrush(QBrush(Qt::transparent));
152 pdfWidget->setAcceptDrops(false);
153 _searchResultHighlightBrush = QColor(255, 255, 0, 63);
154 setCentralWidget(pdfWidget);
155
156 connect(pdfWidget, &QtPDF::PDFDocumentWidget::changedPage, this, &PDFDocumentWindow::updateStatusBar);
157 connect(pdfWidget, &QtPDF::PDFDocumentWidget::changedZoom, this, &PDFDocumentWindow::updateStatusBar);
158 connect(pdfWidget, &QtPDF::PDFDocumentWidget::changedDocument, this, &PDFDocumentWindow::changedDocument);
159 // NB: Using a queued connection ensures the signal has to pass through the
160 // event loop. If searching effectively blocks the GUI for a while (e.g., by
161 // spawning too many threads), this ensures that the highlighting processing
162 // (including clearing the highlighting after kPDFHighlightDuration) only
163 // starts when the GUI is responsive (i.e., the highlight is actually
164 // displayed)
165 connect(pdfWidget, &QtPDF::PDFDocumentWidget::searchResultHighlighted, this, &PDFDocumentWindow::searchResultHighlighted, Qt::QueuedConnection);
166 connect(pdfWidget, &QtPDF::PDFDocumentWidget::changedPageMode, this, &PDFDocumentWindow::updatePageMode);
167 connect(pdfWidget, &QtPDF::PDFDocumentWidget::requestOpenPdf, this, &PDFDocumentWindow::maybeOpenPdf);
168 connect(pdfWidget, &QtPDF::PDFDocumentWidget::requestOpenUrl, this, &PDFDocumentWindow::maybeOpenUrl);
169 connect(pdfWidget, &QtPDF::PDFDocumentWidget::textSelectionChanged, this, &PDFDocumentWindow::maybeEnableCopyCommand);
170
171 toolButtonGroup = new QButtonGroup(toolBar);
172 toolButtonGroup->addButton(qobject_cast<QAbstractButton*>(toolBar->widgetForAction(actionMagnify)), QtPDF::PDFDocumentView::MouseMode_MagnifyingGlass);
173 toolButtonGroup->addButton(qobject_cast<QAbstractButton*>(toolBar->widgetForAction(actionScroll)), QtPDF::PDFDocumentView::MouseMode_Move);
174 toolButtonGroup->addButton(qobject_cast<QAbstractButton*>(toolBar->widgetForAction(actionSelect_Text)), QtPDF::PDFDocumentView::MouseMode_Select);
175#if QT_VERSION < QT_VERSION_CHECK(5, 15, 0)
176 connect(toolButtonGroup, static_cast<void (QButtonGroup::*)(int)>(&QButtonGroup::buttonClicked), this, &PDFDocumentWindow::setMouseMode);
177#else
178 connect(toolButtonGroup, &QButtonGroup::idClicked, this, &PDFDocumentWindow::setMouseMode);
179#endif
180 pdfWidget->setMouseModeMagnifyingGlass();
181
182 scaleLabel = new Tw::UI::ClickableLabel();
183 statusBar()->addPermanentWidget(scaleLabel);
184 scaleLabel->setFrameStyle(QFrame::StyledPanel);
185 scaleLabel->setFont(statusBar()->font());
186 connect(scaleLabel, &Tw::UI::ClickableLabel::mouseLeftClick, this, &PDFDocumentWindow::scaleLabelClick);
187
188 pageLabel = new Tw::UI::ClickableLabel();
189 statusBar()->addPermanentWidget(pageLabel);

Callers

nothing calls this directly

Calls 14

setFontMethod · 0.80
zoomInMethod · 0.80
zoomOutMethod · 0.80
dockWidgetMethod · 0.80
hideMethod · 0.80
containsMethod · 0.80
updateWindowMenusMethod · 0.80
addShortcutMethod · 0.80
openMethod · 0.45
valueMethod · 0.45

Tested by

no test coverage detected