diff options
| author | trialuser02 <trialuser02@90c681e8-e032-0410-971d-27865f9a5e38> | 2019-12-03 20:54:25 +0000 |
|---|---|---|
| committer | trialuser02 <trialuser02@90c681e8-e032-0410-971d-27865f9a5e38> | 2019-12-03 20:54:25 +0000 |
| commit | d3e52b51bfb4af2209a35acb7a35416feb5f7022 (patch) | |
| tree | b97f63df05c4fca3185d0cba4acb308f099722b8 /src/plugins/Ui/skinned | |
| parent | 6c193279676df812287a3c7695663c29e1b444a5 (diff) | |
| download | qmmp-d3e52b51bfb4af2209a35acb7a35416feb5f7022.tar.gz qmmp-d3e52b51bfb4af2209a35acb7a35416feb5f7022.tar.bz2 qmmp-d3e52b51bfb4af2209a35acb7a35416feb5f7022.zip | |
skinned: fixed playlist duration update
git-svn-id: http://svn.code.sf.net/p/qmmp-dev/code/trunk/qmmp@9131 90c681e8-e032-0410-971d-27865f9a5e38
Diffstat (limited to 'src/plugins/Ui/skinned')
| -rw-r--r-- | src/plugins/Ui/skinned/playlist.cpp | 38 | ||||
| -rw-r--r-- | src/plugins/Ui/skinned/playlist.h | 4 |
2 files changed, 32 insertions, 10 deletions
diff --git a/src/plugins/Ui/skinned/playlist.cpp b/src/plugins/Ui/skinned/playlist.cpp index 80833192a..72d5ae2b4 100644 --- a/src/plugins/Ui/skinned/playlist.cpp +++ b/src/plugins/Ui/skinned/playlist.cpp @@ -135,13 +135,15 @@ PlayList::PlayList (PlayListManager *manager, QWidget *parent) m_titleBar = new PlayListTitleBar (this); m_titleBar->setMinimumSize(0,0); - m_titleBar->move (0,0); - connect (m_pl_manager, SIGNAL(currentPlayListChanged(PlayListModel *, PlayListModel *)), - m_titleBar, SLOT(setModel(PlayListModel*))); + m_titleBar->move(0,0); + connect(m_pl_manager, SIGNAL(currentPlayListChanged(PlayListModel *, PlayListModel *)), + SLOT(onCurrentPlayListChanged(PlayListModel*,PlayListModel*))); + connect(m_pl_manager->currentPlayList(), SIGNAL(listChanged(int)), SLOT(onListChanged(int))); m_titleBar->setModel(m_pl_manager->currentPlayList()); setCursor(m_skin->getCursor(Skin::CUR_PNORMAL)); updatePositions(); + setTime(-1); } PlayList::~PlayList() @@ -545,16 +547,20 @@ QString PlayList::formatTime (int sec) void PlayList::setTime(qint64 time) { if (time < 0) - m_current_time->display ("--:--"); + m_current_time->display("--:--"); else - m_current_time->display (formatTime (time/1000)); + m_current_time->display(formatTime (time/1000)); m_current_time->update(); - if (SoundCore::instance()) + SoundCore *core = SoundCore::instance(); + if(core) { - QString str_length = formatTime (m_pl_manager->currentPlayList()->totalDuration() / 1000) + - "/" + formatTime (SoundCore::instance()->duration() / 1000); - m_length_totalLength->display (str_length); + QString str_length = formatTime(m_pl_manager->currentPlayList()->totalDuration() / 1000) + "/"; + if(core->state() == Qmmp::Playing || core->state() == Qmmp::Paused) + str_length.append(formatTime(core->duration() / 1000)); + else + str_length.append("--:--"); + m_length_totalLength->display(str_length); m_length_totalLength->update(); } } @@ -652,6 +658,20 @@ void PlayList::copySelectedMenuActionTriggered(QAction *action) targetPlayList->add(theCopy); } +void PlayList::onCurrentPlayListChanged(PlayListModel *current, PlayListModel *previous) +{ + m_titleBar->setModel(current); + connect(current, SIGNAL(listChanged(int)), SLOT(onListChanged(int))); + if(previous) + disconnect(current, SIGNAL(listChanged(int)), this, SLOT(onListChanged(int))); +} + +void PlayList::onListChanged(int flags) +{ + if(flags & PlayListModel::CURRENT || flags & PlayListModel::STRUCTURE) + setTime(-1); +} + void PlayList::setMinimalMode(bool b) { if(!m_shaded) diff --git a/src/plugins/Ui/skinned/playlist.h b/src/plugins/Ui/skinned/playlist.h index 9835a8e3a..0fd66edac 100644 --- a/src/plugins/Ui/skinned/playlist.h +++ b/src/plugins/Ui/skinned/playlist.h @@ -1,5 +1,5 @@ /*************************************************************************** - * Copyright (C) 2006-2016 by Ilya Kotov * + * Copyright (C) 2006-2019 by Ilya Kotov * * forkotov02@ya.ru * * * * This program is free software; you can redistribute it and/or modify * @@ -86,6 +86,8 @@ class PlayList : public QWidget void showPlayLists(); void generateCopySelectedMenu(); void copySelectedMenuActionTriggered(QAction *action); + void onCurrentPlayListChanged(PlayListModel *current, PlayListModel *previous); + void onListChanged(int flags); private: void updatePositions(); |
