Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix issues with windowed pdf-viewer #3419

Closed
wants to merge 2 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
42 changes: 29 additions & 13 deletions src/pdfviewer/PDFDocument.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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();
Expand Down Expand Up @@ -3000,8 +3012,10 @@ void PDFDocument::setupMenus(bool embedded)
actionGrayscale=configManager->newManagedAction(menuroot,menuEdit, "grayscale", tr("Grayscale"), pdfWidget, SLOT(update()), QList<QKeySequence>());
actionGrayscale->setCheckable(true);

actionMagnify=configManager->newManagedAction(menuroot,menuView, "magnify", tr("&Magnify"), this, "", QList<QKeySequence>(),"magnifier-button");
actionScroll=configManager->newManagedAction(menuroot,menuView, "scroll", tr("&Scroll"), this, "", QList<QKeySequence>(),"hand");
actionMagnify=configManager->newManagedAction(menuroot,menuView, "magnify", tr("&Magnify"), pdfWidget, SLOT(magnifierClicked()), QList<QKeySequence>(),"magnifier-button");
actionMagnify->setCheckable(true);
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

now magnify can also be unchecked in the menu ...

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

ok, needs to be fixed

actionScroll=configManager->newManagedAction(menuroot,menuView, "scroll", tr("&Scroll"), pdfWidget, SLOT(scrollClicked()), QList<QKeySequence>(),"hand");
actionScroll->setCheckable(true);
menuView->addSeparator();
actionFirst_Page=configManager->newManagedAction(menuroot,menuView, "firstPage", tr("&First Page"), pdfWidget, SLOT(goFirst()), QList<QKeySequence>()<<Qt::Key_Home<<QKeySequence(Qt::ControlModifier | Qt::Key_Home),"go-first");
actionBack=configManager->newManagedAction(menuroot,menuView, "back", tr("Back"), pdfWidget, SLOT(goBack()), QList<QKeySequence>()<< QKeySequence(Qt::AltModifier | Qt::Key_L),"back");
Expand Down Expand Up @@ -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)));
Expand Down Expand Up @@ -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);
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

what scenario is fixed here ?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

before closing the window we need to undo the changes done for fullscreen window mode.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

see 3rd list item of PR

actionClose->trigger();
} else {
return false; // nothing to close
Expand Down Expand Up @@ -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();
Expand All @@ -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
Expand All @@ -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()
Expand Down
5 changes: 5 additions & 0 deletions src/pdfviewer/PDFDocument.h
Original file line number Diff line number Diff line change
Expand Up @@ -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();
Expand Down Expand Up @@ -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;
Expand Down
1 change: 1 addition & 0 deletions utilities/manual/source/CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand Down