viewmainpage.h 3.42 KB
Newer Older
1 2
/*
Gwenview: an image viewer
Aurélien Gâteau's avatar
Aurélien Gâteau committed
3
Copyright 2007 Aurélien Gâteau <agateau@kde.org>
4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19

This program is free software; you can redistribute it and/or
modify it under the terms of the GNU General Public License
as published by the Free Software Foundation; either version 2
of the License, or (at your option) any later version.

This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
GNU General Public License for more details.

You should have received a copy of the GNU General Public License
along with this program; if not, write to the Free Software
Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301, USA.

*/
20 21
#ifndef VIEWMAINPAGE_H
#define VIEWMAINPAGE_H
22

23 24 25
// Local
#include <lib/document/document.h>

26
// KDE
David Edmundson's avatar
David Edmundson committed
27
#include <QUrl>
28 29

// Qt
30
#include <QToolButton>
31 32
#include <QWidget>

33
class QGraphicsWidget;
34

35
class KActionCollection;
36

37 38
namespace Gwenview
{
39

40
class AbstractRasterImageViewTool;
41
class DocumentView;
Aurélien Gâteau's avatar
Aurélien Gâteau committed
42
class GvCore;
43
class RasterImageView;
44
class SlideShow;
Aurélien Gâteau's avatar
Aurélien Gâteau committed
45
class ThumbnailBarView;
46

47
struct ViewMainPagePrivate;
48

49
/**
50
 * Holds the active document view and associated widgetry.
51
 */
52
class ViewMainPage : public QWidget
53 54
{
    Q_OBJECT
55
public:
56
    static const int MaxViewCount;
57

Aurélien Gâteau's avatar
Aurélien Gâteau committed
58
    ViewMainPage(QWidget* parent, SlideShow*, KActionCollection*, GvCore*);
59
    ~ViewMainPage() override;
60

61
    ThumbnailBarView* thumbnailBar() const;
Aurélien Gâteau's avatar
Aurélien Gâteau committed
62

63
    void loadConfig();
64

65
    void saveConfig();
66

67 68 69 70
    /**
     * Reset the view
     */
    void reset();
71

72
    void setFullScreenMode(bool fullScreen);
73

74
    int statusBarHeight() const;
75

76 77
    QSize sizeHint() const override;
    QSize minimumSizeHint() const override;
78

79 80 81
    /**
     * Returns the url of the current document, or an invalid url if unknown
     */
David Edmundson's avatar
David Edmundson committed
82
    QUrl url() const;
83

David Edmundson's avatar
David Edmundson committed
84
    void openUrl(const QUrl &url);
85

86 87 88
    /**
     * Opens up to MaxViewCount urls, and set currentUrl as the current one
     */
David Edmundson's avatar
David Edmundson committed
89
    void openUrls(const QList<QUrl>& urls, const QUrl &currentUrl);
90

91
    void reload();
Aurélien Gâteau's avatar
Aurélien Gâteau committed
92

93
    Document::Ptr currentDocument() const;
94

95
    bool isEmpty() const;
96

97 98 99 100
    /**
     * Returns the image view, if the current adapter has one.
     */
    RasterImageView* imageView() const;
101

102 103 104 105
    /**
     * Returns the document view
     */
    DocumentView* documentView() const;
106

107

108
    QToolButton* toggleSideBarButton() const;
109

110
    void showMessageWidget(QGraphicsWidget*, Qt::Alignment align = Qt::AlignHCenter | Qt::AlignTop);
111

112 113
Q_SIGNALS:

114 115 116 117
    /**
     * Emitted when the part has finished loading
     */
    void completed();
118

119
    void previousImageRequested();
120

121
    void nextImageRequested();
122

123 124 125 126
    void openUrlRequested(const QUrl&);

    void openDirUrlRequested(const QUrl&);

127
    void toggleFullScreenRequested();
128

129 130
    void goToBrowseModeRequested();

131
    void captionUpdateRequested(const QString&);
132

Valerio Pilo's avatar
Valerio Pilo committed
133 134 135
public Q_SLOTS:
    void setStatusBarVisible(bool);

136
private Q_SLOTS:
137
    void setThumbnailBarVisibility(bool visible);
138

139
    void showContextMenu();
Aurélien Gâteau's avatar
Aurélien Gâteau committed
140

141
    void slotViewFocused(DocumentView*);
142

143 144
    void slotEnterPressed();

145 146
    void trashView(DocumentView*);
    void deselectView(DocumentView*);
147

148 149
    void slotDirModelItemsAddedOrRemoved();

150
protected:
151
    bool eventFilter(QObject* watched, QEvent* event) override;
152

153
private:
154 155
    friend struct ViewMainPagePrivate;
    ViewMainPagePrivate* const d;
156 157

    void updateFocus(const AbstractRasterImageViewTool* tool);
158 159 160 161
};

} // namespace

162
#endif /* VIEWMAINPAGE_H */