feat: remember volume
This commit is contained in:
parent
cf90e2d70c
commit
a3bc60c977
|
@ -32,6 +32,7 @@
|
|||
#include <QAudioDevice>
|
||||
#include <QMessageBox>
|
||||
#include <QStringBuilder>
|
||||
#include <QSettings>
|
||||
|
||||
constexpr QSize miniSize(490, 160);
|
||||
constexpr QSize fullSize(490, 420);
|
||||
|
@ -57,10 +58,13 @@ MainWindow::MainWindow(QWidget *parent)
|
|||
|
||||
ui->actionHelp->setShortcut(QKeySequence::HelpContents);
|
||||
addAction(ui->actionHelp);
|
||||
ui->actionOpen->setShortcut(QKeySequence::Open);
|
||||
addAction(ui->actionOpen);
|
||||
|
||||
setWindowFlags(Qt::FramelessWindowHint | Qt::WindowSystemMenuHint | Qt::WindowMinimizeButtonHint);
|
||||
setAttribute(Qt::WA_TranslucentBackground, true);
|
||||
|
||||
loadConfig();
|
||||
loadSkinData();
|
||||
initConnections();
|
||||
initUiAndAnimation();
|
||||
|
@ -70,6 +74,7 @@ MainWindow::MainWindow(QWidget *parent)
|
|||
|
||||
MainWindow::~MainWindow()
|
||||
{
|
||||
saveConfig();
|
||||
delete m_lrcbar;
|
||||
delete ui;
|
||||
}
|
||||
|
@ -531,9 +536,27 @@ void MainWindow::initConnections()
|
|||
});
|
||||
}
|
||||
|
||||
void MainWindow::loadConfig()
|
||||
{
|
||||
QDir configDir(QStandardPaths::writableLocation(QStandardPaths::AppConfigLocation));
|
||||
QSettings settings(configDir.filePath("settings.ini"), QSettings::IniFormat);
|
||||
ui->volumeSlider->setValue(settings.value("volume", 100).toInt());
|
||||
}
|
||||
|
||||
void MainWindow::saveConfig()
|
||||
{
|
||||
QDir configDir(QStandardPaths::writableLocation(QStandardPaths::AppConfigLocation));
|
||||
if (!configDir.exists()) {
|
||||
configDir.mkpath(".");
|
||||
}
|
||||
QSettings settings(configDir.filePath("settings.ini"), QSettings::IniFormat);
|
||||
settings.setValue("volume", ui->volumeSlider->value());
|
||||
}
|
||||
|
||||
void MainWindow::loadSkinData()
|
||||
{
|
||||
QFile file(QStandardPaths::writableLocation(QStandardPaths::AppConfigLocation) + "/skin.dat");
|
||||
QDir configDir(QStandardPaths::writableLocation(QStandardPaths::AppConfigLocation));
|
||||
QFile file(configDir.filePath("skin.dat"));
|
||||
bool canOpen = file.open(QIODevice::ReadOnly);
|
||||
if (!canOpen) return;
|
||||
QDataStream stream(&file);
|
||||
|
@ -609,6 +632,10 @@ void MainWindow::on_lrcBtn_clicked()
|
|||
}
|
||||
}
|
||||
|
||||
void MainWindow::on_actionOpen_triggered()
|
||||
{
|
||||
loadFile();
|
||||
}
|
||||
|
||||
void MainWindow::on_actionHelp_triggered()
|
||||
{
|
||||
|
|
|
@ -76,6 +76,7 @@ private slots:
|
|||
void on_playListBtn_clicked();
|
||||
void on_playlistView_activated(const QModelIndex &index);
|
||||
void on_lrcBtn_clicked();
|
||||
void on_actionOpen_triggered();
|
||||
void on_actionHelp_triggered();
|
||||
|
||||
signals:
|
||||
|
@ -101,6 +102,8 @@ private:
|
|||
void initUiAndAnimation();
|
||||
void initConnections();
|
||||
|
||||
void loadConfig();
|
||||
void saveConfig();
|
||||
void loadSkinData();
|
||||
void saveSkinData();
|
||||
|
||||
|
|
|
@ -72,6 +72,7 @@ QSlider::add-page:vertical {
|
|||
/****** PushButton ******/
|
||||
|
||||
QPushButton {
|
||||
color: white;
|
||||
border: 0px solid grey;
|
||||
background-color: transparent;
|
||||
}
|
||||
|
@ -106,6 +107,7 @@ QLabel#coverLabel {
|
|||
/****** ListView ******/
|
||||
|
||||
QListView {
|
||||
color: white;
|
||||
background: rgba(0, 0, 0, 50);
|
||||
}</string>
|
||||
</property>
|
||||
|
@ -659,7 +661,10 @@ QListView {
|
|||
</widget>
|
||||
<action name="actionHelp">
|
||||
<property name="text">
|
||||
<string>help</string>
|
||||
<string>Help</string>
|
||||
</property>
|
||||
<property name="toolTip">
|
||||
<string>Help</string>
|
||||
</property>
|
||||
<property name="shortcut">
|
||||
<string>F1</string>
|
||||
|
@ -668,6 +673,20 @@ QListView {
|
|||
<enum>QAction::MenuRole::NoRole</enum>
|
||||
</property>
|
||||
</action>
|
||||
<action name="actionOpen">
|
||||
<property name="icon">
|
||||
<iconset theme="document-open"/>
|
||||
</property>
|
||||
<property name="text">
|
||||
<string>Open</string>
|
||||
</property>
|
||||
<property name="shortcut">
|
||||
<string>Ctrl+O</string>
|
||||
</property>
|
||||
<property name="menuRole">
|
||||
<enum>QAction::MenuRole::NoRole</enum>
|
||||
</property>
|
||||
</action>
|
||||
</widget>
|
||||
<customwidgets>
|
||||
<customwidget>
|
||||
|
|
Loading…
Reference in New Issue
Block a user