aboutsummaryrefslogtreecommitdiff
path: root/src/plugins/General/statusicon/statusiconpopupwidget.cpp
diff options
context:
space:
mode:
authortrialuser02 <trialuser02@90c681e8-e032-0410-971d-27865f9a5e38>2010-01-27 22:25:47 +0000
committertrialuser02 <trialuser02@90c681e8-e032-0410-971d-27865f9a5e38>2010-01-27 22:25:47 +0000
commitabaab158ba5c7e46ecfee3846ae9d596df871212 (patch)
tree28a8a6eafecc4b6908fae4528ba45990d53460b9 /src/plugins/General/statusicon/statusiconpopupwidget.cpp
parent57da9f81de51faa5daba43346c35424d854f3ced (diff)
downloadqmmp-abaab158ba5c7e46ecfee3846ae9d596df871212.tar.gz
qmmp-abaab158ba5c7e46ecfee3846ae9d596df871212.tar.bz2
qmmp-abaab158ba5c7e46ecfee3846ae9d596df871212.zip
added template editor, improved status icon plugin
git-svn-id: http://svn.code.sf.net/p/qmmp-dev/code/trunk/qmmp@1530 90c681e8-e032-0410-971d-27865f9a5e38
Diffstat (limited to 'src/plugins/General/statusicon/statusiconpopupwidget.cpp')
-rw-r--r--src/plugins/General/statusicon/statusiconpopupwidget.cpp74
1 files changed, 29 insertions, 45 deletions
diff --git a/src/plugins/General/statusicon/statusiconpopupwidget.cpp b/src/plugins/General/statusicon/statusiconpopupwidget.cpp
index dd5b25334..0d1fe5e8f 100644
--- a/src/plugins/General/statusicon/statusiconpopupwidget.cpp
+++ b/src/plugins/General/statusicon/statusiconpopupwidget.cpp
@@ -1,8 +1,8 @@
/***************************************************************************
* Copyright (C) 2009 by Artur Guzik *
- * a.guzik88@gmail.com
- *
- * Copyright (C) 2009 by Ilya Kotov *
+ * a.guzik88@gmail.com *
+ * *
+ * Copyright (C) 2009-2010 by Ilya Kotov *
* forkotov02@hotmail.ru *
* *
* This program is free software; you can redistribute it and/or modify *
@@ -31,8 +31,10 @@
#include <QDesktopWidget>
#include <QSpacerItem>
#include <QProgressBar>
+#include <QSettings>
#include <qmmp/soundcore.h>
#include <qmmp/metadatamanager.h>
+#include <qmmpui/metadataformatter.h>
#include "coverwidget.h"
#include "statusiconpopupwidget.h"
@@ -48,7 +50,6 @@ StatusIconPopupWidget::StatusIconPopupWidget(QWidget * parent)
m_vLayout = new QVBoxLayout();
m_cover = new CoverWidget(this);
- m_cover->setFixedSize(100,100);
m_hLayout->addWidget(m_cover);
m_textLabel = new QLabel(this);
@@ -73,7 +74,16 @@ StatusIconPopupWidget::StatusIconPopupWidget(QWidget * parent)
connect(SoundCore::instance(),SIGNAL(elapsedChanged(qint64)),this,SLOT(updateTime(qint64)));
connect(SoundCore::instance(),SIGNAL(stateChanged(Qmmp::State)),this,SLOT(updateMetaData()));
- setVisible(FALSE);
+ QSettings settings(Qmmp::configFile(), QSettings::IniFormat);
+ settings.beginGroup("Tray");
+ m_timer->setInterval(settings.value("tooltip_delay",2000).toInt());
+ setWindowOpacity(1.0 - settings.value("tooltip_transparency",0).toInt()/100.0);
+ int size = settings.value("tooltip_cover_size",100).toInt();
+ m_cover->setFixedSize(size,size);
+ m_splitFileName = settings.value("split_file_name",TRUE).toBool();
+ m_showProgress = settings.value("tooltip_progress",TRUE).toBool();
+ m_template = settings.value("tooltip_template", DEFAULT_TEMPLATE).toString();
+ settings.endGroup();
}
StatusIconPopupWidget::~StatusIconPopupWidget()
@@ -91,48 +101,23 @@ void StatusIconPopupWidget::updateMetaData()
SoundCore *core = SoundCore::instance();
if(core->state() == Qmmp::Playing || core->state() == Qmmp::Paused)
{
- QString text;
- QString title = core->metaData(Qmmp::TITLE);
- QString artist = core->metaData(Qmmp::ARTIST);
- QString album = core->metaData(Qmmp::ALBUM);
- int year = core->metaData(Qmmp::YEAR).toInt();
- if(title.isEmpty())
+ QString title = m_template;
+ SoundCore *core = SoundCore::instance();
+ QMap<Qmmp::MetaData, QString> meta;
+ if(m_splitFileName && meta[Qmmp::TITLE].isEmpty() && !meta[Qmmp::URL].contains("://"))
{
- title = QFileInfo(core->metaData(Qmmp::URL)).completeBaseName();
- if(m_splitFileName && title.contains("-"))
+ QString name = QFileInfo(meta[Qmmp::URL]).completeBaseName();
+ if(name.contains("-"))
{
- artist = title.section('-',0,0).trimmed();
- title = title.section('-',1,1).trimmed();
+ meta[Qmmp::TITLE] = name.section('-',1,1).trimmed();
+ if(meta[Qmmp::ARTIST].isEmpty())
+ meta[Qmmp::ARTIST] = name.section('-',0,0).trimmed();
}
}
- text.append("<b>" + title + "</b>");
- if(core->totalTime() > 0)
- {
- text.append(" ");
- QString time;
- int l = core->totalTime()/1000;
- if(l > 3600)
- time += QString("(%1:%2:%3)").arg(l/3600,2,10,QChar('0')).arg(l%3600/60,2,10,QChar('0'))
- .arg(l%60,2,10,QChar('0'));
-
- else
- time = QString("(%1:%2)").arg(l/60,2,10,QChar('0')).arg(l%60,2,10,QChar('0'));
- text.append(time);
- }
- if(!artist.isEmpty())
- {
- text.append("<br>");
- text.append(artist);
- }
- if(!album.isEmpty())
- {
- text.append("<br>");
- text.append(album);
- }
- if(year > 0)
- text.append(QString("<br>%1").arg(year));
- m_textLabel->setText(text);
+ MetaDataFormatter f(title);
+ title = f.parse(core->metaData(), core->totalTime()/1000);
+ m_textLabel->setText(title);
QPixmap cover = MetaDataManager::instance()->getCover(core->metaData(Qmmp::URL));
m_cover->show();
m_bar->show();
@@ -141,6 +126,7 @@ void StatusIconPopupWidget::updateMetaData()
else
m_cover->setPixmap(cover);
updateTime(core->elapsed());
+ m_bar->setVisible(m_showProgress);
}
else
{
@@ -186,13 +172,11 @@ void StatusIconPopupWidget::updatePosition(int trayx, int trayy)
return;
}
-void StatusIconPopupWidget::showInfo(int x, int y, int delay, bool splitFileName)
+void StatusIconPopupWidget::showInfo(int x, int y)
{
m_timer->stop();
- m_timer->setInterval(delay);
m_lastTrayX = x;
m_lastTrayY = y;
- m_splitFileName = splitFileName;
updateMetaData();
qApp->processEvents();
updatePosition(x,y);