2024-09-08 00:34:45 +08:00
|
|
|
// SPDX-FileCopyrightText: 2024 Gary Wang <git@blumia.net>
|
|
|
|
//
|
|
|
|
// SPDX-License-Identifier: MIT
|
|
|
|
|
2024-07-07 16:27:22 +08:00
|
|
|
#ifndef MAINWINDOW_H
|
|
|
|
#define MAINWINDOW_H
|
|
|
|
|
|
|
|
#include <QMainWindow>
|
|
|
|
#include <QVariant>
|
|
|
|
|
|
|
|
QT_BEGIN_NAMESPACE
|
|
|
|
namespace Ui { class MainWindow; }
|
|
|
|
|
|
|
|
class QMediaPlayer;
|
|
|
|
class QAudioOutput;
|
|
|
|
class QPropertyAnimation;
|
|
|
|
QT_END_NAMESPACE
|
|
|
|
|
2024-09-06 00:17:39 +08:00
|
|
|
class PlaylistManager;
|
2024-07-07 16:27:22 +08:00
|
|
|
class MainWindow : public QMainWindow
|
|
|
|
{
|
|
|
|
Q_OBJECT
|
|
|
|
|
|
|
|
public:
|
2024-09-06 00:17:39 +08:00
|
|
|
enum PlaybackMode {
|
|
|
|
CurrentItemOnce,
|
|
|
|
CurrentItemInLoop,
|
|
|
|
Sequential,
|
|
|
|
};
|
|
|
|
Q_ENUM(PlaybackMode)
|
|
|
|
|
|
|
|
Q_PROPERTY(PlaybackMode playbackMode MEMBER m_playbackMode NOTIFY playbackModeChanged)
|
|
|
|
|
2024-07-07 16:27:22 +08:00
|
|
|
MainWindow(QWidget *parent = nullptr);
|
|
|
|
~MainWindow() override;
|
|
|
|
|
|
|
|
void commandlinePlayAudioFiles(QStringList audioFiles);
|
|
|
|
void setAudioPropertyInfoForDisplay(int sampleRate, int bitrate, int channelCount, QString audioExt);
|
|
|
|
void setAudioMetadataForDisplay(QString title, QString artist, QString album);
|
|
|
|
|
|
|
|
public slots:
|
|
|
|
void localSocketPlayAudioFiles(QVariant audioFilesVariant);
|
|
|
|
|
|
|
|
protected:
|
|
|
|
void closeEvent(QCloseEvent *) override;
|
|
|
|
void paintEvent(QPaintEvent *e) override;
|
|
|
|
void mousePressEvent(QMouseEvent *event) override;
|
|
|
|
void mouseMoveEvent(QMouseEvent *event) override;
|
|
|
|
void mouseReleaseEvent(QMouseEvent *event) override;
|
|
|
|
void dragEnterEvent(QDragEnterEvent *e) override;
|
|
|
|
void dropEvent(QDropEvent *e) override;
|
|
|
|
|
|
|
|
void loadFile();
|
2024-09-08 00:34:45 +08:00
|
|
|
void loadByModelIndex(const QModelIndex &index);
|
2024-09-07 12:14:54 +08:00
|
|
|
void play();
|
|
|
|
|
2024-09-10 08:13:03 +08:00
|
|
|
void setSkin(QString imagePath, bool save);
|
|
|
|
|
2024-07-07 16:27:22 +08:00
|
|
|
void centerWindow();
|
|
|
|
|
|
|
|
private slots:
|
|
|
|
void on_playbackModeBtn_clicked();
|
|
|
|
void on_closeWindowBtn_clicked();
|
|
|
|
void on_playBtn_clicked();
|
|
|
|
void on_volumeSlider_valueChanged(int value);
|
|
|
|
void on_stopBtn_clicked();
|
|
|
|
void on_playbackSlider_valueChanged(int value);
|
|
|
|
void on_prevBtn_clicked();
|
|
|
|
void on_nextBtn_clicked();
|
|
|
|
void on_volumeBtn_clicked();
|
|
|
|
void on_minimumWindowBtn_clicked();
|
2024-09-10 08:13:03 +08:00
|
|
|
void on_setSkinBtn_clicked();
|
2024-09-06 00:17:39 +08:00
|
|
|
void on_playListBtn_clicked();
|
|
|
|
void on_playlistView_activated(const QModelIndex &index);
|
|
|
|
|
|
|
|
signals:
|
|
|
|
void playbackModeChanged(enum PlaybackMode mode);
|
|
|
|
|
2024-07-07 16:27:22 +08:00
|
|
|
private:
|
|
|
|
bool m_clickedOnWindow = false;
|
|
|
|
bool m_playbackSliderPressed = false;
|
|
|
|
QLinearGradient m_bgLinearGradient;
|
2024-09-10 08:13:03 +08:00
|
|
|
QPixmap m_skin;
|
2024-09-06 00:17:39 +08:00
|
|
|
enum PlaybackMode m_playbackMode = CurrentItemInLoop;
|
2024-07-07 16:27:22 +08:00
|
|
|
|
|
|
|
Ui::MainWindow *ui;
|
|
|
|
|
|
|
|
QMediaPlayer *m_mediaPlayer;
|
|
|
|
QAudioOutput *m_audioOutput;
|
|
|
|
QPropertyAnimation *m_fadeOutAnimation;
|
2024-09-06 00:17:39 +08:00
|
|
|
PlaylistManager *m_playlistManager;
|
2024-07-07 16:27:22 +08:00
|
|
|
|
|
|
|
void initUiAndAnimation();
|
|
|
|
void initConnections();
|
|
|
|
|
2024-09-10 08:13:03 +08:00
|
|
|
void loadSkinData();
|
|
|
|
void saveSkinData();
|
|
|
|
|
2024-07-07 16:27:22 +08:00
|
|
|
static QString ms2str(qint64 ms);
|
|
|
|
static QList<QUrl> strlst2urllst(QStringList strlst);
|
|
|
|
};
|
|
|
|
#endif // MAINWINDOW_H
|