mirror of
https://gitee.com/gfdgd-xi/deep-wine-runner
synced 2025-01-27 16:38:06 +08:00
完善设置功能
This commit is contained in:
parent
db5cee1345
commit
620cea5136
@ -197,7 +197,7 @@ void MainWindow::on_vmChooser_currentIndexChanged(int index)
|
|||||||
|
|
||||||
void MainWindow::on_qemuSetting_clicked()
|
void MainWindow::on_qemuSetting_clicked()
|
||||||
{
|
{
|
||||||
QemuSetting show;
|
QemuSetting *show = new QemuSetting();
|
||||||
show.show();
|
show->show();
|
||||||
show.exec();
|
|
||||||
}
|
}
|
||||||
|
@ -3,12 +3,60 @@
|
|||||||
#include <QMessageBox>
|
#include <QMessageBox>
|
||||||
#include <QDesktopServices>
|
#include <QDesktopServices>
|
||||||
#include <QUrl>
|
#include <QUrl>
|
||||||
|
#include <QJsonObject>
|
||||||
|
#include <QJsonDocument>
|
||||||
|
#include <QFile>
|
||||||
|
#include "infoutils.h"
|
||||||
|
#include <QDir>
|
||||||
|
#include <sys/sysinfo.h>
|
||||||
|
|
||||||
QemuSetting::QemuSetting(QWidget *parent) :
|
QemuSetting::QemuSetting(QWidget *parent) :
|
||||||
QDialog(parent),
|
QWidget(parent),
|
||||||
ui(new Ui::QemuSetting)
|
ui(new Ui::QemuSetting)
|
||||||
{
|
{
|
||||||
ui->setupUi(this);
|
ui->setupUi(this);
|
||||||
|
// 设置变量
|
||||||
|
if(QFile::exists(QDir::homePath() + "/.config/deepin-wine-runner/QemuSetting.json")){
|
||||||
|
// 读取配置文件
|
||||||
|
QFile file(QDir::homePath() + "/.config/deepin-wine-runner/QemuSetting.json");
|
||||||
|
file.open(QIODevice::ReadOnly);
|
||||||
|
QJsonParseError error;
|
||||||
|
QJsonDocument document = QJsonDocument::fromJson(file.readAll(), &error);
|
||||||
|
file.close();
|
||||||
|
if(error.error != QJsonParseError::NoError){
|
||||||
|
QMessageBox::critical(this, "错误", error.errorString());
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
QJsonObject object = document.object();
|
||||||
|
qDebug() << QJsonDocument(object).toJson();
|
||||||
|
ui->enableKvm->setChecked(object.value("EnableKVM").toBool());
|
||||||
|
ui->enableRdp->setChecked(object.value("EnableRDP").toBool());
|
||||||
|
ui->enableVnc->setChecked(object.value("EnableVNC").toBool());
|
||||||
|
ui->enableSound->setChecked(object.value("EnableSound").toBool());
|
||||||
|
ui->memoryNumber->setValue(object.value("Memory").toInt());
|
||||||
|
ui->vncNumber->setValue(object.value("VNC").toInt());
|
||||||
|
ui->cpuNumber->setValue(object.value("CPU").toInt());
|
||||||
|
}
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
// 默认
|
||||||
|
this->SetDefaultValue();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
void QemuSetting::SetDefaultValue(){
|
||||||
|
long memory = 0;
|
||||||
|
long memoryAll = 0;
|
||||||
|
long swap = 0;
|
||||||
|
long swapAll = 0;
|
||||||
|
infoUtils::memoryRate(memory, memoryAll, swap, swapAll);
|
||||||
|
ui->memoryNumber->setValue(memoryAll / 3 / 1024);
|
||||||
|
ui->vncNumber->setValue(5);
|
||||||
|
ui->cpuNumber->setValue(get_nprocs());
|
||||||
|
ui->enableKvm->setChecked(true);
|
||||||
|
ui->enableRdp->setChecked(true);
|
||||||
|
ui->enableVnc->setChecked(true);
|
||||||
|
ui->enableSound->setChecked(true);
|
||||||
}
|
}
|
||||||
|
|
||||||
QemuSetting::~QemuSetting()
|
QemuSetting::~QemuSetting()
|
||||||
@ -24,12 +72,27 @@ void QemuSetting::on_buttonBox_accepted()
|
|||||||
|
|
||||||
void QemuSetting::on_save_clicked()
|
void QemuSetting::on_save_clicked()
|
||||||
{
|
{
|
||||||
|
QJsonParseError error;
|
||||||
|
QJsonDocument document = QJsonDocument::fromJson("{}", &error);
|
||||||
|
if(error.error != QJsonParseError::NoError){
|
||||||
|
QMessageBox::critical(this, "错误", error.errorString());
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
QJsonObject object = document.object();
|
||||||
|
//object.insert("1", QJsonValue("aa"));
|
||||||
|
object.insert("EnableKVM", ui->enableKvm->isChecked());
|
||||||
|
object.insert("EnableRDP", ui->enableRdp->isChecked());
|
||||||
|
object.insert("EnableVNC", ui->enableVnc->isChecked());
|
||||||
|
object.insert("EnableSound", ui->enableSound->isChecked());
|
||||||
|
object.insert("Memory", ui->memoryNumber->value());
|
||||||
|
object.insert("VNC", ui->vncNumber->value());
|
||||||
|
object.insert("CPU", ui->cpuNumber->value());
|
||||||
|
qDebug() << QJsonDocument(object).toJson();
|
||||||
}
|
}
|
||||||
|
|
||||||
void QemuSetting::on_cancel_clicked()
|
void QemuSetting::on_cancel_clicked()
|
||||||
{
|
{
|
||||||
accept();
|
delete this;
|
||||||
}
|
}
|
||||||
|
|
||||||
void QemuSetting::on_getrunner_clicked()
|
void QemuSetting::on_getrunner_clicked()
|
||||||
|
@ -1,13 +1,15 @@
|
|||||||
#ifndef QEMUSETTING_H
|
#ifndef QEMUSETTING_H
|
||||||
#define QEMUSETTING_H
|
#define QEMUSETTING_H
|
||||||
|
|
||||||
#include <QDialog>
|
#include <QWidget>
|
||||||
|
#include <QCheckBox>
|
||||||
|
#include <QSpinBox>
|
||||||
|
|
||||||
namespace Ui {
|
namespace Ui {
|
||||||
class QemuSetting;
|
class QemuSetting;
|
||||||
}
|
}
|
||||||
|
|
||||||
class QemuSetting : public QDialog
|
class QemuSetting : public QWidget
|
||||||
{
|
{
|
||||||
Q_OBJECT
|
Q_OBJECT
|
||||||
|
|
||||||
@ -15,6 +17,7 @@ public:
|
|||||||
explicit QemuSetting(QWidget *parent = nullptr);
|
explicit QemuSetting(QWidget *parent = nullptr);
|
||||||
~QemuSetting();
|
~QemuSetting();
|
||||||
|
|
||||||
|
|
||||||
private slots:
|
private slots:
|
||||||
void on_buttonBox_accepted();
|
void on_buttonBox_accepted();
|
||||||
|
|
||||||
@ -25,6 +28,7 @@ private slots:
|
|||||||
void on_getrunner_clicked();
|
void on_getrunner_clicked();
|
||||||
|
|
||||||
private:
|
private:
|
||||||
|
void SetDefaultValue();
|
||||||
Ui::QemuSetting *ui;
|
Ui::QemuSetting *ui;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
@ -1,22 +1,22 @@
|
|||||||
<?xml version="1.0" encoding="UTF-8"?>
|
<?xml version="1.0" encoding="UTF-8"?>
|
||||||
<ui version="4.0">
|
<ui version="4.0">
|
||||||
<class>QemuSetting</class>
|
<class>QemuSetting</class>
|
||||||
<widget class="QDialog" name="QemuSetting">
|
<widget class="QWidget" name="QemuSetting">
|
||||||
<property name="geometry">
|
<property name="geometry">
|
||||||
<rect>
|
<rect>
|
||||||
<x>0</x>
|
<x>0</x>
|
||||||
<y>0</y>
|
<y>0</y>
|
||||||
<width>400</width>
|
<width>496</width>
|
||||||
<height>300</height>
|
<height>300</height>
|
||||||
</rect>
|
</rect>
|
||||||
</property>
|
</property>
|
||||||
<property name="windowTitle">
|
<property name="windowTitle">
|
||||||
<string>Dialog</string>
|
<string>设置</string>
|
||||||
</property>
|
</property>
|
||||||
<layout class="QHBoxLayout" name="horizontalLayout">
|
<layout class="QHBoxLayout" name="horizontalLayout">
|
||||||
<item>
|
<item>
|
||||||
<layout class="QGridLayout" name="gridLayout">
|
<layout class="QGridLayout" name="gridLayout">
|
||||||
<item row="8" column="1">
|
<item row="9" column="1">
|
||||||
<spacer name="horizontalSpacer">
|
<spacer name="horizontalSpacer">
|
||||||
<property name="orientation">
|
<property name="orientation">
|
||||||
<enum>Qt::Horizontal</enum>
|
<enum>Qt::Horizontal</enum>
|
||||||
@ -29,17 +29,24 @@
|
|||||||
</property>
|
</property>
|
||||||
</spacer>
|
</spacer>
|
||||||
</item>
|
</item>
|
||||||
<item row="5" column="0">
|
<item row="4" column="0">
|
||||||
|
<widget class="QLabel" name="label_2">
|
||||||
|
<property name="text">
|
||||||
|
<string><h3>远程服务</h3></string>
|
||||||
|
</property>
|
||||||
|
</widget>
|
||||||
|
</item>
|
||||||
|
<item row="6" column="0">
|
||||||
<widget class="QLabel" name="label_4">
|
<widget class="QLabel" name="label_4">
|
||||||
<property name="text">
|
<property name="text">
|
||||||
<string>VNC服务端口:</string>
|
<string>VNC服务端口:</string>
|
||||||
</property>
|
</property>
|
||||||
</widget>
|
</widget>
|
||||||
</item>
|
</item>
|
||||||
<item row="3" column="0">
|
<item row="5" column="1">
|
||||||
<widget class="QLabel" name="label_2">
|
<widget class="QCheckBox" name="enableRdp">
|
||||||
<property name="text">
|
<property name="text">
|
||||||
<string><h3>远程服务</h3></string>
|
<string>开启 rdp 服务映射</string>
|
||||||
</property>
|
</property>
|
||||||
</widget>
|
</widget>
|
||||||
</item>
|
</item>
|
||||||
@ -50,7 +57,14 @@
|
|||||||
</property>
|
</property>
|
||||||
</widget>
|
</widget>
|
||||||
</item>
|
</item>
|
||||||
<item row="7" column="1">
|
<item row="1" column="1">
|
||||||
|
<widget class="QSpinBox" name="memoryNumber">
|
||||||
|
<property name="maximum">
|
||||||
|
<number>999999999</number>
|
||||||
|
</property>
|
||||||
|
</widget>
|
||||||
|
</item>
|
||||||
|
<item row="8" column="1">
|
||||||
<spacer name="verticalSpacer">
|
<spacer name="verticalSpacer">
|
||||||
<property name="orientation">
|
<property name="orientation">
|
||||||
<enum>Qt::Vertical</enum>
|
<enum>Qt::Vertical</enum>
|
||||||
@ -63,26 +77,13 @@
|
|||||||
</property>
|
</property>
|
||||||
</spacer>
|
</spacer>
|
||||||
</item>
|
</item>
|
||||||
<item row="1" column="1">
|
<item row="6" column="1">
|
||||||
<widget class="QSpinBox" name="spinBox"/>
|
<widget class="QSpinBox" name="vncNumber">
|
||||||
</item>
|
<property name="maximum">
|
||||||
<item row="4" column="1">
|
<number>9999</number>
|
||||||
<widget class="QCheckBox" name="checkBox">
|
|
||||||
<property name="text">
|
|
||||||
<string>开启 rdp 服务映射</string>
|
|
||||||
</property>
|
</property>
|
||||||
</widget>
|
</widget>
|
||||||
</item>
|
</item>
|
||||||
<item row="4" column="0">
|
|
||||||
<widget class="QCheckBox" name="checkBox_2">
|
|
||||||
<property name="text">
|
|
||||||
<string>开启VNC服务</string>
|
|
||||||
</property>
|
|
||||||
</widget>
|
|
||||||
</item>
|
|
||||||
<item row="5" column="1">
|
|
||||||
<widget class="QSpinBox" name="spinBox_2"/>
|
|
||||||
</item>
|
|
||||||
<item row="0" column="0">
|
<item row="0" column="0">
|
||||||
<widget class="QLabel" name="label_6">
|
<widget class="QLabel" name="label_6">
|
||||||
<property name="text">
|
<property name="text">
|
||||||
@ -90,13 +91,41 @@
|
|||||||
</property>
|
</property>
|
||||||
</widget>
|
</widget>
|
||||||
</item>
|
</item>
|
||||||
<item row="2" column="0">
|
<item row="5" column="0">
|
||||||
<widget class="QCheckBox" name="checkBox_3">
|
<widget class="QCheckBox" name="enableVnc">
|
||||||
|
<property name="text">
|
||||||
|
<string>开启VNC服务</string>
|
||||||
|
</property>
|
||||||
|
</widget>
|
||||||
|
</item>
|
||||||
|
<item row="3" column="0">
|
||||||
|
<widget class="QCheckBox" name="enableKvm">
|
||||||
<property name="text">
|
<property name="text">
|
||||||
<string>开启 kvm 加速</string>
|
<string>开启 kvm 加速</string>
|
||||||
</property>
|
</property>
|
||||||
</widget>
|
</widget>
|
||||||
</item>
|
</item>
|
||||||
|
<item row="2" column="0">
|
||||||
|
<widget class="QLabel" name="label_3">
|
||||||
|
<property name="text">
|
||||||
|
<string>CPU核心数:</string>
|
||||||
|
</property>
|
||||||
|
</widget>
|
||||||
|
</item>
|
||||||
|
<item row="2" column="1">
|
||||||
|
<widget class="QSpinBox" name="cpuNumber">
|
||||||
|
<property name="maximum">
|
||||||
|
<number>999999999</number>
|
||||||
|
</property>
|
||||||
|
</widget>
|
||||||
|
</item>
|
||||||
|
<item row="3" column="1">
|
||||||
|
<widget class="QCheckBox" name="enableSound">
|
||||||
|
<property name="text">
|
||||||
|
<string>开启声音</string>
|
||||||
|
</property>
|
||||||
|
</widget>
|
||||||
|
</item>
|
||||||
</layout>
|
</layout>
|
||||||
</item>
|
</item>
|
||||||
<item>
|
<item>
|
||||||
|
Loading…
x
Reference in New Issue
Block a user