Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

make grid options and two others available to the embedded pdf-viewer #3942

Merged
merged 6 commits into from
Jan 13, 2025

Conversation

octaeder
Copy link
Contributor

@octaeder octaeder commented Jan 10, 2025

Happy new year!

This PR resolves #222 (enhancement request). The changes add a Grid menu to the context menu of both the windowed and the embedded pdf-viewer. The Grid menu offers known options from the main menu View of the windowed pdf-viewer. The menu then looks like this:

grafik

This may often allow working without the windowed pdf-viewer. For example, you could choose grid 2x1 and option Fit to Window. If you want to take a closer look at the pdf, you can expand the viewer to the left (and later on shrink it to the right) with the button Enlarge Viewer grafik to the right of the tool bar. On large screens it may suffice to enlarge the texstudio window.

gridAnimation

Grid4x1continuous

Following assertions hold:

  1. A new embedded viewer (or a windowed viewer getting embedded) always sets the options as shown in the image (including Fit to Width). These are the ones used before this PR (c.f. #3554#issuecomment-2001989472).
  2. Only the windowed viewer saves and restores previously set options.
  3. These options of embedded and windowed viewer do not interfere.

Previous PR is #3554.

Note: Changed PR description after discussion.

@sunderme
Copy link
Member

I have two points

  1. the button should be a symbol, not "grid". It works in English but less so in other languages.
  2. I am really not convinced that it should be placed prominently.
    How about adding it to context menu (next to show or in show) ?

@octaeder
Copy link
Contributor Author

octaeder commented Jan 10, 2025

context menu would be ok. So we would have a sequence of seperator, Grid, Show, right?

@sunderme
Copy link
Member

context menu would be ok. So we would have a sequence of seperator, Grid, Show, right?

correct

@octaeder
Copy link
Contributor Author

Grid to context menu only for embedded mode?

@octaeder
Copy link
Contributor Author

Grid to context menu only for embedded mode?

I would prefere always having Grid in both modes. On large monitors, this can reduce mouse pointer movements.

@octaeder
Copy link
Contributor Author

and for continuous I suggest the same. So you don't need to think about which action where to find in different modes.

@sunderme
Copy link
Member

I don't see a benefit of having non-continuous or single step in the embedded viewer. But if it must be, maybe part of the grid sub menu

----
Grid
  1x1
  ...
  nxm
  ----
  continuous
  etc.
Show
  ...

@octaeder
Copy link
Contributor Author

well that structure is already as you describe it. Non-continous allows faster and precise scrolling with the wheel. The question is should continous also be there in the windowed case. As said, I would prefere it.

@octaeder
Copy link
Contributor Author

so windowed and embedded viewer:

grafik

@sunderme
Copy link
Member

that is fine

@octaeder
Copy link
Contributor Author

and that's why I suggested to move continuous from View to View/Grid in last PR. Would you change your mind now?

@sunderme
Copy link
Member

and that's why I suggested to move continuous from View to View/Grid in last PR. Would you change your mind now?

The previous suggestion was about the pdf main menu , yet here we are talking about context menu , right ?
I still see no reason to change the pdf main menu.

@octaeder
Copy link
Contributor Author

I think nothing more to do from my side

Copy link
Member

@sunderme sunderme left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

There needs to be a cleaner concept about embedded/windowed handling of the grid setting.

And don't leave obsolete/dead code in pull-requests

@@ -2919,7 +2959,7 @@ PDFDocument::~PDFDocument()
/*!
* \brief setup ToolBar
*/
void PDFDocument::setupToolBar(){
Copy link
Member

@sunderme sunderme Jan 11, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

unused, please remove change (here it shows the original side of code)

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

removing argument embedded of method done

@@ -3072,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) {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

unused code, please remove

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

done

setupMenus(embedded);

setupToolBar();
setupToolBar(embedded);
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

see above

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

this is done

@@ -232,6 +232,14 @@ class PDFWidget : public QLabel
Q_INVOKABLE void zoom(qreal scale);

virtual void wheelEvent(QWheelEvent *event);
int getGridxEmbedded() {return gridxEmbedded;};
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

this concepts does not comply with the general idea of object oriented programming.
You should not have special functions to set normal parameters when the object is just in a different state (i.e. embedded)
This way the state needs to be tracked in the caller & the receiver and you can make mistake on both ends.

So the issue is that you want to overwrite the global config for the grid.
The simplest way, is to keep it as it is:

  • grid 1/1 does not overwrite global config
  • other grid settings set the global config and thus stay when you switch from embedded to windowed.
  • This seems like a useful behavior

Copy link
Contributor Author

@octaeder octaeder Jan 12, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The idea of setting grid to 1x1 without changes to the original config turns out to be problematic. When continuous mode is switched off, the grid size is restored from the config, resulting in unexpected grid changes for the user. This is independent of whether the imbedded and windowed viewer use the same or different configurations.
Both embedded and windowed viewer initialize the config to grid 1x1 when startet first time ever. Regarding your concerns about changes to the grid, I would say that this is not such a problem. An unexperienced user might do grid changes and others with the main menu in the windowed viewer. This would have no effect on the embedded viewer (assuming two configs). Only when he discovers the context menu can he make changes in this case. I think this is acceptable. Restoring the settings of the embedded viewer will certainly please many users.
This is now the current PR.

@@ -675,8 +682,10 @@ private slots:

QStatusBar *statusbar;
QToolBar *toolBar;
QToolBar *tbPdfView;
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

unused, please remove

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

indeed, and change to definition of setupToolBar must also be removed. This is done.


int gridx, gridy, pageOffset;
int gridxEmbedded, gridyEmbedded, pageOffsetEmbedded;
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I don't see the need for extra variables to keep a state (grid setting)

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is a missunderstanding. The Embedded ones are used similar to the ones from the config. Why this? Well, option continuous changes temporarily gridy (and similar single page step changes offset temporarily). So, turning of this option makes it necessary to retrieve the original values (I do so for gridx also, even so it is not needed). Until now this has been gridy=1. But now we need the user supplied value. This could be the config. Maybe I didn't get right, what you said here #3554 (comment). Anyway, I still think that the user may want to have two non-shared settings, because one preferes other settings in the smaler area of the embedded viewer. If a future decision is to save the embedded settings, too, then this could be done easier.

Comment on lines 1592 to 1601
if (pdfDoc) {
if (pdfDoc->menuGrid || pdfDoc->menuShow) {
menu.addSeparator();
if (pdfDoc->menuGrid) {
menu.addMenu(pdfDoc->menuGrid);
}
if (pdfDoc->menuShow) {
menu.addMenu(pdfDoc->menuShow);
}
}
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

overly complicated code
apart from the fact the the pointers are not zeroed in the first place, there is no case when only one of the two appears.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

simplified and assinged nullptr in headerfile

}
if (!setAsDefault)
globalConfig->pageOffset = pageOffset;
if (!setAsDefault) {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

the setAsDefault was the way of distinguishing embedded/windowed
Having now an additional "embedded" makes a mess of the concept.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

no. as explained above there are cases where pageOffset needs to be changed temporarily, i.e. without updating the profile. That's what setAsDefault is used.

@@ -2199,7 +2220,15 @@ int PDFWidget::pageStep()
*/
int PDFWidget::gridCols(bool fromConfig) const
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

like above
the concept from/to config and embedded/windowed needs to cleaned up

@octaeder octaeder marked this pull request as draft January 11, 2025 17:21
@octaeder octaeder force-pushed the #222-gridImbeddedPdf branch from e25f20e to 59a4ca1 Compare January 12, 2025 04:15
@octaeder octaeder force-pushed the #222-gridImbeddedPdf branch from 5ee7cba to b971f45 Compare January 12, 2025 14:01
@octaeder octaeder marked this pull request as ready for review January 12, 2025 18:18
@sunderme sunderme merged commit 2e43e5a into texstudio-org:master Jan 13, 2025
7 checks passed
@sunderme
Copy link
Member

Thanks

@octaeder octaeder deleted the #222-gridImbeddedPdf branch January 13, 2025 09:50
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Enhancement: Access to grid view, while viewer is embedded.
2 participants