diff --git a/VM-source/VirtualMachine b/VM-source/VirtualMachine index 7c3d931..462a193 100755 Binary files a/VM-source/VirtualMachine and b/VM-source/VirtualMachine differ diff --git a/VM-source/buildvbox.cpp b/VM-source/buildvbox.cpp index 181708b..3602ae1 100644 --- a/VM-source/buildvbox.cpp +++ b/VM-source/buildvbox.cpp @@ -37,6 +37,13 @@ QString buildvbox::GetNet(){ } buildvbox::buildvbox(QString isoPath, int id){ + /*QDir vboxPath(QDir::homePath() + "/VirtualBox VMs/Windows"); + if(vboxPath.exists()){ + qDebug("虚拟机存在,直接启动!"); + vbox vm("Windows"); + vm.Start(); + return; + }*/ QString programPath = QCoreApplication::applicationDirPath(); QString net = GetNet(); qDebug() << "使用网卡:" << net << endl; diff --git a/VM-source/main.cpp b/VM-source/main.cpp index c93bfae..19eb1a9 100755 --- a/VM-source/main.cpp +++ b/VM-source/main.cpp @@ -2,6 +2,18 @@ #include #include #include +#include +#include + +QString GetRunCommand(QString command){ + QProcess process; + process.start(command); + process.waitForStarted(); + process.waitForFinished(); + QString re = process.readAllStandardOutput(); + process.close(); + return re; +} int main(int argc, char *argv[]) { @@ -11,6 +23,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")){ + QMessageBox::critical(NULL, "错误", "此程序不支持非 X86 架构,立即退出"); + return 0; + } MainWindow w; w.show(); diff --git a/VM-source/main.o b/VM-source/main.o index af22559..7ac6858 100644 Binary files a/VM-source/main.o and b/VM-source/main.o differ diff --git a/VM-source/mainwindow.cpp b/VM-source/mainwindow.cpp index e189b67..b539944 100755 --- a/VM-source/mainwindow.cpp +++ b/VM-source/mainwindow.cpp @@ -21,8 +21,25 @@ MainWindow::MainWindow(QWidget *parent) : ui->tabWidget->setTabPosition(QTabWidget::West); // 标签靠左 // 允许输出 qDebug 信息 QLoggingCategory::defaultCategory()->setEnabled(QtDebugMsg, true); + // 判断是否安装 vbox + if(system("which VBoxManage")){ + if(QMessageBox::question(NULL, "提示", "检测到您似乎没有安装 VirtualBox,立即安装?") == QMessageBox::Yes){ + system("xdg-open https://www.virtualbox.org/wiki/Linux_Downloads"); + } + } } +QString MainWindow::GetRunCommand(QString command){ + QProcess process; + process.start(command); + process.waitForStarted(); + process.waitForFinished(); + QString re = process.readAllStandardOutput(); + process.close(); + return re; +} + + MainWindow::~MainWindow() { delete ui; diff --git a/VM-source/mainwindow.h b/VM-source/mainwindow.h index f72d399..f4be400 100755 --- a/VM-source/mainwindow.h +++ b/VM-source/mainwindow.h @@ -17,7 +17,7 @@ public: private slots: void on_browser_clicked(); - + QString GetRunCommand(QString command); void on_install_clicked(); private: diff --git a/VM-source/mainwindow.o b/VM-source/mainwindow.o index a831486..4495669 100644 Binary files a/VM-source/mainwindow.o and b/VM-source/mainwindow.o differ diff --git a/VM-source/moc_mainwindow.cpp b/VM-source/moc_mainwindow.cpp index e214d97..6b09864 100644 --- a/VM-source/moc_mainwindow.cpp +++ b/VM-source/moc_mainwindow.cpp @@ -22,8 +22,8 @@ QT_BEGIN_MOC_NAMESPACE QT_WARNING_PUSH QT_WARNING_DISABLE_DEPRECATED struct qt_meta_stringdata_MainWindow_t { - QByteArrayData data[4]; - char stringdata0[50]; + QByteArrayData data[6]; + char stringdata0[72]; }; #define QT_MOC_LITERAL(idx, ofs, len) \ Q_STATIC_BYTE_ARRAY_DATA_HEADER_INITIALIZER_WITH_OFFSET(len, \ @@ -35,11 +35,13 @@ static const qt_meta_stringdata_MainWindow_t qt_meta_stringdata_MainWindow = { QT_MOC_LITERAL(0, 0, 10), // "MainWindow" QT_MOC_LITERAL(1, 11, 18), // "on_browser_clicked" QT_MOC_LITERAL(2, 30, 0), // "" -QT_MOC_LITERAL(3, 31, 18) // "on_install_clicked" +QT_MOC_LITERAL(3, 31, 13), // "GetRunCommand" +QT_MOC_LITERAL(4, 45, 7), // "command" +QT_MOC_LITERAL(5, 53, 18) // "on_install_clicked" }, "MainWindow\0on_browser_clicked\0\0" - "on_install_clicked" + "GetRunCommand\0command\0on_install_clicked" }; #undef QT_MOC_LITERAL @@ -49,7 +51,7 @@ static const uint qt_meta_data_MainWindow[] = { 8, // revision 0, // classname 0, 0, // classinfo - 2, 14, // methods + 3, 14, // methods 0, 0, // properties 0, 0, // enums/sets 0, 0, // constructors @@ -57,11 +59,13 @@ static const uint qt_meta_data_MainWindow[] = { 0, // signalCount // slots: name, argc, parameters, tag, flags - 1, 0, 24, 2, 0x08 /* Private */, - 3, 0, 25, 2, 0x08 /* Private */, + 1, 0, 29, 2, 0x08 /* Private */, + 3, 1, 30, 2, 0x08 /* Private */, + 5, 0, 33, 2, 0x08 /* Private */, // slots: parameters QMetaType::Void, + QMetaType::QString, QMetaType::QString, 4, QMetaType::Void, 0 // eod @@ -74,11 +78,12 @@ void MainWindow::qt_static_metacall(QObject *_o, QMetaObject::Call _c, int _id, (void)_t; switch (_id) { case 0: _t->on_browser_clicked(); break; - case 1: _t->on_install_clicked(); break; + case 1: { QString _r = _t->GetRunCommand((*reinterpret_cast< QString(*)>(_a[1]))); + if (_a[0]) *reinterpret_cast< QString*>(_a[0]) = std::move(_r); } break; + case 2: _t->on_install_clicked(); break; default: ; } } - (void)_a; } QT_INIT_METAOBJECT const QMetaObject MainWindow::staticMetaObject = { { @@ -110,13 +115,13 @@ int MainWindow::qt_metacall(QMetaObject::Call _c, int _id, void **_a) if (_id < 0) return _id; if (_c == QMetaObject::InvokeMetaMethod) { - if (_id < 2) + if (_id < 3) qt_static_metacall(this, _c, _id, _a); - _id -= 2; + _id -= 3; } else if (_c == QMetaObject::RegisterMethodArgumentMetaType) { - if (_id < 2) + if (_id < 3) *reinterpret_cast(_a[0]) = -1; - _id -= 2; + _id -= 3; } return _id; } diff --git a/VM-source/moc_mainwindow.o b/VM-source/moc_mainwindow.o index e726b21..ed70fda 100644 Binary files a/VM-source/moc_mainwindow.o and b/VM-source/moc_mainwindow.o differ diff --git a/VM-source/vbox.cpp b/VM-source/vbox.cpp index 94d4c3b..476b1f7 100644 --- a/VM-source/vbox.cpp +++ b/VM-source/vbox.cpp @@ -41,7 +41,6 @@ int vbox::SetCPU(int number){ return system(("\"" + managerPath + "\" modifyvm \"" + name + "\" --cpus " + QString::number(number)).toLatin1()); } int vbox::SetMemory(int memory){ - QMessageBox::information(NULL, "", ("\"" + managerPath + "\" modifyvm \"" + name + "\" --memory " + QString::number(memory)).toLatin1()); return system(("\"" + managerPath + "\" modifyvm \"" + name + "\" --memory " + QString::number(memory)).toLatin1()); } int vbox::SetRemote(bool setting){ diff --git a/VM-source/vbox.o b/VM-source/vbox.o index 0dc63bc..85931c1 100644 Binary files a/VM-source/vbox.o and b/VM-source/vbox.o differ