虚拟机工具支持强制关闭 VirtualBox/Qemu,并增加了对 Windows 7 安装脚本的检测

This commit is contained in:
gfdgd xi 2023-11-12 11:13:42 +08:00
parent ff15b60e4c
commit 4812a9a872
3 changed files with 47 additions and 0 deletions

View File

@ -24,6 +24,8 @@
#include <QIODevice>
#include <QInputDialog>
#include "qemusetting.h"
#include "vbox.h"
#include "qemu.h"
MainWindow::MainWindow(QWidget *parent) :
QMainWindow(parent),
@ -205,6 +207,20 @@ void MainWindow::on_install_clicked()
archFile.write("amd64");
archFile.close();
switch (ui->systemVersion->currentIndex()) {
case 0:
if(!QFile::exists(QCoreApplication::applicationDirPath() + "/Windows7X86Auto.iso")){
if(QMessageBox::question(this, "提示", "似乎无法找到 Windows7X86Auto.iso是否继续创建虚拟机\n缺少该文件可能会导致虚拟机无法正常启动,尝试重新安装 Wine 运行器再试试?") == QMessageBox::No){
return;
}
}
break;
case 1:
if(!QFile::exists(QCoreApplication::applicationDirPath() + "/Windows7X64Auto.iso")){
if(QMessageBox::question(this, "提示", "似乎无法找到 Windows7X64Auto.iso是否继续创建虚拟机\n缺少该文件可能会导致虚拟机无法正常启动,尝试重新安装 Wine 运行器再试试?") == QMessageBox::No){
return;
}
}
break;
case 3:
if(!QFile::exists("/usr/share/qemu/OVMF.fd") && !QFile::exists(QCoreApplication::applicationDirPath() + "/OVMF.fd") && ui->vmChooser->currentIndex() == 0){
if(QMessageBox::question(this, "提示", "似乎无法找到 UEFI 固件,是否继续创建虚拟机?\nQemu 固件可以在“安装 Qemu”处安装") == QMessageBox::No){
@ -419,3 +435,17 @@ void MainWindow::on_actionVMInstallLog_triggered()
file.close();
}
void MainWindow::on_action_StopVirtualBox_triggered()
{
vbox vmControl("");
vmControl.Stop();
}
void MainWindow::on_action_StopQemu_triggered()
{
qemu vmControl("");
vmControl.Stop();
}

View File

@ -54,6 +54,10 @@ private slots:
void on_actionVMInstallLog_triggered();
void on_action_StopVirtualBox_triggered();
void on_action_StopQemu_triggered();
private:
bool stopShowTime = 0;
Ui::MainWindow *ui;

View File

@ -466,6 +466,9 @@ p, li { white-space: pre-wrap; }
<addaction name="actionVMRunlLog"/>
<addaction name="separator"/>
<addaction name="actionVMTest"/>
<addaction name="separator"/>
<addaction name="action_StopVirtualBox"/>
<addaction name="action_StopQemu"/>
</widget>
<addaction name="menuVM"/>
</widget>
@ -504,6 +507,16 @@ p, li { white-space: pre-wrap; }
<string>虚拟机测试X86、Qemu</string>
</property>
</action>
<action name="action_StopVirtualBox">
<property name="text">
<string>强制停止 VirtualBox</string>
</property>
</action>
<action name="action_StopQemu">
<property name="text">
<string>强制停止 Qemu</string>
</property>
</action>
</widget>
<layoutdefault spacing="6" margin="11"/>
<resources/>