mirror of
https://gitee.com/gfdgd-xi/deep-wine-runner
synced 2025-01-13 01:58:27 +08:00
支持qemu+vbox
This commit is contained in:
parent
8a061efa2b
commit
002a6e309d
@ -2,6 +2,7 @@
|
|||||||
* gfdgd xi、为什么您不喜欢熊出没和阿布呢
|
* gfdgd xi、为什么您不喜欢熊出没和阿布呢
|
||||||
* 依照 GPLV3 开源
|
* 依照 GPLV3 开源
|
||||||
*/
|
*/
|
||||||
|
#include <sys/sysinfo.h>
|
||||||
#include "buildvbox.h"
|
#include "buildvbox.h"
|
||||||
#include "vbox.h"
|
#include "vbox.h"
|
||||||
#include <QFile>
|
#include <QFile>
|
||||||
@ -47,13 +48,15 @@ int buildvbox::Download(QString url, QString path, QString fileName){
|
|||||||
return system(("aria2c -x 16 -s 16 -c " + url + " -d " + path + " -o " + fileName).toUtf8());
|
return system(("aria2c -x 16 -s 16 -c " + url + " -d " + path + " -o " + fileName).toUtf8());
|
||||||
}
|
}
|
||||||
|
|
||||||
buildvbox::buildvbox(QString isoPath, int id){
|
buildvbox::buildvbox(QString isoPath, int id, int vm){
|
||||||
/*QDir vboxPath(QDir::homePath() + "/VirtualBox VMs/Windows");
|
/*if(vm == 1){
|
||||||
|
QDir vboxPath(QDir::homePath() + "/VirtualBox VMs/Windows");
|
||||||
if(vboxPath.exists()){
|
if(vboxPath.exists()){
|
||||||
qDebug("虚拟机存在,直接启动!");
|
qDebug("虚拟机存在,直接启动!");
|
||||||
vbox vm("Windows");
|
vbox vm("Windows");
|
||||||
vm.Start();
|
vm.Start();
|
||||||
return;
|
return;
|
||||||
|
}
|
||||||
}*/
|
}*/
|
||||||
QString programPath = QCoreApplication::applicationDirPath();
|
QString programPath = QCoreApplication::applicationDirPath();
|
||||||
|
|
||||||
@ -67,6 +70,7 @@ buildvbox::buildvbox(QString isoPath, int id){
|
|||||||
|
|
||||||
QString net = GetNet();
|
QString net = GetNet();
|
||||||
qDebug() << "使用网卡:" << net << endl;
|
qDebug() << "使用网卡:" << net << endl;
|
||||||
|
if(vm == 0){
|
||||||
//vbox *box = new vbox("Window");
|
//vbox *box = new vbox("Window");
|
||||||
//vbox vm("Windows");
|
//vbox vm("Windows");
|
||||||
qemu vm("Windows");
|
qemu vm("Windows");
|
||||||
@ -108,7 +112,7 @@ buildvbox::buildvbox(QString isoPath, int id){
|
|||||||
vm.MountISO("/usr/share/virtualbox/VBoxGuestAdditions.iso", "storage_controller_1", 1, 1);
|
vm.MountISO("/usr/share/virtualbox/VBoxGuestAdditions.iso", "storage_controller_1", 1, 1);
|
||||||
}*/
|
}*/
|
||||||
|
|
||||||
vm.SetCPU(1);
|
vm.SetCPU(get_nprocs());
|
||||||
long memory = 0;
|
long memory = 0;
|
||||||
long memoryAll = 0;
|
long memoryAll = 0;
|
||||||
long swap = 0;
|
long swap = 0;
|
||||||
@ -128,4 +132,64 @@ buildvbox::buildvbox(QString isoPath, int id){
|
|||||||
vm.ShareFile("ROOT", "/");
|
vm.ShareFile("ROOT", "/");
|
||||||
vm.ShareFile("HOME", QDir::homePath());
|
vm.ShareFile("HOME", QDir::homePath());
|
||||||
vm.Start();
|
vm.Start();
|
||||||
|
}
|
||||||
|
else if(vm == 1){
|
||||||
|
// ?
|
||||||
|
//vbox *box = new vbox("Window");
|
||||||
|
vbox vm("Windows");
|
||||||
|
//qemu vm("Windows");
|
||||||
|
|
||||||
|
switch (id) {
|
||||||
|
case 0:
|
||||||
|
vm.Create("Windows7");
|
||||||
|
break;
|
||||||
|
case 1:
|
||||||
|
vm.Create("Windows7_64");
|
||||||
|
break;
|
||||||
|
vm.Create("WindowsNT_64");
|
||||||
|
}
|
||||||
|
QDir dir("/home/gfdgd_xi/Qemu/Windows/");
|
||||||
|
dir.mkpath("/home/gfdgd_xi/Qemu/Windows/");
|
||||||
|
vm.CreateDiskControl();
|
||||||
|
//vm.CreateDiskControl("storage_controller_2");
|
||||||
|
vm.CreateDisk(QDir::homePath() + "/VirtualBox VMs/Windows/Windows.vdi", 131072);
|
||||||
|
vm.MountDisk(QDir::homePath() + "/VirtualBox VMs/Windows/Windows.vdi");
|
||||||
|
vm.MountISO(isoPath, "storage_controller_1", 0, 1);
|
||||||
|
switch (id) {
|
||||||
|
case 0:
|
||||||
|
vm.MountISO(programPath + "/Windows7X86Auto.iso", "storage_controller_1", 1, 0);
|
||||||
|
break;
|
||||||
|
case 1:
|
||||||
|
vm.MountISO(programPath + "/Windows7X64Auto.iso", "storage_controller_1", 1, 0);
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
|
||||||
|
// 判断 VirtualBox Guest ISO 是否存在
|
||||||
|
// 在的话直接挂载
|
||||||
|
if(QFile::exists("/usr/share/virtualbox/VBoxGuestAdditions.iso")){
|
||||||
|
vm.MountISO("/usr/share/virtualbox/VBoxGuestAdditions.iso", "storage_controller_1", 1, 1);
|
||||||
|
}
|
||||||
|
|
||||||
|
vm.SetCPU(get_nprocs_conf());
|
||||||
|
long memory = 0;
|
||||||
|
long memoryAll = 0;
|
||||||
|
long swap = 0;
|
||||||
|
long swapAll = 0;
|
||||||
|
infoUtils::memoryRate(memory, memoryAll, swap, swapAll);
|
||||||
|
//memoryRate(memory, memoryAll, swap, swapAll);
|
||||||
|
vm.SetMemory(memoryAll / 3 / 1024);
|
||||||
|
vm.SetDisplayMemory(32);
|
||||||
|
vm.SetNetBridge(net);
|
||||||
|
vm.EnabledAudio();
|
||||||
|
vm.EnabledClipboardMode();
|
||||||
|
vm.EnabledDraganddrop();
|
||||||
|
vm.SetVBoxSVGA();
|
||||||
|
vm.SetMousePS2();
|
||||||
|
vm.SetKeyboardPS2();
|
||||||
|
vm.OpenUSB();
|
||||||
|
vm.ShareFile("ROOT", "/");
|
||||||
|
vm.ShareFile("HOME", QDir::homePath());
|
||||||
|
vm.Start();
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
@ -10,7 +10,7 @@ class buildvbox
|
|||||||
{
|
{
|
||||||
// Q_OBJECT
|
// Q_OBJECT
|
||||||
public:
|
public:
|
||||||
buildvbox(QString isoPath, int id=0);
|
buildvbox(QString isoPath, int id=0, int vm=0);
|
||||||
void CleanScreen();
|
void CleanScreen();
|
||||||
QString GetNet();
|
QString GetNet();
|
||||||
int Download(QString url, QString path, QString fileName);
|
int Download(QString url, QString path, QString fileName);
|
||||||
|
@ -19,6 +19,7 @@
|
|||||||
#include <QtMath>
|
#include <QtMath>
|
||||||
#include <QJsonArray>
|
#include <QJsonArray>
|
||||||
#include <QDesktopServices>
|
#include <QDesktopServices>
|
||||||
|
#include <QMessageBox>
|
||||||
|
|
||||||
MainWindow::MainWindow(QWidget *parent) :
|
MainWindow::MainWindow(QWidget *parent) :
|
||||||
QMainWindow(parent),
|
QMainWindow(parent),
|
||||||
@ -26,6 +27,13 @@ MainWindow::MainWindow(QWidget *parent) :
|
|||||||
{
|
{
|
||||||
ui->setupUi(this);
|
ui->setupUi(this);
|
||||||
ui->tabWidget->setTabPosition(QTabWidget::West); // 标签靠左
|
ui->tabWidget->setTabPosition(QTabWidget::West); // 标签靠左
|
||||||
|
// 选择最优虚拟机
|
||||||
|
if(!system("which qemu-x86_64")){
|
||||||
|
ui->vmChooser->setCurrentIndex(0);
|
||||||
|
}
|
||||||
|
if(!system("which vboxmanage")){
|
||||||
|
ui->vmChooser->setCurrentIndex(1);
|
||||||
|
}
|
||||||
// 允许输出 qDebug 信息
|
// 允许输出 qDebug 信息
|
||||||
QLoggingCategory::defaultCategory()->setEnabled(QtDebugMsg, true);
|
QLoggingCategory::defaultCategory()->setEnabled(QtDebugMsg, true);
|
||||||
// 判断是否安装 vbox(无需判断)
|
// 判断是否安装 vbox(无需判断)
|
||||||
@ -79,6 +87,7 @@ MainWindow::MainWindow(QWidget *parent) :
|
|||||||
connect(ui->textBrowser_3, &QTextBrowser::anchorClicked, this, [=](const QUrl &link){
|
connect(ui->textBrowser_3, &QTextBrowser::anchorClicked, this, [=](const QUrl &link){
|
||||||
QDesktopServices::openUrl(link);
|
QDesktopServices::openUrl(link);
|
||||||
});
|
});
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void MainWindow::ShowCPUMessage(){
|
void MainWindow::ShowCPUMessage(){
|
||||||
@ -145,6 +154,22 @@ void MainWindow::on_browser_clicked()
|
|||||||
|
|
||||||
void MainWindow::on_install_clicked()
|
void MainWindow::on_install_clicked()
|
||||||
{
|
{
|
||||||
buildvbox(ui->isoPath->text(), ui->systemVersion->currentIndex());
|
switch (ui->vmChooser->currentIndex()) {
|
||||||
|
case 0:
|
||||||
|
if(system("which qemu-x86_64")){
|
||||||
|
if(QMessageBox::question(this, "提示", "您似乎没有安装 Qemu,是否继续创建虚拟机?") == QMessageBox::No){
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
break;
|
||||||
|
case 1:
|
||||||
|
if(system("which vboxmanage")){
|
||||||
|
if(QMessageBox::question(this, "提示", "您似乎没有安装 VBox,是否继续创建虚拟机?") == QMessageBox::No){
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
buildvbox(ui->isoPath->text(), ui->systemVersion->currentIndex(), ui->vmChooser->currentIndex());
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
@ -25,7 +25,7 @@
|
|||||||
<enum>QTabWidget::Rounded</enum>
|
<enum>QTabWidget::Rounded</enum>
|
||||||
</property>
|
</property>
|
||||||
<property name="currentIndex">
|
<property name="currentIndex">
|
||||||
<number>2</number>
|
<number>0</number>
|
||||||
</property>
|
</property>
|
||||||
<widget class="QWidget" name="tab">
|
<widget class="QWidget" name="tab">
|
||||||
<attribute name="title">
|
<attribute name="title">
|
||||||
@ -96,6 +96,40 @@
|
|||||||
</item>
|
</item>
|
||||||
</layout>
|
</layout>
|
||||||
</item>
|
</item>
|
||||||
|
<item>
|
||||||
|
<layout class="QHBoxLayout" name="horizontalLayout_7" stretch="0,1">
|
||||||
|
<item>
|
||||||
|
<widget class="QLabel" name="label_4">
|
||||||
|
<property name="text">
|
||||||
|
<string>虚拟机(建议默认):</string>
|
||||||
|
</property>
|
||||||
|
</widget>
|
||||||
|
</item>
|
||||||
|
<item>
|
||||||
|
<widget class="QComboBox" name="vmChooser">
|
||||||
|
<property name="currentText">
|
||||||
|
<string>qemu/kvm</string>
|
||||||
|
</property>
|
||||||
|
<property name="currentIndex">
|
||||||
|
<number>0</number>
|
||||||
|
</property>
|
||||||
|
<property name="duplicatesEnabled">
|
||||||
|
<bool>false</bool>
|
||||||
|
</property>
|
||||||
|
<item>
|
||||||
|
<property name="text">
|
||||||
|
<string>qemu/kvm</string>
|
||||||
|
</property>
|
||||||
|
</item>
|
||||||
|
<item>
|
||||||
|
<property name="text">
|
||||||
|
<string>VirtualBox</string>
|
||||||
|
</property>
|
||||||
|
</item>
|
||||||
|
</widget>
|
||||||
|
</item>
|
||||||
|
</layout>
|
||||||
|
</item>
|
||||||
<item>
|
<item>
|
||||||
<layout class="QHBoxLayout" name="horizontalLayout_4">
|
<layout class="QHBoxLayout" name="horizontalLayout_4">
|
||||||
<item>
|
<item>
|
||||||
@ -158,9 +192,10 @@ p, li { white-space: pre-wrap; }
|
|||||||
p, li { white-space: pre-wrap; }
|
p, li { white-space: pre-wrap; }
|
||||||
</style></head><body style=" font-family:'Noto Sans CJK SC'; font-size:10.5pt; font-weight:400; font-style:normal;">
|
</style></head><body style=" font-family:'Noto Sans CJK SC'; font-size:10.5pt; font-weight:400; font-style:normal;">
|
||||||
<p style=" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;"><span style=" font-size:26pt; font-weight:600;">给小白的一段话</span></p>
|
<p style=" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;"><span style=" font-size:26pt; font-weight:600;">给小白的一段话</span></p>
|
||||||
<p style=" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;">其实本质上跑完安装程序就没有然后了,顶多如果想要运行舒服一点点,可以安装加强功能,直接拉到最底下看就可以了</p>
|
<p style=" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;">其实本质上跑完安装程序就没有然后了,顶多如果想要运行舒服一点点,可以安装加强功能,直接拉到最底下看就可以了,<span style=" font-weight:600; font-style:italic; text-decoration: underline;">只限使用 VirtualBox</span></p>
|
||||||
|
<p style=" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;"><span style=" font-weight:600; font-style:italic; text-decoration: underline;">如果你是用非 X86 PC,那暂时只能使用 qemu(没 kvm),且跨架构的性能损失很大,推荐使用 Windows XP 而非 Windows 7</span></p>
|
||||||
<p style=" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;">如果爱折腾的话,下面的都看看也无所谓的,想看往下翻就可以了</p>
|
<p style=" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;">如果爱折腾的话,下面的都看看也无所谓的,想看往下翻就可以了</p>
|
||||||
<p style=" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;">(如果鼠标被锁定到里面了按下键盘右边的“Ctrl”键就可以了)</p>
|
<p style=" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;">(如果鼠标被锁定到里面了按下键盘右边的“Ctrl”键就可以了,<span style=" font-weight:600; font-style:italic; text-decoration: underline;">qemu则是 Ctrl+Alt+G</span> )</p>
|
||||||
<hr />
|
<hr />
|
||||||
<p style="-qt-paragraph-type:empty; margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;"><br /></p>
|
<p style="-qt-paragraph-type:empty; margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;"><br /></p>
|
||||||
<p style="-qt-paragraph-type:empty; margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px; font-size:26pt; font-weight:600;"><br /></p>
|
<p style="-qt-paragraph-type:empty; margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px; font-size:26pt; font-weight:600;"><br /></p>
|
||||||
|
@ -381,14 +381,14 @@ def OpenUrl(url):
|
|||||||
print(url.url())
|
print(url.url())
|
||||||
# 判断是否可以使用小窗打开
|
# 判断是否可以使用小窗打开
|
||||||
if not bad:
|
if not bad:
|
||||||
Temp.webWindow = QtWidgets.QMainWindow()
|
'''Temp.webWindow = QtWidgets.QMainWindow()
|
||||||
web = QtWebEngineWidgets.QWebEngineView()
|
web = QtWebEngineWidgets.QWebEngineView()
|
||||||
web.setUrl(url)
|
web.setUrl(url)
|
||||||
Temp.webWindow.setWindowTitle("浏览页面")
|
Temp.webWindow.setWindowTitle("浏览页面")
|
||||||
Temp.webWindow.setCentralWidget(web)
|
Temp.webWindow.setCentralWidget(web)
|
||||||
Temp.webWindow.setWindowIcon(QtGui.QIcon(iconPath))
|
Temp.webWindow.setWindowIcon(QtGui.QIcon(iconPath))
|
||||||
Temp.webWindow.show()
|
Temp.webWindow.show()
|
||||||
return
|
return'''
|
||||||
webbrowser.open_new_tab(url.url())
|
webbrowser.open_new_tab(url.url())
|
||||||
|
|
||||||
#QtCore.QUrl().url()
|
#QtCore.QUrl().url()
|
||||||
@ -1123,6 +1123,8 @@ class UpdateWindow():
|
|||||||
updateWidgetLayout = QtWidgets.QGridLayout()
|
updateWidgetLayout = QtWidgets.QGridLayout()
|
||||||
versionLabel = QtWidgets.QLabel(f"当前版本:{version}\n最新版本:未知\n更新内容:")
|
versionLabel = QtWidgets.QLabel(f"当前版本:{version}\n最新版本:未知\n更新内容:")
|
||||||
updateText = QtWidgets.QTextBrowser()
|
updateText = QtWidgets.QTextBrowser()
|
||||||
|
updateText.anchorClicked.connect(OpenUrl)
|
||||||
|
updateText.setOpenExternalLinks(False)
|
||||||
ok = QtWidgets.QPushButton(transla.transe("U", "更新(更新时会自动关闭 Wine 运行器)"))
|
ok = QtWidgets.QPushButton(transla.transe("U", "更新(更新时会自动关闭 Wine 运行器)"))
|
||||||
ok.clicked.connect(UpdateWindow.Update)
|
ok.clicked.connect(UpdateWindow.Update)
|
||||||
cancel = QtWidgets.QPushButton("取消")
|
cancel = QtWidgets.QPushButton("取消")
|
||||||
@ -1147,7 +1149,7 @@ class UpdateWindow():
|
|||||||
<p>1、使用编译或者内测版本</p>
|
<p>1、使用编译或者内测版本</p>
|
||||||
<p>2、自己修改了程序版本</p>
|
<p>2、自己修改了程序版本</p>
|
||||||
<p>3、作者忘记更新云端上的更新信息了</p>
|
<p>3、作者忘记更新云端上的更新信息了</p>
|
||||||
<p>如果是第三种情况,请反馈到此:https://gitee.com/gfdgd-xi/deep-wine-runner/issues/I6T3FG</p>
|
<p>如果是第三种情况,请反馈到此:<a href='https://gitee.com/gfdgd-xi/deep-wine-runner/issues/I6T3FG'>https://gitee.com/gfdgd-xi/deep-wine-runner/issues/I6T3FG</a></p>
|
||||||
<p><img src='{programPath}/Icon/doge.png'></p>""")
|
<p><img src='{programPath}/Icon/doge.png'></p>""")
|
||||||
ok.setDisabled(True)
|
ok.setDisabled(True)
|
||||||
break
|
break
|
||||||
@ -2942,7 +2944,7 @@ def AddLib(install: QtWidgets.QAction, uninstall, menu, info):
|
|||||||
menu.addAction(uninstall)
|
menu.addAction(uninstall)
|
||||||
|
|
||||||
if os.path.exists(f"{programPath}/InstallRuntime"):
|
if os.path.exists(f"{programPath}/InstallRuntime"):
|
||||||
installLib = menu.addMenu(transla.transe("U", "运行库"))
|
installLib = menu.addMenu(transla.transe("U", "运行库(&R)"))
|
||||||
installQemuMenu = installLib.addMenu(transla.transe("U", "安装 Qemu User"))
|
installQemuMenu = installLib.addMenu(transla.transe("U", "安装 Qemu User"))
|
||||||
installQemu = QtWidgets.QAction("安装 Qemu User")
|
installQemu = QtWidgets.QAction("安装 Qemu User")
|
||||||
removeQemu = QtWidgets.QAction("卸载 Qemu User")
|
removeQemu = QtWidgets.QAction("卸载 Qemu User")
|
||||||
|
Loading…
Reference in New Issue
Block a user