digiKam
presentationkb.h
Go to the documentation of this file.
1 /* ============================================================
2  *
3  * This file is a part of digiKam project
4  * https://www.digikam.org
5  *
6  * Date : 2007-11-14
7  * Description : a presentation tool.
8  *
9  * Copyright (C) 2007-2009 by Valerio Fuoglio <valerio dot fuoglio at gmail dot com>
10  * Copyright (C) 2012-2022 by Gilles Caulier <caulier dot gilles at gmail dot com>
11  *
12  * Parts of this code are based on
13  * smoothslidesaver by Carsten Weinhold <carsten dot weinhold at gmx dot de>
14  * and slideshowgl by Renchi Raju <renchi dot raju at gmail dot com>
15  *
16  * This program is free software; you can redistribute it
17  * and/or modify it under the terms of the GNU General
18  * Public License as published by the Free Software Foundation;
19  * either version 2, or (at your option) any later version.
20  *
21  * This program is distributed in the hope that it will be useful,
22  * but WITHOUT ANY WARRANTY; without even the implied warranty of
23  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
24  * GNU General Public License for more details.
25  *
26  * ============================================================ */
27 
28 #ifndef DIGIKAM_PRESENTATION_KB_H
29 #define DIGIKAM_PRESENTATION_KB_H
30 
31 // C++ includes
32 
33 #ifndef Q_CC_MSVC
34 # include <cstdlib>
35 #else
36 # include <winsock2.h>
37 #endif
38 
39 // Qt includes
40 
41 #include <QList>
42 #include <QKeyEvent>
43 #include <QMap>
44 #include <QMouseEvent>
45 #include <QPair>
46 #include <QString>
47 #include <QStringList>
48 #include <QTimer>
49 #include <QOpenGLWidget>
50 #include <QOpenGLTexture>
51 #include <QRandomGenerator>
52 
54 {
55 
56 class PresentationContainer;
57 
59 {
60 
61 public:
62 
63  KBViewTrans(bool zoomIn, float relAspect);
64  KBViewTrans();
65  ~KBViewTrans();
66 
67  float transX(float pos) const;
68  float transY(float pos) const;
69  float scale(float pos) const;
70  float xScaleCorrect() const;
71  float yScaleCorrect() const;
72 
73 private:
74 
75  double rnd() const;
76  double rndSign() const;
77 
78 private:
79 
81  double m_deltaX;
82  double m_deltaY;
83  double m_deltaScale;
84  double m_baseScale;
85  double m_baseX;
86  double m_baseY;
87  float m_xScale;
88  float m_yScale;
89 };
90 
91 // -------------------------------------------------------------------------
92 
93 class KBImage
94 {
95 
96 public:
97 
98  explicit KBImage(KBViewTrans* const viewTrans, float aspect = 1.0);
99  ~KBImage();
100 
101 public:
102 
104  float m_aspect;
105  float m_pos;
106  float m_opacity;
107  bool m_paint;
108  QOpenGLTexture* m_texture;
109 };
110 
111 // -------------------------------------------------------------------------
112 
113 class PresentationKB : public QOpenGLWidget
114 {
115  Q_OBJECT
116 
117 public:
118 
119  explicit PresentationKB(PresentationContainer* const sharedData);
120 
121  ~PresentationKB() override;
122 
123  static QStringList effectNames();
124  static QMap<QString, QString> effectNamesI18N();
125 
126  bool checkOpenGL() const;
127 
128 private:
129 
130  float aspect() const;
131  bool setupNewImage(int imageIndex);
132  void startSlideShowOnce();
133  void swapImages();
134  void setNewKBEffect();
135  void endOfShow();
136 
137  void applyTexture(KBImage* const img, const QImage& image);
138  void paintTexture(KBImage* const img);
139  unsigned suggestFrameRate(unsigned forceRate);
140 
141  void readSettings();
142 
143 protected:
144 
145  void initializeGL() override;
146  void paintGL() override;
147  void resizeGL(int w, int h) override;
148 
149  void mousePressEvent(QMouseEvent*) override;
150  void mouseMoveEvent(QMouseEvent*) override;
151  void keyPressEvent(QKeyEvent*) override;
152 
153 private Q_SLOTS:
154 
155  void moveSlot();
156  void slotMouseMoveTimeOut();
157  void slotClose();
158 
159 private:
160 
161  // Disable
162  explicit PresentationKB(QWidget*) = delete;
163 
164 private:
165 
166  class Private;
167  Private* const d;
168 
169  friend class KBEffect;
170 };
171 
172 } // namespace DigikamGenericPresentationPlugin
173 
174 #endif // DIGIKAM_PRESENTATION_KB_H
Definition: presentationkb.h:94
bool m_paint
Definition: presentationkb.h:107
float m_pos
Definition: presentationkb.h:105
~KBImage()
Definition: presentationkb.cpp:208
KBViewTrans * m_viewTrans
Definition: presentationkb.h:103
float m_opacity
Definition: presentationkb.h:106
KBImage(KBViewTrans *const viewTrans, float aspect=1.0)
Definition: presentationkb.cpp:198
float m_aspect
Definition: presentationkb.h:104
QOpenGLTexture * m_texture
Definition: presentationkb.h:108
Definition: presentationkb.h:59
float xScaleCorrect() const
Definition: presentationkb.cpp:176
float transY(float pos) const
Definition: presentationkb.cpp:166
float scale(float pos) const
Definition: presentationkb.cpp:171
KBViewTrans()
Definition: presentationkb.cpp:145
float transX(float pos) const
Definition: presentationkb.cpp:161
~KBViewTrans()
Definition: presentationkb.cpp:157
float yScaleCorrect() const
Definition: presentationkb.cpp:181
Definition: presentationcontainer.h:54
Definition: presentationkb.h:114
void paintGL() override
Definition: presentationkb.cpp:516
static QStringList effectNames()
Definition: presentationkb.cpp:675
void keyPressEvent(QKeyEvent *) override
Definition: presentationkb.cpp:691
void mouseMoveEvent(QMouseEvent *) override
Definition: presentationkb.cpp:723
void initializeGL() override
Definition: presentationkb.cpp:490
static QMap< QString, QString > effectNamesI18N()
Definition: presentationkb.cpp:683
void mousePressEvent(QMouseEvent *) override
Definition: presentationkb.cpp:710
void resizeGL(int w, int h) override
Definition: presentationkb.cpp:558
bool checkOpenGL() const
Definition: presentationkb.cpp:783
~PresentationKB() override
Definition: presentationkb.cpp:323
PresentationKB(PresentationContainer *const sharedData)
Definition: presentationkb.cpp:221
Definition: presentation_audiopage.cpp:46