新增添加Qemu镜像功能

This commit is contained in:
gfdgd xi 2023-04-28 21:43:14 +08:00
parent 73551e9a12
commit 0d3e798644
4 changed files with 80 additions and 11 deletions

View File

@ -1,6 +1,6 @@
#############################################################################
# Makefile for building: VirtualMachine
# Generated by qmake (3.1) (Qt 5.15.6)
# Generated by qmake (3.1) (Qt 5.15.8)
# Project: VirtualMachine.pro
# Template: app
# Command: /usr/lib/qt5/bin/qmake -o Makefile VirtualMachine.pro
@ -151,10 +151,7 @@ DIST = /usr/lib/x86_64-linux-gnu/qt5/mkspecs/features/spec_pre.prf \
/usr/lib/x86_64-linux-gnu/qt5/mkspecs/modules/qt_lib_dbus_private.pri \
/usr/lib/x86_64-linux-gnu/qt5/mkspecs/modules/qt_lib_designer.pri \
/usr/lib/x86_64-linux-gnu/qt5/mkspecs/modules/qt_lib_devicediscovery_support_private.pri \
/usr/lib/x86_64-linux-gnu/qt5/mkspecs/modules/qt_lib_dtkcommon.pri \
/usr/lib/x86_64-linux-gnu/qt5/mkspecs/modules/qt_lib_dtkcore.pri \
/usr/lib/x86_64-linux-gnu/qt5/mkspecs/modules/qt_lib_dtkgui.pri \
/usr/lib/x86_64-linux-gnu/qt5/mkspecs/modules/qt_lib_dtkwidget.pri \
/usr/lib/x86_64-linux-gnu/qt5/mkspecs/modules/qt_lib_edid_support_private.pri \
/usr/lib/x86_64-linux-gnu/qt5/mkspecs/modules/qt_lib_egl_support_private.pri \
/usr/lib/x86_64-linux-gnu/qt5/mkspecs/modules/qt_lib_eglfs_kms_support_private.pri \
@ -203,6 +200,10 @@ DIST = /usr/lib/x86_64-linux-gnu/qt5/mkspecs/features/spec_pre.prf \
/usr/lib/x86_64-linux-gnu/qt5/mkspecs/modules/qt_lib_uiplugin.pri \
/usr/lib/x86_64-linux-gnu/qt5/mkspecs/modules/qt_lib_uitools.pri \
/usr/lib/x86_64-linux-gnu/qt5/mkspecs/modules/qt_lib_vulkan_support_private.pri \
/usr/lib/x86_64-linux-gnu/qt5/mkspecs/modules/qt_lib_waylandclient.pri \
/usr/lib/x86_64-linux-gnu/qt5/mkspecs/modules/qt_lib_waylandclient_private.pri \
/usr/lib/x86_64-linux-gnu/qt5/mkspecs/modules/qt_lib_waylandcompositor.pri \
/usr/lib/x86_64-linux-gnu/qt5/mkspecs/modules/qt_lib_waylandcompositor_private.pri \
/usr/lib/x86_64-linux-gnu/qt5/mkspecs/modules/qt_lib_webchannel.pri \
/usr/lib/x86_64-linux-gnu/qt5/mkspecs/modules/qt_lib_webengine.pri \
/usr/lib/x86_64-linux-gnu/qt5/mkspecs/modules/qt_lib_webenginecore.pri \
@ -345,10 +346,7 @@ Makefile: VirtualMachine.pro /usr/lib/x86_64-linux-gnu/qt5/mkspecs/linux-g++/qma
/usr/lib/x86_64-linux-gnu/qt5/mkspecs/modules/qt_lib_dbus_private.pri \
/usr/lib/x86_64-linux-gnu/qt5/mkspecs/modules/qt_lib_designer.pri \
/usr/lib/x86_64-linux-gnu/qt5/mkspecs/modules/qt_lib_devicediscovery_support_private.pri \
/usr/lib/x86_64-linux-gnu/qt5/mkspecs/modules/qt_lib_dtkcommon.pri \
/usr/lib/x86_64-linux-gnu/qt5/mkspecs/modules/qt_lib_dtkcore.pri \
/usr/lib/x86_64-linux-gnu/qt5/mkspecs/modules/qt_lib_dtkgui.pri \
/usr/lib/x86_64-linux-gnu/qt5/mkspecs/modules/qt_lib_dtkwidget.pri \
/usr/lib/x86_64-linux-gnu/qt5/mkspecs/modules/qt_lib_edid_support_private.pri \
/usr/lib/x86_64-linux-gnu/qt5/mkspecs/modules/qt_lib_egl_support_private.pri \
/usr/lib/x86_64-linux-gnu/qt5/mkspecs/modules/qt_lib_eglfs_kms_support_private.pri \
@ -397,6 +395,10 @@ Makefile: VirtualMachine.pro /usr/lib/x86_64-linux-gnu/qt5/mkspecs/linux-g++/qma
/usr/lib/x86_64-linux-gnu/qt5/mkspecs/modules/qt_lib_uiplugin.pri \
/usr/lib/x86_64-linux-gnu/qt5/mkspecs/modules/qt_lib_uitools.pri \
/usr/lib/x86_64-linux-gnu/qt5/mkspecs/modules/qt_lib_vulkan_support_private.pri \
/usr/lib/x86_64-linux-gnu/qt5/mkspecs/modules/qt_lib_waylandclient.pri \
/usr/lib/x86_64-linux-gnu/qt5/mkspecs/modules/qt_lib_waylandclient_private.pri \
/usr/lib/x86_64-linux-gnu/qt5/mkspecs/modules/qt_lib_waylandcompositor.pri \
/usr/lib/x86_64-linux-gnu/qt5/mkspecs/modules/qt_lib_waylandcompositor_private.pri \
/usr/lib/x86_64-linux-gnu/qt5/mkspecs/modules/qt_lib_webchannel.pri \
/usr/lib/x86_64-linux-gnu/qt5/mkspecs/modules/qt_lib_webengine.pri \
/usr/lib/x86_64-linux-gnu/qt5/mkspecs/modules/qt_lib_webenginecore.pri \
@ -517,10 +519,7 @@ Makefile: VirtualMachine.pro /usr/lib/x86_64-linux-gnu/qt5/mkspecs/linux-g++/qma
/usr/lib/x86_64-linux-gnu/qt5/mkspecs/modules/qt_lib_dbus_private.pri:
/usr/lib/x86_64-linux-gnu/qt5/mkspecs/modules/qt_lib_designer.pri:
/usr/lib/x86_64-linux-gnu/qt5/mkspecs/modules/qt_lib_devicediscovery_support_private.pri:
/usr/lib/x86_64-linux-gnu/qt5/mkspecs/modules/qt_lib_dtkcommon.pri:
/usr/lib/x86_64-linux-gnu/qt5/mkspecs/modules/qt_lib_dtkcore.pri:
/usr/lib/x86_64-linux-gnu/qt5/mkspecs/modules/qt_lib_dtkgui.pri:
/usr/lib/x86_64-linux-gnu/qt5/mkspecs/modules/qt_lib_dtkwidget.pri:
/usr/lib/x86_64-linux-gnu/qt5/mkspecs/modules/qt_lib_edid_support_private.pri:
/usr/lib/x86_64-linux-gnu/qt5/mkspecs/modules/qt_lib_egl_support_private.pri:
/usr/lib/x86_64-linux-gnu/qt5/mkspecs/modules/qt_lib_eglfs_kms_support_private.pri:
@ -569,6 +568,10 @@ Makefile: VirtualMachine.pro /usr/lib/x86_64-linux-gnu/qt5/mkspecs/linux-g++/qma
/usr/lib/x86_64-linux-gnu/qt5/mkspecs/modules/qt_lib_uiplugin.pri:
/usr/lib/x86_64-linux-gnu/qt5/mkspecs/modules/qt_lib_uitools.pri:
/usr/lib/x86_64-linux-gnu/qt5/mkspecs/modules/qt_lib_vulkan_support_private.pri:
/usr/lib/x86_64-linux-gnu/qt5/mkspecs/modules/qt_lib_waylandclient.pri:
/usr/lib/x86_64-linux-gnu/qt5/mkspecs/modules/qt_lib_waylandclient_private.pri:
/usr/lib/x86_64-linux-gnu/qt5/mkspecs/modules/qt_lib_waylandcompositor.pri:
/usr/lib/x86_64-linux-gnu/qt5/mkspecs/modules/qt_lib_waylandcompositor_private.pri:
/usr/lib/x86_64-linux-gnu/qt5/mkspecs/modules/qt_lib_webchannel.pri:
/usr/lib/x86_64-linux-gnu/qt5/mkspecs/modules/qt_lib_webengine.pri:
/usr/lib/x86_64-linux-gnu/qt5/mkspecs/modules/qt_lib_webenginecore.pri:
@ -759,7 +762,8 @@ qemu.o: qemu.cpp qemu.h \
$(CXX) -c $(CXXFLAGS) $(INCPATH) -o qemu.o qemu.cpp
qemusetting.o: qemusetting.cpp qemusetting.h \
ui_qemusetting.h
ui_qemusetting.h \
infoutils.h
$(CXX) -c $(CXXFLAGS) $(INCPATH) -o qemusetting.o qemusetting.cpp
qrc_图标.o: qrc_图标.cpp

View File

@ -20,6 +20,7 @@
#include <QJsonArray>
#include <QDesktopServices>
#include <QMessageBox>
#include <iostream>
#include "qemusetting.h"
MainWindow::MainWindow(QWidget *parent) :
@ -201,3 +202,35 @@ void MainWindow::on_qemuSetting_clicked()
show->show();
}
void MainWindow::on_addQemuDisk_triggered()
{
if(QFile::exists(QDir::homePath() + "/Qemu/Windows/Windows.qcow2")){
if(QMessageBox::question(this, "提示", "磁盘文件已存在,是否覆盖?\n覆盖后将无法恢复!") == QMessageBox::No){
return;
}
}
QString path = QFileDialog::getOpenFileName(this, "选择 Qemu 镜像", QDir::homePath(), "Qemu镜像(*.qcow2 *.img *.raw *.qcow *.qed *.vdi *.vhdx *.vmdk);;所有文件(*.*)");
qDebug() << path;
if(path == ""){
return;
}
QDir dir(QDir::homePath() + "/Qemu/Windows/Windows.qcow2");
if(!dir.exists()){
dir.mkpath(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;
}
QMessageBox::information(this, "提示", "添加完成!");
}
void MainWindow::on_delQemuDisk_triggered()
{
if(!QFile::exists(QDir::homePath() + "/Qemu/Windows/Windows.qcow2")){
QMessageBox::information(this, "提示", "不存在磁盘文件,无法导出");
return;
}
std::system(("xdg-open \"" + QDir::homePath() + "/Qemu/Windows/\"").toUtf8());
}

View File

@ -34,6 +34,10 @@ private slots:
void on_qemuSetting_clicked();
void on_addQemuDisk_triggered();
void on_delQemuDisk_triggered();
private:
Ui::MainWindow *ui;
long m_cpuAll;

View File

@ -374,6 +374,24 @@ p, li { white-space: pre-wrap; }
<string/>
</property>
</widget>
<widget class="QMenuBar" name="menuBar">
<property name="geometry">
<rect>
<x>0</x>
<y>0</y>
<width>807</width>
<height>36</height>
</rect>
</property>
<widget class="QMenu" name="menuQemu">
<property name="title">
<string>Qemu磁盘镜像</string>
</property>
<addaction name="addQemuDisk"/>
<addaction name="delQemuDisk"/>
</widget>
<addaction name="menuQemu"/>
</widget>
<action name="action">
<property name="text">
<string>退出</string>
@ -384,6 +402,16 @@ p, li { white-space: pre-wrap; }
<string>关于</string>
</property>
</action>
<action name="addQemuDisk">
<property name="text">
<string>导入/覆盖</string>
</property>
</action>
<action name="delQemuDisk">
<property name="text">
<string>导出</string>
</property>
</action>
</widget>
<layoutdefault spacing="6" margin="11"/>
<resources/>