This repository was archived by the owner on Jul 19, 2025. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathmainwindow.h
More file actions
80 lines (68 loc) · 2.36 KB
/
mainwindow.h
File metadata and controls
80 lines (68 loc) · 2.36 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
#ifndef MAINWINDOW_H
#define MAINWINDOW_H
#include <QMainWindow>
#include <QMediaPlayer>
#include <QAudioOutput>
#include <QTextEdit>
#include <QStackedWidget>
#include <QMenu>
#include <QSystemTrayIcon>
#include "playlistmodel.h"
QT_BEGIN_NAMESPACE
namespace Ui { class MainWindow; }
QT_END_NAMESPACE
class MainWindow : public QMainWindow {
Q_OBJECT
public:
MainWindow(QWidget* parent = nullptr) noexcept;
~MainWindow();
private slots:
void openFile() noexcept;
void openFolder() noexcept;
void togglePlayback() noexcept;
void showAbout() noexcept;
void previousTrack() noexcept;
void nextTrack() noexcept;
void playTrack(int index) noexcept;
void onPlaylistClicked(const QModelIndex& index) noexcept;
void updateDurationDisplay() noexcept;
void toggleView() noexcept;
void onTrayActivated(QSystemTrayIcon::ActivationReason reason) noexcept;
void toggleMuted() noexcept;
void dragEnterEvent(QDragEnterEvent *ev) noexcept;
private:
void setupPlaylist() noexcept;
void setupConnections() noexcept;
void updatePlaybackButtons() noexcept;
void updatePlayingInfo() noexcept;
void setupLyricsView() noexcept;
void updateLyricsDisplay() noexcept;
QString loadLyrics(const QString &filePath) const noexcept;
QString formatTime(qint64 milliseconds) const noexcept;
void setupTray() noexcept;
void dropEvent(QDropEvent* ev) noexcept;
void playModeClicked() noexcept;
void playerDurationChanged(qint64 d) noexcept;
void playerPositionChanged(qint64 p) noexcept;
void playerMediaStatusChanged(QMediaPlayer::MediaStatus status) noexcept;
void musicProgressPressed() noexcept;
void musicProgressReleased() noexcept;
void musicProgressValueChanged(int value) noexcept;
void volumeChanged(int v) noexcept;
Ui::MainWindow* ui;
QAudioOutput audio;
QMediaPlayer player;
PlaylistModel playlistModel;
int currentTrackIndex, shuffleIndex;
QStackedWidget viewStack;
QTextEdit lyricsDisplay;
bool isLyricsView;
bool muted;
int volume_;
QSystemTrayIcon trayIcon{this};
QMenu trayMenu{"播放控制", this};
QAction actPrev{"上一曲", &trayMenu};
QAction actPlay{"播放", &trayMenu};
QAction actNext{"下一曲", &trayMenu};
};
#endif // MAINWINDOW_H