mirror of
https://gitee.com/gfdgd-xi/deep-wine-runner
synced 2025-12-14 02:52:03 +08:00
初步支持安装deb
This commit is contained in:
@@ -1,10 +1,11 @@
|
|||||||
#include "installdeb.h"
|
#include "installdeb.h"
|
||||||
|
#include "messagebox.h"
|
||||||
#include <QDateTime>
|
#include <QDateTime>
|
||||||
#include <QObject>
|
#include <QObject>
|
||||||
#include <QMessageBox>
|
#include <QMessageBox>
|
||||||
#include <QMainWindow>
|
#include <QMainWindow>
|
||||||
|
|
||||||
InstallDEB::InstallDEB(QTermWidget *terminal, QMainWindow *mainWindow)
|
InstallDEB::InstallDEB(QTermWidget *terminal, DMainWindow *mainWindow)
|
||||||
{
|
{
|
||||||
this->terminal = terminal;
|
this->terminal = terminal;
|
||||||
this->mainWindow = mainWindow;
|
this->mainWindow = mainWindow;
|
||||||
@@ -14,7 +15,7 @@ void InstallDEB::AddCommand(QString command){
|
|||||||
this->commandList.append(command);
|
this->commandList.append(command);
|
||||||
}
|
}
|
||||||
|
|
||||||
void InstallDEB::RunCommand(){
|
void InstallDEB::RunCommand(bool withRoot){
|
||||||
this->terminal->setEnabled(true);
|
this->terminal->setEnabled(true);
|
||||||
this->runStatus = true;
|
this->runStatus = true;
|
||||||
// 写入为 Bash 文件,方便执行
|
// 写入为 Bash 文件,方便执行
|
||||||
@@ -33,12 +34,22 @@ void InstallDEB::RunCommand(){
|
|||||||
file.close();
|
file.close();
|
||||||
system(("chmod +x '" + bashPath + "'").toUtf8()); // 赋予运行权限
|
system(("chmod +x '" + bashPath + "'").toUtf8()); // 赋予运行权限
|
||||||
this->terminal->setColorScheme("DarkPastels");
|
this->terminal->setColorScheme("DarkPastels");
|
||||||
this->terminal->setShellProgram("/usr/bin/bash");
|
if(withRoot){
|
||||||
this->terminal->setArgs(QStringList() << bashPath);
|
this->terminal->setShellProgram("/usr/bin/pkexec");
|
||||||
|
this->terminal->setArgs(QStringList() << "/usr/bin/bash" << bashPath);
|
||||||
|
}
|
||||||
|
else{
|
||||||
|
this->terminal->setShellProgram("/usr/bin/bash");
|
||||||
|
this->terminal->setArgs(QStringList() << bashPath);
|
||||||
|
}
|
||||||
//this->terminal->setAutoClose(1);
|
//this->terminal->setAutoClose(1);
|
||||||
this->terminal->setAutoFillBackground(1);
|
this->terminal->setAutoFillBackground(1);
|
||||||
this->terminal->startShellProgram();
|
|
||||||
QObject::connect(this->terminal, &QTermWidget::finished, this->mainWindow, [this](){
|
QObject::connect(this->terminal, &QTermWidget::finished, this->mainWindow, [this](){
|
||||||
QMessageBox::information(this->mainWindow, "A", "B");
|
//QMessageBox::information(this->mainWindow, "A", "B");
|
||||||
|
MessageBox *message = new MessageBox();
|
||||||
|
message->information("提示", "应用安装完成");
|
||||||
|
this->mainWindow->sendMessage(QIcon(":/Icon/MessageBox/dialog-information.svg"), "应用安装完成");
|
||||||
});
|
});
|
||||||
|
this->terminal->startShellProgram();
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -3,18 +3,19 @@
|
|||||||
|
|
||||||
#include <QObject>
|
#include <QObject>
|
||||||
#include <qtermwidget5/qtermwidget.h>
|
#include <qtermwidget5/qtermwidget.h>
|
||||||
#include <QMainWindow>
|
#include <DMainWindow>
|
||||||
|
using namespace Dtk::Widget;
|
||||||
|
|
||||||
class InstallDEB
|
class InstallDEB
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
InstallDEB(QTermWidget *terminal, QMainWindow *mainWindow = NULL);
|
InstallDEB(QTermWidget *terminal, DMainWindow *mainWindow = NULL);
|
||||||
void AddCommand(QString command);
|
void AddCommand(QString command);
|
||||||
void RunCommand();
|
void RunCommand(bool withRoot=false);
|
||||||
QStringList commandList;
|
QStringList commandList;
|
||||||
private:
|
private:
|
||||||
QTermWidget *terminal;
|
QTermWidget *terminal;
|
||||||
QMainWindow *mainWindow = NULL;
|
DMainWindow *mainWindow = NULL;
|
||||||
bool runStatus;
|
bool runStatus;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|||||||
21
main.cpp
21
main.cpp
@@ -3,11 +3,30 @@
|
|||||||
#include <QLocale>
|
#include <QLocale>
|
||||||
#include <QTranslator>
|
#include <QTranslator>
|
||||||
#include <DApplication>
|
#include <DApplication>
|
||||||
|
#include <DMessageBox>
|
||||||
|
#include <iostream>
|
||||||
using namespace Dtk::Widget;
|
using namespace Dtk::Widget;
|
||||||
|
using namespace std;
|
||||||
|
|
||||||
int main(int argc, char *argv[])
|
int main(int argc, char *argv[])
|
||||||
{
|
{
|
||||||
DApplication a(argc, argv);
|
// 强制使用 DTK 平台插件
|
||||||
|
QVector<char *> fakeArgs(argc + 2);
|
||||||
|
fakeArgs[0] = argv[0];
|
||||||
|
fakeArgs[1] = const_cast<char *>("-platformtheme");
|
||||||
|
fakeArgs[2] = const_cast<char *>("deepin");
|
||||||
|
for(int i = 1; i < argc; i++){
|
||||||
|
fakeArgs[i + 2] = argv[i];
|
||||||
|
}
|
||||||
|
int fakeArgc = argc + 2;
|
||||||
|
DApplication a(fakeArgc, fakeArgs.data());
|
||||||
|
DApplication::setOrganizationName("gfdgd_xi");
|
||||||
|
DApplication::setApplicationName("deepin-wine-runner-aptss-installer");
|
||||||
|
|
||||||
|
if(system("which aptss")){
|
||||||
|
DMessageBox::information(NULL, "错误", "无法检测到 aptss\n请确保您已安装星火应用商店并更新至最新版本");
|
||||||
|
return 1;
|
||||||
|
}
|
||||||
|
|
||||||
QTranslator translator;
|
QTranslator translator;
|
||||||
const QStringList uiLanguages = QLocale::system().uiLanguages();
|
const QStringList uiLanguages = QLocale::system().uiLanguages();
|
||||||
|
|||||||
@@ -10,9 +10,9 @@ MainWindow::MainWindow(QWidget *parent)
|
|||||||
, ui(new Ui::MainWindow)
|
, ui(new Ui::MainWindow)
|
||||||
{
|
{
|
||||||
ui->setupUi(this);
|
ui->setupUi(this);
|
||||||
MessageBox *message = new MessageBox();
|
/*MessageBox *message = new MessageBox();
|
||||||
message->information("A", "B");
|
message->information("A", "B");
|
||||||
this->close();
|
this->close();*/
|
||||||
}
|
}
|
||||||
|
|
||||||
MainWindow::~MainWindow()
|
MainWindow::~MainWindow()
|
||||||
@@ -25,16 +25,11 @@ void MainWindow::on_installPath_clicked()
|
|||||||
{
|
{
|
||||||
QTermWidget *terminal = new QTermWidget(0);
|
QTermWidget *terminal = new QTermWidget(0);
|
||||||
terminal->setColorScheme("DarkPastels");
|
terminal->setColorScheme("DarkPastels");
|
||||||
terminal->setShellProgram("/usr/bin/bash");
|
terminal->setAutoClose(1);
|
||||||
terminal->setArgs(QStringList() << "-c" << "gedit");
|
InstallDEB *deb = new InstallDEB(terminal, this);
|
||||||
connect(terminal, &QTermWidget::finished, this, [&, this](){
|
deb->AddCommand("aptss update");
|
||||||
//QMessageBox::information(NULL, "提示", "系统安装完成");
|
deb->AddCommand("aptss install \"" + ui->debPath->text() + "\"");
|
||||||
MessageBox *message = new MessageBox();
|
deb->RunCommand(1);
|
||||||
message->information("A", "B");
|
|
||||||
});
|
|
||||||
terminal->startShellProgram();
|
|
||||||
|
|
||||||
|
|
||||||
ui->gridLayout->addWidget(terminal, 1, 0);
|
ui->gridLayout->addWidget(terminal, 1, 0);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -20,6 +20,13 @@
|
|||||||
<item>
|
<item>
|
||||||
<widget class="QLineEdit" name="debPath"/>
|
<widget class="QLineEdit" name="debPath"/>
|
||||||
</item>
|
</item>
|
||||||
|
<item>
|
||||||
|
<widget class="QPushButton" name="browserButton">
|
||||||
|
<property name="text">
|
||||||
|
<string>浏览</string>
|
||||||
|
</property>
|
||||||
|
</widget>
|
||||||
|
</item>
|
||||||
<item>
|
<item>
|
||||||
<widget class="QPushButton" name="installPath">
|
<widget class="QPushButton" name="installPath">
|
||||||
<property name="text">
|
<property name="text">
|
||||||
@@ -29,6 +36,19 @@
|
|||||||
</item>
|
</item>
|
||||||
</layout>
|
</layout>
|
||||||
</item>
|
</item>
|
||||||
|
<item row="1" column="0">
|
||||||
|
<spacer name="verticalSpacer">
|
||||||
|
<property name="orientation">
|
||||||
|
<enum>Qt::Vertical</enum>
|
||||||
|
</property>
|
||||||
|
<property name="sizeHint" stdset="0">
|
||||||
|
<size>
|
||||||
|
<width>20</width>
|
||||||
|
<height>40</height>
|
||||||
|
</size>
|
||||||
|
</property>
|
||||||
|
</spacer>
|
||||||
|
</item>
|
||||||
</layout>
|
</layout>
|
||||||
</widget>
|
</widget>
|
||||||
<action name="action1">
|
<action name="action1">
|
||||||
|
|||||||
Reference in New Issue
Block a user