Bug 326844 - Feature request: Include option to resize window to fit page
Summary: Feature request: Include option to resize window to fit page
Status: RESOLVED FIXED
Alias: None
Product: okular
Classification: Applications
Component: general (show other bugs)
Version: 0.17.2
Platform: unspecified Linux
: NOR wishlist
Target Milestone: ---
Assignee: Okular developers
URL:
Keywords: junior-jobs
: 212188 (view as bug list)
Depends on:
Blocks:
 
Reported: 2013-10-29 18:10 UTC by ssameer+bugs
Modified: 2019-04-23 18:18 UTC (History)
5 users (show)

See Also:
Latest Commit:
Version Fixed In: KDE Applications 15.08


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description ssameer+bugs 2013-10-29 18:10:11 UTC
I would like an option in the View menu that resizes the window to fit the current page. This would be useful in non-continuous mode (one page at a time) when viewing presentations and comic books. Some other pdf and image viewers have this option:
mupdf: press w to shrinkwrap window to fit the page.
showimage: press F to fit to page.
Zoom in "fit window to page" mode causes the whole window to magnify or shrink accordingly.

Reproducible: Always
Comment 1 Elodimuor 2013-11-20 00:50:21 UTC
Hi i'm new to contributing to KDE, I'd like to work on implementing this feature, can I please get some help with getting started?


(In reply to comment #0)
> I would like an option in the View menu that resizes the window to fit the
> current page. This would be useful in non-continuous mode (one page at a
> time) when viewing presentations and comic books. Some other pdf and image
> viewers have this option:
> mupdf: press w to shrinkwrap window to fit the page.
> showimage: press F to fit to page.
> Zoom in "fit window to page" mode causes the whole window to magnify or
> shrink accordingly.
> 
> Reproducible: Always
Comment 2 Albert Astals Cid 2013-11-20 17:52:16 UTC
You can get some help. Which question do you have?
Comment 3 Amol 2013-11-22 20:41:43 UTC
Hi, I am also new to contributing to open source softwares. 
Can someone please help me out in how to proceed with solving this bug.
Comment 4 Albert Astals Cid 2013-11-24 17:29:54 UTC
You can get some help. Which question do you have?
Comment 5 Saheb Preet Singh 2014-01-01 11:33:54 UTC
hi,
i am also new to kde. Can any body help me in solving this bug??

i need to know which files or classes are related to adjusting the size of the main window or more precisely how to resize the window?

since the code also contains qml and i am new to it so i am not getting the main class which controls the view of the application
Comment 6 Albert Astals Cid 2014-01-01 20:48:20 UTC
(In reply to comment #5)
> i need to know which files or classes are related to adjusting the size of
> the main window or more precisely how to resize the window?
Have you done any research?
Comment 7 Saheb Preet Singh 2014-01-03 08:31:18 UTC
(In reply to comment #6)
> (In reply to comment #5)
> > i need to know which files or classes are related to adjusting the size of
> > the main window or more precisely how to resize the window?
> Have you done any research?

Yes, as per my research shell is the main element that appears is shell which in turn loads okular part plugin to draw various other things like some menu

is this research correct???

if it is correct then the main thing to be done in this bug is to insert an option in the view menu bar for resizing the window to the size of the page and to resize the window which can be done by resizing shell as it inherits KParts :: MainWindow as per the size of the page. The first part can be done in PageView::setupViewerActions method by making corresponding signal and slot in the PageView class. For the second part the slot which will catch the above signal have to resize the window. Now the question is where the slot will implement the resizing functionality??? (as the resize to page fit and page width functionality is implemented after a series of function calls)

Please guide me if i am wrong somewhere
Comment 8 Albert Astals Cid 2014-01-04 18:22:26 UTC
looking good.

i'd make the part emit a signal that the shell catches and then resizes the window,
Comment 9 Saheb Preet Singh 2014-01-15 10:16:16 UTC
hi,

 I am able to resize the window now. I did some further work and stuck in a problem.

First of all i created a new action in part.cpp and part.rc for fit window option in view menu and connected it to a slot in the same file. From this slot a signal is emitted which is declared in part.h and catched in shell.cpp. The signal contain the size of the page using m_document. now i used this-> resize function to resize the window and the window is resized.

Now there are two problems:-
1. Is the feature required in the maximized mode as it is not possible to resize window in maximized mode.

2. The window is not resizing exactly to the page the problem occurs because the size i provided is of the page and the window also contains thumbnails, menubars etc. Now how to resize the page area so that window is resized to the page???
Comment 10 Albert Astals Cid 2014-01-15 18:51:22 UTC
The shell knows the current size of the part and also knows the total size of the window, so knowing the size the part wants to have should be able to determine what's the delta that has to add to account for menubar, etc, no?
Comment 11 Saheb Preet Singh 2014-01-17 12:41:39 UTC
(In reply to comment #10)
> The shell knows the current size of the part and also knows the total size
> of the window, so knowing the size the part wants to have should be able to
> determine what's the delta that has to add to account for menubar, etc, no?

Yes, shell knows the current size of the part, but i think part also includes the width of the thumbnails, table of content etc. I used the viewport size of the pageview instead in part.cpp and it is working fine now window is resizing as desired. But now another problem, the page size i am using is retrieved from allpagesize() in document class, which returns the size of the pages when they are at 100% zoom level.
Now, when the page is not zoomed to 100%, how should i adjust size ??
Is there any way of knowing the current zoom level??? (As per my research the current zoom level is stored in pageviewprivate class, which is private to pageview class).
Comment 12 Albert Astals Cid 2015-01-25 15:12:35 UTC
*** Bug 212188 has been marked as a duplicate of this bug. ***
Comment 13 Albert Astals Cid 2015-03-16 23:21:07 UTC
Git commit 1eafe4feb151c713e8f7747164348c25886480bf by Albert Astals Cid, on behalf of Saheb Preet Singh.
Committed on 16/03/2015 at 23:20.
Pushed by aacid into branch 'master'.

New shortcut to resize window to fit page

FIXED-IN: KDE Applications 15.08
REVIEW: 115283

M  +10   -0    doc/index.docbook
M  +6    -0    part.cpp
M  +3    -0    part.h
M  +11   -0    shell/shell.cpp
M  +5    -0    shell/shell.h
M  +41   -2    ui/pageview.cpp
M  +2    -0    ui/pageview.h
M  +9    -0    ui/sidebar.cpp
M  +2    -0    ui/sidebar.h

http://commits.kde.org/okular/1eafe4feb151c713e8f7747164348c25886480bf
Comment 14 Tristan Miller 2019-04-23 07:06:03 UTC
This feature is not working for me as expected:

1) The shortcut key combination works, but only when Okular is not in continuous mode.  Is this by design?  (I suppose it might be difficult to accommodate documents that have pages of different sizes.)

2) The command is not so easily discoverable.  You can set a shortcut for it, but as far as I can tell it does not appear in any pull-down menu.  Please add the command to the View menu.
Comment 15 Albert Astals Cid 2019-04-23 18:18:39 UTC
1) Yes it is by design

2) That is also by design, this is a feature almost noone really needs, so the ones that need it can add a shortcut, but adding it to the menu just pollutes the menu for no reason.