Merge branch 'dev' into Reason

This commit is contained in:
uniartisan 2023-03-12 22:05:44 +08:00
commit d3b71fbacc
3 changed files with 74 additions and 2 deletions

@ -14,6 +14,7 @@
#include <QDesktopServices>
#include <QAbstractButton>
#include <QtConcurrent>
#include <unistd.h>
#define AppPageApplist 0
#define AppPageSearchlist 1
@ -32,11 +33,11 @@ MainWindow::MainWindow(QWidget *parent)
{
ui->setupUi(this);
initTmpDir();
initUI();
initConnections();
initTmpDir();
ui->appintopage->setDownloadWidget(downloadlistwidget);
emit DGuiApplicationHelper::instance()->themeTypeChanged(DGuiApplicationHelper::instance()->themeType());
@ -393,6 +394,28 @@ void MainWindow::initTmpDir()
// 新建临时文件夹
QDir dir;
dir.mkpath("/tmp/spark-store");
// 检查写入权限
QFileInfo info("/tmp/spark-store");
if (info.isWritable() == false)
{
QtConcurrent::run([=]
{
sleep(3);
auto upgradeP = new QProcess();
upgradeP->startDetached("zenity", QStringList() << "--warning"
<< "--text"
<< "用户未拥有 /tmp/spark-store 写入权限,星火商店会因此工作异常,请检查!"
<< "--title"
<< "权限受限提示"
<< "--width"
<< "360"
);
upgradeP->waitForStarted();
upgradeP->waitForFinished(30);
upgradeP->deleteLater(); });
}
}
void MainWindow::switchPage(int now) // 临时方案,回家后修改

@ -9,6 +9,9 @@
#include <QtConcurrent>
#include <QClipboard>
#include <QFile>
#include <DSysInfo>
AppIntoPage::AppIntoPage(QWidget *parent)
: QWidget(parent)
@ -336,6 +339,9 @@ void AppIntoPage::isDownloading(const QUrl &url)
void AppIntoPage::setAppinfoTags(const QStringList &tagList)
{
bool ubuntuSupport = false;
bool deepinSupport = false;
bool uosSupport = false;
foreach (const QString &tag, tagList)
{
if (tag == "community")
@ -345,14 +351,18 @@ void AppIntoPage::setAppinfoTags(const QStringList &tagList)
else if (tag == "ubuntu")
{
ui->tag_ubuntu->show();
ubuntuSupport = true;
}
else if (tag == "deepin")
{
ui->tag_deepin->show();
deepinSupport = true;
}
else if (tag == "uos")
{
ui->tag_uos->show();
uosSupport = true;
}
else if (tag == "dtk5")
{
@ -371,6 +381,44 @@ void AppIntoPage::setAppinfoTags(const QStringList &tagList)
ui->tag_a2d->show();
}
}
notifyUserUnsupportedTags(ubuntuSupport, deepinSupport, uosSupport);
}
void AppIntoPage::notifyUserUnsupportedTags(bool ubuntuSupport, bool deepinSupport, bool uosSupport)
{
bool checkdeepin = (Dtk::Core::DSysInfo::productType() == Dtk::Core::DSysInfo::Deepin && !deepinSupport);
bool checkuos = (Dtk::Core::DSysInfo::productType() == Dtk::Core::DSysInfo::Uos && !uosSupport);
bool isUbuntu = false;
if (!checkdeepin && !checkuos)
{
// 检查是否为 ubuntu 系统
QFile lsb("/etc/lsb-release");
if (lsb.open(QIODevice::ReadOnly) && lsb.readAll().contains("Ubuntu"))
{
isUbuntu = true;
lsb.close();
}
}
bool checkubuntu = (isUbuntu && !ubuntuSupport);
if (checkdeepin)
{
Utils::sendNotification("spark-store", tr("Warning"), tr("The current application does not support deepin, there may be problems"));
}
else if (checkuos)
{
Utils::sendNotification("spark-store", tr("Warning"), tr("The current application does not support UOS, there may be problems"));
}
else if (checkubuntu)
{
Utils::sendNotification("spark-store", tr("Warning"), tr("The current application does not support Ubuntu, there may be problems"));
}
else if (!isUbuntu)
{
Utils::sendNotification("spark-store", tr("Warning"), tr("The current application does not support current platform, there may be problems"));
}
return;
}
void AppIntoPage::on_downloadButton_clicked()

@ -29,6 +29,7 @@ private:
void initConnections();
void isDownloading(const QUrl &url);
void setAppinfoTags(const QStringList &tagList);
void notifyUserUnsupportedTags(bool ubuntuSupport, bool deepinSupport, bool uosSupport);
signals:
void clickedDownloadBtn();