2021-05-24 07:25:56 +00:00
|
|
|
/*
|
|
|
|
SPDX-FileCopyrightText: 2005 Enrico Ros <eros.kde@email.it>
|
|
|
|
SPDX-FileCopyrightText: 2006 Albert Astals Cid <aacid@kde.org>
|
|
|
|
|
|
|
|
SPDX-License-Identifier: GPL-2.0-or-later
|
|
|
|
*/
|
2005-01-26 10:42:07 +00:00
|
|
|
|
2006-09-21 08:45:36 +00:00
|
|
|
#ifndef _OKULAR_MINIBAR_H_
|
|
|
|
#define _OKULAR_MINIBAR_H_
|
2005-01-26 10:42:07 +00:00
|
|
|
|
|
|
|
#include "core/observer.h"
|
2020-07-08 11:54:37 +00:00
|
|
|
#include <KLineEdit>
|
|
|
|
#include <QSet>
|
2006-10-15 21:10:52 +00:00
|
|
|
#include <qwidget.h>
|
2005-01-26 10:42:07 +00:00
|
|
|
|
2006-09-21 08:45:36 +00:00
|
|
|
namespace Okular
|
|
|
|
{
|
|
|
|
class Document;
|
|
|
|
}
|
|
|
|
|
2011-08-12 13:39:57 +00:00
|
|
|
class MiniBar;
|
2005-01-26 10:42:07 +00:00
|
|
|
class HoverButton;
|
2011-08-12 13:39:57 +00:00
|
|
|
class QIntValidator;
|
|
|
|
class QLabel;
|
2014-01-12 21:20:29 +00:00
|
|
|
class QToolBar;
|
2011-08-12 13:39:57 +00:00
|
|
|
|
|
|
|
// [private widget] lineEdit for entering/validating page numbers
|
|
|
|
class PagesEdit : public KLineEdit
|
|
|
|
{
|
2013-02-13 12:52:42 +00:00
|
|
|
Q_OBJECT
|
|
|
|
|
2011-08-12 13:39:57 +00:00
|
|
|
public:
|
2018-09-01 08:25:57 +00:00
|
|
|
explicit PagesEdit(MiniBar *parent);
|
2017-03-02 19:39:24 +00:00
|
|
|
void setText(const QString &) override;
|
2011-08-12 13:39:57 +00:00
|
|
|
|
|
|
|
protected:
|
2017-03-02 19:39:24 +00:00
|
|
|
void focusInEvent(QFocusEvent *e) override;
|
|
|
|
void focusOutEvent(QFocusEvent *e) override;
|
|
|
|
void mousePressEvent(QMouseEvent *e) override;
|
|
|
|
void wheelEvent(QWheelEvent *e) override;
|
2011-08-12 13:39:57 +00:00
|
|
|
|
2016-07-11 17:30:31 +00:00
|
|
|
private Q_SLOTS:
|
2013-02-13 12:52:42 +00:00
|
|
|
void updatePalette();
|
|
|
|
|
2011-08-12 13:39:57 +00:00
|
|
|
private:
|
|
|
|
MiniBar *m_miniBar;
|
|
|
|
bool m_eatClick;
|
|
|
|
};
|
|
|
|
|
|
|
|
class PageNumberEdit : public PagesEdit
|
|
|
|
{
|
2016-10-29 14:32:24 +00:00
|
|
|
Q_OBJECT
|
|
|
|
|
2011-08-12 13:39:57 +00:00
|
|
|
public:
|
2019-12-20 15:40:59 +00:00
|
|
|
explicit PageNumberEdit(MiniBar *miniBar);
|
2011-08-12 13:39:57 +00:00
|
|
|
void setPagesNumber(int pages);
|
|
|
|
|
|
|
|
private:
|
|
|
|
QIntValidator *m_validator;
|
|
|
|
};
|
|
|
|
|
|
|
|
class PageLabelEdit : public PagesEdit
|
|
|
|
{
|
|
|
|
Q_OBJECT
|
|
|
|
public:
|
2018-09-01 08:25:57 +00:00
|
|
|
explicit PageLabelEdit(MiniBar *parent);
|
2017-03-02 19:39:24 +00:00
|
|
|
void setText(const QString &newText) override;
|
2011-08-12 13:39:57 +00:00
|
|
|
void setPageLabels(const QVector<Okular::Page *> &pageVector);
|
|
|
|
|
2016-07-11 17:30:31 +00:00
|
|
|
Q_SIGNALS:
|
2011-08-12 13:39:57 +00:00
|
|
|
void pageNumberChosen(int page);
|
|
|
|
|
2016-07-11 17:30:31 +00:00
|
|
|
private Q_SLOTS:
|
2011-08-12 13:39:57 +00:00
|
|
|
void pageChosen();
|
|
|
|
|
|
|
|
private:
|
|
|
|
QString m_lastLabel;
|
|
|
|
QMap<QString, int> m_labelPageMap;
|
|
|
|
};
|
2005-01-26 10:42:07 +00:00
|
|
|
|
|
|
|
/**
|
2012-01-31 18:48:20 +00:00
|
|
|
* @short The object that observes the document and feeds the minibars
|
2005-01-26 10:42:07 +00:00
|
|
|
*/
|
2012-01-31 18:48:20 +00:00
|
|
|
class MiniBarLogic : public QObject, public Okular::DocumentObserver
|
2005-01-26 10:42:07 +00:00
|
|
|
{
|
2016-10-29 14:32:24 +00:00
|
|
|
Q_OBJECT
|
|
|
|
|
2005-01-26 10:42:07 +00:00
|
|
|
public:
|
2012-01-31 18:48:20 +00:00
|
|
|
MiniBarLogic(QObject *parent, Okular::Document *m_document);
|
2019-12-18 11:51:13 +00:00
|
|
|
~MiniBarLogic() override;
|
2020-07-10 22:15:05 +00:00
|
|
|
|
2012-01-31 18:48:20 +00:00
|
|
|
void addMiniBar(MiniBar *miniBar);
|
|
|
|
void removeMiniBar(MiniBar *miniBar);
|
2020-07-10 22:15:05 +00:00
|
|
|
|
2012-01-31 18:48:20 +00:00
|
|
|
Okular::Document *document() const;
|
|
|
|
int currentPage() const;
|
2020-07-10 22:15:05 +00:00
|
|
|
|
2005-01-26 10:42:07 +00:00
|
|
|
// [INHERITED] from DocumentObserver
|
2019-12-20 15:40:59 +00:00
|
|
|
void notifySetup(const QVector<Okular::Page *> &pageVector, int setupFlags) override;
|
2017-03-02 19:39:24 +00:00
|
|
|
void notifyCurrentPageChanged(int previous, int current) override;
|
2020-07-10 22:15:05 +00:00
|
|
|
|
2012-01-31 18:48:20 +00:00
|
|
|
private:
|
|
|
|
QSet<MiniBar *> m_miniBars;
|
|
|
|
Okular::Document *m_document;
|
|
|
|
};
|
|
|
|
|
|
|
|
/**
|
|
|
|
* @short A widget to display page number and change current page.
|
|
|
|
*/
|
|
|
|
class MiniBar : public QWidget
|
|
|
|
{
|
|
|
|
Q_OBJECT
|
|
|
|
friend class MiniBarLogic;
|
2020-07-10 22:15:05 +00:00
|
|
|
|
2012-01-31 18:48:20 +00:00
|
|
|
public:
|
|
|
|
MiniBar(QWidget *parent, MiniBarLogic *miniBarLogic);
|
2019-12-18 11:51:13 +00:00
|
|
|
~MiniBar() override;
|
2020-07-10 22:15:05 +00:00
|
|
|
|
2017-03-02 19:39:24 +00:00
|
|
|
void changeEvent(QEvent *event) override;
|
2020-07-10 22:15:05 +00:00
|
|
|
|
2016-07-11 17:30:31 +00:00
|
|
|
Q_SIGNALS:
|
2005-01-26 10:42:07 +00:00
|
|
|
void gotoPage();
|
|
|
|
void prevPage();
|
|
|
|
void nextPage();
|
2011-06-08 05:47:57 +00:00
|
|
|
void forwardKeyPressEvent(QKeyEvent *e);
|
2020-07-10 22:15:05 +00:00
|
|
|
|
2016-07-11 17:30:31 +00:00
|
|
|
public Q_SLOTS:
|
2020-02-20 14:48:08 +00:00
|
|
|
void slotChangePageFromReturn();
|
2011-08-12 13:39:57 +00:00
|
|
|
void slotChangePage(int page);
|
2005-01-26 10:42:07 +00:00
|
|
|
void slotEmitNextPage();
|
|
|
|
void slotEmitPrevPage();
|
2014-01-12 21:20:29 +00:00
|
|
|
void slotToolBarIconSizeChanged();
|
2020-07-10 22:15:05 +00:00
|
|
|
|
2005-01-26 10:42:07 +00:00
|
|
|
private:
|
2021-07-31 23:17:43 +00:00
|
|
|
void resizeForPage(int pages, const QString &pagesOrLabelString);
|
2017-03-02 19:39:24 +00:00
|
|
|
bool eventFilter(QObject *target, QEvent *event) override;
|
2020-07-10 22:15:05 +00:00
|
|
|
|
2012-01-31 18:48:20 +00:00
|
|
|
MiniBarLogic *m_miniBarLogic;
|
2011-08-12 13:39:57 +00:00
|
|
|
PageNumberEdit *m_pageNumberEdit;
|
|
|
|
PageLabelEdit *m_pageLabelEdit;
|
|
|
|
QLabel *m_pageNumberLabel;
|
2005-01-26 10:42:07 +00:00
|
|
|
HoverButton *m_prevButton;
|
|
|
|
HoverButton *m_pagesButton;
|
|
|
|
HoverButton *m_nextButton;
|
2021-08-15 05:53:44 +00:00
|
|
|
QToolBar *m_oldToolbarParent;
|
2005-01-26 10:42:07 +00:00
|
|
|
};
|
|
|
|
|
2006-10-15 15:59:22 +00:00
|
|
|
/**
|
|
|
|
* @short A small progress bar.
|
|
|
|
*/
|
|
|
|
class ProgressWidget : public QWidget, public Okular::DocumentObserver
|
|
|
|
{
|
|
|
|
Q_OBJECT
|
|
|
|
public:
|
|
|
|
ProgressWidget(QWidget *parent, Okular::Document *document);
|
2019-12-18 11:51:13 +00:00
|
|
|
~ProgressWidget() override;
|
2006-10-15 15:59:22 +00:00
|
|
|
|
|
|
|
// [INHERITED] from DocumentObserver
|
2017-03-02 19:39:24 +00:00
|
|
|
void notifyCurrentPageChanged(int previous, int current) override;
|
2006-10-15 15:59:22 +00:00
|
|
|
|
|
|
|
void slotGotoNormalizedPage(float index);
|
|
|
|
|
2016-07-11 17:30:31 +00:00
|
|
|
Q_SIGNALS:
|
2006-10-15 15:59:22 +00:00
|
|
|
void prevPage();
|
|
|
|
void nextPage();
|
|
|
|
|
|
|
|
protected:
|
|
|
|
void setProgress(float percentage);
|
|
|
|
|
2017-03-02 19:39:24 +00:00
|
|
|
void mouseMoveEvent(QMouseEvent *e) override;
|
|
|
|
void mousePressEvent(QMouseEvent *e) override;
|
|
|
|
void wheelEvent(QWheelEvent *e) override;
|
|
|
|
void paintEvent(QPaintEvent *e) override;
|
2006-10-15 15:59:22 +00:00
|
|
|
|
|
|
|
private:
|
|
|
|
Okular::Document *m_document;
|
|
|
|
float m_progressPercentage;
|
|
|
|
};
|
|
|
|
|
2005-01-26 10:42:07 +00:00
|
|
|
#endif
|