diff options
| author | trialuser02 <trialuser02@90c681e8-e032-0410-971d-27865f9a5e38> | 2015-02-02 14:57:42 +0000 |
|---|---|---|
| committer | trialuser02 <trialuser02@90c681e8-e032-0410-971d-27865f9a5e38> | 2015-02-02 14:57:42 +0000 |
| commit | 96cfa27dc27e4dc81385df243215fd516b043673 (patch) | |
| tree | f6ba582f37b2584406d1f697240f8175fdf98f8f | |
| parent | 017c9101557477b942ced1739a5668187c5254e0 (diff) | |
| download | qmmp-96cfa27dc27e4dc81385df243215fd516b043673.tar.gz qmmp-96cfa27dc27e4dc81385df243215fd516b043673.tar.bz2 qmmp-96cfa27dc27e4dc81385df243215fd516b043673.zip | |
reduced number of template compilation
git-svn-id: http://svn.code.sf.net/p/qmmp-dev/code/trunk/qmmp@4716 90c681e8-e032-0410-971d-27865f9a5e38
| -rw-r--r-- | src/plugins/General/notifier/popupwidget.cpp | 17 | ||||
| -rw-r--r-- | src/plugins/General/notifier/popupwidget.h | 5 | ||||
| -rw-r--r-- | src/plugins/Ui/skinned/popupwidget.cpp | 6 | ||||
| -rw-r--r-- | src/plugins/Ui/skinned/popupwidget.h | 4 | ||||
| -rw-r--r-- | src/plugins/Ui/skinned/textscroller.cpp | 6 | ||||
| -rw-r--r-- | src/plugins/Ui/skinned/textscroller.h | 4 |
6 files changed, 17 insertions, 25 deletions
diff --git a/src/plugins/General/notifier/popupwidget.cpp b/src/plugins/General/notifier/popupwidget.cpp index b29b5c6f0..b14ba6396 100644 --- a/src/plugins/General/notifier/popupwidget.cpp +++ b/src/plugins/General/notifier/popupwidget.cpp @@ -30,8 +30,6 @@ #include <QFont> #include <qmmp/soundcore.h> #include <qmmp/metadatamanager.h> -#include <qmmpui/metadataformatter.h> - #include "popupwidget.h" PopupWidget::PopupWidget(QWidget *parent) @@ -59,7 +57,7 @@ PopupWidget::PopupWidget(QWidget *parent) setWindowOpacity(settings.value("opacity", 1.0).toDouble()); QString fontname = settings.value("font").toString(); m_coverSize = settings.value("cover_size", 64).toInt(); - m_template = settings.value("template",DEFAULT_TEMPLATE).toString(); + m_formatter.setPattern(settings.value("template",DEFAULT_TEMPLATE).toString()); settings.endGroup(); //font QFont font; @@ -84,18 +82,9 @@ void PopupWidget::mousePressEvent (QMouseEvent *) void PopupWidget::showMetaData() { m_timer->stop(); - QString title = m_template; - SoundCore *core = SoundCore::instance(); - if (core->totalTime() > 0) - { - int l = core->totalTime()/1000; - title.replace("%l",QString("%1:%2").arg(l/60).arg(l%60, 2, 10, QChar('0'))); - } - else - title.replace("%l",""); - MetaDataFormatter f(title); - title = f.format(core->metaData()); + + QString title = m_formatter.format(core->metaData(), core->totalTime() / 1000); m_label1->setText(title); diff --git a/src/plugins/General/notifier/popupwidget.h b/src/plugins/General/notifier/popupwidget.h index bed2418af..0eb625c50 100644 --- a/src/plugins/General/notifier/popupwidget.h +++ b/src/plugins/General/notifier/popupwidget.h @@ -1,5 +1,5 @@ /*************************************************************************** - * Copyright (C) 2008-2012 by Ilya Kotov * + * Copyright (C) 2008-2015 by Ilya Kotov * * forkotov02@hotmail.ru * * * * This program is free software; you can redistribute it and/or modify * @@ -22,6 +22,7 @@ #include <QWidget> #include <QFrame> +#include <qmmpui/metadataformatter.h> #define DEFAULT_TEMPLATE "<b>%if(%t,%t,%f)</b> %if(%l,\\(%l\\),) \n%if(%p,<br>%p,)\n%if(%a,<br>%a,)" @@ -63,7 +64,7 @@ private: QTimer *m_timer; QLabel *m_label1; QLabel *m_pixlabel; - QString m_template; + MetaDataFormatter m_formatter; uint m_pos; int m_coverSize; diff --git a/src/plugins/Ui/skinned/popupwidget.cpp b/src/plugins/Ui/skinned/popupwidget.cpp index 63cfc7142..daaa383c0 100644 --- a/src/plugins/Ui/skinned/popupwidget.cpp +++ b/src/plugins/Ui/skinned/popupwidget.cpp @@ -53,6 +53,7 @@ PopupWidget::PopupWidget(QWidget *parent) setWindowOpacity(settings.value("popup_opacity", 1.0).toDouble()); m_coverSize = settings.value("popup_cover_size", 48).toInt(); m_template = settings.value("popup_template",DEFAULT_TEMPLATE).toString(); + m_formatter.setPattern(m_template); int delay = settings.value("popup_delay", 2500).toInt(); bool show_cover = settings.value("popup_show_cover",true).toBool(); settings.endGroup(); @@ -93,10 +94,7 @@ void PopupWidget::prepare(PlayListTrack *item, QPoint pos) return; } - QString title = m_template; - MetaDataFormatter f(title); - title = f.format(item); - m_label1->setText(title); + m_label1->setText(m_formatter.format(item)); qApp->processEvents(); updateGeometry (); resize(sizeHint()); diff --git a/src/plugins/Ui/skinned/popupwidget.h b/src/plugins/Ui/skinned/popupwidget.h index ec2b18f2f..8e5afd97a 100644 --- a/src/plugins/Ui/skinned/popupwidget.h +++ b/src/plugins/Ui/skinned/popupwidget.h @@ -1,5 +1,5 @@ /*************************************************************************** - * Copyright (C) 2008-2013 by Ilya Kotov * + * Copyright (C) 2008-2015 by Ilya Kotov * * forkotov02@hotmail.ru * * * * This program is free software; you can redistribute it and/or modify * @@ -21,6 +21,7 @@ #define POPUPWIDGET_H #include <QWidget> +#include <qmmpui/metadataformatter.h> #define DEFAULT_TEMPLATE "<b>%if(%t,%t,%f)</b>\n%if(%p,<br>%p,)\n%if(%a,<br>%a,)" @@ -58,6 +59,7 @@ private: QString m_template; int m_coverSize; QString m_url; + MetaDataFormatter m_formatter; }; } diff --git a/src/plugins/Ui/skinned/textscroller.cpp b/src/plugins/Ui/skinned/textscroller.cpp index ab86942a9..8fee5c739 100644 --- a/src/plugins/Ui/skinned/textscroller.cpp +++ b/src/plugins/Ui/skinned/textscroller.cpp @@ -1,5 +1,5 @@ /*************************************************************************** - * Copyright (C) 2006-2012 by Ilya Kotov * + * Copyright (C) 2006-2015 by Ilya Kotov * * forkotov02@hotmail.ru * * * * This program is free software; you can redistribute it and/or modify * @@ -41,6 +41,7 @@ TextScroller::TextScroller (QWidget *parent) : QWidget (parent) m_press_pos = 0; m_metrics = 0; m_defautText = QString("Qmmp ") + Qmmp::strVersion(); + m_formater.setPattern(TITLE_FORMAT); m_core = SoundCore::instance(); m_skin = Skin::instance(); m_ratio = m_skin->ratio(); @@ -238,10 +239,9 @@ void TextScroller::processState(Qmmp::State state) void TextScroller::processMetaData() { - MetaDataFormatter formater(TITLE_FORMAT); if(m_core->state() == Qmmp::Playing) { - m_titleText = formater.format(m_core->metaData(), m_core->totalTime()/1000); + m_titleText = m_formater.format(m_core->metaData(), m_core->totalTime()/1000); updateText(); } } diff --git a/src/plugins/Ui/skinned/textscroller.h b/src/plugins/Ui/skinned/textscroller.h index d7225df43..32cc1cb5a 100644 --- a/src/plugins/Ui/skinned/textscroller.h +++ b/src/plugins/Ui/skinned/textscroller.h @@ -1,5 +1,5 @@ /*************************************************************************** - * Copyright (C) 2006-2012 by Ilya Kotov * + * Copyright (C) 2006-2015 by Ilya Kotov * * forkotov02@hotmail.ru * * * * This program is free software; you can redistribute it and/or modify * @@ -21,6 +21,7 @@ #define TEXTSCROLLER_H #include <QWidget> +#include <qmmpui/metadataformatter.h> #include <qmmp/qmmp.h> class QTimer; @@ -76,6 +77,7 @@ private: QMenu *m_menu; QAction *m_scrollAction, *m_transparencyAction; SoundCore *m_core; + MetaDataFormatter m_formater; }; #endif |
