File indexing completed on 2025-03-09 03:52:09

0001 /* ============================================================
0002  *
0003  * This file is a part of digiKam project
0004  * https://www.digikam.org
0005  *
0006  * Date        : 2005-04-21
0007  * Description : slide show tool using preview of pictures.
0008  *
0009  * SPDX-FileCopyrightText: 2005-2024 by Gilles Caulier <caulier dot gilles at gmail dot com>
0010  * SPDX-FileCopyrightText: 2019-2020 by Minh Nghia Duong <minhnghiaduong997 at gmail dot com>
0011  *
0012  * SPDX-License-Identifier: GPL-2.0-or-later
0013  *
0014  * ============================================================ */
0015 
0016 #ifndef DIGIKAM_SLIDE_SHOW_LOADER_H
0017 #define DIGIKAM_SLIDE_SHOW_LOADER_H
0018 
0019 // Qt includes
0020 
0021 #include <QKeyEvent>
0022 #include <QMouseEvent>
0023 #include <QPaintEvent>
0024 #include <QWheelEvent>
0025 #include <QStackedWidget>
0026 
0027 // Local includes
0028 
0029 #include "digikam_config.h"
0030 #include "digikam_export.h"
0031 #include "dinfointerface.h"
0032 #include "loadingdescription.h"
0033 #include "slideshowsettings.h"
0034 #include "dimg.h"
0035 
0036 using namespace Digikam;
0037 
0038 namespace DigikamGenericSlideShowPlugin
0039 {
0040 
0041 class SlideShowLoader : public QStackedWidget
0042 {
0043     Q_OBJECT
0044 
0045 public:
0046 
0047     enum SlideShowViewMode
0048     {
0049         ErrorView = 0,
0050         ImageView,
0051 
0052 #ifdef HAVE_MEDIAPLAYER
0053 
0054         VideoView,
0055 
0056 #endif
0057 
0058         EndView
0059     };
0060 
0061 public:
0062 
0063     explicit SlideShowLoader(SlideShowSettings* const settings);
0064     ~SlideShowLoader()                          override;
0065 
0066     void setCurrentItem(const QUrl& url);
0067     QUrl currentItem() const;
0068 
0069     void setShortCutPrefixes(const QMap<QString, QString>& prefixes);
0070 
0071 Q_SIGNALS:
0072 
0073     void signalLastItemUrl(const QUrl&);
0074 
0075 public Q_SLOTS:
0076 
0077     void slotRemoveImageFromList();
0078     void slotLoadNextItem();
0079     void slotLoadPrevItem();
0080     void slotPause();
0081     void slotPlay();
0082 
0083     void slotAssignRating(int);
0084     void slotAssignColorLabel(int);
0085     void slotAssignPickLabel(int);
0086     void slotToggleTag(int tag);
0087 
0088     void slotHandleShortcut(const QString& shortcut, int val);
0089 
0090 protected:
0091 
0092     void mousePressEvent(QMouseEvent*)          override;
0093     void keyPressEvent(QKeyEvent*)              override;
0094     void wheelEvent(QWheelEvent*)               override;
0095 
0096 private Q_SLOTS:
0097 
0098     void slotMouseMoveTimeOut();
0099     void slotImageLoaded(bool);
0100     void slotScreenSelected(int);
0101     void slotVideoLoaded(bool);
0102     void slotVideoFinished();
0103 
0104 private:
0105 
0106     void setCurrentView(SlideShowViewMode);
0107     bool eventFilter(QObject* obj, QEvent* ev)  override;
0108     void preloadNextItem();
0109     void endOfSlide();
0110     void inhibitScreenSaver();
0111     void allowScreenSaver();
0112     void dispatchCurrentInfoChange(const QUrl& url);
0113     void makeCornerRectangles(const QRect& desktopRect, const QSize& size,
0114                               QRect* const topLeft, QRect* const topRight,
0115                               QRect* const topLeftLarger, QRect* const topRightLarger);
0116 
0117 private:
0118 
0119     // Disable
0120     explicit SlideShowLoader(QWidget*) = delete;
0121 
0122 private:
0123 
0124     class Private;
0125     Private* const d;
0126 };
0127 
0128 } // namespace DigikamGenericSlideShowPlugin
0129 
0130 #endif // DIGIKAM_SLIDE_SHOW_LOADER_H