summaryrefslogtreecommitdiffstats
path: root/playerwidget.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'playerwidget.cpp')
-rw-r--r--playerwidget.cpp34
1 files changed, 25 insertions, 9 deletions
diff --git a/playerwidget.cpp b/playerwidget.cpp
index 1e4a7c6..c476f93 100644
--- a/playerwidget.cpp
+++ b/playerwidget.cpp
@@ -20,6 +20,7 @@
#include <QMenu>
#include <QMessageBox>
#include <QInputDialog>
+#include <QTimer>
#include <QApplication>
#include <algorithm>
@@ -35,8 +36,10 @@
#include "helper.h"
PlayerWidget::PlayerWidget(QWidget *parent) : QWidget(parent), mDurSecs(0), mPlayListLength(0){
+ mStarting = true;
setupGui();
createActions();
+ mStarting = false;
}
PlayerWidget::~PlayerWidget(){
@@ -53,6 +56,9 @@ void PlayerWidget::setupGui(){
mTrayIcon = new QSystemTrayIcon(this);
mTrayIcon->setIcon(QIcon(":/stop.png"));
mTrayIcon->show();
+ mVolumeTimer = new QTimer(this);
+ mVolumeTimer->setSingleShot(true);
+ connect(mVolumeTimer, &QTimer::timeout, this, &PlayerWidget::showVolume);
//THE view
mView = new BeetView;
@@ -633,7 +639,7 @@ void PlayerWidget::doPlay(){
emit playModeChanged(tr("Playing"));
emit setWinTitle(mCurWinTitle);
mTrayIcon->setIcon(QIcon(":/play.png"));
- mTrayIcon->setToolTip(mCurWinTitle);
+ mTrayIcon->setToolTip(mCurToolTip);
return;
}
int playListCount = mPlayListModel->rowCount();
@@ -727,6 +733,12 @@ void PlayerWidget::volumeDown(){
adjustVolume(-2);
}
+void PlayerWidget::showVolume(){
+ int volume = mVolumeSlider->value();
+ QString msg = QString(tr("Volume: %1%")).arg(volume, 3, 10, QChar('0'));
+ mTrayIcon->showMessage(msg, QString(), QSystemTrayIcon::Information, 2000);
+}
+
void PlayerWidget::adjustVolume(int by){
int curVol = mVolumeSlider->value();
int newVol = curVol + by;
@@ -971,7 +983,7 @@ void PlayerWidget::playCurrent(const QModelIndex &index){
QString fullPath = index.data(FullPathRole).toString();
play(fullPath);
mTrayIcon->setIcon(QIcon(":/play.png"));
- mTrayIcon->setToolTip(mCurWinTitle);
+ mTrayIcon->setToolTip(mCurToolTip);
}
void PlayerWidget::play(const QString &fullPath){
@@ -1004,13 +1016,11 @@ void PlayerWidget::play(const QString &fullPath){
mCurrentTE->append(QString("%1 %2:%3").arg(tr("Length:"), -20).arg(minutes, 2, 10, QChar('0')).arg(seconds, 2, 10, QChar('0')));
QString msg = QString("File: %1").arg(fullPath);
emit message(msg);
- mCurWinTitle = QString(tr("%1 [%2 - %3 - %4]")).arg(qApp->applicationName()).arg(artist).arg(album).arg(title);
+ mCurWinTitle = QString(tr("%1 - [%2] - [%3] - [%4]")).arg(qApp->applicationName()).arg(artist).arg(album).arg(title);
+ mCurToolTip = QString(tr("%1: [%2] - [%3]")).arg(artist).arg(album).arg(title);
+ mTrayIcon->setToolTip(mCurToolTip);
+ mTrayIcon->showMessage(QString(tr("Now Playing:")), mCurToolTip, QSystemTrayIcon::Information, 5000);
emit setWinTitle(mCurWinTitle);
- QString toolStr;
- toolStr.append("<html><body>");
- toolStr.append(QString("<p style=\"margin:7px;\"><span style=\"font-weight: bold; font-size: large;\">%1</span></p>").arg(artist));
- toolStr.append(QString("<p style=\"margin:7px;\"><span style=\"font-weight: normal; font-size: medium;\">%1</span></p>").arg(title));
- toolStr.append("</body></html>");
mPlayer->play();
mPlayA->setChecked(true);
@@ -1020,7 +1030,11 @@ void PlayerWidget::play(const QString &fullPath){
void PlayerWidget::volumeChanged(int volume){
QString s = QString("%1 %").arg(volume, 3, 10, QChar('0'));
mVolumePos->setText(s);
- QString tool = QString(tr("Volume: %1")).arg(s);
+ if(!mStarting){
+ if(!mVolumeTimer->isActive()){
+ mVolumeTimer->start(500);
+ }
+ }
}
void PlayerWidget::mute(bool triggered){
@@ -1096,11 +1110,13 @@ void PlayerWidget::expandRecursive(const QModelIndex &idx){
}
void PlayerWidget::readSettings(){
+ mStarting = true;
QSettings s;
int vol = s.value("volume").toInt();
mVolumeSlider->setValue(vol);
QString dir = s.value("folderdir", QDir::homePath()).toString();
mCurDir = dir;
+ mStarting = false;
}
void PlayerWidget::writeSettings(){