1.8.1
This commit is contained in:
@@ -28,11 +28,13 @@ CONFIG += console
|
||||
SOURCES += \
|
||||
main.cpp \
|
||||
mainwindow.cpp \
|
||||
downloadthread.cpp
|
||||
downloadthread.cpp \
|
||||
getipserver.cpp
|
||||
|
||||
HEADERS += \
|
||||
mainwindow.h \
|
||||
downloadthread.h
|
||||
downloadthread.h \
|
||||
getipserver.h
|
||||
|
||||
FORMS += \
|
||||
mainwindow.ui
|
||||
|
||||
@@ -54,10 +54,12 @@ OBJECTS_DIR = ./
|
||||
|
||||
SOURCES = ../main.cpp \
|
||||
../mainwindow.cpp \
|
||||
../downloadthread.cpp moc_mainwindow.cpp
|
||||
../downloadthread.cpp \
|
||||
../getipserver.cpp moc_mainwindow.cpp
|
||||
OBJECTS = main.o \
|
||||
mainwindow.o \
|
||||
downloadthread.o \
|
||||
getipserver.o \
|
||||
moc_mainwindow.o
|
||||
DIST = /usr/lib/x86_64-linux-gnu/qt5/mkspecs/features/spec_pre.prf \
|
||||
/usr/lib/x86_64-linux-gnu/qt5/mkspecs/common/unix.conf \
|
||||
@@ -165,9 +167,11 @@ DIST = /usr/lib/x86_64-linux-gnu/qt5/mkspecs/features/spec_pre.prf \
|
||||
/usr/lib/x86_64-linux-gnu/qt5/mkspecs/features/yacc.prf \
|
||||
/usr/lib/x86_64-linux-gnu/qt5/mkspecs/features/lex.prf \
|
||||
../../AXVM.pro ../mainwindow.h \
|
||||
../downloadthread.h ../main.cpp \
|
||||
../downloadthread.h \
|
||||
../getipserver.h ../main.cpp \
|
||||
../mainwindow.cpp \
|
||||
../downloadthread.cpp
|
||||
../downloadthread.cpp \
|
||||
../getipserver.cpp
|
||||
QMAKE_TARGET = AXVM
|
||||
DESTDIR =
|
||||
TARGET = AXVM
|
||||
@@ -407,8 +411,8 @@ distdir: FORCE
|
||||
@test -d $(DISTDIR) || mkdir -p $(DISTDIR)
|
||||
$(COPY_FILE) --parents $(DIST) $(DISTDIR)/
|
||||
$(COPY_FILE) --parents /usr/lib/x86_64-linux-gnu/qt5/mkspecs/features/data/dummy.cpp $(DISTDIR)/
|
||||
$(COPY_FILE) --parents ../mainwindow.h ../downloadthread.h $(DISTDIR)/
|
||||
$(COPY_FILE) --parents ../main.cpp ../mainwindow.cpp ../downloadthread.cpp $(DISTDIR)/
|
||||
$(COPY_FILE) --parents ../mainwindow.h ../downloadthread.h ../getipserver.h $(DISTDIR)/
|
||||
$(COPY_FILE) --parents ../main.cpp ../mainwindow.cpp ../downloadthread.cpp ../getipserver.cpp $(DISTDIR)/
|
||||
$(COPY_FILE) --parents ../mainwindow.ui $(DISTDIR)/
|
||||
|
||||
|
||||
@@ -477,12 +481,18 @@ main.o: ../main.cpp ../mainwindow.h \
|
||||
|
||||
mainwindow.o: ../mainwindow.cpp ../mainwindow.h \
|
||||
../downloadthread.h \
|
||||
ui_mainwindow.h
|
||||
ui_mainwindow.h \
|
||||
../getipserver.h
|
||||
$(CXX) -c $(CXXFLAGS) $(INCPATH) -o mainwindow.o ../mainwindow.cpp
|
||||
|
||||
downloadthread.o: ../downloadthread.cpp ../downloadthread.h
|
||||
$(CXX) -c $(CXXFLAGS) $(INCPATH) -o downloadthread.o ../downloadthread.cpp
|
||||
|
||||
getipserver.o: ../getipserver.cpp ../getipserver.h \
|
||||
../mainwindow.h \
|
||||
../downloadthread.h
|
||||
$(CXX) -c $(CXXFLAGS) $(INCPATH) -o getipserver.o ../getipserver.cpp
|
||||
|
||||
moc_mainwindow.o: moc_mainwindow.cpp
|
||||
$(CXX) -c $(CXXFLAGS) $(INCPATH) -o moc_mainwindow.o moc_mainwindow.cpp
|
||||
|
||||
|
||||
Binary file not shown.
@@ -1,3 +1,4 @@
|
||||
#define SETTINGSTEP 6
|
||||
#include "downloadthread.h"
|
||||
#include <QProgressDialog>
|
||||
#include <QFile>
|
||||
@@ -7,47 +8,77 @@
|
||||
#include <QTimer>
|
||||
#include <QNetworkReply>
|
||||
#include <QMessageBox>
|
||||
#include <QCoreApplication>
|
||||
// 文件操作
|
||||
#include <QDir>
|
||||
// 命令执行
|
||||
#include <QProcess>
|
||||
// 获取内存总量
|
||||
#if defined(Q_OS_LINUX) // 区分系统平台
|
||||
#include "sys/statfs.h" // Linux 上
|
||||
#else // Windows 上
|
||||
#pragma comment(lib, "Kernel32.lib")
|
||||
#pragma comment(lib, "Psapi.lib")
|
||||
#include <windows.h>
|
||||
#include <tlhelp32.h>
|
||||
#endif
|
||||
|
||||
|
||||
DownloadThread::DownloadThread(QProgressDialog *progressDialog, QString url, QString save){
|
||||
DownloadThread::DownloadThread(QProgressDialog *progressDialog, QString url, QString name, QString mouse, bool NotDownload){
|
||||
dialog = progressDialog;
|
||||
fileUrl = url;
|
||||
savePath = save;
|
||||
vmName = name;
|
||||
setMouse = mouse;
|
||||
notDownload = NotDownload;
|
||||
}
|
||||
|
||||
// 文件下载
|
||||
void DownloadThread::run(){
|
||||
// 创建文件夹
|
||||
QDir dir;
|
||||
QString configDir = QCoreApplication::applicationDirPath() + "/VM";
|
||||
if(!dir.exists(configDir)){
|
||||
// 文件不存在
|
||||
dir.mkpath(configDir);
|
||||
}
|
||||
configDir = QCoreApplication::applicationDirPath() + "/VM/" + vmName;
|
||||
if(!dir.exists(configDir)){
|
||||
// 文件不存在
|
||||
dir.mkpath(configDir);
|
||||
}
|
||||
QString savePath = configDir + "/vm.ova";
|
||||
// 文件下载
|
||||
int timeout = 0;
|
||||
QFile f(savePath);
|
||||
if(!f.open(QIODevice::WriteOnly)){
|
||||
|
||||
emit MessageBoxError("文件无法写入");
|
||||
f.close();
|
||||
delete dialog;
|
||||
dialog->close();
|
||||
return;
|
||||
}
|
||||
if(notDownload){
|
||||
qDebug() << "b";
|
||||
SettingVirtualMachine(savePath);
|
||||
return;
|
||||
}
|
||||
QNetworkAccessManager m;
|
||||
QNetworkRequest req;
|
||||
// 响应 https
|
||||
// 响应 https(就是不行)
|
||||
QSslConfiguration conf = req.sslConfiguration();
|
||||
/*conf.setPeerVerifyMode(QSslSocket::VerifyNone);
|
||||
conf.setProtocol(QSsl::TlsV1SslV3);
|
||||
req.setSslConfiguration(conf);
|
||||
req.setUrl(QUrl(fileUrl));*/
|
||||
conf.setPeerVerifyMode(QSslSocket::VerifyNone);
|
||||
conf.setProtocol(QSsl::TlsV1SslV3);
|
||||
conf.setProtocol(QSsl::TlsV1_0);
|
||||
req.setSslConfiguration(conf);
|
||||
req.setUrl(QUrl(fileUrl));
|
||||
//QNetworkRequest request ;
|
||||
|
||||
//request.setAttribute(QNetworkRequest::HttpPipeliningAllowedAttribute, true);
|
||||
//QNetworkReply* reply = QNetworkAccessManager::createRequest(op, request, outgoingData);
|
||||
//QNetworkRequest request(req);
|
||||
// 下载文件
|
||||
QNetworkReply *reply = m.get(req);
|
||||
QEventLoop loop;
|
||||
QTimer t;
|
||||
//QMessageBox::information(this, "", QString::number(reply->rawHeader(QString("Content-Length").toUtf8())));
|
||||
qDebug() << reply->rawHeader(QString("Content-Length").toUtf8());
|
||||
connect(reply, &QNetworkReply::finished, &loop, &QEventLoop::quit);
|
||||
connect(reply, &QNetworkReply::downloadProgress, [=, &f, &t](qint64 bytesRead, qint64 totalBytes){
|
||||
f.write(reply->readAll());
|
||||
dialog->setValue(bytesRead / totalBytes * 100);
|
||||
dialog->setValue((float)bytesRead / totalBytes * 100);
|
||||
dialog->setLabelText(QString::number(bytesRead / 1024 / 1024) + "MB/" + QString::number(totalBytes / 1024 / 1024) + "MB");
|
||||
if(t.isActive()){
|
||||
t.start(timeout);
|
||||
}
|
||||
@@ -58,9 +89,108 @@ void DownloadThread::run(){
|
||||
}
|
||||
loop.exec();
|
||||
if(reply->error() != QNetworkReply::NoError){
|
||||
|
||||
emit MessageBoxError("下载失败");
|
||||
f.close();
|
||||
delete reply;
|
||||
delete dialog;
|
||||
dialog->close();
|
||||
return;
|
||||
}
|
||||
f.close();
|
||||
delete reply;
|
||||
dialog->close();
|
||||
SettingVirtualMachine(savePath);
|
||||
}
|
||||
|
||||
void DownloadThread::SettingVirtualMachine(QString savePath){
|
||||
// 设置虚拟机
|
||||
dialog->setLabelText("设置虚拟机");
|
||||
dialog->setWindowTitle("正在设置“" + vmName + "”");
|
||||
dialog->setValue(100 / SETTINGSTEP * 0);
|
||||
dialog->show();
|
||||
// 拷贝 OVA 文件
|
||||
if(notDownload){
|
||||
if(QFile::exists(savePath)){
|
||||
QFile::remove(savePath);
|
||||
}
|
||||
if(!QFile::copy(fileUrl, savePath)){
|
||||
emit MessageBoxError("文件复制错误,无法继续");
|
||||
}
|
||||
}
|
||||
// 导入 OVA 镜像
|
||||
QProcess progress;
|
||||
QStringList command;
|
||||
dialog->setValue(100 / SETTINGSTEP * 1);
|
||||
command << "import" << savePath;
|
||||
progress.start("VBoxManage", command);
|
||||
progress.waitForFinished();
|
||||
qDebug() << "正常信息:\n";
|
||||
qDebug() << progress.readAllStandardOutput();
|
||||
qDebug() << "错误信息:\n";
|
||||
qDebug() << progress.readAllStandardError();
|
||||
// 获取内存
|
||||
dialog->setValue(100 / SETTINGSTEP * 2);
|
||||
int memtotal = 0;
|
||||
#if defined (Q_OS_LINUX) // 在 Linux 下读取总内存
|
||||
progress.start("free -m");
|
||||
progress.waitForFinished();
|
||||
progress.readLine(); // 忽略第一行
|
||||
QString memoryInfo = progress.readLine(); // 只读取第 2 行
|
||||
qDebug() << memoryInfo;
|
||||
memoryInfo.replace("\n", ""); // 忽略换行符
|
||||
memoryInfo.replace(QRegExp("( ){1,}"), " "); // 将连续的空格换为单个空格
|
||||
auto memoryList = memoryInfo.split(" "); // 根据空格切割内容
|
||||
qDebug() << memoryList;
|
||||
if(memoryList.size() >= 2){ // 保证至少有两个
|
||||
// 理论上列表应该出现的是如下的内容
|
||||
// ["Mem:", "13998", "9622", "197", "803", "4179", "3331"]
|
||||
// 因此要读[1]
|
||||
memtotal = memoryList[1].toDouble();
|
||||
}
|
||||
else{
|
||||
emit MessageBoxError("内存读取错误,请自行打开 VirtualBox 设置内存");
|
||||
return;
|
||||
}
|
||||
#endif
|
||||
// 设置内存
|
||||
// 示例命令:VBoxManage modifyvm [name] --memory 4096
|
||||
command.clear(); // 清空参数列表
|
||||
command << "modifyvm" << vmName << "--memory" << QString::number(memtotal / 2);
|
||||
progress.start("VBoxManage", command);
|
||||
progress.waitForFinished();
|
||||
// 设置显卡,默认的 VMSVGA 在 Android X86 上运行有很多问题,应设为 VBoxVGA
|
||||
// 示例命令:VBoxManage modifyvm [name] --graphicscontroller vboxvga
|
||||
dialog->setValue(100 / SETTINGSTEP * 3);
|
||||
command.clear(); // 清空参数列表
|
||||
command << "modifyvm" << vmName << "--graphicscontroller" << "vboxvga";
|
||||
qDebug() << command;
|
||||
progress.start("VBoxManage", command);
|
||||
progress.waitForFinished();
|
||||
// 设置声卡
|
||||
// VBoxManage modifyvm [name] --audio pulse --audiocontroller hda --audioin on --audioout on
|
||||
dialog->setValue(100 / SETTINGSTEP * 4);
|
||||
command.clear(); // 清空参数列表
|
||||
command << "modifyvm" << vmName << "--audio" << "pulse" << "--audiocontroller" << "hda" << "--audioin" << "on" << "--audioout" << "on";
|
||||
progress.start("VBoxManage", command);
|
||||
progress.waitForFinished();
|
||||
// 设置显存
|
||||
// VBoxManage modifyvm [name] --vram 128
|
||||
dialog->setValue(100 / SETTINGSTEP * 5);
|
||||
command.clear(); // 清空参数列表
|
||||
command << "modifyvm" << vmName << "--vram" << "128";
|
||||
progress.start("VBoxManage", command);
|
||||
progress.waitForFinished();
|
||||
// 设置鼠标
|
||||
// VBoxManage modifyvm [name] --mouse ps2
|
||||
dialog->setValue(100 / SETTINGSTEP * 6);
|
||||
if(setMouse == "ps2"){
|
||||
command.clear(); // 清空参数列表
|
||||
command << "modifyvm" << vmName << "--mouse" << "ps2";
|
||||
progress.start("VBoxManage", command);
|
||||
progress.waitForFinished();
|
||||
}
|
||||
// 结束
|
||||
dialog->setValue(100);
|
||||
emit MessageBoxOpenVM(vmName);
|
||||
dialog->close();
|
||||
delete dialog;
|
||||
}
|
||||
|
||||
@@ -11,16 +11,23 @@
|
||||
class DownloadThread : public QThread // 继承 QThread
|
||||
{
|
||||
public:
|
||||
DownloadThread(QProgressDialog *dialog, QString url, QString save);
|
||||
DownloadThread(QProgressDialog *dialog, QString url, QString save, QString mouse, bool NotDownload);
|
||||
void SettingVirtualMachine(QString savePath);
|
||||
QProgressDialog *dialog;
|
||||
QString fileUrl;
|
||||
QString savePath;
|
||||
QString vmName;
|
||||
QString setMouse;
|
||||
bool notDownload;
|
||||
QString notDownloadPath;
|
||||
|
||||
protected:
|
||||
void run(); // 核心
|
||||
|
||||
signals:
|
||||
void ChangeValue();
|
||||
// 防止非主线程刷新控件导致程序退出
|
||||
void MessageBoxInfo(QString info);
|
||||
void MessageBoxError(QString info);
|
||||
void MessageBoxOpenVM(QString vmName);
|
||||
};
|
||||
|
||||
#endif // DOWNLOADTHREAD_H
|
||||
|
||||
44
Android X86/AXVM/getipserver.cpp
Normal file
44
Android X86/AXVM/getipserver.cpp
Normal file
@@ -0,0 +1,44 @@
|
||||
#include "getipserver.h"
|
||||
#include <QTcpServer>
|
||||
#include <mainwindow.h>
|
||||
#include <QtNetwork>
|
||||
#include <QHostAddress>
|
||||
#include <QMessageBox>
|
||||
|
||||
GetIPServer::GetIPServer(QLabel *localIp)
|
||||
{
|
||||
lock = false;
|
||||
tcp = new QTcpServer();
|
||||
QHostAddress ip("0.0.0.0");
|
||||
tcp->listen(QHostAddress::Any, 30201);
|
||||
// 获取 IP 地址
|
||||
QString IpAddress;
|
||||
foreach (QHostAddress address, QNetworkInterface::allAddresses())
|
||||
{
|
||||
if(address.protocol() == QAbstractSocket::IPv4Protocol && address.toString() != "127.0.0.1" && address.toString() != "192.168.250.1"){
|
||||
IpAddress = address.toString();
|
||||
}
|
||||
}
|
||||
qDebug() << "服务器IP:" << IpAddress;
|
||||
qDebug() << "服务器端口:" << tcp->serverPort();
|
||||
localIp->setText("访问:http://" + IpAddress + ":" + QString::number(tcp->serverPort()) + " 连接");
|
||||
connect(tcp, &QTcpServer::newConnection, this, [this](){
|
||||
|
||||
tcpSocket = tcp->nextPendingConnection();
|
||||
QString ipAddress = QHostAddress(tcpSocket->peerAddress().toIPv4Address()).toString();
|
||||
qDebug() << ipAddress;
|
||||
qDebug() << tcpSocket->peerPort();
|
||||
tcpSocket->write("HTTP/1.1 200 OK"\
|
||||
"Content-Type: text/html;charset=utf-8"\
|
||||
"\n\n");
|
||||
tcpSocket->write(QString("<html><body><p>IP Address: " + ipAddress + "</p><p>Get Port: " + QString::number(tcpSocket->peerPort()) + "</p></body></html>").toLocal8Bit());
|
||||
tcpSocket->close();
|
||||
if(lock){
|
||||
return;
|
||||
}
|
||||
lock = true;
|
||||
QMessageBox::question(NULL, "提示", "IP地址为“" + ipAddress + "”想要连接,是否连接?");
|
||||
lock = false;
|
||||
});
|
||||
qDebug() << "a";
|
||||
}
|
||||
20
Android X86/AXVM/getipserver.h
Normal file
20
Android X86/AXVM/getipserver.h
Normal file
@@ -0,0 +1,20 @@
|
||||
#ifndef GETIPSERVER_H
|
||||
#define GETIPSERVER_H
|
||||
|
||||
#include <mainwindow.h>
|
||||
#include <QTcpServer>
|
||||
#include <QLabel>
|
||||
|
||||
class GetIPServer : public QMainWindow
|
||||
{
|
||||
public:
|
||||
GetIPServer(QLabel *localIp);
|
||||
void ConnectClient();
|
||||
|
||||
private:
|
||||
bool lock;
|
||||
QTcpServer *tcp;
|
||||
QTcpSocket *tcpSocket;
|
||||
};
|
||||
|
||||
#endif // GETIPSERVER_H
|
||||
@@ -4,6 +4,8 @@
|
||||
#include <QStringListModel>
|
||||
#include <QStandardItem>
|
||||
#include <QThread>
|
||||
#include <QInputDialog>
|
||||
#include <QFileDialog>
|
||||
// 用于镜像信息获取
|
||||
#include <QNetworkReply>
|
||||
#include <QNetworkAccessManager>
|
||||
@@ -16,16 +18,21 @@
|
||||
#include <QProgressDialog>
|
||||
#include "downloadthread.h"
|
||||
#include <QLoggingCategory>
|
||||
// 用于执行命令
|
||||
#include <QProcess>
|
||||
// 用于 Mini HTTP 服务器搭建
|
||||
#include <getipserver.h>
|
||||
|
||||
MainWindow::MainWindow(QWidget *parent) :
|
||||
QMainWindow(parent),
|
||||
ui(new Ui::MainWindow)
|
||||
{
|
||||
ui->setupUi(this);
|
||||
QLoggingCategory::defaultCategory()->setEnabled(QtDebugMsg, true);
|
||||
// 获取网络镜像列表
|
||||
QEventLoop loop;
|
||||
QNetworkAccessManager manager;
|
||||
QNetworkReply *reply = manager.get(QNetworkRequest(QUrl("http://127.0.0.1/list.json")));
|
||||
QNetworkReply *reply = manager.get(QNetworkRequest(QUrl("http://120.25.153.144/AXVM/list.json")));
|
||||
connect(reply, SIGNAL(finished()), &loop, SLOT(quit()));
|
||||
loop.exec();
|
||||
// 解析获取数据并显示
|
||||
@@ -35,6 +42,7 @@ MainWindow::MainWindow(QWidget *parent) :
|
||||
QStringList nameList;
|
||||
QStandardItemModel *nameListModel = new QStandardItemModel(this);
|
||||
int size = name.size();
|
||||
qDebug() << size;
|
||||
for (int i = 0; i < size; ++i) {
|
||||
QJsonValue value = name.at(i);
|
||||
QJsonArray obj = value.toArray();
|
||||
@@ -44,6 +52,7 @@ MainWindow::MainWindow(QWidget *parent) :
|
||||
ui->urlImageList->setModel(nameListModel);
|
||||
// 允许 qDebug() 输出
|
||||
QLoggingCategory::defaultCategory()->setEnabled(QtDebugMsg, true);
|
||||
GetIPServer *ip = new GetIPServer(ui->localIP);
|
||||
}
|
||||
|
||||
MainWindow::~MainWindow()
|
||||
@@ -53,19 +62,88 @@ MainWindow::~MainWindow()
|
||||
// 安装事件
|
||||
void MainWindow::on_pushButton_2_clicked()
|
||||
{
|
||||
QNetworkAccessManager *manager = new QNetworkAccessManager(this);
|
||||
qDebug() << QSslSocket::supportsSsl();
|
||||
qDebug() << QSslSocket::sslLibraryBuildVersionString();
|
||||
qDebug() << QSslSocket::sslLibraryVersionString();
|
||||
qDebug() << manager->supportedSchemes();
|
||||
qDebug() << name.at(ui->urlImageList->selectionModel()->currentIndex().row()).toArray().at(1).toString();
|
||||
downloadDialog = new QProgressDialog("文件下载", "文件下载", 0, 100, this);
|
||||
downloadDialog->setWindowTitle("下载文件ing……");
|
||||
if(ui->urlImageList->selectionModel()->currentIndex().row() == -1){ // 未选择任何选项
|
||||
QMessageBox::information(this, "提示", "您未选择任何项");
|
||||
return;
|
||||
}
|
||||
downloadDialog = new QProgressDialog("", "无用的按钮", 0, 100, this);
|
||||
downloadDialog->setWindowTitle("正在下载“" + name.at(ui->urlImageList->selectionModel()->currentIndex().row()).toArray().at(0).toString() + "”");
|
||||
downloadDialog->show();
|
||||
thread = new DownloadThread(downloadDialog, name.at(ui->urlImageList->selectionModel()->currentIndex().row()).toArray().at(1).toString(), "/tmp/1.exe");
|
||||
if(name.at(ui->urlImageList->selectionModel()->currentIndex().row()).toArray().at(3).isArray()){
|
||||
if(QMessageBox::question(this, "提示", "推荐您手动下载格式包,是否手动获取链接并下载?") == QMessageBox::Yes){
|
||||
QJsonArray urlList = name.at(ui->urlImageList->selectionModel()->currentIndex().row()).toArray().at(3).toArray();
|
||||
QString urlThings = "";
|
||||
for(int i = 0; i < urlList.size(); i=i+2){
|
||||
urlThings += urlList.at(i).toString() + ":" + urlList.at(i + 1).toString();
|
||||
}
|
||||
|
||||
QString choose = QInputDialog::getMultiLineText(this,
|
||||
"“" + name.at(ui->urlImageList->selectionModel()->currentIndex().row()).toArray().at(0).toString() + "”下载链接",
|
||||
"请在下面任选一个链接复制到浏览器地址栏进行下载,下载完成后按下“OK”按钮选择下载的 OVA 文件,如果想要取消操作请按“Cancal”",
|
||||
urlThings);
|
||||
if(choose == ""){ // 忽略取消
|
||||
downloadDialog->close();
|
||||
delete downloadDialog;
|
||||
return;
|
||||
}
|
||||
QString path = QFileDialog::getOpenFileName(this, "浏览 OVA 文件", "~", "OVA文件(*.ova);;全部文件(*.*)");
|
||||
if(path == ""){ // 忽略取消
|
||||
downloadDialog->close();
|
||||
delete downloadDialog;
|
||||
return;
|
||||
}
|
||||
thread = new DownloadThread(downloadDialog,
|
||||
path,
|
||||
name.at(ui->urlImageList->selectionModel()->currentIndex().row()).toArray().at(0).toString(),
|
||||
name.at(ui->urlImageList->selectionModel()->currentIndex().row()).toArray().at(2).toString(),
|
||||
true);
|
||||
//connect(thread, &DownloadThread::MessageBoxInfo, this, [this](QString info){QMessageBox::information(this, "提示", info);});
|
||||
//connect(thread, &DownloadThread::MessageBoxError, this, [this](QString info){QMessageBox::critical(this, "错误", info);});
|
||||
/*connect(thread, &DownloadThread::MessageBoxOpenVM, this, [this](QString vmName){
|
||||
if(QMessageBox::question(this, "提示", "安装成功!是否现在马上启动虚拟机?") == QMessageBox::Yes){
|
||||
QProcess process;
|
||||
QStringList command;
|
||||
command << "startvm" << vmName;
|
||||
process.start("VBoxManage", command);
|
||||
process.waitForFinished();
|
||||
qDebug() << process.readAllStandardError();
|
||||
qDebug() << process.readAllStandardOutput();
|
||||
}});*/
|
||||
thread->start();
|
||||
return;
|
||||
}
|
||||
}
|
||||
thread = new DownloadThread(downloadDialog,
|
||||
name.at(ui->urlImageList->selectionModel()->currentIndex().row()).toArray().at(1).toString(),
|
||||
name.at(ui->urlImageList->selectionModel()->currentIndex().row()).toArray().at(0).toString(),
|
||||
name.at(ui->urlImageList->selectionModel()->currentIndex().row()).toArray().at(2).toString(),
|
||||
false);
|
||||
//connect(thread, &DownloadThread::MessageBoxInfo, this, &MainWindow::MessageBoxInfo);
|
||||
//connect(thread, &DownloadThread::MessageBoxError, this, &MainWindow::MessageBoxError);
|
||||
|
||||
//connect(thread, &DownloadThread::MessageBoxOpenVM, this, &MainWindow::OpenVM);
|
||||
thread->start();
|
||||
}
|
||||
|
||||
void MainWindow::ChangeValue(){
|
||||
//downloadDialog->setValue(thread->value);
|
||||
void DownloadThread::MessageBoxInfo(QString info){
|
||||
QMessageBox::information(NULL, "提示", info);
|
||||
}
|
||||
void DownloadThread::MessageBoxError(QString info){
|
||||
QMessageBox::critical(NULL, "错误", info);
|
||||
}
|
||||
void DownloadThread::MessageBoxOpenVM(QString vmName)
|
||||
{
|
||||
if(QMessageBox::question(NULL, "提示", "安装成功!是否现在马上启动虚拟机?") == QMessageBox::Yes){
|
||||
QProcess process;
|
||||
QStringList command;
|
||||
command << "startvm" << vmName;
|
||||
process.start("VBoxManage", command);
|
||||
process.waitForFinished();
|
||||
qDebug() << process.readAllStandardError();
|
||||
qDebug() << process.readAllStandardOutput();
|
||||
}
|
||||
}
|
||||
|
||||
void MainWindow::on_centralWidget_destroyed()
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
@@ -22,7 +22,11 @@ public:
|
||||
|
||||
private slots:
|
||||
void on_pushButton_2_clicked();
|
||||
void ChangeValue();
|
||||
//void OpenVM(QString vmName);
|
||||
//void MessageBoxInfo(QString info);
|
||||
//void MessageBoxError(QString info);
|
||||
|
||||
void on_centralWidget_destroyed();
|
||||
|
||||
private:
|
||||
Ui::MainWindow *ui;
|
||||
|
||||
@@ -21,7 +21,7 @@
|
||||
<enum>QTabWidget::West</enum>
|
||||
</property>
|
||||
<property name="currentIndex">
|
||||
<number>1</number>
|
||||
<number>0</number>
|
||||
</property>
|
||||
<property name="elideMode">
|
||||
<enum>Qt::ElideNone</enum>
|
||||
@@ -31,12 +31,34 @@
|
||||
<string>操作</string>
|
||||
</attribute>
|
||||
<layout class="QGridLayout" name="gridLayout" columnstretch="0">
|
||||
<item row="1" column="0">
|
||||
<layout class="QHBoxLayout" name="horizontalLayout_2">
|
||||
<item row="3" column="0">
|
||||
<layout class="QHBoxLayout" name="horizontalLayout_5">
|
||||
<item>
|
||||
<widget class="QLabel" name="label_2">
|
||||
<widget class="QLabel" name="label_3">
|
||||
<property name="sizePolicy">
|
||||
<sizepolicy hsizetype="Fixed" vsizetype="Fixed">
|
||||
<horstretch>0</horstretch>
|
||||
<verstretch>0</verstretch>
|
||||
</sizepolicy>
|
||||
</property>
|
||||
<property name="text">
|
||||
<string>TextLabel</string>
|
||||
<string>选择虚拟机:</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item>
|
||||
<widget class="QComboBox" name="comboBox"/>
|
||||
</item>
|
||||
<item>
|
||||
<widget class="QPushButton" name="pushButton_7">
|
||||
<property name="sizePolicy">
|
||||
<sizepolicy hsizetype="Fixed" vsizetype="Fixed">
|
||||
<horstretch>0</horstretch>
|
||||
<verstretch>0</verstretch>
|
||||
</sizepolicy>
|
||||
</property>
|
||||
<property name="text">
|
||||
<string>PushButton</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
@@ -47,7 +69,7 @@
|
||||
<item>
|
||||
<widget class="QLabel" name="label">
|
||||
<property name="text">
|
||||
<string>TextLabel</string>
|
||||
<string>IP地址:</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
@@ -57,13 +79,111 @@
|
||||
<item>
|
||||
<widget class="QPushButton" name="pushButton_3">
|
||||
<property name="text">
|
||||
<string>PushButton</string>
|
||||
<string>连接</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
</layout>
|
||||
</item>
|
||||
<item row="4" column="0">
|
||||
<layout class="QGridLayout" name="gridLayout_2">
|
||||
<item row="0" column="4">
|
||||
<widget class="QPushButton" name="pushButton_11">
|
||||
<property name="text">
|
||||
<string>重置虚拟机</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="0" column="0">
|
||||
<widget class="QPushButton" name="pushButton_8">
|
||||
<property name="text">
|
||||
<string>开启虚拟机</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="0" column="2">
|
||||
<widget class="QPushButton" name="pushButton_10">
|
||||
<property name="text">
|
||||
<string>设置虚拟机</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="0" column="5">
|
||||
<spacer name="horizontalSpacer">
|
||||
<property name="orientation">
|
||||
<enum>Qt::Horizontal</enum>
|
||||
</property>
|
||||
<property name="sizeHint" stdset="0">
|
||||
<size>
|
||||
<width>40</width>
|
||||
<height>20</height>
|
||||
</size>
|
||||
</property>
|
||||
</spacer>
|
||||
</item>
|
||||
<item row="0" column="1">
|
||||
<widget class="QPushButton" name="pushButton_9">
|
||||
<property name="text">
|
||||
<string>关闭虚拟机</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="0" column="3">
|
||||
<widget class="QPushButton" name="pushButton_12">
|
||||
<property name="text">
|
||||
<string>重置虚拟机配置</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
</layout>
|
||||
</item>
|
||||
<item row="2" column="0">
|
||||
<layout class="QHBoxLayout" name="horizontalLayout_4">
|
||||
<item>
|
||||
<widget class="QLabel" name="label_2">
|
||||
<property name="text">
|
||||
<string>安装/卸载应用:</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item>
|
||||
<widget class="QLineEdit" name="lineEdit_2"/>
|
||||
</item>
|
||||
<item>
|
||||
<widget class="QPushButton" name="pushButton_6">
|
||||
<property name="text">
|
||||
<string>安装</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item>
|
||||
<widget class="QPushButton" name="pushButton_5">
|
||||
<property name="text">
|
||||
<string>浏览</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item>
|
||||
<widget class="QPushButton" name="pushButton_4">
|
||||
<property name="text">
|
||||
<string>卸载</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
</layout>
|
||||
</item>
|
||||
<item row="1" column="0">
|
||||
<layout class="QHBoxLayout" name="horizontalLayout_2">
|
||||
<item>
|
||||
<widget class="QLabel" name="localIP">
|
||||
<property name="text">
|
||||
<string>访问:http://127.0.0.1:30201 连接</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
</layout>
|
||||
</item>
|
||||
<item row="5" column="0">
|
||||
<spacer name="verticalSpacer">
|
||||
<property name="orientation">
|
||||
<enum>Qt::Vertical</enum>
|
||||
@@ -142,6 +262,13 @@
|
||||
</widget>
|
||||
</widget>
|
||||
</item>
|
||||
<item>
|
||||
<widget class="QLabel" name="label_4">
|
||||
<property name="text">
|
||||
<string>©2022~Now,gfdgd xi、为什么您不喜欢熊出没和阿布呢</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
</layout>
|
||||
</widget>
|
||||
<widget class="QStatusBar" name="statusBar"/>
|
||||
|
||||
Reference in New Issue
Block a user