mirror of
https://gitee.com/spark-store-project/spark-store
synced 2025-07-11 16:15:58 +08:00
新增 安装方式选择
This commit is contained in:
commit
a732269b62
@ -147,7 +147,6 @@ void downloadlist::install(int t)
|
||||
ui->label_2->setText("安装完成");
|
||||
ui->pushButton_3->show();
|
||||
}else {
|
||||
ui->pushButton_install->show();
|
||||
ui->pushButton_install->show();
|
||||
ui->pushButton_install->setText("重装");
|
||||
ui->label_2->setText("安装出现错误,可重新安装");
|
||||
@ -156,7 +155,6 @@ void downloadlist::install(int t)
|
||||
if(notRoot){
|
||||
ui->label_2->setText("安装被终止,可重新安装");
|
||||
ui->pushButton_install->show();
|
||||
ui->pushButton_install->show();
|
||||
ui->pushButton_3->hide();
|
||||
}
|
||||
ui->widget_spinner->hide();
|
||||
@ -175,6 +173,74 @@ void downloadlist::on_pushButton_install_clicked()
|
||||
// menu_install->show();
|
||||
menu_install->exec(cursor().pos());
|
||||
}
|
||||
void downloadlist::on_pushButton_maninst_clicked()
|
||||
{
|
||||
if(!isInstall)
|
||||
{
|
||||
isInstall = true;
|
||||
ui->pushButton_install->hide();
|
||||
ui->widget_spinner->show();
|
||||
qDebug() << "/tmp/spark-store/" + ui->label_filename->text().toUtf8();
|
||||
ui->label_2->setText("正在安装,请稍候");
|
||||
QtConcurrent::run([=]()
|
||||
{
|
||||
QProcess installer;
|
||||
if(reinstall)
|
||||
{
|
||||
installer.start("pkexec apt reinstall /tmp/spark-store/" + ui->label_filename->text().toUtf8());
|
||||
}
|
||||
else
|
||||
{
|
||||
installer.start("pkexec apt install /tmp/spark-store/" + ui->label_filename->text().toUtf8());
|
||||
}
|
||||
installer.waitForFinished();
|
||||
out = installer.readAllStandardOutput();
|
||||
installer.close();
|
||||
QStringList everyOut = out.split("\n");
|
||||
bool haveError = false;
|
||||
bool notRoot = false;
|
||||
for (int i = 0; i < everyOut.size(); i++)
|
||||
{
|
||||
qDebug() << everyOut[i].left(2);
|
||||
if(everyOut[i].left(2) == "E:")
|
||||
{
|
||||
haveError = true;
|
||||
}
|
||||
if(everyOut[i].right(14) == "Not authorized")
|
||||
{
|
||||
notRoot = true;
|
||||
}
|
||||
}
|
||||
QProcess isInstall;
|
||||
isInstall.start("dpkg -s " + pkgName);
|
||||
isInstall.waitForFinished();
|
||||
int error = QString::fromStdString(isInstall.readAllStandardError().toStdString()).length();
|
||||
isInstall.close();
|
||||
if(error == 0)
|
||||
{
|
||||
ui->pushButton_install->hide();
|
||||
ui->label_2->setText("安装完成");
|
||||
ui->pushButton_3->show();
|
||||
}
|
||||
else
|
||||
{
|
||||
ui->pushButton_install->show();
|
||||
ui->pushButton_install->setText("重装");
|
||||
ui->label_2->setText("安装出现错误,可重新安装");
|
||||
ui->pushButton_3->show();
|
||||
}
|
||||
if(notRoot)
|
||||
{
|
||||
ui->label_2->setText("安装被终止,可重新安装");
|
||||
ui->pushButton_install->show();
|
||||
ui->pushButton_3->hide();
|
||||
}
|
||||
ui->widget_spinner->hide();
|
||||
downloadlist::isInstall = false;
|
||||
});
|
||||
qDebug() << ui->label_filename->text().toUtf8();
|
||||
}
|
||||
}
|
||||
|
||||
void downloadlist::on_pushButton_2_clicked()
|
||||
{
|
||||
@ -186,8 +252,6 @@ void downloadlist::on_pushButton_2_clicked()
|
||||
|
||||
void downloadlist::on_pushButton_3_clicked()
|
||||
{
|
||||
|
||||
|
||||
output_w.layout()->addWidget(textbrowser);
|
||||
textbrowser->setLineWidth(0);
|
||||
textbrowser->setText(out);
|
||||
|
@ -41,10 +41,8 @@ public:
|
||||
void install(int);
|
||||
private slots:
|
||||
void on_pushButton_install_clicked();
|
||||
|
||||
void on_pushButton_maninst_clicked();
|
||||
void on_pushButton_2_clicked();
|
||||
|
||||
|
||||
void on_pushButton_3_clicked();
|
||||
|
||||
private:
|
||||
|
@ -6,7 +6,7 @@
|
||||
<rect>
|
||||
<x>0</x>
|
||||
<y>0</y>
|
||||
<width>729</width>
|
||||
<width>776</width>
|
||||
<height>54</height>
|
||||
</rect>
|
||||
</property>
|
||||
@ -54,6 +54,22 @@
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item>
|
||||
<spacer name="horizontalSpacer">
|
||||
<property name="orientation">
|
||||
<enum>Qt::Horizontal</enum>
|
||||
</property>
|
||||
<property name="sizeType">
|
||||
<enum>QSizePolicy::Fixed</enum>
|
||||
</property>
|
||||
<property name="sizeHint" stdset="0">
|
||||
<size>
|
||||
<width>20</width>
|
||||
<height>20</height>
|
||||
</size>
|
||||
</property>
|
||||
</spacer>
|
||||
</item>
|
||||
<item>
|
||||
<widget class="QLabel" name="label_filename">
|
||||
<property name="maximumSize">
|
||||
@ -71,7 +87,7 @@
|
||||
<widget class="QLabel" name="label">
|
||||
<property name="minimumSize">
|
||||
<size>
|
||||
<width>100</width>
|
||||
<width>80</width>
|
||||
<height>0</height>
|
||||
</size>
|
||||
</property>
|
||||
@ -92,7 +108,7 @@
|
||||
</widget>
|
||||
</item>
|
||||
<item>
|
||||
<spacer name="horizontalSpacer">
|
||||
<spacer name="horizontalSpacer_2">
|
||||
<property name="orientation">
|
||||
<enum>Qt::Horizontal</enum>
|
||||
</property>
|
||||
@ -101,7 +117,7 @@
|
||||
</property>
|
||||
<property name="sizeHint" stdset="0">
|
||||
<size>
|
||||
<width>40</width>
|
||||
<width>20</width>
|
||||
<height>20</height>
|
||||
</size>
|
||||
</property>
|
||||
@ -181,7 +197,7 @@
|
||||
</widget>
|
||||
</item>
|
||||
<item>
|
||||
<spacer name="horizontalSpacer_2">
|
||||
<spacer name="horizontalSpacer_3">
|
||||
<property name="orientation">
|
||||
<enum>Qt::Horizontal</enum>
|
||||
</property>
|
||||
@ -200,7 +216,7 @@
|
||||
<widget class="DSpinner" name="widget_spinner" native="true">
|
||||
<property name="minimumSize">
|
||||
<size>
|
||||
<width>60</width>
|
||||
<width>30</width>
|
||||
<height>0</height>
|
||||
</size>
|
||||
</property>
|
||||
|
Loading…
x
Reference in New Issue
Block a user