From c7772617a3448ba28befbabf4666ad7e7d20661e Mon Sep 17 00:00:00 2001 From: hawkeyexp Date: Fri, 21 Sep 2018 13:20:22 +0200 Subject: [PATCH] Add album next/prev and optimize gui --- .../f1x/openauto/autoapp/UI/MainWindow.hpp | 7 +- src/autoapp/UI/MainWindow.cpp | 47 +- src/autoapp/UI/mainwindow.ui | 705 ++++++++++++++---- 3 files changed, 597 insertions(+), 162 deletions(-) diff --git a/include/f1x/openauto/autoapp/UI/MainWindow.hpp b/include/f1x/openauto/autoapp/UI/MainWindow.hpp index d431b5a..f383114 100644 --- a/include/f1x/openauto/autoapp/UI/MainWindow.hpp +++ b/include/f1x/openauto/autoapp/UI/MainWindow.hpp @@ -121,13 +121,16 @@ private slots: void on_mp3List_itemClicked(QListWidgetItem *item); void metaDataChanged(); void on_pushButtonPlayerPlayList_clicked(); - void on_pushButtonNextBig_clicked(); - void on_pushButtonPrevBig_clicked(); + void on_pushButtonPlayerNextBig_clicked(); + void on_pushButtonPlayerPrevBig_clicked(); + void on_pushButtonPlayerPrevAlbum_clicked(); + void on_pushButtonPlayerNextAlbum_clicked(); void on_comboBoxAlbum_currentIndexChanged(const QString &arg1); void on_mp3List_currentRowChanged(int currentRow); void scanFolders(); void scanFiles(); + private: Ui::MainWindow* ui_; QString brightnessFilename = "/sys/class/backlight/rpi_backlight/brightness"; diff --git a/src/autoapp/UI/MainWindow.cpp b/src/autoapp/UI/MainWindow.cpp index e2a15ad..31390a4 100644 --- a/src/autoapp/UI/MainWindow.cpp +++ b/src/autoapp/UI/MainWindow.cpp @@ -1224,6 +1224,7 @@ void f1x::openauto::autoapp::ui::MainWindow::on_pushButtonPlayerStop_clicked() ui_->PlayerPlayingWidget->hide(); ui_->playerPositionTime->setText("00:00 / 00:00"); ui_->labelCurrentPlaying->setText(""); + ui_->labelTrack->setText(""); } void f1x::openauto::autoapp::ui::MainWindow::on_pushButtonPlayerPause_clicked() @@ -1305,6 +1306,9 @@ void f1x::openauto::autoapp::ui::MainWindow::metaDataChanged() } QString Title = player->metaData(QMediaMetaData::Title).toString(); QString AlbumInterpret = player->metaData(QMediaMetaData::AlbumArtist).toString(); + if (AlbumInterpret == "" && ui_->comboBoxAlbum->currentText() != ".") { + AlbumInterpret = ui_->comboBoxAlbum->currentText(); + } QString currentPlaying = ""; if (AlbumInterpret != "") { currentPlaying.append(AlbumInterpret); @@ -1318,6 +1322,8 @@ void f1x::openauto::autoapp::ui::MainWindow::metaDataChanged() ui_->labelCurrentPlaying->setText(currentPlaying); QString fullpathplaying = player->currentMedia().canonicalUrl().toString(); QString filename = QFileInfo(fullpathplaying).fileName(); + ui_->labelTrack->setText(QString::number(playlist->currentIndex()+1)); + ui_->labelTrackCount->setText(QString::number(playlist->mediaCount())); } void f1x::openauto::autoapp::ui::MainWindow::on_pushButtonPlayerPlayList_clicked() @@ -1328,6 +1334,8 @@ void f1x::openauto::autoapp::ui::MainWindow::on_pushButtonPlayerPlayList_clicked ui_->mp3selectWidget->hide(); ui_->PlayerPlayingWidget->show(); ui_->pushButtonPlayerPause->setStyleSheet( "background-color: rgb(233, 185, 110); border-radius: 4px; border: 2px solid rgba(255,255,255,0.5); color: rgb(0,0,0);"); + int currentalbum = ui_->comboBoxAlbum->currentIndex(); + ui_->labelCurrentAlbumIndex->setText(QString::number(currentalbum+1)); } void f1x::openauto::autoapp::ui::MainWindow::on_comboBoxAlbum_currentIndexChanged(const QString &arg1) @@ -1348,6 +1356,7 @@ void f1x::openauto::autoapp::ui::MainWindow::scanFolders() foreach (QString foldername, folders) { if (foldername != "..") { ui_->comboBoxAlbum->addItem(foldername); + ui_->labelAlbumCount->setText(QString::number(ui_->comboBoxAlbum->count())); } } this->currentPlaylistIndex = 0; @@ -1381,12 +1390,46 @@ void f1x::openauto::autoapp::ui::MainWindow::on_mp3List_currentRowChanged(int cu this->currentPlaylistIndex = currentRow; } -void f1x::openauto::autoapp::ui::MainWindow::on_pushButtonNextBig_clicked() +void f1x::openauto::autoapp::ui::MainWindow::on_pushButtonPlayerNextBig_clicked() { playlist->next(); } -void f1x::openauto::autoapp::ui::MainWindow::on_pushButtonPrevBig_clicked() +void f1x::openauto::autoapp::ui::MainWindow::on_pushButtonPlayerPrevBig_clicked() { playlist->previous(); } + +void f1x::openauto::autoapp::ui::MainWindow::on_pushButtonPlayerPrevAlbum_clicked() +{ + int albumcount = ui_->comboBoxAlbum->count(); + int currentalbum = ui_->comboBoxAlbum->currentIndex(); + if (currentalbum >= 1) { + currentalbum = currentalbum-1; + ui_->comboBoxAlbum->setCurrentIndex(currentalbum); + ui_->labelCurrentAlbumIndex->setText(QString::number(currentalbum+1)); + player->play(); + } else { + currentalbum = albumcount-1; + ui_->comboBoxAlbum->setCurrentIndex(currentalbum); + ui_->labelCurrentAlbumIndex->setText(QString::number(currentalbum+1)); + player->play(); + } +} + +void f1x::openauto::autoapp::ui::MainWindow::on_pushButtonPlayerNextAlbum_clicked() +{ + int albumcount = ui_->comboBoxAlbum->count(); + int currentalbum = ui_->comboBoxAlbum->currentIndex(); + if (currentalbum < albumcount-1) { + currentalbum = currentalbum + 1; + ui_->comboBoxAlbum->setCurrentIndex(currentalbum); + ui_->labelCurrentAlbumIndex->setText(QString::number(currentalbum+1)); + player->play(); + } else { + currentalbum = 0; + ui_->comboBoxAlbum->setCurrentIndex(currentalbum); + ui_->labelCurrentAlbumIndex->setText(QString::number(currentalbum+1)); + player->play(); + } +} diff --git a/src/autoapp/UI/mainwindow.ui b/src/autoapp/UI/mainwindow.ui index 89af723..4fa9261 100644 --- a/src/autoapp/UI/mainwindow.ui +++ b/src/autoapp/UI/mainwindow.ui @@ -6,8 +6,8 @@ 0 0 - 936 - 1286 + 956 + 1296 @@ -2302,6 +2302,9 @@ outline: none; Qt::ScrollBarAsNeeded + + QAbstractScrollArea::AdjustIgnored + 16 @@ -2311,10 +2314,19 @@ outline: none; QListView::Static + + false + + + QListView::Adjust + + + QListView::SinglePass + 0 - 20 + 30 @@ -2323,6 +2335,86 @@ outline: none; false + + + Neues Element + + + + + Neues Element + + + + + Neues Element + + + + + Neues Element + + + + + Neues Element + + + + + Neues Element + + + + + Neues Element + + + + + Neues Element + + + + + Neues Element + + + + + Neues Element + + + + + Neues Element + + + + + Neues Element + + + + + Neues Element + + + + + Neues Element + + + + + Neues Element + + + + + Neues Element + + @@ -2353,82 +2445,225 @@ outline: none; 0 - - - - 0 - 0 - - - - - 100 - 0 - - - - - 100 - 16777215 - - - - outline: none; - - - - - - - :/prevbig-hot.png - - - - - 128 - 140 - - - - - - - - - 0 - 0 - - - - - 100 - 0 - - - - - 100 - 16777215 - - - - outline: none; - - - - - - - :/prevbig-hot.png - - - - - 128 - 160 - - - + + + + + + + Qt::Horizontal + + + + 40 + 20 + + + + + + + + + 0 + 0 + + + + + 12 + 75 + true + + + + color: rgb(255, 255, 255); + + + Title + + + + + + + + 0 + 0 + + + + + 12 + 75 + true + + + + color: rgb(255, 255, 255); +background-color: rgba(0, 0, 0, 0); + + + + + + Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter + + + + + + + + 0 + 0 + + + + + 20 + 0 + + + + + 20 + 16777215 + + + + + 12 + 75 + true + + + + color: rgb(255, 255, 255); + + + / + + + Qt::AlignCenter + + + + + + + + 12 + 75 + true + + + + color: rgb(255, 255, 255); + + + + + + + + + + Qt::Horizontal + + + + 40 + 20 + + + + + + + + + + + + + 0 + 0 + + + + + 100 + 0 + + + + + 100 + 16777215 + + + + outline: none; + + + + + + + :/prevbig-hot.png + + + + + 128 + 140 + + + + + + + + + 0 + 0 + + + + + 100 + 0 + + + + + 100 + 16777215 + + + + outline: none; + + + + + + + :/prevbig-hot.png + + + + + 128 + 160 + + + + + + + @@ -2477,82 +2712,236 @@ outline: none; - - - - 0 - 0 - - - - - 100 - 0 - - - - - 100 - 16777215 - - - - outline: none; - - - - - - - :/nextbig-hot.png - - - - - 128 - 160 - - - - - - - - - 0 - 0 - - - - - 100 - 0 - - - - - 100 - 16777215 - - - - outline: none; - - - - - - - :/nextbig-hot.png - - - - - 128 - 140 - - - + + + + + + + Qt::Horizontal + + + + 1 + 1 + + + + + + + + + 0 + 0 + + + + + 12 + 75 + true + + + + color: rgb(255, 255, 255); + + + Album + + + Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter + + + + + + + + 0 + 0 + + + + + 12 + 75 + true + + + + color: rgb(255, 255, 255); + + + + + + Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter + + + + + + + + 0 + 0 + + + + + 20 + 0 + + + + + 20 + 16777215 + + + + + 12 + 75 + true + + + + color: rgb(255, 255, 255); + + + / + + + Qt::AlignCenter + + + + + + + + 0 + 0 + + + + + 12 + 75 + true + + + + color: rgb(255, 255, 255); + + + + + + Qt::AlignLeading|Qt::AlignLeft|Qt::AlignVCenter + + + + + + + Qt::Horizontal + + + + 1 + 1 + + + + + + + + + + + + + 0 + 0 + + + + + 100 + 0 + + + + + 100 + 16777215 + + + + outline: none; + + + + + + + :/nextbig-hot.png + + + + + 128 + 160 + + + + + + + + + 0 + 0 + + + + + 100 + 0 + + + + + 100 + 16777215 + + + + outline: none; + + + + + + + :/nextbig-hot.png + + + + + 128 + 140 + + + + + + + @@ -2678,7 +3067,7 @@ color: rgb(255, 255, 255); 150 - 17 + 16 @@ -2708,13 +3097,13 @@ background-color: rgba(0, 0, 0, 0); 0 - 10 + 20 16777215 - 10 + 20