mirror of
https://gitee.com/spark-store-project/spark-store
synced 2025-12-14 04:42:03 +08:00
fix: ISSUE #I6B4CS 重复安装应用的bug
应用安装过程中,重新进入应用详情页,仅通过 `dpkg-query -s $pkgName` 判断本地是否已安装,未判断当前安装任务执行状态 Log: 判断本地安装状态后,执行 isDownloading 函数判断安装任务状态,更新按钮显示状态;整理应用详情页代码
This commit is contained in:
@@ -11,6 +11,7 @@
|
|||||||
#include <DGuiApplicationHelper>
|
#include <DGuiApplicationHelper>
|
||||||
|
|
||||||
#include <QAbstractButton>
|
#include <QAbstractButton>
|
||||||
|
#include <QtConcurrent>
|
||||||
|
|
||||||
#define AppPageApplist 0
|
#define AppPageApplist 0
|
||||||
#define AppPageSearchlist 1
|
#define AppPageSearchlist 1
|
||||||
|
|||||||
@@ -1,82 +1,40 @@
|
|||||||
#include "appintopage.h"
|
#include "appintopage.h"
|
||||||
#include "ui_appintopage.h"
|
#include "ui_appintopage.h"
|
||||||
AppIntoPage::AppIntoPage(QWidget *parent) : QWidget(parent),
|
#include "backend/sparkapi.h"
|
||||||
ui(new Ui::AppIntoPage)
|
#include "widgets/downloadlistwidget.h"
|
||||||
|
#include "backend/image_show.h"
|
||||||
|
#include "application.h"
|
||||||
|
|
||||||
|
#include <QtConcurrent>
|
||||||
|
#include <QClipboard>
|
||||||
|
|
||||||
|
AppIntoPage::AppIntoPage(QWidget *parent)
|
||||||
|
: QWidget(parent)
|
||||||
|
, ui(new Ui::AppIntoPage)
|
||||||
|
, api(new SparkAPI(this))
|
||||||
{
|
{
|
||||||
ui->setupUi(this);
|
initUI();
|
||||||
ui->listWidget->setViewMode(QListView::IconMode);
|
initConnections();
|
||||||
ui->listWidget->setMovement(QListView::Static);
|
|
||||||
ui->listWidget->setMaximumHeight(200);
|
|
||||||
ui->listWidget->setFlow(QListView::TopToBottom);
|
|
||||||
api1 = new SparkAPI(this);
|
|
||||||
connect(api1, &SparkAPI::finishedRAW, [=](QString download_times)
|
|
||||||
{
|
|
||||||
download_times.remove(QRegExp("\\n"));
|
|
||||||
ui->download_times->setText(download_times);
|
|
||||||
qDebug()<<"Download Times:"+download_times; });
|
|
||||||
clear();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void AppIntoPage::clear()
|
AppIntoPage::~AppIntoPage()
|
||||||
{
|
{
|
||||||
ui->tag_a2d->hide();
|
delete ui;
|
||||||
ui->tag_uos->hide();
|
|
||||||
ui->tag_dtk5->hide();
|
|
||||||
ui->tag_deepin->hide();
|
|
||||||
ui->tag_dwine2->hide();
|
|
||||||
ui->tag_dwine5->hide();
|
|
||||||
ui->tag_ubuntu->hide();
|
|
||||||
ui->tag_community->hide();
|
|
||||||
ui->icon->clear();
|
|
||||||
ui->title->clear();
|
|
||||||
ui->author->clear();
|
|
||||||
ui->label_2->clear();
|
|
||||||
ui->downloadButton->hide();
|
|
||||||
ui->downloadButton->setEnabled(false);
|
|
||||||
ui->pushButton_3->hide();
|
|
||||||
int n = ui->listWidget->count();
|
|
||||||
for (int i = 0; i < n; i++)
|
|
||||||
{
|
|
||||||
QListWidgetItem *item = ui->listWidget->takeItem(0);
|
|
||||||
QWidget *card = ui->listWidget->itemWidget(item);
|
|
||||||
delete card;
|
|
||||||
card = NULL;
|
|
||||||
delete item;
|
|
||||||
item = NULL;
|
|
||||||
}
|
|
||||||
ui->listWidget->clear();
|
|
||||||
}
|
}
|
||||||
void AppIntoPage::setDownloadWidget(DownloadListWidget *w)
|
|
||||||
{
|
void AppIntoPage::openUrl(const QUrl &url)
|
||||||
dw = w;
|
|
||||||
connect(w, &DownloadListWidget::downloadFinished, [=]()
|
|
||||||
{ isDownloading(SparkAPI::getServerUrl() + "store" + spk.path() + "/" + info["Filename"].toString()); });
|
|
||||||
}
|
|
||||||
void AppIntoPage::openUrl(QUrl url)
|
|
||||||
{
|
{
|
||||||
|
clear();
|
||||||
|
|
||||||
|
// qDebug() << url;
|
||||||
spk = url;
|
spk = url;
|
||||||
SparkAPI *api = new SparkAPI(this);
|
|
||||||
clear();
|
|
||||||
connect(api, &SparkAPI::finishedObject, [=](QJsonObject appinfo)
|
|
||||||
{
|
|
||||||
|
|
||||||
|
SparkAPI *api1 = new SparkAPI(this);
|
||||||
|
connect(api1, &SparkAPI::finishedObject, [=](const QJsonObject &appinfo)
|
||||||
|
{
|
||||||
info = appinfo;
|
info = appinfo;
|
||||||
// qDebug()<<url;
|
|
||||||
//获取图标
|
// 显示基本信息
|
||||||
QNetworkRequest request;
|
|
||||||
QNetworkAccessManager *naManager = new QNetworkAccessManager(this);
|
|
||||||
qDebug()<<api->getImgServerUrl()+"store"+url.path().replace("+","%2B") + "/icon.png";
|
|
||||||
request.setUrl(QUrl(api->getImgServerUrl()+"store"+url.path().replace("+","%2B") + "/icon.png"));
|
|
||||||
request.setRawHeader("User-Agent", "Mozilla/5.0");
|
|
||||||
request.setRawHeader("Content-Type", "charset='utf-8'");
|
|
||||||
naManager->get(request);
|
|
||||||
QObject::connect(naManager,&QNetworkAccessManager::finished,[=](QNetworkReply *reply){
|
|
||||||
QByteArray jpegData = reply->readAll();
|
|
||||||
iconpixmap.loadFromData(jpegData);
|
|
||||||
iconpixmap.scaled(210, 200, Qt::IgnoreAspectRatio, Qt::SmoothTransformation);
|
|
||||||
ui->icon->setPixmap(iconpixmap);
|
|
||||||
ui->icon->setScaledContents(true);
|
|
||||||
});
|
|
||||||
ui->title->setText(info["Name"].toString());
|
ui->title->setText(info["Name"].toString());
|
||||||
ui->version->setText(info["Version"].toString());
|
ui->version->setText(info["Version"].toString());
|
||||||
ui->author->setText(info["Author"].toString());
|
ui->author->setText(info["Author"].toString());
|
||||||
@@ -84,10 +42,66 @@ void AppIntoPage::openUrl(QUrl url)
|
|||||||
ui->d_size->setText(info["Size"].toString());
|
ui->d_size->setText(info["Size"].toString());
|
||||||
ui->d_update->setText(info["Update"].toString());
|
ui->d_update->setText(info["Update"].toString());
|
||||||
ui->d_pkgname->setText(info["Pkgname"].toString());
|
ui->d_pkgname->setText(info["Pkgname"].toString());
|
||||||
ui->d_website->setText("<a href=\""+info["Website"].toString()+"\">"+tr("Click Open"));
|
ui->d_website->setText("<a href=\"" + info["Website"].toString() + "\">" + tr("Click Open"));
|
||||||
ui->d_contributor->setText(info["Contributor"].toString());
|
ui->d_contributor->setText(info["Contributor"].toString());
|
||||||
ui->label_2->setText(info["More"].toString());
|
ui->label_2->setText(info["More"].toString());
|
||||||
|
|
||||||
|
// 显示 tags
|
||||||
|
QStringList taglist = info["Tags"].toString().split(";", QString::SkipEmptyParts);
|
||||||
|
setAppinfoTags(taglist);
|
||||||
|
|
||||||
|
// 获取图标
|
||||||
|
QNetworkRequest request;
|
||||||
|
QNetworkAccessManager *manager = new QNetworkAccessManager(this);
|
||||||
|
qDebug() << api->getImgServerUrl() + "store" + url.path() + "/icon.png";
|
||||||
|
request.setUrl(QUrl(api->getImgServerUrl() + "store" + url.path() + "/icon.png"));
|
||||||
|
request.setRawHeader("User-Agent", "Mozilla/5.0");
|
||||||
|
request.setRawHeader("Content-Type", "charset='utf-8'");
|
||||||
|
manager->get(request);
|
||||||
|
QObject::connect(manager, &QNetworkAccessManager::finished, [=](QNetworkReply *reply)
|
||||||
|
{
|
||||||
|
QByteArray jpegData = reply->readAll();
|
||||||
|
iconpixmap.loadFromData(jpegData);
|
||||||
|
iconpixmap.scaled(210, 200, Qt::IgnoreAspectRatio, Qt::SmoothTransformation);
|
||||||
|
ui->icon->setPixmap(iconpixmap);
|
||||||
|
ui->icon->setScaledContents(true);
|
||||||
|
|
||||||
|
manager->deleteLater(); });
|
||||||
|
|
||||||
|
// 获取截图
|
||||||
|
QJsonParseError error;
|
||||||
|
QJsonArray array = QJsonDocument::fromJson(info.value("img_urls").toString().toUtf8(), &error).array();
|
||||||
|
QStringList imglist;
|
||||||
|
foreach (const QJsonValue &value, array) {
|
||||||
|
QString imgUrl = value.toString();
|
||||||
|
imglist.append(imgUrl);
|
||||||
|
}
|
||||||
|
qDebug() << imglist;
|
||||||
|
|
||||||
|
for (int i = 0; i < imglist.size(); i++)
|
||||||
|
{
|
||||||
|
QNetworkRequest request;
|
||||||
|
QNetworkAccessManager *manager = new QNetworkAccessManager(this);
|
||||||
|
request.setUrl(QUrl(imglist.value(i)));
|
||||||
|
request.setRawHeader("User-Agent", "Mozilla/5.0");
|
||||||
|
request.setRawHeader("Content-Type", "charset='utf-8'");
|
||||||
|
manager->get(request);
|
||||||
|
QObject::connect(manager, &QNetworkAccessManager::finished, [=](QNetworkReply *reply)
|
||||||
|
{
|
||||||
|
QByteArray jpegData = reply->readAll();
|
||||||
|
QPixmap pixmap;
|
||||||
|
pixmap.loadFromData(jpegData);
|
||||||
|
pixmap.scaled(100, 100, Qt::IgnoreAspectRatio, Qt::SmoothTransformation);
|
||||||
|
image_show *img=new image_show(this);
|
||||||
|
img->setImage(pixmap);
|
||||||
|
//img->setScaledContents(true);
|
||||||
|
QListWidgetItem* pItem = new QListWidgetItem();
|
||||||
|
pItem->setSizeHint(QSize(280, 200));
|
||||||
|
ui->listWidget->addItem(pItem);
|
||||||
|
ui->listWidget->setItemWidget(pItem, img);
|
||||||
|
|
||||||
|
manager->deleteLater(); });
|
||||||
|
}
|
||||||
|
|
||||||
// Check UOS
|
// Check UOS
|
||||||
QSettings config(QStandardPaths::writableLocation(QStandardPaths::AppConfigLocation) + "/config.ini", QSettings::IniFormat);
|
QSettings config(QStandardPaths::writableLocation(QStandardPaths::AppConfigLocation) + "/config.ini", QSettings::IniFormat);
|
||||||
@@ -135,79 +149,147 @@ void AppIntoPage::openUrl(QUrl url)
|
|||||||
isUpdated = false;
|
isUpdated = false;
|
||||||
}
|
}
|
||||||
|
|
||||||
QObject::connect(naManager, &QNetworkAccessManager::finished, [=]()
|
if (isInstalled)
|
||||||
{
|
{
|
||||||
|
if (isUpdated)
|
||||||
if (isInstalled)
|
|
||||||
{
|
{
|
||||||
if (isUpdated)
|
ui->downloadButton->setText(tr("Reinstall"));
|
||||||
{
|
ui->downloadButton->setEnabled(true);
|
||||||
ui->downloadButton->setText(tr("Reinstall"));
|
ui->downloadButton->show();
|
||||||
ui->downloadButton->setEnabled(true);
|
ui->pushButton_3->show();
|
||||||
ui->downloadButton->show();
|
|
||||||
ui->pushButton_3->show();
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
ui->downloadButton->setText(tr("Upgrade"));
|
|
||||||
ui->downloadButton->setEnabled(true);
|
|
||||||
ui->downloadButton->show();
|
|
||||||
ui->pushButton_3->show();
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
ui->downloadButton->setText(tr("Download"));
|
ui->downloadButton->setText(tr("Upgrade"));
|
||||||
ui->downloadButton->setEnabled(true);
|
ui->downloadButton->setEnabled(true);
|
||||||
isDownloading(SparkAPI::getServerUrl() + "store" + spk.path() + "/" + info["Filename"].toString());
|
|
||||||
ui->downloadButton->show();
|
ui->downloadButton->show();
|
||||||
} });
|
ui->pushButton_3->show();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
ui->downloadButton->setText(tr("Download"));
|
||||||
|
ui->downloadButton->setEnabled(true);
|
||||||
|
ui->downloadButton->show();
|
||||||
|
}
|
||||||
|
|
||||||
|
isDownloading(SparkAPI::getServerUrl() + "store" + spk.path() + "/" + info["Filename"].toString());
|
||||||
}
|
}
|
||||||
|
|
||||||
QStringList taglist = info["Tags"].toString().split(";");
|
api1->disconnect();
|
||||||
QString tmp=info["img_urls"].toString();
|
api1->deleteLater(); });
|
||||||
qDebug() << tmp;
|
|
||||||
if (tmp.left(2) == "[\"")
|
api1->getAppInfo(url);
|
||||||
{
|
|
||||||
tmp.remove(0, 2);
|
api->getAppDownloadTimes(url);
|
||||||
}
|
|
||||||
if (tmp.right(2) == "\"]")
|
|
||||||
{
|
|
||||||
tmp.remove(tmp.size() - 2, tmp.size());
|
|
||||||
}
|
|
||||||
QStringList imglist = tmp.split("\",\"");
|
|
||||||
qDebug() << imglist;
|
|
||||||
for (int i = 0; i < imglist.size(); i++)
|
|
||||||
{
|
|
||||||
QNetworkRequest request;
|
|
||||||
QNetworkAccessManager *iconNaManager = new QNetworkAccessManager(this);
|
|
||||||
request.setUrl(QUrl(imglist[i].replace("+", "%2B")));
|
|
||||||
request.setRawHeader("User-Agent", "Mozilla/5.0");
|
|
||||||
request.setRawHeader("Content-Type", "charset='utf-8'");
|
|
||||||
iconNaManager->get(request);
|
|
||||||
QObject::connect(iconNaManager, &QNetworkAccessManager::finished, [=](QNetworkReply *reply)
|
|
||||||
{
|
|
||||||
QByteArray jpegData = reply->readAll();
|
|
||||||
QPixmap pixmap;
|
|
||||||
pixmap.loadFromData(jpegData);
|
|
||||||
pixmap.scaled(100, 100, Qt::IgnoreAspectRatio, Qt::SmoothTransformation);
|
|
||||||
image_show *img=new image_show(this);
|
|
||||||
img->setImage(pixmap);
|
|
||||||
//img->setScaledContents(true);
|
|
||||||
QListWidgetItem* pItem = new QListWidgetItem();
|
|
||||||
pItem->setSizeHint(QSize(280, 200));
|
|
||||||
ui->listWidget->addItem(pItem);
|
|
||||||
ui->listWidget->setItemWidget(pItem, img);
|
|
||||||
});
|
|
||||||
}
|
|
||||||
this->sltAppinfoTags(&taglist);
|
|
||||||
disconnect(api,&SparkAPI::finished,nullptr,nullptr);
|
|
||||||
api->deleteLater(); });
|
|
||||||
api->getAppInfo(url);
|
|
||||||
api1->getAppDownloadTimes(url);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void AppIntoPage::isDownloading(QUrl url)
|
void AppIntoPage::clear()
|
||||||
|
{
|
||||||
|
ui->tag_a2d->hide();
|
||||||
|
ui->tag_uos->hide();
|
||||||
|
ui->tag_dtk5->hide();
|
||||||
|
ui->tag_deepin->hide();
|
||||||
|
ui->tag_dwine2->hide();
|
||||||
|
ui->tag_dwine5->hide();
|
||||||
|
ui->tag_ubuntu->hide();
|
||||||
|
ui->tag_community->hide();
|
||||||
|
ui->icon->clear();
|
||||||
|
ui->title->clear();
|
||||||
|
ui->author->clear();
|
||||||
|
ui->label_2->clear();
|
||||||
|
ui->downloadButton->hide();
|
||||||
|
ui->downloadButton->setEnabled(false);
|
||||||
|
ui->pushButton_3->hide();
|
||||||
|
|
||||||
|
// QListWidgetItem *item = nullptr;
|
||||||
|
// while ((item = ui->listWidget->takeItem(0)) != nullptr)
|
||||||
|
// {
|
||||||
|
// QWidget *card = ui->listWidget->itemWidget(item);
|
||||||
|
// if (card)
|
||||||
|
// {
|
||||||
|
// card->deleteLater();
|
||||||
|
// card = nullptr;
|
||||||
|
// }
|
||||||
|
// delete item;
|
||||||
|
// item = nullptr;
|
||||||
|
// }
|
||||||
|
|
||||||
|
ui->listWidget->clear(); // NOTE: QListWidget::clear() 会析构所有 items
|
||||||
|
}
|
||||||
|
|
||||||
|
void AppIntoPage::setTheme(bool dark)
|
||||||
|
{
|
||||||
|
if (dark)
|
||||||
|
{
|
||||||
|
QString frameStyleSheet ="#frame,#frame_2,#frame_3,#frame_4 {background-color: #252525; border-radius: 14px; border: 1px solid rgb(64, 64, 64);}\
|
||||||
|
QLabel#cardtitle,QLabel#title,QLabel#title_1,QLabel#title_2,QLabel#title_3 {color: #FFFFFF}";
|
||||||
|
ui->frame->setStyleSheet(frameStyleSheet);
|
||||||
|
ui->frame_2->setStyleSheet(frameStyleSheet);
|
||||||
|
ui->frame_3->setStyleSheet(frameStyleSheet);
|
||||||
|
ui->frame_4->setStyleSheet(frameStyleSheet);
|
||||||
|
|
||||||
|
ui->icon_1->setPixmap(QPixmap(":/icon/dark/box.svg"));
|
||||||
|
ui->icon_2->setPixmap(QPixmap(":/icon/dark/box.svg"));
|
||||||
|
ui->icon_3->setPixmap(QPixmap(":/icon/dark/calendar.svg"));
|
||||||
|
ui->icon_4->setPixmap(QPixmap(":/icon/dark/text.svg"));
|
||||||
|
ui->icon_5->setPixmap(QPixmap(":/icon/dark/folder.svg"));
|
||||||
|
ui->icon_6->setPixmap(QPixmap(":/icon/dark/globe.svg"));
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
//亮色模式
|
||||||
|
QString frameStyleSheet ="#frame,#frame_2,#frame_3,#frame_4 {background-color: #fbfbfb; border-radius: 14px; border: 1px solid rgb(229,229,229);}\
|
||||||
|
QLabel#cardtitle,QLabel#title,QLabel#title_1,QLabel#title_2,QLabel#title_3 {color: #000000}";
|
||||||
|
ui->frame->setStyleSheet(frameStyleSheet);
|
||||||
|
ui->frame_2->setStyleSheet(frameStyleSheet);
|
||||||
|
ui->frame_3->setStyleSheet(frameStyleSheet);
|
||||||
|
ui->frame_4->setStyleSheet(frameStyleSheet);
|
||||||
|
|
||||||
|
ui->icon_1->setPixmap(QPixmap(":/icon/light/box.svg"));
|
||||||
|
ui->icon_2->setPixmap(QPixmap(":/icon/light/box.svg"));
|
||||||
|
ui->icon_3->setPixmap(QPixmap(":/icon/light/calendar.svg"));
|
||||||
|
ui->icon_4->setPixmap(QPixmap(":/icon/light/text.svg"));
|
||||||
|
ui->icon_5->setPixmap(QPixmap(":/icon/light/folder.svg"));
|
||||||
|
ui->icon_6->setPixmap(QPixmap(":/icon/light/globe.svg"));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
void AppIntoPage::setDownloadWidget(DownloadListWidget *w)
|
||||||
|
{
|
||||||
|
if (dw)
|
||||||
|
{
|
||||||
|
dw->deleteLater();
|
||||||
|
dw = nullptr;
|
||||||
|
}
|
||||||
|
|
||||||
|
dw = w;
|
||||||
|
connect(w, &DownloadListWidget::downloadFinished, [=]()
|
||||||
|
{ isDownloading(SparkAPI::getServerUrl() + "store" + spk.path() + "/" + info["Filename"].toString()); });
|
||||||
|
}
|
||||||
|
|
||||||
|
void AppIntoPage::initUI()
|
||||||
|
{
|
||||||
|
ui->setupUi(this);
|
||||||
|
|
||||||
|
ui->listWidget->setViewMode(QListView::IconMode);
|
||||||
|
ui->listWidget->setFlow(QListView::TopToBottom);
|
||||||
|
ui->listWidget->setMovement(QListView::Static);
|
||||||
|
ui->listWidget->setMaximumHeight(200);
|
||||||
|
|
||||||
|
clear();
|
||||||
|
}
|
||||||
|
|
||||||
|
void AppIntoPage::initConnections()
|
||||||
|
{
|
||||||
|
connect(api, &SparkAPI::finishedRAW, [=](QString download_times)
|
||||||
|
{
|
||||||
|
download_times = download_times.trimmed();
|
||||||
|
qDebug() << "Download Times:" + download_times;
|
||||||
|
ui->download_times->setText(download_times); });
|
||||||
|
}
|
||||||
|
|
||||||
|
void AppIntoPage::isDownloading(const QUrl &url)
|
||||||
{
|
{
|
||||||
if (dw->getUrlList().lastIndexOf(url) == -1)
|
if (dw->getUrlList().lastIndexOf(url) == -1)
|
||||||
{
|
{
|
||||||
@@ -245,9 +327,9 @@ void AppIntoPage::isDownloading(QUrl url)
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void AppIntoPage::sltAppinfoTags(QStringList *tagList)
|
void AppIntoPage::setAppinfoTags(const QStringList &tagList)
|
||||||
{
|
{
|
||||||
foreach (const QString &tag, *tagList)
|
foreach (const QString &tag, tagList)
|
||||||
{
|
{
|
||||||
if (tag == "community")
|
if (tag == "community")
|
||||||
{
|
{
|
||||||
@@ -283,44 +365,6 @@ void AppIntoPage::sltAppinfoTags(QStringList *tagList)
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
void AppIntoPage::setTheme(bool dark)
|
|
||||||
{
|
|
||||||
if (dark)
|
|
||||||
{
|
|
||||||
QString frameStyleSheet ="#frame,#frame_2,#frame_3,#frame_4 {background-color: #252525; border-radius: 14px; border: 1px solid rgb(64, 64, 64);}\
|
|
||||||
QLabel#cardtitle,QLabel#title,QLabel#title_1,QLabel#title_2,QLabel#title_3 {color: #FFFFFF}";
|
|
||||||
ui->frame->setStyleSheet(frameStyleSheet);
|
|
||||||
ui->frame_2->setStyleSheet(frameStyleSheet);
|
|
||||||
ui->frame_3->setStyleSheet(frameStyleSheet);
|
|
||||||
ui->frame_4->setStyleSheet(frameStyleSheet);
|
|
||||||
|
|
||||||
ui->icon_1->setPixmap(QPixmap(":/icon/dark/box.svg"));
|
|
||||||
ui->icon_2->setPixmap(QPixmap(":/icon/dark/box.svg"));
|
|
||||||
ui->icon_3->setPixmap(QPixmap(":/icon/dark/calendar.svg"));
|
|
||||||
ui->icon_4->setPixmap(QPixmap(":/icon/dark/text.svg"));
|
|
||||||
ui->icon_5->setPixmap(QPixmap(":/icon/dark/folder.svg"));
|
|
||||||
ui->icon_6->setPixmap(QPixmap(":/icon/dark/globe.svg"));
|
|
||||||
}else {
|
|
||||||
//亮色模式
|
|
||||||
QString frameStyleSheet ="#frame,#frame_2,#frame_3,#frame_4 {background-color: #fbfbfb; border-radius: 14px; border: 1px solid rgb(229,229,229);}\
|
|
||||||
QLabel#cardtitle,QLabel#title,QLabel#title_1,QLabel#title_2,QLabel#title_3 {color: #000000}";
|
|
||||||
ui->frame->setStyleSheet(frameStyleSheet);
|
|
||||||
ui->frame_2->setStyleSheet(frameStyleSheet);
|
|
||||||
ui->frame_3->setStyleSheet(frameStyleSheet);
|
|
||||||
ui->frame_4->setStyleSheet(frameStyleSheet);
|
|
||||||
|
|
||||||
ui->icon_1->setPixmap(QPixmap(":/icon/light/box.svg"));
|
|
||||||
ui->icon_2->setPixmap(QPixmap(":/icon/light/box.svg"));
|
|
||||||
ui->icon_3->setPixmap(QPixmap(":/icon/light/calendar.svg"));
|
|
||||||
ui->icon_4->setPixmap(QPixmap(":/icon/light/text.svg"));
|
|
||||||
ui->icon_5->setPixmap(QPixmap(":/icon/light/folder.svg"));
|
|
||||||
ui->icon_6->setPixmap(QPixmap(":/icon/light/globe.svg"));
|
|
||||||
}
|
|
||||||
}
|
|
||||||
AppIntoPage::~AppIntoPage()
|
|
||||||
{
|
|
||||||
delete ui;
|
|
||||||
}
|
|
||||||
|
|
||||||
void AppIntoPage::on_downloadButton_clicked()
|
void AppIntoPage::on_downloadButton_clicked()
|
||||||
{
|
{
|
||||||
@@ -328,23 +372,27 @@ void AppIntoPage::on_downloadButton_clicked()
|
|||||||
{
|
{
|
||||||
dw->getDIList()[dw->getUrlList().lastIndexOf(SparkAPI::getServerUrl() + "store" + spk.path() + "/" + info["Filename"].toString())]->install(0);
|
dw->getDIList()[dw->getUrlList().lastIndexOf(SparkAPI::getServerUrl() + "store" + spk.path() + "/" + info["Filename"].toString())]->install(0);
|
||||||
isDownloading(SparkAPI::getServerUrl() + "store" + spk.path() + "/" + info["Filename"].toString());
|
isDownloading(SparkAPI::getServerUrl() + "store" + spk.path() + "/" + info["Filename"].toString());
|
||||||
QObject::connect(dw->getDIList()[dw->getUrlList().lastIndexOf(SparkAPI::getServerUrl() + "store" + spk.path() + "/" + info["Filename"].toString())], &DownloadItem::finished, [=]()
|
connect(dw->getDIList()[dw->getUrlList().lastIndexOf(SparkAPI::getServerUrl() + "store" + spk.path() + "/" + info["Filename"].toString())], &DownloadItem::finished, [=]()
|
||||||
{
|
{
|
||||||
isDownloading(SparkAPI::getServerUrl()+"store"+spk.path()+"/"+info["Filename"].toString());
|
isDownloading(SparkAPI::getServerUrl() + "store" + spk.path() + "/" + info["Filename"].toString());
|
||||||
disconnect(dw->getDIList()[dw->getUrlList().lastIndexOf(SparkAPI::getServerUrl()+"store"+spk.path()+"/"+info["Filename"].toString())],&DownloadItem::finished,nullptr,nullptr); });
|
disconnect(dw->getDIList()[dw->getUrlList().lastIndexOf(SparkAPI::getServerUrl() + "store" + spk.path() + "/" + info["Filename"].toString())], &DownloadItem::finished, nullptr, nullptr); });
|
||||||
|
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
emit clickedDownloadBtn();
|
emit clickedDownloadBtn();
|
||||||
|
|
||||||
dw->addItem(info["Name"].toString(), info["Filename"].toString(), info["Pkgname"].toString(), iconpixmap, SparkAPI::getServerUrl() + "store" + spk.path() + "/" + info["Filename"].toString());
|
dw->addItem(info["Name"].toString(), info["Filename"].toString(), info["Pkgname"].toString(), iconpixmap, SparkAPI::getServerUrl() + "store" + spk.path() + "/" + info["Filename"].toString());
|
||||||
if (ui->downloadButton->text() == tr("Reinstall"))
|
if (ui->downloadButton->text() == tr("Reinstall"))
|
||||||
{
|
{
|
||||||
dw->getDIList()[dw->allDownload - 1]->reinstall = true;
|
dw->getDIList()[dw->allDownload - 1]->reinstall = true;
|
||||||
}
|
}
|
||||||
ui->downloadButton->setEnabled(false);
|
ui->downloadButton->setEnabled(false);
|
||||||
QObject::connect(dw->getDIList()[dw->getUrlList().lastIndexOf(SparkAPI::getServerUrl() + "store" + spk.path() + "/" + info["Filename"].toString())], &DownloadItem::finished, [=]()
|
connect(dw->getDIList()[dw->getUrlList().lastIndexOf(SparkAPI::getServerUrl() + "store" + spk.path() + "/" + info["Filename"].toString())], &DownloadItem::finished, [=]()
|
||||||
{
|
{
|
||||||
isDownloading(SparkAPI::getServerUrl()+"store"+spk.path()+"/"+info["Filename"].toString());
|
isDownloading(SparkAPI::getServerUrl() + "store" + spk.path() + "/" + info["Filename"].toString());
|
||||||
disconnect(dw->getDIList()[dw->getUrlList().lastIndexOf(SparkAPI::getServerUrl()+"store"+spk.path()+"/"+info["Filename"].toString())],&DownloadItem::finished,nullptr,nullptr); });
|
disconnect(dw->getDIList()[dw->getUrlList().lastIndexOf(SparkAPI::getServerUrl() + "store" + spk.path() + "/" + info["Filename"].toString())], &DownloadItem::finished, nullptr, nullptr); });
|
||||||
|
|
||||||
isDownloading(SparkAPI::getServerUrl() + "store" + spk.path() + "/" + info["Filename"].toString());
|
isDownloading(SparkAPI::getServerUrl() + "store" + spk.path() + "/" + info["Filename"].toString());
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -380,9 +428,9 @@ void AppIntoPage::on_pushButton_3_clicked()
|
|||||||
void AppIntoPage::on_shareButton_clicked()
|
void AppIntoPage::on_shareButton_clicked()
|
||||||
{
|
{
|
||||||
qDebug() << "Share" << spk;
|
qDebug() << "Share" << spk;
|
||||||
|
Application::clipboard()->setText(spk.toString());
|
||||||
|
|
||||||
Utils::sendNotification("spark-store", tr("Spark Store"), tr("The URL has been copied to the clipboard"));
|
Utils::sendNotification("spark-store", tr("Spark Store"), tr("The URL has been copied to the clipboard"));
|
||||||
QClipboard *clipboard = QApplication::clipboard();
|
|
||||||
clipboard->setText(spk.toString());
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void AppIntoPage::on_updateButton_clicked()
|
void AppIntoPage::on_updateButton_clicked()
|
||||||
|
|||||||
@@ -1,52 +1,55 @@
|
|||||||
#ifndef APPINTOPAGE_H
|
#ifndef APPINTOPAGE_H
|
||||||
#define APPINTOPAGE_H
|
#define APPINTOPAGE_H
|
||||||
|
|
||||||
#include <QWidget>
|
|
||||||
#include <QUrl>
|
|
||||||
#include <QString>
|
|
||||||
#include <QtConcurrent>
|
|
||||||
#include <QClipboard>
|
|
||||||
#include "backend/sparkapi.h"
|
|
||||||
#include "backend/image_show.h"
|
|
||||||
#include "widgets/downloadlistwidget.h"
|
|
||||||
#include "utils/utils.h"
|
#include "utils/utils.h"
|
||||||
|
|
||||||
|
#include <QWidget>
|
||||||
|
#include <QJsonObject>
|
||||||
|
#include <QUrl>
|
||||||
|
|
||||||
namespace Ui {
|
namespace Ui {
|
||||||
class AppIntoPage;
|
class AppIntoPage;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
class SparkAPI;
|
||||||
|
class DownloadListWidget;
|
||||||
class AppIntoPage : public QWidget
|
class AppIntoPage : public QWidget
|
||||||
{
|
{
|
||||||
Q_OBJECT
|
Q_OBJECT
|
||||||
|
|
||||||
public:
|
public:
|
||||||
void clear();
|
|
||||||
void setDownloadWidget(DownloadListWidget *w);
|
|
||||||
void setTheme(bool dark);
|
|
||||||
void openUrl(QUrl url);
|
|
||||||
explicit AppIntoPage(QWidget *parent = nullptr);
|
explicit AppIntoPage(QWidget *parent = nullptr);
|
||||||
~AppIntoPage();
|
~AppIntoPage() override;
|
||||||
|
|
||||||
private slots:
|
void openUrl(const QUrl &url);
|
||||||
void on_downloadButton_clicked();
|
void clear();
|
||||||
|
void setTheme(bool dark);
|
||||||
void on_pushButton_3_clicked();
|
void setDownloadWidget(DownloadListWidget *w);
|
||||||
|
|
||||||
void on_shareButton_clicked();
|
|
||||||
|
|
||||||
void on_updateButton_clicked();
|
|
||||||
|
|
||||||
private:
|
private:
|
||||||
SparkAPI *api1;
|
void initUI();
|
||||||
QJsonObject info;
|
void initConnections();
|
||||||
QPixmap iconpixmap;
|
void isDownloading(const QUrl &url);
|
||||||
QUrl spk;
|
void setAppinfoTags(const QStringList &tagList);
|
||||||
void isDownloading(QUrl url);
|
|
||||||
void sltAppinfoTags(QStringList *tagList);
|
|
||||||
DownloadListWidget *dw;
|
|
||||||
Ui::AppIntoPage *ui;
|
|
||||||
|
|
||||||
signals:
|
signals:
|
||||||
void clickedDownloadBtn();
|
void clickedDownloadBtn();
|
||||||
|
|
||||||
|
private slots:
|
||||||
|
void on_downloadButton_clicked();
|
||||||
|
void on_pushButton_3_clicked();
|
||||||
|
void on_shareButton_clicked();
|
||||||
|
void on_updateButton_clicked();
|
||||||
|
|
||||||
|
private:
|
||||||
|
Ui::AppIntoPage *ui;
|
||||||
|
|
||||||
|
SparkAPI *api;
|
||||||
|
DownloadListWidget *dw = nullptr;
|
||||||
|
|
||||||
|
QJsonObject info;
|
||||||
|
QPixmap iconpixmap;
|
||||||
|
QUrl spk;
|
||||||
};
|
};
|
||||||
|
|
||||||
#endif // APPINTOPAGE_H
|
#endif // APPINTOPAGE_H
|
||||||
|
|||||||
@@ -1,25 +1,24 @@
|
|||||||
#include "utils.h"
|
#include "utils.h"
|
||||||
|
#include "application.h"
|
||||||
|
|
||||||
Utils::Utils()
|
#include <QDBusInterface>
|
||||||
{
|
|
||||||
}
|
|
||||||
|
|
||||||
// Author: chatGPT
|
// Author: chatGPT
|
||||||
void Utils::sendNotification(QString icon, QString title, QString body)
|
void Utils::sendNotification(const QString &icon, const QString &title, const QString &body)
|
||||||
{
|
{
|
||||||
QDBusInterface iface("org.freedesktop.Notifications",
|
QDBusInterface interface("org.freedesktop.Notifications",
|
||||||
"/org/freedesktop/Notifications",
|
"/org/freedesktop/Notifications",
|
||||||
"org.freedesktop.Notifications");
|
"org.freedesktop.Notifications");
|
||||||
|
|
||||||
QVariantList args;
|
QVariantList args;
|
||||||
args << QCoreApplication::applicationName() // the name of the application
|
args << Application::applicationName() // the name of the application
|
||||||
<< (uint)0 // replaces the previous notification with the same ID
|
<< static_cast<quint32>(0) // replaces the previous notification with the same ID
|
||||||
<< icon // the application icon of the notification
|
<< icon // the application icon of the notification
|
||||||
<< title // the title of the notification
|
<< title // the title of the notification
|
||||||
<< body // the body of the notification
|
<< body // the body of the notification
|
||||||
<< QStringList() // no actions
|
<< QStringList() // no actions
|
||||||
<< QVariantMap() // no hints
|
<< QVariantMap() // no hints
|
||||||
<< -1; // no timeout
|
<< -1; // no timeout
|
||||||
|
|
||||||
iface.callWithArgumentList(QDBus::AutoDetect, "Notify", args);
|
interface.callWithArgumentList(QDBus::AutoDetect, "Notify", args);
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -2,13 +2,11 @@
|
|||||||
#define UTILS_H
|
#define UTILS_H
|
||||||
|
|
||||||
#include <QObject>
|
#include <QObject>
|
||||||
#include <QtDBus>
|
|
||||||
|
|
||||||
class Utils
|
class Utils
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
Utils();
|
static void sendNotification(const QString &icon, const QString &title, const QString &body);
|
||||||
static void sendNotification(QString icon,QString title,QString body);
|
|
||||||
};
|
};
|
||||||
|
|
||||||
#endif // UTILS_H
|
#endif // UTILS_H
|
||||||
|
|||||||
Reference in New Issue
Block a user