Skip to content

Commit

Permalink
add Grid menu to context menu, no toolbar button
Browse files Browse the repository at this point in the history
  • Loading branch information
octaeder committed Jan 10, 2025
1 parent 7f83e03 commit 043ec94
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 16 deletions.
28 changes: 13 additions & 15 deletions src/pdfviewer/PDFDocument.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1589,9 +1589,16 @@ void PDFWidget::contextMenuEvent(QContextMenuEvent *event)
usingTool = kNone;
}

if (pdfDoc && pdfDoc->menuShow) {
menu.addSeparator();
menu.addMenu(pdfDoc->menuShow);
if (pdfDoc) {
if (pdfDoc->menuGrid || pdfDoc->menuShow) {
menu.addSeparator();
if (pdfDoc->menuGrid) {
menu.addMenu(pdfDoc->menuGrid);
}
if (pdfDoc->menuShow) {
menu.addMenu(pdfDoc->menuShow);
}
}
}

QAction *action = menu.exec(event->globalPos());
Expand Down Expand Up @@ -2982,17 +2989,6 @@ void PDFDocument::setupToolBar(bool embedded){
toolBar->addAction(actionFit_to_Text_Width);
toolBar->addAction(actionFit_to_Window);
toolBar->addSeparator();
if (embedded) {
QToolButton *tbPdfView = new QToolButton(toolBar);
actionContinuous->setCheckable(true);
actionContinuous->setChecked(true);
menuGrid->addAction(actionContinuous);
tbPdfView->setMenu(menuGrid);
tbPdfView->setPopupMode(QToolButton::MenuButtonPopup);
tbPdfView->setText(tr("Grid"));
toolBar->addWidget(tbPdfView);
toolBar->addSeparator();
}
toolBar->addAction(actionAutoHideToolbars);
toolBar->addAction(actionEnlargeViewer);
toolBar->addAction(actionShrinkViewer);
Expand Down Expand Up @@ -3116,6 +3112,9 @@ void PDFDocument::setupMenus(bool embedded)
actionGroupGrid->addAction(actionCustom);
menuGrid->addSeparator();
actionSinglePageStep=configManager->newManagedAction(menuroot,menuGrid, "singlePageStep", tr("Single Page Step"), pdfWidget, SLOT(setSinglePageStep(bool)), QList<QKeySequence>());
// if (embedded) {
menuGrid->addAction(actionContinuous);
// }
menuWindow->addAction(menuShow->menuAction());
#if (QT_VERSION > 0x050a00) && (defined(Q_OS_MAC))
actionCloseElement=configManager->newManagedAction(menuroot,menuWindow, "closeElement", tr("&Close something"), this, SLOT(closeElement()), QList<QKeySequence>()); // osx work around
Expand Down Expand Up @@ -3188,7 +3187,6 @@ void PDFDocument::init(bool embedded)
pdfWidget = new PDFWidget(embedded); // needs to be initialized before setup menu
pdfWidget->setPDFDocument(this);

//if (!embedded)
setupMenus(embedded);

setupToolBar(embedded);
Expand Down
2 changes: 1 addition & 1 deletion src/pdfviewer/PDFDocument.h
Original file line number Diff line number Diff line change
Expand Up @@ -598,7 +598,6 @@ private slots:
QMenu *menuFile;
QMenu *menuEdit;
QMenu *menuView;
QMenu *menuGrid;
QMenu *menuWindow;
QList<QMenu *>menus;

Expand Down Expand Up @@ -686,6 +685,7 @@ private slots:
QToolBar *tbPdfView;
QTimer *toolBarTimer;
public:
QMenu *menuGrid;
QMenu *menuShow;
private:
QMenu *menuEdit_2;
Expand Down

0 comments on commit 043ec94

Please sign in to comment.