mirror of
https://gitee.com/spark-store-project/spark-store
synced 2025-05-17 14:49:50 +08:00
format: 代码格式化
This commit is contained in:
parent
89a3ab0b4c
commit
fd4fdbe970
src
@ -30,7 +30,6 @@ void DownloadController::setFilename(QString filename)
|
||||
this->filename = filename;
|
||||
}
|
||||
|
||||
|
||||
bool checkMeatlink(QString metaUrl)
|
||||
{
|
||||
QFile metaStatus("/tmp/spark-store/metaStatus.txt");
|
||||
|
@ -1,13 +1,12 @@
|
||||
#include "image_show.h"
|
||||
|
||||
#include <QHBoxLayout>
|
||||
#include <QScreen> // Qt5 不再建议使用 QDesktopWidget
|
||||
#include <QScreen> // Qt5 不再建议使用 QDesktopWidget
|
||||
#include <QGuiApplication>
|
||||
|
||||
image_show::image_show(QWidget *parent) :
|
||||
QWidget(parent),
|
||||
m_dialog(new big_image),
|
||||
m_label(new QLabel)
|
||||
image_show::image_show(QWidget *parent) : QWidget(parent),
|
||||
m_dialog(new big_image),
|
||||
m_label(new QLabel)
|
||||
{
|
||||
QHBoxLayout *layout = new QHBoxLayout;
|
||||
layout->addWidget(m_label);
|
||||
@ -27,7 +26,7 @@ void image_show::setImage(QPixmap image)
|
||||
desktop_w = QGuiApplication::primaryScreen()->geometry().width();
|
||||
desktop_h = QGuiApplication::primaryScreen()->geometry().height();
|
||||
|
||||
if(screen0.width() > (desktop_w - 20) || screen0.height() > (desktop_h - 20))
|
||||
if (screen0.width() > (desktop_w - 20) || screen0.height() > (desktop_h - 20))
|
||||
{
|
||||
re_screen1 = screen0.scaled(QSize(desktop_w - 20, desktop_h - 20), Qt::KeepAspectRatio, Qt::SmoothTransformation);
|
||||
m_image = QPixmap::fromImage(re_screen1);
|
||||
@ -48,7 +47,7 @@ void image_show::mousePressEvent(QMouseEvent *)
|
||||
// 识别主屏幕尺寸并设置 widget 大小
|
||||
m_dialog->setFixedSize(desktop_w, desktop_h);
|
||||
|
||||
m_dialog->move(0,0);
|
||||
m_dialog->move(0, 0);
|
||||
}
|
||||
image_show::~image_show()
|
||||
{
|
||||
|
@ -7,7 +7,7 @@ QString SparkAPI::serverUrl = "";
|
||||
SparkAPI::SparkAPI(QObject *parent) : QObject(parent)
|
||||
{
|
||||
QSettings readConfig(QDir::homePath() + "/.config/spark-store/config.ini", QSettings::IniFormat);
|
||||
if(!readConfig.value("server/choose").toString().isEmpty() && readConfig.value("server/updated").toString() == "TRUE")
|
||||
if (!readConfig.value("server/choose").toString().isEmpty() && readConfig.value("server/updated").toString() == "TRUE")
|
||||
{
|
||||
SparkAPI::setServerUrl(readConfig.value("server/choose").toString());
|
||||
}
|
||||
@ -15,9 +15,10 @@ SparkAPI::SparkAPI(QObject *parent) : QObject(parent)
|
||||
void SparkAPI::get(QUrl url)
|
||||
{
|
||||
QNetworkRequest request;
|
||||
HttpRequest *httprequest=new HttpRequest;
|
||||
request.setUrl(QUrl(url.toString().replace("+","%2B")));
|
||||
connect(httprequest,&HttpRequest::finished,[=](QString data){
|
||||
HttpRequest *httprequest = new HttpRequest;
|
||||
request.setUrl(QUrl(url.toString().replace("+", "%2B")));
|
||||
connect(httprequest, &HttpRequest::finished, [=](QString data)
|
||||
{
|
||||
QByteArray arr = data.toUtf8();
|
||||
//解析Json
|
||||
QJsonParseError error;
|
||||
@ -30,36 +31,35 @@ void SparkAPI::get(QUrl url)
|
||||
emit finishedObject(doc);
|
||||
}
|
||||
|
||||
httprequest->deleteLater();
|
||||
});
|
||||
httprequest->deleteLater(); });
|
||||
httprequest->getRequest(request);
|
||||
}
|
||||
void SparkAPI::getRAW(QUrl url)
|
||||
{
|
||||
QNetworkRequest request;
|
||||
HttpRequest *httprequest=new HttpRequest;
|
||||
request.setUrl(QUrl(url.toString().replace("+","%2B")));
|
||||
connect(httprequest,&HttpRequest::finished,[=](QString data){
|
||||
HttpRequest *httprequest = new HttpRequest;
|
||||
request.setUrl(QUrl(url.toString().replace("+", "%2B")));
|
||||
connect(httprequest, &HttpRequest::finished, [=](QString data)
|
||||
{
|
||||
emit finishedRAW(data);
|
||||
httprequest->deleteLater();
|
||||
});
|
||||
httprequest->deleteLater(); });
|
||||
httprequest->getRequest(request);
|
||||
}
|
||||
void SparkAPI::getAppList(QString type)
|
||||
{
|
||||
get(QUrl(getServerUrl()+"store/"+type+"/applist.json"));
|
||||
get(QUrl(getServerUrl() + "store/" + type + "/applist.json"));
|
||||
}
|
||||
void SparkAPI::getSearchList(QString keyword)
|
||||
{
|
||||
get(QUrl("https://search.deepinos.org.cn/appinfo/search?keyword="+keyword));
|
||||
get(QUrl("https://search.deepinos.org.cn/appinfo/search?keyword=" + keyword));
|
||||
}
|
||||
void SparkAPI::getAppInfo(QUrl spk)
|
||||
{
|
||||
get(QUrl(getServerUrl()+"store"+spk.path().replace("+","%2B") + "/app.json"));
|
||||
get(QUrl(getServerUrl() + "store" + spk.path().replace("+", "%2B") + "/app.json"));
|
||||
}
|
||||
void SparkAPI::getAppDownloadTimes(QUrl spk)
|
||||
{
|
||||
getRAW(QUrl(getServerUrl()+"store"+spk.path().replace("+","%2B") + "/download-times.txt"));
|
||||
getRAW(QUrl(getServerUrl() + "store" + spk.path().replace("+", "%2B") + "/download-times.txt"));
|
||||
}
|
||||
QString SparkAPI::getServerUrl()
|
||||
{
|
||||
|
@ -3,10 +3,9 @@
|
||||
DBusSparkStoreService::DBusSparkStoreService(QObject *parent)
|
||||
: QDBusAbstractAdaptor(parent)
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
void DBusSparkStoreService::activeWindow(const QString & arg)
|
||||
void DBusSparkStoreService::activeWindow(const QString &arg)
|
||||
{
|
||||
emit sigOpenUrl(arg);
|
||||
}
|
||||
|
103
src/main.cpp
103
src/main.cpp
@ -16,55 +16,57 @@ int main(int argc, char *argv[])
|
||||
{
|
||||
// Get build time
|
||||
static const QString version = "Version 4.1.1";
|
||||
static const QDate buildDate = QLocale( QLocale::English ).toDate( QString(__DATE__).replace(" ", " 0"), "MMM dd yyyy");
|
||||
static const QDate buildDate = QLocale(QLocale::English).toDate(QString(__DATE__).replace(" ", " 0"), "MMM dd yyyy");
|
||||
static const QTime buildTime = QTime::fromString(__TIME__, "hh:mm:ss");
|
||||
|
||||
//设置桌面环境环境变量
|
||||
if (!QString(qgetenv("XDG_CURRENT_DESKTOP")).toLower().startsWith("deepin")) {
|
||||
// 设置桌面环境环境变量
|
||||
if (!QString(qgetenv("XDG_CURRENT_DESKTOP")).toLower().startsWith("deepin"))
|
||||
{
|
||||
setenv("XDG_CURRENT_DESKTOP", "Deepin", 1);
|
||||
}
|
||||
bool isWayland = false;
|
||||
auto e = QProcessEnvironment::systemEnvironment();
|
||||
QString XDG_SESSION_TYPE = e.value(QStringLiteral("XDG_SESSION_TYPE"));
|
||||
QString WAYLAND_DISPLAY = e.value(QStringLiteral("WAYLAND_DISPLAY"));
|
||||
if (XDG_SESSION_TYPE == QLatin1String("wayland") || WAYLAND_DISPLAY.contains(QLatin1String("wayland"), Qt::CaseInsensitive)){
|
||||
if (XDG_SESSION_TYPE == QLatin1String("wayland") || WAYLAND_DISPLAY.contains(QLatin1String("wayland"), Qt::CaseInsensitive))
|
||||
{
|
||||
isWayland = true;
|
||||
}
|
||||
qDebug() << "Wayland enabled:" << isWayland;
|
||||
|
||||
if(isWayland && !Dtk::Core::DSysInfo::isDDE()){
|
||||
if (isWayland && !Dtk::Core::DSysInfo::isDDE())
|
||||
{
|
||||
qputenv("QT_QPA_PLATFORM", "wayland");
|
||||
|
||||
}
|
||||
else if (isWayland && Dtk::Core::DSysInfo::isDDE()){
|
||||
else if (isWayland && Dtk::Core::DSysInfo::isDDE())
|
||||
{
|
||||
qputenv("QT_QPA_PLATFORM", "dwayland");
|
||||
}
|
||||
else {
|
||||
else
|
||||
{
|
||||
qputenv("QT_QPA_PLATFORM", "dxcb");
|
||||
}
|
||||
DApplication::setAttribute(Qt::AA_EnableHighDpiScaling); // 开启 Hidpi 支持
|
||||
|
||||
|
||||
|
||||
// 浏览器开启 GPU 支持
|
||||
qputenv("QTWEBENGINE_CHROMIUM_FLAGS", "--ignore-gpu-blocklist --enable-gpu-rasterization --enable-native-gpu-memory-buffers --enable-accelerated-video-decode");
|
||||
|
||||
QVector<char*> fakeArgs(argc + 2);
|
||||
QVector<char *> fakeArgs(argc + 2);
|
||||
fakeArgs[0] = argv[0];
|
||||
fakeArgs[1] = "-platformtheme";
|
||||
fakeArgs[2] = "deepin";
|
||||
for(int i = 1; i < argc; i++) fakeArgs[i + 2] = argv[i];
|
||||
int fakeArgc = argc + 2; // 为啥DApplication的argc要用引用啊?
|
||||
for (int i = 1; i < argc; i++)
|
||||
fakeArgs[i + 2] = argv[i];
|
||||
int fakeArgc = argc + 2; // DApplication的argc要用引用,避免c++编译器优化
|
||||
DApplication a(fakeArgc, fakeArgs.data());
|
||||
|
||||
|
||||
//初始化日志模块 (默认日志位置 ~/.cache/deepin/spark-store)
|
||||
// 初始化日志模块 (默认日志位置 ~/.cache/deepin/spark-store)
|
||||
DLogManager::registerConsoleAppender();
|
||||
DLogManager::registerFileAppender();
|
||||
|
||||
|
||||
//Wayland 环境下使用,防止子控件 Native 化
|
||||
if (!DPlatformWindowHandle::pluginVersion().isEmpty()) {
|
||||
// Wayland 环境下使用,防止子控件 Native 化
|
||||
if (!DPlatformWindowHandle::pluginVersion().isEmpty())
|
||||
{
|
||||
a.setAttribute(Qt::AA_DontCreateNativeWidgetSiblings, true);
|
||||
}
|
||||
a.setAttribute(Qt::AA_UseHighDpiPixmaps);
|
||||
@ -74,50 +76,47 @@ int main(int argc, char *argv[])
|
||||
|
||||
QSettings readConfig(QDir::homePath() + "/.config/spark-store/config.ini", QSettings::IniFormat);
|
||||
|
||||
if (readConfig.value("build/version").toString() != version){
|
||||
if (readConfig.value("build/version").toString() != version)
|
||||
{
|
||||
qDebug() << "Spark Store has been updated!";
|
||||
QSettings *setConfig = new QSettings(QDir::homePath() + "/.config/spark-store/config.ini", QSettings::IniFormat);
|
||||
setConfig->setValue("build/version", version);
|
||||
setConfig->setValue("build/time", buildDate.toString("yyyy.MM.dd")+"-"+buildTime.toString());
|
||||
setConfig->setValue("build/time", buildDate.toString("yyyy.MM.dd") + "-" + buildTime.toString());
|
||||
setConfig->deleteLater();
|
||||
}
|
||||
|
||||
//Customized DAboutDialog
|
||||
// Customized DAboutDialog
|
||||
|
||||
DAboutDialog dialog;
|
||||
a.setAboutDialog(&dialog);
|
||||
dialog.setLicense(QObject::tr("We publish this program under GPL V3"));
|
||||
dialog.setVersion(DApplication::buildVersion(readConfig.value("build/version").toString()+"-"+"Flamescion"+"-"+readConfig.value("build/time").toString()));
|
||||
dialog.setProductIcon(QIcon::fromTheme("spark-store")); // 设置Logo
|
||||
dialog.setProductName(QLabel::tr("Spark Store"));
|
||||
dialog.setDescription(
|
||||
QObject::tr(
|
||||
"<span style=' font-size:10pt;font-weight:60;'>An appstore powered by community</span><br/>"
|
||||
"<a href='https://www.spark-app.store/'>https://www.spark-app.store</a><br/>"
|
||||
"<span style=' font-size:12pt;'>Spark developers</span>"
|
||||
)
|
||||
);
|
||||
DAboutDialog dialog;
|
||||
a.setAboutDialog(&dialog);
|
||||
dialog.setLicense(QObject::tr("We publish this program under GPL V3"));
|
||||
dialog.setVersion(DApplication::buildVersion(readConfig.value("build/version").toString() + "-" + "Flamescion" + "-" + readConfig.value("build/time").toString()));
|
||||
dialog.setProductIcon(QIcon::fromTheme("spark-store")); // 设置Logo
|
||||
dialog.setProductName(QLabel::tr("Spark Store"));
|
||||
dialog.setDescription(
|
||||
QObject::tr(
|
||||
"<span style=' font-size:10pt;font-weight:60;'>An appstore powered by community</span><br/>"
|
||||
"<a href='https://www.spark-app.store/'>https://www.spark-app.store</a><br/>"
|
||||
"<span style=' font-size:12pt;'>Spark developers</span>"));
|
||||
|
||||
dialog.setProductName(QLabel::tr("Spark Store"));
|
||||
dialog.setCompanyLogo(QPixmap(":/spark-store.png"));
|
||||
dialog.setWebsiteName(QObject::tr("The Spark Project"));
|
||||
dialog.setWebsiteLink("https://gitee.com/deepin-community-store");
|
||||
dialog.setProductName(QLabel::tr("Spark Store"));
|
||||
dialog.setCompanyLogo(QPixmap(":/spark-store.png"));
|
||||
dialog.setWebsiteName(QObject::tr("The Spark Project"));
|
||||
dialog.setWebsiteLink("https://gitee.com/deepin-community-store");
|
||||
|
||||
a.setOrganizationName("spark-union");
|
||||
a.setProductName(QObject::tr("Spark Store"));
|
||||
a.setApplicationName("Spark Store"); // 不用翻译,影响 ~/.local/share/spark-union 下文件夹名称
|
||||
a.setApplicationName("Spark Store"); // 不用翻译,影响 ~/.local/share/spark-union 下文件夹名称
|
||||
a.setApplicationDisplayName(QObject::tr("Spark Store")); // 设置窗口显示标题 (Wayland 下会显示 Qt 原生标题栏)
|
||||
a.setWindowIcon(QIcon::fromTheme("spark-store"));
|
||||
a.setApplicationDescription(
|
||||
QObject::tr(
|
||||
"<span style='font-size:10pt;font-weight:60;'>An appstore powered by deepin community</span><br/>"
|
||||
"<a href='https://www.spark-app.store/'>https://www.spark-app.store</a><br/>"
|
||||
"<span style='font-size:12pt;'>Spark developers</span><br/><br/>"
|
||||
"Published under GPL V3"
|
||||
)
|
||||
);
|
||||
QObject::tr(
|
||||
"<span style='font-size:10pt;font-weight:60;'>An appstore powered by deepin community</span><br/>"
|
||||
"<a href='https://www.spark-app.store/'>https://www.spark-app.store</a><br/>"
|
||||
"<span style='font-size:12pt;'>Spark developers</span><br/><br/>"
|
||||
"Published under GPL V3"));
|
||||
// 限制单实例运行
|
||||
if(!a.setSingleInstance("spark-store"))
|
||||
if (!a.setSingleInstance("spark-store"))
|
||||
{
|
||||
qDebug() << "The application is already running!";
|
||||
QDBusInterface iface("com.gitee.spark.store",
|
||||
@ -127,21 +126,21 @@ int main(int argc, char *argv[])
|
||||
|
||||
QString arg1 = argv[1];
|
||||
|
||||
iface.asyncCall("activeWindow",arg1);
|
||||
|
||||
iface.asyncCall("activeWindow", arg1);
|
||||
|
||||
return -1;
|
||||
}
|
||||
|
||||
DGuiApplicationHelper::instance()->setPaletteType(DGuiApplicationHelper::LightType); //固定主题为浅色主题
|
||||
DApplicationSettings settings; // 定义 DApplicationSettings,自动保存主题设置
|
||||
DGuiApplicationHelper::instance()->setPaletteType(DGuiApplicationHelper::LightType); // 固定主题为浅色主题
|
||||
DApplicationSettings settings; // 定义 DApplicationSettings,自动保存主题设置
|
||||
|
||||
MainWindow w;
|
||||
// 让打开时界面显示在正中
|
||||
Dtk::Widget::moveToCenter(&w);
|
||||
|
||||
QString arg1 = argv[1];
|
||||
if (arg1.startsWith("spk://")) {
|
||||
if (arg1.startsWith("spk://"))
|
||||
{
|
||||
w.openUrl(QUrl(argv[1]));
|
||||
}
|
||||
w.show();
|
||||
|
@ -11,14 +11,13 @@
|
||||
#define AppPageSettings 3
|
||||
|
||||
MainWindow::MainWindow(QWidget *parent)
|
||||
: BaseWidgetOpacity(parent)
|
||||
, ui(new Ui::MainWindow)
|
||||
: BaseWidgetOpacity(parent), ui(new Ui::MainWindow)
|
||||
{
|
||||
ui->setupUi(this);
|
||||
initConfig();
|
||||
moveToCenter(this); //让窗口居中显示
|
||||
moveToCenter(this); // 让窗口居中显示
|
||||
|
||||
WidgetAnimation::widgetOpacity(this,true);
|
||||
WidgetAnimation::widgetOpacity(this, true);
|
||||
|
||||
downloadlistwidget = new DownloadListWidget;
|
||||
downloadButton = new ProgressButton(ui->titlebar);
|
||||
@ -26,7 +25,7 @@ MainWindow::MainWindow(QWidget *parent)
|
||||
ui->appintopage->setDownloadWidget(downloadlistwidget);
|
||||
ui->stackedWidget->setCurrentIndex(0);
|
||||
ui->titlebar->setBackgroundTransparent(true);
|
||||
//ui->titlebar->setSwitchThemeMenuVisible(false); // 去除 dtk 标题栏主题切换菜单
|
||||
// ui->titlebar->setSwitchThemeMenuVisible(false); // 去除 dtk 标题栏主题切换菜单
|
||||
setMaskAlpha(250);
|
||||
|
||||
updateUi(0);
|
||||
@ -42,32 +41,34 @@ MainWindow::MainWindow(QWidget *parent)
|
||||
menu->addAction(actionSubmissionWithClient);
|
||||
|
||||
ui->titlebar->setMenu(menu);
|
||||
connect(actionSubmission, &QAction::triggered, this, [=]{QDesktopServices::openUrl(QUrl("https://upload.deepinos.org/"));});
|
||||
connect(setting, &QAction::triggered, this, [=]{
|
||||
connect(actionSubmission, &QAction::triggered, this, [=]
|
||||
{ QDesktopServices::openUrl(QUrl("https://upload.deepinos.org/")); });
|
||||
connect(setting, &QAction::triggered, this, [=]
|
||||
{
|
||||
switchPage(AppPageSettings);
|
||||
ui->settingspage->updateUI();
|
||||
});
|
||||
connect(upgrade, &QAction::triggered, this, [=]{QProcess::startDetached("/opt/durapps/spark-store/bin/update-upgrade/ss-update-controler.sh");});
|
||||
ui->settingspage->updateUI(); });
|
||||
connect(upgrade, &QAction::triggered, this, [=]
|
||||
{ QProcess::startDetached("/opt/durapps/spark-store/bin/update-upgrade/ss-update-controler.sh"); });
|
||||
// 投稿器
|
||||
connect(actionSubmissionWithClient, &QAction::triggered, this, [=]
|
||||
{
|
||||
QString submitterSpk = "spk://store/tools/spark-store-submitter";
|
||||
QFile actionSubmissionClientStatus("/opt/spark-store-submitter/bin/spark-store-submitter");
|
||||
if (actionSubmissionClientStatus.exists())
|
||||
{
|
||||
qDebug() << "投稿器存在";
|
||||
QProcess::startDetached("/opt/spark-store-submitter/bin/spark-store-submitter");
|
||||
}
|
||||
else{
|
||||
qDebug() << "投稿器不存在,跳转页面";
|
||||
openUrl(submitterSpk);
|
||||
}
|
||||
QString submitterSpk = "spk://store/tools/spark-store-submitter";
|
||||
QFile actionSubmissionClientStatus("/opt/spark-store-submitter/bin/spark-store-submitter");
|
||||
if (actionSubmissionClientStatus.exists())
|
||||
{
|
||||
qDebug() << "投稿器存在";
|
||||
QProcess::startDetached("/opt/spark-store-submitter/bin/spark-store-submitter");
|
||||
}
|
||||
else
|
||||
{
|
||||
qDebug() << "投稿器不存在,跳转页面";
|
||||
openUrl(submitterSpk);
|
||||
}
|
||||
});
|
||||
|
||||
});
|
||||
|
||||
|
||||
//主题切换
|
||||
connect(DGuiApplicationHelper::instance(), &DGuiApplicationHelper::themeTypeChanged, this, [=](DGuiApplicationHelper::ColorType themeType) {
|
||||
// 主题切换
|
||||
connect(DGuiApplicationHelper::instance(), &DGuiApplicationHelper::themeTypeChanged, this, [=](DGuiApplicationHelper::ColorType themeType)
|
||||
{
|
||||
if (themeType == DGuiApplicationHelper::DarkType) {
|
||||
//深色模式
|
||||
setMaskColor(QColor("#2a2b2b"));
|
||||
@ -123,32 +124,32 @@ MainWindow::MainWindow(QWidget *parent)
|
||||
ui->applistpage->setTheme(themeType == DGuiApplicationHelper::DarkType);
|
||||
ui->applistpage_1->setTheme(themeType == DGuiApplicationHelper::DarkType);
|
||||
ui->appintopage->setTheme(themeType == DGuiApplicationHelper::DarkType);
|
||||
ui->settingspage->setTheme(themeType == DGuiApplicationHelper::DarkType);
|
||||
});
|
||||
ui->settingspage->setTheme(themeType == DGuiApplicationHelper::DarkType); });
|
||||
|
||||
//初始化标题栏控件
|
||||
connect(downloadButton, &ProgressButton::clicked, [=]() {
|
||||
// 初始化标题栏控件
|
||||
connect(downloadButton, &ProgressButton::clicked, [=]()
|
||||
{
|
||||
QPoint pos;
|
||||
pos.setX(downloadButton->mapToGlobal(QPoint(0, 0)).x() + downloadButton->width() / 2 - downloadlistwidget->width() / 2);
|
||||
pos.setY(downloadButton->mapToGlobal(QPoint(0, 0)).y() + downloadButton->height() + 5);
|
||||
downloadlistwidget->m_move(pos.x(), pos.y());
|
||||
downloadlistwidget->show();
|
||||
});
|
||||
downloadlistwidget->show(); });
|
||||
|
||||
//appintopage按下下载按钮时标题栏下载列表按钮抖动
|
||||
connect(ui->appintopage, &AppIntoPage::clickedDownloadBtn, [=]() {
|
||||
WidgetAnimation::widgetShake(downloadButton,6);//第一个参数是抖动的控件,第二个参数是抖动范围(像素)
|
||||
});
|
||||
// appintopage按下下载按钮时标题栏下载列表按钮抖动
|
||||
connect(ui->appintopage, &AppIntoPage::clickedDownloadBtn, [=]()
|
||||
{
|
||||
WidgetAnimation::widgetShake(downloadButton, 6); // 第一个参数是抖动的控件,第二个参数是抖动范围(像素)
|
||||
});
|
||||
|
||||
connect(backButtom, &QPushButton::clicked, [=]() {
|
||||
connect(backButtom, &QPushButton::clicked, [=]()
|
||||
{
|
||||
ui->stackedWidget->setCurrentIndex(pageHistory.at(pageHistory.count() - 2));
|
||||
pageHistory.removeLast();
|
||||
if (pageHistory.count() > 1) {
|
||||
backButtom->show();
|
||||
} else {
|
||||
backButtom->hide();
|
||||
}
|
||||
});
|
||||
} });
|
||||
downloadlistwidget->hide();
|
||||
backButtom->hide();
|
||||
ui->titlebar->setIcon(QIcon::fromTheme(":/icon/logo.svg"));
|
||||
@ -164,21 +165,23 @@ MainWindow::MainWindow(QWidget *parent)
|
||||
ly_titlebar->addWidget(downloadButton);
|
||||
ly_titlebar->addStretch(1);
|
||||
ui->titlebar->setCustomWidget(w_titlebar);
|
||||
//侧边栏按钮
|
||||
// 侧边栏按钮
|
||||
int i = 0;
|
||||
while (i < ui->buttonGroup->buttons().size()) {
|
||||
while (i < ui->buttonGroup->buttons().size())
|
||||
{
|
||||
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) {
|
||||
searchEdit->clearEdit();
|
||||
updateUi(i);
|
||||
}
|
||||
});
|
||||
} });
|
||||
i++;
|
||||
}
|
||||
|
||||
// 搜索事件
|
||||
connect(searchEdit, &DSearchEdit::returnPressed, this, [=]() {
|
||||
connect(searchEdit, &DSearchEdit::returnPressed, this, [=]()
|
||||
{
|
||||
QString searchtext = searchEdit->text();
|
||||
if (!searchtext.isEmpty()) {
|
||||
if (searchtext.startsWith("spk://")) {
|
||||
@ -189,22 +192,17 @@ MainWindow::MainWindow(QWidget *parent)
|
||||
switchPage(AppPageSearchlist);
|
||||
}
|
||||
}
|
||||
this->setFocus();
|
||||
});
|
||||
this->setFocus(); });
|
||||
|
||||
connect(downloadlistwidget, &DownloadListWidget::downloadProgress, this, [=](int i) {
|
||||
downloadButton->setProgress(i);
|
||||
});
|
||||
connect(downloadlistwidget, &DownloadListWidget::downloadProgress, this, [=](int i)
|
||||
{ downloadButton->setProgress(i); });
|
||||
// 列表点击事件
|
||||
connect(ui->applistpage, &AppListPage::clicked, this, [=](QUrl spk) {
|
||||
openUrl(spk);
|
||||
});
|
||||
connect(ui->applistpage_1, &AppListPage::clicked, this, [=](QUrl spk) {
|
||||
openUrl(spk);
|
||||
});
|
||||
connect(ui->settingspage, &SettingsPage::openUrl, this, [=](QUrl spk) {
|
||||
openUrl(spk);
|
||||
});
|
||||
connect(ui->applistpage, &AppListPage::clicked, this, [=](QUrl spk)
|
||||
{ openUrl(spk); });
|
||||
connect(ui->applistpage_1, &AppListPage::clicked, this, [=](QUrl spk)
|
||||
{ openUrl(spk); });
|
||||
connect(ui->settingspage, &SettingsPage::openUrl, this, [=](QUrl spk)
|
||||
{ openUrl(spk); });
|
||||
emit DGuiApplicationHelper::instance()->themeTypeChanged(DGuiApplicationHelper::instance()->themeType());
|
||||
|
||||
initDbus();
|
||||
@ -223,12 +221,12 @@ void MainWindow::initDbus()
|
||||
|
||||
QDBusConnection::sessionBus().registerService("com.gitee.spark.store");
|
||||
QDBusConnection::sessionBus().registerObject("/com/gitee/spark/store", "com.gitee.spark.store", this);
|
||||
connect(dbusInter,&DBusSparkStoreService::sigOpenUrl,this,&MainWindow::onGetUrl);
|
||||
connect(dbusInter, &DBusSparkStoreService::sigOpenUrl, this, &MainWindow::onGetUrl);
|
||||
}
|
||||
|
||||
void MainWindow::onGetUrl(const QString &url)
|
||||
{
|
||||
if(url.left(6)=="spk://")
|
||||
if (url.left(6) == "spk://")
|
||||
{
|
||||
openUrl(QUrl(url));
|
||||
}
|
||||
@ -237,11 +235,14 @@ void MainWindow::onGetUrl(const QString &url)
|
||||
|
||||
void MainWindow::openUrl(QUrl url)
|
||||
{
|
||||
if (url.toString().startsWith("spk://")) {
|
||||
ui->appintopage->openUrl(QUrl(url.toString().replace("+","%2B")));
|
||||
if (url.toString().startsWith("spk://"))
|
||||
{
|
||||
ui->appintopage->openUrl(QUrl(url.toString().replace("+", "%2B")));
|
||||
switchPage(AppPageAppdetail);
|
||||
} else {
|
||||
QDesktopServices::openUrl(QUrl(url.toString().replace("+","%2B")));
|
||||
}
|
||||
else
|
||||
{
|
||||
QDesktopServices::openUrl(QUrl(url.toString().replace("+", "%2B")));
|
||||
}
|
||||
}
|
||||
|
||||
@ -252,50 +253,54 @@ void MainWindow::initConfig()
|
||||
dir.mkpath("/tmp/spark-store");
|
||||
}
|
||||
|
||||
void MainWindow::switchPage(int now) //临时方案,回家后修改
|
||||
void MainWindow::switchPage(int now) // 临时方案,回家后修改
|
||||
{
|
||||
qDebug() << pageHistory.count();
|
||||
if (pageHistory.count() >= 1) {
|
||||
if (pageHistory.count() >= 1)
|
||||
{
|
||||
backButtom->show();
|
||||
} else {
|
||||
}
|
||||
else
|
||||
{
|
||||
backButtom->hide();
|
||||
}
|
||||
ui->stackedWidget->setCurrentIndex(now);
|
||||
pageHistory << now;
|
||||
}
|
||||
|
||||
//刷新界面
|
||||
// 刷新界面
|
||||
void MainWindow::updateUi(int now)
|
||||
{
|
||||
pageHistory.clear();
|
||||
QStringList itemlist;
|
||||
itemlist << ""
|
||||
<< "network"
|
||||
<< "chat"
|
||||
<< "music"
|
||||
<< "video"
|
||||
<< "image_graphics"
|
||||
<< "games"
|
||||
<< "office"
|
||||
<< "reading"
|
||||
<< "development"
|
||||
<< "tools"
|
||||
<< "themes"
|
||||
<< "others";
|
||||
ui->applistpage->getAppList(itemlist[now]);
|
||||
qDebug() << itemlist[now];
|
||||
switchPage(AppPageApplist);
|
||||
QStringList itemlist;
|
||||
itemlist << ""
|
||||
<< "network"
|
||||
<< "chat"
|
||||
<< "music"
|
||||
<< "video"
|
||||
<< "image_graphics"
|
||||
<< "games"
|
||||
<< "office"
|
||||
<< "reading"
|
||||
<< "development"
|
||||
<< "tools"
|
||||
<< "themes"
|
||||
<< "others";
|
||||
ui->applistpage->getAppList(itemlist[now]);
|
||||
qDebug() << itemlist[now];
|
||||
switchPage(AppPageApplist);
|
||||
}
|
||||
|
||||
void MainWindow::on_pushButton_14_clicked()
|
||||
{
|
||||
QFile upgradeStatus("/tmp/spark-store/upgradeStatus.txt");
|
||||
if (!upgradeStatus.exists()){
|
||||
QtConcurrent::run([=]{
|
||||
if (!upgradeStatus.exists())
|
||||
{
|
||||
QtConcurrent::run([=]
|
||||
{
|
||||
auto upgradeP = new QProcess();
|
||||
upgradeP->startDetached("/opt/durapps/spark-store/bin/update-upgrade/ss-do-upgrade.sh");
|
||||
upgradeP->waitForStarted();
|
||||
upgradeP->waitForFinished(-1);
|
||||
});
|
||||
upgradeP->waitForFinished(-1); });
|
||||
}
|
||||
}
|
||||
|
@ -1,20 +1,19 @@
|
||||
#include "appintopage.h"
|
||||
#include "ui_appintopage.h"
|
||||
AppIntoPage::AppIntoPage(QWidget *parent) :
|
||||
QWidget(parent),
|
||||
ui(new Ui::AppIntoPage)
|
||||
AppIntoPage::AppIntoPage(QWidget *parent) : QWidget(parent),
|
||||
ui(new Ui::AppIntoPage)
|
||||
{
|
||||
ui->setupUi(this);
|
||||
ui->listWidget->setViewMode(QListView::IconMode);
|
||||
ui->listWidget->setMovement(QListView::Static);
|
||||
ui->listWidget->setMaximumHeight(200);
|
||||
ui->listWidget->setFlow(QListView::TopToBottom);
|
||||
api1=new SparkAPI(this);
|
||||
connect(api1,&SparkAPI::finishedRAW,[=](QString download_times){
|
||||
api1 = new SparkAPI(this);
|
||||
connect(api1, &SparkAPI::finishedRAW, [=](QString download_times)
|
||||
{
|
||||
download_times.remove(QRegExp("\\n"));
|
||||
ui->download_times->setText(download_times);
|
||||
qDebug()<<"Download Times:"+download_times;
|
||||
});
|
||||
qDebug()<<"Download Times:"+download_times; });
|
||||
clear();
|
||||
}
|
||||
|
||||
@ -35,31 +34,31 @@ void AppIntoPage::clear()
|
||||
ui->downloadButton->hide();
|
||||
ui->downloadButton->setEnabled(true);
|
||||
ui->pushButton_3->hide();
|
||||
int n=ui->listWidget->count();
|
||||
for(int i=0;i<n;i++)
|
||||
int n = ui->listWidget->count();
|
||||
for (int i = 0; i < n; i++)
|
||||
{
|
||||
QListWidgetItem *item = ui->listWidget->takeItem(0);
|
||||
QWidget *card = ui->listWidget->itemWidget(item);
|
||||
delete card;
|
||||
card = NULL;
|
||||
card = NULL;
|
||||
delete item;
|
||||
item = NULL;
|
||||
item = NULL;
|
||||
}
|
||||
ui->listWidget->clear();
|
||||
}
|
||||
void AppIntoPage::setDownloadWidget(DownloadListWidget *w)
|
||||
{
|
||||
dw=w;
|
||||
connect(w, &DownloadListWidget::downloadFinished, [=]() {
|
||||
isDownloading(SparkAPI::getServerUrl()+"store"+spk.path()+"/"+info["Filename"].toString());
|
||||
});
|
||||
dw = w;
|
||||
connect(w, &DownloadListWidget::downloadFinished, [=]()
|
||||
{ isDownloading(SparkAPI::getServerUrl() + "store" + spk.path() + "/" + info["Filename"].toString()); });
|
||||
}
|
||||
void AppIntoPage::openUrl(QUrl url)
|
||||
{
|
||||
spk=url;
|
||||
SparkAPI *api=new SparkAPI(this);
|
||||
spk = url;
|
||||
SparkAPI *api = new SparkAPI(this);
|
||||
clear();
|
||||
connect(api,&SparkAPI::finishedObject,[=](QJsonObject appinfo){
|
||||
connect(api, &SparkAPI::finishedObject, [=](QJsonObject appinfo)
|
||||
{
|
||||
|
||||
info = appinfo;
|
||||
// qDebug()<<url;
|
||||
@ -188,36 +187,42 @@ void AppIntoPage::openUrl(QUrl url)
|
||||
}
|
||||
this->sltAppinfoTags(&taglist);
|
||||
disconnect(api,&SparkAPI::finished,nullptr,nullptr);
|
||||
api->deleteLater();
|
||||
});
|
||||
api->deleteLater(); });
|
||||
api->getAppInfo(url);
|
||||
api1->getAppDownloadTimes(url);
|
||||
}
|
||||
|
||||
void AppIntoPage::isDownloading(QUrl url)
|
||||
{
|
||||
if (dw->getUrlList().lastIndexOf(url) == -1) {
|
||||
if (dw->getUrlList().lastIndexOf(url) == -1)
|
||||
{
|
||||
ui->downloadButton->setEnabled(true);
|
||||
return;
|
||||
} else {
|
||||
}
|
||||
else
|
||||
{
|
||||
ui->downloadButton->setEnabled(false);
|
||||
}
|
||||
|
||||
ui->pushButton_3->hide();
|
||||
if (dw->getDIList()[dw->getUrlList().lastIndexOf(url)]->download == 2) {
|
||||
if (dw->getDIList()[dw->getUrlList().lastIndexOf(url)]->download == 2)
|
||||
{
|
||||
ui->downloadButton->setEnabled(true);
|
||||
ui->downloadButton->setText(tr("Download"));
|
||||
}
|
||||
if (dw->getDIList()[dw->getUrlList().lastIndexOf(url)]->download == 1) {
|
||||
if (dw->getDIList()[dw->getUrlList().lastIndexOf(url)]->download == 1)
|
||||
{
|
||||
ui->downloadButton->setEnabled(true);
|
||||
ui->downloadButton->setText(tr("Install"));
|
||||
}
|
||||
if (dw->getDIList()[dw->getUrlList().lastIndexOf(url)]->isInstall) {
|
||||
if (dw->getDIList()[dw->getUrlList().lastIndexOf(url)]->isInstall)
|
||||
{
|
||||
ui->downloadButton->setEnabled(false);
|
||||
ui->downloadButton->setText(tr("Installing"));
|
||||
return;
|
||||
}
|
||||
if (dw->getDIList()[dw->getUrlList().lastIndexOf(url)]->download == 3) {
|
||||
if (dw->getDIList()[dw->getUrlList().lastIndexOf(url)]->download == 3)
|
||||
{
|
||||
ui->downloadButton->setEnabled(true);
|
||||
ui->downloadButton->setText(tr("Reinstall"));
|
||||
ui->downloadButton->show();
|
||||
@ -227,37 +232,37 @@ void AppIntoPage::isDownloading(QUrl url)
|
||||
|
||||
void AppIntoPage::sltAppinfoTags(QStringList *tagList)
|
||||
{
|
||||
foreach(const QString &tag, *tagList)
|
||||
foreach (const QString &tag, *tagList)
|
||||
{
|
||||
if(tag=="community")
|
||||
if (tag == "community")
|
||||
{
|
||||
ui->tag_community->show();
|
||||
}
|
||||
else if(tag=="ubuntu")
|
||||
else if (tag == "ubuntu")
|
||||
{
|
||||
ui->tag_ubuntu->show();
|
||||
}
|
||||
else if(tag=="deepin")
|
||||
else if (tag == "deepin")
|
||||
{
|
||||
ui->tag_deepin->show();
|
||||
}
|
||||
else if(tag=="uos")
|
||||
else if (tag == "uos")
|
||||
{
|
||||
ui->tag_uos->show();
|
||||
}
|
||||
else if(tag=="dtk5")
|
||||
else if (tag == "dtk5")
|
||||
{
|
||||
ui->tag_dtk5->show();
|
||||
}
|
||||
else if(tag=="dwine2")
|
||||
else if (tag == "dwine2")
|
||||
{
|
||||
ui->tag_dwine2->show();
|
||||
}
|
||||
else if(tag=="dwine5")
|
||||
else if (tag == "dwine5")
|
||||
{
|
||||
ui->tag_dwine5->show();
|
||||
}
|
||||
else if(tag=="a2d")
|
||||
else if (tag == "a2d")
|
||||
{
|
||||
ui->tag_a2d->show();
|
||||
}
|
||||
@ -265,9 +270,9 @@ void AppIntoPage::sltAppinfoTags(QStringList *tagList)
|
||||
}
|
||||
void AppIntoPage::setTheme(bool dark)
|
||||
{
|
||||
if(dark)
|
||||
if (dark)
|
||||
{
|
||||
QString frameStyleSheet ="#frame,#frame_2,#frame_3,#frame_4{background-color: #252525;border-radius:14px;border:1px solid rgb(64, 64, 64);}";
|
||||
QString frameStyleSheet = "#frame,#frame_2,#frame_3,#frame_4{background-color: #252525;border-radius:14px;border:1px solid rgb(64, 64, 64);}";
|
||||
ui->frame->setStyleSheet(frameStyleSheet);
|
||||
ui->frame_2->setStyleSheet(frameStyleSheet);
|
||||
ui->frame_3->setStyleSheet(frameStyleSheet);
|
||||
@ -279,9 +284,11 @@ void AppIntoPage::setTheme(bool dark)
|
||||
ui->icon_4->setPixmap(QPixmap(":/icon/dark/text.svg"));
|
||||
ui->icon_5->setPixmap(QPixmap(":/icon/dark/folder.svg"));
|
||||
ui->icon_6->setPixmap(QPixmap(":/icon/dark/globe.svg"));
|
||||
}else {
|
||||
//亮色模式
|
||||
QString frameStyleSheet ="#frame,#frame_2,#frame_3,#frame_4{background-color: #fbfbfb;border-radius:14px;border:1px solid rgb(229,229,229);}";
|
||||
}
|
||||
else
|
||||
{
|
||||
// 亮色模式
|
||||
QString frameStyleSheet = "#frame,#frame_2,#frame_3,#frame_4{background-color: #fbfbfb;border-radius:14px;border:1px solid rgb(229,229,229);}";
|
||||
ui->frame->setStyleSheet(frameStyleSheet);
|
||||
ui->frame_2->setStyleSheet(frameStyleSheet);
|
||||
ui->frame_3->setStyleSheet(frameStyleSheet);
|
||||
@ -293,7 +300,6 @@ void AppIntoPage::setTheme(bool dark)
|
||||
ui->icon_4->setPixmap(QPixmap(":/icon/light/text.svg"));
|
||||
ui->icon_5->setPixmap(QPixmap(":/icon/light/folder.svg"));
|
||||
ui->icon_6->setPixmap(QPixmap(":/icon/light/globe.svg"));
|
||||
|
||||
}
|
||||
}
|
||||
AppIntoPage::~AppIntoPage()
|
||||
@ -303,34 +309,34 @@ AppIntoPage::~AppIntoPage()
|
||||
|
||||
void AppIntoPage::on_downloadButton_clicked()
|
||||
{
|
||||
if(ui->downloadButton->text() == tr("Install"))
|
||||
if (ui->downloadButton->text() == tr("Install"))
|
||||
{
|
||||
dw->getDIList()[dw->getUrlList().lastIndexOf(SparkAPI::getServerUrl()+"store"+spk.path()+"/"+info["Filename"].toString())]->install(0);
|
||||
isDownloading(SparkAPI::getServerUrl()+"store"+spk.path()+"/"+info["Filename"].toString());
|
||||
QObject::connect(dw->getDIList()[dw->getUrlList().lastIndexOf(SparkAPI::getServerUrl()+"store"+spk.path()+"/"+info["Filename"].toString())],&DownloadItem::finished,[=](){
|
||||
dw->getDIList()[dw->getUrlList().lastIndexOf(SparkAPI::getServerUrl() + "store" + spk.path() + "/" + info["Filename"].toString())]->install(0);
|
||||
isDownloading(SparkAPI::getServerUrl() + "store" + spk.path() + "/" + info["Filename"].toString());
|
||||
QObject::connect(dw->getDIList()[dw->getUrlList().lastIndexOf(SparkAPI::getServerUrl() + "store" + spk.path() + "/" + info["Filename"].toString())], &DownloadItem::finished, [=]()
|
||||
{
|
||||
isDownloading(SparkAPI::getServerUrl()+"store"+spk.path()+"/"+info["Filename"].toString());
|
||||
disconnect(dw->getDIList()[dw->getUrlList().lastIndexOf(SparkAPI::getServerUrl()+"store"+spk.path()+"/"+info["Filename"].toString())],&DownloadItem::finished,nullptr,nullptr);
|
||||
});
|
||||
disconnect(dw->getDIList()[dw->getUrlList().lastIndexOf(SparkAPI::getServerUrl()+"store"+spk.path()+"/"+info["Filename"].toString())],&DownloadItem::finished,nullptr,nullptr); });
|
||||
return;
|
||||
}
|
||||
emit clickedDownloadBtn();
|
||||
dw->addItem(info["Name"].toString(),info["Filename"].toString(),info["Pkgname"].toString(),iconpixmap,SparkAPI::getServerUrl()+"store"+spk.path()+"/"+info["Filename"].toString());
|
||||
if(ui->downloadButton->text() == tr("Reinstall"))
|
||||
dw->addItem(info["Name"].toString(), info["Filename"].toString(), info["Pkgname"].toString(), iconpixmap, SparkAPI::getServerUrl() + "store" + spk.path() + "/" + info["Filename"].toString());
|
||||
if (ui->downloadButton->text() == tr("Reinstall"))
|
||||
{
|
||||
dw->getDIList()[dw->allDownload - 1]->reinstall = true;
|
||||
}
|
||||
ui->downloadButton->setEnabled(false);
|
||||
QObject::connect(dw->getDIList()[dw->getUrlList().lastIndexOf(SparkAPI::getServerUrl()+"store"+spk.path()+"/"+info["Filename"].toString())],&DownloadItem::finished,[=](){
|
||||
QObject::connect(dw->getDIList()[dw->getUrlList().lastIndexOf(SparkAPI::getServerUrl() + "store" + spk.path() + "/" + info["Filename"].toString())], &DownloadItem::finished, [=]()
|
||||
{
|
||||
isDownloading(SparkAPI::getServerUrl()+"store"+spk.path()+"/"+info["Filename"].toString());
|
||||
disconnect(dw->getDIList()[dw->getUrlList().lastIndexOf(SparkAPI::getServerUrl()+"store"+spk.path()+"/"+info["Filename"].toString())],&DownloadItem::finished,nullptr,nullptr);
|
||||
});
|
||||
isDownloading(SparkAPI::getServerUrl()+"store"+spk.path()+"/"+info["Filename"].toString());
|
||||
disconnect(dw->getDIList()[dw->getUrlList().lastIndexOf(SparkAPI::getServerUrl()+"store"+spk.path()+"/"+info["Filename"].toString())],&DownloadItem::finished,nullptr,nullptr); });
|
||||
isDownloading(SparkAPI::getServerUrl() + "store" + spk.path() + "/" + info["Filename"].toString());
|
||||
}
|
||||
|
||||
void AppIntoPage::on_pushButton_3_clicked()
|
||||
{
|
||||
QtConcurrent::run([=]()
|
||||
{
|
||||
{
|
||||
ui->downloadButton->setEnabled(false);
|
||||
ui->pushButton_3->setEnabled(false);
|
||||
|
||||
@ -352,19 +358,17 @@ void AppIntoPage::on_pushButton_3_clicked()
|
||||
}
|
||||
|
||||
ui->downloadButton->setEnabled(true);
|
||||
ui->pushButton_3->setEnabled(true);
|
||||
});
|
||||
ui->pushButton_3->setEnabled(true); });
|
||||
}
|
||||
|
||||
void AppIntoPage::on_shareButton_clicked()
|
||||
{
|
||||
qDebug() << "Share" << spk;
|
||||
Utils::sendNotification("spark-store",tr("Spark Store"),tr("The URL has been copied to the clipboard"));
|
||||
Utils::sendNotification("spark-store", tr("Spark Store"), tr("The URL has been copied to the clipboard"));
|
||||
QClipboard *clipboard = QApplication::clipboard();
|
||||
clipboard->setText(spk.toString());
|
||||
}
|
||||
|
||||
|
||||
void AppIntoPage::on_updateButton_clicked()
|
||||
{
|
||||
QString feedbackSpk = "spk://store/chat/store.spark-app.feedback";
|
||||
@ -374,9 +378,9 @@ void AppIntoPage::on_updateButton_clicked()
|
||||
qDebug() << "反馈器存在";
|
||||
QProcess::startDetached("sh /opt/durapps/store.spark-app.feedback/launch.sh");
|
||||
}
|
||||
else{
|
||||
else
|
||||
{
|
||||
qDebug() << "反馈器不存在,跳转页面";
|
||||
openUrl(feedbackSpk);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -1,48 +1,55 @@
|
||||
#include "applistpage.h"
|
||||
#include "ui_applistpage.h"
|
||||
|
||||
AppListPage::AppListPage(QWidget *parent) :
|
||||
QWidget(parent),
|
||||
ui(new Ui::AppListPage)
|
||||
AppListPage::AppListPage(QWidget *parent) : QWidget(parent),
|
||||
ui(new Ui::AppListPage)
|
||||
{
|
||||
ui->setupUi(this);
|
||||
ui->webEngineView->page()->setBackgroundColor(Qt::transparent);
|
||||
}
|
||||
void AppListPage::setTheme(bool dark)
|
||||
{
|
||||
isDark=dark;
|
||||
if(dark)
|
||||
isDark = dark;
|
||||
if (dark)
|
||||
{
|
||||
this->setStyleSheet("#frame{background-color: #252525;border-radius:14px;border:1px solid rgb(64, 64, 64);}");
|
||||
}else {
|
||||
//亮色模式
|
||||
}
|
||||
else
|
||||
{
|
||||
// 亮色模式
|
||||
this->setStyleSheet("#frame{background-color: #ffffff;border-radius:14px;border:1px solid rgb(229,229,229);}");
|
||||
}
|
||||
if(isSearch)
|
||||
if (isSearch)
|
||||
{
|
||||
getSearchList(nowType);
|
||||
}else{
|
||||
}
|
||||
else
|
||||
{
|
||||
getAppList(nowType);
|
||||
}
|
||||
}
|
||||
void AppListPage::getAppList(QString type)
|
||||
{
|
||||
isSearch=false;
|
||||
nowType=type;
|
||||
SparkAPI *api=new SparkAPI(this);
|
||||
isSearch = false;
|
||||
nowType = type;
|
||||
SparkAPI *api = new SparkAPI(this);
|
||||
QString url;
|
||||
QString theme;
|
||||
if(isDark)
|
||||
if (isDark)
|
||||
{
|
||||
theme="theme=dark";
|
||||
}else{
|
||||
theme="theme=light";
|
||||
theme = "theme=dark";
|
||||
}
|
||||
if(type=="")
|
||||
else
|
||||
{
|
||||
url=api->getServerUrl()+"store/#/flamescion/?"+theme;
|
||||
}else{
|
||||
url=api->getServerUrl()+"store/#/flamescion/applist?type="+type+"&"+theme;
|
||||
theme = "theme=light";
|
||||
}
|
||||
if (type == "")
|
||||
{
|
||||
url = api->getServerUrl() + "store/#/flamescion/?" + theme;
|
||||
}
|
||||
else
|
||||
{
|
||||
url = api->getServerUrl() + "store/#/flamescion/applist?type=" + type + "&" + theme;
|
||||
}
|
||||
|
||||
ui->webEngineView->setUrl(url);
|
||||
@ -50,18 +57,20 @@ void AppListPage::getAppList(QString type)
|
||||
|
||||
void AppListPage::getSearchList(QString keyword)
|
||||
{
|
||||
isSearch=true;
|
||||
nowType=keyword;
|
||||
SparkAPI *api=new SparkAPI(this);
|
||||
isSearch = true;
|
||||
nowType = keyword;
|
||||
SparkAPI *api = new SparkAPI(this);
|
||||
QString url;
|
||||
QString theme;
|
||||
if(isDark)
|
||||
if (isDark)
|
||||
{
|
||||
theme="theme=dark";
|
||||
}else{
|
||||
theme="theme=light";
|
||||
theme = "theme=dark";
|
||||
}
|
||||
url=api->getServerUrl()+"store/#/flamescion/search?keywords="+keyword+"&"+theme;
|
||||
else
|
||||
{
|
||||
theme = "theme=light";
|
||||
}
|
||||
url = api->getServerUrl() + "store/#/flamescion/search?keywords=" + keyword + "&" + theme;
|
||||
ui->webEngineView->setUrl(url);
|
||||
}
|
||||
|
||||
@ -72,15 +81,14 @@ AppListPage::~AppListPage()
|
||||
|
||||
void AppListPage::on_webEngineView_urlChanged(const QUrl &arg1)
|
||||
{
|
||||
if(arg1.path().right(8) == "app.json")
|
||||
{
|
||||
QString url = arg1.toString();
|
||||
url = url.mid(url.indexOf("/store/"));
|
||||
url = "spk:/"+url;
|
||||
url = url.mid(0,url.indexOf("/app.json"));
|
||||
qDebug() << "程序跳转链接地址:" << url;
|
||||
ui->webEngineView->back();
|
||||
emit clicked(url);
|
||||
}
|
||||
if (arg1.path().right(8) == "app.json")
|
||||
{
|
||||
QString url = arg1.toString();
|
||||
url = url.mid(url.indexOf("/store/"));
|
||||
url = "spk:/" + url;
|
||||
url = url.mid(0, url.indexOf("/app.json"));
|
||||
qDebug() << "程序跳转链接地址:" << url;
|
||||
ui->webEngineView->back();
|
||||
emit clicked(url);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -1,9 +1,8 @@
|
||||
#include "settingspage.h"
|
||||
#include "ui_settingspage.h"
|
||||
bool SettingsPage::isdownload = false;
|
||||
SettingsPage::SettingsPage(QWidget *parent) :
|
||||
QWidget(parent),
|
||||
ui(new Ui::SettingsPage)
|
||||
SettingsPage::SettingsPage(QWidget *parent) : QWidget(parent),
|
||||
ui(new Ui::SettingsPage)
|
||||
{
|
||||
ui->setupUi(this);
|
||||
configCanSave = false;
|
||||
@ -12,11 +11,13 @@ SettingsPage::SettingsPage(QWidget *parent) :
|
||||
|
||||
void SettingsPage::setTheme(bool dark)
|
||||
{
|
||||
if(dark)
|
||||
if (dark)
|
||||
{
|
||||
this->setStyleSheet("#frame{background-color: #252525;border-radius:14px;border:1px solid rgb(64, 64, 64);}");
|
||||
}else {
|
||||
//亮色模式
|
||||
}
|
||||
else
|
||||
{
|
||||
// 亮色模式
|
||||
this->setStyleSheet("#frame{background-color: #ffffff;border-radius:14px;border:1px solid rgb(229,229,229);}");
|
||||
}
|
||||
}
|
||||
@ -26,7 +27,7 @@ void SettingsPage::readServerList()
|
||||
// 读取服务器列表并初始化
|
||||
QFile file(QDir::homePath().toUtf8() + "/.config/spark-store/server.list");
|
||||
|
||||
//判断文件是否存在
|
||||
// 判断文件是否存在
|
||||
if (!file.exists())
|
||||
{
|
||||
ui->comboBox_server->addItem("https://d.store.deepinos.org.cn/");
|
||||
@ -34,28 +35,28 @@ void SettingsPage::readServerList()
|
||||
|
||||
if (!file.open(QIODevice::ReadOnly | QIODevice::Text))
|
||||
{
|
||||
qDebug()<<"无法读取server.list";
|
||||
qDebug() << "无法读取server.list";
|
||||
}
|
||||
|
||||
//创建QTextStream对象
|
||||
// 创建QTextStream对象
|
||||
QTextStream textStream(&file);
|
||||
|
||||
QString lineData = textStream.readLine();//读取文件的第一行
|
||||
QString lineData = textStream.readLine(); // 读取文件的第一行
|
||||
ui->comboBox_server->addItem(lineData);
|
||||
while(!lineData.isNull())
|
||||
while (!lineData.isNull())
|
||||
{
|
||||
lineData = textStream.readLine();
|
||||
ui->comboBox_server->addItem(lineData);
|
||||
}
|
||||
for(int i = 0; i < ui->comboBox_server->count(); i++)
|
||||
for (int i = 0; i < ui->comboBox_server->count(); i++)
|
||||
{
|
||||
if(ui->comboBox_server->itemText(i) == "开发者模式 Dev only")
|
||||
if (ui->comboBox_server->itemText(i) == "开发者模式 Dev only")
|
||||
{
|
||||
ui->comboBox_server->model()->setData(ui->comboBox_server->model()->index(i, 0), QVariant(0), Qt::UserRole - 1);
|
||||
}
|
||||
if(ui->comboBox_server->itemText(i) == "镜像源 Download only")
|
||||
if (ui->comboBox_server->itemText(i) == "镜像源 Download only")
|
||||
{
|
||||
for(int j = i; j < ui->comboBox_server->count(); j++)
|
||||
for (int j = i; j < ui->comboBox_server->count(); j++)
|
||||
{
|
||||
ui->comboBox_server->model()->setData(ui->comboBox_server->model()->index(j, 0), QVariant(0), Qt::UserRole - 1);
|
||||
}
|
||||
@ -71,13 +72,13 @@ void SettingsPage::initConfig()
|
||||
|
||||
// 读取服务器URL并初始化菜单项的链接
|
||||
QSettings readConfig(QDir::homePath() + "/.config/spark-store/config.ini", QSettings::IniFormat);
|
||||
if(!readConfig.value("server/choose").toString().isEmpty() && readConfig.value("server/updated").toString() == "TRUE")
|
||||
if (!readConfig.value("server/choose").toString().isEmpty() && readConfig.value("server/updated").toString() == "TRUE")
|
||||
{
|
||||
qDebug()<<readConfig.value("server/choose").toString();
|
||||
qDebug() << readConfig.value("server/choose").toString();
|
||||
ui->comboBox_server->setCurrentText(readConfig.value("server/choose").toString());
|
||||
SparkAPI::setServerUrl(readConfig.value("server/choose").toString());
|
||||
}
|
||||
configCanSave = true; // 防止触发保存配置信号
|
||||
configCanSave = true; // 防止触发保存配置信号
|
||||
}
|
||||
|
||||
SettingsPage::~SettingsPage()
|
||||
@ -88,7 +89,7 @@ SettingsPage::~SettingsPage()
|
||||
void SettingsPage::on_pushButton_updateServer_clicked()
|
||||
{
|
||||
QtConcurrent::run([=]()
|
||||
{
|
||||
{
|
||||
ui->pushButton_updateServer->setEnabled(false);
|
||||
ui->comboBox_server->clear();
|
||||
|
||||
@ -97,17 +98,15 @@ void SettingsPage::on_pushButton_updateServer_clicked()
|
||||
|
||||
ui->pushButton_updateServer->setEnabled(true);
|
||||
readServerList();
|
||||
ui->comboBox_server->setCurrentIndex(0);
|
||||
});
|
||||
ui->comboBox_server->setCurrentIndex(0); });
|
||||
}
|
||||
|
||||
|
||||
void SettingsPage::on_comboBox_server_currentIndexChanged(const QString &arg1)
|
||||
{
|
||||
SparkAPI::setServerUrl(arg1); // 服务器信息更新
|
||||
qDebug()<<arg1;
|
||||
SparkAPI::setServerUrl(arg1); // 服务器信息更新
|
||||
qDebug() << arg1;
|
||||
const QString updatedInfo = "TRUE";
|
||||
if(configCanSave)
|
||||
if (configCanSave)
|
||||
{
|
||||
// ui->label_setting1->show();
|
||||
QSettings *setConfig = new QSettings(QDir::homePath() + "/.config/spark-store/config.ini", QSettings::IniFormat);
|
||||
@ -124,7 +123,7 @@ void SettingsPage::setIsDownload(bool isdownload)
|
||||
|
||||
void SettingsPage::updateUI()
|
||||
{
|
||||
if(isdownload)
|
||||
if (isdownload)
|
||||
{
|
||||
ui->pushButton_clear->setEnabled(false);
|
||||
}
|
||||
@ -135,15 +134,15 @@ void SettingsPage::updateUI()
|
||||
// 显示缓存占用空间
|
||||
quint64 tmp_size = dirFileSize(QString::fromUtf8(TMP_PATH));
|
||||
QString tmp_size_str;
|
||||
if(tmp_size < 1024)
|
||||
if (tmp_size < 1024)
|
||||
{
|
||||
tmp_size_str = QString::number(tmp_size) + "B";
|
||||
}
|
||||
else if(tmp_size < (1024 * 1024))
|
||||
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))
|
||||
else if (tmp_size < (1024 * 1024 * 1024))
|
||||
{
|
||||
tmp_size_str = QString::number(0.01 * int(100 * (tmp_size / (1024 * 1024)))) + "MB";
|
||||
}
|
||||
@ -160,13 +159,13 @@ quint64 SettingsPage::dirFileSize(const QString &path)
|
||||
QDir dir(path);
|
||||
quint64 size = 0;
|
||||
// dir.entryInfoList(QDir::Files); // 返回文件信息
|
||||
foreach(QFileInfo fileInfo, 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))
|
||||
foreach (QString subDir, dir.entryList(QDir::Dirs | QDir::NoDotAndDotDot))
|
||||
{
|
||||
// 若存在子目录,则递归调用 dirFileSize() 函数
|
||||
size += dirFileSize(path + QDir::separator() + subDir);
|
||||
@ -177,22 +176,20 @@ quint64 SettingsPage::dirFileSize(const QString &path)
|
||||
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);
|
||||
});
|
||||
ui->pushButton_updateApt->setEnabled(true); });
|
||||
}
|
||||
|
||||
|
||||
void SettingsPage::on_pushButton_clear_clicked()
|
||||
{
|
||||
QtConcurrent::run([=]()
|
||||
{
|
||||
{
|
||||
ui->pushButton_clear->setEnabled(false);
|
||||
|
||||
QDir tmpdir("/tmp/spark-store");
|
||||
@ -204,15 +201,13 @@ void SettingsPage::on_pushButton_clear_clicked()
|
||||
}
|
||||
Utils::sendNotification("spark-store",tr("Spark Store"),tr("Temporary cache was cleaned"));
|
||||
ui->pushButton_clear->setEnabled(true);
|
||||
updateUI();
|
||||
});
|
||||
updateUI(); });
|
||||
}
|
||||
|
||||
|
||||
void SettingsPage::on_pushButton_clearWebCache_clicked()
|
||||
{
|
||||
QtConcurrent::run([=]()
|
||||
{
|
||||
{
|
||||
QString dataLocal = QStandardPaths::writableLocation(QStandardPaths::AppLocalDataLocation);
|
||||
qDebug() << dataLocal;
|
||||
QDir dataDir(dataLocal);
|
||||
@ -220,7 +215,5 @@ void SettingsPage::on_pushButton_clearWebCache_clicked()
|
||||
dataLocal = QStandardPaths::writableLocation(QStandardPaths::TempLocation);
|
||||
qDebug() << dataLocal;
|
||||
QDir cacheDir(dataLocal);
|
||||
cacheDir.removeRecursively();
|
||||
});
|
||||
cacheDir.removeRecursively(); });
|
||||
}
|
||||
|
||||
|
@ -1,22 +1,19 @@
|
||||
#include "httprequest.h"
|
||||
|
||||
|
||||
|
||||
HttpRequest::HttpRequest()
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
void HttpRequest::getRequest(QNetworkRequest request)
|
||||
{
|
||||
QNetworkAccessManager *naManager=new QNetworkAccessManager(this);
|
||||
QNetworkAccessManager *naManager = new QNetworkAccessManager(this);
|
||||
|
||||
request.setRawHeader("User-Agent", "Mozilla/5.0");
|
||||
request.setRawHeader("Content-Type", "charset='utf-8'");
|
||||
request.setRawHeader("Content-Type", "application/json");
|
||||
|
||||
naManager->get(request);
|
||||
QObject::connect(naManager,&QNetworkAccessManager::finished,this,&HttpRequest::readdata_slot);
|
||||
QObject::connect(naManager, &QNetworkAccessManager::finished, this, &HttpRequest::readdata_slot);
|
||||
}
|
||||
void HttpRequest::readdata_slot(QNetworkReply *reply)
|
||||
{
|
||||
@ -24,19 +21,19 @@ void HttpRequest::readdata_slot(QNetworkReply *reply)
|
||||
}
|
||||
QString HttpRequest::postRequest(QString url, QString jsondata)
|
||||
{
|
||||
QByteArray array= jsondata.toLatin1();
|
||||
QByteArray array = jsondata.toLatin1();
|
||||
QNetworkRequest request;
|
||||
QNetworkAccessManager *naManager=new QNetworkAccessManager(this);
|
||||
QUrl strUrl = url.replace("+","%2B");
|
||||
QNetworkAccessManager *naManager = new QNetworkAccessManager(this);
|
||||
QUrl strUrl = url.replace("+", "%2B");
|
||||
request.setUrl(strUrl);
|
||||
request.setRawHeader("Content-Type", "charset='utf-8'");
|
||||
request.setRawHeader("Content-Type", "application/json");
|
||||
|
||||
QNetworkReply* reply = naManager->post(request, array);
|
||||
QNetworkReply *reply = naManager->post(request, array);
|
||||
QEventLoop eventLoop;
|
||||
connect(naManager, SIGNAL(finished(QNetworkReply*)), &eventLoop, SLOT(quit()));
|
||||
connect(naManager, SIGNAL(finished(QNetworkReply *)), &eventLoop, SLOT(quit()));
|
||||
eventLoop.exec();
|
||||
QTextCodec* codec = QTextCodec::codecForName("utf8");
|
||||
QTextCodec *codec = QTextCodec::codecForName("utf8");
|
||||
QString strReply = codec->toUnicode(reply->readAll());
|
||||
reply->deleteLater();
|
||||
return strReply;
|
||||
|
@ -2,18 +2,17 @@
|
||||
|
||||
Utils::Utils()
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
//这个函数是chatGPT写的
|
||||
void Utils::sendNotification(QString icon,QString title,QString body)
|
||||
// Author: chatGPT
|
||||
void Utils::sendNotification(QString icon, QString title, QString body)
|
||||
{
|
||||
QDBusInterface iface("org.freedesktop.Notifications",
|
||||
"/org/freedesktop/Notifications",
|
||||
"org.freedesktop.Notifications");
|
||||
|
||||
QVariantList args;
|
||||
args << QCoreApplication::applicationName() // the name of the application
|
||||
args << QCoreApplication::applicationName() // the name of the application
|
||||
<< (uint)0 // replaces the previous notification with the same ID
|
||||
<< icon // the application icon of the notification
|
||||
<< title // the title of the notification
|
||||
|
@ -2,43 +2,45 @@
|
||||
|
||||
WidgetAnimation::WidgetAnimation()
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
void WidgetAnimation::widgetShake(QWidget *pWidget, int nRange)
|
||||
{
|
||||
int nX = pWidget->x();
|
||||
int nY = pWidget->y();
|
||||
QPropertyAnimation *pAnimation = new QPropertyAnimation(pWidget,"geometry");
|
||||
QPropertyAnimation *pAnimation = new QPropertyAnimation(pWidget, "geometry");
|
||||
pAnimation->setEasingCurve(QEasingCurve::InOutSine);
|
||||
pAnimation->setDuration(400);
|
||||
pAnimation->setStartValue(QRect(QPoint(nX,nY),pWidget->size()));
|
||||
pAnimation->setStartValue(QRect(QPoint(nX, nY), pWidget->size()));
|
||||
|
||||
int nShakeCount = 8;
|
||||
double nStep = 1.0/nShakeCount;
|
||||
for(int i = 1; i < nShakeCount; i++){
|
||||
nRange = i&1 ? -nRange : nRange;
|
||||
pAnimation->setKeyValueAt(nStep*i,QRect(QPoint(nX + nRange,nY),pWidget->size()));
|
||||
double nStep = 1.0 / nShakeCount;
|
||||
for (int i = 1; i < nShakeCount; i++)
|
||||
{
|
||||
nRange = i & 1 ? -nRange : nRange;
|
||||
pAnimation->setKeyValueAt(nStep * i, QRect(QPoint(nX + nRange, nY), pWidget->size()));
|
||||
}
|
||||
|
||||
pAnimation->setEndValue(QRect(QPoint(nX,nY),pWidget->size()));
|
||||
pAnimation->setEndValue(QRect(QPoint(nX, nY), pWidget->size()));
|
||||
pAnimation->start(QAbstractAnimation::DeleteWhenStopped);
|
||||
}
|
||||
|
||||
QPropertyAnimation* WidgetAnimation::createWidgetOpacity(QWidget *pWidget, bool isAppear)
|
||||
QPropertyAnimation *WidgetAnimation::createWidgetOpacity(QWidget *pWidget, bool isAppear)
|
||||
{
|
||||
QPropertyAnimation *animation = new QPropertyAnimation(pWidget, "windowOpacity", pWidget);
|
||||
//设置动画效果
|
||||
// 设置动画效果
|
||||
animation->setEasingCurve(QEasingCurve::Linear);
|
||||
//设置动画时间(单位:毫秒)
|
||||
// 设置动画时间(单位:毫秒)
|
||||
animation->setDuration(500);
|
||||
// 设置动画步长值,以及在该位置时显示的透明度
|
||||
if(isAppear)
|
||||
if (isAppear)
|
||||
{
|
||||
animation->setKeyValueAt(0, 0);
|
||||
// m_animation->setKeyValueAt(0.5, 0);
|
||||
animation->setKeyValueAt(1, 1);
|
||||
}else{
|
||||
}
|
||||
else
|
||||
{
|
||||
animation->setKeyValueAt(0, 1);
|
||||
animation->setKeyValueAt(1, 0);
|
||||
}
|
||||
@ -46,7 +48,7 @@ QPropertyAnimation* WidgetAnimation::createWidgetOpacity(QWidget *pWidget, bool
|
||||
}
|
||||
|
||||
void WidgetAnimation::widgetOpacity(QWidget *pWidget, bool isAppear)
|
||||
{
|
||||
{
|
||||
// 开始动画
|
||||
createWidgetOpacity(pWidget, isAppear)->start();
|
||||
}
|
||||
|
@ -5,14 +5,15 @@
|
||||
|
||||
BaseWidgetOpacity::BaseWidgetOpacity(QWidget *parent) : DBlurEffectWidget(parent)
|
||||
{
|
||||
// WidgetAnimation::widgetOpacity(this,true);
|
||||
// WidgetAnimation::widgetOpacity(this,true);
|
||||
}
|
||||
|
||||
/// @brief 窗口关闭事件
|
||||
/// @param event
|
||||
void BaseWidgetOpacity::closeEvent(QCloseEvent *event)
|
||||
{
|
||||
if (!closeWindowAnimation) {
|
||||
if (!closeWindowAnimation)
|
||||
{
|
||||
closeWindowAnimation = true;
|
||||
|
||||
QPropertyAnimation *animation = new QPropertyAnimation(this, "windowOpacity");
|
||||
@ -21,18 +22,20 @@ void BaseWidgetOpacity::closeEvent(QCloseEvent *event)
|
||||
animation->setStartValue(1.0);
|
||||
animation->setEndValue(0.0);
|
||||
|
||||
QObject::connect(animation, &QPropertyAnimation::valueChanged, this, [=](const QVariant &value){
|
||||
this->update();
|
||||
// setWindowTitle(QString("ヾ(⌒∇⌒*)See You♪ - %1%").arg(int(value.toFloat() * 100)));
|
||||
});
|
||||
QObject::connect(animation, &QPropertyAnimation::valueChanged, this, [=](const QVariant &value)
|
||||
{
|
||||
this->update();
|
||||
// setWindowTitle(QString("ヾ(⌒∇⌒*)See You♪ - %1%").arg(int(value.toFloat() * 100)));
|
||||
});
|
||||
|
||||
QObject::connect(animation, &QPropertyAnimation::finished, this, [=](){
|
||||
this->close();
|
||||
});
|
||||
QObject::connect(animation, &QPropertyAnimation::finished, this, [=]()
|
||||
{ this->close(); });
|
||||
|
||||
animation->start();
|
||||
event->ignore();
|
||||
} else {
|
||||
}
|
||||
else
|
||||
{
|
||||
event->accept();
|
||||
}
|
||||
}
|
||||
|
@ -3,11 +3,10 @@
|
||||
#include <QHBoxLayout>
|
||||
#include <QtConcurrent>
|
||||
|
||||
big_image::big_image(DBlurEffectWidget *parent) :
|
||||
DBlurEffectWidget(parent),
|
||||
m_image(new QLabel)
|
||||
big_image::big_image(DBlurEffectWidget *parent) : DBlurEffectWidget(parent),
|
||||
m_image(new QLabel)
|
||||
{
|
||||
// setWindowFlags(this->windowFlags() | Qt::WindowStaysOnTopHint); // 设置图片对话框总在最前
|
||||
// setWindowFlags(this->windowFlags() | Qt::WindowStaysOnTopHint); // 设置图片对话框总在最前
|
||||
setWindowModality(Qt::ApplicationModal); // 以上无效不如直接使用 模态化对话框
|
||||
setRadius(0);
|
||||
setMaskAlpha(60);
|
||||
|
@ -6,13 +6,12 @@
|
||||
|
||||
bool DownloadItem::isInstall = false;
|
||||
|
||||
DownloadItem::DownloadItem(QWidget *parent) :
|
||||
QWidget(parent),
|
||||
reinstall(false),
|
||||
close(false),
|
||||
ui(new Ui::DownloadItem),
|
||||
output_w(new DDialog),
|
||||
textbrowser(new QTextBrowser)
|
||||
DownloadItem::DownloadItem(QWidget *parent) : QWidget(parent),
|
||||
reinstall(false),
|
||||
close(false),
|
||||
ui(new Ui::DownloadItem),
|
||||
output_w(new DDialog),
|
||||
textbrowser(new QTextBrowser)
|
||||
{
|
||||
ui->setupUi(this);
|
||||
|
||||
@ -34,7 +33,7 @@ void DownloadItem::setValue(qint64 value)
|
||||
{
|
||||
ui->progressBar->setValue(qint32(value));
|
||||
ui->label_2->setText(QString::number(double(value) / 100) + "% (" + speed + ")");
|
||||
if(ui->label_2->text().left(4) == "100%")
|
||||
if (ui->label_2->text().left(4) == "100%")
|
||||
{
|
||||
download = 1;
|
||||
ui->label_2->setText(tr("Download Complete."));
|
||||
@ -58,7 +57,7 @@ QString DownloadItem::getName()
|
||||
|
||||
void DownloadItem::readyInstall()
|
||||
{
|
||||
if(!close)
|
||||
if (!close)
|
||||
{
|
||||
ui->progressBar->hide();
|
||||
ui->pushButton_install->setEnabled(true);
|
||||
@ -90,7 +89,7 @@ void DownloadItem::setSpeed(QString s)
|
||||
|
||||
void DownloadItem::install(int t)
|
||||
{
|
||||
if(!isInstall)
|
||||
if (!isInstall)
|
||||
{
|
||||
isInstall = true;
|
||||
ui->pushButton_install->hide();
|
||||
@ -99,7 +98,7 @@ void DownloadItem::install(int t)
|
||||
ui->label_2->setText(tr("Installing"));
|
||||
|
||||
QtConcurrent::run([=]()
|
||||
{
|
||||
{
|
||||
QProcess installer;
|
||||
switch(t)
|
||||
{
|
||||
@ -164,10 +163,9 @@ void DownloadItem::install(int t)
|
||||
|
||||
ui->widget_spinner->hide();
|
||||
DownloadItem::isInstall = false;
|
||||
emit finished();
|
||||
});
|
||||
emit finished(); });
|
||||
// emit finished();
|
||||
qDebug()<<ui->label_filename->text().toUtf8();
|
||||
qDebug() << ui->label_filename->text().toUtf8();
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -8,15 +8,15 @@
|
||||
ProgressButton::ProgressButton(QWidget *parent)
|
||||
: QWidget{parent}
|
||||
{
|
||||
//this->setWindowFlags(Qt::FramelessWindowHint);
|
||||
// this->setWindowFlags(Qt::FramelessWindowHint);
|
||||
this->setAttribute(Qt::WA_TranslucentBackground, true);
|
||||
setMinimumWidth(36);
|
||||
setMinimumHeight(36);
|
||||
svgPath="";
|
||||
backColor=Qt::transparent;
|
||||
svgPath = "";
|
||||
backColor = Qt::transparent;
|
||||
setMouseTracking(true);
|
||||
|
||||
connect(this,&ProgressButton::startProcessing,this,&ProgressButton::operationProcessing,Qt::QueuedConnection);
|
||||
connect(this, &ProgressButton::startProcessing, this, &ProgressButton::operationProcessing, Qt::QueuedConnection);
|
||||
}
|
||||
|
||||
ProgressButton::~ProgressButton()
|
||||
@ -26,63 +26,63 @@ ProgressButton::~ProgressButton()
|
||||
void ProgressButton::paintEvent(QPaintEvent *event)
|
||||
{
|
||||
QPainter painter(this);
|
||||
painter.setRenderHint(QPainter::Antialiasing,true);
|
||||
painter.setRenderHint(QPainter::Antialiasing, true);
|
||||
auto rect = event->rect();
|
||||
|
||||
if(buttonState == state::normal || buttonState == state::hover)
|
||||
if (buttonState == state::normal || buttonState == state::hover)
|
||||
{
|
||||
auto radiu = (rect.height() - 6) / 2;
|
||||
painter.translate(rect.center());
|
||||
painter.setPen(Qt::transparent);
|
||||
painter.setBrush(QColor(buttonState == state::normal ? color : color.darker()));
|
||||
//painter.drawEllipse(QPoint(0,0),radiu,radiu);
|
||||
// painter.drawEllipse(QPoint(0,0),radiu,radiu);
|
||||
|
||||
//radiu -= 3;
|
||||
// radiu -= 3;
|
||||
painter.setBrush(backColor);
|
||||
painter.drawEllipse(QPoint(0,0),radiu,radiu);
|
||||
painter.drawEllipse(QPoint(0, 0), radiu, radiu);
|
||||
|
||||
QSvgRenderer m_svgRender;
|
||||
m_svgRender.load(svgPath);
|
||||
m_svgRender.render(&painter ,QRectF(-radiu / 2,-radiu / 2,radiu,radiu));
|
||||
m_svgRender.render(&painter, QRectF(-radiu / 2, -radiu / 2, radiu, radiu));
|
||||
}
|
||||
else if(buttonState == state::openProgress)
|
||||
else if (buttonState == state::openProgress)
|
||||
{
|
||||
painter.translate(rect.center());
|
||||
auto radiu = (rect.height() - 6) / 2 -3;
|
||||
auto radiu = (rect.height() - 6) / 2 - 3;
|
||||
painter.setBrush(backColor);
|
||||
painter.setPen(QPen(backColor,3));
|
||||
painter.drawEllipse(QPoint(0,0),radiu,radiu);
|
||||
painter.setPen(QPen(backColor, 3));
|
||||
painter.drawEllipse(QPoint(0, 0), radiu, radiu);
|
||||
|
||||
painter.setPen(QPen(backColor,3));
|
||||
painter.setPen(QPen(backColor, 3));
|
||||
|
||||
QSvgRenderer m_svgRender;
|
||||
m_svgRender.load(svgPath);
|
||||
m_svgRender.render(&painter ,QRectF(-radiu / 2,-radiu / 2,radiu,radiu));
|
||||
m_svgRender.render(&painter, QRectF(-radiu / 2, -radiu / 2, radiu, radiu));
|
||||
|
||||
QRect rect = QRect(-radiu, -radiu,
|
||||
radiu*2, radiu*2);
|
||||
radiu * 2, radiu * 2);
|
||||
|
||||
painter.setPen(QPen(color.darker(100),3));
|
||||
painter.setPen(QPen(color.darker(100), 3));
|
||||
auto angle = progress * 360 / 100;
|
||||
painter.drawArc(rect.adjusted(-3,-3,3,3),90 * 16,-static_cast<int>(angle * 16));
|
||||
painter.drawArc(rect.adjusted(-3, -3, 3, 3), 90 * 16, -static_cast<int>(angle * 16));
|
||||
}
|
||||
else if(buttonState == state::closeProgress)
|
||||
else if (buttonState == state::closeProgress)
|
||||
{
|
||||
auto radiu = (rect.height() - 6) / 2;
|
||||
painter.translate(rect.center());
|
||||
painter.setPen(Qt::transparent);
|
||||
painter.setBrush(QColor(0, 0, 0, 63));
|
||||
painter.drawEllipse(QPoint(0,0),radiu,radiu);
|
||||
painter.drawEllipse(QPoint(0, 0), radiu, radiu);
|
||||
|
||||
radiu -= 3;
|
||||
painter.setBrush(backColor);
|
||||
painter.drawEllipse(QPoint(0,0),radiu,radiu);
|
||||
painter.drawEllipse(QPoint(0, 0), radiu, radiu);
|
||||
|
||||
painter.setPen(QPen(color,3,Qt::SolidLine,Qt::RoundCap,Qt::RoundJoin));
|
||||
painter.drawLine(QPoint(-radiu / 3,0),
|
||||
QPoint(-radiu / 5,radiu / 3));
|
||||
painter.drawLine(QPoint(-radiu / 5,radiu / 3),
|
||||
QPoint(radiu / 4,-radiu / 4));
|
||||
painter.setPen(QPen(color, 3, Qt::SolidLine, Qt::RoundCap, Qt::RoundJoin));
|
||||
painter.drawLine(QPoint(-radiu / 3, 0),
|
||||
QPoint(-radiu / 5, radiu / 3));
|
||||
painter.drawLine(QPoint(-radiu / 5, radiu / 3),
|
||||
QPoint(radiu / 4, -radiu / 4));
|
||||
}
|
||||
}
|
||||
|
||||
@ -90,12 +90,12 @@ void ProgressButton::setProgress(int progress)
|
||||
{
|
||||
buttonState = state::openProgress;
|
||||
ProgressButton::progress = progress;
|
||||
if(progress == 0)
|
||||
if (progress == 0)
|
||||
{
|
||||
buttonState = state::normal;
|
||||
update();
|
||||
}
|
||||
if(progress == 100)
|
||||
if (progress == 100)
|
||||
{
|
||||
buttonState = state::closeProgress;
|
||||
update();
|
||||
@ -127,7 +127,7 @@ void ProgressButton::setColor(QColor color)
|
||||
|
||||
void ProgressButton::leaveEvent(QEvent *event)
|
||||
{
|
||||
if(buttonState == state::hover)
|
||||
if (buttonState == state::hover)
|
||||
{
|
||||
buttonState = state::normal;
|
||||
update();
|
||||
@ -137,12 +137,12 @@ void ProgressButton::leaveEvent(QEvent *event)
|
||||
|
||||
void ProgressButton::mousePressEvent(QMouseEvent *event)
|
||||
{
|
||||
if(buttonState == state::hover || buttonState == state::normal)
|
||||
if (buttonState == state::hover || buttonState == state::normal)
|
||||
{
|
||||
widthChangeValue = (this->width() - 6) / 2;
|
||||
update();
|
||||
}
|
||||
else if(buttonState == state::closeProgress)
|
||||
else if (buttonState == state::closeProgress)
|
||||
{
|
||||
update();
|
||||
}
|
||||
@ -152,24 +152,21 @@ void ProgressButton::mousePressEvent(QMouseEvent *event)
|
||||
|
||||
void ProgressButton::operationProcessing()
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
const int RADIUS = 60;
|
||||
WaterDrop::WaterDrop(QWidget *parent)
|
||||
: QWidget(parent)
|
||||
, m_waterDropAnimation(nullptr)
|
||||
, m_animationRadius(0)
|
||||
: QWidget(parent), m_waterDropAnimation(nullptr), m_animationRadius(0)
|
||||
{
|
||||
this->setFixedSize(QSize(RADIUS * 2, RADIUS * 2));
|
||||
this->setWindowFlags(Qt::FramelessWindowHint | Qt::Tool);
|
||||
this->setAttribute(Qt::WA_TranslucentBackground);
|
||||
this->setAttribute(Qt::WA_DeleteOnClose);
|
||||
m_waterDropAnimation = new QVariantAnimation(this);
|
||||
// m_waterDropAnimation->setEasingCurve(QEasingCurve(static_cast<QEasingCurve::Type>(QRandomGenerator::global()->bounded(40))));
|
||||
// m_waterDropAnimation->setEasingCurve(QEasingCurve(static_cast<QEasingCurve::Type>(QRandomGenerator::global()->bounded(40))));
|
||||
}
|
||||
|
||||
//把鼠标点击的点转换为圆心点坐标
|
||||
// 把鼠标点击的点转换为圆心点坐标
|
||||
void WaterDrop::move(const QPoint &point)
|
||||
{
|
||||
QPoint translatePoint = point - QPoint(RADIUS, RADIUS);
|
||||
@ -196,7 +193,7 @@ void WaterDrop::paintEvent(QPaintEvent *event)
|
||||
pen.setColor(QColor(0xffffff80));
|
||||
pen.setWidth(5);
|
||||
painter.setPen(pen);
|
||||
painter.drawEllipse(event->rect().center(),m_animationRadius, m_animationRadius);
|
||||
painter.drawEllipse(event->rect().center(), m_animationRadius, m_animationRadius);
|
||||
}
|
||||
|
||||
void WaterDrop::onRaduisChanged(QVariant value)
|
||||
|
@ -5,13 +5,13 @@
|
||||
#include <QDebug>
|
||||
SmoothListWidget::SmoothListWidget(QWidget *parent) : QListWidget(parent)
|
||||
{
|
||||
vScrollBar->setOrientation(Qt::Orientation::Vertical); //将滚动条设置为纵向
|
||||
setVerticalScrollBar(vScrollBar); //设置纵向滚动条
|
||||
vScrollBar->setOrientation(Qt::Orientation::Vertical); // 将滚动条设置为纵向
|
||||
setVerticalScrollBar(vScrollBar); // 设置纵向滚动条
|
||||
connect(vScrollBar, SIGNAL(valueChanged(int)), this, SLOT(onSliderChanged(int)));
|
||||
}
|
||||
void SmoothListWidget::wheelEvent(QWheelEvent *e)
|
||||
{
|
||||
//当捕获到事件后,调用相对滚动的槽函数
|
||||
// 当捕获到事件后,调用相对滚动的槽函数
|
||||
vScrollBar->scroll(e->angleDelta().y());
|
||||
}
|
||||
void SmoothListWidget::onSliderChanged(int p)
|
||||
@ -21,5 +21,5 @@ void SmoothListWidget::onSliderChanged(int p)
|
||||
{
|
||||
emit reachedBottom(); // 1
|
||||
}
|
||||
emit msliderChanged(p); // 2
|
||||
emit msliderChanged(p); // 2
|
||||
}
|
||||
|
@ -1,56 +1,56 @@
|
||||
#include "smoothscrollbar.h"
|
||||
#include <QWheelEvent>
|
||||
#include <QDebug>
|
||||
SmoothScrollBar::SmoothScrollBar(QWidget* parent):QScrollBar(parent)
|
||||
SmoothScrollBar::SmoothScrollBar(QWidget *parent) : QScrollBar(parent)
|
||||
{
|
||||
m_scrollAni=new QPropertyAnimation(this);
|
||||
m_scrollAni = new QPropertyAnimation(this);
|
||||
m_scrollAni->setTargetObject(this);
|
||||
m_scrollAni->setPropertyName("value");
|
||||
m_scrollAni->setEasingCurve(QEasingCurve::OutQuint); //设置动画曲线,在Qt文档中有详细的介绍
|
||||
m_scrollAni->setDuration(500); //设置动画时间,数值越小播放越快
|
||||
m_targetValue_v=value(); //将m_targetValue_v初始化
|
||||
m_scrollAni->setEasingCurve(QEasingCurve::OutQuint); // 设置动画曲线,在Qt文档中有详细的介绍
|
||||
m_scrollAni->setDuration(500); // 设置动画时间,数值越小播放越快
|
||||
m_targetValue_v = value(); // 将m_targetValue_v初始化
|
||||
}
|
||||
|
||||
void SmoothScrollBar::setValue(int value)
|
||||
{
|
||||
m_scrollAni->stop();//停止现在的动画,防止出现冲突
|
||||
m_scrollAni->setStartValue(this->value()); //设置动画滚动的初始值为当前位置
|
||||
m_scrollAni->setEndValue(value); //设置动画的结束位置为目标值
|
||||
m_scrollAni->start(); //开始动画
|
||||
m_scrollAni->stop(); // 停止现在的动画,防止出现冲突
|
||||
m_scrollAni->setStartValue(this->value()); // 设置动画滚动的初始值为当前位置
|
||||
m_scrollAni->setEndValue(value); // 设置动画的结束位置为目标值
|
||||
m_scrollAni->start(); // 开始动画
|
||||
}
|
||||
void SmoothScrollBar::scrollTop()
|
||||
{
|
||||
setValue(-m_targetValue_v); //开始动画
|
||||
m_targetValue_v=0;
|
||||
setValue(-m_targetValue_v); // 开始动画
|
||||
m_targetValue_v = 0;
|
||||
}
|
||||
void SmoothScrollBar::scroll(int value)
|
||||
{
|
||||
//这里推荐评论区中大佬优化的写法
|
||||
if(m_targetValue_v-value>=0)
|
||||
// 这里推荐评论区中大佬优化的写法
|
||||
if (m_targetValue_v - value >= 0)
|
||||
{
|
||||
m_targetValue_v-=value; //将目标值和相对位置进行运算
|
||||
setValue(m_targetValue_v); //开始动画
|
||||
m_targetValue_v -= value; // 将目标值和相对位置进行运算
|
||||
setValue(m_targetValue_v); // 开始动画
|
||||
}
|
||||
}
|
||||
|
||||
void SmoothScrollBar::mousePressEvent(QMouseEvent *e)
|
||||
{
|
||||
//当使用鼠标操作滚动条时,不会刷新m_targetValue_v的值,因而需要重写事件,对其进行刷新。
|
||||
// 当使用鼠标操作滚动条时,不会刷新m_targetValue_v的值,因而需要重写事件,对其进行刷新。
|
||||
m_scrollAni->stop();
|
||||
QScrollBar::mousePressEvent(e);
|
||||
m_targetValue_v=value();
|
||||
m_targetValue_v = value();
|
||||
}
|
||||
|
||||
void SmoothScrollBar::mouseReleaseEvent(QMouseEvent *e)
|
||||
{
|
||||
m_scrollAni->stop();
|
||||
QScrollBar::mouseReleaseEvent(e);
|
||||
m_targetValue_v=value();
|
||||
m_targetValue_v = value();
|
||||
}
|
||||
|
||||
void SmoothScrollBar::mouseMoveEvent(QMouseEvent *e)
|
||||
{
|
||||
m_scrollAni->stop();
|
||||
QScrollBar::mouseMoveEvent(e);
|
||||
m_targetValue_v=value();
|
||||
m_targetValue_v = value();
|
||||
}
|
||||
|
@ -13,7 +13,8 @@ WebEnginePage::~WebEnginePage()
|
||||
|
||||
void WebEnginePage::setUrl(const QUrl &url)
|
||||
{
|
||||
if (m_currentUrl == url) {
|
||||
if (m_currentUrl == url)
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
@ -32,7 +33,8 @@ QWebEnginePage *WebEnginePage::createWindow(QWebEnginePage::WebWindowType type)
|
||||
|
||||
void WebEnginePage::slotUrlChanged(const QUrl &url)
|
||||
{
|
||||
if (m_currentUrl == url) {
|
||||
if (m_currentUrl == url)
|
||||
{
|
||||
sender()->deleteLater();
|
||||
return;
|
||||
}
|
||||
|
@ -3,23 +3,22 @@
|
||||
#include <QGraphicsOpacityEffect>
|
||||
#include <QPropertyAnimation>
|
||||
#include <QDebug>
|
||||
DownloadListWidget::DownloadListWidget(QWidget *parent) :
|
||||
DBlurEffectWidget(parent),
|
||||
ui(new Ui::DownloadListWidget)
|
||||
DownloadListWidget::DownloadListWidget(QWidget *parent) : DBlurEffectWidget(parent),
|
||||
ui(new Ui::DownloadListWidget)
|
||||
{
|
||||
ui->setupUi(this);
|
||||
installEventFilter(this);
|
||||
this->setAttribute(Qt::WA_Hover,true);
|
||||
this->setAttribute(Qt::WA_Hover, true);
|
||||
setFocus();
|
||||
setFixedSize(500,400);
|
||||
setFixedSize(500, 400);
|
||||
setMaskAlpha(250);
|
||||
ui->listWidget->hide();
|
||||
ui->widget->show();
|
||||
// 计算显示下载速度
|
||||
download_speed.setInterval(1000);
|
||||
download_speed.start();
|
||||
connect(&download_speed,&QTimer::timeout,[=]()
|
||||
{
|
||||
connect(&download_speed, &QTimer::timeout, [=]()
|
||||
{
|
||||
if(isdownload && theSpeed == "")
|
||||
{
|
||||
size1 = download_size;
|
||||
@ -47,13 +46,13 @@ DownloadListWidget::DownloadListWidget(QWidget *parent) :
|
||||
downloaditemlist[nowDownload - 1]->setSpeed(theSpeed);
|
||||
}else{
|
||||
emit downloadProgress(0);
|
||||
}
|
||||
});
|
||||
} });
|
||||
}
|
||||
|
||||
DownloadListWidget::~DownloadListWidget()
|
||||
{
|
||||
if (downloadController) {
|
||||
if (downloadController)
|
||||
{
|
||||
downloadController->stopDownload();
|
||||
downloadController->deleteLater();
|
||||
}
|
||||
@ -64,41 +63,41 @@ DownloadListWidget::~DownloadListWidget()
|
||||
void DownloadListWidget::clearItem()
|
||||
{
|
||||
ui->listWidget->vScrollBar->scrollTop();
|
||||
int n=ui->listWidget->count();
|
||||
for(int i=0;i<n;i++)
|
||||
int n = ui->listWidget->count();
|
||||
for (int i = 0; i < n; i++)
|
||||
{
|
||||
QListWidgetItem *item = ui->listWidget->takeItem(0);
|
||||
QWidget *card = ui->listWidget->itemWidget(item);
|
||||
delete card;
|
||||
card = NULL;
|
||||
card = NULL;
|
||||
delete item;
|
||||
item = NULL;
|
||||
item = NULL;
|
||||
}
|
||||
ui->listWidget->clear();
|
||||
}
|
||||
void DownloadListWidget::addItem(QString name,QString fileName,QString pkgName,const QPixmap icon,QString downloadurl)
|
||||
void DownloadListWidget::addItem(QString name, QString fileName, QString pkgName, const QPixmap icon, QString downloadurl)
|
||||
{
|
||||
if(fileName.isEmpty())
|
||||
if (fileName.isEmpty())
|
||||
{
|
||||
return;
|
||||
}
|
||||
urList.append(downloadurl);
|
||||
allDownload += 1;
|
||||
DownloadItem *di=new DownloadItem(this);
|
||||
dlist<<downloadurl;
|
||||
downloaditemlist<<di;
|
||||
DownloadItem *di = new DownloadItem(this);
|
||||
dlist << downloadurl;
|
||||
downloaditemlist << di;
|
||||
di->setName(name);
|
||||
di->setFileName(fileName);
|
||||
di->pkgName=pkgName;
|
||||
di->pkgName = pkgName;
|
||||
di->seticon(icon);
|
||||
QListWidgetItem* pItem = new QListWidgetItem();
|
||||
QListWidgetItem *pItem = new QListWidgetItem();
|
||||
pItem->setSizeHint(QSize(240, 50));
|
||||
ui->listWidget->addItem(pItem);
|
||||
ui->listWidget->setItemWidget(pItem, di);
|
||||
if(!isBusy)
|
||||
if (!isBusy)
|
||||
{
|
||||
nowDownload += 1;
|
||||
startRequest(urList.at(nowDownload - 1), fileName); // 进行链接请求
|
||||
startRequest(urList.at(nowDownload - 1), fileName); // 进行链接请求
|
||||
}
|
||||
}
|
||||
|
||||
@ -120,10 +119,10 @@ void DownloadListWidget::startRequest(QUrl url, QString fileName)
|
||||
isdownload = true;
|
||||
downloaditemlist[allDownload - 1]->free = false;
|
||||
|
||||
downloadController = new DownloadController(this); // 并发下载,在点击下载按钮的时候才会初始化
|
||||
downloadController = new DownloadController(this); // 并发下载,在点击下载按钮的时候才会初始化
|
||||
connect(downloadController, &DownloadController::downloadProcess, this, &DownloadListWidget::updateDataReadProgress);
|
||||
connect(downloadController, &DownloadController::downloadFinished, this, &DownloadListWidget::httpFinished);
|
||||
//connect(downloadController, &DownloadController::errorOccur, this, [=](QString msg){this->sendNotification(msg);});
|
||||
// connect(downloadController, &DownloadController::errorOccur, this, [=](QString msg){this->sendNotification(msg);});
|
||||
downloadController->setFilename(fileName);
|
||||
downloadController->startDownload(url.toString());
|
||||
}
|
||||
@ -135,37 +134,37 @@ void DownloadListWidget::httpFinished() // 完成下载
|
||||
downloaditemlist[nowDownload - 1]->readyInstall();
|
||||
downloaditemlist[nowDownload - 1]->free = true;
|
||||
emit downloadFinished();
|
||||
if(nowDownload < allDownload)
|
||||
if (nowDownload < allDownload)
|
||||
{
|
||||
// 如果有排队则下载下一个
|
||||
qDebug() << "切换下一个下载...";
|
||||
nowDownload += 1;
|
||||
while(downloaditemlist[nowDownload - 1]->close)
|
||||
while (downloaditemlist[nowDownload - 1]->close)
|
||||
{
|
||||
nowDownload += 1;
|
||||
if(nowDownload >= allDownload)
|
||||
if (nowDownload >= allDownload)
|
||||
{
|
||||
nowDownload = allDownload;
|
||||
return;
|
||||
}
|
||||
}
|
||||
QString fileName = downloaditemlist[nowDownload - 1]->getName();
|
||||
startRequest(urList.at(nowDownload-1), fileName);
|
||||
startRequest(urList.at(nowDownload - 1), fileName);
|
||||
}
|
||||
}
|
||||
|
||||
void DownloadListWidget::updateDataReadProgress(QString speedInfo, qint64 bytesRead, qint64 totalBytes)
|
||||
{
|
||||
if(totalBytes <= 0)
|
||||
if (totalBytes <= 0)
|
||||
{
|
||||
return;
|
||||
}
|
||||
theSpeed = speedInfo;
|
||||
downloaditemlist[nowDownload - 1]->setMax(10000); // 最大值
|
||||
downloaditemlist[nowDownload - 1]->setValue(int(bytesRead * 100 / totalBytes) * 100); // 当前值
|
||||
downloaditemlist[nowDownload - 1]->setMax(10000); // 最大值
|
||||
downloaditemlist[nowDownload - 1]->setValue(int(bytesRead * 100 / totalBytes) * 100); // 当前值
|
||||
emit downloadProgress(int(bytesRead * 100 / totalBytes));
|
||||
download_size = bytesRead;
|
||||
if(downloaditemlist[nowDownload - 1]->close)
|
||||
if (downloaditemlist[nowDownload - 1]->close)
|
||||
{
|
||||
// 随时检测下载是否被取消
|
||||
downloadController->disconnect();
|
||||
@ -175,21 +174,23 @@ void DownloadListWidget::updateDataReadProgress(QString speedInfo, qint64 bytesR
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
void DownloadListWidget::m_move(int x,int y)
|
||||
void DownloadListWidget::m_move(int x, int y)
|
||||
{
|
||||
m_rect.setX(x);
|
||||
m_rect.setY(y);
|
||||
move(x,y);
|
||||
move(x, y);
|
||||
return;
|
||||
}
|
||||
bool DownloadListWidget::eventFilter(QObject *watched, QEvent *event)
|
||||
{
|
||||
if (Q_NULLPTR == watched) {
|
||||
if (Q_NULLPTR == watched)
|
||||
{
|
||||
return false;
|
||||
}
|
||||
if (QEvent::ActivationChange == event->type()) {
|
||||
if(QApplication::activeWindow() != this){
|
||||
if (QEvent::ActivationChange == event->type())
|
||||
{
|
||||
if (QApplication::activeWindow() != this)
|
||||
{
|
||||
this->close();
|
||||
}
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user