File indexing completed on 2024-05-05 04:19:20

0001 /*
0002 Gwenview: an image viewer
0003 Copyright 2007 Aurélien Gâteau <agateau@kde.org>
0004 
0005 This program is free software; you can redistribute it and/or
0006 modify it under the terms of the GNU General Public License
0007 as published by the Free Software Foundation; either version 2
0008 of the License, or (at your option) any later version.
0009 
0010 This program is distributed in the hope that it will be useful,
0011 but WITHOUT ANY WARRANTY; without even the implied warranty of
0012 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
0013 GNU General Public License for more details.
0014 
0015 You should have received a copy of the GNU General Public License
0016 along with this program; if not, write to the Free Software
0017 Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301, USA.
0018 
0019 */
0020 #ifndef VIEWMAINPAGE_H
0021 #define VIEWMAINPAGE_H
0022 
0023 // Local
0024 #include <lib/document/document.h>
0025 
0026 // KF
0027 
0028 // Qt
0029 #include <QToolButton>
0030 #include <QUrl>
0031 #include <QWidget>
0032 
0033 class QGraphicsWidget;
0034 
0035 class KActionCollection;
0036 
0037 namespace Gwenview
0038 {
0039 class AbstractRasterImageViewTool;
0040 class DocumentView;
0041 class GvCore;
0042 class RasterImageView;
0043 class SlideShow;
0044 class ThumbnailBarView;
0045 
0046 struct ViewMainPagePrivate;
0047 
0048 /**
0049  * Holds the active document view and associated widgetry.
0050  */
0051 class ViewMainPage : public QWidget
0052 {
0053     Q_OBJECT
0054 public:
0055     static const int MaxViewCount;
0056 
0057     ViewMainPage(QWidget *parent, SlideShow *, KActionCollection *, GvCore *);
0058     ~ViewMainPage() override;
0059 
0060     ThumbnailBarView *thumbnailBar() const;
0061 
0062     void loadConfig();
0063 
0064     void saveConfig();
0065 
0066     /**
0067      * Reset the view
0068      */
0069     void reset();
0070 
0071     void setFullScreenMode(bool fullScreen);
0072 
0073     void setSpotlightMode(bool spotlight);
0074 
0075     int statusBarHeight() const;
0076 
0077     QSize sizeHint() const override;
0078     QSize minimumSizeHint() const override;
0079 
0080     /**
0081      * Returns the url of the current document, or an invalid url if unknown
0082      */
0083     QUrl url() const;
0084 
0085     void openUrl(const QUrl &url);
0086 
0087     /**
0088      * Opens up to MaxViewCount urls, and set currentUrl as the current one
0089      */
0090     void openUrls(const QList<QUrl> &urls, const QUrl &currentUrl);
0091 
0092     void reload();
0093 
0094     Document::Ptr currentDocument() const;
0095 
0096     bool isEmpty() const;
0097 
0098     /**
0099      * Returns the image view, if the current adapter has one.
0100      */
0101     RasterImageView *imageView() const;
0102 
0103     /**
0104      * Returns the document view
0105      */
0106     DocumentView *documentView() const;
0107 
0108     QToolButton *toggleSideBarButton() const;
0109 
0110     void showMessageWidget(QGraphicsWidget *, Qt::Alignment align = Qt::AlignHCenter | Qt::AlignTop);
0111 
0112 Q_SIGNALS:
0113 
0114     /**
0115      * Emitted when the part has finished loading
0116      */
0117     void completed();
0118 
0119     void previousImageRequested();
0120 
0121     void nextImageRequested();
0122 
0123     void openUrlRequested(const QUrl &);
0124 
0125     void openDirUrlRequested(const QUrl &);
0126 
0127     void toggleFullScreenRequested();
0128 
0129     void goToBrowseModeRequested();
0130 
0131     void captionUpdateRequested(const QString &);
0132 
0133 public Q_SLOTS:
0134     void setStatusBarVisible(bool);
0135 
0136 private Q_SLOTS:
0137     void setThumbnailBarVisibility(bool visible);
0138 
0139     void showContextMenu();
0140 
0141     void slotViewFocused(DocumentView *);
0142 
0143     void slotEnterPressed();
0144 
0145     void trashView(DocumentView *);
0146     void deselectView(DocumentView *);
0147 
0148     void slotDirModelItemsAddedOrRemoved();
0149 
0150 protected:
0151     bool eventFilter(QObject *watched, QEvent *event) override;
0152 
0153 private:
0154     friend struct ViewMainPagePrivate;
0155     ViewMainPagePrivate *const d;
0156 
0157     void updateFocus(const AbstractRasterImageViewTool *tool);
0158 };
0159 
0160 } // namespace
0161 
0162 #endif /* VIEWMAINPAGE_H */