mirror of
https://gitee.com/spark-store-project/spark-store
synced 2025-12-14 04:42:03 +08:00
应用详情页添加分享和请求更新按钮,设置页面添加更新客户端和清理缓存、读取缓存大小功能
This commit is contained in:
@@ -37,7 +37,10 @@ MainWindow::MainWindow(QWidget *parent)
|
|||||||
menu->addAction(setting);
|
menu->addAction(setting);
|
||||||
|
|
||||||
ui->titlebar->setMenu(menu);
|
ui->titlebar->setMenu(menu);
|
||||||
connect(setting, &QAction::triggered, this, [=]{switchPage(AppPageSettings);});
|
connect(setting, &QAction::triggered, this, [=]{
|
||||||
|
switchPage(AppPageSettings);
|
||||||
|
ui->settingspage->updateUI();
|
||||||
|
});
|
||||||
//主题切换
|
//主题切换
|
||||||
connect(DGuiApplicationHelper::instance(), &DGuiApplicationHelper::themeTypeChanged, this, [=](DGuiApplicationHelper::ColorType themeType) {
|
connect(DGuiApplicationHelper::instance(), &DGuiApplicationHelper::themeTypeChanged, this, [=](DGuiApplicationHelper::ColorType themeType) {
|
||||||
if (themeType == DGuiApplicationHelper::DarkType) {
|
if (themeType == DGuiApplicationHelper::DarkType) {
|
||||||
@@ -107,10 +110,6 @@ MainWindow::MainWindow(QWidget *parent)
|
|||||||
|
|
||||||
connect(backButtom, &QPushButton::clicked, [=]() {
|
connect(backButtom, &QPushButton::clicked, [=]() {
|
||||||
ui->stackedWidget->setCurrentIndex(pageHistory.at(pageHistory.count() - 2));
|
ui->stackedWidget->setCurrentIndex(pageHistory.at(pageHistory.count() - 2));
|
||||||
if (pageHistory.at(pageHistory.count() - 1) == 3) {
|
|
||||||
ui->appintopage->clear();
|
|
||||||
}
|
|
||||||
|
|
||||||
pageHistory.removeLast();
|
pageHistory.removeLast();
|
||||||
if (pageHistory.count() > 1) {
|
if (pageHistory.count() > 1) {
|
||||||
backButtom->show();
|
backButtom->show();
|
||||||
@@ -139,7 +138,6 @@ MainWindow::MainWindow(QWidget *parent)
|
|||||||
ui->buttonGroup->buttons()[i]->setStyleSheet("QPushButton{qproperty-icon: url(data/images/userMangaer/teacher.png);}");
|
ui->buttonGroup->buttons()[i]->setStyleSheet("QPushButton{qproperty-icon: url(data/images/userMangaer/teacher.png);}");
|
||||||
connect(ui->buttonGroup->buttons()[i], &QPushButton::toggled, [=](bool checked) {
|
connect(ui->buttonGroup->buttons()[i], &QPushButton::toggled, [=](bool checked) {
|
||||||
if (checked == true) {
|
if (checked == true) {
|
||||||
ui->appintopage->clear();
|
|
||||||
updateUi(i);
|
updateUi(i);
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
@@ -169,7 +167,9 @@ MainWindow::MainWindow(QWidget *parent)
|
|||||||
connect(ui->applistpage_1, &AppListPage::clicked, this, [=](QUrl spk) {
|
connect(ui->applistpage_1, &AppListPage::clicked, this, [=](QUrl spk) {
|
||||||
openUrl(spk);
|
openUrl(spk);
|
||||||
});
|
});
|
||||||
|
connect(ui->settingspage, &SettingsPage::openUrl, this, [=](QUrl spk) {
|
||||||
|
openUrl(spk);
|
||||||
|
});
|
||||||
emit DGuiApplicationHelper::instance()->themeTypeChanged(DGuiApplicationHelper::instance()->themeType());
|
emit DGuiApplicationHelper::instance()->themeTypeChanged(DGuiApplicationHelper::instance()->themeType());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -51,6 +51,7 @@ void AppIntoPage::openUrl(QUrl url)
|
|||||||
{
|
{
|
||||||
spk=url;
|
spk=url;
|
||||||
SparkAPI *api=new SparkAPI(this);
|
SparkAPI *api=new SparkAPI(this);
|
||||||
|
clear();
|
||||||
connect(api,&SparkAPI::finishedObject,[=](QJsonObject appinfo){
|
connect(api,&SparkAPI::finishedObject,[=](QJsonObject appinfo){
|
||||||
|
|
||||||
info = appinfo;
|
info = appinfo;
|
||||||
@@ -316,3 +317,28 @@ void AppIntoPage::on_pushButton_3_clicked()
|
|||||||
ui->pushButton_3->setEnabled(true);
|
ui->pushButton_3->setEnabled(true);
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void AppIntoPage::on_shareButton_clicked()
|
||||||
|
{
|
||||||
|
qDebug() << "Share" << spk;
|
||||||
|
|
||||||
|
QClipboard *clipboard = QApplication::clipboard();
|
||||||
|
clipboard->setText(spk.toString());
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
void AppIntoPage::on_updateButton_clicked()
|
||||||
|
{
|
||||||
|
QString feedbackSpk = "spk://store/chat/store.spark-app.feedback";
|
||||||
|
QFile actionSubmissionClientStatus("/opt/durapps/store.spark-app.feedback");
|
||||||
|
if (actionSubmissionClientStatus.exists())
|
||||||
|
{
|
||||||
|
qDebug() << "反馈器存在";
|
||||||
|
QProcess::startDetached("sh /opt/durapps/store.spark-app.feedback/launch.sh");
|
||||||
|
}
|
||||||
|
else{
|
||||||
|
qDebug() << "反馈器不存在,跳转页面";
|
||||||
|
openUrl(feedbackSpk);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -5,6 +5,7 @@
|
|||||||
#include <QUrl>
|
#include <QUrl>
|
||||||
#include <QString>
|
#include <QString>
|
||||||
#include <QtConcurrent>
|
#include <QtConcurrent>
|
||||||
|
#include <QClipboard>
|
||||||
#include "backend/sparkapi.h"
|
#include "backend/sparkapi.h"
|
||||||
#include "backend/image_show.h"
|
#include "backend/image_show.h"
|
||||||
#include "widgets/downloadlistwidget.h"
|
#include "widgets/downloadlistwidget.h"
|
||||||
@@ -29,6 +30,10 @@ private slots:
|
|||||||
|
|
||||||
void on_pushButton_3_clicked();
|
void on_pushButton_3_clicked();
|
||||||
|
|
||||||
|
void on_shareButton_clicked();
|
||||||
|
|
||||||
|
void on_updateButton_clicked();
|
||||||
|
|
||||||
private:
|
private:
|
||||||
QJsonObject info;
|
QJsonObject info;
|
||||||
QPixmap iconpixmap;
|
QPixmap iconpixmap;
|
||||||
|
|||||||
@@ -529,16 +529,16 @@
|
|||||||
</spacer>
|
</spacer>
|
||||||
</item>
|
</item>
|
||||||
<item>
|
<item>
|
||||||
<widget class="QPushButton" name="pushButton">
|
<widget class="QPushButton" name="shareButton">
|
||||||
<property name="text">
|
<property name="text">
|
||||||
<string>PushButton</string>
|
<string>Share</string>
|
||||||
</property>
|
</property>
|
||||||
</widget>
|
</widget>
|
||||||
</item>
|
</item>
|
||||||
<item>
|
<item>
|
||||||
<widget class="QPushButton" name="pushButton_2">
|
<widget class="QPushButton" name="updateButton">
|
||||||
<property name="text">
|
<property name="text">
|
||||||
<string>PushButton</string>
|
<string>Request Update</string>
|
||||||
</property>
|
</property>
|
||||||
</widget>
|
</widget>
|
||||||
</item>
|
</item>
|
||||||
|
|||||||
@@ -1,6 +1,6 @@
|
|||||||
#include "settingspage.h"
|
#include "settingspage.h"
|
||||||
#include "ui_settingspage.h"
|
#include "ui_settingspage.h"
|
||||||
|
bool SettingsPage::isdownload = false;
|
||||||
SettingsPage::SettingsPage(QWidget *parent) :
|
SettingsPage::SettingsPage(QWidget *parent) :
|
||||||
QWidget(parent),
|
QWidget(parent),
|
||||||
ui(new Ui::SettingsPage)
|
ui(new Ui::SettingsPage)
|
||||||
@@ -116,3 +116,104 @@ void SettingsPage::on_comboBox_server_currentIndexChanged(const QString &arg1)
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void SettingsPage::setIsDownload(bool isdownload)
|
||||||
|
{
|
||||||
|
SettingsPage::isdownload = isdownload;
|
||||||
|
}
|
||||||
|
|
||||||
|
void SettingsPage::updateUI()
|
||||||
|
{
|
||||||
|
if(isdownload)
|
||||||
|
{
|
||||||
|
ui->pushButton_clear->setEnabled(false);
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
ui->pushButton_clear->setEnabled(true);
|
||||||
|
}
|
||||||
|
// 显示缓存占用空间
|
||||||
|
quint64 tmp_size = dirFileSize(QString::fromUtf8(TMP_PATH));
|
||||||
|
QString tmp_size_str;
|
||||||
|
if(tmp_size < 1024)
|
||||||
|
{
|
||||||
|
tmp_size_str = QString::number(tmp_size) + "B";
|
||||||
|
}
|
||||||
|
else if(tmp_size < (1024 * 1024))
|
||||||
|
{
|
||||||
|
tmp_size_str = QString::number(0.01 * int(100 * (tmp_size / 1024))) + "KB";
|
||||||
|
}
|
||||||
|
else if(tmp_size<(1024*1024*1024))
|
||||||
|
{
|
||||||
|
tmp_size_str = QString::number(0.01 * int(100 * (tmp_size / (1024 * 1024)))) + "MB";
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
tmp_size_str = QString::number(0.01 * int(100 * (tmp_size / (1024 * 1024 * 1024)))) + "GB";
|
||||||
|
}
|
||||||
|
|
||||||
|
ui->tmp_size_ui->setText(tmp_size_str);
|
||||||
|
}
|
||||||
|
|
||||||
|
quint64 SettingsPage::dirFileSize(const QString &path)
|
||||||
|
{
|
||||||
|
QDir dir(path);
|
||||||
|
quint64 size = 0;
|
||||||
|
// dir.entryInfoList(QDir::Files); // 返回文件信息
|
||||||
|
foreach(QFileInfo fileInfo, dir.entryInfoList(QDir::Files))
|
||||||
|
{
|
||||||
|
// 计算文件大小
|
||||||
|
size += quint64(fileInfo.size());
|
||||||
|
}
|
||||||
|
// dir.entryList(QDir::Dirs|QDir::NoDotAndDotDot); // 返回所有子目录,并进行过滤
|
||||||
|
foreach(QString subDir, dir.entryList(QDir::Dirs | QDir::NoDotAndDotDot))
|
||||||
|
{
|
||||||
|
// 若存在子目录,则递归调用 dirFileSize() 函数
|
||||||
|
size += dirFileSize(path + QDir::separator() + subDir);
|
||||||
|
}
|
||||||
|
return size;
|
||||||
|
}
|
||||||
|
|
||||||
|
void SettingsPage::on_pushButton_updateApt_clicked()
|
||||||
|
{
|
||||||
|
QtConcurrent::run([=]()
|
||||||
|
{
|
||||||
|
ui->pushButton_updateApt->setEnabled(false);
|
||||||
|
ui->label_aptserver->setText(tr("Updating, please wait..."));
|
||||||
|
|
||||||
|
emit openUrl(QUrl("spk://store/tools/spark-store"));
|
||||||
|
ui->label_aptserver->setText(tr(""));
|
||||||
|
|
||||||
|
ui->pushButton_updateApt->setEnabled(true);
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
void SettingsPage::on_pushButton_clear_clicked()
|
||||||
|
{
|
||||||
|
QtConcurrent::run([=]()
|
||||||
|
{
|
||||||
|
ui->pushButton_clear->setEnabled(false);
|
||||||
|
|
||||||
|
QDir tmpdir("/tmp/spark-store");
|
||||||
|
tmpdir.setFilter(QDir::Files);
|
||||||
|
int quantity = int(tmpdir.count());
|
||||||
|
for(int i = 0; i < quantity; i++)
|
||||||
|
{
|
||||||
|
tmpdir.remove(tmpdir[i]);
|
||||||
|
}
|
||||||
|
ui->pushButton_clear->setEnabled(true);
|
||||||
|
updateUI();
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
void SettingsPage::on_pushButton_clearWebCache_clicked()
|
||||||
|
{
|
||||||
|
QtConcurrent::run([=]()
|
||||||
|
{
|
||||||
|
QString dataLocal = QStandardPaths::writableLocation(QStandardPaths::AppLocalDataLocation);
|
||||||
|
QDir cacheDir(dataLocal );
|
||||||
|
cacheDir.removeRecursively();
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -8,6 +8,8 @@
|
|||||||
#include <QSettings>
|
#include <QSettings>
|
||||||
#include <QtConcurrent>
|
#include <QtConcurrent>
|
||||||
#include "../backend/sparkapi.h"
|
#include "../backend/sparkapi.h"
|
||||||
|
#define TMP_PATH "/tmp/spark-store"
|
||||||
|
|
||||||
namespace Ui {
|
namespace Ui {
|
||||||
class SettingsPage;
|
class SettingsPage;
|
||||||
}
|
}
|
||||||
@@ -17,6 +19,8 @@ class SettingsPage : public QWidget
|
|||||||
Q_OBJECT
|
Q_OBJECT
|
||||||
|
|
||||||
public:
|
public:
|
||||||
|
static void setIsDownload(bool isdownload);
|
||||||
|
void updateUI();
|
||||||
explicit SettingsPage(QWidget *parent = nullptr);
|
explicit SettingsPage(QWidget *parent = nullptr);
|
||||||
void setTheme(bool dark);
|
void setTheme(bool dark);
|
||||||
~SettingsPage();
|
~SettingsPage();
|
||||||
@@ -26,11 +30,22 @@ private slots:
|
|||||||
|
|
||||||
void on_comboBox_server_currentIndexChanged(const QString &arg1);
|
void on_comboBox_server_currentIndexChanged(const QString &arg1);
|
||||||
|
|
||||||
|
void on_pushButton_updateApt_clicked();
|
||||||
|
|
||||||
|
void on_pushButton_clear_clicked();
|
||||||
|
|
||||||
|
void on_pushButton_clearWebCache_clicked();
|
||||||
|
|
||||||
private:
|
private:
|
||||||
|
static bool isdownload;
|
||||||
bool configCanSave;
|
bool configCanSave;
|
||||||
|
quint64 dirFileSize(const QString &path);
|
||||||
void readServerList();
|
void readServerList();
|
||||||
void initConfig();
|
void initConfig();
|
||||||
Ui::SettingsPage *ui;
|
Ui::SettingsPage *ui;
|
||||||
|
|
||||||
|
signals:
|
||||||
|
void openUrl(QUrl spk);
|
||||||
};
|
};
|
||||||
|
|
||||||
#endif // SETTINGSPAGE_H
|
#endif // SETTINGSPAGE_H
|
||||||
|
|||||||
Reference in New Issue
Block a user