KMediaPlayer

view.cpp
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 #include "view.h"
25 
26 class KMediaPlayer::ViewPrivate
27 {
28 public:
29  ViewPrivate()
30  : videoWidget(nullptr)
31  , currentButtons(View::All)
32  {
33  if (!buttonEnumRegistered) {
34  buttonEnumRegistered = qRegisterMetaType<KMediaPlayer::View::Button>("KMediaPlayer::View::Button");
35  }
36  if (!buttonsFlagsRegistered) {
37  buttonsFlagsRegistered = qRegisterMetaType<KMediaPlayer::View::Buttons>("KMediaPlayer::View::Buttons");
38  }
39  }
40 
41  QWidget *videoWidget;
42  View::Buttons currentButtons;
43 
44  static bool buttonEnumRegistered;
45  static bool buttonsFlagsRegistered;
46 };
47 bool KMediaPlayer::ViewPrivate::buttonEnumRegistered = false;
48 bool KMediaPlayer::ViewPrivate::buttonsFlagsRegistered = false;
49 
51  : QWidget(parent)
52  , d(new ViewPrivate())
53 {
54 }
55 
56 KMediaPlayer::View::~View() = default;
57 
59 {
60  return d->currentButtons;
61 }
62 
64 {
65  if (buttons != d->currentButtons) {
66  d->currentButtons = buttons;
67  Q_EMIT buttonsChanged(buttons);
68  }
69 }
70 
72 {
73  return d->currentButtons & b;
74 }
75 
77 {
78  setButtons(d->currentButtons | b);
79 }
80 
82 {
83  setButtons(d->currentButtons & ~b);
84 }
85 
87 {
88  setButtons(d->currentButtons ^ b);
89 }
90 
92 {
93  d->videoWidget = videoWidget;
94 }
95 
97 {
98  return d->videoWidget;
99 }
100 
virtual ~View()
Destroys all related resources (but not the player object).
void toggleButton(Button button)
Toggle the display of a control.
Definition: view.cpp:86
QWidget * videoWidget()
Returns the widget used to display video output.
void setButtons(Buttons buttons)
Set the controls to display.
Definition: view.cpp:63
Buttons buttons()
Returns which buttons are being displayed.
void showButton(Button button)
Display a control.
Definition: view.cpp:76
void hideButton(Button button)
Stop displaying a control.
Definition: view.cpp:81
void setVideoWidget(QWidget *videoWidget)
Set the widget used to display video output.
Definition: view.cpp:91
Button
The controls that can appear in the interface.
Definition: view.h:68
View(QWidget *parent)
Creates the user interface widget.
Definition: view.cpp:50
void buttonsChanged(KMediaPlayer::View::Buttons buttons)
Indicates that the value returned by buttons() has changed.
bool button(Button button)
Queries whether a particular control is being displayed.
Definition: view.cpp:71
Q_EMITQ_EMIT
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.