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