-
Notifications
You must be signed in to change notification settings - Fork 2
/
Copy pathmainsettings.cpp
52 lines (42 loc) · 1 KB
/
mainsettings.cpp
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
#include "mainsettings.h"
#include "ui_mainsettings.h"
MainSettings::MainSettings(QMediaPlayer *_player, QAudioOutput *_output, QWidget *parent) :
player(_player),
output(_output),
QWidget(parent),
ui(new Ui::MainSettings)
{
ui->setupUi(this);
this -> setFixedSize((parent -> size()));
ui -> MusicController -> setValue(output -> volume() * 100);
if(!player -> isPlaying()){
ui -> MusicPause -> setText("播放音乐");
}
}
MainSettings::~MainSettings()
{
delete ui;
}
void MainSettings::on_MusicPause_clicked()
{
if(player->isPlaying()){
player -> pause();
ui -> MusicPause -> setText("播放音乐");
}
else {
player -> play();
ui -> MusicPause -> setText("暂停音乐");
}
}
void MainSettings::on_SettingsExit_clicked()
{
this -> close();
}
void MainSettings::on_GameExit_clicked()
{
exit(0);
}
void MainSettings::on_MusicController_valueChanged(int value)
{
this -> output -> setVolume(value / 100.0);
}