MythTV  master
imageview.h
Go to the documentation of this file.
1 // -*- Mode: c++ -*-
2 /* ============================================================
3  * File : imageview.h
4  * Description :
5  *
6  * Copyright 2004-2006 Renchi Raju, Daniel Kristjansson
7  *
8  * This program is free software; you can redistribute it
9  * and/or modify it under the terms of the GNU General
10  * Public License as published bythe Free Software Foundation;
11  * either version 2, or (at your option)
12  * any later version.
13  *
14  * This program is distributed in the hope that it will be useful,
15  * but WITHOUT ANY WARRANTY; without even the implied warranty of
16  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
17  * GNU General Public License for more details.
18  *
19  * ============================================================ */
20 
21 #ifndef IMAGEVIEW_H
22 #define IMAGEVIEW_H
23 
24 #include <vector>
25 using namespace std;
26 
27 #include <QObject>
28 // MythGallery headers
29 #include "iconview.h"
30 #include "sequence.h"
31 
32 class MThread;
33 class QImage;
34 class QMutex;
35 class QRunnable;
36 class QTimer;
37 class QWaitCondition;
38 class ImageView;
39 class ThumbItem;
40 
42 class LoadAlbumListener : public QObject {
43  Q_OBJECT
45 public:
46  explicit LoadAlbumListener(ImageView *parent)
47  : m_parent(parent) {}
48  virtual ~LoadAlbumListener() = default;
49 private slots:
50  void FinishLoading() const;
51 };
52 
53 class ImageView
54 {
55  Q_DECLARE_TR_FUNCTIONS(ImageView);
56 
57  public:
58  ImageView(const ThumbList &itemList,
59  int *pos, int slideShow, int sortorder);
60  ThumbItem *getCurrentItem() const;
61  virtual ~ImageView();
62 
63  protected:
64  static SequenceBase *ComposeSlideshowSequence(int slideshow_sequencing);
65 
66  // Commands
67  virtual void Rotate(int angle) = 0;
68  virtual void DisplayNext(bool reset, bool loadImage) = 0;
69  virtual void DisplayPrev(bool reset, bool loadImage) = 0;
70  virtual void Load(void) = 0;
71 
72  // Sets
73  virtual void SetZoom(float zoom) = 0;
74 
75  // Effects
76  virtual void RegisterEffects(void) = 0;
77  virtual QString GetRandomEffect(void) const;
78  virtual void RunEffect(const QString &effect) = 0;
79 
80  void UpdateLCD(const ThumbItem *item);
81  QString GetDescriptionStatus(void) const;
82  void GetScreenShot(QImage& image, const ThumbItem *item);
83  virtual void AddItems(const ThumbList &itemList);
84  ThumbItem *advanceItem();
85  ThumbItem *retreatItem();
86 
87  private:
88  friend class LoadAlbumListener;
89  void FinishLoading();
90  double GetSeasonalWeight(ThumbItem *item);
91 
92  protected:
93  QSize m_screenSize {640,480};
94  float m_wmult {1.0F};
95  float m_hmult {1.0F};
96  int m_pos;
97  int *m_savedPos {nullptr};
98  int m_movieState {0};
99  float m_zoom {1.0F};
100 
101  bool m_info_show {false};
102  bool m_info_show_short {false};
103 
104  // Common slideshow variables
105  bool m_slideshow_running {false};
107  int m_slideshow_frame_delay {2};
108  int m_slideshow_frame_delay_state {2000};
109  QTimer *m_slideshow_timer {nullptr};
110  const char *m_slideshow_mode {nullptr};
111 
112  // Common effect state variables
113  bool m_effect_running {false};
114  int m_effect_current_frame {0};
116  QMap<QString,QString> m_effect_map;
117  bool m_effect_random {false};
118 
119 private:
120  Q_DISABLE_COPY(ImageView)
121  class LoadAlbumRunnable;
122 
123  LoadAlbumRunnable *m_loaderRunnable {nullptr};
125  MThread *m_loaderThread {nullptr};
126  QWaitCondition m_imagesLoaded;
127  // This lock must be held to access m_itemList and m_slideshow_sequence.
128  mutable QMutex m_itemListLock;
130  SequenceBase *m_slideshow_sequence {nullptr};
131  bool m_finishedLoading {false};
132 };
133 
134 #endif /* IMAGEVIEW_H */
int m_pos
Definition: imageview.h:96
This is a wrapper around QThread that does several additional things.
Definition: mthread.h:46
unsigned int slots[4]
Definition: element.c:38
LoadAlbumListener(ImageView *parent)
Definition: imageview.h:46
QList< ThumbItem * > ThumbList
Definition: thumbview.h:78
QMap< QString, QString > m_effect_map
Definition: imageview.h:116
ThumbList m_itemList
Definition: imageview.h:129
ImageView * m_parent
Definition: imageview.h:44
const int m_slideshow_sequencing
Definition: imageview.h:106
QString m_effect_method
Definition: imageview.h:115
Handler for events related to LoadAlbumListener.
Definition: imageview.h:42
void FinishLoading() const
Definition: imageview.cpp:424
QWaitCondition m_imagesLoaded
Definition: imageview.h:126
LoadAlbumListener m_listener
Definition: imageview.h:124
QMutex m_itemListLock
Definition: imageview.h:128