mirror of
https://gitee.com/spark-store-project/spark-store
synced 2025-09-29 15:12:21 +08:00
!16 Improve Features
* Improce Features * History Backup for Version 3.0-stable
This commit is contained in:
parent
3101f1fe70
commit
1a4b1176fb
135
src/widget.cpp
135
src/widget.cpp
@ -28,6 +28,7 @@
|
|||||||
#include <QClipboard>
|
#include <QClipboard>
|
||||||
#include <DApplication>
|
#include <DApplication>
|
||||||
#include <DGuiApplicationHelper>
|
#include <DGuiApplicationHelper>
|
||||||
|
#include <DStyle>
|
||||||
#include <QPushButton>
|
#include <QPushButton>
|
||||||
#include "HttpClient.h"
|
#include "HttpClient.h"
|
||||||
#include "appitem.h"
|
#include "appitem.h"
|
||||||
@ -35,7 +36,6 @@
|
|||||||
|
|
||||||
DWIDGET_USE_NAMESPACE
|
DWIDGET_USE_NAMESPACE
|
||||||
|
|
||||||
|
|
||||||
Widget::Widget(DBlurEffectWidget *parent) :
|
Widget::Widget(DBlurEffectWidget *parent) :
|
||||||
DBlurEffectWidget(parent),
|
DBlurEffectWidget(parent),
|
||||||
ui(new Ui::Widget)
|
ui(new Ui::Widget)
|
||||||
@ -73,11 +73,13 @@ Widget::Widget(DBlurEffectWidget *parent) :
|
|||||||
connect(&appinfoLoadThread, &SpkAppInfoLoaderThread::finishAllLoading, this, &Widget::sltAppinfoFinish, Qt::ConnectionType::BlockingQueuedConnection);
|
connect(&appinfoLoadThread, &SpkAppInfoLoaderThread::finishAllLoading, this, &Widget::sltAppinfoFinish, Qt::ConnectionType::BlockingQueuedConnection);
|
||||||
|
|
||||||
// 搜索事件
|
// 搜索事件
|
||||||
connect(searchEdit,&DSearchEdit::returnPressed ,this,[=](){
|
connect(searchEdit, &DSearchEdit::returnPressed, this, [=]()
|
||||||
|
{
|
||||||
qDebug() << "触发了搜索,呜啦啦啦!";
|
qDebug() << "触发了搜索,呜啦啦啦!";
|
||||||
QString searchtext=searchEdit->text();
|
QString searchtext = searchEdit->text();
|
||||||
if(searchtext!=""){
|
if(searchtext != "")
|
||||||
qDebug()<<searchEdit->text();
|
{
|
||||||
|
qDebug() << searchEdit->text();
|
||||||
searchApp(searchtext);
|
searchApp(searchtext);
|
||||||
}
|
}
|
||||||
this->setFocus();
|
this->setFocus();
|
||||||
@ -211,6 +213,12 @@ void Widget::initUI()
|
|||||||
|
|
||||||
// 搜索列表页
|
// 搜索列表页
|
||||||
applist_grid = new FlowLayout;
|
applist_grid = new FlowLayout;
|
||||||
|
main = new QHBoxLayout;
|
||||||
|
main->setAlignment(Qt::AlignHCenter);
|
||||||
|
main->setMargin(0);
|
||||||
|
main->addWidget(spinner);
|
||||||
|
ui->applist_scrollAreaWidget->setLayout(main);
|
||||||
|
spinner->setFixedSize(80, 80);
|
||||||
}
|
}
|
||||||
|
|
||||||
void Widget::initConfig()
|
void Widget::initConfig()
|
||||||
@ -293,7 +301,7 @@ void Widget::setTheme(bool isDark,QColor color)
|
|||||||
ui->label->setStyleSheet("background-color:#252525");
|
ui->label->setStyleSheet("background-color:#252525");
|
||||||
// ui->scrollArea->setStyleSheet("background-color:#252525");
|
// ui->scrollArea->setStyleSheet("background-color:#252525");
|
||||||
ui->label_show->setStyleSheet("background-color:#252525");
|
ui->label_show->setStyleSheet("background-color:#252525");
|
||||||
ui->pushButton_return->setIcon(QIcon(":/icons/icons/category_active_dark.svg"));
|
ui->pushButton_return->setIcon(DStyle().standardIcon(DStyle::SP_ArrowLeft));
|
||||||
ui->pushButton_refresh->setIcon(QIcon(":/icons/icons/refresh-page-dark.svg"));
|
ui->pushButton_refresh->setIcon(QIcon(":/icons/icons/refresh-page-dark.svg"));
|
||||||
}else {
|
}else {
|
||||||
// 亮色模式
|
// 亮色模式
|
||||||
@ -304,7 +312,7 @@ void Widget::setTheme(bool isDark,QColor color)
|
|||||||
ui->label->setStyleSheet("background-color:#FFFFFF");
|
ui->label->setStyleSheet("background-color:#FFFFFF");
|
||||||
// ui->scrollArea->setStyleSheet("background-color:#F8F8F8");
|
// ui->scrollArea->setStyleSheet("background-color:#F8F8F8");
|
||||||
ui->label_show->setStyleSheet("background-color:#F8F8F8");
|
ui->label_show->setStyleSheet("background-color:#F8F8F8");
|
||||||
ui->pushButton_return->setIcon(QIcon(":/icons/icons/category_active.svg"));
|
ui->pushButton_return->setIcon(DStyle().standardIcon(DStyle::SP_ArrowLeft));
|
||||||
ui->pushButton_refresh->setIcon(QIcon(":/icons/icons/refresh-page.svg"));
|
ui->pushButton_refresh->setIcon(QIcon(":/icons/icons/refresh-page.svg"));
|
||||||
}
|
}
|
||||||
main_color=color;
|
main_color=color;
|
||||||
@ -729,7 +737,7 @@ void Widget::searchApp(QString text)
|
|||||||
if(text.left(6)=="spk://"){
|
if(text.left(6)=="spk://"){
|
||||||
openUrl(text);
|
openUrl(text);
|
||||||
searchEdit->clearEdit();
|
searchEdit->clearEdit();
|
||||||
}else {
|
} else {
|
||||||
// sendNotification(tr("Spark store could only process spk:// links for now. The search feature is coming soon!"));
|
// sendNotification(tr("Spark store could only process spk:// links for now. The search feature is coming soon!"));
|
||||||
// ui->webView->setUrl(QUrl("http://www.baidu.com/s?wd="+text));//这东西对接百度
|
// ui->webView->setUrl(QUrl("http://www.baidu.com/s?wd="+text));//这东西对接百度
|
||||||
// ui->stackedWidget->setCurrentIndex(0);
|
// ui->stackedWidget->setCurrentIndex(0);
|
||||||
@ -771,34 +779,43 @@ void Widget::displaySearchApp(QJsonArray array)
|
|||||||
ui->stackedWidget->setCurrentIndex(4);
|
ui->stackedWidget->setCurrentIndex(4);
|
||||||
|
|
||||||
// 清除原有的搜索结果
|
// 清除原有的搜索结果
|
||||||
QLayoutItem *item;
|
QLayoutItem *item = nullptr;
|
||||||
while ((item = applist_grid->takeAt(0)) != nullptr) {
|
while ((item = applist_grid->takeAt(0)) != nullptr) {
|
||||||
|
applist_grid->removeWidget(item->widget());
|
||||||
item->widget()->disconnect();
|
item->widget()->disconnect();
|
||||||
delete item->widget();
|
item->widget()->setParent(nullptr);
|
||||||
delete item;
|
delete item;
|
||||||
}
|
}
|
||||||
item = nullptr;
|
|
||||||
|
main->removeItem(applist_grid);
|
||||||
|
spinner->show();
|
||||||
|
spinner->start();
|
||||||
|
|
||||||
for(int i = 0; i < array.size(); i++)
|
for(int i = 0; i < array.size(); i++)
|
||||||
{
|
{
|
||||||
QJsonObject appInfo = array.at(i).toObject();
|
QJsonObject appInfo = array.at(i).toObject();
|
||||||
AppItem *appItem = new AppItem(this);
|
AppItem *appItem = new AppItem(this);
|
||||||
QString url = QString("spk://store/%1/%2")
|
QString url = QString("spk://store/%1/%2")
|
||||||
.arg(appInfo["category_slug"].toString())
|
.arg(appInfo["category_slug"].toString())
|
||||||
.arg(appInfo["pkgname"].toString());
|
.arg(appInfo["pkgname"].toString());
|
||||||
appItem->setTitle(appInfo["name"].toString());
|
appItem->setTitle(appInfo["name"].toString());
|
||||||
appItem->setDescription(appInfo["more"].toString());
|
appItem->setDescription(appInfo["more"].toString());
|
||||||
appItem->setIcon(appInfo["icon"].toString());
|
appItem->setIcon(appInfo["icon"].toString());
|
||||||
appItem->setUrl(url);
|
appItem->setUrl(url);
|
||||||
applist_grid->addWidget(appItem);
|
applist_grid->addWidget(appItem);
|
||||||
qDebug() << "应用链接为:" << url;
|
qDebug() << "应用链接为:" << url;
|
||||||
connect(appItem, &AppItem::clicked, this, &Widget::openUrl);
|
connect(appItem, &AppItem::clicked, this, &Widget::openUrl);
|
||||||
connect(appItem, &AppItem::finished, this, [=](){
|
|
||||||
count++;
|
connect(appItem, &AppItem::clicked, this, [=]()
|
||||||
downloadIconsFinished(array.size());
|
{
|
||||||
});
|
prePage = ui->stackedWidget->currentIndex();
|
||||||
|
});
|
||||||
|
|
||||||
|
connect(appItem, &AppItem::finished, this, [=](){
|
||||||
|
count++;
|
||||||
|
downloadIconsFinished(array.size());
|
||||||
|
});
|
||||||
}
|
}
|
||||||
ui->applist_scrollarea->widget()->setLayout(applist_grid);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void Widget::downloadIconsFinished(int arraysize)
|
void Widget::downloadIconsFinished(int arraysize)
|
||||||
@ -806,10 +823,12 @@ void Widget::downloadIconsFinished(int arraysize)
|
|||||||
// 当前搜索列表图标全部加载完成后才允许下一次搜索
|
// 当前搜索列表图标全部加载完成后才允许下一次搜索
|
||||||
if(count == arraysize)
|
if(count == arraysize)
|
||||||
{
|
{
|
||||||
|
spinner->stop();
|
||||||
|
spinner->hide();
|
||||||
|
main->addLayout(applist_grid, 1);
|
||||||
count = 0;
|
count = 0;
|
||||||
mutex.unlock();
|
mutex.unlock();
|
||||||
}
|
}
|
||||||
ui->applist_scrollarea->widget()->setLayout(applist_grid);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void Widget::httpReadyRead()
|
void Widget::httpReadyRead()
|
||||||
@ -968,36 +987,42 @@ void Widget::httpFinished() // 完成下载
|
|||||||
|
|
||||||
void Widget::on_pushButton_return_clicked()
|
void Widget::on_pushButton_return_clicked()
|
||||||
{
|
{
|
||||||
// ui->stackedWidget->setCurrentIndex(0);
|
|
||||||
// if(nowMenu==13){
|
|
||||||
// chooseLeftMenu(13);
|
|
||||||
// return;
|
|
||||||
// }
|
|
||||||
appinfoLoadThread.requestInterruption();
|
appinfoLoadThread.requestInterruption();
|
||||||
|
|
||||||
// 检测是否是从搜索页面进入到应用详情页的,根据搜索栏是否有关键词判断
|
// 检测是否是从搜索页面进入到应用详情页的,根据搜索栏是否有关键词判断
|
||||||
if (searchEdit->text().isEmpty()) {
|
if (searchEdit->text().isEmpty())
|
||||||
ui->webEngineView->back();
|
{
|
||||||
ui->stackedWidget->setCurrentIndex(0);
|
if(ui->stackedWidget->currentIndex() == 2)
|
||||||
} else {
|
{
|
||||||
ui->stackedWidget->setCurrentIndex(4);
|
ui->webEngineView->back();
|
||||||
|
ui->stackedWidget->setCurrentIndex(0);
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
ui->stackedWidget->setCurrentIndex(prePage);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
if (ui->stackedWidget->currentIndex() == 4)
|
||||||
|
{
|
||||||
|
searchEdit->clear();
|
||||||
|
chooseLeftMenu(nowMenu);
|
||||||
|
}
|
||||||
|
else if(ui->stackedWidget->currentIndex() == 2)
|
||||||
|
{
|
||||||
|
ui->stackedWidget->setCurrentIndex(4);
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
ui->stackedWidget->setCurrentIndex(prePage);
|
||||||
|
}
|
||||||
|
|
||||||
|
if(ui->stackedWidget->currentIndex() == 4)
|
||||||
// chooseLeftMenu(nowMenu);
|
{
|
||||||
// if(themeIsDark){
|
searchApp(searchEdit->text());
|
||||||
// QString darkurl=menuUrl[nowMenu].toString();
|
}
|
||||||
// QStringList tmp=darkurl.split("/");
|
}
|
||||||
// darkurl.clear();
|
|
||||||
// for (int i=0;i<tmp.size()-1;i++) {
|
|
||||||
// darkurl+=tmp[i]+"/";
|
|
||||||
// }
|
|
||||||
// darkurl+="dark"+tmp[tmp.size()-1];
|
|
||||||
// ui->webView->setUrl(darkurl);
|
|
||||||
// qDebug()<<darkurl;
|
|
||||||
// }else {
|
|
||||||
// ui->webView->setUrl(menuUrl[nowMenu]);
|
|
||||||
// }
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void Widget::on_pushButton_refresh_clicked()
|
void Widget::on_pushButton_refresh_clicked()
|
||||||
@ -1183,6 +1208,7 @@ void Widget::opensetting()
|
|||||||
tmp_size_str=QString::number(0.01*int(100*(tmp_size/(1024*1024*1024))))+"GB";
|
tmp_size_str=QString::number(0.01*int(100*(tmp_size/(1024*1024*1024))))+"GB";
|
||||||
}
|
}
|
||||||
ui->tmp_size_ui->setText(tmp_size_str);
|
ui->tmp_size_ui->setText(tmp_size_str);
|
||||||
|
prePage = ui->stackedWidget->currentIndex();
|
||||||
ui->stackedWidget->setCurrentIndex(3);
|
ui->stackedWidget->setCurrentIndex(3);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -1234,6 +1260,7 @@ void Widget::on_webEngineView_urlChanged(const QUrl &arg1)
|
|||||||
}
|
}
|
||||||
//如果是app.json就打开详情页
|
//如果是app.json就打开详情页
|
||||||
if(arg1.path().right(8)=="app.json"){
|
if(arg1.path().right(8)=="app.json"){
|
||||||
|
prePage = ui->stackedWidget->currentIndex();
|
||||||
load.cancel();//打开并发加载线程前关闭正在执行的线程
|
load.cancel();//打开并发加载线程前关闭正在执行的线程
|
||||||
m_loadweb->setValue(0);
|
m_loadweb->setValue(0);
|
||||||
ui->label_more->setText("");//清空详情介绍
|
ui->label_more->setText("");//清空详情介绍
|
||||||
|
@ -2,6 +2,7 @@
|
|||||||
#define WIDGET_H
|
#define WIDGET_H
|
||||||
|
|
||||||
#include <QWidget>
|
#include <QWidget>
|
||||||
|
#include <QLabel>
|
||||||
#include <QUrl>
|
#include <QUrl>
|
||||||
#include <QFile>
|
#include <QFile>
|
||||||
#include <QNetworkReply>
|
#include <QNetworkReply>
|
||||||
@ -21,7 +22,7 @@
|
|||||||
#include <DBlurEffectWidget>
|
#include <DBlurEffectWidget>
|
||||||
#include <DSpinner>
|
#include <DSpinner>
|
||||||
#include <DWaterProgress>
|
#include <DWaterProgress>
|
||||||
#include <QLabel>
|
#include <DSpinner>
|
||||||
#include <DTitlebar>
|
#include <DTitlebar>
|
||||||
#include <DSearchEdit>
|
#include <DSearchEdit>
|
||||||
#include <progressload.h>
|
#include <progressload.h>
|
||||||
@ -138,6 +139,7 @@ private:
|
|||||||
bool configCanSave=false;
|
bool configCanSave=false;
|
||||||
bool isBusy=false;
|
bool isBusy=false;
|
||||||
int nowMenu=0; //定位当前菜单
|
int nowMenu=0; //定位当前菜单
|
||||||
|
int prePage=0; //定位前一个页面
|
||||||
long download_size=0;
|
long download_size=0;
|
||||||
long size1=0;
|
long size1=0;
|
||||||
long size2=0;
|
long size2=0;
|
||||||
@ -148,8 +150,9 @@ private:
|
|||||||
QString type_name;
|
QString type_name;
|
||||||
QColor main_color;
|
QColor main_color;
|
||||||
int foot;
|
int foot;
|
||||||
DSearchEdit *searchEdit=new DSearchEdit;
|
DSearchEdit *searchEdit = new DSearchEdit;
|
||||||
DTitlebar *titlebar;
|
DTitlebar *titlebar;
|
||||||
|
DSpinner *spinner = new DSpinner;
|
||||||
|
|
||||||
int count = 0; // 记录当前搜索列表下载图标完成的个数
|
int count = 0; // 记录当前搜索列表下载图标完成的个数
|
||||||
QMutex mutex; // 禁止多次搜索事件同时发生
|
QMutex mutex; // 禁止多次搜索事件同时发生
|
||||||
@ -159,6 +162,7 @@ private:
|
|||||||
|
|
||||||
AeaQt::HttpClient *httpClient;
|
AeaQt::HttpClient *httpClient;
|
||||||
FlowLayout *applist_grid;
|
FlowLayout *applist_grid;
|
||||||
|
QHBoxLayout *main;
|
||||||
};
|
};
|
||||||
|
|
||||||
#endif // WIDGET_H
|
#endif // WIDGET_H
|
||||||
|
@ -365,11 +365,11 @@
|
|||||||
<number>0</number>
|
<number>0</number>
|
||||||
</property>
|
</property>
|
||||||
<item>
|
<item>
|
||||||
<widget class="QWebEngineView" name="webEngineView" native="true">
|
<widget class="QWebEngineView" name="webEngineView">
|
||||||
<property name="contextMenuPolicy">
|
<property name="contextMenuPolicy">
|
||||||
<enum>Qt::DefaultContextMenu</enum>
|
<enum>Qt::DefaultContextMenu</enum>
|
||||||
</property>
|
</property>
|
||||||
<property name="url" stdset="0">
|
<property name="url">
|
||||||
<url>
|
<url>
|
||||||
<string>about:blank</string>
|
<string>about:blank</string>
|
||||||
</url>
|
</url>
|
||||||
@ -489,7 +489,7 @@
|
|||||||
<rect>
|
<rect>
|
||||||
<x>0</x>
|
<x>0</x>
|
||||||
<y>0</y>
|
<y>0</y>
|
||||||
<width>889</width>
|
<width>606</width>
|
||||||
<height>854</height>
|
<height>854</height>
|
||||||
</rect>
|
</rect>
|
||||||
</property>
|
</property>
|
||||||
@ -984,7 +984,7 @@
|
|||||||
<rect>
|
<rect>
|
||||||
<x>0</x>
|
<x>0</x>
|
||||||
<y>0</y>
|
<y>0</y>
|
||||||
<width>851</width>
|
<width>568</width>
|
||||||
<height>323</height>
|
<height>323</height>
|
||||||
</rect>
|
</rect>
|
||||||
</property>
|
</property>
|
||||||
@ -1114,8 +1114,8 @@
|
|||||||
<rect>
|
<rect>
|
||||||
<x>0</x>
|
<x>0</x>
|
||||||
<y>0</y>
|
<y>0</y>
|
||||||
<width>889</width>
|
<width>743</width>
|
||||||
<height>858</height>
|
<height>902</height>
|
||||||
</rect>
|
</rect>
|
||||||
</property>
|
</property>
|
||||||
<layout class="QVBoxLayout" name="verticalLayout_23">
|
<layout class="QVBoxLayout" name="verticalLayout_23">
|
||||||
|
Loading…
x
Reference in New Issue
Block a user