Bug 389668 - Saving a pdf switches from thumbnail view in sidebar to contents view
Summary: Saving a pdf switches from thumbnail view in sidebar to contents view
Status: RESOLVED FIXED
Alias: None
Product: okular
Classification: Applications
Component: general (show other bugs)
Version: 1.3.1
Platform: Neon Linux
: NOR normal
Target Milestone: ---
Assignee: Okular developers
URL:
Keywords: junior-jobs
Depends on:
Blocks:
 
Reported: 2018-01-31 03:02 UTC by Michael D
Modified: 2018-08-13 11:20 UTC (History)
4 users (show)

See Also:
Latest Commit:
Version Fixed In:


Attachments
PDF that does not produce this bug (1.82 MB, application/pdf)
2018-02-12 04:06 UTC, Huon
Details

Note You need to log in before you can comment on or make changes to this bug.
Description Michael D 2018-01-31 03:02:40 UTC
If I save a pdf while the sidebar view is on Thumbnails, it switches the view to Contents. This is true if I've last clicked on the contents of the pdf, rather than a thumbnail.
Comment 1 Huon 2018-02-08 03:57:45 UTC
I can't replicate this using olular 17.12.1 from the Arch repos.
I made sure the document I tested with had a Contents, switch to Thumbnail, and saved using Save As... to a different location.
Comment 2 Michael D 2018-02-08 04:00:59 UTC
I'm using okular 1.3.1 and NOT using "save as" but just "save" after editing a file with annotations.
Comment 3 Huon 2018-02-08 04:05:58 UTC
@Michael D - 1.3.1? 3.2.0 was released in 2004.

I tested saving with "Save" after adding annotations, still couldn't reproduce.
Comment 4 Michael D 2018-02-08 04:19:50 UTC
On this bug, the drop down the version maxes out at 1.3.1, "okular --version" says 1.3.1, and even through the help gui it says 1.3.1, so...

Anyway, I can only reproduce it on certain files and not others. I would attach the file here but it's a pdf book and copyrighted, so I can't do that. It may not be helpful at all, but the metadata says that it was created by PScript5.dll version 5.2, the producer is Adobe Acrobat Distiller 6.0 (Windows), format PDF v. 1.5. I thought it might be the pdf reloading and showing bookmarks by default, but it seems not to be, because when I use the hyperref package with LaTeX with bookmarksopen=true, I can't reproduce the bug.
Comment 5 Huon 2018-02-08 04:31:42 UTC
Hmm, I'm new to the KDE (dev) world, not sure why the package version (and versions on github) are different to the version reported by okular itself and the bugtracker. I am also using 1.3.1 as reported by okular.

I guess someone needs to find a non-copyrighted PDF that causes the bug...
Comment 6 Huon 2018-02-08 04:37:36 UTC
Could you try to extract a page or two to a separate file? Like a blank page or a page without copyrighted material?
Comment 7 Michael D 2018-02-08 14:07:35 UTC
If I extract pages (e.g. using python-pyPdf) the properties of the original pdf won't (necessarily) be preserved in the resulting extraction, so I don't think it will be helpful. I'll try it out using a couple of methods and report back later.
Comment 8 Albert Astals Cid 2018-02-11 23:02:07 UTC
@Huon really you must be testing the wrong thing because any pdf file with Contents will switch to it if you're not there when saving.

You can use https://bugs.kde.org/attachment.cgi?id=27458 as an example. This should be relatively easy to fix.
Comment 9 Huon 2018-02-12 04:06:06 UTC
Created attachment 110552 [details]
PDF that does not produce this bug
Comment 10 Huon 2018-02-12 04:07:20 UTC
@Albert I can reproduce the bug in the PDF you linked, however the following PDF does not produce this bug: https://bugs.kde.org/attachment.cgi?id=110552
Comment 11 Albert Astals Cid 2018-08-13 09:14:29 UTC
Git commit 5e622484c874a81718faaac3d948d355d4e03164 by Albert Astals Cid, on behalf of Ahmad Osama.
Committed on 13/08/2018 at 09:13.
Pushed by aacid into branch 'Applications/18.08'.

Fix problem of saving pdf switches from thumbnail view in sidebar to contents view

Summary:
When save/save as functions are called they internally call the openFile() function, in the open file function the side bar item is set to Table of Contents (ToC) item

```
if ( m_document->metaData( QStringLiteral("OpenTOC") ).toBool() && m_sidebar->isItemEnabled( m_toc ) && !m_sidebar->isCollapsed() && m_sidebar->currentItem() != m_toc )
{
     m_sidebar->setCurrentItem( m_toc, Sidebar::DoNotUncollapseIfCollapsed );
}
```
so I just store the sidebar's item before saving and then set this item back if changed.

Reviewers: #okular

Subscribers: aacid, okular-devel

Tags: #okular

Differential Revision: https://phabricator.kde.org/D14740

M  +19   -0    autotests/parttest.cpp
M  +4    -0    part.cpp
M  +2    -1    ui/sidebar.h

https://commits.kde.org/okular/5e622484c874a81718faaac3d948d355d4e03164
Comment 12 Michael D 2018-08-13 11:20:58 UTC
Great, thanks for the fix Albert.