1 /**************************************************************************************** 2 * Copyright (c) 2007 Nikolaj Hald Nielsen <nhn@kde.org> * 3 * * 4 * This program is free software; you can redistribute it and/or modify it under * 5 * the terms of the GNU General Public License as published by the Free Software * 6 * Foundation; either version 2 of the License, or (at your option) any later * 7 * version. * 8 * * 9 * This program is distributed in the hope that it will be useful, but WITHOUT ANY * 10 * WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A * 11 * PARTICULAR PURPOSE. See the GNU General Public License for more details. * 12 * * 13 * You should have received a copy of the GNU General Public License along with * 14 * this program. If not, see <http://www.gnu.org/licenses/>. * 15 ****************************************************************************************/ 16 17 #include "InfoParserBase.h" 18 19 #include "core/support/Debug.h" 20 21 #include <QStandardPaths> 22 #include <QUrl> 23 24 #include <QFile> 25 #include <QPalette> 26 27 QString InfoParserBase::s_loadingBaseHtml; 28 InfoParserBase()29InfoParserBase::InfoParserBase() 30 : QObject() 31 {} 32 showLoading(const QString & message)33void InfoParserBase::showLoading( const QString &message ) 34 { 35 DEBUG_BLOCK 36 37 if( s_loadingBaseHtml.isEmpty() ) 38 { 39 const QUrl url( QStandardPaths::locate( QStandardPaths::GenericDataLocation, QStringLiteral("amarok/data/") ) ); 40 QString htmlFile = url.path() + "InfoParserLoading.html"; 41 42 if( !QFile::exists( htmlFile ) ) 43 { 44 debug() << "file " << htmlFile << "does not exist"; 45 return; 46 } 47 48 QFile file( htmlFile ); 49 if( !file.open( QIODevice::ReadOnly ) ) 50 { 51 debug() << "error reading file " << htmlFile; 52 return; 53 } 54 55 s_loadingBaseHtml = file.readAll(); 56 } 57 58 QString currentHtml = s_loadingBaseHtml; 59 60 const QUrl url( QStandardPaths::locate( QStandardPaths::GenericDataLocation, QStringLiteral("amarok/images/") ) ); 61 currentHtml = currentHtml.replace( QLatin1String("%%IMAGEPATH%%"), url.url() ); 62 currentHtml = currentHtml.replace( QLatin1String("%%TEXT%%"), message ); 63 64 // debug() << "showing html: " << currentHtml; 65 Q_EMIT ( info( currentHtml ) ); 66 } 67 68 69