Add spinner to lyrics and info pages
This commit is contained in:
committed by
craig.p.drummond
parent
60e0d2351d
commit
32c8efdbaf
@@ -92,7 +92,7 @@ void InfoPage::update(const Song &s, bool force)
|
||||
if (currentSong.isEmpty()) {
|
||||
text->setText(QString());
|
||||
} else {
|
||||
text->setHtml("<i>Retrieving...</i>");
|
||||
text->setHtml("<i>Retrieving...</i>", true);
|
||||
|
||||
Song s;
|
||||
s.albumartist=currentSong.artist;
|
||||
|
||||
@@ -378,10 +378,10 @@ void LyricsPage::getLyrics()
|
||||
UltimateLyricsProvider *prov=UltimateLyrics::self()->getNext(currentProvider);
|
||||
if (prov) {
|
||||
text->setText(i18nc("<title> by <artist>\nFetching lyrics via <url>", "%1 by %2\nFetching lyrics via %3")
|
||||
.arg(currentSong.title).arg(currentSong.artist, prov->getName()));
|
||||
.arg(currentSong.title).arg(currentSong.artist, prov->getName()), true);
|
||||
prov->fetchInfo(currentRequest, currentSong);
|
||||
} else {
|
||||
text->setText(i18nc("<title> by <artist>\nFailed\n", "%1 by %2\nFailed to fetch lyrics").arg(currentSong.title).arg(currentSong.artist));
|
||||
text->setText(i18nc("<title> by <artist>\nFailed\n", "%1 by %2\nFailed to fetch lyrics").arg(currentSong.title).arg(currentSong.artist), true);
|
||||
currentProvider=-1;
|
||||
// Set lyrics file anyway - so that editing is enabled!
|
||||
lyricsFile=Settings::self()->storeLyricsInMpdDir()
|
||||
|
||||
@@ -22,6 +22,7 @@
|
||||
*/
|
||||
|
||||
#include "textbrowser.h"
|
||||
#include "spinner.h"
|
||||
#include <QPainter>
|
||||
#include <QDebug>
|
||||
|
||||
@@ -108,6 +109,7 @@ static void toGray(QImage &img)
|
||||
TextBrowser::TextBrowser(QWidget *p)
|
||||
: QTextBrowser(p)
|
||||
, drawImage(false)
|
||||
, spinner(0)
|
||||
{
|
||||
orig=font().pointSize();
|
||||
if (-1==minSize) {
|
||||
@@ -168,3 +170,41 @@ void TextBrowser::paintEvent(QPaintEvent *e)
|
||||
|
||||
QTextBrowser::paintEvent(e);
|
||||
}
|
||||
|
||||
void TextBrowser::setHtml(const QString &txt, bool showSpin)
|
||||
{
|
||||
QTextBrowser::setHtml(txt);
|
||||
if (showSpin) {
|
||||
showSpiner();
|
||||
} else {
|
||||
hideSpinner();
|
||||
}
|
||||
}
|
||||
|
||||
void TextBrowser::setText(const QString &txt, bool showSpin)
|
||||
{
|
||||
QTextBrowser::setText(txt);
|
||||
if (showSpin) {
|
||||
showSpiner();
|
||||
} else {
|
||||
hideSpinner();
|
||||
}
|
||||
}
|
||||
|
||||
void TextBrowser::showSpiner()
|
||||
{
|
||||
if (!spinner) {
|
||||
spinner=new Spinner(this);
|
||||
spinner->setWidget(this);
|
||||
}
|
||||
if (!spinner->isActive()) {
|
||||
spinner->start();
|
||||
}
|
||||
}
|
||||
|
||||
void TextBrowser::hideSpinner()
|
||||
{
|
||||
if (spinner) {
|
||||
spinner->stop();
|
||||
}
|
||||
}
|
||||
|
||||
@@ -27,6 +27,7 @@
|
||||
#include <QTextBrowser>
|
||||
#include <QImage>
|
||||
#include <QDebug>
|
||||
class Spinner;
|
||||
|
||||
class TextBrowser : public QTextBrowser
|
||||
{
|
||||
@@ -40,11 +41,16 @@ public:
|
||||
void enableImage(bool e);
|
||||
bool imageEnabled() { return drawImage; }
|
||||
void paintEvent(QPaintEvent *e);
|
||||
void setHtml(const QString &txt, bool showSpin=false);
|
||||
void setText(const QString &txt, bool showSpin=false);
|
||||
void showSpiner();
|
||||
void hideSpinner();
|
||||
|
||||
private:
|
||||
int orig;
|
||||
QImage image;
|
||||
bool drawImage;
|
||||
Spinner *spinner;
|
||||
};
|
||||
|
||||
#endif
|
||||
|
||||
Reference in New Issue
Block a user