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/playlist.cpp | |
| 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/playlist.cpp')
| -rw-r--r-- | src/plugins/Ui/skinned/playlist.cpp | 38 |
1 files changed, 29 insertions, 9 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) |
