mirror of
https://gitee.com/spark-store-project/spark-store
synced 2025-09-29 15:12:21 +08:00
完成搜索功能
This commit is contained in:
parent
4315f04023
commit
91fcab56df
@ -6,12 +6,20 @@
|
|||||||
#include <QNetworkRequest>
|
#include <QNetworkRequest>
|
||||||
#include <QEventLoop>
|
#include <QEventLoop>
|
||||||
#include <QPainter>
|
#include <QPainter>
|
||||||
|
#include <QGraphicsDropShadowEffect>
|
||||||
|
|
||||||
AppItem::AppItem(QWidget *parent) :
|
AppItem::AppItem(QWidget *parent) :
|
||||||
QWidget(parent),
|
QWidget(parent),
|
||||||
ui(new Ui::AppItem)
|
ui(new Ui::AppItem)
|
||||||
{
|
{
|
||||||
ui->setupUi(this);
|
ui->setupUi(this);
|
||||||
|
|
||||||
|
// auto shadow = new QGraphicsDropShadowEffect();
|
||||||
|
// shadow->setXOffset(0);
|
||||||
|
// shadow->setYOffset(1);
|
||||||
|
// shadow->setBlurRadius(2);
|
||||||
|
// shadow->setColor(QColor::fromRgba(qRgba(0, 0, 0, 180)));
|
||||||
|
// ui->container->setGraphicsEffect(shadow);
|
||||||
}
|
}
|
||||||
|
|
||||||
AppItem::~AppItem()
|
AppItem::~AppItem()
|
||||||
@ -28,13 +36,19 @@ void AppItem::setTitle(QString title)
|
|||||||
void AppItem::setDescription(QString description)
|
void AppItem::setDescription(QString description)
|
||||||
{
|
{
|
||||||
m_description = description;
|
m_description = description;
|
||||||
ui->lbl_desc->setText(description);
|
QString elidedText = ui->lbl_desc->fontMetrics().elidedText(
|
||||||
|
description, Qt::ElideRight,
|
||||||
|
ui->lbl_desc->width(), Qt::TextShowMnemonic);
|
||||||
|
ui->lbl_desc->setText(elidedText);
|
||||||
|
ui->lbl_desc->setAlignment(Qt::AlignTop);
|
||||||
}
|
}
|
||||||
|
|
||||||
void AppItem::setIcon(QString icon)
|
void AppItem::setIcon(QString icon)
|
||||||
{
|
{
|
||||||
m_icon = icon;
|
m_icon = icon;
|
||||||
downloadIcon(icon);
|
if (!icon.isEmpty()) {
|
||||||
|
downloadIcon(icon);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void AppItem::setUrl(QString url)
|
void AppItem::setUrl(QString url)
|
||||||
@ -65,6 +79,7 @@ void AppItem::downloadIcon(QString icon)
|
|||||||
QPixmap pixmap;
|
QPixmap pixmap;
|
||||||
pixmap.loadFromData(reply->readAll());
|
pixmap.loadFromData(reply->readAll());
|
||||||
qDebug() << "图标下载完毕:" << pixmap;
|
qDebug() << "图标下载完毕:" << pixmap;
|
||||||
|
qDebug() << icon << "响应有报错吗?" << reply->errorString();
|
||||||
pixmap = pixmap.scaled(78, 78, Qt::IgnoreAspectRatio, Qt::SmoothTransformation);
|
pixmap = pixmap.scaled(78, 78, Qt::IgnoreAspectRatio, Qt::SmoothTransformation);
|
||||||
if (reply->error() == QNetworkReply::NoError) {
|
if (reply->error() == QNetworkReply::NoError) {
|
||||||
QMetaObject::invokeMethod(this, "loadIcon", Qt::QueuedConnection,
|
QMetaObject::invokeMethod(this, "loadIcon", Qt::QueuedConnection,
|
||||||
|
169
src/appitem.ui
169
src/appitem.ui
@ -6,8 +6,8 @@
|
|||||||
<rect>
|
<rect>
|
||||||
<x>0</x>
|
<x>0</x>
|
||||||
<y>0</y>
|
<y>0</y>
|
||||||
<width>331</width>
|
<width>333</width>
|
||||||
<height>131</height>
|
<height>133</height>
|
||||||
</rect>
|
</rect>
|
||||||
</property>
|
</property>
|
||||||
<property name="windowTitle">
|
<property name="windowTitle">
|
||||||
@ -20,6 +20,15 @@
|
|||||||
margin: 15px;
|
margin: 15px;
|
||||||
color: #6d6d6d;
|
color: #6d6d6d;
|
||||||
border-radius: 18px;
|
border-radius: 18px;
|
||||||
|
background-color: width: 300px;
|
||||||
|
height: 100px;
|
||||||
|
margin: 15px;
|
||||||
|
color: #6d6d6d;
|
||||||
|
border-radius: 18px;
|
||||||
|
background-color: #F4F4F6;
|
||||||
|
}
|
||||||
|
|
||||||
|
QWidget#container {
|
||||||
background-color: #F4F4F6;
|
background-color: #F4F4F6;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -30,10 +39,10 @@ QLabel#lbl_icon {
|
|||||||
|
|
||||||
QLabel#lbl_title {
|
QLabel#lbl_title {
|
||||||
text-align: left;
|
text-align: left;
|
||||||
font-weight: lighter;
|
|
||||||
white-space: nowrap;
|
white-space: nowrap;
|
||||||
padding-right: 10px;
|
padding-right: 10px;
|
||||||
font-size: 19px;
|
font-size: 19px;
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
QLabel#lbl_desc {
|
QLabel#lbl_desc {
|
||||||
@ -44,70 +53,106 @@ QLabel#lbl_desc {
|
|||||||
color: grey;
|
color: grey;
|
||||||
}</string>
|
}</string>
|
||||||
</property>
|
</property>
|
||||||
<layout class="QHBoxLayout" name="horizontalLayout">
|
<layout class="QVBoxLayout" name="verticalLayout_2">
|
||||||
|
<property name="spacing">
|
||||||
|
<number>0</number>
|
||||||
|
</property>
|
||||||
|
<property name="leftMargin">
|
||||||
|
<number>0</number>
|
||||||
|
</property>
|
||||||
|
<property name="topMargin">
|
||||||
|
<number>0</number>
|
||||||
|
</property>
|
||||||
|
<property name="rightMargin">
|
||||||
|
<number>0</number>
|
||||||
|
</property>
|
||||||
|
<property name="bottomMargin">
|
||||||
|
<number>0</number>
|
||||||
|
</property>
|
||||||
<item>
|
<item>
|
||||||
<widget class="QLabel" name="lbl_icon">
|
<widget class="QWidget" name="container" native="true">
|
||||||
<property name="minimumSize">
|
<layout class="QHBoxLayout" name="horizontalLayout">
|
||||||
<size>
|
<property name="spacing">
|
||||||
<width>100</width>
|
<number>0</number>
|
||||||
<height>100</height>
|
</property>
|
||||||
</size>
|
<property name="leftMargin">
|
||||||
</property>
|
<number>0</number>
|
||||||
<property name="styleSheet">
|
</property>
|
||||||
<string notr="true">width: 78px;
|
<property name="topMargin">
|
||||||
|
<number>0</number>
|
||||||
|
</property>
|
||||||
|
<property name="rightMargin">
|
||||||
|
<number>0</number>
|
||||||
|
</property>
|
||||||
|
<property name="bottomMargin">
|
||||||
|
<number>0</number>
|
||||||
|
</property>
|
||||||
|
<item>
|
||||||
|
<widget class="QLabel" name="lbl_icon">
|
||||||
|
<property name="minimumSize">
|
||||||
|
<size>
|
||||||
|
<width>100</width>
|
||||||
|
<height>100</height>
|
||||||
|
</size>
|
||||||
|
</property>
|
||||||
|
<property name="styleSheet">
|
||||||
|
<string notr="true">width: 78px;
|
||||||
height: 70px;
|
height: 70px;
|
||||||
padding: 10px;</string>
|
padding: 10px;</string>
|
||||||
</property>
|
</property>
|
||||||
<property name="text">
|
<property name="text">
|
||||||
<string/>
|
<string/>
|
||||||
</property>
|
</property>
|
||||||
<property name="scaledContents">
|
<property name="scaledContents">
|
||||||
<bool>true</bool>
|
<bool>true</bool>
|
||||||
</property>
|
</property>
|
||||||
|
</widget>
|
||||||
|
</item>
|
||||||
|
<item>
|
||||||
|
<layout class="QVBoxLayout" name="verticalLayout">
|
||||||
|
<item>
|
||||||
|
<widget class="QLabel" name="lbl_title">
|
||||||
|
<property name="minimumSize">
|
||||||
|
<size>
|
||||||
|
<width>200</width>
|
||||||
|
<height>50</height>
|
||||||
|
</size>
|
||||||
|
</property>
|
||||||
|
<property name="maximumSize">
|
||||||
|
<size>
|
||||||
|
<width>200</width>
|
||||||
|
<height>50</height>
|
||||||
|
</size>
|
||||||
|
</property>
|
||||||
|
<property name="text">
|
||||||
|
<string/>
|
||||||
|
</property>
|
||||||
|
</widget>
|
||||||
|
</item>
|
||||||
|
<item>
|
||||||
|
<widget class="QLabel" name="lbl_desc">
|
||||||
|
<property name="minimumSize">
|
||||||
|
<size>
|
||||||
|
<width>200</width>
|
||||||
|
<height>50</height>
|
||||||
|
</size>
|
||||||
|
</property>
|
||||||
|
<property name="maximumSize">
|
||||||
|
<size>
|
||||||
|
<width>200</width>
|
||||||
|
<height>50</height>
|
||||||
|
</size>
|
||||||
|
</property>
|
||||||
|
<property name="text">
|
||||||
|
<string/>
|
||||||
|
</property>
|
||||||
|
</widget>
|
||||||
|
</item>
|
||||||
|
</layout>
|
||||||
|
</item>
|
||||||
|
</layout>
|
||||||
</widget>
|
</widget>
|
||||||
</item>
|
</item>
|
||||||
<item>
|
|
||||||
<layout class="QVBoxLayout" name="verticalLayout">
|
|
||||||
<item>
|
|
||||||
<widget class="QLabel" name="lbl_title">
|
|
||||||
<property name="minimumSize">
|
|
||||||
<size>
|
|
||||||
<width>200</width>
|
|
||||||
<height>50</height>
|
|
||||||
</size>
|
|
||||||
</property>
|
|
||||||
<property name="maximumSize">
|
|
||||||
<size>
|
|
||||||
<width>200</width>
|
|
||||||
<height>50</height>
|
|
||||||
</size>
|
|
||||||
</property>
|
|
||||||
<property name="text">
|
|
||||||
<string/>
|
|
||||||
</property>
|
|
||||||
</widget>
|
|
||||||
</item>
|
|
||||||
<item>
|
|
||||||
<widget class="QLabel" name="lbl_desc">
|
|
||||||
<property name="minimumSize">
|
|
||||||
<size>
|
|
||||||
<width>200</width>
|
|
||||||
<height>50</height>
|
|
||||||
</size>
|
|
||||||
</property>
|
|
||||||
<property name="maximumSize">
|
|
||||||
<size>
|
|
||||||
<width>200</width>
|
|
||||||
<height>50</height>
|
|
||||||
</size>
|
|
||||||
</property>
|
|
||||||
<property name="text">
|
|
||||||
<string/>
|
|
||||||
</property>
|
|
||||||
</widget>
|
|
||||||
</item>
|
|
||||||
</layout>
|
|
||||||
</item>
|
|
||||||
</layout>
|
</layout>
|
||||||
</widget>
|
</widget>
|
||||||
<resources/>
|
<resources/>
|
||||||
|
@ -725,6 +725,7 @@ void Widget::searchApp(QString text)
|
|||||||
// 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);
|
||||||
|
|
||||||
// 关键字搜索处理
|
// 关键字搜索处理
|
||||||
httpClient->get("http://192.168.0.103:8000/appinfo/search")
|
httpClient->get("http://192.168.0.103:8000/appinfo/search")
|
||||||
.header("content-type", "application/json")
|
.header("content-type", "application/json")
|
||||||
@ -743,6 +744,7 @@ void Widget::searchApp(QString text)
|
|||||||
})
|
})
|
||||||
.onError([](QString errorStr) {
|
.onError([](QString errorStr) {
|
||||||
qDebug() << "请求出错:" << errorStr;
|
qDebug() << "请求出错:" << errorStr;
|
||||||
|
sendNotification(QString("请求出错:%1").arg(errorStr));
|
||||||
})
|
})
|
||||||
.timeout(10 * 1000)
|
.timeout(10 * 1000)
|
||||||
.exec();
|
.exec();
|
||||||
|
@ -345,7 +345,7 @@
|
|||||||
<number>0</number>
|
<number>0</number>
|
||||||
</property>
|
</property>
|
||||||
<property name="currentIndex">
|
<property name="currentIndex">
|
||||||
<number>2</number>
|
<number>3</number>
|
||||||
</property>
|
</property>
|
||||||
<widget class="QWidget" name="page">
|
<widget class="QWidget" name="page">
|
||||||
<layout class="QVBoxLayout" name="verticalLayout_4">
|
<layout class="QVBoxLayout" name="verticalLayout_4">
|
||||||
@ -1390,6 +1390,9 @@
|
|||||||
<layout class="QVBoxLayout" name="verticalLayout_3">
|
<layout class="QVBoxLayout" name="verticalLayout_3">
|
||||||
<item>
|
<item>
|
||||||
<widget class="QScrollArea" name="applist_scrollarea">
|
<widget class="QScrollArea" name="applist_scrollarea">
|
||||||
|
<property name="frameShape">
|
||||||
|
<enum>QFrame::NoFrame</enum>
|
||||||
|
</property>
|
||||||
<property name="widgetResizable">
|
<property name="widgetResizable">
|
||||||
<bool>true</bool>
|
<bool>true</bool>
|
||||||
</property>
|
</property>
|
||||||
@ -1398,8 +1401,8 @@
|
|||||||
<rect>
|
<rect>
|
||||||
<x>0</x>
|
<x>0</x>
|
||||||
<y>0</y>
|
<y>0</y>
|
||||||
<width>98</width>
|
<width>881</width>
|
||||||
<height>28</height>
|
<height>659</height>
|
||||||
</rect>
|
</rect>
|
||||||
</property>
|
</property>
|
||||||
</widget>
|
</widget>
|
||||||
|
Loading…
x
Reference in New Issue
Block a user