Audio: small design improvements

This commit is contained in:
Nicolas Mailloux 2023-07-24 21:36:02 -04:00
parent dad0a8468d
commit e872cedf3f
4 changed files with 14 additions and 14 deletions

View file

@ -220,7 +220,7 @@ namespace global {
inline QVector<Action> currentAction; inline QVector<Action> currentAction;
inline QVector<musicFile> queue; inline QVector<musicFile> queue;
inline QVector<musicFile> fileList; inline QVector<musicFile> fileList;
inline int itemCurrentlyPlaying = -1; // Also indicates in the queue menu which a grey color which is playing inline int itemCurrentlyPlaying = -1; // Also indicates in the queue menu which a gray color which is playing
inline QMutex audioMutex; // These variables will be shared between threads, so here, it's to protect it inline QMutex audioMutex; // These variables will be shared between threads, so here, it's to protect it
inline int progressSeconds = -5; // -5 at default to avoid cutting song too early... yea inline int progressSeconds = -5; // -5 at default to avoid cutting song too early... yea
inline bool paused = false; inline bool paused = false;

View file

@ -62,7 +62,7 @@ audioDialog::audioDialog(QWidget *parent) :
ui->fileNameLabel->setWordWrap(true); ui->fileNameLabel->setWordWrap(true);
// Default "page" // Default "page"
ui->libraryBtn->setStyleSheet("background: grey;"); ui->libraryBtn->setStyleSheet("background: #aeadac;");
ui->refreshBtn->setIcon(QIcon(":/resources/refresh-small.png")); ui->refreshBtn->setIcon(QIcon(":/resources/refresh-small.png"));
ui->refreshBtn->hide(); ui->refreshBtn->hide();
ui->lineRefresh->hide(); ui->lineRefresh->hide();
@ -114,7 +114,7 @@ void audioDialog::changeMenu() {
ui->lineRefresh->show(); ui->lineRefresh->show();
ui->refreshBtn->setIcon(QIcon(":/resources/clean.png")); ui->refreshBtn->setIcon(QIcon(":/resources/clean.png"));
ui->libraryBtn->setStyleSheet("background: white;"); ui->libraryBtn->setStyleSheet("background: white;");
ui->queueBtn->setStyleSheet("background: grey;"); ui->queueBtn->setStyleSheet("background: #aeadac;");
refreshAudioFileWidgetsQueue(); refreshAudioFileWidgetsQueue();
} }
else if(currentMenu != Library){ else if(currentMenu != Library){
@ -122,7 +122,7 @@ void audioDialog::changeMenu() {
emit deleteItself(); emit deleteItself();
ui->refreshBtn->hide(); ui->refreshBtn->hide();
ui->lineRefresh->hide(); ui->lineRefresh->hide();
ui->libraryBtn->setStyleSheet("background: grey;"); ui->libraryBtn->setStyleSheet("background: #aeadac;");
ui->queueBtn->setStyleSheet("background: white;"); ui->queueBtn->setStyleSheet("background: white;");
refreshAudioFileWidgets(); refreshAudioFileWidgets();
} }
@ -152,7 +152,7 @@ void audioDialog::refreshFileList() {
} }
// For example in this path: /mnt/onboard/onboard/music/ ( with / at the end ) // For example in this path: /mnt/onboard/onboard/music/ ( with / at the end )
QString path = readFile(".config/e-2-audio/path").replace("\n", ""); QString path = readFile(".config/e-2-audio/path").replace("\n", "");
log("Path for audio files: " + path, className); log("Path for audio files: '" + path + "'", className);
QDir dir{path}; QDir dir{path};
// Other file formats could be added, by building more libraries // Other file formats could be added, by building more libraries
// https://github.com/arnavyc/sndfile-alsa-example/blob/main/src/sndfile-alsa.c // https://github.com/arnavyc/sndfile-alsa-example/blob/main/src/sndfile-alsa.c
@ -248,12 +248,12 @@ void audioDialog::refreshAudioFileWidgetsQueue() {
for(int i = 0; i < global::audio::queue.size(); i++) { for(int i = 0; i < global::audio::queue.size(); i++) {
log("Adding new item: " + QString::number(i), className); log("Adding new item: " + QString::number(i), className);
audiofilequeue* newAudioFileQueue = new audiofilequeue(this); audiofilequeue* newAudioFileQueue = new audiofilequeue(this);
bool grey = false; bool gray = false;
if(global::audio::isSomethingCurrentlyPlaying == true && global::audio::itemCurrentlyPlaying == i) { if(global::audio::isSomethingCurrentlyPlaying == true && global::audio::itemCurrentlyPlaying == i) {
grey = true; gray = true;
} }
global::audio::queue[i].id = i; // Give them invidual ID once more, because files can repeat global::audio::queue[i].id = i; // Give them invidual ID once more, because files can repeat
newAudioFileQueue->provideData(global::audio::queue[i], grey); newAudioFileQueue->provideData(global::audio::queue[i], gray);
QObject::connect(this, &audioDialog::deleteItself, newAudioFileQueue, &audiofilequeue::die); QObject::connect(this, &audioDialog::deleteItself, newAudioFileQueue, &audiofilequeue::die);
QObject::connect(newAudioFileQueue, &audiofilequeue::playFileChild, this, &audioDialog::playFile); QObject::connect(newAudioFileQueue, &audiofilequeue::playFileChild, this, &audioDialog::playFile);
ui->verticalLayout->addWidget(newAudioFileQueue, Qt::AlignTop); ui->verticalLayout->addWidget(newAudioFileQueue, Qt::AlignTop);

View file

@ -16,14 +16,14 @@ audiofilequeue::~audiofilequeue()
delete ui; delete ui;
} }
void audiofilequeue::provideData(global::audio::musicFile fileProvided, bool grey) { void audiofilequeue::provideData(global::audio::musicFile fileProvided, bool gray) {
file = fileProvided; file = fileProvided;
ui->nameLabel->setText(file.name); ui->nameLabel->setText(file.name);
ui->timeLabel->setText(file.length); ui->timeLabel->setText(file.length);
if(grey == true) { if(gray == true) {
log("Setting background grey", className); log("Setting background gray", className);
ui->deleteBtn->setStyleSheet("background: grey;"); ui->deleteBtn->setStyleSheet("background: #aeadac;");
ui->playButton->setStyleSheet("background: grey;"); ui->playButton->setStyleSheet("background: #aeadac;");
isPlaying = true; isPlaying = true;
} }
} }

View file

@ -18,7 +18,7 @@ public:
QString className = this->metaObject()->className(); QString className = this->metaObject()->className();
bool isPlaying = false; bool isPlaying = false;
void provideData(global::audio::musicFile fileProvided, bool grey); void provideData(global::audio::musicFile fileProvided, bool gray);
global::audio::musicFile file; global::audio::musicFile file;
public slots: public slots: