From 15c492f75bd1a5797f6e339cdf66dc3086664e43 Mon Sep 17 00:00:00 2001 From: trialuser02 Date: Fri, 16 Oct 2009 21:00:11 +0000 Subject: updated status icon plugin, fixed build git-svn-id: http://svn.code.sf.net/p/qmmp-dev/code/trunk/qmmp@1319 90c681e8-e032-0410-971d-27865f9a5e38 --- src/plugins/General/CMakeLists.txt | 2 +- src/plugins/General/statusicon/CMakeLists.txt | 2 + src/plugins/General/statusicon/coverwidget.cpp | 44 +++++ src/plugins/General/statusicon/coverwidget.h | 50 ++++++ src/plugins/General/statusicon/qmmptrayicon.cpp | 4 +- src/plugins/General/statusicon/qmmptrayicon.h | 4 +- src/plugins/General/statusicon/settingsdialog.cpp | 13 +- src/plugins/General/statusicon/settingsdialog.h | 4 +- src/plugins/General/statusicon/settingsdialog.ui | 147 ++++++++++------- src/plugins/General/statusicon/statusicon.cpp | 56 +++++-- src/plugins/General/statusicon/statusicon.h | 5 +- .../General/statusicon/statusiconfactory.cpp | 6 +- .../General/statusicon/statusiconpopupwidget.cpp | 177 +++++++++++---------- .../General/statusicon/statusiconpopupwidget.h | 64 +++++--- .../translations/statusicon_plugin_cs.ts | 72 ++++++--- .../translations/statusicon_plugin_de.ts | 72 ++++++--- .../translations/statusicon_plugin_it.ts | 70 +++++--- .../translations/statusicon_plugin_lt.ts | 70 +++++--- .../translations/statusicon_plugin_pl.ts | 72 ++++++--- .../translations/statusicon_plugin_ru.ts | 72 ++++++--- .../translations/statusicon_plugin_tr.ts | 70 +++++--- .../translations/statusicon_plugin_uk_UA.ts | 72 ++++++--- .../translations/statusicon_plugin_zh_CN.ts | 70 +++++--- .../translations/statusicon_plugin_zh_TW.ts | 70 +++++--- 24 files changed, 901 insertions(+), 387 deletions(-) create mode 100644 src/plugins/General/statusicon/coverwidget.cpp create mode 100644 src/plugins/General/statusicon/coverwidget.h (limited to 'src/plugins/General') diff --git a/src/plugins/General/CMakeLists.txt b/src/plugins/General/CMakeLists.txt index ec7019c9f..cdd47cbd3 100644 --- a/src/plugins/General/CMakeLists.txt +++ b/src/plugins/General/CMakeLists.txt @@ -17,7 +17,7 @@ add_subdirectory(scrobbler) ENDIF(USE_SCROBBLER) IF(USE_STATICON) -#add_subdirectory(statusicon) +add_subdirectory(statusicon) ENDIF(USE_STATICON) IF(USE_NOTIFIER) diff --git a/src/plugins/General/statusicon/CMakeLists.txt b/src/plugins/General/statusicon/CMakeLists.txt index 0e28749ab..f912b11a5 100644 --- a/src/plugins/General/statusicon/CMakeLists.txt +++ b/src/plugins/General/statusicon/CMakeLists.txt @@ -33,6 +33,7 @@ SET(libstatusicon_SRCS statusiconfactory.cpp qmmptrayicon.cpp statusiconpopupwidget.cpp + coverwidget.cpp ) SET(libstatusicon_MOC_HDRS @@ -41,6 +42,7 @@ SET(libstatusicon_MOC_HDRS statusicon.h qmmptrayicon.h statusiconpopupwidget.h + coverwidget.h ) SET(libstatusicon_RCCS diff --git a/src/plugins/General/statusicon/coverwidget.cpp b/src/plugins/General/statusicon/coverwidget.cpp new file mode 100644 index 000000000..28e4e8b91 --- /dev/null +++ b/src/plugins/General/statusicon/coverwidget.cpp @@ -0,0 +1,44 @@ +/*************************************************************************** + * Copyright (C) 2009 by Ilya Kotov * + * forkotov02@hotmail.ru * + * * + * This program is free software; you can redistribute it and/or modify * + * it under the terms of the GNU General Public License as published by * + * the Free Software Foundation; either version 2 of the License, or * + * (at your option) any later version. * + * * + * This program is distributed in the hope that it will be useful, * + * but WITHOUT ANY WARRANTY; without even the implied warranty of * + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * + * GNU General Public License for more details. * + * * + * You should have received a copy of the GNU General Public License * + * along with this program; if not, write to the * + * Free Software Foundation, Inc., * + * 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. * + ***************************************************************************/ +#include +#include +#include + +#include "coverwidget.h" + +CoverWidget::CoverWidget(QWidget *parent) + : QWidget(parent) +{} + +CoverWidget::~CoverWidget() +{} + +void CoverWidget::setPixmap(const QPixmap &pixmap) +{ + m_pixmap = pixmap; + update(); +} + +void CoverWidget::paintEvent (QPaintEvent *p) +{ + QPainter paint(this); + if(!m_pixmap.isNull()) + paint.drawPixmap(0,0, m_pixmap.scaled(p->rect().size())); +} diff --git a/src/plugins/General/statusicon/coverwidget.h b/src/plugins/General/statusicon/coverwidget.h new file mode 100644 index 000000000..b06e66f7e --- /dev/null +++ b/src/plugins/General/statusicon/coverwidget.h @@ -0,0 +1,50 @@ +/*************************************************************************** + * Copyright (C) 2009 by Ilya Kotov * + * forkotov02@hotmail.ru * + * * + * This program is free software; you can redistribute it and/or modify * + * it under the terms of the GNU General Public License as published by * + * the Free Software Foundation; either version 2 of the License, or * + * (at your option) any later version. * + * * + * This program is distributed in the hope that it will be useful, * + * but WITHOUT ANY WARRANTY; without even the implied warranty of * + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * + * GNU General Public License for more details. * + * * + * You should have received a copy of the GNU General Public License * + * along with this program; if not, write to the * + * Free Software Foundation, Inc., * + * 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. * + ***************************************************************************/ +#ifndef PIXMAPWIDGET_H +#define PIXMAPWIDGET_H + +#include +#include + +/** + @author Ilya Kotov +*/ + +class CoverWidget : public QWidget +{ +Q_OBJECT +public: + CoverWidget(QWidget *parent = 0); + + ~CoverWidget(); + + virtual void setPixmap(const QPixmap&); + +protected: + void paintEvent (QPaintEvent *event); + +private: + QPixmap m_pixmap; + + + +}; + +#endif diff --git a/src/plugins/General/statusicon/qmmptrayicon.cpp b/src/plugins/General/statusicon/qmmptrayicon.cpp index ad6f03906..d7a7bf230 100644 --- a/src/plugins/General/statusicon/qmmptrayicon.cpp +++ b/src/plugins/General/statusicon/qmmptrayicon.cpp @@ -1,5 +1,5 @@ /*************************************************************************** - * Copyright (C) 2008 by Ilya Kotov * + * Copyright (C) 2008-2009 by Ilya Kotov * * forkotov02@hotmail.ru * * * * This program is free software; you can redistribute it and/or modify * @@ -25,7 +25,7 @@ #include #include "qmmptrayicon.h" -#include +#include "statusiconpopupwidget.h" QmmpTrayIcon::QmmpTrayIcon(QObject *parent) diff --git a/src/plugins/General/statusicon/qmmptrayicon.h b/src/plugins/General/statusicon/qmmptrayicon.h index 468e424fd..239fe918e 100644 --- a/src/plugins/General/statusicon/qmmptrayicon.h +++ b/src/plugins/General/statusicon/qmmptrayicon.h @@ -1,5 +1,5 @@ /*************************************************************************** - * Copyright (C) 2008 by Ilya Kotov * + * Copyright (C) 2008-2009 by Ilya Kotov * * forkotov02@hotmail.ru * * * * This program is free software; you can redistribute it and/or modify * @@ -23,8 +23,6 @@ #include #include -//#include "statusiconpopupwidget.h" - class QEvent; class QWheelEvent; class StatusIconPopupWidget; diff --git a/src/plugins/General/statusicon/settingsdialog.cpp b/src/plugins/General/statusicon/settingsdialog.cpp index 51d23442c..1735054c7 100644 --- a/src/plugins/General/statusicon/settingsdialog.cpp +++ b/src/plugins/General/statusicon/settingsdialog.cpp @@ -1,5 +1,5 @@ /*************************************************************************** - * Copyright (C) 2008 by Ilya Kotov * + * Copyright (C) 2009 by Ilya Kotov * * forkotov02@hotmail.ru * * * * This program is free software; you can redistribute it and/or modify * @@ -32,10 +32,9 @@ SettingsDialog::SettingsDialog(QWidget *parent) settings.beginGroup("Tray"); ui.messageGroupBox->setChecked(settings.value("show_message",TRUE).toBool()); ui.messageDelaySpinBox->setValue(settings.value("message_delay", 2000).toInt()); - ui.toolTipCheckBox->setChecked(settings.value("show_tooltip",FALSE).toBool()); ui.niceTooltipGroupBox->setChecked(settings.value("show_nicetooltip", TRUE).toBool()); ui.niceTooltipDelaySpinBox->setValue(settings.value("nicetooltip_delay",2000).toInt()); - ui.niceTooltipOpacitySlider->setValue(settings.value("nicetooltip_opacity",0).toInt()); + ui.transparencySlider->setValue(settings.value("nicetooltip_transparency",0).toInt()); ui.niceTooltipSplitCheckBox->setChecked(settings.value("split_file_name",TRUE).toBool()); #if QT_VERSION >= 0x040400 ui.standardIconsCheckBox->setChecked(settings.value("use_standard_icons",FALSE).toBool()); @@ -55,10 +54,9 @@ void SettingsDialog::accept() settings.beginGroup("Tray"); settings.setValue ("show_message", ui.messageGroupBox->isChecked()); settings.setValue ("message_delay", ui.messageDelaySpinBox->value()); - settings.setValue ("show_tooltip", ui.toolTipCheckBox->isChecked()); settings.setValue ("show_nicetooltip", ui.niceTooltipGroupBox->isChecked()); settings.setValue ("nicetooltip_delay", ui.niceTooltipDelaySpinBox->value()); - settings.setValue("nicetooltip_opacity", ui.niceTooltipOpacitySlider->value()); + settings.setValue ("nicetooltip_transparency", ui.transparencySlider->value()); settings.setValue("split_file_name", ui.niceTooltipSplitCheckBox->isChecked()); #if QT_VERSION >= 0x040400 settings.setValue ("use_standard_icons",ui.standardIconsCheckBox->isChecked()); @@ -66,8 +64,3 @@ void SettingsDialog::accept() settings.endGroup(); QDialog::accept(); } - -void SettingsDialog::on_niceTooltipOpacitySlider_valueChanged(int value) -{ - ui.niceTooltipOpacityValueLabel->setText(QString::number(value)); -} diff --git a/src/plugins/General/statusicon/settingsdialog.h b/src/plugins/General/statusicon/settingsdialog.h index 21d61a868..2983bcde9 100644 --- a/src/plugins/General/statusicon/settingsdialog.h +++ b/src/plugins/General/statusicon/settingsdialog.h @@ -1,5 +1,5 @@ /*************************************************************************** - * Copyright (C) 2008 by Ilya Kotov * + * Copyright (C) 2008-2009 by Ilya Kotov * * forkotov02@hotmail.ru * * * * This program is free software; you can redistribute it and/or modify * @@ -36,10 +36,8 @@ public: ~SettingsDialog(); - public slots: virtual void accept(); - void on_niceTooltipOpacitySlider_valueChanged (int value); private: Ui::SettingsDialog ui; diff --git a/src/plugins/General/statusicon/settingsdialog.ui b/src/plugins/General/statusicon/settingsdialog.ui index 4f1040258..c6d37b4f5 100644 --- a/src/plugins/General/statusicon/settingsdialog.ui +++ b/src/plugins/General/statusicon/settingsdialog.ui @@ -7,14 +7,23 @@ 0 0 340 - 348 + 237 Status Icon Plugin Settings - + + 6 + + + 6 + + + 6 + + Qt::Horizontal @@ -27,7 +36,7 @@ - + @@ -40,23 +49,26 @@ - + - Show nice tooltip + Tooltip + + + false true - + - Tooltip delay, ms + Delay, ms: - + 10000 @@ -69,40 +81,50 @@ - - + + - Tooltip opacity + Transparency: - - - - 100 - - - Qt::Horizontal - - - QSlider::NoTicks - - - - - - - - 3 - 0 - - - - 0 - - + + + + + + 100 + + + Qt::Horizontal + + + QSlider::NoTicks + + + + + + + + 3 + 0 + + + + + 20 + 0 + + + + 0 + + + + - + Try to split file name when no tag @@ -112,27 +134,33 @@ - + - Show message + Balloone message true - - + + - Message delay, ms: + Delay, ms: Qt::AlignLeading|Qt::AlignLeft|Qt::AlignVCenter - + + + + 0 + 0 + + 100 @@ -150,14 +178,7 @@ - - - - Show tooltip - - - - + Use standard icons @@ -175,8 +196,8 @@ accept() - 180 - 102 + 333 + 230 112 @@ -191,8 +212,8 @@ reject() - 242 - 107 + 333 + 230 27 @@ -200,5 +221,21 @@ + + transparencySlider + valueChanged(int) + niceTooltipOpacityValueLabel + setNum(int) + + + 166 + 127 + + + 309 + 129 + + + diff --git a/src/plugins/General/statusicon/statusicon.cpp b/src/plugins/General/statusicon/statusicon.cpp index 0d3b86efa..491e7a1af 100644 --- a/src/plugins/General/statusicon/statusicon.cpp +++ b/src/plugins/General/statusicon/statusicon.cpp @@ -1,5 +1,5 @@ /*************************************************************************** - * Copyright (C) 2008 by Ilya Kotov * + * Copyright (C) 2008-2009 by Ilya Kotov * * forkotov02@hotmail.ru * * * * This program is free software; you can redistribute it and/or modify * @@ -38,31 +38,19 @@ StatusIcon::StatusIcon(QObject *parent) : General(parent) { m_tray = new QmmpTrayIcon(this); - connect(m_tray, SIGNAL(activated(QSystemTrayIcon::ActivationReason)), this, SLOT(trayActivated(QSystemTrayIcon::ActivationReason))); + connect(m_tray, SIGNAL(activated(QSystemTrayIcon::ActivationReason)), SLOT(trayActivated(QSystemTrayIcon::ActivationReason))); //m_tray->show(); m_core = SoundCore::instance(); m_player = MediaPlayer::instance(); - QMenu *menu = new QMenu(qobject_cast(parent)); - menu->addAction(QIcon(":/tray_play.png"),tr("Play"), m_player, SLOT(play())); - menu->addAction(QIcon(":/tray_pause.png"),tr("Pause"), m_core, SLOT(pause())); - menu->addAction(QIcon(":/tray_stop.png"),tr("Stop"), m_core, SLOT(stop())); - menu->addSeparator(); - menu->addAction(tr("Next"), m_player, SLOT(next())); - menu->addAction(tr("Previous"), m_player, SLOT(previous())); - menu->addSeparator(); - menu->addAction(tr("Exit"), this, SLOT(exit())); - m_tray->setContextMenu(menu); - QSettings settings(Qmmp::configFile(), QSettings::IniFormat); settings.beginGroup("Tray"); m_showMessage = settings.value("show_message",TRUE).toBool(); m_messageDelay = settings.value("message_delay", 2000).toInt(); - m_showTooltip = settings.value("show_tooltip",FALSE).toBool(); m_hideToTray = settings.value("hide_on_close", FALSE).toBool(); m_useStandardIcons = settings.value("use_standard_icons",FALSE).toBool(); m_tray->showNiceToolTip(settings.value("show_nicetooltip",TRUE).toBool()); m_tray->setNiceToolTipDelay(settings.value("nicetooltip_delay",2000).toInt()); - m_tray->setNiceToolTipOpacity(1 - (settings.value("nicetooltip_opacity",0).toDouble()/100)); + m_tray->setNiceToolTipOpacity(1 - (settings.value("nicetooltip_transparency",0).toDouble()/100)); m_tray->setSplitFileName(settings.value("split_file_name",TRUE).toBool()); #if QT_VERSION >= 0x040400 if(m_useStandardIcons) @@ -72,6 +60,42 @@ StatusIcon::StatusIcon(QObject *parent) m_tray->setIcon ( QIcon(":/tray_stop.png")); m_tray->show(); settings.endGroup(); + //actions + QMenu *menu = new QMenu(qobject_cast(parent)); + QIcon playIcon; + QIcon pauseIcon; + QIcon stopIcon; + QIcon nextIcon; + QIcon previousIcon; +#if QT_VERSION >= 0x040400 + if(m_useStandardIcons) + { + playIcon = QApplication::style()->standardIcon(QStyle::SP_MediaPlay); + pauseIcon = QApplication::style()->standardIcon(QStyle::SP_MediaPause); + stopIcon = QApplication::style()->standardIcon(QStyle::SP_MediaStop); + nextIcon = QApplication::style()->standardIcon(QStyle::SP_MediaSkipForward); + previousIcon = QApplication::style()->standardIcon(QStyle::SP_MediaSkipBackward); + } + else + { +#endif + playIcon = QIcon(":/tray_play.png"); + pauseIcon = QIcon(":/tray_pause.png"); + stopIcon = QIcon(":/tray_stop.png"); + //TODO add more icons +#if QT_VERSION >= 0x040400 + } +#endif + menu->addAction(playIcon,tr("Play"), m_player, SLOT(play())); + menu->addAction(pauseIcon,tr("Pause"), m_core, SLOT(pause())); + menu->addAction(stopIcon,tr("Stop"), m_core, SLOT(stop())); + menu->addSeparator(); + menu->addAction(nextIcon, tr("Next"), m_player, SLOT(next())); + menu->addAction(previousIcon, tr("Previous"), m_player, SLOT(previous())); + menu->addSeparator(); + menu->addAction(tr("Exit"), this, SLOT(exit())); + m_tray->setContextMenu(menu); + connect (m_core, SIGNAL(metaDataChanged ()), SLOT(showMetaData())); connect (m_core, SIGNAL(stateChanged (Qmmp::State)), SLOT(setState(Qmmp::State))); setState(m_core->state()); //update state @@ -131,8 +155,6 @@ void StatusIcon::showMetaData() if (m_showMessage) m_tray->showMessage (tr("Now Playing"), message, QSystemTrayIcon::Information, m_messageDelay); - if (m_showTooltip) - m_tray->setToolTip(message); } void StatusIcon::trayActivated(QSystemTrayIcon::ActivationReason reason) diff --git a/src/plugins/General/statusicon/statusicon.h b/src/plugins/General/statusicon/statusicon.h index 9aa0937f1..ba3cd11e2 100644 --- a/src/plugins/General/statusicon/statusicon.h +++ b/src/plugins/General/statusicon/statusicon.h @@ -1,5 +1,5 @@ /*************************************************************************** - * Copyright (C) 2008 by Ilya Kotov * + * Copyright (C) 2008-2009 by Ilya Kotov * * forkotov02@hotmail.ru * * * * This program is free software; you can redistribute it and/or modify * @@ -20,9 +20,7 @@ #ifndef STATUSICON_H #define STATUSICON_H -//#include #include - #include #include #include @@ -52,7 +50,6 @@ private slots: private: QmmpTrayIcon *m_tray; bool m_showMessage; - bool m_showTooltip; bool m_hideToTray; bool m_useStandardIcons; int m_messageDelay; diff --git a/src/plugins/General/statusicon/statusiconfactory.cpp b/src/plugins/General/statusicon/statusiconfactory.cpp index 129414cc6..0c4eb883e 100644 --- a/src/plugins/General/statusicon/statusiconfactory.cpp +++ b/src/plugins/General/statusicon/statusiconfactory.cpp @@ -1,5 +1,5 @@ /*************************************************************************** - * Copyright (C) 2008 by Ilya Kotov * + * Copyright (C) 2008-2009 by Ilya Kotov * * forkotov02@hotmail.ru * * * * This program is free software; you can redistribute it and/or modify * @@ -49,7 +49,9 @@ void StatusIconFactory::showAbout(QWidget *parent) { QMessageBox::about (parent, tr("About Status Icon Plugin"), tr("Qmmp Status Icon Plugin")+"\n"+ - tr("Writen by: Ilya Kotov ")); + tr("Writen by:") + "\n"+ + tr("Ilya Kotov ") + + tr("Artur Guzik ")); } QTranslator *StatusIconFactory::createTranslator(QObject *parent) diff --git a/src/plugins/General/statusicon/statusiconpopupwidget.cpp b/src/plugins/General/statusicon/statusiconpopupwidget.cpp index ab1530bd4..dd5b25334 100644 --- a/src/plugins/General/statusicon/statusiconpopupwidget.cpp +++ b/src/plugins/General/statusicon/statusiconpopupwidget.cpp @@ -1,6 +1,28 @@ -#include "statusiconpopupwidget.h" -#include "qmmp/soundcore.h" - +/*************************************************************************** + * Copyright (C) 2009 by Artur Guzik * + * a.guzik88@gmail.com + * + * Copyright (C) 2009 by Ilya Kotov * + * forkotov02@hotmail.ru * + * * + * This program is free software; you can redistribute it and/or modify * + * it under the terms of the GNU General Public License as published by * + * the Free Software Foundation; either version 2 of the License, or * + * (at your option) any later version. * + * * + * This program is distributed in the hope that it will be useful, * + * but WITHOUT ANY WARRANTY; without even the implied warranty of * + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * + * GNU General Public License for more details. * + * * + * You should have received a copy of the GNU General Public License * + * along with this program; if not, write to the * + * Free Software Foundation, Inc., * + * 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. * + ***************************************************************************/ + +#include +#include #include #include #include @@ -8,40 +30,43 @@ #include #include #include +#include +#include +#include +#include "coverwidget.h" +#include "statusiconpopupwidget.h" StatusIconPopupWidget::StatusIconPopupWidget(QWidget * parent) : QFrame(parent) { setWindowFlags(Qt::X11BypassWindowManagerHint | Qt::WindowStaysOnTopHint | Qt::Dialog | Qt::FramelessWindowHint); - setFrameStyle(QFrame::StyledPanel | QFrame::Plain); - setLineWidth(0); - - setSizePolicy(QSizePolicy::Minimum,QSizePolicy::Minimum); - gLayout = new QGridLayout(this); - m_lblTitle = new QLabel(); - m_lblArtist = new QLabel(); - m_lblAlbum = new QLabel(); - m_lblTime = new QLabel(); + setFrameStyle(QFrame::NoFrame | QFrame::Plain); + setAttribute(Qt::WA_QuitOnClose, FALSE); + + m_hLayout = new QHBoxLayout(); + m_vLayout = new QVBoxLayout(); + + m_cover = new CoverWidget(this); + m_cover->setFixedSize(100,100); + m_hLayout->addWidget(m_cover); + + m_textLabel = new QLabel(this); + m_vLayout->addWidget(m_textLabel); + m_spacer = new QSpacerItem(20,0,QSizePolicy::Expanding,QSizePolicy::Expanding); - m_cover = new CoverWidget(); + m_vLayout->addItem(m_spacer); - m_cover->setMinimumSize(100,100); - m_cover->setMaximumSize(100,100); + m_bar = new TimeBar(this); + m_vLayout->addWidget(m_bar); - gLayout->addWidget(m_cover,0,0,5,1); - gLayout->addWidget(m_lblTitle,0,1); - gLayout->addWidget(m_lblArtist,1,1); - gLayout->addWidget(m_lblAlbum,2,1); - gLayout->addWidget(m_lblTime,3,1); - setLayout(gLayout); + m_hLayout->addLayout(m_vLayout); + setLayout(m_hLayout); m_timer = new QTimer(this); m_timer->setSingleShot(TRUE); - m_timer->stop(); - gLayout->addItem(m_spacer,4,1,1,1); - gLayout->setHorizontalSpacing(15); + m_bar->setMinimumWidth(110); connect(m_timer,SIGNAL(timeout()),SLOT(deleteLater())); connect(SoundCore::instance(),SIGNAL(metaDataChanged()),this,SLOT(updateMetaData())); @@ -62,13 +87,15 @@ void StatusIconPopupWidget::mousePressEvent(QMouseEvent *) void StatusIconPopupWidget::updateMetaData() { + m_timer->stop(); SoundCore *core = SoundCore::instance(); - if(core->state() == Qmmp::Playing) + 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()) { title = QFileInfo(core->metaData(Qmmp::URL)).completeBaseName(); @@ -78,92 +105,62 @@ void StatusIconPopupWidget::updateMetaData() title = title.section('-',1,1).trimmed(); } } - - m_lblTitle->setText("" + title + ""); - - if(!artist.isEmpty()) + text.append("" + title + ""); + if(core->totalTime() > 0) { - m_lblArtist->setText(artist); - m_lblArtist->setVisible(TRUE); + 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); } - else + if(!artist.isEmpty()) { - m_lblArtist->setVisible(FALSE); + text.append("
"); + text.append(artist); } - if(!album.isEmpty()) { - m_lblAlbum->setText(album); - m_lblAlbum->setVisible(TRUE); - } - else - { - m_lblAlbum->setVisible(FALSE); + text.append("
"); + text.append(album); } + if(year > 0) + text.append(QString("
%1").arg(year)); - QPixmap cover = Decoder::findCover(core->metaData(Qmmp::URL)); + m_textLabel->setText(text); + QPixmap cover = MetaDataManager::instance()->getCover(core->metaData(Qmmp::URL)); + m_cover->show(); + m_bar->show(); if(cover.isNull()) - { m_cover->setPixmap(QPixmap(":/empty_cover.png")); - m_cover->setVisible(TRUE); - } else - { m_cover->setPixmap(cover); - m_cover->setVisible(TRUE); - } - m_lblTime->setVisible(TRUE); - m_totalTime = totalTimeString(); - setVisible(TRUE); + updateTime(core->elapsed()); } else { - m_cover->setVisible(FALSE); - m_lblAlbum->setVisible(FALSE); - m_lblArtist->setVisible(FALSE); - m_lblTime->setVisible(FALSE); - m_lblTitle->setText("Nothing is playing"); - setVisible(FALSE); // + m_cover->hide(); + m_bar->hide(); + m_textLabel->setText(tr("Stopped")); } qApp->processEvents(); resize(sizeHint()); qApp->processEvents(); if(isVisible()) updatePosition(m_lastTrayX,m_lastTrayY); + m_timer->start(); } void StatusIconPopupWidget::updateTime(qint64 elapsed) { - int second = elapsed / 1000; - int minute = second / 60; - int hour = minute / 60; - - SoundCore * core = SoundCore::instance(); - - if(core->totalTime() > 3600000) - { - m_lblTime->setText(QString("%1:%2:%3").arg(hour,2,10,QChar('0')).arg(minute%60,2,10,QChar('0')) - .arg(second%60,2,10,QChar('0')) + "/" + m_totalTime); - return; - } - m_lblTime->setText(QString("%1:%2").arg(minute%60,2,10,QChar('0')).arg(second%60,2,10,QChar('0')) + - "/" + m_totalTime); -} - -QString StatusIconPopupWidget::totalTimeString() -{ - SoundCore * core = SoundCore::instance(); - - int second = core->totalTime() / 1000; - int minute = second / 60; - int hour = minute / 60; - - if(core->totalTime() > 3600000) - { - return QString("%1:%2:%3").arg(hour,2,10,QChar('0')).arg(minute%60,2,10,QChar('0')) - .arg(second%60,2,10,QChar('0')); - } - return QString("%1:%2").arg(minute%60,2,10,QChar('0')).arg(second%60,2,10,QChar('0')); + m_bar->setMaximum(SoundCore::instance()->totalTime()/1000); + m_bar->setValue(elapsed/1000); + m_bar->update(); } void StatusIconPopupWidget::updatePosition(int trayx, int trayy) @@ -204,4 +201,10 @@ void StatusIconPopupWidget::showInfo(int x, int y, int delay, bool splitFileName m_timer->start(); } +TimeBar::TimeBar(QWidget *parent) : QProgressBar(parent) +{} +QString TimeBar::text() const +{ + return QString("%1:%2").arg(value()/60,2,10,QChar('0')).arg(value()%60,2,10,QChar('0')); +} diff --git a/src/plugins/General/statusicon/statusiconpopupwidget.h b/src/plugins/General/statusicon/statusiconpopupwidget.h index 183074155..bcef0cc87 100644 --- a/src/plugins/General/statusicon/statusiconpopupwidget.h +++ b/src/plugins/General/statusicon/statusiconpopupwidget.h @@ -1,14 +1,40 @@ +/*************************************************************************** + * Copyright (C) 2009 by Artur Guzik * + * a.guzik88@gmail.com + * + * Copyright (C) 2009 by Ilya Kotov * + * forkotov02@hotmail.ru * + * * + * This program is free software; you can redistribute it and/or modify * + * it under the terms of the GNU General Public License as published by * + * the Free Software Foundation; either version 2 of the License, or * + * (at your option) any later version. * + * * + * This program is distributed in the hope that it will be useful, * + * but WITHOUT ANY WARRANTY; without even the implied warranty of * + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * + * GNU General Public License for more details. * + * * + * You should have received a copy of the GNU General Public License * + * along with this program; if not, write to the * + * Free Software Foundation, Inc., * + * 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. * + ***************************************************************************/ + #ifndef STATUSICONPOPUPWIDGET_H #define STATUSICONPOPUPWIDGET_H #include #include -#include -#include "plugins/General/covermanager/coverwidget.h" +#include class QLabel; class QTimer; - +class QHBoxLayout; +class QVBoxLayout; +class QSpacerItem; +class TimeBar; +class CoverWidget; class StatusIconPopupWidget : public QFrame { @@ -21,32 +47,34 @@ public: void showInfo(int x, int y, int delay, bool splitFileName); //x,y are tray icon position protected: - virtual void mousePressEvent(QMouseEvent *); -private: +private slots: + void updatePosition(int trayx, int trayy); + void updateMetaData(); + void updateTime(qint64 elapsed); - QString totalTimeString(); - QLabel *m_lblTitle; - QLabel *m_lblArtist; - QLabel *m_lblAlbum; - QLabel *m_lblTime; - QGridLayout * gLayout; +private: + QLabel *m_textLabel; + QHBoxLayout *m_hLayout; + QVBoxLayout *m_vLayout; QTimer *m_timer; CoverWidget * m_cover; QString m_totalTime; QSpacerItem *m_spacer; - + QProgressBar *m_bar; int m_lastTrayX; int m_lastTrayY; int m_splitFileName; +}; -private slots: - - void updatePosition(int trayx, int trayy); - void updateMetaData(); - void updateTime(qint64 elapsed); - +class TimeBar : public QProgressBar +{ + Q_OBJECT +public: + TimeBar(QWidget *parent = 0); + virtual QString text() const; }; + #endif // STATUSICONPOPUPWIDGET_H diff --git a/src/plugins/General/statusicon/translations/statusicon_plugin_cs.ts b/src/plugins/General/statusicon/translations/statusicon_plugin_cs.ts index 64225385e..ea5375581 100644 --- a/src/plugins/General/statusicon/translations/statusicon_plugin_cs.ts +++ b/src/plugins/General/statusicon/translations/statusicon_plugin_cs.ts @@ -9,22 +9,38 @@ Nastavení modulu stavové ikony - - Show message - Zobrazovat zprávu + + Tooltip + - - Show tooltip - Zobrazovat tooltip + + + Delay, ms: + - - Message delay (ms): - Prodleva zprávy (ms): + + Transparency: + - + + 0 + + + + + Try to split file name when no tag + + + + + Balloone message + + + + Use standard icons Použít standardní ikony @@ -32,37 +48,37 @@ StatusIcon - + Play Přehrát - + Pause Pauza - + Stop Stop - + Next Další - + Previous Předchozí - + Exit Ukončit - + Now Playing Nyní hraje @@ -81,8 +97,18 @@ - Writen by: Ilya Kotov <forkotov02@hotmail.ru> - Autor: Ilja Kotov <forkotov02@hotmail.ru> + Writen by: + + + + + Ilya Kotov <forkotov02@hotmail.ru> + + + + + Artur Guzik <a.guzik88@gmail.com> + @@ -90,4 +116,12 @@ O modulu stavové ikony + + StatusIconPopupWidget + + + Stopped + + + diff --git a/src/plugins/General/statusicon/translations/statusicon_plugin_de.ts b/src/plugins/General/statusicon/translations/statusicon_plugin_de.ts index 7e5f4094d..f49742546 100644 --- a/src/plugins/General/statusicon/translations/statusicon_plugin_de.ts +++ b/src/plugins/General/statusicon/translations/statusicon_plugin_de.ts @@ -9,22 +9,38 @@ Einstellungen Statussymbol-Modul - - Show message - Mitteilung anzeigen + + Tooltip + - - Show tooltip - Kurzinfo anzeigen + + + Delay, ms: + - - Message delay (ms): - Anzeigedauer der Nachricht (ms): + + Transparency: + - + + 0 + + + + + Try to split file name when no tag + + + + + Balloone message + + + + Use standard icons System-Symbole benutzen @@ -32,37 +48,37 @@ StatusIcon - + Play Wiedergabe - + Pause Pause - + Stop Stopp - + Next Nächster - + Previous Vorheriger - + Exit Beenden - + Now Playing Aktueller Titel @@ -81,8 +97,18 @@ - Writen by: Ilya Kotov <forkotov02@hotmail.ru> - Autor: Ilya Kotov <forkotov02@hotmail.ru> + Writen by: + + + + + Ilya Kotov <forkotov02@hotmail.ru> + + + + + Artur Guzik <a.guzik88@gmail.com> + @@ -90,4 +116,12 @@ Über Statussymbol-Modul + + StatusIconPopupWidget + + + Stopped + + + diff --git a/src/plugins/General/statusicon/translations/statusicon_plugin_it.ts b/src/plugins/General/statusicon/translations/statusicon_plugin_it.ts index da21f2020..912fc1c06 100644 --- a/src/plugins/General/statusicon/translations/statusicon_plugin_it.ts +++ b/src/plugins/General/statusicon/translations/statusicon_plugin_it.ts @@ -9,22 +9,38 @@ Impostazione del modulo icona di stato - - Show message - Mostra messaggi + + Tooltip + + + + + + Delay, ms: + + + + + Transparency: + + + + + 0 + - - Show tooltip - Mostra suggerimenti + + Try to split file name when no tag + - - Message delay (ms): + + Balloone message - + Use standard icons @@ -32,37 +48,37 @@ StatusIcon - + Play Esegui - + Pause Pausa - + Stop Ferma - + Next Successivo - + Previous Precedente - + Exit Esci - + Now Playing Brano in esecuzione: @@ -81,8 +97,18 @@ - Writen by: Ilya Kotov <forkotov02@hotmail.ru> - Autore: Ilya Kotov <forkotov02@hotmail.ru> + Writen by: + + + + + Ilya Kotov <forkotov02@hotmail.ru> + + + + + Artur Guzik <a.guzik88@gmail.com> + @@ -90,4 +116,12 @@ Info sul modulo icona di stato + + StatusIconPopupWidget + + + Stopped + + + diff --git a/src/plugins/General/statusicon/translations/statusicon_plugin_lt.ts b/src/plugins/General/statusicon/translations/statusicon_plugin_lt.ts index 42372e8cc..8e226e957 100644 --- a/src/plugins/General/statusicon/translations/statusicon_plugin_lt.ts +++ b/src/plugins/General/statusicon/translations/statusicon_plugin_lt.ts @@ -9,22 +9,38 @@ Status Icon įskiepio nustatymai - - Show message - Rodyti pranešimą + + Tooltip + + + + + + Delay, ms: + + + + + Transparency: + + + + + 0 + - - Show tooltip - Rodyti iššokantį balionėlį + + Try to split file name when no tag + - - Message delay (ms): + + Balloone message - + Use standard icons @@ -32,37 +48,37 @@ StatusIcon - + Play Groti - + Pause Pauzė - + Stop Stop - + Next Sekantis takelis - + Previous Ankstesnis takelis - + Exit Uždaryti - + Now Playing Dabar groju @@ -86,8 +102,26 @@ - Writen by: Ilya Kotov <forkotov02@hotmail.ru> - Sukūrė: Ilya Kotov <forkotov02@hotmail.ru> + Writen by: + + + + + Ilya Kotov <forkotov02@hotmail.ru> + + + + + Artur Guzik <a.guzik88@gmail.com> + + + + + StatusIconPopupWidget + + + Stopped + diff --git a/src/plugins/General/statusicon/translations/statusicon_plugin_pl.ts b/src/plugins/General/statusicon/translations/statusicon_plugin_pl.ts index d50fb254f..604a5d2f8 100644 --- a/src/plugins/General/statusicon/translations/statusicon_plugin_pl.ts +++ b/src/plugins/General/statusicon/translations/statusicon_plugin_pl.ts @@ -9,22 +9,38 @@ Ustawienia wtyczki Ikona Statusu - - Show message - Pokaż wiadomość + + Tooltip + - - Show tooltip - Pokaż chmurki + + + Delay, ms: + - - Message delay (ms): - Czas wyśw. wiadomości (ms): + + Transparency: + - + + 0 + + + + + Try to split file name when no tag + + + + + Balloone message + + + + Use standard icons Użyj standardowych ikon @@ -32,37 +48,37 @@ StatusIcon - + Play Odtwarzaj - + Pause Pauza - + Stop Zatrzymaj - + Next Następny - + Previous Poprzedni - + Exit Wyjdź - + Now Playing Teraz odtwarza @@ -86,8 +102,26 @@ - Writen by: Ilya Kotov <forkotov02@hotmail.ru> - Autor: Ilya Kotov <forkotov02@hotmail.ru> + Writen by: + + + + + Ilya Kotov <forkotov02@hotmail.ru> + + + + + Artur Guzik <a.guzik88@gmail.com> + + + + + StatusIconPopupWidget + + + Stopped + diff --git a/src/plugins/General/statusicon/translations/statusicon_plugin_ru.ts b/src/plugins/General/statusicon/translations/statusicon_plugin_ru.ts index f84454989..7f468b9e0 100644 --- a/src/plugins/General/statusicon/translations/statusicon_plugin_ru.ts +++ b/src/plugins/General/statusicon/translations/statusicon_plugin_ru.ts @@ -9,22 +9,38 @@ Настройки модуля Status Icon - - Show message - Показывать сообщение + + Tooltip + Всплывающая подсказка - - Show tooltip - Показывать всплывающую подсказку + + + Delay, ms: + Задержка, мс: - - Message delay (ms): - + + Transparency: + Прозрачность: - + + 0 + 0 + + + + Try to split file name when no tag + Разделить имя файла, если нет тегов + + + + Balloone message + Сообщение + + + Use standard icons Использовать стандартные иконки @@ -32,37 +48,37 @@ StatusIcon - + Play Воспроизвести - + Pause Пауза - + Stop Стоп - + Next Следующий фрагмент - + Previous Предыдущий фрагмент - + Exit Выход - + Now Playing Сейчас играет @@ -86,8 +102,26 @@ - Writen by: Ilya Kotov <forkotov02@hotmail.ru> - Разработчик: Илья Котов <forkotov02@hotmail.ru> + Writen by: + Разработчики: + + + + Ilya Kotov <forkotov02@hotmail.ru> + Илья Котов <orkotov02@hotmail.ru> + + + + Artur Guzik <a.guzik88@gmail.com> + Artur Guzik <a.guzik88@gmail.com> + + + + StatusIconPopupWidget + + + Stopped + Остановлено diff --git a/src/plugins/General/statusicon/translations/statusicon_plugin_tr.ts b/src/plugins/General/statusicon/translations/statusicon_plugin_tr.ts index 305bb394e..e32e41f37 100644 --- a/src/plugins/General/statusicon/translations/statusicon_plugin_tr.ts +++ b/src/plugins/General/statusicon/translations/statusicon_plugin_tr.ts @@ -9,22 +9,38 @@ Durum Simgesi Eklenti Ayarları - - Show message - Mesaj göster + + Tooltip + + + + + + Delay, ms: + + + + + Transparency: + + + + + 0 + - - Show tooltip - İpucu Göster + + Try to split file name when no tag + - - Message delay (ms): + + Balloone message - + Use standard icons Standart simgeleri kullan @@ -32,37 +48,37 @@ StatusIcon - + Play Oynat - + Pause Duraklat - + Stop Durdur - + Next Sonraki - + Previous Önceki - + Exit Çık - + Now Playing Şimdi Oynatılıyor @@ -86,8 +102,26 @@ - Writen by: Ilya Kotov <forkotov02@hotmail.ru> - Yazan: Ilya Kotov <forkotov02@hotmail.ru> + Writen by: + + + + + Ilya Kotov <forkotov02@hotmail.ru> + + + + + Artur Guzik <a.guzik88@gmail.com> + + + + + StatusIconPopupWidget + + + Stopped + diff --git a/src/plugins/General/statusicon/translations/statusicon_plugin_uk_UA.ts b/src/plugins/General/statusicon/translations/statusicon_plugin_uk_UA.ts index 9fc652d2b..bf511163b 100644 --- a/src/plugins/General/statusicon/translations/statusicon_plugin_uk_UA.ts +++ b/src/plugins/General/statusicon/translations/statusicon_plugin_uk_UA.ts @@ -9,22 +9,38 @@ Налаштування модуля Status Icon - - Show message - Показувати повідомлення + + Tooltip + - - Show tooltip - Показувати спливаючу підказку + + + Delay, ms: + - - Message delay (ms): - Затримка повідомлення (мс): + + Transparency: + - + + 0 + + + + + Try to split file name when no tag + + + + + Balloone message + + + + Use standard icons Використовувати стандартну іконку @@ -32,37 +48,37 @@ StatusIcon - + Play Грати - + Pause Пауза - + Stop Стоп - + Next Вперед - + Previous Назад - + Exit Вихід - + Now Playing Зараз грає @@ -86,8 +102,26 @@ - Writen by: Ilya Kotov <forkotov02@hotmail.ru> - Розробник: Ілля Котов <forkotov02@hotmail.ru> + Writen by: + + + + + Ilya Kotov <forkotov02@hotmail.ru> + + + + + Artur Guzik <a.guzik88@gmail.com> + + + + + StatusIconPopupWidget + + + Stopped + diff --git a/src/plugins/General/statusicon/translations/statusicon_plugin_zh_CN.ts b/src/plugins/General/statusicon/translations/statusicon_plugin_zh_CN.ts index 32dcfafa4..e06e6466f 100644 --- a/src/plugins/General/statusicon/translations/statusicon_plugin_zh_CN.ts +++ b/src/plugins/General/statusicon/translations/statusicon_plugin_zh_CN.ts @@ -9,22 +9,38 @@ 状态图标插件设置 - - Show message - 显示消息 + + Tooltip + + + + + + Delay, ms: + + + + + Transparency: + + + + + 0 + - - Show tooltip - 显示工具提示 + + Try to split file name when no tag + - - Message delay (ms): + + Balloone message - + Use standard icons 使用标准图标 @@ -32,37 +48,37 @@ StatusIcon - + Play 播放 - + Pause 暂停 - + Stop 停止 - + Next 下一曲 - + Previous 上一曲 - + Exit 退出 - + Now Playing 正在播放 @@ -81,8 +97,18 @@ - Writen by: Ilya Kotov <forkotov02@hotmail.ru> - 作者:Ilya Kotov <forkotov02@hotmail.ru> + Writen by: + + + + + Ilya Kotov <forkotov02@hotmail.ru> + + + + + Artur Guzik <a.guzik88@gmail.com> + @@ -90,4 +116,12 @@ 关于状态图标插件 + + StatusIconPopupWidget + + + Stopped + + + diff --git a/src/plugins/General/statusicon/translations/statusicon_plugin_zh_TW.ts b/src/plugins/General/statusicon/translations/statusicon_plugin_zh_TW.ts index 0b7cb1e5e..ce7d11c17 100644 --- a/src/plugins/General/statusicon/translations/statusicon_plugin_zh_TW.ts +++ b/src/plugins/General/statusicon/translations/statusicon_plugin_zh_TW.ts @@ -9,22 +9,38 @@ 狀態圖像插件設定 - - Show message - 察看訊息 + + Tooltip + + + + + + Delay, ms: + + + + + Transparency: + + + + + 0 + - - Show tooltip - 察看工具輔助說明 + + Try to split file name when no tag + - - Message delay (ms): + + Balloone message - + Use standard icons 使用標准圖標 @@ -32,37 +48,37 @@ StatusIcon - + Play 播放 - + Pause 暫停 - + Stop 停止 - + Next 下一曲 - + Previous 上一曲 - + Exit 結束 - + Now Playing 正在播放 @@ -81,8 +97,18 @@ - Writen by: Ilya Kotov <forkotov02@hotmail.ru> - 作者:Ilya Kotov <forkotov02@hotmail.ru> + Writen by: + + + + + Ilya Kotov <forkotov02@hotmail.ru> + + + + + Artur Guzik <a.guzik88@gmail.com> + @@ -90,4 +116,12 @@ 關於狀態圖像插件 + + StatusIconPopupWidget + + + Stopped + + + -- cgit v1.2.3-13-gbd6f