Skip to content

Commit

Permalink
[fix]修复直接添加播放不高亮
Browse files Browse the repository at this point in the history
修复直接添加播放文件到播放窗口,播放列表不高亮
  • Loading branch information
itisyang committed Jun 23, 2018
1 parent 0bb21e6 commit 6e952a6
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 2 deletions.
10 changes: 9 additions & 1 deletion playerdemo/playlist.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -96,6 +96,7 @@ void Playlist::on_List_itemDoubleClicked(QListWidgetItem *item)
{
emit SigPlay(item->data(Qt::UserRole).toString());
m_nCurrentPlayListIndex = ui->List->row(item);
ui->List->setCurrentRow(m_nCurrentPlayListIndex);
}

bool Playlist::GetPlaylistStatus()
Expand All @@ -112,14 +113,21 @@ void Playlist::OnAddFile(QString strFileName)
{
QFileInfo fileInfo(strFileName);
QList<QListWidgetItem *> listItem = ui->List->findItems(fileInfo.fileName(), Qt::MatchExactly);
QListWidgetItem *pItem = nullptr;
if (listItem.isEmpty())
{
QListWidgetItem *pItem = new QListWidgetItem(ui->List);
pItem = new QListWidgetItem(ui->List);
pItem->setData(Qt::UserRole, QVariant(fileInfo.filePath())); // 用户数据
pItem->setText(fileInfo.fileName()); // 显示文本
pItem->setToolTip(fileInfo.filePath());
ui->List->addItem(pItem);
}
else
{
pItem = listItem.at(0);
}

on_List_itemDoubleClicked(pItem);
}

void Playlist::OnBackwardPlay()
Expand Down
2 changes: 1 addition & 1 deletion playerdemo/show.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -194,5 +194,5 @@ void Show::dropEvent(QDropEvent *event)
break;
}

emit SigPlay(urls.first().toLocalFile());
//emit SigPlay(urls.first().toLocalFile());
}

0 comments on commit 6e952a6

Please sign in to comment.