Add album next/prev and optimize gui

This commit is contained in:
hawkeyexp 2018-09-21 13:20:22 +02:00
parent f2e27a8d64
commit c7772617a3
3 changed files with 597 additions and 162 deletions

View File

@ -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";

View File

@ -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();
}
}

View File

@ -6,8 +6,8 @@
<rect>
<x>0</x>
<y>0</y>
<width>936</width>
<height>1286</height>
<width>956</width>
<height>1296</height>
</rect>
</property>
<property name="sizePolicy">
@ -2302,6 +2302,9 @@ outline: none;
<property name="horizontalScrollBarPolicy">
<enum>Qt::ScrollBarAsNeeded</enum>
</property>
<property name="sizeAdjustPolicy">
<enum>QAbstractScrollArea::AdjustIgnored</enum>
</property>
<property name="autoScrollMargin">
<number>16</number>
</property>
@ -2311,10 +2314,19 @@ outline: none;
<property name="movement">
<enum>QListView::Static</enum>
</property>
<property name="isWrapping" stdset="0">
<bool>false</bool>
</property>
<property name="resizeMode">
<enum>QListView::Adjust</enum>
</property>
<property name="layoutMode">
<enum>QListView::SinglePass</enum>
</property>
<property name="gridSize">
<size>
<width>0</width>
<height>20</height>
<height>30</height>
</size>
</property>
<property name="viewMode">
@ -2323,6 +2335,86 @@ outline: none;
<property name="sortingEnabled">
<bool>false</bool>
</property>
<item>
<property name="text">
<string>Neues Element</string>
</property>
</item>
<item>
<property name="text">
<string>Neues Element</string>
</property>
</item>
<item>
<property name="text">
<string>Neues Element</string>
</property>
</item>
<item>
<property name="text">
<string>Neues Element</string>
</property>
</item>
<item>
<property name="text">
<string>Neues Element</string>
</property>
</item>
<item>
<property name="text">
<string>Neues Element</string>
</property>
</item>
<item>
<property name="text">
<string>Neues Element</string>
</property>
</item>
<item>
<property name="text">
<string>Neues Element</string>
</property>
</item>
<item>
<property name="text">
<string>Neues Element</string>
</property>
</item>
<item>
<property name="text">
<string>Neues Element</string>
</property>
</item>
<item>
<property name="text">
<string>Neues Element</string>
</property>
</item>
<item>
<property name="text">
<string>Neues Element</string>
</property>
</item>
<item>
<property name="text">
<string>Neues Element</string>
</property>
</item>
<item>
<property name="text">
<string>Neues Element</string>
</property>
</item>
<item>
<property name="text">
<string>Neues Element</string>
</property>
</item>
<item>
<property name="text">
<string>Neues Element</string>
</property>
</item>
</widget>
</item>
</layout>
@ -2353,7 +2445,146 @@ outline: none;
<number>0</number>
</property>
<item>
<widget class="QPushButton" name="pushButton">
<layout class="QVBoxLayout" name="verticalLayout_5">
<item>
<layout class="QHBoxLayout" name="horizontalLayout_12">
<item>
<spacer name="horizontalSpacer_3">
<property name="orientation">
<enum>Qt::Horizontal</enum>
</property>
<property name="sizeHint" stdset="0">
<size>
<width>40</width>
<height>20</height>
</size>
</property>
</spacer>
</item>
<item>
<widget class="QLabel" name="label_4">
<property name="sizePolicy">
<sizepolicy hsizetype="Preferred" vsizetype="Preferred">
<horstretch>0</horstretch>
<verstretch>0</verstretch>
</sizepolicy>
</property>
<property name="font">
<font>
<pointsize>12</pointsize>
<weight>75</weight>
<bold>true</bold>
</font>
</property>
<property name="styleSheet">
<string notr="true">color: rgb(255, 255, 255);</string>
</property>
<property name="text">
<string>Title</string>
</property>
</widget>
</item>
<item>
<widget class="QLabel" name="labelTrack">
<property name="sizePolicy">
<sizepolicy hsizetype="Preferred" vsizetype="Preferred">
<horstretch>0</horstretch>
<verstretch>0</verstretch>
</sizepolicy>
</property>
<property name="font">
<font>
<pointsize>12</pointsize>
<weight>75</weight>
<bold>true</bold>
</font>
</property>
<property name="styleSheet">
<string notr="true">color: rgb(255, 255, 255);
background-color: rgba(0, 0, 0, 0);</string>
</property>
<property name="text">
<string/>
</property>
<property name="alignment">
<set>Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter</set>
</property>
</widget>
</item>
<item>
<widget class="QLabel" name="labelTrackDash">
<property name="sizePolicy">
<sizepolicy hsizetype="Fixed" vsizetype="Preferred">
<horstretch>0</horstretch>
<verstretch>0</verstretch>
</sizepolicy>
</property>
<property name="minimumSize">
<size>
<width>20</width>
<height>0</height>
</size>
</property>
<property name="maximumSize">
<size>
<width>20</width>
<height>16777215</height>
</size>
</property>
<property name="font">
<font>
<pointsize>12</pointsize>
<weight>75</weight>
<bold>true</bold>
</font>
</property>
<property name="styleSheet">
<string notr="true">color: rgb(255, 255, 255);</string>
</property>
<property name="text">
<string>/</string>
</property>
<property name="alignment">
<set>Qt::AlignCenter</set>
</property>
</widget>
</item>
<item>
<widget class="QLabel" name="labelTrackCount">
<property name="font">
<font>
<pointsize>12</pointsize>
<weight>75</weight>
<bold>true</bold>
</font>
</property>
<property name="styleSheet">
<string notr="true">color: rgb(255, 255, 255);</string>
</property>
<property name="text">
<string/>
</property>
</widget>
</item>
<item>
<spacer name="horizontalSpacer_4">
<property name="orientation">
<enum>Qt::Horizontal</enum>
</property>
<property name="sizeHint" stdset="0">
<size>
<width>40</width>
<height>20</height>
</size>
</property>
</spacer>
</item>
</layout>
</item>
<item>
<layout class="QHBoxLayout" name="horizontalLayout_8">
<item>
<widget class="QPushButton" name="pushButtonPlayerPrevAlbum">
<property name="sizePolicy">
<sizepolicy hsizetype="Fixed" vsizetype="Expanding">
<horstretch>0</horstretch>
@ -2392,7 +2623,7 @@ outline: none;
</widget>
</item>
<item>
<widget class="QPushButton" name="pushButtonPrevBig">
<widget class="QPushButton" name="pushButtonPlayerPrevBig">
<property name="sizePolicy">
<sizepolicy hsizetype="Fixed" vsizetype="Expanding">
<horstretch>0</horstretch>
@ -2430,6 +2661,10 @@ outline: none;
</property>
</widget>
</item>
</layout>
</item>
</layout>
</item>
<item>
<widget class="QPushButton" name="pushButtonBack">
<property name="sizePolicy">
@ -2477,7 +2712,157 @@ outline: none;</string>
</widget>
</item>
<item>
<widget class="QPushButton" name="pushButtonNextBig">
<layout class="QVBoxLayout" name="verticalLayout_10">
<item>
<layout class="QHBoxLayout" name="horizontalLayout_11">
<item>
<spacer name="horizontalSpacer">
<property name="orientation">
<enum>Qt::Horizontal</enum>
</property>
<property name="sizeHint" stdset="0">
<size>
<width>1</width>
<height>1</height>
</size>
</property>
</spacer>
</item>
<item>
<widget class="QLabel" name="labelAlbum">
<property name="sizePolicy">
<sizepolicy hsizetype="Preferred" vsizetype="Preferred">
<horstretch>0</horstretch>
<verstretch>0</verstretch>
</sizepolicy>
</property>
<property name="font">
<font>
<pointsize>12</pointsize>
<weight>75</weight>
<bold>true</bold>
</font>
</property>
<property name="styleSheet">
<string notr="true">color: rgb(255, 255, 255);</string>
</property>
<property name="text">
<string>Album</string>
</property>
<property name="alignment">
<set>Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter</set>
</property>
</widget>
</item>
<item>
<widget class="QLabel" name="labelCurrentAlbumIndex">
<property name="sizePolicy">
<sizepolicy hsizetype="Preferred" vsizetype="Preferred">
<horstretch>0</horstretch>
<verstretch>0</verstretch>
</sizepolicy>
</property>
<property name="font">
<font>
<pointsize>12</pointsize>
<weight>75</weight>
<bold>true</bold>
</font>
</property>
<property name="styleSheet">
<string notr="true">color: rgb(255, 255, 255);</string>
</property>
<property name="text">
<string/>
</property>
<property name="alignment">
<set>Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter</set>
</property>
</widget>
</item>
<item>
<widget class="QLabel" name="labelAlbumDash">
<property name="sizePolicy">
<sizepolicy hsizetype="Minimum" vsizetype="Preferred">
<horstretch>0</horstretch>
<verstretch>0</verstretch>
</sizepolicy>
</property>
<property name="minimumSize">
<size>
<width>20</width>
<height>0</height>
</size>
</property>
<property name="maximumSize">
<size>
<width>20</width>
<height>16777215</height>
</size>
</property>
<property name="font">
<font>
<pointsize>12</pointsize>
<weight>75</weight>
<bold>true</bold>
</font>
</property>
<property name="styleSheet">
<string notr="true">color: rgb(255, 255, 255);</string>
</property>
<property name="text">
<string>/</string>
</property>
<property name="alignment">
<set>Qt::AlignCenter</set>
</property>
</widget>
</item>
<item>
<widget class="QLabel" name="labelAlbumCount">
<property name="sizePolicy">
<sizepolicy hsizetype="Preferred" vsizetype="Preferred">
<horstretch>0</horstretch>
<verstretch>0</verstretch>
</sizepolicy>
</property>
<property name="font">
<font>
<pointsize>12</pointsize>
<weight>75</weight>
<bold>true</bold>
</font>
</property>
<property name="styleSheet">
<string notr="true">color: rgb(255, 255, 255);</string>
</property>
<property name="text">
<string/>
</property>
<property name="alignment">
<set>Qt::AlignLeading|Qt::AlignLeft|Qt::AlignVCenter</set>
</property>
</widget>
</item>
<item>
<spacer name="horizontalSpacer_2">
<property name="orientation">
<enum>Qt::Horizontal</enum>
</property>
<property name="sizeHint" stdset="0">
<size>
<width>1</width>
<height>1</height>
</size>
</property>
</spacer>
</item>
</layout>
</item>
<item>
<layout class="QHBoxLayout" name="horizontalLayout_9">
<item>
<widget class="QPushButton" name="pushButtonPlayerNextBig">
<property name="sizePolicy">
<sizepolicy hsizetype="Fixed" vsizetype="Expanding">
<horstretch>0</horstretch>
@ -2516,7 +2901,7 @@ outline: none;</string>
</widget>
</item>
<item>
<widget class="QPushButton" name="pushButton_2">
<widget class="QPushButton" name="pushButtonPlayerNextAlbum">
<property name="sizePolicy">
<sizepolicy hsizetype="Fixed" vsizetype="Expanding">
<horstretch>0</horstretch>
@ -2555,6 +2940,10 @@ outline: none;</string>
</widget>
</item>
</layout>
</item>
</layout>
</item>
</layout>
</widget>
</item>
</layout>
@ -2678,7 +3067,7 @@ color: rgb(255, 255, 255);</string>
<property name="maximumSize">
<size>
<width>150</width>
<height>17</height>
<height>16</height>
</size>
</property>
<property name="font">
@ -2708,13 +3097,13 @@ background-color: rgba(0, 0, 0, 0);</string>
<property name="minimumSize">
<size>
<width>0</width>
<height>10</height>
<height>20</height>
</size>
</property>
<property name="maximumSize">
<size>
<width>16777215</width>
<height>10</height>
<height>20</height>
</size>
</property>
<property name="layoutDirection">