~ubuntu-branches/ubuntu/gutsy/smplayer/gutsy

« back to all changes in this revision

Viewing changes to src/old/oldgui.cpp

  • Committer: Bazaar Package Importer
  • Author(s): Breuil Cyril
  • Date: 2007-05-06 17:09:35 UTC
  • Revision ID: james.westby@ubuntu.com-20070506170935-d83qqn48tv1muk7j
Tags: upstream-0.4.12
ImportĀ upstreamĀ versionĀ 0.4.12

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
/*  smplayer, GUI front-end for mplayer.
 
2
    Copyright (C) 2007 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 "guibase.h"
 
20
#include "timeslider.h"
 
21
 
 
22
#include <qpushbutton.h>
 
23
#include <qframe.h>
 
24
#include <qslider.h>
 
25
#include <qlayout.h>
 
26
#include <qtooltip.h>
 
27
#include <qwhatsthis.h>
 
28
#include <qaction.h>
 
29
#include <qmenubar.h>
 
30
#include <qpopupmenu.h>
 
31
#include <qtoolbar.h>
 
32
#include <qpixmap.h>
 
33
#include <qtooltip.h>
 
34
 
 
35
#include "keys.h"
 
36
#include "images.h"
 
37
#include "global.h"
 
38
 
 
39
 
 
40
GuiBase::GuiBase( QWidget* parent, const char* name, WFlags fl )
 
41
    : QMainWindow( parent, name, fl )
 
42
{
 
43
        setCaption( "SMPlayer" );
 
44
 
 
45
        centralwidget = new QWidget(this, "central widget");
 
46
        setCentralWidget( centralwidget );
 
47
 
 
48
        centralwidgetLayout = new QVBoxLayout( centralwidget, 0, 0, "centralwidgetLayout");
 
49
 
 
50
        //panel = new QFrame( centralwidget, "panel" );
 
51
        panel = new QWidget( centralwidget, "panel" );
 
52
    panel->setSizePolicy( QSizePolicy::Expanding, QSizePolicy::Expanding );
 
53
    //panel->setFocusPolicy( NOFOCUS );
 
54
        /*
 
55
    panel->setFrameShape( QFrame::NoFrame );
 
56
    panel->setFrameShadow( QFrame::Plain );
 
57
    panel->setLineWidth( 0 );
 
58
    panel->setMargin( 0 );
 
59
        */
 
60
        panel->setMinimumSize( QSize(0,0) );
 
61
 
 
62
    centralwidgetLayout->addWidget( panel );
 
63
 
 
64
        controlwidget = new QWidget( centralwidget, "control widget");
 
65
        controlwidgetLayout = new QVBoxLayout( controlwidget, 2, 0, "controlwidgetLayout");
 
66
 
 
67
        // Up part
 
68
        fastrewindbutton = new QPushButton( controlwidget, "fastrewindbutton" );
 
69
        fastrewindbutton->setFocusPolicy( NOFOCUS );
 
70
 
 
71
        rewindbutton = new QPushButton( controlwidget, "rewindbutton" );
 
72
        rewindbutton->setFocusPolicy( NOFOCUS );
 
73
 
 
74
        smallrewindbutton = new QPushButton( controlwidget, "smallrewindbutton" );
 
75
        smallrewindbutton->setFocusPolicy( NOFOCUS );
 
76
 
 
77
        timeslider = new TimeSlider( controlwidget, "timeslider" );
 
78
    timeslider->setFocusPolicy( NOFOCUS );
 
79
    timeslider->setOrientation( Qt::Horizontal );
 
80
 
 
81
        smallforwardbutton = new QPushButton( controlwidget, "smallforwardbutton" );
 
82
        smallforwardbutton->setFocusPolicy( NOFOCUS );
 
83
 
 
84
        forwardbutton = new QPushButton( controlwidget, "forwardbutton" );
 
85
        forwardbutton->setFocusPolicy( NOFOCUS );
 
86
 
 
87
        fastforwardbutton = new QPushButton( controlwidget, "fastforwardbutton" );
 
88
        fastforwardbutton->setFocusPolicy( NOFOCUS );
 
89
 
 
90
        layout1 = new QHBoxLayout( 0, 0, 0, "layout1");
 
91
        layout1->addWidget( fastrewindbutton );
 
92
        layout1->addWidget( rewindbutton );
 
93
        layout1->addWidget( smallrewindbutton );
 
94
        layout1->addWidget( timeslider );
 
95
        layout1->addWidget( smallforwardbutton );
 
96
        layout1->addWidget( forwardbutton );
 
97
        layout1->addWidget( fastforwardbutton );
 
98
 
 
99
        controlwidgetLayout->addLayout( layout1 );
 
100
 
 
101
        // Down part
 
102
        playbutton = new QPushButton( controlwidget, "playbutton" );
 
103
        playbutton->setFocusPolicy( NOFOCUS );
 
104
 
 
105
        pausebutton = new QPushButton( controlwidget, "pausebutton" );
 
106
        pausebutton->setFocusPolicy( NOFOCUS );
 
107
 
 
108
        stopbutton = new QPushButton( controlwidget, "stopbutton" );
 
109
        stopbutton->setFocusPolicy( NOFOCUS );
 
110
 
 
111
        spacer1 = new QSpacerItem( 270, 20, QSizePolicy::Expanding, QSizePolicy::Minimum );
 
112
 
 
113
        playlistbutton = new QPushButton( controlwidget, "playlistbutton" );
 
114
        playlistbutton->setToggleButton( TRUE );
 
115
 
 
116
        playlistbutton->setFocusPolicy( NOFOCUS );
 
117
 
 
118
        spacer2 = new QSpacerItem( 30, 20, QSizePolicy::Preferred, QSizePolicy::Minimum );
 
119
 
 
120
        prevbutton = new QPushButton( controlwidget, "prevbutton" );
 
121
        prevbutton->setFocusPolicy( NOFOCUS );
 
122
        prevbutton->setAccel( key_list->find("PLAYLIST_PREV") );
 
123
 
 
124
        nextbutton = new QPushButton( controlwidget, "nextbutton" );
 
125
        nextbutton->setFocusPolicy( NOFOCUS );
 
126
        nextbutton->setAccel( key_list->find("PLAYLIST_NEXT") );
 
127
 
 
128
        spacer3 = new QSpacerItem( 50, 20, QSizePolicy::Preferred, QSizePolicy::Minimum );
 
129
 
 
130
        fullscreenbutton = new QPushButton( controlwidget, "fullscreenbutton" );
 
131
 
 
132
        fullscreenbutton->setToggleButton( TRUE );
 
133
 
 
134
        fullscreenbutton->setFocusPolicy( NOFOCUS );
 
135
 
 
136
        mutebutton = new QPushButton( controlwidget, "mutebutton" );
 
137
 
 
138
        mutebutton->setToggleButton( TRUE );
 
139
 
 
140
        mutebutton->setFocusPolicy( NOFOCUS );
 
141
 
 
142
        volumeslider = new MySlider( controlwidget, "volumeslider" );
 
143
 
 
144
        volumeslider->setOrientation( Qt::Horizontal );
 
145
    volumeslider->setSizePolicy( QSizePolicy::Fixed, QSizePolicy::Fixed );
 
146
        volumeslider->setFocusPolicy( NOFOCUS );
 
147
        volumeslider->setTickmarks( QSlider::Below );
 
148
        volumeslider->setTickInterval( 10 );
 
149
        volumeslider->setLineStep( 1 );
 
150
        volumeslider->setPageStep( 10 );
 
151
 
 
152
 
 
153
        layout2 = new QHBoxLayout( 0, 0, 0, "layout2");
 
154
        layout2->addWidget( playbutton );
 
155
        layout2->addWidget( pausebutton );
 
156
        layout2->addWidget( stopbutton );
 
157
        layout2->addItem( spacer1 );
 
158
        layout2->addWidget( playlistbutton );
 
159
        layout2->addItem( spacer2 );
 
160
        layout2->addWidget( prevbutton );
 
161
        layout2->addWidget( nextbutton );
 
162
        layout2->addItem( spacer3 );
 
163
        layout2->addWidget( fullscreenbutton );
 
164
        layout2->addWidget( mutebutton );
 
165
        layout2->addWidget( volumeslider );
 
166
 
 
167
        controlwidgetLayout->addLayout( layout2 );
 
168
 
 
169
        centralwidgetLayout->addWidget( controlwidget );
 
170
 
 
171
        controlwidget->setSizePolicy( QSizePolicy::Preferred , QSizePolicy::Fixed ); 
 
172
 
 
173
        #if QT_VERSION < 0x040000
 
174
        layout()->setSpacing(-1); // Removes two extra lines
 
175
        #endif
 
176
 
 
177
        languageChange();
 
178
 
 
179
        resize(580, 440);
 
180
 
 
181
        panel->setFocus();
 
182
}
 
183
 
 
184
 
 
185
GuiBase::~GuiBase()
 
186
{
 
187
    // no need to delete child widgets, Qt does it all for us
 
188
}
 
189
 
 
190
void GuiBase::languageChange() {
 
191
        // Main window icon
 
192
        setIcon( Images::icon("logo", 64) );
 
193
 
 
194
        // Widgets
 
195
        QToolTip::add( fastrewindbutton, tr("-10 minutes") );
 
196
        fastrewindbutton->setPixmap( Images::icon("rewind10m_small") );
 
197
 
 
198
        QToolTip::add( rewindbutton, tr("-1 minute") );
 
199
        rewindbutton->setPixmap( Images::icon("rewind1m_small") );
 
200
 
 
201
        QToolTip::add( smallrewindbutton, tr("-10 seconds") );
 
202
        smallrewindbutton->setPixmap( Images::icon("rewind10s_small") );
 
203
 
 
204
        QToolTip::add( smallforwardbutton, tr("+10 seconds") );
 
205
        smallforwardbutton->setPixmap( Images::icon("forward10s_small") );
 
206
 
 
207
        QToolTip::add( forwardbutton, tr("+1 minute") );
 
208
        forwardbutton->setPixmap( Images::icon("forward1m_small") );
 
209
 
 
210
        QToolTip::add( fastforwardbutton, tr("+10 minutes") );
 
211
        fastforwardbutton->setPixmap( Images::icon("forward10m_small") );
 
212
 
 
213
        QToolTip::add( playbutton, tr("Play") );
 
214
        playbutton->setPixmap( Images::icon("play_small") );
 
215
 
 
216
        QToolTip::add( pausebutton, tr("Pause") );
 
217
        pausebutton->setPixmap( Images::icon("pause_small") );
 
218
 
 
219
        QToolTip::add( stopbutton, tr("Stop") );
 
220
        stopbutton->setPixmap( Images::icon("stop_small") );
 
221
 
 
222
        QToolTip::add( playlistbutton, tr("Playlist") );
 
223
        playlistbutton->setPixmap( Images::icon("playlist_small") );
 
224
 
 
225
        QToolTip::add( prevbutton, tr("Previous") );
 
226
        prevbutton->setPixmap( Images::icon("previous_small") );
 
227
 
 
228
        QToolTip::add( nextbutton, tr("Next") );
 
229
        nextbutton->setPixmap( Images::icon("next_small") );
 
230
 
 
231
        QToolTip::add( fullscreenbutton, tr("Fullscreen") );
 
232
        fullscreenbutton->setPixmap( Images::icon("fullscreen_small") );
 
233
 
 
234
        QToolTip::add( mutebutton, tr("Mute") );
 
235
        mutebutton->setPixmap( Images::icon("volume_small") );
 
236
 
 
237
        QToolTip::add( volumeslider, tr("Volume") );
 
238
}
 
239