diff --git a/Music-Player.pro b/Music-Player.pro index b3871eb..7e75b2a 100644 --- a/Music-Player.pro +++ b/Music-Player.pro @@ -13,6 +13,7 @@ greaterThan(QT_MAJOR_VERSION, 4): QT += widgets SOURCES += \ src/components/albumTile/albumtile.cpp \ src/components/spinningAlbumArt/spinningalbumart.cpp \ + src/components/timePlayedWidget/timePlayedWidget.cpp \ src/components/tracklistWidget/tracklistwidget.cpp \ src/main.cpp \ src/windows/musicSelector/musicSelector.cpp \ @@ -26,6 +27,7 @@ SOURCES += \ HEADERS += \ src/components/albumTile/albumtile.h \ src/components/spinningAlbumArt/spinningalbumart.h \ + src/components/timePlayedWidget/timePlayedWidget.h \ src/components/tracklistWidget/tracklistwidget.h \ src/data/cleanerScripts.h \ src/windows/musicSelector/musicSelector.h \ diff --git a/build/Desktop-Debug/Makefile b/build/Desktop-Debug/Makefile index ae90e3a..7799be0 100644 --- a/build/Desktop-Debug/Makefile +++ b/build/Desktop-Debug/Makefile @@ -3,7 +3,7 @@ # Generated by qmake (3.1) (Qt 6.9.3) # Project: ../../Music-Player.pro # Template: app -# Command: /opt/homebrew/Cellar/qtbase/6.9.3/bin/qmake -o Makefile ../../Music-Player.pro -spec macx-clang CONFIG+=debug CONFIG+=qml_debug +# Command: /opt/homebrew/opt/qtbase/bin/qmake -o Makefile ../../Music-Player.pro -spec macx-clang CONFIG+=debug CONFIG+=qml_debug ############################################################################# MAKEFILE = Makefile @@ -18,7 +18,7 @@ DEFINES = -DQT_QML_DEBUG -DQT_WIDGETS_LIB -DQT_MULTIMEDIA_LIB -DQT_GUI_LIB CFLAGS = -pipe -g $(EXPORT_ARCH_ARGS) -isysroot /Library/Developer/CommandLineTools/SDKs/MacOSX.sdk -mmacosx-version-min=14.0 -Wall -Wextra $(DEFINES) CXXFLAGS = -pipe -stdlib=libc++ -g -std=gnu++1z $(EXPORT_ARCH_ARGS) -isysroot /Library/Developer/CommandLineTools/SDKs/MacOSX.sdk -mmacosx-version-min=14.0 -Wall -Wextra $(DEFINES) INCPATH = -I../../../Qt-Music-Player -I. -I/opt/homebrew/lib/QtWidgets.framework/Headers -I/opt/homebrew/lib/QtMultimedia.framework/Headers -I/opt/homebrew/lib/QtGui.framework/Headers -I/opt/homebrew/lib/QtNetwork.framework/Headers -I/opt/homebrew/lib/QtCore.framework/Headers -I. -I/Library/Developer/CommandLineTools/SDKs/MacOSX.sdk/System/Library/Frameworks/OpenGL.framework/Headers -I. -I/Library/Developer/CommandLineTools/SDKs/MacOSX.sdk/System/Library/Frameworks/OpenGL.framework/Headers -I/opt/homebrew/share/qt/mkspecs/macx-clang -F/opt/homebrew/lib -QMAKE = /opt/homebrew/Cellar/qtbase/6.9.3/bin/qmake +QMAKE = /opt/homebrew/opt/qtbase/bin/qmake DEL_FILE = rm -f CHK_DIR_EXISTS= test -d MKDIR = mkdir -p @@ -28,8 +28,8 @@ COPY_DIR = cp -f -R INSTALL_FILE = install -m 644 -p INSTALL_PROGRAM = install -m 755 -p INSTALL_DIR = cp -f -R -QINSTALL = /opt/homebrew/Cellar/qtbase/6.9.3/bin/qmake -install qinstall -QINSTALL_PROGRAM = /opt/homebrew/Cellar/qtbase/6.9.3/bin/qmake -install qinstall -exe +QINSTALL = /opt/homebrew/opt/qtbase/bin/qmake -install qinstall +QINSTALL_PROGRAM = /opt/homebrew/opt/qtbase/bin/qmake -install qinstall -exe DEL_FILE = rm -f SYMLINK = ln -f -s DEL_DIR = rmdir @@ -54,6 +54,7 @@ OBJECTS_DIR = ./ SOURCES = ../../src/components/albumTile/albumtile.cpp \ ../../src/components/spinningAlbumArt/spinningalbumart.cpp \ + ../../src/components/timePlayedWidget/timePlayedWidget.cpp \ ../../src/components/tracklistWidget/tracklistwidget.cpp \ ../../src/main.cpp \ ../../src/windows/musicSelector/musicSelector.cpp \ @@ -61,11 +62,13 @@ SOURCES = ../../src/components/albumTile/albumtile.cpp \ ../../src/layout/flowLayout/flowLayout.cpp qrc_qmake_qmake_qm_files.cpp \ moc_albumtile.cpp \ moc_spinningalbumart.cpp \ + moc_timePlayedWidget.cpp \ moc_tracklistwidget.cpp \ moc_musicSelector.cpp \ moc_playerWindow.cpp OBJECTS = albumtile.o \ spinningalbumart.o \ + timePlayedWidget.o \ tracklistwidget.o \ main.o \ musicSelector.o \ @@ -74,6 +77,7 @@ OBJECTS = albumtile.o \ qrc_qmake_qmake_qm_files.o \ moc_albumtile.o \ moc_spinningalbumart.o \ + moc_timePlayedWidget.o \ moc_tracklistwidget.o \ moc_musicSelector.o \ moc_playerWindow.o @@ -451,6 +455,7 @@ DIST = /opt/homebrew/share/qt/mkspecs/features/spec_pre.prf \ /opt/homebrew/share/qt/mkspecs/features/lex.prf \ ../../../../Music-Player.pro ../../src/components/albumTile/albumtile.h \ ../../src/components/spinningAlbumArt/spinningalbumart.h \ + ../../src/components/timePlayedWidget/timePlayedWidget.h \ ../../src/components/tracklistWidget/tracklistwidget.h \ ../../src/data/cleanerScripts.h \ ../../src/windows/musicSelector/musicSelector.h \ @@ -458,6 +463,7 @@ DIST = /opt/homebrew/share/qt/mkspecs/features/spec_pre.prf \ ../../src/data/albumInformation.h \ ../../src/layout/flowLayout/flowLayout.h ../../src/components/albumTile/albumtile.cpp \ ../../src/components/spinningAlbumArt/spinningalbumart.cpp \ + ../../src/components/timePlayedWidget/timePlayedWidget.cpp \ ../../src/components/tracklistWidget/tracklistwidget.cpp \ ../../src/main.cpp \ ../../src/windows/musicSelector/musicSelector.cpp \ @@ -1272,8 +1278,8 @@ distdir: FORCE $(COPY_FILE) --parents $(DIST) $(DISTDIR)/ $(COPY_FILE) --parents qmake_qmake_qm_files.qrc $(DISTDIR)/ $(COPY_FILE) --parents /opt/homebrew/share/qt/mkspecs/features/data/dummy.cpp $(DISTDIR)/ - $(COPY_FILE) --parents ../../src/components/albumTile/albumtile.h ../../src/components/spinningAlbumArt/spinningalbumart.h ../../src/components/tracklistWidget/tracklistwidget.h ../../src/data/cleanerScripts.h ../../src/windows/musicSelector/musicSelector.h ../../src/windows/playerWindow/playerWindow.h ../../src/data/albumInformation.h ../../src/layout/flowLayout/flowLayout.h $(DISTDIR)/ - $(COPY_FILE) --parents ../../src/components/albumTile/albumtile.cpp ../../src/components/spinningAlbumArt/spinningalbumart.cpp ../../src/components/tracklistWidget/tracklistwidget.cpp ../../src/main.cpp ../../src/windows/musicSelector/musicSelector.cpp ../../src/windows/playerWindow/playerWindow.cpp ../../src/layout/flowLayout/flowLayout.cpp $(DISTDIR)/ + $(COPY_FILE) --parents ../../src/components/albumTile/albumtile.h ../../src/components/spinningAlbumArt/spinningalbumart.h ../../src/components/timePlayedWidget/timePlayedWidget.h ../../src/components/tracklistWidget/tracklistwidget.h ../../src/data/cleanerScripts.h ../../src/windows/musicSelector/musicSelector.h ../../src/windows/playerWindow/playerWindow.h ../../src/data/albumInformation.h ../../src/layout/flowLayout/flowLayout.h $(DISTDIR)/ + $(COPY_FILE) --parents ../../src/components/albumTile/albumtile.cpp ../../src/components/spinningAlbumArt/spinningalbumart.cpp ../../src/components/timePlayedWidget/timePlayedWidget.cpp ../../src/components/tracklistWidget/tracklistwidget.cpp ../../src/main.cpp ../../src/windows/musicSelector/musicSelector.cpp ../../src/windows/playerWindow/playerWindow.cpp ../../src/layout/flowLayout/flowLayout.cpp $(DISTDIR)/ $(COPY_FILE) --parents ../../src/windows/musicSelector/musicSelector.ui $(DISTDIR)/ @@ -1316,9 +1322,9 @@ compiler_moc_predefs_clean: moc_predefs.h: /opt/homebrew/share/qt/mkspecs/features/data/dummy.cpp /Library/Developer/CommandLineTools/usr/bin/clang++ -pipe -stdlib=libc++ -g -std=gnu++1z $(EXPORT_ARCH_ARGS) -isysroot /Library/Developer/CommandLineTools/SDKs/MacOSX.sdk -mmacosx-version-min=14.0 -Wall -Wextra -dM -E -o moc_predefs.h /opt/homebrew/share/qt/mkspecs/features/data/dummy.cpp -compiler_moc_header_make_all: moc_albumtile.cpp moc_spinningalbumart.cpp moc_tracklistwidget.cpp moc_musicSelector.cpp moc_playerWindow.cpp +compiler_moc_header_make_all: moc_albumtile.cpp moc_spinningalbumart.cpp moc_timePlayedWidget.cpp moc_tracklistwidget.cpp moc_musicSelector.cpp moc_playerWindow.cpp compiler_moc_header_clean: - -$(DEL_FILE) moc_albumtile.cpp moc_spinningalbumart.cpp moc_tracklistwidget.cpp moc_musicSelector.cpp moc_playerWindow.cpp + -$(DEL_FILE) moc_albumtile.cpp moc_spinningalbumart.cpp moc_timePlayedWidget.cpp moc_tracklistwidget.cpp moc_musicSelector.cpp moc_playerWindow.cpp moc_albumtile.cpp: ../../src/components/albumTile/albumtile.h \ /opt/homebrew/lib/QtWidgets.framework/Headers/QWidget \ /opt/homebrew/lib/QtWidgets.framework/Headers/qwidget.h \ @@ -1346,10 +1352,23 @@ moc_spinningalbumart.cpp: ../../src/components/spinningAlbumArt/spinningalbumart /opt/homebrew/lib/QtGui.framework/Headers/qpixmap.h \ /opt/homebrew/lib/QtCore.framework/Headers/QTimer \ /opt/homebrew/lib/QtCore.framework/Headers/qtimer.h \ + /opt/homebrew/lib/QtGui.framework/Headers/QMouseEvent \ + /opt/homebrew/lib/QtGui.framework/Headers/qevent.h \ moc_predefs.h \ /opt/homebrew/share/qt/libexec/moc /opt/homebrew/share/qt/libexec/moc $(DEFINES) --include /Users/lucas/Developer/Qt-Music-Player/build/Desktop-Debug/moc_predefs.h -I/opt/homebrew/share/qt/mkspecs/macx-clang -I/Users/lucas/Developer/Qt-Music-Player -I/opt/homebrew/lib/QtWidgets.framework/Headers -I/opt/homebrew/lib/QtMultimedia.framework/Headers -I/opt/homebrew/lib/QtGui.framework/Headers -I/opt/homebrew/lib/QtNetwork.framework/Headers -I/opt/homebrew/lib/QtCore.framework/Headers -I. -I/Library/Developer/CommandLineTools/SDKs/MacOSX.sdk/usr/include/c++/v1 -I/Library/Developer/CommandLineTools/usr/lib/clang/17/include -I/Library/Developer/CommandLineTools/SDKs/MacOSX.sdk/usr/include -I/Library/Developer/CommandLineTools/usr/include -F/opt/homebrew/lib ../../src/components/spinningAlbumArt/spinningalbumart.h -o moc_spinningalbumart.cpp +moc_timePlayedWidget.cpp: ../../src/components/timePlayedWidget/timePlayedWidget.h \ + /opt/homebrew/lib/QtWidgets.framework/Headers/QWidget \ + /opt/homebrew/lib/QtWidgets.framework/Headers/qwidget.h \ + /opt/homebrew/lib/QtWidgets.framework/Headers/QLabel \ + /opt/homebrew/lib/QtWidgets.framework/Headers/qlabel.h \ + /opt/homebrew/lib/QtWidgets.framework/Headers/QVBoxLayout \ + /opt/homebrew/lib/QtWidgets.framework/Headers/qboxlayout.h \ + moc_predefs.h \ + /opt/homebrew/share/qt/libexec/moc + /opt/homebrew/share/qt/libexec/moc $(DEFINES) --include /Users/lucas/Developer/Qt-Music-Player/build/Desktop-Debug/moc_predefs.h -I/opt/homebrew/share/qt/mkspecs/macx-clang -I/Users/lucas/Developer/Qt-Music-Player -I/opt/homebrew/lib/QtWidgets.framework/Headers -I/opt/homebrew/lib/QtMultimedia.framework/Headers -I/opt/homebrew/lib/QtGui.framework/Headers -I/opt/homebrew/lib/QtNetwork.framework/Headers -I/opt/homebrew/lib/QtCore.framework/Headers -I. -I/Library/Developer/CommandLineTools/SDKs/MacOSX.sdk/usr/include/c++/v1 -I/Library/Developer/CommandLineTools/usr/lib/clang/17/include -I/Library/Developer/CommandLineTools/SDKs/MacOSX.sdk/usr/include -I/Library/Developer/CommandLineTools/usr/include -F/opt/homebrew/lib ../../src/components/timePlayedWidget/timePlayedWidget.h -o moc_timePlayedWidget.cpp + moc_tracklistwidget.cpp: ../../src/components/tracklistWidget/tracklistwidget.h \ /opt/homebrew/lib/QtWidgets.framework/Headers/QWidget \ /opt/homebrew/lib/QtWidgets.framework/Headers/qwidget.h \ @@ -1392,9 +1411,14 @@ moc_playerWindow.cpp: ../../src/windows/playerWindow/playerWindow.h \ ../../src/components/spinningalbumart/spinningAlbumArt.h \ /opt/homebrew/lib/QtGui.framework/Headers/QPixmap \ /opt/homebrew/lib/QtGui.framework/Headers/qpixmap.h \ + /opt/homebrew/lib/QtGui.framework/Headers/QMouseEvent \ + /opt/homebrew/lib/QtGui.framework/Headers/qevent.h \ ../../src/components/tracklistWidget/tracklistwidget.h \ /opt/homebrew/lib/QtWidgets.framework/Headers/QListWidget \ /opt/homebrew/lib/QtWidgets.framework/Headers/qlistwidget.h \ + ../../src/components/timePlayedWidget/timePlayedWidget.h \ + /opt/homebrew/lib/QtWidgets.framework/Headers/QVBoxLayout \ + /opt/homebrew/lib/QtWidgets.framework/Headers/qboxlayout.h \ moc_predefs.h \ /opt/homebrew/share/qt/libexec/moc /opt/homebrew/share/qt/libexec/moc $(DEFINES) --include /Users/lucas/Developer/Qt-Music-Player/build/Desktop-Debug/moc_predefs.h -I/opt/homebrew/share/qt/mkspecs/macx-clang -I/Users/lucas/Developer/Qt-Music-Player -I/opt/homebrew/lib/QtWidgets.framework/Headers -I/opt/homebrew/lib/QtMultimedia.framework/Headers -I/opt/homebrew/lib/QtGui.framework/Headers -I/opt/homebrew/lib/QtNetwork.framework/Headers -I/opt/homebrew/lib/QtCore.framework/Headers -I. -I/Library/Developer/CommandLineTools/SDKs/MacOSX.sdk/usr/include/c++/v1 -I/Library/Developer/CommandLineTools/usr/lib/clang/17/include -I/Library/Developer/CommandLineTools/SDKs/MacOSX.sdk/usr/include -I/Library/Developer/CommandLineTools/usr/include -F/opt/homebrew/lib ../../src/windows/playerWindow/playerWindow.h -o moc_playerWindow.cpp @@ -1449,12 +1473,23 @@ spinningalbumart.o: ../../src/components/spinningAlbumArt/spinningalbumart.cpp . /opt/homebrew/lib/QtGui.framework/Headers/qpixmap.h \ /opt/homebrew/lib/QtCore.framework/Headers/QTimer \ /opt/homebrew/lib/QtCore.framework/Headers/qtimer.h \ + /opt/homebrew/lib/QtGui.framework/Headers/QMouseEvent \ + /opt/homebrew/lib/QtGui.framework/Headers/qevent.h \ /opt/homebrew/lib/QtGui.framework/Headers/QPainter \ /opt/homebrew/lib/QtGui.framework/Headers/qpainter.h \ /opt/homebrew/lib/QtGui.framework/Headers/QPainterPath \ /opt/homebrew/lib/QtGui.framework/Headers/qpainterpath.h $(CXX) -c $(CXXFLAGS) $(INCPATH) -o spinningalbumart.o ../../src/components/spinningAlbumArt/spinningalbumart.cpp +timePlayedWidget.o: ../../src/components/timePlayedWidget/timePlayedWidget.cpp ../../src/components/timePlayedWidget/timePlayedWidget.h \ + /opt/homebrew/lib/QtWidgets.framework/Headers/QWidget \ + /opt/homebrew/lib/QtWidgets.framework/Headers/qwidget.h \ + /opt/homebrew/lib/QtWidgets.framework/Headers/QLabel \ + /opt/homebrew/lib/QtWidgets.framework/Headers/qlabel.h \ + /opt/homebrew/lib/QtWidgets.framework/Headers/QVBoxLayout \ + /opt/homebrew/lib/QtWidgets.framework/Headers/qboxlayout.h + $(CXX) -c $(CXXFLAGS) $(INCPATH) -o timePlayedWidget.o ../../src/components/timePlayedWidget/timePlayedWidget.cpp + tracklistwidget.o: ../../src/components/tracklistWidget/tracklistwidget.cpp ../../src/components/tracklistWidget/tracklistwidget.h \ /opt/homebrew/lib/QtWidgets.framework/Headers/QWidget \ /opt/homebrew/lib/QtWidgets.framework/Headers/qwidget.h \ @@ -1519,6 +1554,7 @@ musicSelector.o: ../../src/windows/musicSelector/musicSelector.cpp ../../src/win ../../src/components/tracklistWidget/tracklistwidget.h \ /opt/homebrew/lib/QtWidgets.framework/Headers/QListWidget \ /opt/homebrew/lib/QtWidgets.framework/Headers/qlistwidget.h \ + ../../src/components/timePlayedWidget/timePlayedWidget.h \ ../../src/layout/flowlayout/flowLayout.h \ /opt/homebrew/lib/QtWidgets.framework/Headers/QLayout \ /opt/homebrew/lib/QtWidgets.framework/Headers/qlayout.h \ @@ -1553,15 +1589,17 @@ playerWindow.o: ../../src/windows/playerWindow/playerWindow.cpp ../../src/window ../../src/components/spinningalbumart/spinningAlbumArt.h \ /opt/homebrew/lib/QtGui.framework/Headers/QPixmap \ /opt/homebrew/lib/QtGui.framework/Headers/qpixmap.h \ + /opt/homebrew/lib/QtGui.framework/Headers/QMouseEvent \ + /opt/homebrew/lib/QtGui.framework/Headers/qevent.h \ ../../src/components/tracklistWidget/tracklistwidget.h \ /opt/homebrew/lib/QtWidgets.framework/Headers/QListWidget \ /opt/homebrew/lib/QtWidgets.framework/Headers/qlistwidget.h \ + ../../src/components/timePlayedWidget/timePlayedWidget.h \ /opt/homebrew/lib/QtWidgets.framework/Headers/QVBoxLayout \ /opt/homebrew/lib/QtWidgets.framework/Headers/qboxlayout.h \ /opt/homebrew/lib/QtCore.framework/Headers/QFileInfo \ /opt/homebrew/lib/QtCore.framework/Headers/qfileinfo.h \ /opt/homebrew/lib/QtGui.framework/Headers/QCloseEvent \ - /opt/homebrew/lib/QtGui.framework/Headers/qevent.h \ ../../src/data/cleanerScripts.h \ /opt/homebrew/lib/QtCore.framework/Headers/QRegularExpression \ /opt/homebrew/lib/QtCore.framework/Headers/qregularexpression.h @@ -1706,6 +1744,9 @@ moc_albumtile.o: moc_albumtile.cpp moc_spinningalbumart.o: moc_spinningalbumart.cpp $(CXX) -c $(CXXFLAGS) $(INCPATH) -o moc_spinningalbumart.o moc_spinningalbumart.cpp +moc_timePlayedWidget.o: moc_timePlayedWidget.cpp + $(CXX) -c $(CXXFLAGS) $(INCPATH) -o moc_timePlayedWidget.o moc_timePlayedWidget.cpp + moc_tracklistwidget.o: moc_tracklistwidget.cpp $(CXX) -c $(CXXFLAGS) $(INCPATH) -o moc_tracklistwidget.o moc_tracklistwidget.cpp diff --git a/build/Desktop-Debug/Music-Player.app/Contents/MacOS/Music-Player b/build/Desktop-Debug/Music-Player.app/Contents/MacOS/Music-Player index da32677..8452284 100755 Binary files a/build/Desktop-Debug/Music-Player.app/Contents/MacOS/Music-Player and b/build/Desktop-Debug/Music-Player.app/Contents/MacOS/Music-Player differ diff --git a/build/Desktop-Debug/moc_playerWindow.o b/build/Desktop-Debug/moc_playerWindow.o index 1cdbfdd..208ab0e 100644 Binary files a/build/Desktop-Debug/moc_playerWindow.o and b/build/Desktop-Debug/moc_playerWindow.o differ diff --git a/build/Desktop-Debug/moc_spinningalbumart.cpp b/build/Desktop-Debug/moc_spinningalbumart.cpp index a82c610..7c548cc 100644 --- a/build/Desktop-Debug/moc_spinningalbumart.cpp +++ b/build/Desktop-Debug/moc_spinningalbumart.cpp @@ -40,19 +40,22 @@ template <> constexpr inline auto SpinningAlbumArt::qt_create_metaobjectdata(1, 2, QMC::AccessPublic, QMetaType::Void), // Slot 'start' - QtMocHelpers::SlotData(1, 2, QMC::AccessPublic, QMetaType::Void), - // Slot 'stop' QtMocHelpers::SlotData(3, 2, QMC::AccessPublic, QMetaType::Void), + // Slot 'stop' + QtMocHelpers::SlotData(4, 2, QMC::AccessPublic, QMetaType::Void), // Slot 'updateRotation' - QtMocHelpers::SlotData(4, 2, QMC::AccessPrivate, QMetaType::Void), + QtMocHelpers::SlotData(5, 2, QMC::AccessPrivate, QMetaType::Void), }; QtMocHelpers::UintData qt_properties { }; @@ -76,13 +79,17 @@ void SpinningAlbumArt::qt_static_metacall(QObject *_o, QMetaObject::Call _c, int auto *_t = static_cast(_o); if (_c == QMetaObject::InvokeMetaMethod) { switch (_id) { - case 0: _t->start(); break; - case 1: _t->stop(); break; - case 2: _t->updateRotation(); break; + case 0: _t->artClicked(); break; + case 1: _t->start(); break; + case 2: _t->stop(); break; + case 3: _t->updateRotation(); break; default: ; } } - (void)_a; + if (_c == QMetaObject::IndexOfMethod) { + if (QtMocHelpers::indexOfMethod(_a, &SpinningAlbumArt::artClicked, 0)) + return; + } } const QMetaObject *SpinningAlbumArt::metaObject() const @@ -104,15 +111,21 @@ int SpinningAlbumArt::qt_metacall(QMetaObject::Call _c, int _id, void **_a) if (_id < 0) return _id; if (_c == QMetaObject::InvokeMetaMethod) { - if (_id < 3) + if (_id < 4) qt_static_metacall(this, _c, _id, _a); - _id -= 3; + _id -= 4; } if (_c == QMetaObject::RegisterMethodArgumentMetaType) { - if (_id < 3) + if (_id < 4) *reinterpret_cast(_a[0]) = QMetaType(); - _id -= 3; + _id -= 4; } return _id; } + +// SIGNAL 0 +void SpinningAlbumArt::artClicked() +{ + QMetaObject::activate(this, &staticMetaObject, 0, nullptr); +} QT_WARNING_POP diff --git a/build/Desktop-Debug/moc_spinningalbumart.o b/build/Desktop-Debug/moc_spinningalbumart.o index 2971c3d..aa58a65 100644 Binary files a/build/Desktop-Debug/moc_spinningalbumart.o and b/build/Desktop-Debug/moc_spinningalbumart.o differ diff --git a/build/Desktop-Debug/moc_timePlayedWidget.cpp b/build/Desktop-Debug/moc_timePlayedWidget.cpp new file mode 100644 index 0000000..af9f38c --- /dev/null +++ b/build/Desktop-Debug/moc_timePlayedWidget.cpp @@ -0,0 +1,122 @@ +/**************************************************************************** +** Meta object code from reading C++ file 'timePlayedWidget.h' +** +** Created by: The Qt Meta Object Compiler version 69 (Qt 6.9.3) +** +** WARNING! All changes made in this file will be lost! +*****************************************************************************/ + +#include "../../src/components/timePlayedWidget/timePlayedWidget.h" +#include +#include + +#include + +#include + + +#include +#if !defined(Q_MOC_OUTPUT_REVISION) +#error "The header file 'timePlayedWidget.h' doesn't include ." +#elif Q_MOC_OUTPUT_REVISION != 69 +#error "This file was generated using the moc from 6.9.3. It" +#error "cannot be used with the include files from this version of Qt." +#error "(The moc has changed too much.)" +#endif + +#ifndef Q_CONSTINIT +#define Q_CONSTINIT +#endif + +QT_WARNING_PUSH +QT_WARNING_DISABLE_DEPRECATED +QT_WARNING_DISABLE_GCC("-Wuseless-cast") +namespace { +struct qt_meta_tag_ZN16TimePlayedWidgetE_t {}; +} // unnamed namespace + +template <> constexpr inline auto TimePlayedWidget::qt_create_metaobjectdata() +{ + namespace QMC = QtMocConstants; + QtMocHelpers::StringRefStorage qt_stringData { + "TimePlayedWidget", + "setDuration", + "", + "ms", + "setPosition", + "reset" + }; + + QtMocHelpers::UintData qt_methods { + // Slot 'setDuration' + QtMocHelpers::SlotData(1, 2, QMC::AccessPublic, QMetaType::Void, {{ + { QMetaType::LongLong, 3 }, + }}), + // Slot 'setPosition' + QtMocHelpers::SlotData(4, 2, QMC::AccessPublic, QMetaType::Void, {{ + { QMetaType::LongLong, 3 }, + }}), + // Slot 'reset' + QtMocHelpers::SlotData(5, 2, QMC::AccessPublic, QMetaType::Void), + }; + QtMocHelpers::UintData qt_properties { + }; + QtMocHelpers::UintData qt_enums { + }; + return QtMocHelpers::metaObjectData(QMC::MetaObjectFlag{}, qt_stringData, + qt_methods, qt_properties, qt_enums); +} +Q_CONSTINIT const QMetaObject TimePlayedWidget::staticMetaObject = { { + QMetaObject::SuperData::link(), + qt_staticMetaObjectStaticContent.stringdata, + qt_staticMetaObjectStaticContent.data, + qt_static_metacall, + nullptr, + qt_staticMetaObjectRelocatingContent.metaTypes, + nullptr +} }; + +void TimePlayedWidget::qt_static_metacall(QObject *_o, QMetaObject::Call _c, int _id, void **_a) +{ + auto *_t = static_cast(_o); + if (_c == QMetaObject::InvokeMetaMethod) { + switch (_id) { + case 0: _t->setDuration((*reinterpret_cast< std::add_pointer_t>(_a[1]))); break; + case 1: _t->setPosition((*reinterpret_cast< std::add_pointer_t>(_a[1]))); break; + case 2: _t->reset(); break; + default: ; + } + } +} + +const QMetaObject *TimePlayedWidget::metaObject() const +{ + return QObject::d_ptr->metaObject ? QObject::d_ptr->dynamicMetaObject() : &staticMetaObject; +} + +void *TimePlayedWidget::qt_metacast(const char *_clname) +{ + if (!_clname) return nullptr; + if (!strcmp(_clname, qt_staticMetaObjectStaticContent.strings)) + return static_cast(this); + return QWidget::qt_metacast(_clname); +} + +int TimePlayedWidget::qt_metacall(QMetaObject::Call _c, int _id, void **_a) +{ + _id = QWidget::qt_metacall(_c, _id, _a); + if (_id < 0) + return _id; + if (_c == QMetaObject::InvokeMetaMethod) { + if (_id < 3) + qt_static_metacall(this, _c, _id, _a); + _id -= 3; + } + if (_c == QMetaObject::RegisterMethodArgumentMetaType) { + if (_id < 3) + *reinterpret_cast(_a[0]) = QMetaType(); + _id -= 3; + } + return _id; +} +QT_WARNING_POP diff --git a/build/Desktop-Debug/moc_timePlayedWidget.o b/build/Desktop-Debug/moc_timePlayedWidget.o new file mode 100644 index 0000000..73adc3a Binary files /dev/null and b/build/Desktop-Debug/moc_timePlayedWidget.o differ diff --git a/build/Desktop-Debug/musicSelector.o b/build/Desktop-Debug/musicSelector.o index 5d20895..34199cc 100644 Binary files a/build/Desktop-Debug/musicSelector.o and b/build/Desktop-Debug/musicSelector.o differ diff --git a/build/Desktop-Debug/playerWindow.o b/build/Desktop-Debug/playerWindow.o index a11549a..ae518cd 100644 Binary files a/build/Desktop-Debug/playerWindow.o and b/build/Desktop-Debug/playerWindow.o differ diff --git a/build/Desktop-Debug/spinningalbumart.o b/build/Desktop-Debug/spinningalbumart.o index 6f0972a..0169ddc 100644 Binary files a/build/Desktop-Debug/spinningalbumart.o and b/build/Desktop-Debug/spinningalbumart.o differ diff --git a/build/Desktop-Debug/timePlayedWidget.o b/build/Desktop-Debug/timePlayedWidget.o new file mode 100644 index 0000000..c11c84a Binary files /dev/null and b/build/Desktop-Debug/timePlayedWidget.o differ diff --git a/src/components/spinningAlbumArt/spinningalbumart.cpp b/src/components/spinningAlbumArt/spinningalbumart.cpp index 85e3fcb..80c9249 100644 --- a/src/components/spinningAlbumArt/spinningalbumart.cpp +++ b/src/components/spinningAlbumArt/spinningalbumart.cpp @@ -80,3 +80,9 @@ void SpinningAlbumArt::updateRotation() artLabel_->setPixmap(frame); } + +void SpinningAlbumArt::mousePressEvent(QMouseEvent* event) +{ + emit artClicked(); + QWidget::mousePressEvent(event); +} diff --git a/src/components/spinningAlbumArt/spinningalbumart.h b/src/components/spinningAlbumArt/spinningalbumart.h index 4f4bbb4..1e8ea24 100644 --- a/src/components/spinningAlbumArt/spinningalbumart.h +++ b/src/components/spinningAlbumArt/spinningalbumart.h @@ -4,6 +4,7 @@ #include #include #include +#include class SpinningAlbumArt : public QWidget { @@ -16,9 +17,15 @@ public slots: void start(); void stop(); +signals: + void artClicked(); + private slots: void updateRotation(); +protected: + void mousePressEvent(QMouseEvent* event) override; + private: QPixmap discArt_; // circular-masked album image QLabel* artLabel_; // widget that displays the spinning frame diff --git a/src/components/timePlayedWidget/timePlayedWidget.cpp b/src/components/timePlayedWidget/timePlayedWidget.cpp new file mode 100644 index 0000000..a4595ab --- /dev/null +++ b/src/components/timePlayedWidget/timePlayedWidget.cpp @@ -0,0 +1,47 @@ +#include "timePlayedWidget.h" + +TimePlayedWidget::TimePlayedWidget(QWidget* parent) + : QWidget(parent) +{ + label_ = new QLabel("00:00 / 00:00", this); + label_->setAlignment(Qt::AlignCenter); + label_->setStyleSheet("font-size: 12px; color: #666;"); + + QVBoxLayout* layout = new QVBoxLayout(this); + layout->setContentsMargins(0, 0, 0, 0); + layout->addWidget(label_); +} + +QString TimePlayedWidget::formatTime(qint64 ms) const +{ + int sec = ms / 1000; + int min = sec / 60; + int s = sec % 60; + + return QString("%1:%2") + .arg(min, 2, 10, QChar('0')) + .arg(s, 2, 10, QChar('0')); +} + +void TimePlayedWidget::setDuration(qint64 ms) +{ + duration_ = ms; +} + +void TimePlayedWidget::setPosition(qint64 ms) +{ + if (duration_ > 0) + { + label_->setText( + QString("%1 / %2") + .arg(formatTime(ms)) + .arg(formatTime(duration_)) + ); + } +} + +void TimePlayedWidget::reset() +{ + duration_ = 0; + label_->setText("00:00 / 00:00"); +} diff --git a/src/components/timePlayedWidget/timePlayedWidget.h b/src/components/timePlayedWidget/timePlayedWidget.h new file mode 100644 index 0000000..7a30860 --- /dev/null +++ b/src/components/timePlayedWidget/timePlayedWidget.h @@ -0,0 +1,27 @@ +#ifndef TIMEPLAYEDWIDGET_H +#define TIMEPLAYEDWIDGET_H + +#include +#include +#include + +class TimePlayedWidget : public QWidget +{ + Q_OBJECT + +public: + explicit TimePlayedWidget(QWidget* parent = nullptr); + +public slots: + void setDuration(qint64 ms); + void setPosition(qint64 ms); + void reset(); + +private: + QLabel* label_; + qint64 duration_ = 0; + + QString formatTime(qint64 ms) const; +}; + +#endif // TIMEPLAYEDWIDGET_H diff --git a/src/windows/playerWindow/playerWindow.cpp b/src/windows/playerWindow/playerWindow.cpp index 3581d0a..1af1bc8 100644 --- a/src/windows/playerWindow/playerWindow.cpp +++ b/src/windows/playerWindow/playerWindow.cpp @@ -22,6 +22,17 @@ PlayerWindow::PlayerWindow(const AlbumData& item, QWidget* parent) trackLabel_->setStyleSheet("font-size: 14px; font-weight: 500;"); layout->addWidget(trackLabel_); + // Time played in Song Indicator + timeIndicator_ = new TimePlayedWidget(this); + layout->addWidget(timeIndicator_); + + // Volume slider (NEW) + volumeSlider_ = new QSlider(Qt::Horizontal); + volumeSlider_->setRange(0, 100); + volumeSlider_->setValue(80); + volumeSlider_->setStyleSheet("margin: 0 12px;"); + layout->addWidget(volumeSlider_); + // Track list widget trackList_ = new TrackListWidget(item_.audioFiles, this); layout->addWidget(trackList_); @@ -31,6 +42,10 @@ PlayerWindow::PlayerWindow(const AlbumData& item, QWidget* parent) audio_ = new QAudioOutput(this); player_->setAudioOutput(audio_); + audio_->setVolume(0.8f); // match slider + connect(volumeSlider_, &QSlider::valueChanged, this, + [this](int v){ audio_->setVolume(v / 100.0); }); + // Spin album art based on playback connect(player_, &QMediaPlayer::playbackStateChanged, this, [this](QMediaPlayer::PlaybackState st){ @@ -40,6 +55,24 @@ PlayerWindow::PlayerWindow(const AlbumData& item, QWidget* parent) spinningArt_->stop(); }); + // Get song duration and played time + connect(player_, &QMediaPlayer::durationChanged, + timeIndicator_, &TimePlayedWidget::setDuration); + + connect(player_, &QMediaPlayer::positionChanged, + timeIndicator_, &TimePlayedWidget::setPosition); + + // Pause/Play on album art click + connect(spinningArt_, &SpinningAlbumArt::artClicked, this, [this]() { + if (player_->playbackState() == QMediaPlayer::PlayingState) { + player_->pause(); + spinningArt_->stop(); + } else { + player_->play(); + spinningArt_->start(); + } + }); + // When a track finishes, auto-play next connect(player_, &QMediaPlayer::mediaStatusChanged, this, [this](QMediaPlayer::MediaStatus st){ diff --git a/src/windows/playerWindow/playerWindow.h b/src/windows/playerWindow/playerWindow.h index 6403eef..5ee1a19 100644 --- a/src/windows/playerWindow/playerWindow.h +++ b/src/windows/playerWindow/playerWindow.h @@ -9,10 +9,13 @@ #include "src/data/albumInformation.h" #include "src/components/spinningalbumart/spinningAlbumArt.h" #include "src/components/tracklistWidget/tracklistwidget.h" +#include "src/components/timePlayedWidget/timePlayedWidget.h" class PlayerWindow : public QWidget { Q_OBJECT + QSlider* volumeSlider_; + TimePlayedWidget* timeIndicator_; public: explicit PlayerWindow(const AlbumData& item, QWidget* parent = nullptr);