优化wine下载器

This commit is contained in:
gfdgd xi 2023-04-05 16:09:58 +08:00
parent ba91aae7e1
commit 05c297647e
14 changed files with 66 additions and 36 deletions

View File

@ -3,6 +3,8 @@ build:
clean:
python3 RemovePycacheFile.py
cd VM-source ; make clean
rm VM-source/VirtualMachine
package:
#cd VM-source && qmake

View File

@ -1,3 +1,7 @@
/*
* gfdgd xi
* GPLV3
*/
#include "buildvbox.h"
#include "vbox.h"
#include <QFile>

View File

@ -1,3 +1,7 @@
/*
* gfdgd xi
* GPLV3
*/
#ifndef BUILDVBOX_H
#define BUILDVBOX_H
#include <QString>

View File

@ -1,3 +1,7 @@
/*
* gfdgd xi
* GPLV3
*/
#include "command.h"
#include <QProcess>
Command::Command()

View File

@ -1,3 +1,7 @@
/*
* gfdgd xi
* GPLV3
*/
#ifndef COMMAND_H
#define COMMAND_H
#include <QString>

View File

@ -1,3 +1,7 @@
/*
* gfdgd xi
* GPLV3
*/
#include "mainwindow.h"
#include <QApplication>
#include <QTranslator>
@ -23,11 +27,11 @@ int main(int argc, char *argv[])
trans->load("virtualmachine-en_US.qm");
a.installTranslator(trans);
// 判断是否为 !amd64
if(GetRunCommand("arch").replace(" ", "").replace("\n", "") != QString("x86_64")){
// 判断是否为 !amd64(无需判断了)
/*if(GetRunCommand("arch").replace(" ", "").replace("\n", "") != QString("x86_64")){
QMessageBox::critical(NULL, "错误", "此程序不支持非 X86 架构,立即退出");
return 0;
}
}*/
MainWindow w;
w.show();

View File

@ -28,12 +28,12 @@ MainWindow::MainWindow(QWidget *parent) :
ui->tabWidget->setTabPosition(QTabWidget::West); // 标签靠左
// 允许输出 qDebug 信息
QLoggingCategory::defaultCategory()->setEnabled(QtDebugMsg, true);
// 判断是否安装 vbox
if(system("which VBoxManage")){
// 判断是否安装 vbox(无需判断)
/*if(system("which VBoxManage")){
if(QMessageBox::question(this, "提示", "检测到您似乎没有安装 VirtualBox立即安装") == QMessageBox::Yes){
system("xdg-open https://www.virtualbox.org/wiki/Linux_Downloads");
}
}
}*/
// QTimer
QTimer *cpuGet = new QTimer(this);
connect(cpuGet, &QTimer::timeout, this, &MainWindow::ShowCPUMessage);

View File

@ -1,3 +1,7 @@
/*
* gfdgd xi
* GPLV3
*/
#ifndef MAINWINDOW_H
#define MAINWINDOW_H

View File

@ -1,3 +1,6 @@
/*
* gfdgd xi
*/
#include "qemu.h"
#include <QDir>
#include <QFile>
@ -30,7 +33,7 @@ int qemu::CreateDisk(QString path, int size){
if(QFile::exists(path)){
return 0;
}
return system(("qemu-img create '" + path + "' " + QString::number(size) + "M").toLatin1());
return system(("qemu-img create -f qcow2 '" + path + "' " + QString::number(size) + "M").toLatin1());
}
int qemu::CreateDiskControl(QString controlName){
return 0;

View File

@ -1,3 +1,7 @@
/*
* gfdgd xi
* GPLV3
*/
#ifndef QEMU_H
#define QEMU_H
#include <QString>

View File

@ -1,3 +1,6 @@
/*
* gfdgd xi
*/
#include "vbox.h"
#include "command.h"
#include <QMessageBox>

View File

@ -1,3 +1,7 @@
/*
* gfdgd xi
* GPLV3
*/
#ifndef VBOX_H
#define VBOX_H
#include <QString>

View File

@ -1,24 +0,0 @@
QMAKE_CXX.QT_COMPILER_STDCXX = 201402L
QMAKE_CXX.QMAKE_GCC_MAJOR_VERSION = 8
QMAKE_CXX.QMAKE_GCC_MINOR_VERSION = 3
QMAKE_CXX.QMAKE_GCC_PATCH_VERSION = 0
QMAKE_CXX.COMPILER_MACROS = \
QT_COMPILER_STDCXX \
QMAKE_GCC_MAJOR_VERSION \
QMAKE_GCC_MINOR_VERSION \
QMAKE_GCC_PATCH_VERSION
QMAKE_CXX.INCDIRS = \
/usr/include/c++/8 \
/usr/include/x86_64-linux-gnu/c++/8 \
/usr/include/c++/8/backward \
/usr/lib/gcc/x86_64-linux-gnu/8/include \
/usr/local/include \
/usr/lib/gcc/x86_64-linux-gnu/8/include-fixed \
/usr/include/x86_64-linux-gnu \
/usr/include
QMAKE_CXX.LIBDIRS = \
/usr/lib/gcc/x86_64-linux-gnu/8 \
/usr/lib/x86_64-linux-gnu \
/usr/lib \
/lib/x86_64-linux-gnu \
/lib

View File

@ -78,17 +78,24 @@ class Ui_MainWindow(object):
self.menu = MainWindow.menuBar()
self.changeSources = self.menu.addMenu(_translate("MainWindow", "更换源"))
self.gitlinkAction = QtWidgets.QAction(_translate("MainWindow", "Gitlink 源(推荐)"))
self.ipv6Action = QtWidgets.QAction(_translate("MainWindow", "备用源(只支持 IPv6 用户)"))
self.kgithubAction = QtWidgets.QAction(_translate("MainWindow", "KGithub 源"))
self.ipv6Action = QtWidgets.QAction(_translate("MainWindow", "Github 源1国内访问不稳定"))
self.githubAction = QtWidgets.QAction(_translate("MainWindow", "Github 源2国内访问不稳定"))
self.localAction = QtWidgets.QAction(_translate("MainWindow", "本地测试源127.0.0.1"))
self.changeSources.addAction(self.gitlinkAction)
self.changeSources.addAction(self.kgithubAction)
self.changeSources.addAction(self.ipv6Action)
self.changeSources.addAction(self.githubAction)
self.changeSources.addAction(self.localAction)
for i in [self.gitlinkAction, self.ipv6Action, self.localAction]:
for i in [self.gitlinkAction, self.ipv6Action, self.localAction, self.kgithubAction, self.githubAction]:
i.setCheckable(True)
self.gitlinkAction.setChecked(True)
self.changeSourcesGroup = QtWidgets.QActionGroup(MainWindow)
self.changeSourcesGroup.addAction(self.gitlinkAction)
self.changeSourcesGroup.addAction(self.kgithubAction)
self.changeSourcesGroup.addAction(self.ipv6Action)
self.changeSourcesGroup.addAction(self.githubAction)
self.changeSourcesGroup.addAction(self.localAction)
self.retranslateUi(MainWindow)
@ -153,7 +160,7 @@ def InstallOtherWine():
def ChangeSources():
global urlSources
global internetWineSource
sources = [ui.gitlinkAction, ui.ipv6Action, ui.localAction]
sources = [ui.gitlinkAction, ui.kgithubAction, ui.ipv6Action, ui.githubAction, ui.localAction]
for i in range(0, len(sources)):
if sources[i].isChecked():
urlSources = internetWineSourceList[i]
@ -171,6 +178,7 @@ def ReadInternetInformation():
try:
internetJsonList = json.loads(requests.get(f"{internetWineSource}/information.json").text)
except:
traceback.print_exc()
QtWidgets.QMessageBox.critical(window, "错误", "无法连接服务器!")
return
nmodel = QtGui.QStandardItemModel(window)
@ -292,7 +300,11 @@ def on_addButton_clicked():
if(ui.deleteZip.isChecked() + ui.unzip.isChecked() == 2):
ui.deleteZip.setChecked(False)
ui.unzip.setChecked(False)
downloadUrl = internetWineSource + downloadName
#downloadUrl = internetWineSource + downloadName
if "://" in downloadName:
downloadUrl = downloadName
else:
downloadUrl = internetWineSource + downloadName
dialog = QtWidgets.QProgressDialog()
cancel = QtWidgets.QPushButton("取消")
cancel.setDisabled(True)
@ -346,7 +358,9 @@ if __name__ == "__main__":
internetJsonList = []
internetWineSourceList = [
"https://code.gitlink.org.cn/gfdgd_xi/wine-mirrors/raw/branch/master/",
"http://gfdgdxi.msns.cn/wine-mirrors/", # 备用源,纯 IPv6 源
"https://kgithub.com/gfdgd-xi/wine-mirrors-websize/raw/master/",
"http://wine.wine-runner.gfdgdxi.top/",
"https://github.com/gfdgd-xi/wine-mirrors-websize/raw/master/",
"http://127.0.0.1/wine-mirrors/" # 本地测试源
]
internetWineSource = internetWineSourceList[0]