diff --git a/src/View/MainWidget.cpp b/src/View/MainWidget.cpp index 18b91ce..21d2fb2 100644 --- a/src/View/MainWidget.cpp +++ b/src/View/MainWidget.cpp @@ -55,14 +55,4 @@ MainWidget::MainWidget(QWidget* parent) setupMainWidget( ); } -MainWidget::MainWidget(std::filesystem::path path, QWidget* parent) - : QWidget(parent), - pageNav(new PageNavModule(this)), - playlistNav(new PlaylistNavModule(this)), - playlistPage(new PlaylistPage(this)), - homePage(new HomePage(this)), - floatingControlls(new FloatingControls(this, path)) { - setupMainWidget( ); -} - MainWidget::~MainWidget( ) { } diff --git a/src/View/MainWindow.cpp b/src/View/MainWindow.cpp index 1b957b4..8541017 100755 --- a/src/View/MainWindow.cpp +++ b/src/View/MainWindow.cpp @@ -19,9 +19,4 @@ MainWindow::MainWindow(QWidget* parent) setupMainWindow( ); } -MainWindow::MainWindow(std::filesystem::path path, QWidget* parent) - : QMainWindow(parent), mainWidget(new MainWidget(path, this)) { - setupMainWindow( ); -} - MainWindow::~MainWindow( ) { } diff --git a/src/View/Modules/FloatingControls/FloatingControls.cpp b/src/View/Modules/FloatingControls/FloatingControls.cpp index f4b38c6..20f534d 100755 --- a/src/View/Modules/FloatingControls/FloatingControls.cpp +++ b/src/View/Modules/FloatingControls/FloatingControls.cpp @@ -1,18 +1,7 @@ #include #include "FloatingControls.h" -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include + enum Repeat : short { ALL, @@ -40,7 +29,7 @@ static QPushButton* makeSongControlButton(QString name, QSize size = QSize(36, 3 return button; } -FloatingControls::FloatingControls(QWidget* parent, std::filesystem::path path) : +FloatingControls::FloatingControls(QWidget* parent) : QFrame(parent), volume(100), albumArtPath("default.png"), @@ -48,8 +37,7 @@ FloatingControls::FloatingControls(QWidget* parent, std::filesystem::path path) playPause(false), songRepeat(NONE), artist("Artist"), - songName("Song"), - song(Audio::getInstance( )) { + songName("Song") { this->setFixedHeight(100); this->setObjectName("main"); this->setStyleSheet(R"( @@ -79,13 +67,13 @@ FloatingControls::FloatingControls(QWidget* parent, std::filesystem::path path) border-radius: 8px; } )"); - //! Change later to the actual album art when the controls are done - albumArt->setPixmap(song.GetAlbumCover( ).scaled(QSize(64, 64), Qt::IgnoreAspectRatio)); + + //albumArt->setPixmap(); leftLayout->addWidget(albumArt); // Artist and Song name layout QVBoxLayout* artistSongLayout = new QVBoxLayout( ); - QLabel* artist = new QLabel(QString::fromStdString(song.GetArtist( ))); + QLabel* artist = new QLabel(""); artist->setMinimumWidth(50); connect(this, &FloatingControls::artistChanged, artist, &QLabel::setText); artist->setObjectName("artist"); @@ -100,7 +88,7 @@ FloatingControls::FloatingControls(QWidget* parent, std::filesystem::path path) QLabel* songName = new QLabel( ); songName->setMinimumWidth(50); QFontMetrics metrics(songName->font( )); - songName->setText(metrics.elidedText(QString::fromStdString(song.GetTitle( )), Qt::ElideRight, songName->width( ))); + songName->setText(metrics.elidedText("", Qt::ElideRight, songName->width( ))); connect(this, &FloatingControls::songNameChanged, songName, &QLabel::setText); songName->setObjectName("title"); @@ -133,26 +121,9 @@ FloatingControls::FloatingControls(QWidget* parent, std::filesystem::path path) col = "#D7D7D7"; QPushButton* pb = makeSongControlButton(buttonNames[i], QSize(36, 36), col); if (buttonNames[i] == "play") { - //TODO Change later - QObject::connect(pb, &QPushButton::clicked, [pb, this]( ) { - if (!song.IsMusicPlaying( )) { - song.StartMusic( ); - pb->setIcon(RenderSvg(":/icons/pause.svg", 36, 36)); - return; - } - if (GetPlayPause( )) { - song.ResumeMusic( ); - pb->setIcon(RenderSvg(":/icons/pause.svg", 36, 36)); - } - else { - song.PauseMusic( ); - pb->setIcon(RenderSvg(":/icons/play.svg", 36, 36)); - } - togglePlayPause( ); - }); + } songControlsLayout->addWidget(pb); - } @@ -163,12 +134,6 @@ FloatingControls::FloatingControls(QWidget* parent, std::filesystem::path path) // Song timestamp QLabel* songTimestamp = new QLabel("00:00"); - songTimestamp->setText( - QTime( - 0, - song.GetMusicPos( ) / 60, - song.GetMusicPos( ) % 60 - ).toString("mm:ss")); songTimestamp->setObjectName("songTimestamp"); songTimestamp->setStyleSheet(R"( QLabel#songTimestamp{ @@ -180,12 +145,6 @@ FloatingControls::FloatingControls(QWidget* parent, std::filesystem::path path) // Song duration QLabel* songDuration = new QLabel("00:00"); - songDuration->setText( - QTime( - 0, - song.GetMusicDuration( ) / 60, - song.GetMusicDuration( ) % 60 - ).toString("mm:ss")); songDuration->setObjectName("songDuration"); songDuration->setStyleSheet(R"( QLabel#songDuration{ @@ -197,8 +156,8 @@ FloatingControls::FloatingControls(QWidget* parent, std::filesystem::path path) // Song duration slider QSlider* songDurationSlider = new QSlider(Qt::Horizontal); songDurationSlider->setObjectName("songDurationSlider"); - songDurationSlider->setRange(0, song.GetMusicDuration( )); - songDurationSlider->setValue(song.GetMusicPos( )); + songDurationSlider->setRange(0, 100); + songDurationSlider->setValue(50); songDurationSlider->setFixedHeight(28); songDurationSlider->setStyleSheet(R"( QSlider#songDurationSlider::groove:horizontal{ @@ -224,7 +183,7 @@ FloatingControls::FloatingControls(QWidget* parent, std::filesystem::path path) songDurationSlider->setCursor(Qt::PointingHandCursor); connect(songDurationSlider, &QSlider::sliderReleased, [this, songDurationSlider]( ) { - song.SetMusicPos(songDurationSlider->value( )); + }); songScrollerLayout->addWidget(songTimestamp); @@ -234,7 +193,7 @@ FloatingControls::FloatingControls(QWidget* parent, std::filesystem::path path) QTimer* timer = new QTimer(this); connect(timer, &QTimer::timeout, this, [this, songTimestamp, songDurationSlider]( ) { - int sec = song.GetMusicPos( ); + int sec = 0; songTimestamp->setText( QTime( @@ -269,7 +228,7 @@ FloatingControls::FloatingControls(QWidget* parent, std::filesystem::path path) QSlider* VolumeSlider = new QSlider(Qt::Horizontal); VolumeSlider->setObjectName("volumeSlider"); VolumeSlider->setRange(0, 128); - VolumeSlider->setValue(song.GetVolume( )); + VolumeSlider->setValue(50); VolumeSlider->setFixedHeight(28); VolumeSlider->setStyleSheet(R"( QSlider#volumeSlider::groove:horizontal{ @@ -295,7 +254,6 @@ FloatingControls::FloatingControls(QWidget* parent, std::filesystem::path path) VolumeSlider->setCursor(Qt::PointingHandCursor); connect(VolumeSlider, &QSlider::valueChanged, [this, VolumeSlider]( ) { - song.SetVolume(VolumeSlider->value( )); }); rightLayout->addWidget(VolumeSlider); diff --git a/src/View/Modules/FloatingControls/FloatingControls.h b/src/View/Modules/FloatingControls/FloatingControls.h index 29271b2..cb2c9ed 100755 --- a/src/View/Modules/FloatingControls/FloatingControls.h +++ b/src/View/Modules/FloatingControls/FloatingControls.h @@ -1,6 +1,6 @@ #pragma once -#include "../../../core/audio/audio.h" +#include "../../../Controller/MusicPlayer/MusicPlayer.h" #include "../../Tools/SvgToPixmap.hpp" #include @@ -9,6 +9,18 @@ #include #include #include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include enum Repeat : short; @@ -61,7 +73,7 @@ public: return this->playPause; } - FloatingControls(QWidget* parent = nullptr, std::filesystem::path path = std::filesystem::path( )); + FloatingControls(QWidget* parent = nullptr); ~FloatingControls( ); signals: @@ -82,6 +94,4 @@ private: QPixmap albumArt; int songPos; int songLength; - - Audio& song; }; diff --git a/src/main.cpp b/src/main.cpp index 7bf1749..6e0d5a1 100755 --- a/src/main.cpp +++ b/src/main.cpp @@ -20,7 +20,7 @@ bool CheckValidFile(std::filesystem::path path) { int main(int argc, char* argv[]) { QApplication a(argc, argv); - MainWindow* w = argc > 1 && CheckValidFile(std::filesystem::path(argv[1])) ? new MainWindow(std::filesystem::path(argv[1])) : new MainWindow( ); + MainWindow* w = argc > 1 && CheckValidFile(std::filesystem::path(argv[1])) ? new MainWindow(/*std::filesystem::path(argv[1])*/) : new MainWindow( ); w->setMinimumHeight(600); w->show( );