Skip to content

Commit

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

ConfigManager *configManager=dynamic_cast<ConfigManager *>(ConfigManager::getInstance());
if(!configManager) return;
bool enlarged=configManager->viewerEnlarged;
setVisibleMenuEntriesEnlargeShrink(embeddedMode && !enlarged, embeddedMode && enlarged);
}

PDFDocument::~PDFDocument()
Expand All @@ -2890,6 +2893,10 @@ PDFDocument::~PDFDocument()
ConfigManager *configManager=dynamic_cast<ConfigManager *>(ConfigManager::getInstance());

if(configManager){
if (embeddedMode) {
QAction *act=configManager->getManagedAction("main/view/enlargePDF");
setVisibleMenuEntriesEnlargeShrink(false, false);
}
#if (QT_VERSION > 0x050000) && (QT_VERSION <= 0x050700) && (defined(Q_OS_MAC))
QList<QKeySequence> keys=configManager->specialShortcuts.keys();
foreach(QKeySequence key,keys){
Expand Down Expand Up @@ -3774,6 +3781,10 @@ void PDFDocument::runInternalViewer()

void PDFDocument::toggleEmbedded()
{
ConfigManager *configManager=dynamic_cast<ConfigManager *>(ConfigManager::getInstance());
if(!configManager) return;
bool enlarged=configManager->viewerEnlarged;
setVisibleMenuEntriesEnlargeShrink(!embeddedMode && !enlarged, !embeddedMode && enlarged);
if (embeddedMode)
emit runCommand("txs:///view-pdf-internal --windowed --close-embedded", masterFile, QFileInfo(lastSyncPoint.filename), lastSyncPoint.line);
else
Expand Down Expand Up @@ -3855,6 +3866,7 @@ void PDFDocument::setStateEnlarged(bool state)
{
actionEnlargeViewer->setVisible(!state);
actionShrinkViewer->setVisible(state);
setVisibleMenuEntriesEnlargeShrink(!state, state);
}

/*!
Expand Down Expand Up @@ -4878,4 +4890,14 @@ void PDFDocument::splitMergeTool()
psmt->show();
}

void PDFDocument::setVisibleMenuEntriesEnlargeShrink(bool visibleEnlarge, bool visibleShrink)
{
ConfigManager *configManager=dynamic_cast<ConfigManager *>(ConfigManager::getInstance());
if(!configManager) return;
QAction *act=configManager->getManagedAction("main/view/enlargePDF");
act->setVisible(visibleEnlarge);
act=configManager->getManagedAction("main/view/shrinkPDF");
act->setVisible(visibleShrink);
}

#endif // ndef NO_POPPLER_PREVIEW
1 change: 1 addition & 0 deletions src/pdfviewer/PDFDocument.h
Original file line number Diff line number Diff line change
Expand Up @@ -565,6 +565,7 @@ private slots:
void setupToolBar();
void setCurrentFile(const QString &fileName);
void loadSyncData();
void setVisibleMenuEntriesEnlargeShrink(bool visibleEnlarge, bool visibleShrink);

qreal zoomSliderPosToScale(int pos);
int scaleToZoomSliderPos(qreal scale);
Expand Down
5 changes: 2 additions & 3 deletions src/texstudio.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1403,9 +1403,8 @@ void Texstudio::setupMenus()
}
}

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

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

menu->addSeparator();
Expand Down

0 comments on commit c419d43

Please sign in to comment.