From 466a7c559659df5ee33e8effab8c38d81af1f81a Mon Sep 17 00:00:00 2001
From: gfdgd_xi <3025613752@qq.com>
Date: Sat, 29 Apr 2023 17:09:09 +0800
Subject: [PATCH] =?UTF-8?q?=E6=9B=B4=E6=96=B0UI+=E6=96=B0=E5=A2=9E?=
=?UTF-8?q?=E7=A3=81=E7=9B=98=E6=96=87=E4=BB=B6=E6=B7=BB=E5=8A=A0/?=
=?UTF-8?q?=E5=AF=BC=E5=87=BA/=E5=88=A0=E9=99=A4=E5=8A=9F=E8=83=BD?=
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
---
VM-source/mainwindow.cpp | 44 ++++++++++++++++++++++++++++++++----
VM-source/mainwindow.h | 6 +++++
VM-source/mainwindow.ui | 49 +++++++++++++++++++++-------------------
3 files changed, 71 insertions(+), 28 deletions(-)
diff --git a/VM-source/mainwindow.cpp b/VM-source/mainwindow.cpp
index 40ce13b..ae2b781 100755
--- a/VM-source/mainwindow.cpp
+++ b/VM-source/mainwindow.cpp
@@ -215,13 +215,21 @@ void MainWindow::on_addQemuDisk_triggered()
if(path == ""){
return;
}
- QDir dir(QDir::homePath() + "/Qemu/Windows/Windows.qcow2");
+ QDir dir(QDir::homePath() + "/Qemu/Windows");
if(!dir.exists()){
- dir.mkpath(QDir::homePath() + "/Qemu/Windows/Windows.qcow2");
+ dir.mkpath(QDir::homePath() + "/Qemu/Windows");
}
- if(!QFile::remove(QDir::homePath() + "/Qemu/Windows/Windows.qcow2") | !QFile::copy(path, QDir::homePath() + "/Qemu/Windows/Windows.qcow2")){
- QMessageBox::critical(this, "提示", "添加错误!");
- return;
+ if(QFile::exists(QDir::homePath() + "/Qemu/Windows/Windows.qcow2")){
+ if(!QFile::remove(QDir::homePath() + "/Qemu/Windows/Windows.qcow2") | !QFile::copy(path, QDir::homePath() + "/Qemu/Windows/Windows.qcow2")){
+ QMessageBox::critical(this, "提示", "添加错误!");
+ return;
+ }
+ }
+ else{
+ if(!QFile::copy(path, QDir::homePath() + "/Qemu/Windows/Windows.qcow2")){
+ QMessageBox::critical(this, "提示", "添加错误!");
+ return;
+ }
}
QMessageBox::information(this, "提示", "添加完成!");
}
@@ -234,3 +242,29 @@ void MainWindow::on_delQemuDisk_triggered()
}
std::system(("xdg-open \"" + QDir::homePath() + "/Qemu/Windows/\"").toUtf8());
}
+
+void MainWindow::on_addQemuDiskButton_clicked()
+{
+ MainWindow::on_addQemuDisk_triggered();
+}
+
+void MainWindow::on_saveQemuDiskButton_clicked()
+{
+ MainWindow::on_delQemuDisk_triggered();
+}
+
+void MainWindow::on_delQemuDiskButton_clicked()
+{
+ if(!QFile::exists(QDir::homePath() + "/Qemu/Windows/Windows.qcow2")){
+ QMessageBox::information(this, "提示", "不存在磁盘文件,无法移除");
+ return;
+ }
+ if(QMessageBox::question(this, "提示", "是否删除?\n删除后将无法恢复!") == QMessageBox::No){
+ return;
+ }
+ if(!QFile::remove(QDir::homePath() + "/Qemu/Windows/Windows.qcow2")){
+ QMessageBox::critical(this, "提示", "移除失败");
+ return;
+ }
+ QMessageBox::information(this, "提示", "移除成功");
+}
diff --git a/VM-source/mainwindow.h b/VM-source/mainwindow.h
index ff179a6..ad5c725 100755
--- a/VM-source/mainwindow.h
+++ b/VM-source/mainwindow.h
@@ -38,6 +38,12 @@ private slots:
void on_delQemuDisk_triggered();
+ void on_addQemuDiskButton_clicked();
+
+ void on_saveQemuDiskButton_clicked();
+
+ void on_delQemuDiskButton_clicked();
+
private:
Ui::MainWindow *ui;
long m_cpuAll;
diff --git a/VM-source/mainwindow.ui b/VM-source/mainwindow.ui
index 82760f3..66412cc 100755
--- a/VM-source/mainwindow.ui
+++ b/VM-source/mainwindow.ui
@@ -6,8 +6,8 @@
0
0
- 807
- 429
+ 1058
+ 512
@@ -25,7 +25,7 @@
QTabWidget::Rounded
- 2
+ 0
@@ -142,6 +142,13 @@
+ -
+
+
+ 安装 Qemu
+
+
+
-
@@ -150,9 +157,23 @@
-
-
+
- 安装 Qemu
+ 添加/覆盖Qemu磁盘
+
+
+
+ -
+
+
+ 导出Qemu磁盘
+
+
+
+ -
+
+
+ 移除Qemu磁盘
@@ -374,24 +395,6 @@ p, li { white-space: pre-wrap; }
-
退出