From c691536e779b24888ddcf34189163a0a7be27d4b Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Rodrigo=20M=C3=A9ndez?= Date: Sat, 25 Nov 2023 22:15:16 -0600 Subject: [PATCH] Refactor DONE, experimenting with BT --- audiosourcebluetooth.cpp | 77 ++++++++++++++++ audiosourcebluetooth.h | 29 +++++++ audiosourcecoordinator.cpp | 8 +- audiosourcefile.cpp | 37 +------- audiosourcefile.h | 4 +- controlbuttonswidget.cpp | 10 +++ controlbuttonswidget.h | 3 + mainmenuview.cpp | 44 ++++++++++ mainmenuview.h | 34 ++++++++ mainmenuview.ui | 111 ++++++++++++++++++++++++ mainwindow.cpp | 66 +++++++++++--- mainwindow.h | 6 ++ player.pro | 5 ++ player.pro.user | 4 +- playerview.cpp | 22 +++-- playerview.h | 7 +- playerview.ui | 6 +- styles/playerview.playlistButton.1x.qss | 6 +- styles/playerview.playlistButton.2x.qss | 6 +- styles/playerview.playlistButton.3x.qss | 6 +- styles/playerview.playlistButton.4x.qss | 6 +- 21 files changed, 420 insertions(+), 77 deletions(-) create mode 100644 audiosourcebluetooth.cpp create mode 100644 audiosourcebluetooth.h create mode 100644 mainmenuview.cpp create mode 100644 mainmenuview.h create mode 100644 mainmenuview.ui diff --git a/audiosourcebluetooth.cpp b/audiosourcebluetooth.cpp new file mode 100644 index 0000000..53cffa5 --- /dev/null +++ b/audiosourcebluetooth.cpp @@ -0,0 +1,77 @@ +#include "audiosourcebluetooth.h" + +AudioSourceBluetooth::AudioSourceBluetooth(QObject *parent) + : AudioSource{parent} +{ + +} + +void AudioSourceBluetooth::activate() +{ + QMediaMetaData metadata = QMediaMetaData{}; + metadata.insert(QMediaMetaData::Title, "Bluetooth"); + + emit playbackStateChanged(MediaPlayer::StoppedState); + emit positionChanged(0); + emit metadataChanged(metadata); + emit durationChanged(0); + emit eqEnabledChanged(false); + emit plEnabledChanged(false); + emit shuffleEnabledChanged(false); + emit repeatEnabledChanged(false); +} + +void AudioSourceBluetooth::deactivate() +{ + +} + +void AudioSourceBluetooth::handlePl() +{ + emit plEnabledChanged(false); +} + +void AudioSourceBluetooth::handlePrevious() +{ + +} + +void AudioSourceBluetooth::handlePlay() +{ + +} + +void AudioSourceBluetooth::handlePause() +{ + +} + +void AudioSourceBluetooth::handleStop() +{ + +} + +void AudioSourceBluetooth::handleNext() +{ + +} + +void AudioSourceBluetooth::handleOpen() +{ + +} + +void AudioSourceBluetooth::handleShuffle() +{ + emit shuffleEnabledChanged(false); +} + +void AudioSourceBluetooth::handleRepeat() +{ + emit repeatEnabledChanged(false); +} + +void AudioSourceBluetooth::handleSeek(int mseconds) +{ + +} diff --git a/audiosourcebluetooth.h b/audiosourcebluetooth.h new file mode 100644 index 0000000..99b7bc3 --- /dev/null +++ b/audiosourcebluetooth.h @@ -0,0 +1,29 @@ +#ifndef AUDIOSOURCEBLUETOOTH_H +#define AUDIOSOURCEBLUETOOTH_H + +#include + +#include "audiosource.h" + +class AudioSourceBluetooth : public AudioSource +{ + Q_OBJECT +public: + explicit AudioSourceBluetooth(QObject *parent = nullptr); + +public slots: + void activate(); + void deactivate(); + void handlePl(); + void handlePrevious(); + void handlePlay(); + void handlePause(); + void handleStop(); + void handleNext(); + void handleOpen(); + void handleShuffle(); + void handleRepeat(); + void handleSeek(int mseconds); +}; + +#endif // AUDIOSOURCEBLUETOOTH_H diff --git a/audiosourcecoordinator.cpp b/audiosourcecoordinator.cpp index 8c4fa18..1cc2cc3 100644 --- a/audiosourcecoordinator.cpp +++ b/audiosourcecoordinator.cpp @@ -1,5 +1,4 @@ #include "audiosourcecoordinator.h" -#include "audiosourcefile.h" AudioSourceCoordinator::AudioSourceCoordinator(QObject *parent, PlayerView *playerView) : QObject{parent} @@ -19,6 +18,11 @@ AudioSourceCoordinator::AudioSourceCoordinator(QObject *parent, PlayerView *play void AudioSourceCoordinator::setSource(int newSource) { + if(newSource > sources.length() - 1) { + qDebug() << "WARNING: Trying to set source out of range"; + return; + } + if(currentSource >= 0) { // deactivate old source sources[currentSource]->deactivate(); @@ -32,6 +36,7 @@ void AudioSourceCoordinator::setSource(int newSource) disconnect(view, &PlayerView::openClicked, sources[currentSource], &AudioSource::handleOpen); disconnect(view, &PlayerView::shuffleClicked, sources[currentSource], &AudioSource::handleShuffle); disconnect(view, &PlayerView::repeatClicked, sources[currentSource], &AudioSource::handleRepeat); + disconnect(view, &PlayerView::plClicked, sources[currentSource], &AudioSource::handlePl); disconnect(sources[currentSource], &AudioSource::playbackStateChanged, view, &PlayerView::setPlaybackState); disconnect(sources[currentSource], &AudioSource::positionChanged, view, &PlayerView::setPosition); @@ -57,6 +62,7 @@ void AudioSourceCoordinator::setSource(int newSource) connect(view, &PlayerView::openClicked, sources[currentSource], &AudioSource::handleOpen); connect(view, &PlayerView::shuffleClicked, sources[currentSource], &AudioSource::handleShuffle); connect(view, &PlayerView::repeatClicked, sources[currentSource], &AudioSource::handleRepeat); + connect(view, &PlayerView::plClicked, sources[currentSource], &AudioSource::handlePl); connect(sources[currentSource], &AudioSource::playbackStateChanged, view, &PlayerView::setPlaybackState); connect(sources[currentSource], &AudioSource::positionChanged, view, &PlayerView::setPosition); diff --git a/audiosourcefile.cpp b/audiosourcefile.cpp index 9220986..30e1a25 100644 --- a/audiosourcefile.cpp +++ b/audiosourcefile.cpp @@ -56,7 +56,8 @@ void AudioSourceFile::deactivate() void AudioSourceFile::handlePl() { - + emit showPlaylistRequested(); + emit plEnabledChanged(true); } void AudioSourceFile::handlePrevious() @@ -101,7 +102,7 @@ void AudioSourceFile::handleNext() void AudioSourceFile::handleOpen() { - + emit showPlaylistRequested(); } void AudioSourceFile::handleShuffle() @@ -221,38 +222,6 @@ void AudioSourceFile::jump(const QModelIndex &index) } } -void AudioSourceFile::open() -{ - - /* - QList urls; - urls << QUrl::fromLocalFile(QStandardPaths::standardLocations(QStandardPaths::HomeLocation).first()) - << QUrl::fromLocalFile(QStandardPaths::standardLocations(QStandardPaths::DownloadLocation).first()) - << QUrl::fromLocalFile(QStandardPaths::standardLocations(QStandardPaths::MusicLocation).first()); - - - QFileDialog fileDialog(this); - QString filters = audioFileFilters().join(" "); - fileDialog.setNameFilter("Audio (" + filters + ")"); - fileDialog.setAcceptMode(QFileDialog::AcceptOpen); - fileDialog.setFileMode(QFileDialog::ExistingFiles); - fileDialog.setWindowTitle(tr("Open Files")); - fileDialog.setDirectory(QStandardPaths::standardLocations(QStandardPaths::MusicLocation) - .value(0, QDir::homePath())); - fileDialog.setOption(QFileDialog::ReadOnly, true); - fileDialog.setOption(QFileDialog::DontUseNativeDialog, true); - fileDialog.setViewMode(QFileDialog::Detail); - fileDialog.setSidebarUrls(urls); - -#ifdef IS_EMBEDDED - fileDialog.setWindowState(Qt::WindowFullScreen); -#endif - - if (fileDialog.exec() == QDialog::Accepted) - addToPlaylist(fileDialog.selectedUrls()); -*/ -} - void AudioSourceFile::addToPlaylist(const QList &urls) { const int previousMediaCount = m_playlist->mediaCount(); diff --git a/audiosourcefile.h b/audiosourcefile.h index 2d61d54..3f6b639 100644 --- a/audiosourcefile.h +++ b/audiosourcefile.h @@ -15,6 +15,9 @@ class AudioSourceFile : public AudioSource public: explicit AudioSourceFile(QObject *parent = nullptr, PlaylistModel *playlistModel = nullptr); +signals: + void showPlaylistRequested(); + public slots: void activate(); void deactivate(); @@ -31,7 +34,6 @@ public slots: void jump(const QModelIndex &index); - void open(); void addToPlaylist(const QList &urls); private slots: diff --git a/controlbuttonswidget.cpp b/controlbuttonswidget.cpp index 1b605ec..bb644b0 100644 --- a/controlbuttonswidget.cpp +++ b/controlbuttonswidget.cpp @@ -86,3 +86,13 @@ void ControlButtonsWidget::scale() this->setMaximumHeight(this->maximumHeight() * UI_SCALE); this->setMinimumHeight(this->minimumHeight() * UI_SCALE); } + +void ControlButtonsWidget::setShuffleEnabled(bool enabled) +{ + ui->shuffleButton->setChecked(enabled); +} + +void ControlButtonsWidget::setRepeatEnabled(bool enabled) +{ + ui->repeatButton->setChecked(enabled); +} diff --git a/controlbuttonswidget.h b/controlbuttonswidget.h index 3cf0fec..63d919f 100644 --- a/controlbuttonswidget.h +++ b/controlbuttonswidget.h @@ -15,6 +15,9 @@ class ControlButtonsWidget : public QWidget explicit ControlButtonsWidget(QWidget *parent = nullptr); ~ControlButtonsWidget(); + void setShuffleEnabled(bool enabled); + void setRepeatEnabled(bool enabled); + private: Ui::ControlButtonsWidget *ui; void scale(); diff --git a/mainmenuview.cpp b/mainmenuview.cpp new file mode 100644 index 0000000..354f6ea --- /dev/null +++ b/mainmenuview.cpp @@ -0,0 +1,44 @@ +#include "mainmenuview.h" +#include "ui_mainmenuview.h" + +MainMenuView::MainMenuView(QWidget *parent) : + QWidget(parent), + ui(new Ui::MainMenuView) +{ + ui->setupUi(this); + + connect(ui->backButton, &QPushButton::clicked, this, &MainMenuView::backClicked); + connect(ui->fileSourceButton, &QPushButton::clicked, this, &MainMenuView::fileSourceClicked); + connect(ui->btSourceButton, &QPushButton::clicked, this, &MainMenuView::btSourceClicked); + connect(ui->spotifySourceButton, &QPushButton::clicked, this, &MainMenuView::spotifySourceClicked); + connect(ui->shutdownButton, &QPushButton::clicked, this, &MainMenuView::shutdown); +} + +MainMenuView::~MainMenuView() +{ + delete ui; +} + +void MainMenuView::fileSourceClicked() +{ + emit sourceSelected(0); +} + +void MainMenuView::btSourceClicked() +{ + emit sourceSelected(1); +} + +void MainMenuView::spotifySourceClicked() +{ + emit sourceSelected(2); +} + +void MainMenuView::shutdown() +{ + QString appPath = QCoreApplication::applicationDirPath(); + QString cmd = appPath + "/shutdown.sh"; + + shutdownProcess = new QProcess(this); + shutdownProcess->start(cmd); +} diff --git a/mainmenuview.h b/mainmenuview.h new file mode 100644 index 0000000..64bf37f --- /dev/null +++ b/mainmenuview.h @@ -0,0 +1,34 @@ +#ifndef MAINMENUVIEW_H +#define MAINMENUVIEW_H + +#include +#include + +namespace Ui { +class MainMenuView; +} + +class MainMenuView : public QWidget +{ + Q_OBJECT + +public: + explicit MainMenuView(QWidget *parent = nullptr); + ~MainMenuView(); + +signals: + void sourceSelected(int source); + void backClicked(); + +private: + Ui::MainMenuView *ui; + + void fileSourceClicked(); + void btSourceClicked(); + void spotifySourceClicked(); + + QProcess *shutdownProcess = nullptr; + void shutdown(); +}; + +#endif // MAINMENUVIEW_H diff --git a/mainmenuview.ui b/mainmenuview.ui new file mode 100644 index 0000000..e5d6111 --- /dev/null +++ b/mainmenuview.ui @@ -0,0 +1,111 @@ + + + MainMenuView + + + + 0 + 0 + 1280 + 400 + + + + + 1280 + 400 + + + + Form + + + false + + + #MainMenuView { + background-color: #333350; +} + + + + + 1070 + 20 + 191 + 71 + + + + File + + + + + + 1070 + 120 + 191 + 71 + + + + Bluetooth + + + + + + 1070 + 220 + 191 + 71 + + + + Spotify + + + + + + 1180 + 310 + 81 + 71 + + + + Back + + + + + + 60 + 60 + 261 + 211 + + + + Shut Down + + + + + + 470 + 60 + 261 + 211 + + + + Restart + + + + + + diff --git a/mainwindow.cpp b/mainwindow.cpp index 73c475a..42cc53c 100644 --- a/mainwindow.cpp +++ b/mainwindow.cpp @@ -1,7 +1,11 @@ +#include + #include "mainwindow.h" #include "desktopplayerwindow.h" +#include "qstandardpaths.h" #include "ui_desktopplayerwindow.h" #include "scale.h" +#include "util.h" #ifdef IS_EMBEDDED #include "embeddedbasewindow.h" @@ -31,7 +35,8 @@ MainWindow::MainWindow(QWidget *parent) m_playlist = m_playlistModel->playlist(); // Setup views - player = new PlayerView(this, m_playlistModel); + controlButtons = new ControlButtonsWidget(this); + player = new PlayerView(this, controlButtons); player->setAttribute(Qt::WidgetAttribute::WA_StyledBackground, true); playlist = new PlaylistView(this, m_playlistModel); @@ -39,25 +44,18 @@ MainWindow::MainWindow(QWidget *parent) coordinator = new AudioSourceCoordinator(this, player); fileSource = new AudioSourceFile(this, m_playlistModel); + btSource = new AudioSourceBluetooth(this); coordinator->addSource(fileSource, true); + coordinator->addSource(btSource, false); - controlButtons = new ControlButtonsWidget(this); // Connect events - connect(player, &PlayerView::showPlaylistClicked, this, &MainWindow::showPlaylist); + connect(fileSource, &AudioSourceFile::showPlaylistRequested, this, &MainWindow::showPlaylist); connect(playlist, &PlaylistView::showPlayerClicked, this, &MainWindow::showPlayer); connect(playlist, &PlaylistView::songSelected, fileSource, &AudioSourceFile::jump); connect(playlist, &PlaylistView::addSelectedFilesClicked, fileSource, &AudioSourceFile::addToPlaylist); - connect(controlButtons, &ControlButtonsWidget::playClicked, player, &PlayerView::playClicked); - connect(controlButtons, &ControlButtonsWidget::pauseClicked, player, &PlayerView::pauseClicked); - connect(controlButtons, &ControlButtonsWidget::stopClicked, player, &PlayerView::stopClicked); - connect(controlButtons, &ControlButtonsWidget::nextClicked, player, &PlayerView::nextClicked); - connect(controlButtons, &ControlButtonsWidget::previousClicked, player, &PlayerView::previousClicked); - connect(controlButtons, &ControlButtonsWidget::openClicked, player, &PlayerView::showPlaylistClicked); - connect(controlButtons, &ControlButtonsWidget::repeatClicked, player, &PlayerView::repeatClicked); - connect(controlButtons, &ControlButtonsWidget::shuffleClicked, player, &PlayerView::shuffleClicked); - connect(controlButtons, &ControlButtonsWidget::logoClicked, this, &MainWindow::showShutdownModal); + connect(controlButtons, &ControlButtonsWidget::logoClicked, this, &MainWindow::showMenu); // Prepare player main view #ifdef IS_EMBEDDED @@ -96,10 +94,17 @@ MainWindow::MainWindow(QWidget *parent) playlistLayout->addWidget(playlist); playlistWindow->ui->body->setLayout(playlistLayout); + // Prepare menu view + menu = new MainMenuView(this); + menu->setAttribute(Qt::WidgetAttribute::WA_StyledBackground, true); + connect(menu, &MainMenuView::backClicked, this, &MainWindow::showPlayer); + connect(menu, &MainMenuView::sourceSelected, coordinator, &AudioSourceCoordinator::setSource); + // Prepare navigation stack viewStack = new QStackedLayout; viewStack->addWidget(playerWindow); viewStack->addWidget(playlistWindow); + viewStack->addWidget(menu); // Final UI setup and show QVBoxLayout *centralLayout = new QVBoxLayout; @@ -137,6 +142,11 @@ void MainWindow::showPlaylist() viewStack->setCurrentIndex(1); } +void MainWindow::showMenu() +{ + viewStack->setCurrentIndex(2); +} + void MainWindow::showShutdownModal() { QMessageBox msgBox; @@ -164,3 +174,35 @@ void MainWindow::shutdown() shutdownProcess = new QProcess(this); shutdownProcess->start(cmd); } + +// Shows a standard file picker for adding items to the playlist +// Not used currently +void MainWindow::open() +{ + QList urls; + urls << QUrl::fromLocalFile(QStandardPaths::standardLocations(QStandardPaths::HomeLocation).first()) + << QUrl::fromLocalFile(QStandardPaths::standardLocations(QStandardPaths::DownloadLocation).first()) + << QUrl::fromLocalFile(QStandardPaths::standardLocations(QStandardPaths::MusicLocation).first()); + + + QFileDialog fileDialog(this); + QString filters = audioFileFilters().join(" "); + fileDialog.setNameFilter("Audio (" + filters + ")"); + fileDialog.setAcceptMode(QFileDialog::AcceptOpen); + fileDialog.setFileMode(QFileDialog::ExistingFiles); + fileDialog.setWindowTitle(tr("Open Files")); + fileDialog.setDirectory(QStandardPaths::standardLocations(QStandardPaths::MusicLocation) + .value(0, QDir::homePath())); + fileDialog.setOption(QFileDialog::ReadOnly, true); + fileDialog.setOption(QFileDialog::DontUseNativeDialog, true); + fileDialog.setViewMode(QFileDialog::Detail); + fileDialog.setSidebarUrls(urls); + +#ifdef IS_EMBEDDED + fileDialog.setWindowState(Qt::WindowFullScreen); +#endif + + if (fileDialog.exec() == QDialog::Accepted) + fileSource->addToPlaylist(fileDialog.selectedUrls()); + +} diff --git a/mainwindow.h b/mainwindow.h index 1cc4434..1424167 100644 --- a/mainwindow.h +++ b/mainwindow.h @@ -4,9 +4,11 @@ #include #include #include +#include "audiosourcebluetooth.h" #include "audiosourcecoordinator.h" #include "audiosourcefile.h" #include "controlbuttonswidget.h" +#include "mainmenuview.h" #include "playerview.h" #include "playlistview.h" #include "qmediaplaylist.h" @@ -24,13 +26,17 @@ class MainWindow : public QMainWindow PlayerView *player; ControlButtonsWidget *controlButtons; PlaylistView *playlist; + MainMenuView *menu; AudioSourceCoordinator *coordinator; AudioSourceFile *fileSource; + AudioSourceBluetooth *btSource; public slots: void showPlayer(); void showPlaylist(); + void showMenu(); void showShutdownModal(); + void open(); private: QMediaPlaylist *m_playlist = nullptr; diff --git a/player.pro b/player.pro index 9b6d271..7f206f2 100644 --- a/player.pro +++ b/player.pro @@ -10,6 +10,7 @@ LIBS += -ltag -lasound HEADERS = \ audiosource.h \ + audiosourcebluetooth.h \ audiosourcecoordinator.h \ audiosourcefile.h \ controlbuttonswidget.h \ @@ -18,6 +19,7 @@ HEADERS = \ embeddedbasewindow.h \ fft.h \ filebrowsericonprovider.h \ + mainmenuview.h \ mainwindow.h \ mediaplayer.h \ playerview.h \ @@ -35,6 +37,7 @@ HEADERS = \ SOURCES = main.cpp \ audiosource.cpp \ + audiosourcebluetooth.cpp \ audiosourcecoordinator.cpp \ audiosourcefile.cpp \ controlbuttonswidget.cpp \ @@ -43,6 +46,7 @@ SOURCES = main.cpp \ embeddedbasewindow.cpp \ fft.cpp \ filebrowsericonprovider.cpp \ + mainmenuview.cpp \ mainwindow.cpp \ mediaplayer.cpp \ playerview.cpp \ @@ -66,6 +70,7 @@ FORMS += \ desktopbasewindow.ui \ desktopplayerwindow.ui \ embeddedbasewindow.ui \ + mainmenuview.ui \ playerview.ui \ playlistview.ui \ titlebar.ui diff --git a/player.pro.user b/player.pro.user index 4836254..6c4a32a 100644 --- a/player.pro.user +++ b/player.pro.user @@ -1,6 +1,6 @@ - + EnvironmentId @@ -102,7 +102,7 @@ true QtProjectManager.QMakeBuildStep - false + true diff --git a/playerview.cpp b/playerview.cpp index 3ece218..bfcf26d 100644 --- a/playerview.cpp +++ b/playerview.cpp @@ -1,7 +1,6 @@ #include "playerview.h" #include "ui_playerview.h" -#include "playlistmodel.h" #include "scale.h" #include "util.h" @@ -17,7 +16,7 @@ #include #include -PlayerView::PlayerView(QWidget *parent, PlaylistModel *playlistModel) : +PlayerView::PlayerView(QWidget *parent, ControlButtonsWidget *ctlBtns) : QWidget(parent), ui(new Ui::PlayerView) { @@ -28,6 +27,17 @@ PlayerView::PlayerView(QWidget *parent, PlaylistModel *playlistModel) : ui->setupUi(this); scale(); + controlButtons = ctlBtns; + + connect(controlButtons, &ControlButtonsWidget::playClicked, this, &PlayerView::playClicked); + connect(controlButtons, &ControlButtonsWidget::pauseClicked, this, &PlayerView::pauseClicked); + connect(controlButtons, &ControlButtonsWidget::stopClicked, this, &PlayerView::stopClicked); + connect(controlButtons, &ControlButtonsWidget::nextClicked, this, &PlayerView::nextClicked); + connect(controlButtons, &ControlButtonsWidget::previousClicked, this, &PlayerView::previousClicked); + connect(controlButtons, &ControlButtonsWidget::openClicked, this, &PlayerView::openClicked); + connect(controlButtons, &ControlButtonsWidget::repeatClicked, this, &PlayerView::repeatClicked); + connect(controlButtons, &ControlButtonsWidget::shuffleClicked, this, &PlayerView::shuffleClicked); + // Setup spectrum analyzer spectrum = new SpectrumWidget(this); @@ -50,7 +60,6 @@ PlayerView::PlayerView(QWidget *parent, PlaylistModel *playlistModel) : setPlaybackState(MediaPlayer::StoppedState); connect(ui->playlistButton, &QCheckBox::clicked, this, &PlayerView::plClicked); - connect(ui->playlistButton, &QCheckBox::clicked, this, &PlayerView::showPlaylistClicked); // Setup spectrum widget QVBoxLayout *spectrumLayout = new QVBoxLayout; @@ -145,7 +154,6 @@ void PlayerView::scale() ui->progressTimeLabel->setGeometry(39*UI_SCALE, 3*UI_SCALE, 50*UI_SCALE, 20*UI_SCALE); QFont ptlFont = ui->progressTimeLabel->font(); - //ptlFont.setLetterSpacing(ptlFont.PercentageSpacing, 150); // NOT WORKING TODO ptlFont.setWordSpacing(-2); ui->progressTimeLabel->setFont(ptlFont); ui->progressTimeLabel->ensurePolished(); @@ -257,13 +265,13 @@ void PlayerView::setPlEnabled(bool enabled) void PlayerView::setShuffleEnabled(bool enabled) { shuffleEnabled = enabled; - // TODO set controlbuttonswidget shuffle button state + controlButtons->setShuffleEnabled(shuffleEnabled); } void PlayerView::setRepeatEnabled(bool enabled) { repeatEnabled = enabled; - // TODO set controlbuttonswidget repeat button state + controlButtons->setRepeatEnabled(repeatEnabled); } void PlayerView::setMessage(QString message, qint64 timeout) @@ -279,8 +287,6 @@ void PlayerView::clearMessage() messageTimer->stop(); } -///////////// - void PlayerView::updateDurationInfo(qint64 currentInfo) { QString tStr, tDisplayStr; diff --git a/playerview.h b/playerview.h index 21d869c..a26e865 100644 --- a/playerview.h +++ b/playerview.h @@ -1,7 +1,7 @@ #ifndef PLAYERVIEW_H #define PLAYERVIEW_H -#include "playlistmodel.h" +#include "controlbuttonswidget.h" #include "mediaplayer.h" #include "spectrumwidget.h" @@ -29,7 +29,7 @@ class PlayerView : public QWidget Q_OBJECT public: - explicit PlayerView(QWidget *parent = nullptr, PlaylistModel *playlistModel = nullptr); + explicit PlayerView(QWidget *parent = nullptr, ControlButtonsWidget *ctlBtns = nullptr); ~PlayerView(); public slots: @@ -63,13 +63,12 @@ public slots: void repeatClicked(); void menuClicked(); - void showPlaylistClicked(); - private: Ui::PlayerView *ui; void scale(); SpectrumWidget *spectrum = nullptr; QTimer *messageTimer = nullptr; + ControlButtonsWidget *controlButtons = nullptr; QString m_trackInfo; QString m_statusInfo; diff --git a/playerview.ui b/playerview.ui index 12aed20..07cf415 100644 --- a/playerview.ui +++ b/playerview.ui @@ -1241,15 +1241,15 @@ QCheckBox::indicator { } QCheckBox::indicator:unchecked { - image: url(:assets/pl_on.png); + image: url(:assets/pl_off.png); } QCheckBox::indicator:unchecked:hover { - image: url(:assets/pl_on.png); + image: url(:assets/pl_off.png); } QCheckBox::indicator:unchecked:pressed { - image: url(:assets/pl_on_p.png); + image: url(:assets/pl_off_p.png); } QCheckBox::indicator:checked { diff --git a/styles/playerview.playlistButton.1x.qss b/styles/playerview.playlistButton.1x.qss index d7d4f7e..5df8b01 100644 --- a/styles/playerview.playlistButton.1x.qss +++ b/styles/playerview.playlistButton.1x.qss @@ -8,15 +8,15 @@ QCheckBox::indicator { } QCheckBox::indicator:unchecked { - image: url(:assets/pl_on.png); + image: url(:assets/pl_off.png); } QCheckBox::indicator:unchecked:hover { - image: url(:assets/pl_on.png); + image: url(:assets/pl_off.png); } QCheckBox::indicator:unchecked:pressed { - image: url(:assets/pl_on_p.png); + image: url(:assets/pl_off_p.png); } QCheckBox::indicator:checked { diff --git a/styles/playerview.playlistButton.2x.qss b/styles/playerview.playlistButton.2x.qss index c27f9ea..38d484c 100644 --- a/styles/playerview.playlistButton.2x.qss +++ b/styles/playerview.playlistButton.2x.qss @@ -8,15 +8,15 @@ QCheckBox::indicator { } QCheckBox::indicator:unchecked { - image: url(:assets/pl_on.png); + image: url(:assets/pl_off.png); } QCheckBox::indicator:unchecked:hover { - image: url(:assets/pl_on.png); + image: url(:assets/pl_off.png); } QCheckBox::indicator:unchecked:pressed { - image: url(:assets/pl_on_p.png); + image: url(:assets/pl_off_p.png); } QCheckBox::indicator:checked { diff --git a/styles/playerview.playlistButton.3x.qss b/styles/playerview.playlistButton.3x.qss index 81ac3cc..41b4b13 100644 --- a/styles/playerview.playlistButton.3x.qss +++ b/styles/playerview.playlistButton.3x.qss @@ -8,15 +8,15 @@ QCheckBox::indicator { } QCheckBox::indicator:unchecked { - image: url(:assets/pl_on.png); + image: url(:assets/pl_off.png); } QCheckBox::indicator:unchecked:hover { - image: url(:assets/pl_on.png); + image: url(:assets/pl_off.png); } QCheckBox::indicator:unchecked:pressed { - image: url(:assets/pl_on_p.png); + image: url(:assets/pl_off_p.png); } QCheckBox::indicator:checked { diff --git a/styles/playerview.playlistButton.4x.qss b/styles/playerview.playlistButton.4x.qss index 5b218cb..580ff7d 100644 --- a/styles/playerview.playlistButton.4x.qss +++ b/styles/playerview.playlistButton.4x.qss @@ -8,15 +8,15 @@ QCheckBox::indicator { } QCheckBox::indicator:unchecked { - image: url(:assets/pl_on.png); + image: url(:assets/pl_off.png); } QCheckBox::indicator:unchecked:hover { - image: url(:assets/pl_on.png); + image: url(:assets/pl_off.png); } QCheckBox::indicator:unchecked:pressed { - image: url(:assets/pl_on_p.png); + image: url(:assets/pl_off_p.png); } QCheckBox::indicator:checked {