2021-05-24 07:25:56 +00:00
|
|
|
/*
|
|
|
|
SPDX-FileCopyrightText: 2004 Albert Astals Cid <aacid@kde.org>
|
|
|
|
|
|
|
|
SPDX-License-Identifier: GPL-2.0-or-later
|
|
|
|
*/
|
2004-04-15 18:36:43 +00:00
|
|
|
|
2006-09-21 08:45:36 +00:00
|
|
|
#ifndef _OKULAR_THUMBNAILLIST_H_
|
|
|
|
#define _OKULAR_THUMBNAILLIST_H_
|
2004-04-15 18:36:43 +00:00
|
|
|
|
2016-07-21 19:53:54 +00:00
|
|
|
#include <QScrollArea>
|
|
|
|
#include <QToolBar>
|
2006-03-24 19:35:20 +00:00
|
|
|
|
2005-01-02 14:55:14 +00:00
|
|
|
#include "core/observer.h"
|
2016-07-21 19:53:54 +00:00
|
|
|
|
2008-01-24 11:37:00 +00:00
|
|
|
class ThumbnailListPrivate;
|
2004-09-04 22:28:14 +00:00
|
|
|
|
2006-09-21 08:45:36 +00:00
|
|
|
namespace Okular
|
|
|
|
{
|
|
|
|
class Document;
|
|
|
|
}
|
|
|
|
|
2004-09-23 17:16:04 +00:00
|
|
|
/**
|
2008-12-01 03:52:13 +00:00
|
|
|
* @short A scrollview that displays page pixmap previews (aka thumbnails).
|
2004-09-23 17:16:04 +00:00
|
|
|
*
|
|
|
|
* ...
|
|
|
|
*/
|
2006-09-21 08:45:36 +00:00
|
|
|
class ThumbnailList : public QScrollArea, public Okular::DocumentObserver
|
2004-04-15 18:36:43 +00:00
|
|
|
{
|
2004-09-07 21:29:44 +00:00
|
|
|
Q_OBJECT
|
2006-07-15 10:23:43 +00:00
|
|
|
public:
|
2006-09-21 08:45:36 +00:00
|
|
|
ThumbnailList(QWidget *parent, Okular::Document *document);
|
2019-12-18 11:51:13 +00:00
|
|
|
~ThumbnailList() override;
|
2020-07-10 22:15:05 +00:00
|
|
|
|
2004-12-22 18:21:36 +00:00
|
|
|
// inherited: create thumbnails ( inherited as a DocumentObserver )
|
2017-03-02 19:39:24 +00:00
|
|
|
void notifySetup(const QVector<Okular::Page *> &pages, int setupFlags) override;
|
2004-12-22 18:21:36 +00:00
|
|
|
// inherited: hilihght current thumbnail ( inherited as DocumentObserver )
|
2017-03-02 19:39:24 +00:00
|
|
|
void notifyCurrentPageChanged(int previous, int current) override;
|
2004-12-22 18:21:36 +00:00
|
|
|
// inherited: redraw thumbnail ( inherited as DocumentObserver )
|
2017-03-02 19:39:24 +00:00
|
|
|
void notifyPageChanged(int pageNumber, int changedFlags) override;
|
2018-11-14 19:12:15 +00:00
|
|
|
// inherited: request all visible pixmap (due to a global change or so..)
|
2017-03-02 19:39:24 +00:00
|
|
|
void notifyContentsCleared(int changedFlags) override;
|
2006-06-23 21:11:52 +00:00
|
|
|
// inherited: the visible areas of the page have changed
|
2017-03-02 19:39:24 +00:00
|
|
|
void notifyVisibleRectsChanged() override;
|
2005-01-09 23:37:07 +00:00
|
|
|
// inherited: tell if pixmap is hidden and can be unloaded
|
2017-03-02 19:39:24 +00:00
|
|
|
bool canUnloadPixmap(int pageNumber) const override;
|
2020-07-10 22:15:05 +00:00
|
|
|
|
2004-11-07 11:20:27 +00:00
|
|
|
// redraw visible widgets (useful for refreshing contents...)
|
|
|
|
void updateWidgets();
|
2020-07-10 22:15:05 +00:00
|
|
|
|
2022-02-18 12:12:41 +00:00
|
|
|
// show current page in Thumbnails view
|
|
|
|
void syncThumbnail();
|
|
|
|
|
2016-07-11 17:30:31 +00:00
|
|
|
public Q_SLOTS:
|
2005-01-03 15:51:05 +00:00
|
|
|
// these are connected to ThumbnailController buttons
|
|
|
|
void slotFilterBookmarks(bool filterOn);
|
2020-07-10 22:15:05 +00:00
|
|
|
|
2006-07-15 10:23:43 +00:00
|
|
|
protected:
|
|
|
|
// scroll up/down the view
|
2019-12-20 15:40:59 +00:00
|
|
|
void keyPressEvent(QKeyEvent *keyEvent) override;
|
2020-07-10 22:15:05 +00:00
|
|
|
|
2006-07-15 10:23:43 +00:00
|
|
|
// catch the viewport event and filter them if necessary
|
2017-03-02 19:39:24 +00:00
|
|
|
bool viewportEvent(QEvent *) override;
|
2020-07-10 22:15:05 +00:00
|
|
|
|
2016-07-11 17:30:31 +00:00
|
|
|
Q_SIGNALS:
|
2020-02-20 17:45:46 +00:00
|
|
|
void rightClick(const Okular::Page *, const QPoint);
|
2020-07-10 22:15:05 +00:00
|
|
|
|
2006-07-15 10:23:43 +00:00
|
|
|
private:
|
2008-01-24 11:37:00 +00:00
|
|
|
friend class ThumbnailListPrivate;
|
|
|
|
ThumbnailListPrivate *d;
|
2004-04-15 18:36:43 +00:00
|
|
|
};
|
|
|
|
|
2004-09-23 17:16:04 +00:00
|
|
|
/**
|
2004-09-27 21:36:25 +00:00
|
|
|
* @short A vertical boxed container with zero size hint (for insertion on left toolbox)
|
2004-09-23 17:16:04 +00:00
|
|
|
*/
|
2015-03-17 22:15:20 +00:00
|
|
|
class ThumbnailsBox : public QWidget
|
2004-09-23 17:16:04 +00:00
|
|
|
{
|
2016-10-29 14:32:24 +00:00
|
|
|
Q_OBJECT
|
|
|
|
|
2006-07-15 10:23:43 +00:00
|
|
|
public:
|
Improve the sidebar's navigation and UX
Okular's sidebar vertical view chooser toolbar suffers from a few issues:
* It's a nonstandard UI not used for category choosers in other pieces of KDE software,
and not used in other FOSS document readers
* What is shown and what is hidden is simultaneously too configurable while still not
offering the desirable UI common to other programs (i.e. no visible category chooser,
but a sidebar capable of displaying thumbnails, table of contents, search results, etc.)
* With labels on it takes up quite a bit of horizontal space, while with labels off, the
categories are less than clear
* UX is kind of clunky with nonstandard behaviors (e.g. clicking on the current category
to hide that category's view while keeping the view chooser visible, showing mostly
disabled items)
* It's made with custom painting code, which reduces maintainability and introduces bugs
(e.g. https://bugs.kde.org/show_bug.cgi?id=408190)
This patch removes the vertical category chooser entirely and replaces it with a tabbed
view on the top of the sidebar itself. The tabs are icons-only and have large icons. A
button is added on the left side of the default toolbar to quickly hide or show the
sidebar. In order to make room for the new button, the Previous and Next buttons on the
toolbar are removed, as previous/next buttons are already present on the Page Bar on the
bottom of the window so there's no need to duplicate this functionality. This improves
the UX, fixes a variety of bugs, and deletes a lot of custom code of dubious long-term
maintainability.
![vokoscreenNG-2020-04-16_13-29-24](https://invent.kde.org/graphics/okular/uploads/a1f96a315b69282df51de9993b1befaf/vokoscreenNG-2020-04-16_13-29-24.webm)
BUG: 213508
BUG: 334441
BUG: 344599
BUG: 408190
CCBUG: 335189
FIXED-IN: 1.11.0
CHANGELOG: The sidebar can now be easily shown or hidden with a toolbar button, and the category chooser no longer takes up so much space
2020-05-27 13:37:42 +00:00
|
|
|
explicit ThumbnailsBox(QWidget *parent);
|
|
|
|
QSize sizeHint() const override;
|
2004-09-23 17:16:04 +00:00
|
|
|
};
|
|
|
|
|
2005-01-03 15:51:05 +00:00
|
|
|
/**
|
2008-12-01 03:52:13 +00:00
|
|
|
* @short A toolbar that sets ThumbnailList properties when clicking on items
|
2005-01-03 15:51:05 +00:00
|
|
|
*
|
2008-12-01 03:52:13 +00:00
|
|
|
* This class is the small toolbar that resides in the bottom of the
|
2005-01-03 15:51:05 +00:00
|
|
|
* ThumbnailsBox container (below ThumbnailList and the SearchLine) and
|
|
|
|
* emits signals whenever a button is pressed. A click action results
|
|
|
|
* in invoking some method (or slot) in ThumbnailList.
|
|
|
|
*/
|
2006-04-01 00:01:07 +00:00
|
|
|
class ThumbnailController : public QToolBar
|
2005-01-03 15:51:05 +00:00
|
|
|
{
|
2016-10-29 14:32:24 +00:00
|
|
|
Q_OBJECT
|
|
|
|
|
2005-01-03 15:51:05 +00:00
|
|
|
public:
|
|
|
|
ThumbnailController(QWidget *parent, ThumbnailList *thumbnailList);
|
|
|
|
};
|
|
|
|
|
2004-04-15 18:36:43 +00:00
|
|
|
#endif
|