Skip to content

Commit

Permalink
make menu entries Show embedded PDF large/small consistent (#3931)
Browse files Browse the repository at this point in the history
  • Loading branch information
octaeder authored Jan 5, 2025
1 parent 1755c72 commit 66b810b
Show file tree
Hide file tree
Showing 3 changed files with 17 additions and 4 deletions.
1 change: 0 additions & 1 deletion src/pdfviewer/PDFDocument.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -2880,7 +2880,6 @@ PDFDocument::PDFDocument(PDFDocumentConfig *const pdfConfig, bool embedded)
if (embeddedMode && globalConfig->autoHideToolbars) {
setAutoHideToolbars(true);
}

}

PDFDocument::~PDFDocument()
Expand Down
19 changes: 16 additions & 3 deletions src/texstudio.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1403,9 +1403,10 @@ void Texstudio::setupMenus()
}
}

newManagedAction(menu, "enlargePDF", tr("Show embedded PDF large"), SLOT(enlargeEmbeddedPDFViewer()));
newManagedAction(menu, "shrinkPDF", tr("Show embedded PDF small"), SLOT(shrinkEmbeddedPDFViewer()));

act=newManagedAction(menu, "enlargePDF", tr("Show embedded PDF large"), SLOT(enlargeEmbeddedPDFViewer()));
act->setEnabled(false);
act=newManagedAction(menu, "shrinkPDF", tr("Show embedded PDF small"), SLOT(shrinkEmbeddedPDFViewer()));
act->setEnabled(false);
newManagedAction(menu, "closeelement", tr("Close Element"), SLOT(viewCloseElement()), Qt::Key_Escape);

menu->addSeparator();
Expand Down Expand Up @@ -6215,6 +6216,7 @@ void Texstudio::runInternalPdfViewer(const QFileInfo &master, const QString &opt
viewer->setStateEnlarged(true);
centralVSplitter->hide();
}
setEnabledMenusEnlargeShrink(viewer->embeddedMode && !configManager.viewerEnlarged, viewer->embeddedMode && configManager.viewerEnlarged);

if (preserveDuplicates) break;
}
Expand Down Expand Up @@ -7739,6 +7741,7 @@ void Texstudio::pdfClosed()
PDFDocument *from = qobject_cast<PDFDocument *>(sender());
if (from) {
if (from->embeddedMode) {
setEnabledMenusEnlargeShrink(false, false);
shrinkEmbeddedPDFViewer(true);
QList<int> sz = mainHSplitter->sizes(); // set widths to 50%, eventually restore user setting
int sum = 0;
Expand Down Expand Up @@ -11379,6 +11382,7 @@ void Texstudio::enlargeEmbeddedPDFViewer()
enlargedViewer=true;
pdfConfig->followFromScroll=false;
viewer->setStateEnlarged(true);
setEnabledMenusEnlargeShrink(false, true);
#endif
}
/*!
Expand All @@ -11403,11 +11407,20 @@ void Texstudio::shrinkEmbeddedPDFViewer(bool preserveConfig)
enlargedViewer=false;
}
viewer->setStateEnlarged(false);
setEnabledMenusEnlargeShrink(true, false);
#else
Q_UNUSED(preserveConfig)
#endif
}

void Texstudio::setEnabledMenusEnlargeShrink(bool enabledEnlarge, bool enabledShrink)
{
QAction *act=configManager.getManagedAction("main/view/enlargePDF");
act->setEnabled(enabledEnlarge);
act=configManager.getManagedAction("main/view/shrinkPDF");
act->setEnabled(enabledShrink);
}

void Texstudio::showStatusbar()
{
QAction *act = qobject_cast<QAction *>(sender());
Expand Down
1 change: 1 addition & 0 deletions src/texstudio.h
Original file line number Diff line number Diff line change
Expand Up @@ -560,6 +560,7 @@ protected slots:
void focusViewer();
void enlargeEmbeddedPDFViewer();
void shrinkEmbeddedPDFViewer(bool preserveConfig = false);
void setEnabledMenusEnlargeShrink(bool enabledEnlarge, bool enabledShrink);

void showStatusbar();
void viewCloseElement();
Expand Down

0 comments on commit 66b810b

Please sign in to comment.