Skip to content

Commit

Permalink
option where to place embedded pdf-viewer
Browse files Browse the repository at this point in the history
  • Loading branch information
octaeder committed Dec 31, 2023
1 parent 38a520a commit 47b8b3a
Show file tree
Hide file tree
Showing 8 changed files with 98 additions and 34 deletions.
75 changes: 53 additions & 22 deletions src/configdialog.ui
Original file line number Diff line number Diff line change
Expand Up @@ -4163,7 +4163,7 @@ them here.</string>
<string>Internal PDF Viewer</string>
</property>
<layout class="QGridLayout" name="gridLayout_4">
<item row="3" column="1">
<item row="4" column="1">
<widget class="QSpinBox" name="spinBoxPreviewScale">
<property name="sizePolicy">
<sizepolicy hsizetype="Minimum" vsizetype="Fixed">
Expand All @@ -4185,7 +4185,7 @@ them here.</string>
</property>
</widget>
</item>
<item row="3" column="0">
<item row="4" column="0">
<widget class="QLabel" name="label_29">
<property name="text">
<string>Scaling:</string>
Expand Down Expand Up @@ -4219,7 +4219,7 @@ them here.</string>
</property>
</widget>
</item>
<item row="6" column="1">
<item row="7" column="1">
<widget class="QSpinBox" name="spinBoxPreviewMagnifierSize">
<property name="suffix">
<string> px</string>
Expand All @@ -4241,7 +4241,7 @@ them here.</string>
</property>
</widget>
</item>
<item row="12" column="1">
<item row="13" column="1">
<widget class="QSpinBox" name="spinBoxHighlightDuration">
<property name="specialValueText">
<string>Infinite</string>
Expand All @@ -4260,7 +4260,7 @@ them here.</string>
</property>
</widget>
</item>
<item row="4" column="1">
<item row="5" column="1">
<widget class="QSpinBox" name="spinBoxPreviewDPI">
<property name="suffix">
<string> dpi</string>
Expand Down Expand Up @@ -4298,7 +4298,7 @@ them here.</string>
</item>
</widget>
</item>
<item row="12" column="0">
<item row="13" column="0">
<widget class="QLabel" name="label_66">
<property name="text">
<string>Highlight Duration</string>
Expand All @@ -4308,7 +4308,7 @@ them here.</string>
</property>
</widget>
</item>
<item row="11" column="1">
<item row="12" column="1">
<widget class="QLineEdit" name="lineEditHighlightColor">
<property name="toolTip">
<string>Specify as hexadecimal RGBA value. Note: The transparency is required because the highlighting is drawn on top of the text due to technical limitations.</string>
Expand All @@ -4324,7 +4324,7 @@ them here.</string>
</property>
</widget>
</item>
<item row="5" column="1">
<item row="6" column="1">
<widget class="QComboBox" name="comboBoxPreviewMagnifierShape">
<item>
<property name="text">
Expand All @@ -4351,7 +4351,7 @@ them here.</string>
</property>
</widget>
</item>
<item row="11" column="0">
<item row="12" column="0">
<widget class="QLabel" name="label_67">
<property name="text">
<string>Highlight Color</string>
Expand All @@ -4361,7 +4361,7 @@ them here.</string>
</property>
</widget>
</item>
<item row="10" column="1">
<item row="11" column="1">
<widget class="QLineEdit" name="lineEditPaperColor">
<property name="toolTip">
<string>Default background color. Specify as hexadecimal RGB value. Note: This will only affect PDFs loaded after the change of the option. The paper color of already open PDFs is not modified.</string>
Expand All @@ -4377,14 +4377,14 @@ them here.</string>
</property>
</widget>
</item>
<item row="4" column="0">
<item row="5" column="0">
<widget class="QLabel" name="labelScreenResolution">
<property name="text">
<string notr="true">&lt;ScreenResolution&gt;</string>
</property>
</widget>
</item>
<item row="7" column="1">
<item row="8" column="1">
<layout class="QHBoxLayout" name="HBoxLayout_magnifier">
<item>
<widget class="QCheckBox" name="checkBoxPreviewMagnifierBorder">
Expand Down Expand Up @@ -4415,7 +4415,7 @@ them here.</string>
</item>
</layout>
</item>
<item row="1" column="1">
<item row="2" column="1">
<widget class="QComboBox" name="comboBoxPreviewScale">
<item>
<property name="text">
Expand Down Expand Up @@ -4476,7 +4476,7 @@ them here.</string>
</property>
</widget>
</item>
<item row="10" column="0">
<item row="11" column="0">
<widget class="QLabel" name="label_84">
<property name="text">
<string>Paper Color</string>
Expand All @@ -4502,7 +4502,7 @@ Note: Changing this setting will only affect documents that are opened afterward
</property>
</widget>
</item>
<item row="8" column="0">
<item row="9" column="0">
<widget class="QLabel" name="label_88">
<property name="text">
<string>Presentation Laser Pointer Size:</string>
Expand All @@ -4516,7 +4516,7 @@ Note: Changing this setting will only affect documents that are opened afterward
</property>
</widget>
</item>
<item row="2" column="1">
<item row="3" column="1">
<widget class="QCheckBox" name="checkBoxDisableHorizontalScrollingForFitToTextWidth">
<property name="text">
<string>Disable horizontal scrolling for &quot;Fit to Text Width&quot;</string>
Expand All @@ -4526,14 +4526,14 @@ Note: Changing this setting will only affect documents that are opened afterward
</property>
</widget>
</item>
<item row="1" column="0">
<item row="2" column="0">
<widget class="QLabel" name="label_28">
<property name="text">
<string>Scale Option:</string>
</property>
</widget>
</item>
<item row="5" column="0">
<item row="6" column="0">
<widget class="QLabel" name="label_26">
<property name="text">
<string>Magnifier Shape:</string>
Expand Down Expand Up @@ -4563,7 +4563,7 @@ Note: Changing this setting will only affect documents that are opened afterward
</item>
</widget>
</item>
<item row="6" column="0">
<item row="7" column="0">
<widget class="QLabel" name="label_25">
<property name="text">
<string>Magnifier Size:</string>
Expand All @@ -4577,23 +4577,54 @@ Note: Changing this setting will only affect documents that are opened afterward
</property>
</widget>
</item>
<item row="9" column="0">
<item row="10" column="0">
<widget class="QLabel" name="label_89">
<property name="text">
<string>Presentation Laser Pointer Color:</string>
</property>
</widget>
</item>
<item row="8" column="1">
<item row="9" column="1">
<widget class="QSpinBox" name="spinBoxPreviewLaserPointerSize">
<property name="suffix">
<string> px</string>
</property>
</widget>
</item>
<item row="9" column="1">
<item row="10" column="1">
<widget class="QLineEdit" name="lineEditLaserPointerColor"/>
</item>
<item row="1" column="0">
<widget class="QLabel" name="labelComboPdfViewerLoc">
<property name="text">
<string>Embedded Viewer Location:</string>
</property>
</widget>
</item>
<item row="1" column="1">
<widget class="QComboBox" name="comboBoxViewerLocation">
<item>
<property name="text">
<string>Left</string>
</property>
</item>
<item>
<property name="text">
<string>Right</string>
</property>
</item>
<item>
<property name="text">
<string>Top</string>
</property>
</item>
<item>
<property name="text">
<string>Bottom</string>
</property>
</item>
</widget>
</item>
</layout>
</widget>
</item>
Expand Down
2 changes: 2 additions & 0 deletions src/configmanager.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@
#include "webpublishdialog_config.h"
#include "insertgraphics_config.h"
#include "grammarcheck_config.h"
#include "PDFDocument.h"
#include "PDFDocument_config.h"
#include "terminal_config.h"
#include "encoding.h"
Expand Down Expand Up @@ -772,6 +773,7 @@ ConfigManager::ConfigManager(QObject *parent): QObject (parent),
registerOption("Preview/Sync File Mask", &pdfDocumentConfig->syncFileMask, "*.tex;*.tikz;*.pdf_tex;*.ctx", &pseudoDialog->lineEditPreviewSyncFileMask);
registerOption("Preview/AutoHideToolbars", &pdfDocumentConfig->autoHideToolbars, false, &pseudoDialog->autoHideToolbars);
registerOption("Preview/Auto Full Recompile", &editorConfig->fullCompilePreview, false, &pseudoDialog->autoRecompileFullDocument);
registerOption("Preview/ViewerLocation", &pdfDocumentConfig->viewerLocation, PDFviewerRight, &pseudoDialog->comboBoxViewerLocation);

registerOption("Preview/EnlargedEmbedded", &viewerEnlarged, false);

Expand Down
1 change: 1 addition & 0 deletions src/main.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -202,6 +202,7 @@ int main(int argc, char **argv)
#endif
// This is a dummy constructor so that the programs loads fast.
TexstudioApp a(appId, argc, argv);
qputenv("QT_ASSUME_STDERR_HAS_CONSOLE", "1");
bool startAlways = false;
QStringList cmdLine = parseArguments(QCoreApplication::arguments(), startAlways);

Expand Down
2 changes: 1 addition & 1 deletion src/pdfviewer/PDFDocument.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -4281,7 +4281,7 @@ void PDFDocument::setCurrentFile(const QString &fileName)
curFileUnnormalized = fileName;
curFile = QFileInfo(fileName).canonicalFilePath();
QString niceFile = QFileInfo(curFile).fileName();
setWindowTitle(tr("%1[*] - %2").arg(niceFile,tr(TEXSTUDIO)));
setWindowTitle(tr("%1[*] - %2 [_pdfViewer] %3").arg(niceFile,tr(TEXSTUDIO),TEXSTUDIO_GIT_REVISION ? TEXSTUDIO_GIT_REVISION : "n/a"));
}

PDFDocument *PDFDocument::findDocument(const QString &fileName)
Expand Down
7 changes: 7 additions & 0 deletions src/pdfviewer/PDFDocument.h
Original file line number Diff line number Diff line change
Expand Up @@ -166,6 +166,13 @@ typedef enum {
kFitTextWidth
} autoScaleOption;

enum PDFviewerLocation {
PDFviewerLeft,
PDFviewerRight,
PDFviewerTop,
PDFviewerBottom
};

struct PDFPageHistoryItem{
int page;
double x, y;
Expand Down
1 change: 1 addition & 0 deletions src/pdfviewer/PDFDocument_config.h
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,7 @@ struct PDFDocumentConfig {
QString paperColor; // hex rgb
QString highlightColor; // hex rgba, e.g. #FFFF003F
int highlightDuration;
int viewerLocation;

//live options
int editTool;
Expand Down
42 changes: 32 additions & 10 deletions src/texstudio.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -327,10 +327,21 @@ Texstudio::Texstudio(QWidget *parent, Qt::WindowFlags flags, QSplashScreen *spla
sidePanelSplitter = new MiniSplitter(Qt::Horizontal, this);
sidePanelSplitter->addWidget(centralVSplitter);

mainHSplitter = new MiniSplitter(Qt::Horizontal, this); // top-level element: splits: [ everything else | PDF ]
mainHSplitter->addWidget(sidePanelSplitter);
mainHSplitter->setChildrenCollapsible(false);
setCentralWidget(mainHSplitter);
Qt::Orientation orientation;
switch(configManager.pdfDocumentConfig->viewerLocation) {
case PDFviewerTop:
case PDFviewerBottom: orientation = Qt::Vertical;
break;
case PDFviewerLeft:
case PDFviewerRight: orientation = Qt::Horizontal;
break;
default: orientation = Qt::Horizontal;
}
mainHorVerSplitter = new MiniSplitter(orientation, this); // top-level element: splits: [ everything else | PDF ]

mainHorVerSplitter->addWidget(sidePanelSplitter);
mainHorVerSplitter->setChildrenCollapsible(false);
setCentralWidget(mainHorVerSplitter);

setContextMenuPolicy(Qt::ActionsContextMenu);

Expand Down Expand Up @@ -1839,7 +1850,7 @@ void Texstudio::updateCaption()
updateOpenDocumentMenu(true);
newDocumentLineEnding();
}
setWindowTitle(title);
setWindowTitle(title + QString(" [_pdfViewer] %1").arg(TEXSTUDIO_GIT_REVISION ? TEXSTUDIO_GIT_REVISION : "n/a"));
updateUndoRedoStatus();
cursorPositionChanged();
if (documents.singleMode()) {
Expand Down Expand Up @@ -4543,7 +4554,7 @@ void Texstudio::saveSettings(const QString &configName)
if (!PDFDocument::documentList().isEmpty()) {
PDFDocument *doc = PDFDocument::documentList().constFirst();
if (doc->embeddedMode) {
QList<int> sz = mainHSplitter->sizes(); // set widths to 50%, eventually restore user setting
QList<int> sz = mainHorVerSplitter->sizes(); // set widths to 50%, eventually restore user setting
int sum = 0;
int last = 0;
foreach (int i, sz) {
Expand Down Expand Up @@ -7531,7 +7542,7 @@ void Texstudio::pdfClosed()
if (from) {
if (from->embeddedMode) {
shrinkEmbeddedPDFViewer(true);
QList<int> sz = mainHSplitter->sizes(); // set widths to 50%, eventually restore user setting
QList<int> sz = mainHorVerSplitter->sizes(); // set widths to 50%, eventually restore user setting
int sum = 0;
int last = 0;
foreach (int i, sz) {
Expand All @@ -7553,8 +7564,19 @@ QObject *Texstudio::newPdfPreviewer(bool embedded)
PDFDocument *pdfviewerWindow = new PDFDocument(configManager.pdfDocumentConfig, embedded);
pdfviewerWindow->setToolbarIconSize(pdfviewerWindow->embeddedMode ? configManager.guiPDFToolbarIconSize : configManager.guiToolbarIconSize);
if (embedded) {
mainHSplitter->addWidget(pdfviewerWindow);
QList<int> sz = mainHSplitter->sizes(); // set widths to 50%, eventually restore user setting
int index;
switch(configManager.pdfDocumentConfig->viewerLocation) {
case PDFviewerTop:
case PDFviewerLeft: index = 0;
break;
case PDFviewerBottom:
case PDFviewerRight: index = 1;
break;
default: index = 1;
}
mainHorVerSplitter->insertWidget(index,pdfviewerWindow);

QList<int> sz = mainHorVerSplitter->sizes(); // set widths to 50%, eventually restore user setting
int sum = 0;
foreach (int i, sz) {
sum += i;
Expand All @@ -7564,7 +7586,7 @@ QObject *Texstudio::newPdfPreviewer(bool embedded)
pdfSplitterRel = 0.5;
sz << sum - qRound(pdfSplitterRel * sum);
sz << qRound(pdfSplitterRel * sum);
mainHSplitter->setSizes(sz);
mainHorVerSplitter->setSizes(sz);
}
connect(pdfviewerWindow, SIGNAL(triggeredAbout()), SLOT(helpAbout()));
connect(pdfviewerWindow, SIGNAL(triggeredEnlarge()), SLOT(enlargeEmbeddedPDFViewer()));
Expand Down
2 changes: 1 addition & 1 deletion src/texstudio.h
Original file line number Diff line number Diff line change
Expand Up @@ -156,7 +156,7 @@ private slots:
//gui
Editors *editors;
QSplitter *sidePanelSplitter;
QSplitter *mainHSplitter;
QSplitter *mainHorVerSplitter;
QSplitter *centralVSplitter;
QFrame *centralFrame;
QToolBar *centralToolBar;
Expand Down

0 comments on commit 47b8b3a

Please sign in to comment.