okular/part/bookmarklist.h
snooxx 💤 9432565ede Fix broken page MiniBar
The `MiniBar` normally used to display page numbers and to provide
navigation buttons regressed since 01557c16c4 to only show an empty
non-functional button called "Page Number", along with multiple
warnings:
`QObject::connect(MiniBar, QAction): invalid nullptr parameter`

This is caused by moving `setupViewerActions()` to a place where
`m_miniBar` is not initialized yet, even though it has a runtime
`connect`-dependency on it.

By moving `setupViewerActions()` back, the `MiniBar` starts working
again. Now the `m_addBookmark` action, which is created in that
function, is not available anymore to be passed to the constructor of
`BookmarkList`. To avoid moving the setup of the latter away from the
rest of the sidebar code, only assigning the action to the bookmark
button contained in the `BookmarkList` is deferred to
`setupViewerActions()`.

As requested, any accidental future `nullptr`-access will be handled by
crashing, even in Release builds, by omitting any checks.

BUG: 450347

Test Plan:

Page numbers show up again in toolbar, no more `connect` warnings.
2022-02-22 23:16:34 +00:00

66 lines
1.6 KiB
C++

/*
SPDX-FileCopyrightText: 2006 Pino Toscano <pino@kde.org>
SPDX-License-Identifier: GPL-2.0-or-later
*/
#ifndef BOOKMARKLIST_H
#define BOOKMARKLIST_H
#include <qwidget.h>
#include "core/observer.h"
class QAction;
class QCheckBox;
class QToolButton;
class QTreeWidget;
class QTreeWidgetItem;
class KTreeWidgetSearchLine;
class QUrl;
class BookmarkItem;
class FileItem;
namespace Okular
{
class Document;
}
class BookmarkList : public QWidget, public Okular::DocumentObserver
{
Q_OBJECT
public:
explicit BookmarkList(Okular::Document *document, QWidget *parent = nullptr);
~BookmarkList() override;
// inherited from DocumentObserver
void notifySetup(const QVector<Okular::Page *> &pages, int setupFlags) override;
void setAddBookmarkAction(QAction *addBookmarkAction);
private Q_SLOTS:
void slotShowAllBookmarks(bool);
void slotExecuted(QTreeWidgetItem *item);
void slotChanged(QTreeWidgetItem *item);
void slotContextMenu(const QPoint p);
void slotBookmarksChanged(const QUrl &url);
private:
void rebuildTree(bool showAll);
void goTo(BookmarkItem *item);
void selectiveUrlUpdate(const QUrl &url, QTreeWidgetItem *&item);
QTreeWidgetItem *itemForUrl(const QUrl &url) const;
void contextMenuForBookmarkItem(const QPoint p, BookmarkItem *bmItem);
void contextMenuForFileItem(const QPoint p, FileItem *fItem);
Okular::Document *m_document;
QTreeWidget *m_tree;
KTreeWidgetSearchLine *m_searchLine;
QCheckBox *m_showForAllDocumentsCheckbox;
QTreeWidgetItem *m_currentDocumentItem;
QToolButton *m_showAllToolButton;
};
#endif