diff --git a/StartVM.sh b/StartVM.sh index ef87b5d..bb8ef0f 100755 --- a/StartVM.sh +++ b/StartVM.sh @@ -15,6 +15,12 @@ if [[ 0 == $? ]]; then fi # 检查是否有 QEMU if [[ -f "$HOME/Qemu/Windows/Windows.qcow2" ]]; then + if [[ -f "$HOME/.config/deepin-wine-runner/QemuSetting.json" ]]; then + echo 有设置文件,读设置文件 + cd `dirname $0` + python3 ./VM/StartQemu.py + exit + fi # 查看逻辑CPU的个数 CpuCount=`cat /proc/cpuinfo| grep "processor"| wc -l` diff --git a/VM-source/qemusetting.cpp b/VM-source/qemusetting.cpp index f26744a..40a556b 100644 --- a/VM-source/qemusetting.cpp +++ b/VM-source/qemusetting.cpp @@ -15,6 +15,8 @@ QemuSetting::QemuSetting(QWidget *parent) : ui(new Ui::QemuSetting) { ui->setupUi(this); + // 判断是否安装了 Wine 运行器 + ui->getrunner->setHidden(QFile::exists(QCoreApplication::applicationDirPath() + "/../mainwindow.py")); // 设置变量 if(QFile::exists(QDir::homePath() + "/.config/deepin-wine-runner/QemuSetting.json")){ // 读取配置文件 @@ -89,6 +91,10 @@ void QemuSetting::on_save_clicked() object.insert("CPU", ui->cpuNumber->value()); qDebug() << QJsonDocument(object).toJson(); // 读取配置文件 + QDir dir(QDir::homePath() + "/.config/deepin-wine-runner/"); + if(!dir.exists()){ + dir.mkpath(QDir::homePath() + "/.config/deepin-wine-runner/"); + } QFile file(QDir::homePath() + "/.config/deepin-wine-runner/QemuSetting.json"); file.open(QIODevice::WriteOnly); file.write(QJsonDocument(object).toJson()); @@ -105,3 +111,19 @@ void QemuSetting::on_getrunner_clicked() { QDesktopServices::openUrl(QUrl("https://gitee.com/gfdgd-xi/deep-wine-runner/")); } + +void QemuSetting::on_enableVnc_stateChanged(int arg1) +{ + // 控件的开启/关闭 + ui->vncNumber->setEnabled(ui->enableVnc->isChecked()); +} + +void QemuSetting::on_setDefault_clicked() +{ + if(QMessageBox::question(this, "提示", "你确定要重置为默认?重置后将无法恢复") == QMessageBox::No){ + return; + } + QFile::remove(QDir::homePath() + "/.config/deepin-wine-runner/QemuSetting.json"); + this->SetDefaultValue(); + QMessageBox::information(this, "提示", "设置完成!"); +} diff --git a/VM-source/qemusetting.h b/VM-source/qemusetting.h index f3d6866..18ea1a5 100644 --- a/VM-source/qemusetting.h +++ b/VM-source/qemusetting.h @@ -27,6 +27,10 @@ private slots: void on_getrunner_clicked(); + void on_enableVnc_stateChanged(int arg1); + + void on_setDefault_clicked(); + private: void SetDefaultValue(); Ui::QemuSetting *ui; diff --git a/VM-source/qemusetting.ui b/VM-source/qemusetting.ui index 6d6b764..258ef78 100644 --- a/VM-source/qemusetting.ui +++ b/VM-source/qemusetting.ui @@ -159,8 +159,28 @@ + + + + + 0 + 0 + + + + 重置 +默认 + + + + + + 0 + 0 + + 获取 Wine