From a3b10c29c5041a4706bd2e4badf25c3269909aa6 Mon Sep 17 00:00:00 2001
From: Chris Xiong
- The data is an stream of raw RGBA values, where each color takes one byte in every pixel. The frame
+ The data is a stream of raw RGBA values, where each color takes one byte in every pixel. The frame
size is the same as used by the visualization module, and the frames should be played back at a fixed
frame rate. The pixel data starts from the bottom-left of a frame and follows row-major ordering (so
you may want to flip the frame when using the frame with some applications).
diff --git a/qmidiplayer-desktop/qmpmainwindow.cpp b/qmidiplayer-desktop/qmpmainwindow.cpp
index 456ae60..41c42c6 100644
--- a/qmidiplayer-desktop/qmpmainwindow.cpp
+++ b/qmidiplayer-desktop/qmpmainwindow.cpp
@@ -361,6 +361,8 @@ void qmpMainWindow::switchTrack(QString s, bool interrupt)
QString fns = s;
setWindowTitle(QUrl::fromLocalFile(fns).fileName().left(QUrl::fromLocalFile(fns).fileName().lastIndexOf('.')) + " - QMidiPlayer");
ui->lbFileName->setText(QUrl::fromLocalFile(fns).fileName().left(QUrl::fromLocalFile(fns).fileName().lastIndexOf('.')));
+ if (plistw->getCurrentItem() != fns)
+ plistw->setCurrentItem(fns);
onfnChanged();
if (!loadFile(fns))
return;
@@ -687,7 +689,7 @@ void qmpMainWindow::on_pbNext_clicked()
void qmpMainWindow::selectionChanged()
{
- switchTrack(plistw->getSelectedItem());
+ switchTrack(plistw->getCurrentItem());
}
void qmpMainWindow::on_lbFileName_customContextMenuRequested(const QPoint &pos)
@@ -793,8 +795,8 @@ void qmpMainWindow::startRender()
free(ifstr);
#else
fluidrenderer = new qmpFileRendererFluid(
- plistw->getSelectedItem().toStdString().c_str(),
- (plistw->getSelectedItem() + QString(".wav")).toStdString().c_str()
+ plistw->getCurrentItem().toStdString().c_str(),
+ (plistw->getCurrentItem() + QString(".wav")).toStdString().c_str()
);
playerSetup(fluidrenderer);
fluidrenderer->renderInit();
diff --git a/qmidiplayer-desktop/qmpplistwindow.cpp b/qmidiplayer-desktop/qmpplistwindow.cpp
index 59bea38..3a1062e 100644
--- a/qmidiplayer-desktop/qmpplistwindow.cpp
+++ b/qmidiplayer-desktop/qmpplistwindow.cpp
@@ -262,7 +262,7 @@ QString qmpPlistWindow::getFirstItem(bool a)
int id = 0;
if (shuffle && !a)
id = rand() % ui->lwFiles->count();
- ui->lwFiles->setCurrentRow(id);
+ setCurrentItem(ui->lwFiles->item(id));
return ui->lwFiles->item(id)->text();
}
QString qmpPlistWindow::getLastItem(bool a)
@@ -272,50 +272,72 @@ QString qmpPlistWindow::getLastItem(bool a)
int id = ui->lwFiles->count() - 1;
if (shuffle && !a)
id = rand() % ui->lwFiles->count();
- ui->lwFiles->setCurrentRow(id);
+ setCurrentItem(ui->lwFiles->item(id));
return ui->lwFiles->item(id)->text();
}
QString qmpPlistWindow::getNextItem()
{
- if (ui->lwFiles->count() == 0)
+ if (ui->lwFiles->count() == 0 || getCurrentItemIndex() == -1)
return QString();
if (repeat == 1)
- return ui->lwFiles->item(ui->lwFiles->currentRow())->text();
- int id = ui->lwFiles->currentRow();
+ return ui->lwFiles->item(getCurrentItemIndex())->text();
+ int id = getCurrentItemIndex();
++id;
id %= ui->lwFiles->count();
if (shuffle)
id = rand() % ui->lwFiles->count();
- ui->lwFiles->setCurrentRow(id);
+ setCurrentItem(ui->lwFiles->item(id));
return ui->lwFiles->item(id)->text();
}
QString qmpPlistWindow::getPrevItem()
{
- if (ui->lwFiles->count() == 0)
+ if (ui->lwFiles->count() == 0 || getCurrentItemIndex() == -1)
return QString();
if (repeat == 1)
return ui->lwFiles->item(ui->lwFiles->currentRow())->text();
- int id = ui->lwFiles->currentRow();
+ int id = getCurrentItemIndex();
--id;
id < 0 ? id += ui->lwFiles->count() : 0;
if (shuffle)
id = rand() % ui->lwFiles->count();
- ui->lwFiles->setCurrentRow(id);
+ setCurrentItem(ui->lwFiles->item(id));
return ui->lwFiles->item(id)->text();
}
-QString qmpPlistWindow::getSelectedItem()
+QString qmpPlistWindow::getCurrentItem()
{
- if (ui->lwFiles->count() == 0)
+ if (ui->lwFiles->count() == 0 || getCurrentItemIndex() == -1)
return QString();
- return ui->lwFiles->item(ui->lwFiles->currentRow())->text();
+ return ui->lwFiles->item(getCurrentItemIndex())->text();
}
+void qmpPlistWindow::setCurrentItem(QString item)
+{
+ for (int i = 0; i < ui->lwFiles->count(); ++i)
+ {
+ if (ui->lwFiles->item(i)->text() == item)
+ ui->lwFiles->item(i)->setData(Qt::ItemDataRole::BackgroundRole, QBrush(QColor(160, 160, 160)));
+ else
+ ui->lwFiles->item(i)->setData(Qt::ItemDataRole::BackgroundRole, QVariant());
+ }
+}
+void qmpPlistWindow::setCurrentItem(QListWidgetItem *item)
+{
+ for (int i = 0; i < ui->lwFiles->count(); ++i)
+ {
+ if (ui->lwFiles->item(i) == item)
+ ui->lwFiles->item(i)->setData(Qt::ItemDataRole::BackgroundRole, QBrush(QColor(160, 160, 160)));
+ else
+ ui->lwFiles->item(i)->setData(Qt::ItemDataRole::BackgroundRole, QVariant());
+ }
+}
+
int qmpPlistWindow::getRepeat()
{
return repeat;
}
-void qmpPlistWindow::on_lwFiles_itemDoubleClicked()
+void qmpPlistWindow::on_lwFiles_itemDoubleClicked(QListWidgetItem *item)
{
+ setCurrentItem(item);
emit selectionChanging();
}
@@ -376,6 +398,16 @@ void qmpPlistWindow::on_pbLoad_clicked()
}
delete plist;
}
+
+int qmpPlistWindow::getCurrentItemIndex()
+{
+ for (int i = 0; i < ui->lwFiles->count(); ++i)
+ {
+ if (ui->lwFiles->item(i)->data(Qt::ItemDataRole::BackgroundRole).value