summaryrefslogtreecommitdiffstats
path: root/umbrello/umbrello/kplayerslideraction.h
blob: 8c0b11efb85b562839623653565b356c31e6f649 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
/***************************************************************************
                          kplayerslideraction.h
                          ---------------------
    begin                : Sat Jan 11 2003
    copyright            : (C) 2003 by kiriuja
    email                : kplayer-dev@en-directo.net
 ***************************************************************************/

/***************************************************************************
 *   This program is free software; you can redistribute it and/or modify  *
 *   it under the terms of the GNU General Public License as published by  *
 *   the Free Software Foundation; either version 2 of the License, or     *
 *   (at your option) any later version.                                   *
 ***************************************************************************/

#ifndef KPLAYERSLIDERACTION_H
#define KPLAYERSLIDERACTION_H

#include <kaction.h>
#include <tqslider.h>

/**KPlayer's slider widget. Works around the TQt upside-down slider bug.
 * Taken from kplayer CVS 2003-09-21 (kplayer > 0.3.1) by Jonathan Riddell
  *@author kiriuja
  */
class KPlayerSlider : public TQSlider
{
    Q_OBJECT
  TQ_OBJECT

public:
    /** The KPlayerSlider constructor. Parameters are passed on to TQSlider.
      */
    explicit KPlayerSlider (Qt::Orientation, TQWidget* parent = 0, const char* name = 0);
    /** The KPlayerSlider destructor. Does nothing.
      */
    virtual ~KPlayerSlider();

    /** The size hint.
     */
    virtual TQSize tqsizeHint() const;
    /** The minimum size hint.
     */
    virtual TQSize tqminimumSizeHint() const;

    /** The minimum value.
      */
    int minValue (void) const;
    /** Sets the minimum value.
      */
    void setMinValue (int);
    /** The maximum value.
      */
    int maxValue (void) const;
    /** Sets the maximum value.
      */
    void setMaxValue (int);
    /** The line step.
      */
    int lineStep (void) const;
    /** Sets the line step.
      */
    void setLineStep (int);
    /** The page step.
      */
    int pageStep (void) const;
    /** Sets the page step.
      */
    void setPageStep (int);
    /** The current value.
      */
    int value (void) const;
    /** Sets the current value. The extra parameter prevents overriding of the virtual TQSlider::setValue.
      */
    void setValue (int, int = 0); // do not override the virtual setValue

    /** Sets up the slider by setting five options in one go.
      */
    void setup (int minValue, int maxValue, int value, int pageStep, int lineStep = 1);
    /** Sets the slider orientation.
      */
    virtual void setOrientation (Qt::Orientation);

signals:
    /** Emitted when the slider value changes.
      */
    void changed (int);

protected slots:
    /** Receives the valueChanged signal from TQSlider.
      */
    void sliderValueChanged (int);

protected:
    // Recursion prevention. Should be private.
    bool m_changing_orientation;

    friend class KPlayerSliderAction;
    friend class KPlayerPopupSliderAction;
};

/**KPlayer popup frame.
  *@author kiriuja
  */
class KPlayerPopupFrame : public TQFrame
{
    Q_OBJECT
  TQ_OBJECT

public:
    /** The KPlayerPopupFrame constructor. Parameters are passed on to TQFrame.
      */
    KPlayerPopupFrame (TQWidget* parent = 0, const char* name = 0)
            : TQFrame (parent, name, TQt::WType_Popup) { }
    /** The KPlayerPopupFrame destructor. Does nothing.
      */
    virtual ~KPlayerPopupFrame() { }

protected:
    /** Closes the popup frame when Alt, Tab, Esc, Enter or Return is pressed.
      */
    virtual void keyPressEvent (TQKeyEvent*);
};

/**Action representing a popup slider activated by a toolbar button.
  *@author kiriuja
  */
class KPlayerPopupSliderAction : public KAction
{
    Q_OBJECT
  TQ_OBJECT

public:
    /** The KPlayerPopupSliderAction constructor. Parameters are passed on to KAction.
      */
    KPlayerPopupSliderAction (const TQString& text, const TQString& pix, const KShortcut& shortcut,
                              const TQObject* receiver, const char* slot, TQObject* parent = 0, const char* name = 0);
    /** The KPlayerPopupSliderAction destructor. Deletes the KPlayerPopupFrame.
      */
    virtual ~KPlayerPopupSliderAction();

    /** Returns a pointer to the KPlayerSlider object.
      */
    KPlayerSlider* slider (void)
    { return m_slider; }

    /** Plugs the action into the toolbar. Reparents the slider into the toolbar. */
    //virtual int plug (TQWidget*, int = -1);
    /** Unplugs the action from the toolbar. Reparents the slider out of the toolbar. */
    //virtual void unplug (TQWidget*);

protected slots:
    /** Pops up the slider.
      */
    virtual void slotActivated (void);

protected:
    /** The slider.
      */
    KPlayerSlider* m_slider;
    /** The popup frame.
      */
    KPlayerPopupFrame* m_frame;
};

/**Slider action suitable for insertion into a toolbar.
  *@author kiriuja
  */
class KPlayerSliderAction : public KWidgetAction
{
    Q_OBJECT
  TQ_OBJECT

public:
    /** The KPlayerSliderAction constructor. Parameters are passed on to KAction.
      */
    KPlayerSliderAction (const TQString& text, const KShortcut&, const TQObject* receiver,
                         const char* slot, KActionCollection* parent = 0, const char* name = 0);
    /** The KPlayerSliderAction destructor. Does nothing.
      */
    virtual ~KPlayerSliderAction();

    /** Returns a pointer to the KPlayerSlider object.
      */
    KPlayerSlider* slider (void)
    { return (KPlayerSlider*) widget(); }

    /** Plugs the slider into the toolbar.
      */
    virtual int plug (TQWidget* widget, int index = -1);
    /** Unplugs the slider from the toolbar.
      */
    virtual void unplug (TQWidget* widget);

protected slots:
    /** Changes the slider orientation when the toolbar orientation changes.
      */
    void orientationChanged (Qt::Orientation);

protected:
    /** The slider.
      */
    //KPlayerSlider* m_slider;
};

#endif