~ubuntu-branches/debian/sid/smplayer/sid

« back to all changes in this revision

Viewing changes to src/old-code/floatingcontrol.cpp

  • Committer: Bazaar Package Importer
  • Author(s): Maia Kozheva
  • Date: 2009-03-31 23:05:43 UTC
  • mfrom: (1.2.2 upstream)
  • mto: This revision was merged to the branch mainline in revision 14.
  • Revision ID: james.westby@ubuntu.com-20090331230543-0h2hfwpwlu9opbv2
Tags: 0.6.7-1
* New upstream release. (Closes: #523791)
  - Reworked subtitle font preferences. (Closes: #503295)
  - No longer installs qt_fr.qm. (Closes: #486314)
* debian/control:
  - Bumped Standards-Version to 3.8.1.
  - Changed maintainer name (still the same person and GPG key).
  - Changed section to video.
  - Build-depend on zlib1g-dev for findsubtitles.
  - Require Qt >= 4.3 per readme.
  - Added ${misc:Depends}.
  - Make smplayer-translations depend on smplayer and smplayer recommend
    smplayer-translations, not the other way round. (Closes: #489375)
* debian/copyright:
  - Significantly expanded per-file with new upstream authors.
* debian/rules:
  - Make make use correct uic in install.
  - Clean svn_revision.
  - Removed get-orig-source - not needed with uscan --repack.
* debian/patches/01_gl_translation.patch:
  - Added patch to fix lrelease error on smplayer_gl.ts.
* Added debian/README.source for simple-patchsys.

Show diffs side-by-side

added added

removed removed

Lines of Context:
1
 
/*  smplayer, GUI front-end for mplayer.
2
 
    Copyright (C) 2006-2008 Ricardo Villalba <rvm@escomposlinux.org>
3
 
 
4
 
    This program is free software; you can redistribute it and/or modify
5
 
    it under the terms of the GNU General Public License as published by
6
 
    the Free Software Foundation; either version 2 of the License, or
7
 
    (at your option) any later version.
8
 
 
9
 
    This program is distributed in the hope that it will be useful,
10
 
    but WITHOUT ANY WARRANTY; without even the implied warranty of
11
 
    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
12
 
    GNU General Public License for more details.
13
 
 
14
 
    You should have received a copy of the GNU General Public License
15
 
    along with this program; if not, write to the Free Software
16
 
    Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
17
 
*/
18
 
 
19
 
#include "floatingcontrol.h"
20
 
 
21
 
#include <QToolButton>
22
 
#include <QIcon>
23
 
#include <QLCDNumber>
24
 
#include <QLabel>
25
 
#include <QFrame>
26
 
#include <QHBoxLayout>
27
 
#include <QEvent>
28
 
#include <QApplication>
29
 
 
30
 
#include "timeslider.h"
31
 
#include "images.h"
32
 
#include "helper.h"
33
 
 
34
 
 
35
 
class MyToolButton : public QToolButton {
36
 
public:
37
 
        MyToolButton ( QWidget * parent );
38
 
};
39
 
 
40
 
MyToolButton::MyToolButton( QWidget * parent ) : QToolButton(parent) 
41
 
{
42
 
        setAutoRaise(true);
43
 
        setIconSize( QSize(32,32) );
44
 
}
45
 
 
46
 
 
47
 
FloatingControl::FloatingControl( QWidget * parent )
48
 
        : QWidget( parent, Qt::Window | Qt::FramelessWindowHint | 
49
 
                       Qt::WindowStaysOnTopHint | 
50
 
                       Qt::X11BypassWindowManagerHint )
51
 
{
52
 
        play = new MyToolButton(this);
53
 
        pause = new MyToolButton(this);
54
 
        stop = new MyToolButton(this);
55
 
 
56
 
        rewind3 = new MyToolButton(this);
57
 
        rewind2 = new MyToolButton(this);
58
 
        rewind1 = new MyToolButton(this);
59
 
 
60
 
        time = new TimeSlider(this);
61
 
 
62
 
        forward1 = new MyToolButton(this);
63
 
        forward2 = new MyToolButton(this);
64
 
        forward3 = new MyToolButton(this);
65
 
 
66
 
#if NEW_CONTROLWIDGET
67
 
        time_label = new QLabel(this);
68
 
        time_label->setAlignment(Qt::AlignVCenter | Qt::AlignHCenter);
69
 
        time_label->setAutoFillBackground(TRUE);
70
 
 
71
 
        Helper::setBackgroundColor( time_label, QColor(0,0,0) );
72
 
        Helper::setForegroundColor( time_label, QColor(255,255,255) );
73
 
        time_label->setText( "00:00:00" );
74
 
        time_label->setFrameShape( QFrame::Panel );
75
 
        time_label->setFrameShadow( QFrame::Sunken );
76
 
#else
77
 
        lcd = new QLCDNumber(this);
78
 
        lcd->setNumDigits(10); // maximum time with 10 digits is 9999:59:59
79
 
        lcd->setFrameShape( QFrame::WinPanel );
80
 
        lcd->setFrameShadow( QFrame::Sunken );
81
 
        lcd->setAutoFillBackground(TRUE);
82
 
 
83
 
        Helper::setBackgroundColor( lcd, QColor(0,0,0) );
84
 
        Helper::setForegroundColor( lcd, QColor(200,200,200) );
85
 
        lcd->setSegmentStyle( QLCDNumber::Flat );
86
 
        lcd->setSizePolicy( QSizePolicy::Expanding, QSizePolicy::Fixed);
87
 
#endif
88
 
 
89
 
        fullscreen = new MyToolButton(this);
90
 
        fullscreen->setCheckable(true);
91
 
 
92
 
        mute = new MyToolButton(this);
93
 
        mute->setCheckable(true);
94
 
 
95
 
        volume = new MySlider(this);
96
 
        volume->setMinimum(0);
97
 
        volume->setMaximum(100);
98
 
        volume->setValue(50);
99
 
        volume->setTickPosition( QSlider::TicksBelow );
100
 
        volume->setTickInterval( 10 );
101
 
        volume->setSingleStep( 1 );
102
 
        volume->setPageStep( 10 );
103
 
        volume->setSizePolicy( QSizePolicy::Fixed, QSizePolicy::Fixed);
104
 
 
105
 
        // No focus on widgets
106
 
        rewind3->setFocusPolicy( Qt::NoFocus );
107
 
        rewind2->setFocusPolicy( Qt::NoFocus );
108
 
        rewind1->setFocusPolicy( Qt::NoFocus );
109
 
 
110
 
        forward1->setFocusPolicy( Qt::NoFocus );
111
 
        forward2->setFocusPolicy( Qt::NoFocus );
112
 
        forward3->setFocusPolicy( Qt::NoFocus );
113
 
 
114
 
        play->setFocusPolicy( Qt::NoFocus );
115
 
        pause->setFocusPolicy( Qt::NoFocus );
116
 
        stop->setFocusPolicy( Qt::NoFocus );
117
 
#if !NEW_CONTROLWIDGET
118
 
        lcd->setFocusPolicy( Qt::NoFocus );
119
 
#endif
120
 
        fullscreen->setFocusPolicy( Qt::NoFocus );
121
 
        mute->setFocusPolicy( Qt::NoFocus );
122
 
        volume->setFocusPolicy( Qt::NoFocus );
123
 
 
124
 
        // Layout
125
 
#if NEW_CONTROLWIDGET
126
 
        QHBoxLayout * l = new QHBoxLayout;
127
 
        l->setMargin(2);
128
 
        l->setSpacing(1);
129
 
 
130
 
        l->addWidget( play );
131
 
        l->addWidget( pause );
132
 
        l->addWidget( stop );
133
 
        l->addSpacing( 10 );
134
 
        l->addWidget( rewind3 );
135
 
        l->addWidget( rewind2 );
136
 
        l->addWidget( rewind1 );
137
 
        l->addWidget( time );
138
 
        l->addWidget( forward1 );
139
 
        l->addWidget( forward2 );
140
 
        l->addWidget( forward3 );
141
 
        l->addSpacing( 10 );
142
 
        l->addWidget( fullscreen );
143
 
        l->addWidget( mute );
144
 
        l->addWidget( volume );
145
 
        l->addSpacing( 10 );
146
 
        l->addWidget( time_label );
147
 
 
148
 
        setLayout(l);
149
 
#else
150
 
        QHBoxLayout * l1 = new QHBoxLayout;
151
 
        l1->setMargin(0);
152
 
        l1->setSpacing(0);
153
 
 
154
 
        l1->addWidget( rewind3 );
155
 
        l1->addWidget( rewind2 );
156
 
        l1->addWidget( rewind1 );
157
 
        l1->addWidget( time );
158
 
        l1->addWidget( forward1 );
159
 
        l1->addWidget( forward2 );
160
 
        l1->addWidget( forward3 );
161
 
 
162
 
        QSpacerItem * spacer1 = new QSpacerItem( 20, 10, QSizePolicy::Expanding,
163
 
                                             QSizePolicy::Minimum );
164
 
 
165
 
        QSpacerItem * spacer2 = new QSpacerItem( 20, 10, QSizePolicy::Expanding,
166
 
                                             QSizePolicy::Minimum );
167
 
 
168
 
        QHBoxLayout * l2 = new QHBoxLayout;
169
 
        l2->setMargin(0);
170
 
        l2->setSpacing(0);
171
 
 
172
 
        l2->addWidget( play );
173
 
        l2->addWidget( pause );
174
 
        l2->addWidget( stop );
175
 
        l2->addItem( spacer1 );
176
 
        l2->addWidget( lcd );
177
 
        l2->addItem( spacer2 );
178
 
        l2->addWidget( fullscreen );
179
 
        l2->addWidget( mute );
180
 
        l2->addWidget( volume );
181
 
 
182
 
        QVBoxLayout * l = new QVBoxLayout;
183
 
        l->setMargin(0);
184
 
        l->setSpacing(0);
185
 
 
186
 
        l->addLayout(l1);
187
 
        l->addLayout(l2);
188
 
 
189
 
        setLayout(l);
190
 
#endif
191
 
 
192
 
        retranslateStrings();
193
 
 
194
 
        setSizePolicy( QSizePolicy::Expanding, QSizePolicy::Fixed);
195
 
        adjustSize();
196
 
}
197
 
 
198
 
 
199
 
FloatingControl::~FloatingControl()
200
 
{
201
 
}
202
 
 
203
 
void FloatingControl::retranslateStrings() {
204
 
        int size = 22;
205
 
 
206
 
        pause->setIcon( Images::icon("pause", size) );
207
 
        stop->setIcon( Images::icon("stop", size) );
208
 
 
209
 
        if (qApp->isLeftToRight()) {
210
 
                play->setIcon( Images::icon("play", size) );
211
 
 
212
 
                forward1->setIcon( Images::icon("forward10s", size) );
213
 
                forward2->setIcon( Images::icon("forward1m", size) );
214
 
                forward3->setIcon( Images::icon("forward10m", size) );
215
 
 
216
 
                rewind1->setIcon( Images::icon("rewind10s", size) );
217
 
                rewind2->setIcon( Images::icon("rewind1m", size) );
218
 
                rewind3->setIcon( Images::icon("rewind10m", size) );
219
 
        } else {
220
 
                play->setIcon( Images::flippedIcon("play", size) );
221
 
 
222
 
                forward1->setIcon( Images::flippedIcon("forward10s", size) );
223
 
                forward2->setIcon( Images::flippedIcon("forward1m", size) );
224
 
                forward3->setIcon( Images::flippedIcon("forward10m", size) );
225
 
 
226
 
                rewind1->setIcon( Images::flippedIcon("rewind10s", size) );
227
 
                rewind2->setIcon( Images::flippedIcon("rewind1m", size) );
228
 
                rewind3->setIcon( Images::flippedIcon("rewind10m", size) );
229
 
        }
230
 
 
231
 
        fullscreen->setIcon( Images::icon("fullscreen", size) );
232
 
 
233
 
        QIcon icset( Images::icon("volume", size) );
234
 
        icset.addPixmap( Images::icon("mute", size), QIcon::Normal, QIcon::On  );
235
 
        mute->setIcon( icset );
236
 
}
237
 
 
238
 
// Language change stuff
239
 
void FloatingControl::changeEvent(QEvent *e) {
240
 
        if (e->type() == QEvent::LanguageChange) {
241
 
                retranslateStrings();
242
 
        } else {
243
 
                QWidget::changeEvent(e);
244
 
        }
245
 
}
246
 
 
247
 
#include "moc_floatingcontrol.cpp"