Commit c1b5b195 authored by Martin Tobias Holmedahl Sandsmark's avatar Martin Tobias Holmedahl Sandsmark Committed by Martin Tobias Holmedahl Sandsmark
Browse files

make it actually work

parent 903c4714
......@@ -8,12 +8,12 @@
#include "lyricswidget.h"
#include "tag.h"
LyricsWidget::LyricsWidget(QWidget* parent): QTextEdit(parent),
LyricsWidget::LyricsWidget(QWidget* parent): QTextBrowser(parent),
m_networkAccessManager(new QNetworkAccessManager)
{
setReadOnly(true);
setWordWrapMode(QTextOption::WordWrap);
setOpenExternalLinks(true);
}
LyricsWidget::~LyricsWidget()
{
......@@ -22,7 +22,6 @@ LyricsWidget::~LyricsWidget()
void LyricsWidget::playing(const FileHandle &file)
{
qWarning() << "LOL";
setHtml("<i>Loading...</i>");
QUrl listUrl("http://lyrics.wikia.com/api.php");
......@@ -31,6 +30,7 @@ void LyricsWidget::playing(const FileHandle &file)
listUrl.addQueryItem("fmt", "xml");
listUrl.addQueryItem("artist", file.tag()->artist());
listUrl.addQueryItem("song", file.tag()->title());
m_title = file.tag()->artist() + " &#8211; " + file.tag()->title();
connect(m_networkAccessManager, SIGNAL(finished(QNetworkReply*)), this, SLOT(receiveListReply(QNetworkReply*)));
m_networkAccessManager->get(QNetworkRequest(listUrl));
}
......@@ -59,6 +59,7 @@ void LyricsWidget::receiveListReply(QNetworkReply* reply)
connect(m_networkAccessManager, SIGNAL(finished(QNetworkReply*)), this, SLOT(receiveLyricsReply(QNetworkReply*)));
m_networkAccessManager->get(QNetworkRequest(url));
}
void LyricsWidget::receiveLyricsReply(QNetworkReply* reply)
{
disconnect(m_networkAccessManager, SIGNAL(finished(QNetworkReply*)), this, SLOT(receiveLyricsReply(QNetworkReply*)));
......@@ -80,5 +81,7 @@ void LyricsWidget::receiveLyricsReply(QNetworkReply* reply)
content = content.mid(lIndex, rIndex - lIndex).trimmed();
content.replace("\n", "<br />");
//setText(content);
setHtml(content);
setHtml("<h1>" + m_title + "</h1>" +
content +
"<br /><br /><i>Lyrics provided by <a href='http://lyrics.wikia.com/Lyrics_Wiki'>LyricWiki</a></i>");
}
#ifndef LYRICSWIDGET_H
#define LYRICSWIDGET_H
#include <QTextEdit>
#include <QTextBrowser>
#include "filehandle.h"
class QNetworkAccessManager;
class QNetworkReply;
class LyricsWidget : public QTextEdit
class LyricsWidget : public QTextBrowser
{
Q_OBJECT
......@@ -17,6 +17,8 @@ public:
virtual ~LyricsWidget();
QSize minimumSize() const { return QSize(100, 0); }
public Q_SLOTS:
void playing(const FileHandle &file);
......@@ -26,6 +28,7 @@ private Q_SLOTS:
private:
QNetworkAccessManager *m_networkAccessManager;
QString m_title;
};
......
......@@ -207,8 +207,7 @@ void PlaylistSplitter::setupLayout()
connect(m_playlistBox, SIGNAL(startupComplete()), SLOT(slotEnable()));
connect(m_playlistBox, SIGNAL(startFilePlayback(FileHandle)),
m_player, SLOT(play(FileHandle)));
connect(m_playlistBox, SIGNAL(startFilePlayback(FileHandle)),
m_lyricsWidget, SLOT(playing(FileHandle)));
m_player->setPlaylistInterface(m_playlistBox);
......@@ -220,6 +219,8 @@ void PlaylistSplitter::setupLayout()
m_nowPlaying = new NowPlaying(top, m_playlistBox);
connect(m_player, SIGNAL(signalItemChanged(FileHandle)),
m_nowPlaying, SLOT(slotUpdate(FileHandle)));
connect(m_player, SIGNAL(signalItemChanged(FileHandle)),
m_lyricsWidget, SLOT(playing(FileHandle)));
// Create the search widget -- this must be done after the CollectionList is created.
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment