From 0706514b203c6619077f79a235038223d1a7d7a0 Mon Sep 17 00:00:00 2001 From: octaeder <102688820+octaeder@users.noreply.github.com> Date: Thu, 14 Dec 2023 13:35:21 +0100 Subject: [PATCH 1/2] fix issues with windowed pdf-viewer --- src/pdfviewer/PDFDocument.cpp | 42 ++++++++++++++++++++++++----------- src/pdfviewer/PDFDocument.h | 5 +++++ 2 files changed, 34 insertions(+), 13 deletions(-) diff --git a/src/pdfviewer/PDFDocument.cpp b/src/pdfviewer/PDFDocument.cpp index 2282248bfa..93d6d16943 100644 --- a/src/pdfviewer/PDFDocument.cpp +++ b/src/pdfviewer/PDFDocument.cpp @@ -2809,6 +2809,18 @@ void PDFWidget::restoreState() emit changedScaleOption(scaleOption); } +void PDFWidget::magnifierClicked() +{ + setTool(kMagnifier); + updateCursor(); +} + +void PDFWidget::scrollClicked() +{ + setTool(kScroll); + updateCursor(); +} + PDFScrollArea *PDFWidget::getScrollArea() const { QWidget *parent = parentWidget(); @@ -3000,8 +3012,10 @@ void PDFDocument::setupMenus(bool embedded) actionGrayscale=configManager->newManagedAction(menuroot,menuEdit, "grayscale", tr("Grayscale"), pdfWidget, SLOT(update()), QList()); actionGrayscale->setCheckable(true); - actionMagnify=configManager->newManagedAction(menuroot,menuView, "magnify", tr("&Magnify"), this, "", QList(),"magnifier-button"); - actionScroll=configManager->newManagedAction(menuroot,menuView, "scroll", tr("&Scroll"), this, "", QList(),"hand"); + actionMagnify=configManager->newManagedAction(menuroot,menuView, "magnify", tr("&Magnify"), pdfWidget, SLOT(magnifierClicked()), QList(),"magnifier-button"); + actionMagnify->setCheckable(true); + actionScroll=configManager->newManagedAction(menuroot,menuView, "scroll", tr("&Scroll"), pdfWidget, SLOT(scrollClicked()), QList(),"hand"); + actionScroll->setCheckable(true); menuView->addSeparator(); actionFirst_Page=configManager->newManagedAction(menuroot,menuView, "firstPage", tr("&First Page"), pdfWidget, SLOT(goFirst()), QList()<newManagedAction(menuroot,menuView, "back", tr("Back"), pdfWidget, SLOT(goBack()), QList()<< QKeySequence(Qt::AltModifier | Qt::Key_L),"back"); @@ -3360,6 +3374,7 @@ void PDFDocument::init(bool embedded) //connect(actionZoom_Out, SIGNAL(triggered()), pdfWidget, SLOT(zoomOut())); //connect(actionFull_Screen, SIGNAL(triggered(bool)), this, SLOT(toggleFullScreen(bool))); //connect(actionPresentation, SIGNAL(triggered(bool)), this, SLOT(toggleFullScreen(bool))); + wasFullScreen = false; connect(pdfWidget, SIGNAL(changedZoom(qreal)), this, SLOT(enableZoomActions(qreal))); connect(pdfWidget, SIGNAL(changedScaleOption(autoScaleOption)), this, SLOT(adjustScaleActions(autoScaleOption))); connect(pdfWidget, SIGNAL(syncClick(int,const QPointF&,bool)), this, SLOT(syncClick(int,const QPointF&,bool))); @@ -3898,6 +3913,7 @@ bool PDFDocument::closeElement() else if (dwOverview && dwOverview->isVisible()) dwOverview->hide(); else if (configManager->useEscForClosingEmbeddedViewer && isVisible()) { // Note: avoid crash on osx where esc key is passed to hidden window + toggleFullScreen(false); actionClose->trigger(); } else { return false; // nothing to close @@ -4454,12 +4470,16 @@ void PDFDocument::toggleFullScreen(bool fullscreen) { bool presentation = false; if (fullscreen) { - // entering full-screen mode + // entering full-screen mode (maybe a second time when switching from fullscreen to presentation) + if (!wasFullScreen) { + wasContinuous = actionContinuous->isChecked() == true; + wasShowToolBar = toolBar->isVisible() == true; + } + pdfWidget->saveState(); statusBar()->hide(); toolBar->hide(); globalConfig->windowMaximized = isMaximized(); showFullScreen(); - pdfWidget->saveState(); pdfWidget->fitWindow(true); dwVisOutline = dwOutline->isVisible(); dwVisOverview = dwOverview->isVisible(); @@ -4479,18 +4499,14 @@ void PDFDocument::toggleFullScreen(bool fullscreen) dwInfo->hide(); dwOverview->hide(); presentation = true; - if (actionContinuous->isChecked()) { - actionContinuous->setChecked(false); - wasContinuous = true; - } else wasContinuous = false; + if (wasContinuous) actionContinuous->setChecked(false); } else actionFull_Screen->setChecked(true); - - //actionFull_Screen->setChecked(true); } else { // exiting full-screen mode statusBar()->show(); - toolBar->show(); + if (wasContinuous) actionContinuous->setChecked(true); + if (wasShowToolBar) toolBar->show(); if (globalConfig->windowMaximized) showMaximized(); else @@ -4505,10 +4521,10 @@ void PDFDocument::toggleFullScreen(bool fullscreen) pdfWidget->setContextMenuPolicy(Qt::DefaultContextMenu); if (exitFullscreen) { delete exitFullscreen; - exitFullscreen = nullptr; + exitFullscreen = nullptr; } - if (wasContinuous) actionContinuous->setChecked(true); } + wasFullScreen = fullscreen; } void PDFDocument::zoomFromAction() diff --git a/src/pdfviewer/PDFDocument.h b/src/pdfviewer/PDFDocument.h index 9ea75a64e1..d86db2d1fd 100644 --- a/src/pdfviewer/PDFDocument.h +++ b/src/pdfviewer/PDFDocument.h @@ -242,6 +242,9 @@ protected slots: //not private, so scripts have access void goBack(); void doPageDialog(); + void magnifierClicked(); + void scrollClicked(); + void fitWidth(bool checked = true); void fitTextWidth(bool checked = true); void zoomIn(); @@ -705,6 +708,8 @@ private slots: PDFDock *dwClock, *dwOutline, *dwFonts, *dwInfo, *dwOverview; bool dwVisOutline, dwVisFonts, dwVisInfo, dwVisSearch, dwVisOverview; bool wasContinuous; + bool wasShowToolBar; + bool wasFullScreen; PDFSearchDock *dwSearch; PDFSearchResult lastSearchResult; From 3d6ab5cd61df0ac49f5c31697f2e03612e0f3990 Mon Sep 17 00:00:00 2001 From: octaeder <102688820+octaeder@users.noreply.github.com> Date: Thu, 14 Dec 2023 14:02:20 +0100 Subject: [PATCH 2/2] Update CHANGELOG.md --- utilities/manual/source/CHANGELOG.md | 1 + 1 file changed, 1 insertion(+) diff --git a/utilities/manual/source/CHANGELOG.md b/utilities/manual/source/CHANGELOG.md index 4fb4f678e8..977db5339f 100644 --- a/utilities/manual/source/CHANGELOG.md +++ b/utilities/manual/source/CHANGELOG.md @@ -3,6 +3,7 @@ ## TeXstudio 4.7.2 - fix duplicate shortcut in 'Additional Shortcut' column is not removed [#3408](https://github.com/texstudio-org/texstudio/pull/3408) +- fix some minor issues in the windowed internal pdf-viewer [#3419](https://github.com/texstudio-org/texstudio/pull/3419) ## TeXstudio 4.7.1