File indexing completed on 2024-05-05 16:39:04

0001 /* This file is part of the KDE project
0002    Copyright (C) 1998-2006 Carsten Pfeiffer <pfeiffer@kde.org>
0003 
0004    This program is free software; you can redistribute it and/or
0005    modify it under the terms of the GNU General Public
0006    License as published by the Free Software Foundation, version 2.
0007 
0008    This program is distributed in the hope that it will be useful,
0009    but WITHOUT ANY WARRANTY; without even the implied warranty of
0010    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
0011     General Public License for more details.
0012 
0013    You should have received a copy of the GNU General Public License
0014    along with this program; see the file COPYING.  If not, write to
0015    the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
0016    Boston, MA 02110-1301, USA.
0017 */
0018 
0019 #ifndef KUICKSHOW_H
0020 #define KUICKSHOW_H
0021 
0022 #include <KXmlGuiWindow>
0023 
0024 #include <QKeyEvent>
0025 #include <QPointer>
0026 #include <QX11Info>
0027 
0028 #include "imlib-wrapper.h"
0029 
0030 class KFileItem;
0031 class KToggleAction;
0032 class KUrlComboBox;
0033 class QDropEvent;
0034 class QEvent;
0035 class QLabel;
0036 class QString;
0037 class QUrl;
0038 class AboutWidget;
0039 class FileWidget;
0040 class ImageWindow;
0041 class ImData;
0042 class KuickConfigDialog;
0043 class KuickFile;
0044 
0045 
0046 class DelayedRepeatEvent
0047 {
0048 public:
0049     DelayedRepeatEvent( ImageWindow *view, QKeyEvent *ev ) {
0050         viewer = view;
0051         event  = ev;
0052     }
0053     DelayedRepeatEvent( ImageWindow *view, int action, void *data ) {
0054         this->viewer = view;
0055         this->action = action;
0056         this->data   = data;
0057         this->event  = 0L;
0058     }
0059 
0060     ~DelayedRepeatEvent() {
0061         delete event;
0062     }
0063 
0064     enum Action
0065     {
0066         DeleteCurrentFile,
0067         TrashCurrentFile,
0068         AdvanceViewer
0069     };
0070 
0071     ImageWindow *viewer;
0072     QKeyEvent *event;
0073     int action;
0074     void *data;
0075 };
0076 
0077 
0078 class KuickShow : public KXmlGuiWindow
0079 {
0080     Q_OBJECT
0081 
0082 public:
0083     KuickShow( const char *name=0 );
0084     ~KuickShow();
0085 
0086     virtual void    show();
0087     static QList<ImageWindow*>  s_viewers;
0088 
0089     // overridden to make KDCOPActionProxy work -- all our actions are not
0090     // in the mainwindow's collection, but in the filewidget's.
0091     virtual KActionCollection* actionCollection() const override;
0092 
0093 
0094 protected:
0095     virtual void    readProperties( const KConfigGroup& kc ) override;
0096     void        initImlibParams( ImData *, ImlibInitParams * );
0097     void                tryShowNextImage();
0098 
0099 private slots:
0100     void        toggleBrowser();
0101     void        slotToggleInlinePreview( bool on );
0102     void        slotQuit() { delete this; }
0103     void        slotPrint();
0104     void        slotConfigApplied();
0105     void        slotConfigClosed();
0106     void        messageCantLoadImage( const KuickFile *file, const QString& message );
0107     bool        showImage(const KFileItem&, bool newWindow = false,
0108                           bool fullscreen = false, bool moveToTopLeft = true, bool ignoreFileType = false );
0109     void        showFileItem( ImageWindow *, const KFileItem * );
0110     void        slotHighlighted( const KFileItem& );
0111     void        slotSelected( const KFileItem& );
0112     void        dirSelected( const QUrl& );
0113     void        configuration();
0114     void            about();
0115     void        startSlideShow();
0116     void                pauseSlideShow();
0117     void        nextSlide();
0118     void                nextSlide( const KFileItem& item );
0119     void        viewerDeleted();
0120     void        slotDropped( const KFileItem&, QDropEvent *, const QList<QUrl> &);
0121     void        slotSetActiveViewer( ImageWindow *i ) { m_viewer = i; }
0122     void                slotAdvanceImage( ImageWindow *, int steps );
0123 
0124     void        slotShowInSameWindow();
0125     void        slotShowInOtherWindow();
0126     void                slotShowFullscreen();
0127 
0128     void        slotReplayEvent();
0129     void                slotOpenURL();
0130     void        slotSetURL( const QUrl& );
0131     void        slotURLComboReturnPressed();
0132 //     void                invalidateImages( const KFileItemList& items );
0133     void        slotDeleteCurrentImage(ImageWindow *viewer);
0134     void        slotTrashCurrentImage(ImageWindow *viewer);
0135     void                slotDeleteCurrentImage();
0136     void                slotTrashCurrentImage();
0137 
0138     void                doReplay();
0139 
0140 private:
0141     Display *       getX11Display() const { return QX11Info::display(); }
0142     int getX11Screen() const;
0143     void        initGUI( const QUrl& startDir );
0144     bool            eventFilter( QObject *, QEvent * ) override;
0145     void        initImlib();
0146     void        saveProperties( KConfigGroup& kc ) override;
0147     void        saveSettings();
0148     bool        haveBrowser() const;
0149     void        delayedRepeatEvent( ImageWindow *, QKeyEvent * );
0150     void        abortDelayedEvent();
0151     void                deleteAllViewers();
0152     void                redirectDeleteAndTrashActions(KActionCollection *coll);
0153 
0154     void                delayAction(DelayedRepeatEvent *event);
0155     void                replayAdvance(DelayedRepeatEvent *event);
0156 
0157     void                performDeleteCurrentImage(QWidget *parent);
0158     void                performTrashCurrentImage(QWidget *parent);
0159 
0160     uint        viewItem, renameItem, deleteItem, printItem;
0161     uint                m_slideshowCycle;
0162 
0163     FileWidget      *fileWidget;
0164     KUrlComboBox    *cmbPath;
0165     KuickConfigDialog   *dialog;
0166     ImlibData           *id;
0167     ImageWindow     *m_viewer;
0168     KToggleAction   *oneWindowAction;
0169     DelayedRepeatEvent  *m_delayedRepeatItem;
0170     QTimer              *m_slideTimer;
0171     bool                m_slideShowStopped;
0172     KToggleAction       *m_toggleBrowserAction;
0173     QPointer<AboutWidget> aboutWidget;
0174 
0175     QLabel* sblblUrlInfo;
0176     QLabel* sblblMetaInfo;
0177     QLabel* createStatusBarLabel(int stretch);
0178 };
0179 
0180 #endif