mirror of
https://gitee.com/spark-store-project/spark-store
synced 2025-12-14 04:42:03 +08:00
format: 代码格式化
This commit is contained in:
@@ -1,20 +1,19 @@
|
||||
#include "appintopage.h"
|
||||
#include "ui_appintopage.h"
|
||||
AppIntoPage::AppIntoPage(QWidget *parent) :
|
||||
QWidget(parent),
|
||||
ui(new Ui::AppIntoPage)
|
||||
AppIntoPage::AppIntoPage(QWidget *parent) : QWidget(parent),
|
||||
ui(new Ui::AppIntoPage)
|
||||
{
|
||||
ui->setupUi(this);
|
||||
ui->listWidget->setViewMode(QListView::IconMode);
|
||||
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){
|
||||
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;
|
||||
});
|
||||
qDebug()<<"Download Times:"+download_times; });
|
||||
clear();
|
||||
}
|
||||
|
||||
@@ -35,31 +34,31 @@ void AppIntoPage::clear()
|
||||
ui->downloadButton->hide();
|
||||
ui->downloadButton->setEnabled(true);
|
||||
ui->pushButton_3->hide();
|
||||
int n=ui->listWidget->count();
|
||||
for(int i=0;i<n;i++)
|
||||
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;
|
||||
card = NULL;
|
||||
delete item;
|
||||
item = NULL;
|
||||
item = NULL;
|
||||
}
|
||||
ui->listWidget->clear();
|
||||
}
|
||||
void AppIntoPage::setDownloadWidget(DownloadListWidget *w)
|
||||
{
|
||||
dw=w;
|
||||
connect(w, &DownloadListWidget::downloadFinished, [=]() {
|
||||
isDownloading(SparkAPI::getServerUrl()+"store"+spk.path()+"/"+info["Filename"].toString());
|
||||
});
|
||||
dw = w;
|
||||
connect(w, &DownloadListWidget::downloadFinished, [=]()
|
||||
{ isDownloading(SparkAPI::getServerUrl() + "store" + spk.path() + "/" + info["Filename"].toString()); });
|
||||
}
|
||||
void AppIntoPage::openUrl(QUrl url)
|
||||
{
|
||||
spk=url;
|
||||
SparkAPI *api=new SparkAPI(this);
|
||||
spk = url;
|
||||
SparkAPI *api = new SparkAPI(this);
|
||||
clear();
|
||||
connect(api,&SparkAPI::finishedObject,[=](QJsonObject appinfo){
|
||||
connect(api, &SparkAPI::finishedObject, [=](QJsonObject appinfo)
|
||||
{
|
||||
|
||||
info = appinfo;
|
||||
// qDebug()<<url;
|
||||
@@ -188,36 +187,42 @@ void AppIntoPage::openUrl(QUrl url)
|
||||
}
|
||||
this->sltAppinfoTags(&taglist);
|
||||
disconnect(api,&SparkAPI::finished,nullptr,nullptr);
|
||||
api->deleteLater();
|
||||
});
|
||||
api->deleteLater(); });
|
||||
api->getAppInfo(url);
|
||||
api1->getAppDownloadTimes(url);
|
||||
}
|
||||
|
||||
void AppIntoPage::isDownloading(QUrl url)
|
||||
{
|
||||
if (dw->getUrlList().lastIndexOf(url) == -1) {
|
||||
if (dw->getUrlList().lastIndexOf(url) == -1)
|
||||
{
|
||||
ui->downloadButton->setEnabled(true);
|
||||
return;
|
||||
} else {
|
||||
}
|
||||
else
|
||||
{
|
||||
ui->downloadButton->setEnabled(false);
|
||||
}
|
||||
|
||||
ui->pushButton_3->hide();
|
||||
if (dw->getDIList()[dw->getUrlList().lastIndexOf(url)]->download == 2) {
|
||||
if (dw->getDIList()[dw->getUrlList().lastIndexOf(url)]->download == 2)
|
||||
{
|
||||
ui->downloadButton->setEnabled(true);
|
||||
ui->downloadButton->setText(tr("Download"));
|
||||
}
|
||||
if (dw->getDIList()[dw->getUrlList().lastIndexOf(url)]->download == 1) {
|
||||
if (dw->getDIList()[dw->getUrlList().lastIndexOf(url)]->download == 1)
|
||||
{
|
||||
ui->downloadButton->setEnabled(true);
|
||||
ui->downloadButton->setText(tr("Install"));
|
||||
}
|
||||
if (dw->getDIList()[dw->getUrlList().lastIndexOf(url)]->isInstall) {
|
||||
if (dw->getDIList()[dw->getUrlList().lastIndexOf(url)]->isInstall)
|
||||
{
|
||||
ui->downloadButton->setEnabled(false);
|
||||
ui->downloadButton->setText(tr("Installing"));
|
||||
return;
|
||||
}
|
||||
if (dw->getDIList()[dw->getUrlList().lastIndexOf(url)]->download == 3) {
|
||||
if (dw->getDIList()[dw->getUrlList().lastIndexOf(url)]->download == 3)
|
||||
{
|
||||
ui->downloadButton->setEnabled(true);
|
||||
ui->downloadButton->setText(tr("Reinstall"));
|
||||
ui->downloadButton->show();
|
||||
@@ -227,37 +232,37 @@ void AppIntoPage::isDownloading(QUrl url)
|
||||
|
||||
void AppIntoPage::sltAppinfoTags(QStringList *tagList)
|
||||
{
|
||||
foreach(const QString &tag, *tagList)
|
||||
foreach (const QString &tag, *tagList)
|
||||
{
|
||||
if(tag=="community")
|
||||
if (tag == "community")
|
||||
{
|
||||
ui->tag_community->show();
|
||||
}
|
||||
else if(tag=="ubuntu")
|
||||
else if (tag == "ubuntu")
|
||||
{
|
||||
ui->tag_ubuntu->show();
|
||||
}
|
||||
else if(tag=="deepin")
|
||||
else if (tag == "deepin")
|
||||
{
|
||||
ui->tag_deepin->show();
|
||||
}
|
||||
else if(tag=="uos")
|
||||
else if (tag == "uos")
|
||||
{
|
||||
ui->tag_uos->show();
|
||||
}
|
||||
else if(tag=="dtk5")
|
||||
else if (tag == "dtk5")
|
||||
{
|
||||
ui->tag_dtk5->show();
|
||||
}
|
||||
else if(tag=="dwine2")
|
||||
else if (tag == "dwine2")
|
||||
{
|
||||
ui->tag_dwine2->show();
|
||||
}
|
||||
else if(tag=="dwine5")
|
||||
else if (tag == "dwine5")
|
||||
{
|
||||
ui->tag_dwine5->show();
|
||||
}
|
||||
else if(tag=="a2d")
|
||||
else if (tag == "a2d")
|
||||
{
|
||||
ui->tag_a2d->show();
|
||||
}
|
||||
@@ -265,9 +270,9 @@ void AppIntoPage::sltAppinfoTags(QStringList *tagList)
|
||||
}
|
||||
void AppIntoPage::setTheme(bool dark)
|
||||
{
|
||||
if(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);}";
|
||||
QString frameStyleSheet = "#frame,#frame_2,#frame_3,#frame_4{background-color: #252525;border-radius:14px;border:1px solid rgb(64, 64, 64);}";
|
||||
ui->frame->setStyleSheet(frameStyleSheet);
|
||||
ui->frame_2->setStyleSheet(frameStyleSheet);
|
||||
ui->frame_3->setStyleSheet(frameStyleSheet);
|
||||
@@ -279,9 +284,11 @@ void AppIntoPage::setTheme(bool dark)
|
||||
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);}";
|
||||
}
|
||||
else
|
||||
{
|
||||
// 亮色模式
|
||||
QString frameStyleSheet = "#frame,#frame_2,#frame_3,#frame_4{background-color: #fbfbfb;border-radius:14px;border:1px solid rgb(229,229,229);}";
|
||||
ui->frame->setStyleSheet(frameStyleSheet);
|
||||
ui->frame_2->setStyleSheet(frameStyleSheet);
|
||||
ui->frame_3->setStyleSheet(frameStyleSheet);
|
||||
@@ -293,7 +300,6 @@ void AppIntoPage::setTheme(bool dark)
|
||||
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()
|
||||
@@ -303,34 +309,34 @@ AppIntoPage::~AppIntoPage()
|
||||
|
||||
void AppIntoPage::on_downloadButton_clicked()
|
||||
{
|
||||
if(ui->downloadButton->text() == tr("Install"))
|
||||
if (ui->downloadButton->text() == tr("Install"))
|
||||
{
|
||||
dw->getDIList()[dw->getUrlList().lastIndexOf(SparkAPI::getServerUrl()+"store"+spk.path()+"/"+info["Filename"].toString())]->install(0);
|
||||
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,[=](){
|
||||
dw->getDIList()[dw->getUrlList().lastIndexOf(SparkAPI::getServerUrl() + "store" + spk.path() + "/" + info["Filename"].toString())]->install(0);
|
||||
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, [=]()
|
||||
{
|
||||
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;
|
||||
}
|
||||
emit clickedDownloadBtn();
|
||||
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"))
|
||||
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"))
|
||||
{
|
||||
dw->getDIList()[dw->allDownload - 1]->reinstall = true;
|
||||
}
|
||||
ui->downloadButton->setEnabled(false);
|
||||
QObject::connect(dw->getDIList()[dw->getUrlList().lastIndexOf(SparkAPI::getServerUrl()+"store"+spk.path()+"/"+info["Filename"].toString())],&DownloadItem::finished,[=](){
|
||||
QObject::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());
|
||||
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());
|
||||
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());
|
||||
}
|
||||
|
||||
void AppIntoPage::on_pushButton_3_clicked()
|
||||
{
|
||||
QtConcurrent::run([=]()
|
||||
{
|
||||
{
|
||||
ui->downloadButton->setEnabled(false);
|
||||
ui->pushButton_3->setEnabled(false);
|
||||
|
||||
@@ -352,19 +358,17 @@ void AppIntoPage::on_pushButton_3_clicked()
|
||||
}
|
||||
|
||||
ui->downloadButton->setEnabled(true);
|
||||
ui->pushButton_3->setEnabled(true);
|
||||
});
|
||||
ui->pushButton_3->setEnabled(true); });
|
||||
}
|
||||
|
||||
void AppIntoPage::on_shareButton_clicked()
|
||||
{
|
||||
qDebug() << "Share" << spk;
|
||||
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()
|
||||
{
|
||||
QString feedbackSpk = "spk://store/chat/store.spark-app.feedback";
|
||||
@@ -374,9 +378,9 @@ void AppIntoPage::on_updateButton_clicked()
|
||||
qDebug() << "反馈器存在";
|
||||
QProcess::startDetached("sh /opt/durapps/store.spark-app.feedback/launch.sh");
|
||||
}
|
||||
else{
|
||||
else
|
||||
{
|
||||
qDebug() << "反馈器不存在,跳转页面";
|
||||
openUrl(feedbackSpk);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -1,48 +1,55 @@
|
||||
#include "applistpage.h"
|
||||
#include "ui_applistpage.h"
|
||||
|
||||
AppListPage::AppListPage(QWidget *parent) :
|
||||
QWidget(parent),
|
||||
ui(new Ui::AppListPage)
|
||||
AppListPage::AppListPage(QWidget *parent) : QWidget(parent),
|
||||
ui(new Ui::AppListPage)
|
||||
{
|
||||
ui->setupUi(this);
|
||||
ui->webEngineView->page()->setBackgroundColor(Qt::transparent);
|
||||
}
|
||||
void AppListPage::setTheme(bool dark)
|
||||
{
|
||||
isDark=dark;
|
||||
if(dark)
|
||||
isDark = dark;
|
||||
if (dark)
|
||||
{
|
||||
this->setStyleSheet("#frame{background-color: #252525;border-radius:14px;border:1px solid rgb(64, 64, 64);}");
|
||||
}else {
|
||||
//亮色模式
|
||||
}
|
||||
else
|
||||
{
|
||||
// 亮色模式
|
||||
this->setStyleSheet("#frame{background-color: #ffffff;border-radius:14px;border:1px solid rgb(229,229,229);}");
|
||||
}
|
||||
if(isSearch)
|
||||
if (isSearch)
|
||||
{
|
||||
getSearchList(nowType);
|
||||
}else{
|
||||
}
|
||||
else
|
||||
{
|
||||
getAppList(nowType);
|
||||
}
|
||||
}
|
||||
void AppListPage::getAppList(QString type)
|
||||
{
|
||||
isSearch=false;
|
||||
nowType=type;
|
||||
SparkAPI *api=new SparkAPI(this);
|
||||
isSearch = false;
|
||||
nowType = type;
|
||||
SparkAPI *api = new SparkAPI(this);
|
||||
QString url;
|
||||
QString theme;
|
||||
if(isDark)
|
||||
if (isDark)
|
||||
{
|
||||
theme="theme=dark";
|
||||
}else{
|
||||
theme="theme=light";
|
||||
theme = "theme=dark";
|
||||
}
|
||||
if(type=="")
|
||||
else
|
||||
{
|
||||
url=api->getServerUrl()+"store/#/flamescion/?"+theme;
|
||||
}else{
|
||||
url=api->getServerUrl()+"store/#/flamescion/applist?type="+type+"&"+theme;
|
||||
theme = "theme=light";
|
||||
}
|
||||
if (type == "")
|
||||
{
|
||||
url = api->getServerUrl() + "store/#/flamescion/?" + theme;
|
||||
}
|
||||
else
|
||||
{
|
||||
url = api->getServerUrl() + "store/#/flamescion/applist?type=" + type + "&" + theme;
|
||||
}
|
||||
|
||||
ui->webEngineView->setUrl(url);
|
||||
@@ -50,18 +57,20 @@ void AppListPage::getAppList(QString type)
|
||||
|
||||
void AppListPage::getSearchList(QString keyword)
|
||||
{
|
||||
isSearch=true;
|
||||
nowType=keyword;
|
||||
SparkAPI *api=new SparkAPI(this);
|
||||
isSearch = true;
|
||||
nowType = keyword;
|
||||
SparkAPI *api = new SparkAPI(this);
|
||||
QString url;
|
||||
QString theme;
|
||||
if(isDark)
|
||||
if (isDark)
|
||||
{
|
||||
theme="theme=dark";
|
||||
}else{
|
||||
theme="theme=light";
|
||||
theme = "theme=dark";
|
||||
}
|
||||
url=api->getServerUrl()+"store/#/flamescion/search?keywords="+keyword+"&"+theme;
|
||||
else
|
||||
{
|
||||
theme = "theme=light";
|
||||
}
|
||||
url = api->getServerUrl() + "store/#/flamescion/search?keywords=" + keyword + "&" + theme;
|
||||
ui->webEngineView->setUrl(url);
|
||||
}
|
||||
|
||||
@@ -72,15 +81,14 @@ AppListPage::~AppListPage()
|
||||
|
||||
void AppListPage::on_webEngineView_urlChanged(const QUrl &arg1)
|
||||
{
|
||||
if(arg1.path().right(8) == "app.json")
|
||||
{
|
||||
QString url = arg1.toString();
|
||||
url = url.mid(url.indexOf("/store/"));
|
||||
url = "spk:/"+url;
|
||||
url = url.mid(0,url.indexOf("/app.json"));
|
||||
qDebug() << "程序跳转链接地址:" << url;
|
||||
ui->webEngineView->back();
|
||||
emit clicked(url);
|
||||
}
|
||||
if (arg1.path().right(8) == "app.json")
|
||||
{
|
||||
QString url = arg1.toString();
|
||||
url = url.mid(url.indexOf("/store/"));
|
||||
url = "spk:/" + url;
|
||||
url = url.mid(0, url.indexOf("/app.json"));
|
||||
qDebug() << "程序跳转链接地址:" << url;
|
||||
ui->webEngineView->back();
|
||||
emit clicked(url);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -1,9 +1,8 @@
|
||||
#include "settingspage.h"
|
||||
#include "ui_settingspage.h"
|
||||
bool SettingsPage::isdownload = false;
|
||||
SettingsPage::SettingsPage(QWidget *parent) :
|
||||
QWidget(parent),
|
||||
ui(new Ui::SettingsPage)
|
||||
SettingsPage::SettingsPage(QWidget *parent) : QWidget(parent),
|
||||
ui(new Ui::SettingsPage)
|
||||
{
|
||||
ui->setupUi(this);
|
||||
configCanSave = false;
|
||||
@@ -12,11 +11,13 @@ SettingsPage::SettingsPage(QWidget *parent) :
|
||||
|
||||
void SettingsPage::setTheme(bool dark)
|
||||
{
|
||||
if(dark)
|
||||
if (dark)
|
||||
{
|
||||
this->setStyleSheet("#frame{background-color: #252525;border-radius:14px;border:1px solid rgb(64, 64, 64);}");
|
||||
}else {
|
||||
//亮色模式
|
||||
}
|
||||
else
|
||||
{
|
||||
// 亮色模式
|
||||
this->setStyleSheet("#frame{background-color: #ffffff;border-radius:14px;border:1px solid rgb(229,229,229);}");
|
||||
}
|
||||
}
|
||||
@@ -26,7 +27,7 @@ void SettingsPage::readServerList()
|
||||
// 读取服务器列表并初始化
|
||||
QFile file(QDir::homePath().toUtf8() + "/.config/spark-store/server.list");
|
||||
|
||||
//判断文件是否存在
|
||||
// 判断文件是否存在
|
||||
if (!file.exists())
|
||||
{
|
||||
ui->comboBox_server->addItem("https://d.store.deepinos.org.cn/");
|
||||
@@ -34,28 +35,28 @@ void SettingsPage::readServerList()
|
||||
|
||||
if (!file.open(QIODevice::ReadOnly | QIODevice::Text))
|
||||
{
|
||||
qDebug()<<"无法读取server.list";
|
||||
qDebug() << "无法读取server.list";
|
||||
}
|
||||
|
||||
//创建QTextStream对象
|
||||
// 创建QTextStream对象
|
||||
QTextStream textStream(&file);
|
||||
|
||||
QString lineData = textStream.readLine();//读取文件的第一行
|
||||
QString lineData = textStream.readLine(); // 读取文件的第一行
|
||||
ui->comboBox_server->addItem(lineData);
|
||||
while(!lineData.isNull())
|
||||
while (!lineData.isNull())
|
||||
{
|
||||
lineData = textStream.readLine();
|
||||
ui->comboBox_server->addItem(lineData);
|
||||
}
|
||||
for(int i = 0; i < ui->comboBox_server->count(); i++)
|
||||
for (int i = 0; i < ui->comboBox_server->count(); i++)
|
||||
{
|
||||
if(ui->comboBox_server->itemText(i) == "开发者模式 Dev only")
|
||||
if (ui->comboBox_server->itemText(i) == "开发者模式 Dev only")
|
||||
{
|
||||
ui->comboBox_server->model()->setData(ui->comboBox_server->model()->index(i, 0), QVariant(0), Qt::UserRole - 1);
|
||||
}
|
||||
if(ui->comboBox_server->itemText(i) == "镜像源 Download only")
|
||||
if (ui->comboBox_server->itemText(i) == "镜像源 Download only")
|
||||
{
|
||||
for(int j = i; j < ui->comboBox_server->count(); j++)
|
||||
for (int j = i; j < ui->comboBox_server->count(); j++)
|
||||
{
|
||||
ui->comboBox_server->model()->setData(ui->comboBox_server->model()->index(j, 0), QVariant(0), Qt::UserRole - 1);
|
||||
}
|
||||
@@ -71,13 +72,13 @@ void SettingsPage::initConfig()
|
||||
|
||||
// 读取服务器URL并初始化菜单项的链接
|
||||
QSettings readConfig(QDir::homePath() + "/.config/spark-store/config.ini", QSettings::IniFormat);
|
||||
if(!readConfig.value("server/choose").toString().isEmpty() && readConfig.value("server/updated").toString() == "TRUE")
|
||||
if (!readConfig.value("server/choose").toString().isEmpty() && readConfig.value("server/updated").toString() == "TRUE")
|
||||
{
|
||||
qDebug()<<readConfig.value("server/choose").toString();
|
||||
qDebug() << readConfig.value("server/choose").toString();
|
||||
ui->comboBox_server->setCurrentText(readConfig.value("server/choose").toString());
|
||||
SparkAPI::setServerUrl(readConfig.value("server/choose").toString());
|
||||
}
|
||||
configCanSave = true; // 防止触发保存配置信号
|
||||
configCanSave = true; // 防止触发保存配置信号
|
||||
}
|
||||
|
||||
SettingsPage::~SettingsPage()
|
||||
@@ -88,7 +89,7 @@ SettingsPage::~SettingsPage()
|
||||
void SettingsPage::on_pushButton_updateServer_clicked()
|
||||
{
|
||||
QtConcurrent::run([=]()
|
||||
{
|
||||
{
|
||||
ui->pushButton_updateServer->setEnabled(false);
|
||||
ui->comboBox_server->clear();
|
||||
|
||||
@@ -97,17 +98,15 @@ void SettingsPage::on_pushButton_updateServer_clicked()
|
||||
|
||||
ui->pushButton_updateServer->setEnabled(true);
|
||||
readServerList();
|
||||
ui->comboBox_server->setCurrentIndex(0);
|
||||
});
|
||||
ui->comboBox_server->setCurrentIndex(0); });
|
||||
}
|
||||
|
||||
|
||||
void SettingsPage::on_comboBox_server_currentIndexChanged(const QString &arg1)
|
||||
{
|
||||
SparkAPI::setServerUrl(arg1); // 服务器信息更新
|
||||
qDebug()<<arg1;
|
||||
SparkAPI::setServerUrl(arg1); // 服务器信息更新
|
||||
qDebug() << arg1;
|
||||
const QString updatedInfo = "TRUE";
|
||||
if(configCanSave)
|
||||
if (configCanSave)
|
||||
{
|
||||
// ui->label_setting1->show();
|
||||
QSettings *setConfig = new QSettings(QDir::homePath() + "/.config/spark-store/config.ini", QSettings::IniFormat);
|
||||
@@ -124,7 +123,7 @@ void SettingsPage::setIsDownload(bool isdownload)
|
||||
|
||||
void SettingsPage::updateUI()
|
||||
{
|
||||
if(isdownload)
|
||||
if (isdownload)
|
||||
{
|
||||
ui->pushButton_clear->setEnabled(false);
|
||||
}
|
||||
@@ -135,15 +134,15 @@ void SettingsPage::updateUI()
|
||||
// 显示缓存占用空间
|
||||
quint64 tmp_size = dirFileSize(QString::fromUtf8(TMP_PATH));
|
||||
QString tmp_size_str;
|
||||
if(tmp_size < 1024)
|
||||
if (tmp_size < 1024)
|
||||
{
|
||||
tmp_size_str = QString::number(tmp_size) + "B";
|
||||
}
|
||||
else if(tmp_size < (1024 * 1024))
|
||||
else if (tmp_size < (1024 * 1024))
|
||||
{
|
||||
tmp_size_str = QString::number(0.01 * int(100 * (tmp_size / 1024))) + "KB";
|
||||
}
|
||||
else if(tmp_size<(1024*1024*1024))
|
||||
else if (tmp_size < (1024 * 1024 * 1024))
|
||||
{
|
||||
tmp_size_str = QString::number(0.01 * int(100 * (tmp_size / (1024 * 1024)))) + "MB";
|
||||
}
|
||||
@@ -160,13 +159,13 @@ quint64 SettingsPage::dirFileSize(const QString &path)
|
||||
QDir dir(path);
|
||||
quint64 size = 0;
|
||||
// dir.entryInfoList(QDir::Files); // 返回文件信息
|
||||
foreach(QFileInfo fileInfo, dir.entryInfoList(QDir::Files))
|
||||
foreach (QFileInfo fileInfo, dir.entryInfoList(QDir::Files))
|
||||
{
|
||||
// 计算文件大小
|
||||
size += quint64(fileInfo.size());
|
||||
}
|
||||
// dir.entryList(QDir::Dirs|QDir::NoDotAndDotDot); // 返回所有子目录,并进行过滤
|
||||
foreach(QString subDir, dir.entryList(QDir::Dirs | QDir::NoDotAndDotDot))
|
||||
foreach (QString subDir, dir.entryList(QDir::Dirs | QDir::NoDotAndDotDot))
|
||||
{
|
||||
// 若存在子目录,则递归调用 dirFileSize() 函数
|
||||
size += dirFileSize(path + QDir::separator() + subDir);
|
||||
@@ -177,22 +176,20 @@ quint64 SettingsPage::dirFileSize(const QString &path)
|
||||
void SettingsPage::on_pushButton_updateApt_clicked()
|
||||
{
|
||||
QtConcurrent::run([=]()
|
||||
{
|
||||
{
|
||||
ui->pushButton_updateApt->setEnabled(false);
|
||||
ui->label_aptserver->setText(tr("Updating, please wait..."));
|
||||
|
||||
emit openUrl(QUrl("spk://store/tools/spark-store"));
|
||||
ui->label_aptserver->setText(tr(""));
|
||||
|
||||
ui->pushButton_updateApt->setEnabled(true);
|
||||
});
|
||||
ui->pushButton_updateApt->setEnabled(true); });
|
||||
}
|
||||
|
||||
|
||||
void SettingsPage::on_pushButton_clear_clicked()
|
||||
{
|
||||
QtConcurrent::run([=]()
|
||||
{
|
||||
{
|
||||
ui->pushButton_clear->setEnabled(false);
|
||||
|
||||
QDir tmpdir("/tmp/spark-store");
|
||||
@@ -204,15 +201,13 @@ void SettingsPage::on_pushButton_clear_clicked()
|
||||
}
|
||||
Utils::sendNotification("spark-store",tr("Spark Store"),tr("Temporary cache was cleaned"));
|
||||
ui->pushButton_clear->setEnabled(true);
|
||||
updateUI();
|
||||
});
|
||||
updateUI(); });
|
||||
}
|
||||
|
||||
|
||||
void SettingsPage::on_pushButton_clearWebCache_clicked()
|
||||
{
|
||||
QtConcurrent::run([=]()
|
||||
{
|
||||
{
|
||||
QString dataLocal = QStandardPaths::writableLocation(QStandardPaths::AppLocalDataLocation);
|
||||
qDebug() << dataLocal;
|
||||
QDir dataDir(dataLocal);
|
||||
@@ -220,7 +215,5 @@ void SettingsPage::on_pushButton_clearWebCache_clicked()
|
||||
dataLocal = QStandardPaths::writableLocation(QStandardPaths::TempLocation);
|
||||
qDebug() << dataLocal;
|
||||
QDir cacheDir(dataLocal);
|
||||
cacheDir.removeRecursively();
|
||||
});
|
||||
cacheDir.removeRecursively(); });
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user