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; }
-
退出