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
|
// (C) 2005 Max Howell (max.howell@methylblue.com)
// See COPYING file for licensing information
#include "config.h"
#include "listView.cpp"
#include <tdeapplication.h>
#include <tdeconfig.h>
#include <kguiitem.h>
#include <tdelistview.h>
#include <kpushbutton.h>
#include <kstdguiitem.h>
#include "playDialog.h"
#include "mxcl.library.h"
#include <ntqfile.h>
#include <ntqlabel.h>
#include <ntqlayout.h>
#include <ntqsignalmapper.h>
TQString i18n( const char *text );
namespace Codeine {
PlayDialog::PlayDialog( TQWidget *parent, bool be_welcome_dialog )
: TQDialog( parent )
{
setCaption( kapp->makeStdCaption( i18n("Play Media") ) );
TQSignalMapper *mapper = new TQSignalMapper( this );
TQWidget *o, *closeButton = new KPushButton( KStdGuiItem::close(), this );
TQBoxLayout *hbox, *vbox = new TQVBoxLayout( this, 15, 20 );
vbox->addWidget( new TQLabel( i18n( "What media would you like to play?" ), this ) );
TQGridLayout *grid = new TQGridLayout( vbox, 1, 3, 20 );
//TODO use the kguiItems from the actions
mapper->setMapping( o = new KPushButton( KGuiItem( i18n("Play File..."), "fileopen" ), this ), FILE );
connect( o, SIGNAL(clicked()), mapper, SLOT(map()) );
grid->TQLayout::add( o );
mapper->setMapping( o = new KPushButton( KGuiItem( i18n("Play VCD"), "cdaudio_unmount" ), this ), VCD );
connect( o, SIGNAL(clicked()), mapper, SLOT(map()) );
grid->TQLayout::add( o );
mapper->setMapping( o = new KPushButton( KGuiItem( i18n("Play DVD"), "dvd_unmount" ), this ), DVD );
connect( o, SIGNAL(clicked()), mapper, SLOT(map()) );
grid->TQLayout::add( o );
mapper->setMapping( closeButton, TQDialog::Rejected );
connect( closeButton, SIGNAL(clicked()), mapper, SLOT(map()) );
createRecentFileWidget( vbox );
hbox = new TQHBoxLayout( vbox );
hbox->addItem( new TQSpacerItem( 10, 10, TQSizePolicy::Expanding ) );
if( be_welcome_dialog ) {
TQWidget *w = new KPushButton( KStdGuiItem::quit(), this );
hbox->addWidget( w );
connect( w, SIGNAL(clicked()), kapp, SLOT(quit()) );
}
hbox->addWidget( closeButton );
connect( mapper, SIGNAL(mapped( int )), SLOT(done( int )) );
}
void
PlayDialog::createRecentFileWidget( TQBoxLayout *layout )
{
TDEListView *lv;
lv = new Codeine::ListView( this );
lv->setColumnText( 1, i18n("Recently Played Media") );
const TQStringList list1 = Codeine::config( "General" )->readPathListEntry( "Recent Urls" );
KURL::List urls;
foreach( list1 )
urls += *it;
for( KURL::List::Iterator it = urls.begin(), end = urls.end(); it != end; ) {
if( urls.contains( *it ) > 1 )
//remove duplicates
it = urls.remove( it );
else if( (*it).protocol() == "file" && !TQFile::exists( (*it).path() ) )
//remove stale entries
it = urls.remove( it );
else
++it;
}
for( KURL::List::ConstIterator it = urls.begin(), end = urls.end(); it != end; ++it ) {
const TQString fileName = (*it).fileName();
new TDEListViewItem( lv, 0, (*it).url(), fileName.isEmpty() ? (*it).prettyURL() : fileName );
}
if( lv->childCount() ) {
layout->addWidget( lv, 1 );
connect( lv, SIGNAL(executed( TQListViewItem* )), SLOT(done( TQListViewItem* )) );
}
else
delete lv;
}
void
PlayDialog::done( TQListViewItem *item )
{
m_url = item->text( 0 );
TQDialog::done( RECENT_FILE );
}
}
|