Mercurial > hg > easaier-soundaccess
diff 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 |
line wrap: on
line diff
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/widgets/RelatedMediaWidget.cpp Tue Nov 13 10:07:49 2007 +0000 @@ -0,0 +1,65 @@ +/* -*- c-basic-offset: 4 indent-tabs-mode: nil -*- vi:set ts=8 sts=4 sw=4: */ + +/* Sound Access + EASAIER client application. + Silogic 2007. Laure Bajard. + + This program is free software; you can redistribute it and/or + modify it under the terms of the GNU General Public License as + published by the Free Software Foundation; either version 2 of the + License, or (at your option) any later version. See the file + COPYING included with this distribution for more information . +*/ + +#include "RelatedMediaWidget.h" + +#include <QScrollArea> +#include <QLayoutItem> +#include <QLinearGradient> + +#include <iostream> + +#include "sv/main/MainWindow.h" + +RelatedMediaWidget::RelatedMediaWidget() : QWidget() , + m_nbRelMedia(0), + m_painter(0) +{ + m_relMediaLayout = new QGridLayout; + + QWidget *mediaWidget = new QWidget; + mediaWidget->setLayout(m_relMediaLayout); + + QScrollArea * scrollArea = new QScrollArea; + scrollArea->setWidget(mediaWidget); + scrollArea->setWidgetResizable(true); + + QVBoxLayout *mainLayout = new QVBoxLayout; + mainLayout->addWidget(scrollArea); + + setLayout(mainLayout); +} + +RelatedMediaWidget::~RelatedMediaWidget() +{} + +void RelatedMediaWidget::reset() +{ + m_nbRelMedia = 0; + + QLayoutItem *child; + while ((child = m_relMediaLayout->takeAt(0)) != 0) { + delete child->widget(); + } +} + +void RelatedMediaWidget::addRelatedMedia(const QString &filename) +{ + QLabel *mediaLabel = new QLabel(); + mediaLabel->setText("<html><header><style type=\"text/css\">a {text-decoration: none;}</style></header><body><a href=\"" + filename + "\"><img src=\"" + filename + "\"> </a></body></html>"); + + connect(mediaLabel, SIGNAL(linkActivated(QString)), MainWindow::instance(), SLOT(runExternProcess(QString))); + + m_relMediaLayout->addWidget(mediaLabel, 0, m_nbRelMedia); + m_nbRelMedia++; +}