Mercurial > hg > easaier-soundaccess
comparison widgets/RelatedMediaWidget.cpp @ 143:97fd6148fb8e
support related media display and loading
author | lbajardsilogic |
---|---|
date | Tue, 13 Nov 2007 10:07:49 +0000 |
parents | |
children | 98df77b4f041 |
comparison
equal
deleted
inserted
replaced
142:c1ea7af931e7 | 143:97fd6148fb8e |
---|---|
1 /* -*- c-basic-offset: 4 indent-tabs-mode: nil -*- vi:set ts=8 sts=4 sw=4: */ | |
2 | |
3 /* Sound Access | |
4 EASAIER client application. | |
5 Silogic 2007. Laure Bajard. | |
6 | |
7 This program is free software; you can redistribute it and/or | |
8 modify it under the terms of the GNU General Public License as | |
9 published by the Free Software Foundation; either version 2 of the | |
10 License, or (at your option) any later version. See the file | |
11 COPYING included with this distribution for more information . | |
12 */ | |
13 | |
14 #include "RelatedMediaWidget.h" | |
15 | |
16 #include <QScrollArea> | |
17 #include <QLayoutItem> | |
18 #include <QLinearGradient> | |
19 | |
20 #include <iostream> | |
21 | |
22 #include "sv/main/MainWindow.h" | |
23 | |
24 RelatedMediaWidget::RelatedMediaWidget() : QWidget() , | |
25 m_nbRelMedia(0), | |
26 m_painter(0) | |
27 { | |
28 m_relMediaLayout = new QGridLayout; | |
29 | |
30 QWidget *mediaWidget = new QWidget; | |
31 mediaWidget->setLayout(m_relMediaLayout); | |
32 | |
33 QScrollArea * scrollArea = new QScrollArea; | |
34 scrollArea->setWidget(mediaWidget); | |
35 scrollArea->setWidgetResizable(true); | |
36 | |
37 QVBoxLayout *mainLayout = new QVBoxLayout; | |
38 mainLayout->addWidget(scrollArea); | |
39 | |
40 setLayout(mainLayout); | |
41 } | |
42 | |
43 RelatedMediaWidget::~RelatedMediaWidget() | |
44 {} | |
45 | |
46 void RelatedMediaWidget::reset() | |
47 { | |
48 m_nbRelMedia = 0; | |
49 | |
50 QLayoutItem *child; | |
51 while ((child = m_relMediaLayout->takeAt(0)) != 0) { | |
52 delete child->widget(); | |
53 } | |
54 } | |
55 | |
56 void RelatedMediaWidget::addRelatedMedia(const QString &filename) | |
57 { | |
58 QLabel *mediaLabel = new QLabel(); | |
59 mediaLabel->setText("<html><header><style type=\"text/css\">a {text-decoration: none;}</style></header><body><a href=\"" + filename + "\"><img src=\"" + filename + "\"> </a></body></html>"); | |
60 | |
61 connect(mediaLabel, SIGNAL(linkActivated(QString)), MainWindow::instance(), SLOT(runExternProcess(QString))); | |
62 | |
63 m_relMediaLayout->addWidget(mediaLabel, 0, m_nbRelMedia); | |
64 m_nbRelMedia++; | |
65 } |