KMediaPlayer

view.h
1 // Copyright (C) 2002 Neil Stevens <[email protected]>
2 //
3 // Permission is hereby granted, free of charge, to any person obtaining a copy
4 // of this software and associated documentation files (the "Software"), to deal
5 // in the Software without restriction, including without limitation the rights
6 // to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
7 // copies of the Software, and to permit persons to whom the Software is
8 // furnished to do so, subject to the following conditions:
9 //
10 // The above copyright notice and this permission notice shall be included in
11 // all copies or substantial portions of the Software.
12 //
13 // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
14 // IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
15 // FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
16 // THE AUTHOR(S) BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN
17 // AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
18 // CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
19 //
20 // Except as contained in this notice, the name(s) of the author(s) shall not be
21 // used in advertising or otherwise to promote the sale, use or other dealings
22 // in this Software without prior written authorization from the author(s).
23 
24 #ifndef KMEDIAPLAYERVIEW_H
25 #define KMEDIAPLAYERVIEW_H
26 
27 #include <QWidget>
28 #include "kmediaplayer_export.h"
29 
30 #include <memory>
31 
32 namespace KMediaPlayer
33 {
34 
35 /**
36  * A user interface to control a Player object.
37  *
38  * Player::view() should be used to access an instance of this class.
39  */
40 class KMEDIAPLAYER_EXPORT View : public QWidget
41 {
42  Q_OBJECT
43  Q_FLAGS(Button Buttons)
44  /**
45  * The controls that are displayed by the interface.
46  */
47  Q_PROPERTY(Buttons buttons READ buttons WRITE setButtons NOTIFY buttonsChanged)
48  /**
49  * The widget that displays video output.
50  *
51  * This may be 0 if video output is not supported.
52  */
53  Q_PROPERTY(QWidget* videoWidget READ videoWidget)
54 
55 public:
56  /**
57  * Creates the user interface widget.
58  *
59  * @param parent The parent widget.
60  */
61  explicit View(QWidget *parent);
62  /**
63  * Destroys all related resources (but not the player object).
64  */
65  virtual ~View();
66 
67  /** The controls that can appear in the interface. */
68  enum Button {
69  /**
70  * A control to start playback.
71  *
72  * @see Player::play()
73  */
74  Play = 1,
75  /**
76  * A control to stop playback.
77  *
78  * @see Player::stop()
79  */
80  Stop = 2,
81  /**
82  * A control to pause playback.
83  *
84  * @see Player::pause()
85  */
86  Pause = 4,
87  /**
88  * A control to adjust the playback position.
89  *
90  * @see Player::seek()
91  */
92  Seeker = 8,
93  /**
94  * All controls.
95  */
96  All = 255
97  };
98  Q_DECLARE_FLAGS(Buttons, Button)
99 
100  /**
101  * Returns which buttons are being displayed.
102  */
103  Buttons buttons();
104 
105  /**
106  * Returns the widget used to display video output.
107  *
108  * May return 0 if video output is not supported.
109  */
110  QWidget *videoWidget();
111 
112 public Q_SLOTS:
113  /**
114  * Set the controls to display.
115  *
116  * @param buttons A ORed combination of buttons to display.
117  */
118  void setButtons(Buttons buttons);
119 
120  /**
121  * Queries whether a particular control is being displayed.
122  *
123  * @param button The control to query.
124  */
125  bool button(Button button);
126  /**
127  * Display a control.
128  *
129  * If the control is already displayed, this has no effect. Otherwise, it
130  * will be added to the set of controls to be displayed.
131  *
132  * @param button The control to display.
133  */
134  void showButton(Button button);
135  /**
136  * Stop displaying a control.
137  *
138  * If the control is not already displayed, this has no effect. Otherwise,
139  * it will be removed from the set of controls to be displayed.
140  *
141  * @param button The control to stop displaying.
142  */
143  void hideButton(Button button);
144  /**
145  * Toggle the display of a control.
146  *
147  * If the control is not already displayed, it will be added to the set of
148  * controls to be displayed. Otherwise, it will be removed from that set.
149  *
150  * @param button The control to toggle.
151  */
152  void toggleButton(Button button);
153 
154 Q_SIGNALS:
155  /**
156  * Indicates that the value returned by buttons() has changed.
157  *
158  * Subclasses should connect to this signal to update the set of controls
159  * they display.
160  *
161  * @param buttons The new value.
162  */
163  void buttonsChanged(KMediaPlayer::View::Buttons buttons);
164 
165 protected:
166  /**
167  * Set the widget used to display video output.
168  *
169  * This should normally be created with this object as the parent, but users
170  * of this object may use QWidget::setParent(QWidget*) to move it elsewhere.
171  */
172  void setVideoWidget(QWidget *videoWidget);
173 
174 private:
175  std::unique_ptr<class ViewPrivate> const d;
176 };
177 
178 Q_DECLARE_OPERATORS_FOR_FLAGS(View::Buttons)
179 
180 }
181 
182 Q_DECLARE_METATYPE(KMediaPlayer::View::Button)
183 Q_DECLARE_METATYPE(KMediaPlayer::View::Buttons)
184 
185 #endif
A user interface to control a Player object.
Definition: view.h:40
An interface for media playback parts.
Definition: player.h:37
Button
The controls that can appear in the interface.
Definition: view.h:68
This file is part of the KDE documentation.
Documentation copyright © 1996-2021 The KDE developers.
Generated on Tue May 11 2021 22:42:46 by doxygen 1.8.11 written by Dimitri van Heesch, © 1997-2006

KDE's Doxygen guidelines are available online.