mirror of
https://github.com/gtalent/sc9k.git
synced 2025-01-23 00:33:36 -06:00
[sc9k] Make song selector a QListWidget instead of QComboBox
This commit is contained in:
parent
68d963ab69
commit
7ca3b810fc
@ -15,7 +15,7 @@
|
|||||||
|
|
||||||
MainWindow::MainWindow(QWidget *parent): QMainWindow(parent) {
|
MainWindow::MainWindow(QWidget *parent): QMainWindow(parent) {
|
||||||
move(0, 0);
|
move(0, 0);
|
||||||
setFixedSize(600, 555);
|
setFixedSize(590, 555);
|
||||||
setWindowTitle(tr("Slide Controller 9000"));
|
setWindowTitle(tr("Slide Controller 9000"));
|
||||||
const auto mainWidget = new QWidget(this);
|
const auto mainWidget = new QWidget(this);
|
||||||
const auto rootLyt = new QVBoxLayout;
|
const auto rootLyt = new QVBoxLayout;
|
||||||
|
@ -8,15 +8,16 @@
|
|||||||
|
|
||||||
#include <QComboBox>
|
#include <QComboBox>
|
||||||
#include <QDebug>
|
#include <QDebug>
|
||||||
|
#include <QHBoxLayout>
|
||||||
#include <QHeaderView>
|
#include <QHeaderView>
|
||||||
|
#include <QListWidget>
|
||||||
#include <QTableWidget>
|
#include <QTableWidget>
|
||||||
#include <QVBoxLayout>
|
|
||||||
|
|
||||||
#include "slideview.hpp"
|
#include "slideview.hpp"
|
||||||
|
|
||||||
SlideView::SlideView(QWidget *parent): QWidget(parent) {
|
SlideView::SlideView(QWidget *parent): QWidget(parent) {
|
||||||
auto lyt = new QVBoxLayout(this);
|
auto lyt = new QHBoxLayout(this);
|
||||||
m_songSelector = new QComboBox(this);
|
m_songSelector = new QListWidget(this);
|
||||||
m_slideTable = new QTableWidget(this);
|
m_slideTable = new QTableWidget(this);
|
||||||
auto header = m_slideTable->horizontalHeader();
|
auto header = m_slideTable->horizontalHeader();
|
||||||
header->setVisible(false);
|
header->setVisible(false);
|
||||||
@ -35,17 +36,22 @@ SlideView::SlideView(QWidget *parent): QWidget(parent) {
|
|||||||
|
|
||||||
QString SlideView::getNextSong() const {
|
QString SlideView::getNextSong() const {
|
||||||
const auto cnt = m_songSelector->count();
|
const auto cnt = m_songSelector->count();
|
||||||
const auto idx = m_songSelector->currentIndex() + 1;
|
const auto idx = m_songSelector->currentRow() + 1;
|
||||||
if (idx < cnt) {
|
if (idx < cnt) {
|
||||||
return m_songSelector->itemText(idx);
|
return m_songSelector->currentItem()->text();
|
||||||
}
|
}
|
||||||
return "";
|
return "";
|
||||||
}
|
}
|
||||||
|
|
||||||
void SlideView::pollUpdate(QString songName, int slide) {
|
void SlideView::pollUpdate(QString songName, int slide) {
|
||||||
if (songName != m_currentSong) {
|
auto songItems = m_songSelector->findItems(songName, Qt::MatchExactly);
|
||||||
|
if (songItems.size() < 1) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
auto songItem = songItems.first();
|
||||||
|
if (songItem != m_songSelector->currentItem()) {
|
||||||
m_currentSong = songName;
|
m_currentSong = songName;
|
||||||
m_songSelector->setCurrentText(songName);
|
m_songSelector->setCurrentItem(songItem);
|
||||||
}
|
}
|
||||||
if (slide != m_currentSlide) {
|
if (slide != m_currentSlide) {
|
||||||
m_currentSlide = slide;
|
m_currentSlide = slide;
|
||||||
@ -54,7 +60,8 @@ void SlideView::pollUpdate(QString songName, int slide) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
void SlideView::changeSong(int song) {
|
void SlideView::changeSong(int song) {
|
||||||
if (m_songSelector->currentText() != m_currentSong) {
|
auto songItem = m_songSelector->item(song);
|
||||||
|
if (songItem->text() != m_currentSong) {
|
||||||
emit songChanged(song);
|
emit songChanged(song);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -13,12 +13,14 @@ class SlideView: public QWidget {
|
|||||||
Q_OBJECT
|
Q_OBJECT
|
||||||
private:
|
private:
|
||||||
class QTableWidget *m_slideTable = nullptr;
|
class QTableWidget *m_slideTable = nullptr;
|
||||||
class QComboBox *m_songSelector = nullptr;
|
class QListWidget *m_songSelector = nullptr;
|
||||||
QString m_currentSong;
|
QString m_currentSong;
|
||||||
int m_currentSlide = -1;
|
int m_currentSlide = -1;
|
||||||
|
|
||||||
public:
|
public:
|
||||||
explicit SlideView(QWidget *parent = nullptr);
|
explicit SlideView(QWidget *parent = nullptr);
|
||||||
|
|
||||||
|
[[nodiscard]]
|
||||||
QString getNextSong() const;
|
QString getNextSong() const;
|
||||||
|
|
||||||
public slots:
|
public slots:
|
||||||
|
Loading…
Reference in New Issue
Block a user