Skip to content

Commit

Permalink
move changes from PDFdocument to Texstudio
Browse files Browse the repository at this point in the history
  • Loading branch information
octaeder committed Jan 5, 2025
1 parent 0b95895 commit f4e3bfe
Show file tree
Hide file tree
Showing 4 changed files with 15 additions and 26 deletions.
23 changes: 0 additions & 23 deletions src/pdfviewer/PDFDocument.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -2880,10 +2880,6 @@ 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 @@ -2893,10 +2889,6 @@ 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 @@ -3781,10 +3773,6 @@ 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 @@ -3866,7 +3854,6 @@ void PDFDocument::setStateEnlarged(bool state)
{
actionEnlargeViewer->setVisible(!state);
actionShrinkViewer->setVisible(state);
setVisibleMenuEntriesEnlargeShrink(!state, state);
}

/*!
Expand Down Expand Up @@ -4890,14 +4877,4 @@ 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: 0 additions & 1 deletion src/pdfviewer/PDFDocument.h
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down
16 changes: 14 additions & 2 deletions src/texstudio.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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();
Expand Down Expand Up @@ -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;
}
Expand Down Expand Up @@ -7740,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 @@ -11380,6 +11382,7 @@ void Texstudio::enlargeEmbeddedPDFViewer()
enlargedViewer=true;
pdfConfig->followFromScroll=false;
viewer->setStateEnlarged(true);
setEnabledMenusEnlargeShrink(false, true);
#endif
}
/*!
Expand All @@ -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<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 f4e3bfe

Please sign in to comment.