| 1 |
/**************************************************************************************** |
| 2 |
* Copyright (c) 2007 Nikolaj Hald Nielsen <[email protected]> * |
| 3 |
* Copyright (c) 2007 Leo Franchi <[email protected]> * |
| 4 |
* * |
| 5 |
* This program is free software; you can redistribute it and/or modify it under * |
| 6 |
* the terms of the GNU General Public License as published by the Free Software * |
| 7 |
* Foundation; either version 2 of the License, or (at your option) any later * |
| 8 |
* version. * |
| 9 |
* * |
| 10 |
* This program is distributed in the hope that it will be useful, but WITHOUT ANY * |
| 11 |
* WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A * |
| 12 |
* PARTICULAR PURPOSE. See the GNU General Public License for more details. * |
| 13 |
* * |
| 14 |
* You should have received a copy of the GNU General Public License along with * |
| 15 |
* this program. If not, see <http://www.gnu.org/licenses/>. * |
| 16 |
****************************************************************************************/ |
| 17 |
|
| 18 |
#include "InfoEngine.h" |
| 19 |
|
| 20 |
#include "core/support/Amarok.h" |
| 21 |
#include "core/support/Debug.h" |
| 22 |
#include "browsers/InfoProxy.h" |
| 23 |
#include "PaletteHandler.h" |
| 24 |
|
| 25 |
QString InfoEngine::s_standardContent = "<html>" |
| 26 |
" <head>" |
| 27 |
" <style type=\"text/css\">body {text-align:center}</style>" |
| 28 |
" </head>" |
| 29 |
" <body>" |
| 30 |
" <b>%%SUBJECT_NAME%%</b>" |
| 31 |
" </body>" |
| 32 |
"</html>"; |
| 33 |
|
| 34 |
InfoEngine::InfoEngine( QObject* parent ) |
| 35 |
: QObject( parent ) |
| 36 |
{ |
| 37 |
DEBUG_BLOCK |
| 38 |
|
| 39 |
The::infoProxy()->subscribe( this ); |
| 40 |
|
| 41 |
connect( The::paletteHandler(), &PaletteHandler::newPalette, this, &InfoEngine::serviceChanged ); |
| 42 |
} |
| 43 |
|
| 44 |
InfoEngine::~InfoEngine() |
| 45 |
{ |
| 46 |
The::infoProxy()->unsubscribe( this ); |
| 47 |
} |
| 48 |
|
| 49 |
QString InfoEngine::mainInfo() const |
| 50 |
{ |
| 51 |
QString main_info; |
| 52 |
|
| 53 |
if( m_storedInfo.contains("main_info") ) |
| 54 |
{ |
| 55 |
auto palette = The::paletteHandler()->palette(); |
| 56 |
main_info = m_storedInfo.value("main_info").toString(); |
| 57 |
main_info.replace("{text_color}", palette.windowText().color().name()); |
| 58 |
main_info.replace("{content_background_color}", palette.window().color().name()); |
| 59 |
main_info.replace("{background_color}", palette.window().color().name()); |
| 60 |
main_info.replace("{border_color}", palette.text().color().name()); |
| 61 |
} |
| 62 |
|
| 63 |
if( main_info.isEmpty() ) |
| 64 |
main_info = s_standardContent.replace("%%SUBJECT_NAME%%", serviceName()); |
| 65 |
|
| 66 |
return main_info; |
| 67 |
} |
| 68 |
|
| 69 |
void InfoEngine::infoChanged( QVariantMap infoMap ) |
| 70 |
{ |
| 71 |
m_storedInfo = infoMap; |
| 72 |
Q_EMIT serviceChanged(); |
| 73 |
} |
| 74 |
|