Diffstat (limited to 'noncore/multimedia/opieplayer2/playlistwidgetgui.cpp') (more/less context) (ignore whitespace changes)
-rw-r--r-- | noncore/multimedia/opieplayer2/playlistwidgetgui.cpp | 207 |
1 files changed, 207 insertions, 0 deletions
diff --git a/noncore/multimedia/opieplayer2/playlistwidgetgui.cpp b/noncore/multimedia/opieplayer2/playlistwidgetgui.cpp new file mode 100644 index 0000000..6ecd016 --- a/dev/null +++ b/noncore/multimedia/opieplayer2/playlistwidgetgui.cpp | |||
@@ -0,0 +1,207 @@ | |||
1 | /* | ||
2 | This file is part of the Opie Project | ||
3 | |||
4 | Copyright (c) 2002 Max Reiss <harlekin@handhelds.org> | ||
5 | Copyright (c) 2002 L. Potter <ljp@llornkcor.com> | ||
6 | Copyright (c) 2002 Holger Freyther <zecke@handhelds.org> | ||
7 | =. | ||
8 | .=l. | ||
9 | .>+-= | ||
10 | _;:, .> :=|. This program is free software; you can | ||
11 | .> <`_, > . <= redistribute it and/or modify it under | ||
12 | :`=1 )Y*s>-.-- : the terms of the GNU General Public | ||
13 | .="- .-=="i, .._ License as published by the Free Software | ||
14 | - . .-<_> .<> Foundation; either version 2 of the License, | ||
15 | ._= =} : or (at your option) any later version. | ||
16 | .%`+i> _;_. | ||
17 | .i_,=:_. -<s. This program is distributed in the hope that | ||
18 | + . -:. = it will be useful, but WITHOUT ANY WARRANTY; | ||
19 | : .. .:, . . . without even the implied warranty of | ||
20 | =_ + =;=|` MERCHANTABILITY or FITNESS FOR A | ||
21 | _.=:. : :=>`: PARTICULAR PURPOSE. See the GNU | ||
22 | ..}^=.= = ; Library General Public License for more | ||
23 | ++= -. .` .: details. | ||
24 | : = ...= . :.=- | ||
25 | -. .:....=;==+<; You should have received a copy of the GNU | ||
26 | -_. . . )=. = Library General Public License along with | ||
27 | -- :-=` this library; see the file COPYING.LIB. | ||
28 | If not, write to the Free Software Foundation, | ||
29 | Inc., 59 Temple Place - Suite 330, | ||
30 | Boston, MA 02111-1307, USA. | ||
31 | |||
32 | */ | ||
33 | |||
34 | #include <qpe/qpemenubar.h> | ||
35 | #include <qpe/qpetoolbar.h> | ||
36 | #include <qpe/fileselector.h> | ||
37 | #include <qpe/qpeapplication.h> | ||
38 | #include <qpe/storage.h> | ||
39 | #include <qpe/mimetype.h> | ||
40 | #include <qpe/config.h> | ||
41 | #include <qpe/global.h> | ||
42 | #include <qpe/resource.h> | ||
43 | |||
44 | #include <qpopupmenu.h> | ||
45 | #include <qaction.h> | ||
46 | #include <qcursor.h> | ||
47 | #include <qdir.h> | ||
48 | #include <qlayout.h> | ||
49 | |||
50 | #include "playlistselection.h" | ||
51 | #include "playlistwidget.h" | ||
52 | #include "mediaplayerstate.h" | ||
53 | #include "inputDialog.h" | ||
54 | |||
55 | //only needed for the random play | ||
56 | #include <stdlib.h> | ||
57 | |||
58 | #include "audiowidget.h" | ||
59 | #include "videowidget.h" | ||
60 | #include "mediaplayerstate.h" | ||
61 | |||
62 | extern MediaPlayerState *mediaPlayerState; | ||
63 | |||
64 | PlayListWidgetGui::PlayListWidgetGui( QWidget* parent, const char* name, WFlags fl ) | ||
65 | : QMainWindow( parent, name, fl ) { | ||
66 | |||
67 | d = new PlayListWidgetPrivate; | ||
68 | d->setDocumentUsed = FALSE; | ||
69 | d->current = NULL; | ||
70 | |||
71 | setBackgroundMode( PaletteButton ); | ||
72 | setToolBarsMovable( FALSE ); | ||
73 | |||
74 | // Create Toolbar | ||
75 | QPEToolBar *toolbar = new QPEToolBar( this ); | ||
76 | toolbar->setHorizontalStretchable( TRUE ); | ||
77 | |||
78 | // Create Menubar | ||
79 | QPEMenuBar *menu = new QPEMenuBar( toolbar ); | ||
80 | menu->setMargin( 0 ); | ||
81 | |||
82 | bar = new QPEToolBar( this ); | ||
83 | bar->setLabel( tr( "Play Operations" ) ); | ||
84 | |||
85 | tbDeletePlaylist = new QPushButton( Resource::loadIconSet( "trash" ), "", bar, "close" ); | ||
86 | tbDeletePlaylist->setFlat( TRUE ); | ||
87 | tbDeletePlaylist->setFixedSize( 20, 20 ); | ||
88 | |||
89 | tbDeletePlaylist->hide(); | ||
90 | |||
91 | pmPlayList = new QPopupMenu( this ); | ||
92 | menu->insertItem( tr( "File" ), pmPlayList ); | ||
93 | |||
94 | pmView = new QPopupMenu( this ); | ||
95 | menu->insertItem( tr( "View" ), pmView ); | ||
96 | pmView->isCheckable(); | ||
97 | |||
98 | skinsMenu = new QPopupMenu( this ); | ||
99 | pmView->insertItem( tr( "Skins" ), skinsMenu ); | ||
100 | skinsMenu->isCheckable(); | ||
101 | |||
102 | vbox5 = new QVBox( this ); | ||
103 | QVBox *vbox4 = new QVBox( vbox5 ); | ||
104 | QHBox *hbox6 = new QHBox( vbox4 ); | ||
105 | |||
106 | tabWidget = new QTabWidget( hbox6, "tabWidget" ); | ||
107 | |||
108 | QWidget *pTab; | ||
109 | pTab = new QWidget( tabWidget, "pTab" ); | ||
110 | tabWidget->insertTab( pTab,"Playlist"); | ||
111 | |||
112 | QGridLayout *Playout = new QGridLayout( pTab ); | ||
113 | Playout->setSpacing( 2); | ||
114 | Playout->setMargin( 2); | ||
115 | |||
116 | // Add the playlist area | ||
117 | QVBox *vbox3 = new QVBox( pTab ); | ||
118 | d->playListFrame = vbox3; | ||
119 | |||
120 | QHBox *hbox2 = new QHBox( vbox3 ); | ||
121 | d->selectedFiles = new PlayListSelection( hbox2 ); | ||
122 | |||
123 | vbox1 = new QVBox( hbox2 ); | ||
124 | QPEApplication::setStylusOperation( d->selectedFiles->viewport(), QPEApplication::RightOnHold ); | ||
125 | QVBox *stretch1 = new QVBox( vbox1 ); // add stretch | ||
126 | |||
127 | Playout->addMultiCellWidget( vbox3, 0, 0, 0, 1 ); | ||
128 | |||
129 | QWidget *aTab; | ||
130 | aTab = new QWidget( tabWidget, "aTab" ); | ||
131 | |||
132 | QGridLayout *Alayout = new QGridLayout( aTab ); | ||
133 | Alayout->setSpacing( 2 ); | ||
134 | Alayout->setMargin( 2 ); | ||
135 | audioView = new QListView( aTab, "Audioview" ); | ||
136 | audioView->addColumn( tr( "Title" ), 140 ); | ||
137 | audioView->addColumn( tr( "Size" ), -1 ); | ||
138 | audioView->addColumn( tr( "Media" ), -1 ); | ||
139 | audioView->setColumnAlignment( 1, Qt::AlignRight ); | ||
140 | audioView->setColumnAlignment( 2, Qt::AlignRight ); | ||
141 | audioView->setAllColumnsShowFocus( TRUE ); | ||
142 | audioView->setSorting( 0, TRUE ); | ||
143 | audioView->setMultiSelection( TRUE ); | ||
144 | audioView->setSelectionMode( QListView::Extended ); | ||
145 | Alayout->addMultiCellWidget( audioView, 0, 0, 0, 1 ); | ||
146 | tabWidget->insertTab( aTab, tr( "Audio" ) ); | ||
147 | |||
148 | QPEApplication::setStylusOperation( audioView->viewport(), QPEApplication::RightOnHold ); | ||
149 | |||
150 | QWidget *vTab; | ||
151 | vTab = new QWidget( tabWidget, "vTab" ); | ||
152 | |||
153 | QGridLayout *Vlayout = new QGridLayout( vTab ); | ||
154 | Vlayout->setSpacing( 2 ); | ||
155 | Vlayout->setMargin( 2 ); | ||
156 | videoView = new QListView( vTab, "Videoview" ); | ||
157 | videoView->addColumn( tr( "Title" ), 140); | ||
158 | videoView->addColumn( tr( "Size" ), -1 ); | ||
159 | videoView->addColumn(tr( "Media" ), -1 ); | ||
160 | videoView->setColumnAlignment( 1, Qt::AlignRight ); | ||
161 | videoView->setColumnAlignment( 2, Qt::AlignRight ); | ||
162 | videoView->setAllColumnsShowFocus( TRUE ); | ||
163 | videoView->setSorting( 0, TRUE ); | ||
164 | videoView->setMultiSelection( TRUE ); | ||
165 | videoView->setSelectionMode( QListView::Extended ); | ||
166 | Vlayout->addMultiCellWidget( videoView, 0, 0, 0, 1 ); | ||
167 | |||
168 | QPEApplication::setStylusOperation( videoView->viewport(), QPEApplication::RightOnHold ); | ||
169 | |||
170 | tabWidget->insertTab( vTab, tr( "Video" ) ); | ||
171 | |||
172 | //playlists list | ||
173 | QWidget *LTab; | ||
174 | LTab = new QWidget( tabWidget, "LTab" ); | ||
175 | QGridLayout *Llayout = new QGridLayout( LTab ); | ||
176 | Llayout->setSpacing( 2 ); | ||
177 | Llayout->setMargin( 2 ); | ||
178 | |||
179 | playLists = new FileSelector( "playlist/plain", LTab, "fileselector" , FALSE, FALSE ); //buggy | ||
180 | Llayout->addMultiCellWidget( playLists, 0, 0, 0, 1 ); | ||
181 | |||
182 | tabWidget->insertTab( LTab, tr( "Lists" ) ); | ||
183 | |||
184 | setCentralWidget( vbox5 ); | ||
185 | } | ||
186 | |||
187 | |||
188 | |||
189 | PlayListWidgetGui::~PlayListWidgetGui() { | ||
190 | } | ||
191 | |||
192 | void PlayListWidgetGui::setView( char view ) { | ||
193 | if ( view == 'l' ) | ||
194 | showMaximized(); | ||
195 | else | ||
196 | hide(); | ||
197 | } | ||
198 | |||
199 | |||
200 | void PlayListWidgetGui::setActiveWindow() { | ||
201 | // qDebug("SETTING active window"); | ||
202 | // When we get raised we need to ensure that it switches views | ||
203 | char origView = mediaPlayerState->view(); | ||
204 | mediaPlayerState->setView( 'l' ); // invalidate | ||
205 | mediaPlayerState->setView( origView ); // now switch back | ||
206 | } | ||
207 | |||