From 47b8b3a16f988b5b3b52f0586c542846d3f8688b Mon Sep 17 00:00:00 2001 From: octaeder <102688820+octaeder@users.noreply.github.com> Date: Sun, 31 Dec 2023 06:56:38 +0100 Subject: [PATCH] option where to place embedded pdf-viewer --- src/configdialog.ui | 75 +++++++++++++++++++++--------- src/configmanager.cpp | 2 + src/main.cpp | 1 + src/pdfviewer/PDFDocument.cpp | 2 +- src/pdfviewer/PDFDocument.h | 7 +++ src/pdfviewer/PDFDocument_config.h | 1 + src/texstudio.cpp | 42 +++++++++++++---- src/texstudio.h | 2 +- 8 files changed, 98 insertions(+), 34 deletions(-) diff --git a/src/configdialog.ui b/src/configdialog.ui index fb155c5d4d..ae4065ec68 100644 --- a/src/configdialog.ui +++ b/src/configdialog.ui @@ -4163,7 +4163,7 @@ them here. Internal PDF Viewer - + @@ -4185,7 +4185,7 @@ them here. - + Scaling: @@ -4219,7 +4219,7 @@ them here. - + px @@ -4241,7 +4241,7 @@ them here. - + Infinite @@ -4260,7 +4260,7 @@ them here. - + dpi @@ -4298,7 +4298,7 @@ them here. - + Highlight Duration @@ -4308,7 +4308,7 @@ them here. - + Specify as hexadecimal RGBA value. Note: The transparency is required because the highlighting is drawn on top of the text due to technical limitations. @@ -4324,7 +4324,7 @@ them here. - + @@ -4351,7 +4351,7 @@ them here. - + Highlight Color @@ -4361,7 +4361,7 @@ them here. - + 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. @@ -4377,14 +4377,14 @@ them here. - + <ScreenResolution> - + @@ -4415,7 +4415,7 @@ them here. - + @@ -4476,7 +4476,7 @@ them here. - + Paper Color @@ -4502,7 +4502,7 @@ Note: Changing this setting will only affect documents that are opened afterward - + Presentation Laser Pointer Size: @@ -4516,7 +4516,7 @@ Note: Changing this setting will only affect documents that are opened afterward - + Disable horizontal scrolling for "Fit to Text Width" @@ -4526,14 +4526,14 @@ Note: Changing this setting will only affect documents that are opened afterward - + Scale Option: - + Magnifier Shape: @@ -4563,7 +4563,7 @@ Note: Changing this setting will only affect documents that are opened afterward - + Magnifier Size: @@ -4577,23 +4577,54 @@ Note: Changing this setting will only affect documents that are opened afterward - + Presentation Laser Pointer Color: - + px - + + + + + Embedded Viewer Location: + + + + + + + + Left + + + + + Right + + + + + Top + + + + + Bottom + + + + diff --git a/src/configmanager.cpp b/src/configmanager.cpp index d069867efa..e1f1d441b7 100644 --- a/src/configmanager.cpp +++ b/src/configmanager.cpp @@ -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" @@ -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); diff --git a/src/main.cpp b/src/main.cpp index 25c8bdab91..c7c5fbfa78 100644 --- a/src/main.cpp +++ b/src/main.cpp @@ -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); diff --git a/src/pdfviewer/PDFDocument.cpp b/src/pdfviewer/PDFDocument.cpp index 620dc26413..9b6d4ee71a 100644 --- a/src/pdfviewer/PDFDocument.cpp +++ b/src/pdfviewer/PDFDocument.cpp @@ -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) diff --git a/src/pdfviewer/PDFDocument.h b/src/pdfviewer/PDFDocument.h index d86db2d1fd..7e8cbf2100 100644 --- a/src/pdfviewer/PDFDocument.h +++ b/src/pdfviewer/PDFDocument.h @@ -166,6 +166,13 @@ typedef enum { kFitTextWidth } autoScaleOption; +enum PDFviewerLocation { + PDFviewerLeft, + PDFviewerRight, + PDFviewerTop, + PDFviewerBottom +}; + struct PDFPageHistoryItem{ int page; double x, y; diff --git a/src/pdfviewer/PDFDocument_config.h b/src/pdfviewer/PDFDocument_config.h index 1a906d7b5c..474e5c4e0d 100644 --- a/src/pdfviewer/PDFDocument_config.h +++ b/src/pdfviewer/PDFDocument_config.h @@ -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; diff --git a/src/texstudio.cpp b/src/texstudio.cpp index 7b10a1839d..f1ca60f57c 100644 --- a/src/texstudio.cpp +++ b/src/texstudio.cpp @@ -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); @@ -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()) { @@ -4543,7 +4554,7 @@ void Texstudio::saveSettings(const QString &configName) if (!PDFDocument::documentList().isEmpty()) { PDFDocument *doc = PDFDocument::documentList().constFirst(); if (doc->embeddedMode) { - QList sz = mainHSplitter->sizes(); // set widths to 50%, eventually restore user setting + QList sz = mainHorVerSplitter->sizes(); // set widths to 50%, eventually restore user setting int sum = 0; int last = 0; foreach (int i, sz) { @@ -7531,7 +7542,7 @@ void Texstudio::pdfClosed() if (from) { if (from->embeddedMode) { shrinkEmbeddedPDFViewer(true); - QList sz = mainHSplitter->sizes(); // set widths to 50%, eventually restore user setting + QList sz = mainHorVerSplitter->sizes(); // set widths to 50%, eventually restore user setting int sum = 0; int last = 0; foreach (int i, sz) { @@ -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 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 sz = mainHorVerSplitter->sizes(); // set widths to 50%, eventually restore user setting int sum = 0; foreach (int i, sz) { sum += i; @@ -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())); diff --git a/src/texstudio.h b/src/texstudio.h index 447985f53f..647c662575 100644 --- a/src/texstudio.h +++ b/src/texstudio.h @@ -156,7 +156,7 @@ private slots: //gui Editors *editors; QSplitter *sidePanelSplitter; - QSplitter *mainHSplitter; + QSplitter *mainHorVerSplitter; QSplitter *centralVSplitter; QFrame *centralFrame; QToolBar *centralToolBar;