diff --git a/src/pdfviewer/PDFDocument.cpp b/src/pdfviewer/PDFDocument.cpp index bc10e5d40..da4e80e1b 100644 --- a/src/pdfviewer/PDFDocument.cpp +++ b/src/pdfviewer/PDFDocument.cpp @@ -2880,10 +2880,6 @@ PDFDocument::PDFDocument(PDFDocumentConfig *const pdfConfig, bool embedded) if (embeddedMode && globalConfig->autoHideToolbars) { setAutoHideToolbars(true); } - ConfigManager *configManager=dynamic_cast(ConfigManager::getInstance()); - if(!configManager) return; - bool enlarged=configManager->viewerEnlarged; - setVisibleMenuEntriesEnlargeShrink(embeddedMode && !enlarged, embeddedMode && enlarged); } PDFDocument::~PDFDocument() @@ -2893,10 +2889,6 @@ PDFDocument::~PDFDocument() ConfigManager *configManager=dynamic_cast(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 keys=configManager->specialShortcuts.keys(); foreach(QKeySequence key,keys){ @@ -3781,10 +3773,6 @@ void PDFDocument::runInternalViewer() void PDFDocument::toggleEmbedded() { - ConfigManager *configManager=dynamic_cast(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 @@ -3866,7 +3854,6 @@ void PDFDocument::setStateEnlarged(bool state) { actionEnlargeViewer->setVisible(!state); actionShrinkViewer->setVisible(state); - setVisibleMenuEntriesEnlargeShrink(!state, state); } /*! @@ -4890,14 +4877,4 @@ void PDFDocument::splitMergeTool() psmt->show(); } -void PDFDocument::setVisibleMenuEntriesEnlargeShrink(bool visibleEnlarge, bool visibleShrink) -{ - ConfigManager *configManager=dynamic_cast(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 diff --git a/src/pdfviewer/PDFDocument.h b/src/pdfviewer/PDFDocument.h index 4b8bbffaf..7ca022804 100644 --- a/src/pdfviewer/PDFDocument.h +++ b/src/pdfviewer/PDFDocument.h @@ -565,7 +565,6 @@ 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); diff --git a/src/texstudio.cpp b/src/texstudio.cpp index bad5d45af..867b9286b 100644 --- a/src/texstudio.cpp +++ b/src/texstudio.cpp @@ -1404,9 +1404,9 @@ void Texstudio::setupMenus() } act=newManagedAction(menu, "enlargePDF", tr("Show embedded PDF large"), SLOT(enlargeEmbeddedPDFViewer())); - act->setVisible(false); + act->setEnabled(false); act=newManagedAction(menu, "shrinkPDF", tr("Show embedded PDF small"), SLOT(shrinkEmbeddedPDFViewer())); - act->setVisible(false); + act->setEnabled(false); newManagedAction(menu, "closeelement", tr("Close Element"), SLOT(viewCloseElement()), Qt::Key_Escape); menu->addSeparator(); @@ -6216,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; } @@ -7740,6 +7741,7 @@ void Texstudio::pdfClosed() PDFDocument *from = qobject_cast(sender()); if (from) { if (from->embeddedMode) { + setEnabledMenusEnlargeShrink(false, false); shrinkEmbeddedPDFViewer(true); QList sz = mainHSplitter->sizes(); // set widths to 50%, eventually restore user setting int sum = 0; @@ -11380,6 +11382,7 @@ void Texstudio::enlargeEmbeddedPDFViewer() enlargedViewer=true; pdfConfig->followFromScroll=false; viewer->setStateEnlarged(true); + setEnabledMenusEnlargeShrink(false, true); #endif } /*! @@ -11404,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(sender()); diff --git a/src/texstudio.h b/src/texstudio.h index e49cc6c7e..409e169f1 100644 --- a/src/texstudio.h +++ b/src/texstudio.h @@ -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();