File indexing completed on 2024-05-12 08:17:15

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 MAINWINDOW_H
0021 #define MAINWINDOW_H
0022 
0023 // Qt
0024 #include <QAction>
0025 
0026 // KF
0027 #include <KXmlGuiWindow>
0028 
0029 class QModelIndex;
0030 
0031 class QUrl;
0032 
0033 class QMouseEvent;
0034 
0035 namespace Gwenview
0036 {
0037 class ViewMainPage;
0038 class ContextManager;
0039 
0040 class MainWindow : public KXmlGuiWindow
0041 {
0042     Q_OBJECT
0043 public:
0044     MainWindow();
0045     ~MainWindow() override;
0046     /**
0047      * Defines the url to display when the window is shown for the first time.
0048      */
0049     void setInitialUrl(const QUrl &);
0050 
0051     void startSlideShow();
0052 
0053     ViewMainPage *viewMainPage() const;
0054 
0055     ContextManager *contextManager() const;
0056 
0057     void setDistractionFreeMode(bool);
0058 
0059 public Q_SLOTS:
0060     void showStartMainPage();
0061 
0062     /**
0063      * Go to url, without changing current mode
0064      */
0065     void goToUrl(const QUrl &);
0066 
0067 Q_SIGNALS:
0068     void viewModeChanged();
0069 
0070 public Q_SLOTS:
0071     void setCaption(const QString &) override;
0072 
0073     void setCaption(const QString &, bool modified) override;
0074 
0075 protected:
0076     bool queryClose() override;
0077     QSize sizeHint() const override;
0078     void showEvent(QShowEvent *) override;
0079     void resizeEvent(QResizeEvent *) override;
0080     void saveProperties(KConfigGroup &) override;
0081     void readProperties(const KConfigGroup &) override;
0082     bool eventFilter(QObject *, QEvent *) override;
0083     void mousePressEvent(QMouseEvent *) override;
0084     void mouseDoubleClickEvent(QMouseEvent *) override;
0085 
0086 private Q_SLOTS:
0087     void setActiveViewModeAction(QAction *action);
0088     void openDirUrl(const QUrl &);
0089     void slotThumbnailViewIndexActivated(const QModelIndex &);
0090 
0091     void slotStartMainPageUrlSelected(const QUrl &);
0092 
0093     void goUp();
0094     void toggleSideBar(bool visible);
0095     void toggleOperationsSideBar(bool visible);
0096     void slotModifiedDocumentListChanged();
0097     void slotUpdateCaption(const QString &caption);
0098     void slotPartCompleted();
0099     void slotDirModelNewItems();
0100     void slotDirListerCompleted();
0101 
0102     void slotSelectionChanged();
0103     void slotCurrentDirUrlChanged(const QUrl &url);
0104 
0105     void goToPrevious();
0106     void goToNext();
0107     void goToFirst();
0108     void goToLast();
0109     void updatePreviousNextActions();
0110 
0111     void leaveFullScreen();
0112     void toggleFullScreen(bool);
0113     void toggleSlideShow();
0114     void updateSlideShowAction();
0115 
0116     void saveCurrent();
0117     void saveCurrentAs();
0118     void openFile();
0119     void openUrl(const QUrl &url);
0120     void reload();
0121 
0122     void showDocumentInFullScreen(const QUrl &);
0123 
0124     /**
0125      * Shows Gwenview's settings dialog.
0126      * @param page defines which page should be shown initially.
0127      */
0128     void showConfigDialog(int page = 0);
0129     void loadConfig();
0130     void print();
0131     void printPreview();
0132 
0133     void preloadNextUrl();
0134 
0135     void toggleMenuBar();
0136     void toggleStatusBar(bool visible);
0137 
0138     void showFirstDocumentReached();
0139     void showLastDocumentReached();
0140 
0141     void replaceLocation();
0142 
0143     void onFocusChanged(QWidget *old, QWidget *now);
0144 
0145 private:
0146     struct Private;
0147     MainWindow::Private *const d;
0148 
0149     void openSelectedDocuments();
0150     void saveConfig();
0151     void configureShortcuts();
0152 
0153     void mouseButtonNavigate(QMouseEvent *);
0154 
0155     void folderViewUrlChanged(const QUrl &url);
0156     void syncSortOrder(const QUrl &url);
0157 };
0158 
0159 } // namespace
0160 
0161 #endif /* MAINWINDOW_H */