okular/part/minibar.h

Ignoring revisions in .git-blame-ignore-revs. Click here to bypass and see the normal blame view.

181 lines
4 KiB
C
Raw Normal View History

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
*/
#ifndef _OKULAR_MINIBAR_H_
#define _OKULAR_MINIBAR_H_
#include "core/observer.h"
2020-07-08 11:54:37 +00:00
#include <KLineEdit>
#include <QSet>
#include <qwidget.h>
namespace Okular
{
class Document;
}
class MiniBar;
class HoverButton;
class QIntValidator;
class QLabel;
class QToolBar;
// [private widget] lineEdit for entering/validating page numbers
class PagesEdit : public KLineEdit
{
Q_OBJECT
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;
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;
private Q_SLOTS:
void updatePalette();
private:
MiniBar *m_miniBar;
bool m_eatClick;
};
class PageNumberEdit : public PagesEdit
{
2016-10-29 14:32:24 +00:00
Q_OBJECT
public:
explicit PageNumberEdit(MiniBar *miniBar);
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;
void setPageLabels(const QVector<Okular::Page *> &pageVector);
Q_SIGNALS:
void pageNumberChosen(int page);
private Q_SLOTS:
void pageChosen();
private:
QString m_lastLabel;
QMap<QString, int> m_labelPageMap;
};
/**
* @short The object that observes the document and feeds the minibars
*/
class MiniBarLogic : public QObject, public Okular::DocumentObserver
{
2016-10-29 14:32:24 +00:00
Q_OBJECT
public:
MiniBarLogic(QObject *parent, Okular::Document *m_document);
~MiniBarLogic() override;
void addMiniBar(MiniBar *miniBar);
void removeMiniBar(MiniBar *miniBar);
Okular::Document *document() const;
int currentPage() const;
// [INHERITED] from DocumentObserver
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;
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;
public:
MiniBar(QWidget *parent, MiniBarLogic *miniBarLogic);
~MiniBar() override;
2017-03-02 19:39:24 +00:00
void changeEvent(QEvent *event) override;
Q_SIGNALS:
void gotoPage();
void prevPage();
void nextPage();
void forwardKeyPressEvent(QKeyEvent *e);
public Q_SLOTS:
2020-02-20 14:48:08 +00:00
void slotChangePageFromReturn();
void slotChangePage(int page);
void slotEmitNextPage();
void slotEmitPrevPage();
void slotToolBarIconSizeChanged();
private:
void resizeForPage(int pages, const QString &pagesOrLabelString);
2017-03-02 19:39:24 +00:00
bool eventFilter(QObject *target, QEvent *event) override;
MiniBarLogic *m_miniBarLogic;
PageNumberEdit *m_pageNumberEdit;
PageLabelEdit *m_pageLabelEdit;
QLabel *m_pageNumberLabel;
HoverButton *m_prevButton;
HoverButton *m_pagesButton;
HoverButton *m_nextButton;
2021-08-15 05:53:44 +00:00
QToolBar *m_oldToolbarParent;
};
/**
* @short A small progress bar.
*/
class ProgressWidget : public QWidget, public Okular::DocumentObserver
{
Q_OBJECT
public:
ProgressWidget(QWidget *parent, Okular::Document *document);
~ProgressWidget() override;
// [INHERITED] from DocumentObserver
2017-03-02 19:39:24 +00:00
void notifyCurrentPageChanged(int previous, int current) override;
void slotGotoNormalizedPage(float index);
Q_SIGNALS:
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;
private:
Okular::Document *m_document;
float m_progressPercentage;
};
#endif