5 #include "ui_glspectrumgui.h" 10 m_contextMenuType(ContextMenuNone),
11 m_streamIndicator(
"S")
13 setMinimumSize(250, 150);
14 setSizePolicy(QSizePolicy::MinimumExpanding, QSizePolicy::MinimumExpanding);
15 setBackgroundRole(QPalette::Window);
17 setAutoFillBackground(
false);
18 setAttribute(Qt::WA_OpaquePaintEvent,
true);
28 QDataStream stream(&state, QIODevice::WriteOnly);
31 for(
int i = 0;
i < children().count(); ++
i) {
32 QWidget* r = qobject_cast<QWidget*>(children()[
i]);
41 for(
int i = 0;
i < children().count(); ++
i) {
42 QWidget* r = qobject_cast<QWidget*>(children()[
i]);
44 stream << r->objectName();
47 else stream << (int)1;
58 QByteArray sd = state;
59 QDataStream stream(&sd, QIODevice::ReadOnly);
63 if((stream.status() != QDataStream::Ok) || (marker !=
VersionMarker) || (v != version))
69 if(stream.status() != QDataStream::Ok)
71 for(
int i = 0;
i < count; ++
i) {
78 if(stream.status() != QDataStream::Ok)
81 for(
int j = 0; j < children().count(); ++j) {
82 QWidget* r = qobject_cast<QWidget*>(children()[j]);
84 if(r->objectName() == name) {
100 float l = 0.2126*c.redF() + 0.7152*c.greenF() + 0.0722*c.blueF();
116 QFontMetrics fm(font());
117 int pos = fm.height() + 4;
119 for(
int i = 0;
i < children().count(); ++
i)
121 QWidget* r = qobject_cast<QWidget*>(children()[
i]);
124 pos += fm.height() + 2;
126 if (!r->isHidden() && (r->windowTitle() !=
"Basic channel settings") && (r->windowTitle() !=
"Select device stream"))
131 if(r->hasHeightForWidth()) {
132 h = r->heightForWidth(width() - 4);
134 h = r->sizeHint().height();
137 r->resize(width() - 4, h);
138 pos += r->height() + 5;
143 setMinimumHeight(pos);
144 setMaximumHeight(pos);
152 QColor frame = palette().highlight().color();
155 QFontMetrics fm(font());
157 p.setRenderHint(QPainter::Antialiasing,
true);
161 p.setBrush(palette().base());
162 p.drawRect(0, 0, 5, 5);
163 p.drawRect(width() - 5, 0, 5, 5);
164 p.drawRect(0, height() - 5, 5, 5);
165 p.drawRect(width() - 5, height() - 5, 5, 5);
169 p.setBrush(palette().window());
171 r.adjust(0.5, 0.5, -0.5, -0.5);
172 p.drawRoundedRect(r, 3.0, 3.0, Qt::AbsoluteSize);
178 path.moveTo(1.5, fm.height() + 2.5);
179 path.lineTo(width() - 1.5, fm.height() + 2.5);
180 path.lineTo(width() - 1.5, 3.5);
181 path.arcTo(QRectF(width() - 3.5, 0, 2.5, 2.5), 270, -90);
182 path.lineTo(3.5, 1.5);
183 path.arcTo(QRectF(1.5, 2.5, 2.5, 2.5), 90, 90);
188 p.drawLine(QPointF(0.5, 2 + fm.height() + 1.5), QPointF(width() - 1.5, 2 + fm.height() + 1.5));
191 p.setPen(QPen(palette().windowText().color(), 1.0));
192 p.setBrush(palette().light());
193 p.drawRoundedRect(QRectF(3.5, 3.5, fm.ascent(), fm.ascent()), 2.0, 2.0, Qt::AbsoluteSize);
194 p.setPen(QPen(Qt::white, 1.0));
195 p.drawText(QRectF(3.5, 2.5, fm.ascent(), fm.ascent()), Qt::AlignCenter,
"c");
198 p.setPen(QPen(palette().windowText().color(), 1.0));
199 p.setBrush(palette().light());
200 p.drawRoundedRect(QRectF(5.5 + fm.ascent(), 2.5, fm.ascent() + 2.0, fm.ascent() + 2.0), 2.0, 2.0, Qt::AbsoluteSize);
201 p.setPen(QPen(Qt::white, 1.0));
202 p.drawText(QRectF(5.5 + fm.ascent(), 2.5, fm.ascent() + 2.0, fm.ascent() + 2.0), Qt::AlignCenter,
m_streamIndicator);
205 p.setRenderHint(QPainter::Antialiasing,
true);
206 p.setPen(QPen(palette().windowText().color(), 1.0));
207 p.setBrush(palette().light());
208 r = QRectF(width() - 3.5 - fm.ascent(), 3.5, fm.ascent(), fm.ascent());
209 p.drawRoundedRect(r, 2.0, 2.0, Qt::AbsoluteSize);
210 p.setPen(QPen(palette().windowText().color(), 1.5));
211 p.drawLine(r.topLeft() + QPointF(1, 1), r.bottomRight() + QPointF(-1, -1));
212 p.drawLine(r.bottomLeft() + QPointF(1, -1), r.topRight() + QPointF(-1, 1));
217 p.drawText(QRect(2 + 2*fm.height() + 2, 2, width() - 6 - 3*fm.height(), fm.height()),
218 fm.elidedText(windowTitle(), Qt::ElideMiddle, width() - 6 - 3*fm.height(), 0));
221 int pos = fm.height() + 4;
223 const QObjectList& c = children();
224 QObjectList::ConstIterator w = c.begin();
225 QObjectList::ConstIterator n = c.begin();
227 for(n = c.begin(); n != c.end(); ++n) {
228 if(qobject_cast<QWidget*>(*n) != NULL)
231 for(w = n; w != c.end(); w = n) {
234 for(; n != c.end(); ++n) {
235 if(qobject_cast<QWidget*>(*n) != NULL)
238 pos +=
paintRollup(qobject_cast<QWidget*>(*w), pos, &p, n == c.end(), frame);
244 if ((rollup->windowTitle() ==
"Basic channel settings") || (rollup->windowTitle() ==
"Select device stream")) {
248 QFontMetrics fm(font());
252 if(!rollup->isHidden()) {
253 p->setPen(palette().dark().color());
254 p->drawLine(QPointF(1.5, pos + fm.height() + 1.5), QPointF(width() - 1.5, pos + fm.height() + 1.5));
255 p->setPen(palette().light().color());
256 p->drawLine(QPointF(1.5, pos + fm.height() + 2.5), QPointF(width() - 1.5, pos + fm.height() + 2.5));
261 p->drawLine(QPointF(1.5, pos + fm.height() + 1.5), QPointF(width() - 1.5, pos + fm.height() + 1.5));
267 p->setPen(palette().windowText().color());
268 p->drawText(QRect(2 + fm.height(), pos, width() - 4 - fm.height(), fm.height()),
269 fm.elidedText(rollup->windowTitle(), Qt::ElideMiddle, width() - 4 - fm.height(), 0));
270 height += fm.height();
273 p->setPen(palette().windowText().color());
274 p->setBrush(palette().windowText());
275 if(!rollup->isHidden()) {
277 a.append(QPointF(3.5, pos + 2));
278 a.append(QPointF(3.5 + fm.ascent(), pos + 2));
279 a.append(QPointF(3.5 + fm.ascent() / 2.0, pos + fm.height() - 2));
283 a.append(QPointF(3.5, pos + 2));
284 a.append(QPointF(3.5, pos + fm.height() - 2));
285 a.append(QPointF(3.5 + fm.ascent(), pos + fm.height() / 2));
290 if(!rollup->isHidden() && (!last)) {
293 p->drawLine(QPointF(1.5, pos + fm.height() + rollup->height() + 6.5),
294 QPointF(width() - 1.5, pos + fm.height() + rollup->height() + 6.5));
295 height += rollup->height() + 4;
304 QWidget::resizeEvent(size);
309 QFontMetrics fm(font());
312 if (QRectF(3.5, 3.5, fm.ascent(), fm.ascent()).contains(event->pos()))
315 emit customContextMenuRequested(event->globalPos());
320 if (QRectF(5.5 + fm.ascent(), 2.5, fm.ascent() + 2.0, fm.ascent() + 2.0).contains(event->pos()))
323 emit customContextMenuRequested(event->globalPos());
328 if(QRectF(width() - 3.5 - fm.ascent(), 3.5, fm.ascent(), fm.ascent()).contains(event->pos())) {
334 int pos = fm.height() + 4;
335 for(
int i = 0;
i < children().count(); ++
i) {
336 QWidget* r = qobject_cast<QWidget*>(children()[
i]);
338 if((event->y() >= pos) && (event->y() < (pos + fm.height() + 3))) {
350 pos += fm.height() + 2;
352 pos += r->height() + 5;
360 if(event->type() == QEvent::ChildAdded) {
361 ((QChildEvent*)event)->child()->installEventFilter(
this);
363 }
else if(event->type() == QEvent::ChildRemoved) {
364 ((QChildEvent*)event)->child()->removeEventFilter(
this);
367 return QWidget::event(event);
372 if(event->type() == QEvent::Show) {
373 if(children().contains(
object)) {
375 emit
widgetRolled(qobject_cast<QWidget*>(
object),
true);
377 }
else if(event->type() == QEvent::Hide) {
378 if(children().contains(
object)) {
380 emit
widgetRolled(qobject_cast<QWidget*>(
object),
false);
382 }
else if(event->type() == QEvent::WindowTitleChange) {
383 if(children().contains(
object))
386 return QWidget::eventFilter(
object, event);