From 4fe7c8a62e75ce7a155f5ecb08173cf42d5e62f2 Mon Sep 17 00:00:00 2001 From: xiaoming <2014500726@smail.xtu.edu.cn> Date: Mon, 26 Aug 2024 13:36:19 +0800 Subject: [PATCH] Automatically use the default configuration if the Profile does not exist on Windows Signed-off-by: xiaoming <2014500726@smail.xtu.edu.cn> --- CHANGELOG.md | 8 ++++++++ docs/changelog.md | 2 ++ src/globaloptions/globaloptionswindow.cpp | 11 +++++++++++ 3 files changed, 21 insertions(+) diff --git a/CHANGELOG.md b/CHANGELOG.md index 48ef7d4d..d94b397b 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -2,6 +2,14 @@ ## [[Unrelease](https://github.com/QQxiaoming/quardCRT)] +en-US: + +- Automatically use the default configuration if the Profile does not exist on Windows + +zh-CN: + +- Windows下Profile如果不存在则自动使用默认配置 + ## [[V0.5.0](https://github.com/QQxiaoming/quardCRT/releases/tag/V0.5.0)] - 2024-08-26 en-US: diff --git a/docs/changelog.md b/docs/changelog.md index 4811f5e5..d89d8def 100644 --- a/docs/changelog.md +++ b/docs/changelog.md @@ -4,6 +4,8 @@ ## [[Unrelease](https://github.com/QQxiaoming/quardCRT)] +- Automatically use the default configuration if the Profile does not exist on Windows + ## [[V0.5.0](https://github.com/QQxiaoming/quardCRT/releases/tag/V0.5.0)] - 2024-08-26 - Add Python scripting engine for scripting feature [#31](https://github.com/QQxiaoming/quardCRT/pull/31) diff --git a/src/globaloptions/globaloptionswindow.cpp b/src/globaloptions/globaloptionswindow.cpp index 5f3aa610..d50116fa 100644 --- a/src/globaloptions/globaloptionswindow.cpp +++ b/src/globaloptions/globaloptionswindow.cpp @@ -651,6 +651,17 @@ bool GlobalOptionsWindow::getEnableCtrlC(void) #if defined(Q_OS_WIN) QString GlobalOptionsWindow::getPowerShellProfile(void) { + GlobalSetting settings; + QString profile = settings.value("Global/Options/PowerShellProfile", QApplication::applicationDirPath() + "/Profile.ps1").toString(); + if (!profile.isEmpty()) { + QFileInfo profileInfo(profile); + if(!profileInfo.exists() || !profileInfo.isFile()) { + globalOptionsAdvancedWidget->ui->lineEditPowerShellProfile->setText(QApplication::applicationDirPath() + "/Profile.ps1"); + } + } else { + globalOptionsAdvancedWidget->ui->lineEditPowerShellProfile->setText(QApplication::applicationDirPath() + "/Profile.ps1"); + } + settings.setValue("Global/Options/PowerShellProfile", globalOptionsAdvancedWidget->ui->lineEditPowerShellProfile->text()); return globalOptionsAdvancedWidget->ui->lineEditPowerShellProfile->text(); } #endif