Skip to content

Commit

Permalink
配置文件保存在exe所属目录下
Browse files Browse the repository at this point in the history
  • Loading branch information
orestonce committed Oct 21, 2024
1 parent 247bc90 commit ae19c78
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 4 deletions.
12 changes: 8 additions & 4 deletions m3u8d-qt/mainwindow.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -234,8 +234,6 @@ void MainWindow::updateMergeUi(bool runing)
ui->checkBox_SkipBadResolutionFps->setEnabled(!runing);
}

static const QString configPath = "m3u8d_config.json";

void MainWindow::saveUiConfig()
{
QJsonObject obj;
Expand All @@ -259,7 +257,7 @@ void MainWindow::saveUiConfig()
QJsonDocument doc;
doc.setObject(obj);
QByteArray data = doc.toJson();
QFile file(configPath);
QFile file(getConfigFilePath());
if(!file.open(QFile::WriteOnly)) {
return;
}
Expand All @@ -277,7 +275,7 @@ void setupCheckbox(QJsonObject& obj,QCheckBox *box, QString key)

void MainWindow::loadUiConfig()
{
QFile file(configPath);
QFile file(getConfigFilePath());
if(!file.open(QFile::ReadOnly)) {
return;
}
Expand Down Expand Up @@ -328,6 +326,12 @@ void MainWindow::loadUiConfig()
setupCheckbox(obj, ui->checkBox_SkipBadResolutionFps, "SkipBadResolutionFps");
}

QString MainWindow::getConfigFilePath()
{
QString dp =QApplication::applicationDirPath() + QDir::separator() + "m3u8d_config.json";
return QDir::cleanPath(dp);
}

void MainWindow::closeEvent(QCloseEvent *event)
{
do {
Expand Down
1 change: 1 addition & 0 deletions m3u8d-qt/mainwindow.h
Original file line number Diff line number Diff line change
Expand Up @@ -47,6 +47,7 @@ private slots:

void saveUiConfig();
void loadUiConfig();
QString getConfigFilePath();
private:
Ui::MainWindow *ui;
RunOnUiThread m_syncUi;
Expand Down

0 comments on commit ae19c78

Please sign in to comment.