支持图标跟随主题,改进详情页,加入更好的多线程下载

新的下载会重试一个线程上的错误,一个线程崩溃次数过多会转移到队列里等待重新安排,其他的暂时没写
This commit is contained in:
RigoLigoRLC
2021-11-28 02:11:54 +08:00
parent acf013d8ab
commit 6491b19f6e
17 changed files with 722 additions and 14 deletions

View File

@@ -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);