mirror of
https://gitee.com/spark-store-project/spark-store
synced 2025-12-14 12:52:04 +08:00
支持图标跟随主题,改进详情页,加入更好的多线程下载
新的下载会重试一个线程上的错误,一个线程崩溃次数过多会转移到队列里等待重新安排,其他的暂时没写
This commit is contained in:
@@ -53,6 +53,11 @@ namespace SpkUi
|
||||
// TODO: tags
|
||||
}
|
||||
|
||||
void SpkPageAppDetails::SetWebsiteLink(QString url)
|
||||
{
|
||||
mWebsite->setText(QString("<a href=\"%1\">%1</a>").arg(url));
|
||||
}
|
||||
|
||||
SpkPageAppDetails::SpkPageAppDetails(QWidget *parent) : SpkPageBase(parent)
|
||||
{
|
||||
mMainArea = new QScrollArea;
|
||||
@@ -81,6 +86,7 @@ namespace SpkUi
|
||||
mAppShortDesc->setSizePolicy(QSizePolicy::MinimumExpanding, QSizePolicy::Preferred);
|
||||
mAppShortDesc->setMinimumWidth(100);
|
||||
mVersion = new QLabel;
|
||||
mWebsite = new QLabel;
|
||||
mPkgName = new QLabel;
|
||||
mPkgName->setObjectName("styDetPkg");
|
||||
|
||||
@@ -90,6 +96,7 @@ namespace SpkUi
|
||||
mTitleLay->addWidget(mVersion);
|
||||
mTitleLay->addWidget(mAppShortDesc);
|
||||
mTitleLay->addWidget(mPkgName);
|
||||
mTitleLay->addWidget(mWebsite);
|
||||
mTitleLay->setSpacing(0);
|
||||
|
||||
mIconTitleLay = new QHBoxLayout;
|
||||
@@ -118,7 +125,7 @@ namespace SpkUi
|
||||
mDetailLay->addWidget(mContributor);
|
||||
mDetailLay->addWidget(mSize);
|
||||
mDetailLay->addWidget(mArch);
|
||||
mDetailLay->addWidget(mSite);
|
||||
// mDetailLay->addWidget(mSite);
|
||||
|
||||
// mDetailWidget = new QWidget;
|
||||
// mDetailWidget->setLayout(mDetailLay);
|
||||
@@ -133,6 +140,9 @@ namespace SpkUi
|
||||
mWid4MainArea->setLayout(mMainLay);
|
||||
|
||||
mMainArea->setWidget(mWid4MainArea);
|
||||
|
||||
mWebsite->setTextFormat(Qt::RichText);
|
||||
mWebsite->setOpenExternalLinks(true);
|
||||
}
|
||||
|
||||
void SpkPageAppDetails::ResourceAcquisitionFinished(int id, ResourceResult result)
|
||||
@@ -178,4 +188,4 @@ namespace SpkUi
|
||||
setMinimumWidth(300);
|
||||
setAutoFillBackground(true);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -23,6 +23,15 @@ SpkMainWindow::SpkMainWindow(QWidget *parent) : SpkWindow(parent)
|
||||
move(size.width(), size.height());
|
||||
}
|
||||
|
||||
void SpkMainWindow::SwitchDayNightTheme()
|
||||
{
|
||||
if(SpkUi::CurrentStyle == SpkUi::Dark)
|
||||
SpkUi::SetGlobalStyle(SpkUi::Light, true);
|
||||
else
|
||||
SpkUi::SetGlobalStyle(SpkUi::Dark, true);
|
||||
ReloadThemedUiIcons();
|
||||
}
|
||||
|
||||
void SpkMainWindow::SwitchToPage(SpkUi::SpkStackedPages page)
|
||||
{
|
||||
if(mCurrentPage != page)
|
||||
@@ -296,7 +305,8 @@ void SpkMainWindow::PopulateAppDetails(QJsonObject appDetails)
|
||||
w->mAppDescription->setText(details);
|
||||
w->mAuthor->SetValue(author);
|
||||
w->mContributor->SetValue(contributor);
|
||||
w->mSite->SetValue(site);
|
||||
// w->mSite->SetValue(site); // Doesn't look good, I disabled it temporarily. Better solution?
|
||||
w->SetWebsiteLink(site);
|
||||
w->mArch->SetValue(arch);
|
||||
w->mSize->SetValue(SpkUtils::BytesToSize(packageSize));
|
||||
w->mVersion->setText(version);
|
||||
@@ -306,6 +316,12 @@ void SpkMainWindow::PopulateAppDetails(QJsonObject appDetails)
|
||||
w->LoadAppResources(pkgName, iconPath, screenshots, tags);
|
||||
}
|
||||
|
||||
void SpkMainWindow::ReloadThemedUiIcons()
|
||||
{
|
||||
for(auto &i : mThemedUiIconReferences)
|
||||
i.first->setIcon(SpkUi::GetThemedIcon(i.second));
|
||||
}
|
||||
|
||||
// ==================== Main Window Initialization ====================
|
||||
|
||||
void SpkMainWindow::Initialize()
|
||||
@@ -322,6 +338,17 @@ void SpkMainWindow::Initialize()
|
||||
[=](){ emit SearchKeyword(ui->SearchEdit->text(), 1); });
|
||||
connect(ui->PageAppList, &SpkUi::SpkPageAppList::ApplicationClicked,
|
||||
this, &SpkMainWindow::EnterAppDetails);
|
||||
connect(ui->BtnDayNight, &QPushButton::pressed,
|
||||
this, &SpkMainWindow::SwitchDayNightTheme);
|
||||
if(SpkUi::States::IsUsingDtkPlugin)
|
||||
{
|
||||
connect(SpkUi::DtkPlugin, &SpkDtkPlugin::DarkLightThemeChanged,
|
||||
this, &SpkMainWindow::ReloadThemedUiIcons);
|
||||
}
|
||||
|
||||
// Register themed button icons
|
||||
mThemedUiIconReferences.append({ ui->BtnSettings, "settings" });
|
||||
mThemedUiIconReferences.append({ ui->BtnDayNight, "daynight" });
|
||||
}
|
||||
|
||||
// ==================== Main Widget Initialization ====================
|
||||
@@ -384,8 +411,17 @@ SpkUi::SpkMainWidget::SpkMainWidget(QWidget *parent) : QFrame(parent)
|
||||
BtnSettings->setProperty("spk_pageno", 0);
|
||||
SidebarMgr->BindPageSwitcherButton(BtnSettings);
|
||||
|
||||
BtnDayNight = new QPushButton(this);
|
||||
BtnDayNight->setObjectName("styPlainChkBtn");
|
||||
BtnDayNight->setSizePolicy(QSizePolicy::Fixed, QSizePolicy::Fixed);
|
||||
BtnDayNight->setMaximumSize({ 40, 40 });
|
||||
BtnDayNight->setMinimumSize({ 40, 40 });
|
||||
BtnDayNight->setIconSize(QSize(20, 20));
|
||||
BtnDayNight->setIcon(SpkUi::GetThemedIcon("daynight"));
|
||||
|
||||
HLaySideTop->addWidget(StoreIcon);
|
||||
HLaySideTop->addStretch();
|
||||
HLaySideTop->addWidget(BtnDayNight);
|
||||
HLaySideTop->addWidget(BtnSettings);
|
||||
VLaySidebar->addLayout(HLaySideTop);
|
||||
|
||||
|
||||
@@ -20,6 +20,7 @@
|
||||
#include "spkmsgbox.h"
|
||||
#include "spkpopup.h"
|
||||
#include "spklogging.h"
|
||||
#include "spkstore.h"
|
||||
|
||||
namespace SpkUi
|
||||
{
|
||||
|
||||
Reference in New Issue
Block a user