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
|
/****************************************************************************
Copyright (C) 2002 Charles Samuels
this file is on the BSD license, sans advertisement clause
*****************************************************************************/
#include <noatun/video.h>
#include <noatun/app.h>
#include <noatun/player.h>
#include <noatun/engine.h>
#include <tqpopupmenu.h>
#include <tdeaction.h>
#include <tdelocale.h>
#include "globalvideo.h"
// sorry :)
TQPtrList<VideoFrame> VideoFrame::frames;
VideoFrame *VideoFrame::whose=0;
struct VideoFrame::Private
{
};
VideoFrame::VideoFrame(KXMLGUIClient *clientParent, TQWidget *parent, const char*name, WFlags f)
: KVideoWidget(clientParent, parent, name, f)
{
d = new Private;
connect(napp->player(), TQT_SIGNAL(newSong()), TQT_SLOT(changed()));
connect(napp->player(), TQT_SIGNAL(stopped()), TQT_SLOT(stopped()));
frames.append(this);
}
VideoFrame::VideoFrame(TQWidget *parent, const char *name, WFlags f)
: KVideoWidget(parent, name, f)
{
d = new Private;
connect(napp->player(), TQT_SIGNAL(newSong()), TQT_SLOT(changed()));
connect(napp->player(), TQT_SIGNAL(stopped()), TQT_SLOT(stopped()));
frames.append(this);
}
VideoFrame::~VideoFrame()
{
if (whose == this)
{
embed(Arts::VideoPlayObject::null());
whose=0;
}
frames.removeRef(this);
VideoFrame *l = frames.last();
if (l) l->give();
else whose=0;
delete d;
}
VideoFrame *VideoFrame::playing()
{
return whose;
}
TQPopupMenu *VideoFrame::popupMenu(TQWidget *parent)
{
TQPopupMenu *view = new TQPopupMenu(parent);
action( "half_size" )->plug( view );
action( "normal_size" )->plug( view );
action( "double_size" )->plug( view );
view->insertSeparator();
action( "fullscreen_mode" )->plug( view );
return view;
}
void VideoFrame::give()
{
VideoFrame *old=whose;
whose = this;
if (whose != old && old != 0)
{
old->embed(Arts::VideoPlayObject::null());
emit old->lost();
}
Arts::PlayObject po = napp->player()->engine()->playObject();
if (po.isNull()) return;
Arts::VideoPlayObject vpo = Arts::DynamicCast(po);
if (!vpo.isNull())
{
embed(vpo);
emit acquired();
}
}
void VideoFrame::changed()
{
if (whose==this)
give();
}
void VideoFrame::stopped()
{
if (whose==this)
{
embed(Arts::VideoPlayObject::null());
emit lost();
}
}
#include <tqlayout.h>
GlobalVideo::GlobalVideo()
: TQWidget( 0, 0, WType_TopLevel | WStyle_Customize | WStyle_DialogBorder | WStyle_Title )
{
setCaption(i18n("Video - Noatun"));
(new TQVBoxLayout(this))->setAutoAdd(true);
video = new VideoFrame(this);
menu = video->popupMenu(this);
// FIXME: How to obtain minimum size for top-level widgets?
// video->setMinimumSize(minimumSizeHint());
// video->setMinimumSize(101,35);
video->setMinimumSize(128,96);
connect(video, TQT_SIGNAL(acquired()), TQT_SLOT(appear()));
connect(video, TQT_SIGNAL(lost()), TQT_SLOT(hide()));
connect(video, TQT_SIGNAL(adaptSize(int,int)), this, TQT_SLOT(slotAdaptSize(int,int)));
video->setNormalSize();
video->give();
}
void GlobalVideo::slotAdaptSize(int w, int h)
{
resize(w, h);
}
void GlobalVideo::appear()
{
TQWidget::show();
}
void GlobalVideo::hide()
{
TQWidget::hide();
}
void GlobalVideo::mouseReleaseEvent(TQMouseEvent *e)
{
if (e->button() == Qt::RightButton)
{
menu->exec(mapToGlobal(e->pos()));
}
}
#include "globalvideo.moc"
#include "video.moc"
|