mirror of
https://gitee.com/spark-store-project/spark-store
synced 2025-12-13 12:22:05 +08:00
添加应用详情页面
This commit is contained in:
55
inc/page/spkpageappdetails.h
Normal file
55
inc/page/spkpageappdetails.h
Normal file
@@ -0,0 +1,55 @@
|
||||
// SPDX-License-Identifier: GPL-3.0-only
|
||||
|
||||
#pragma once
|
||||
|
||||
#include <QLabel>
|
||||
#include <QScrollArea>
|
||||
#include <QVBoxLayout>
|
||||
#include <QFormLayout>
|
||||
#include "page/spkpagebase.h"
|
||||
#include "spkstretchlayout.h"
|
||||
|
||||
namespace SpkUi
|
||||
{
|
||||
class SpkDetailEntry;
|
||||
|
||||
class SpkPageAppDetails : public SpkPageBase
|
||||
{
|
||||
Q_OBJECT
|
||||
public:
|
||||
SpkPageAppDetails(QWidget *parent = nullptr);
|
||||
|
||||
void LoadAppResources(QString pkgName, QString icon, QStringList screenshots, QStringList tags);
|
||||
|
||||
private:
|
||||
|
||||
public slots:
|
||||
void ResourceAcquisitionFinished(int id, ResourceResult result);
|
||||
void Activated();
|
||||
|
||||
public:
|
||||
static constexpr QSize IconSize { 144, 144 };
|
||||
|
||||
QScrollArea *mMainArea;
|
||||
QWidget *mDetailWidget, *mIconTitleWidget, *mWid4MainArea;
|
||||
QLabel *mAppTitle, *mAppIcon, *mAppDescription, *mAppShortDesc, *mPkgName, *mVersion;
|
||||
SpkDetailEntry *mAuthor, *mContributor, *mSite, *mArch, *mSize;
|
||||
SpkStretchLayout *mDetailLay;
|
||||
QVBoxLayout *mMainLay, *mTitleLay, *mLay4MainArea;
|
||||
QHBoxLayout *mIconTitleLay;
|
||||
|
||||
};
|
||||
|
||||
class SpkDetailEntry : public QWidget
|
||||
{
|
||||
Q_OBJECT
|
||||
public:
|
||||
SpkDetailEntry(QWidget *parent = nullptr);
|
||||
void SetTitle(const QString &s) { mTitle.setText(s); }
|
||||
void SetValue(const QString &s) { mField.setText(s); }
|
||||
|
||||
private:
|
||||
QLabel mTitle, mField;
|
||||
QHBoxLayout mLay;
|
||||
};
|
||||
}
|
||||
@@ -43,7 +43,7 @@ namespace SpkUi
|
||||
QString mKeyword;
|
||||
|
||||
signals:
|
||||
void ApplicationClicked(QString name, QString pkgName);
|
||||
void ApplicationClicked(int appId);
|
||||
void SwitchListPage(int categoryId, int page);
|
||||
void SwitchSearchPage(QString keyword, int page);
|
||||
|
||||
|
||||
@@ -12,6 +12,8 @@
|
||||
#include <QHBoxLayout>
|
||||
#include <QSlider>
|
||||
#include "spkappitem.h"
|
||||
#include "spkstretchlayout.h"
|
||||
#include "page/spkpageappdetails.h"
|
||||
|
||||
#include "spkloading.h"
|
||||
|
||||
@@ -40,6 +42,9 @@ namespace SpkUi
|
||||
QSlider *SlideV;
|
||||
SpkLoading *Loading;
|
||||
SpkAppItem *AppItem;
|
||||
SpkStretchLayout *DetailsLay;
|
||||
SpkDetailEntry *Detail1, *Detail2, *Detail3;
|
||||
QWidget *DetailsWidget;
|
||||
|
||||
QLineEdit *PopupText;
|
||||
QPushButton *ShowPopup,
|
||||
|
||||
@@ -18,6 +18,8 @@ class SpkAppItem : public QWidget
|
||||
|
||||
protected:
|
||||
void paintEvent(QPaintEvent *e);
|
||||
void mousePressEvent(QMouseEvent *e);
|
||||
void mouseReleaseEvent(QMouseEvent *e);
|
||||
|
||||
public:
|
||||
static constexpr int IconSize = 72;
|
||||
@@ -29,7 +31,11 @@ class SpkAppItem : public QWidget
|
||||
ElidedLabel *mDescription;
|
||||
int mAppId;
|
||||
|
||||
bool mPressCond;
|
||||
|
||||
QVBoxLayout *mLayText;
|
||||
QHBoxLayout *mMainLay;
|
||||
|
||||
signals:
|
||||
void clicked(int);
|
||||
};
|
||||
|
||||
@@ -16,6 +16,7 @@
|
||||
#include "spkfocuslineedit.h"
|
||||
#include "page/spkpageuitest.h"
|
||||
#include "page/spkpageapplist.h"
|
||||
#include "page/spkpageappdetails.h"
|
||||
|
||||
class QNetworkReply;
|
||||
|
||||
@@ -25,6 +26,7 @@ namespace SpkUi
|
||||
{
|
||||
PgInvalid = -1,
|
||||
PgAppList,
|
||||
PgAppDetails,
|
||||
PgQssTest // Must be at last
|
||||
};
|
||||
|
||||
@@ -86,7 +88,7 @@ namespace SpkUi
|
||||
mLastSelectedItem = nullptr;
|
||||
}
|
||||
mLastCheckedBtn = b;
|
||||
emit SwitchToPage(b->property("spk_pageno").toInt());
|
||||
emit SwitchToPage(static_cast<SpkStackedPages>(b->property("spk_pageno").toInt()));
|
||||
}
|
||||
void TreeItemSelected(QTreeWidgetItem *item, int column)
|
||||
{
|
||||
@@ -103,7 +105,8 @@ namespace SpkUi
|
||||
if(item->data(column, RoleItemIsCategory).toBool())
|
||||
emit SwitchToCategory(item->data(column, RoleItemCategoryPageId).toInt(), 0);
|
||||
else
|
||||
emit SwitchToPage(item->data(column, RoleItemCategoryPageId).toInt());
|
||||
emit SwitchToPage(static_cast<SpkStackedPages>(
|
||||
item->data(column, RoleItemCategoryPageId).toInt()));
|
||||
}
|
||||
void UnusableItemSelected(QTreeWidgetItem *i)
|
||||
{
|
||||
@@ -120,7 +123,7 @@ namespace SpkUi
|
||||
|
||||
signals:
|
||||
void SwitchToCategory(int aCategoryId, int aPage);
|
||||
void SwitchToPage(int aPageId);
|
||||
void SwitchToPage(SpkStackedPages aPageId);
|
||||
};
|
||||
|
||||
class SpkMainWidget : public QFrame
|
||||
@@ -146,7 +149,9 @@ namespace SpkUi
|
||||
QMap<int, QTreeWidgetItem> *CategoryItemMap;
|
||||
SpkSidebarSelector *SidebarMgr;
|
||||
|
||||
QTreeWidgetItem *CategoryParentItem;
|
||||
QTreeWidgetItem *CategoryParentItem,
|
||||
*AppDetailsItem,
|
||||
*UiTestItem;
|
||||
|
||||
// Title bar search bar
|
||||
SpkFocusLineEdit *SearchEdit;
|
||||
@@ -156,6 +161,7 @@ namespace SpkUi
|
||||
//Pages
|
||||
SpkPageUiTest *PageQssTest;
|
||||
SpkPageAppList *PageAppList;
|
||||
SpkPageAppDetails *PageAppDetails;
|
||||
};
|
||||
}
|
||||
|
||||
@@ -175,7 +181,8 @@ class SpkMainWindow : public SpkWindow
|
||||
|
||||
private:
|
||||
QPointer<QNetworkReply> mCategoryGetReply,
|
||||
mCategoryAppListGetReply;
|
||||
mCategoryAppListGetReply,
|
||||
mAppDetailsGetReply;
|
||||
SpkUi::SpkStackedPages mCurrentPage = SpkUi::PgInvalid;
|
||||
|
||||
public slots:
|
||||
@@ -191,7 +198,11 @@ class SpkMainWindow : public SpkWindow
|
||||
// Search a keyword (and switch pages)
|
||||
void SearchKeyword(QString aKeyword, int aPage);
|
||||
void SearchDataReceived();
|
||||
// Enter the details page of an application (and switch pages)
|
||||
void EnterAppDetails(int aAppId);
|
||||
void AppDetailsDataReceived();
|
||||
|
||||
private:
|
||||
void PopulateAppList(QJsonObject appData, QString &&keyword);
|
||||
void PopulateAppDetails(QJsonObject appDetails);
|
||||
};
|
||||
|
||||
@@ -30,6 +30,7 @@ namespace SpkUi
|
||||
TextOnGlobalBgnd,
|
||||
TextOnControlsBgnd,
|
||||
TextLighter,
|
||||
TextEvenLighter,
|
||||
TextDisabled,
|
||||
GlossyEdge,
|
||||
ShadesEdge,
|
||||
|
||||
@@ -26,4 +26,5 @@ namespace SpkUtils
|
||||
|
||||
QString CutFileName(QString);
|
||||
QString CutPath(QString);
|
||||
QString BytesToSize(size_t s, int prec = 2);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user