diff --git a/debian/spark-store.prerm b/debian/spark-store.prerm index 2d04f0b..c6eef81 100755 --- a/debian/spark-store.prerm +++ b/debian/spark-store.prerm @@ -32,4 +32,5 @@ if [ "$1" = "remove" ] || [ "$1" = "purge" ] ; then apt-key del '9D9A A859 F750 24B1 A1EC E16E 0E41 D354 A29A 440C' else echo "非卸载操作,不进行配置清理" + (echo "关闭已有 spark-store..") && (pkill spark-store) || echo "继续安装 spark-store.." fi diff --git a/src/application.cpp b/src/application.cpp index e6c861e..f9928e7 100644 --- a/src/application.cpp +++ b/src/application.cpp @@ -113,6 +113,11 @@ void Application::setMainWindow(MainWindow *window) #endif } +MainWindow *Application::mainWindow() +{ + return m_mainWindow; +} + void Application::initAboutDialog() { if (m_mainWindow == nullptr) diff --git a/src/application.h b/src/application.h index 25aee94..de66a7e 100644 --- a/src/application.h +++ b/src/application.h @@ -20,7 +20,9 @@ public: static void checkAppConfigLocation(); void setBuildDateTime(const QString &buildDateTime); + void setMainWindow(MainWindow *window); + MainWindow *mainWindow(); private: void initAboutDialog(); diff --git a/src/mainwindow-dtk.cpp b/src/mainwindow-dtk.cpp index 19582d0..9ba4da2 100644 --- a/src/mainwindow-dtk.cpp +++ b/src/mainwindow-dtk.cpp @@ -104,6 +104,22 @@ void MainWindow::openUrl(const QString &url) } } +bool MainWindow::isCloseWindowAnimation() +{ + return closeWindowAnimation; +} + +void MainWindow::closeEvent(QCloseEvent *event) +{ + // 判断下载任务数量,如果没有要下载的,就直接退出主程序 + if(!downloadlistwidget->isDownloadInProcess()){ + // 已经全部下载完成 + qApp->quit(); + } + + BaseWidgetOpacity::closeEvent(event); +} + void MainWindow::initUI() { setWindowTitle(QObject::tr("Spark Store")); diff --git a/src/mainwindow-dtk.h b/src/mainwindow-dtk.h index 251df1f..11fd60e 100644 --- a/src/mainwindow-dtk.h +++ b/src/mainwindow-dtk.h @@ -29,6 +29,11 @@ public: void openUrl(const QString &url); + bool isCloseWindowAnimation(); + +protected: + void closeEvent(QCloseEvent *event) override; + private: void initUI(); void initTitleBar(); diff --git a/src/widgets/base/basewidgetopacity.cpp b/src/widgets/base/basewidgetopacity.cpp index 3874b7e..0c137cc 100644 --- a/src/widgets/base/basewidgetopacity.cpp +++ b/src/widgets/base/basewidgetopacity.cpp @@ -1,6 +1,7 @@ #include "basewidgetopacity.h" #include "utils/widgetanimation.h" #include "utils/utils.h" +#include "widgets/downloadlistwidget.h" #include <QSettings> #include <QStandardPaths> @@ -43,6 +44,7 @@ void BaseWidgetOpacity::closeEvent(QCloseEvent *event) bool isWayland = Utils::isWayland(); if (isWayland) { + closeWindowAnimation = true; return DBlurEffectWidget::closeEvent(event); } diff --git a/src/widgets/common/downloaditem.cpp b/src/widgets/common/downloaditem.cpp index 8ea7d56..8142790 100644 --- a/src/widgets/common/downloaditem.cpp +++ b/src/widgets/common/downloaditem.cpp @@ -111,7 +111,7 @@ void DownloadItem::setSpeed(QString s) /*************************************************************** * @brief 安装当前应用 * @param int t, t为安装方式,可以为 0,1,2 - * @note 备注 + * @note 执行这个函数时,需要已经检查是否可以安装,但该函数仍然会再检测一次! * @Sample usage: DownloadItem::install(0); **************************************************************/ void DownloadItem::install(int t) diff --git a/src/widgets/downloadlistwidget.cpp b/src/widgets/downloadlistwidget.cpp index ba3c499..adfdc08 100644 --- a/src/widgets/downloadlistwidget.cpp +++ b/src/widgets/downloadlistwidget.cpp @@ -5,6 +5,7 @@ #include "backend/downloadworker.h" #include "utils/utils.h" #include "application.h" +#include "mainwindow-dtk.h" #include <QDesktopServices> #include <QtConcurrent> @@ -70,6 +71,15 @@ DownloadListWidget::~DownloadListWidget() delete ui; } +bool DownloadListWidget::isDownloadInProcess() +{ + if (toDownload > 0) + { + return true; + } + return false; +} + void DownloadListWidget::clearItem() { ui->listWidget->clear(); @@ -83,6 +93,7 @@ DownloadItem* DownloadListWidget::addItem(QString name, QString fileName, QStrin } urList.append(downloadurl); allDownload += 1; + toDownload += 1; DownloadItem *di = new DownloadItem; dlist << downloadurl; downloaditemlist << di; @@ -126,8 +137,7 @@ void DownloadListWidget::startRequest(QUrl url, QString fileName) { downloadController = new DownloadController; // 并发下载,在第一次点击下载按钮的时候才会初始化 } - - if (downloadController) + else { downloadController->disconnect(); downloadController->stopDownload(); @@ -153,17 +163,33 @@ void DownloadListWidget::httpFinished() // 完成下载 QtConcurrent::run([=]() { - while (downloaditemlist[nowDownload - 1]->readyInstall() == -1) + while (downloaditemlist[nowDownload - 1]->readyInstall() == -1) // 安装当前应用,堵塞安装,后面的下载suspend { continue; } + toDownload -= 1; // 安装完以后减少待安装数目 + qDebug() << "Download: 还没有下载的数目:" << toDownload; + + if(toDownload == 0){ + Application *app = qobject_cast<Application *>(qApp); + MainWindow *mainWindow = app->mainWindow(); + if(mainWindow->isCloseWindowAnimation() == true){ + qDebug()<< "Download: 后台安装结束,退出程序"; + qApp->quit(); + } + else{ + delete app; + delete mainWindow; + } + + } downloaditemlist[nowDownload - 1]->free = true; emit downloadFinished(); if (nowDownload < allDownload) { // 如果有排队则下载下一个 - qDebug() << "切换下一个下载..."; + qDebug() << "Download: 切换下一个下载..."; nowDownload += 1; while (downloaditemlist[nowDownload - 1]->close) { diff --git a/src/widgets/downloadlistwidget.h b/src/widgets/downloadlistwidget.h index 9500a11..09517f5 100644 --- a/src/widgets/downloadlistwidget.h +++ b/src/widgets/downloadlistwidget.h @@ -22,12 +22,15 @@ public: DownloadItem *addItem(QString name, QString fileName, QString pkgName, const QPixmap icon, QString downloadurl); int nowDownload = 0; int allDownload = 0; + int toDownload = 0; QList<DownloadItem *> getDIList(); QList<QUrl> getUrlList(); void m_move(int x, int y); explicit DownloadListWidget(QWidget *parent = nullptr); ~DownloadListWidget() override; + bool isDownloadInProcess(); + protected: void mouseMoveEvent(QMouseEvent *event) override; diff --git a/translations/spark-store_en.ts b/translations/spark-store_en.ts index a788a4c..d70c3b5 100644 --- a/translations/spark-store_en.ts +++ b/translations/spark-store_en.ts @@ -240,12 +240,12 @@ <context> <name>DAboutDialog</name> <message> - <location filename="../src/application.cpp" line="133"/> + <location filename="../src/application.cpp" line="138"/> <source>Version: %1</source> <translation type="unfinished"></translation> </message> <message> - <location filename="../src/application.cpp" line="143"/> + <location filename="../src/application.cpp" line="148"/> <source>%1 is released under %2</source> <translation type="unfinished"></translation> </message> @@ -452,33 +452,33 @@ <translation type="unfinished"></translation> </message> <message> - <location filename="../src/mainwindow-dtk.cpp" line="170"/> + <location filename="../src/mainwindow-dtk.cpp" line="186"/> <source>Submit App</source> <translation type="unfinished"></translation> </message> <message> - <location filename="../src/mainwindow-dtk.cpp" line="171"/> + <location filename="../src/mainwindow-dtk.cpp" line="187"/> <source>Submit App with client(Recommanded)</source> <translation type="unfinished"></translation> </message> <message> - <location filename="../src/mainwindow-dtk.cpp" line="172"/> + <location filename="../src/mainwindow-dtk.cpp" line="188"/> <source>Settings</source> <translation type="unfinished"></translation> </message> <message> - <location filename="../src/mainwindow-dtk.cpp" line="173"/> + <location filename="../src/mainwindow-dtk.cpp" line="189"/> <source>APP Upgrade and Install Settings</source> <translation type="unfinished"></translation> </message> <message> - <location filename="../src/mainwindow-dtk.cpp" line="129"/> - <location filename="../src/mainwindow-dtk.cpp" line="224"/> + <location filename="../src/mainwindow-dtk.cpp" line="145"/> + <location filename="../src/mainwindow-dtk.cpp" line="240"/> <source>Spark Store</source> <translation type="unfinished"></translation> </message> <message> - <location filename="../src/mainwindow-dtk.cpp" line="134"/> + <location filename="../src/mainwindow-dtk.cpp" line="150"/> <source>Search or enter spk://</source> <translation type="unfinished"></translation> </message> @@ -488,7 +488,7 @@ <message> <location filename="../src/application.cpp" line="33"/> <location filename="../src/application.cpp" line="34"/> - <location filename="../src/mainwindow-dtk.cpp" line="109"/> + <location filename="../src/mainwindow-dtk.cpp" line="125"/> <source>Spark Store</source> <translation type="unfinished"></translation> </message> @@ -498,17 +498,17 @@ <translation type="unfinished"></translation> </message> <message> - <location filename="../src/application.cpp" line="140"/> + <location filename="../src/application.cpp" line="145"/> <source>Spark Project</source> <translation type="unfinished"></translation> </message> <message> - <location filename="../src/widgets/downloadlistwidget.cpp" line="17"/> + <location filename="../src/widgets/downloadlistwidget.cpp" line="18"/> <source>Download list</source> <translation type="unfinished"></translation> </message> <message> - <location filename="../src/mainwindow-dtk.cpp" line="227"/> + <location filename="../src/mainwindow-dtk.cpp" line="243"/> <source>Show MainWindow</source> <translation type="unfinished"></translation> </message> @@ -619,12 +619,12 @@ <context> <name>TitleBarMenu</name> <message> - <location filename="../src/mainwindow-dtk.cpp" line="228"/> + <location filename="../src/mainwindow-dtk.cpp" line="244"/> <source>About</source> <translation type="unfinished"></translation> </message> <message> - <location filename="../src/mainwindow-dtk.cpp" line="229"/> + <location filename="../src/mainwindow-dtk.cpp" line="245"/> <source>Exit</source> <translation type="unfinished"></translation> </message> diff --git a/translations/spark-store_fr.ts b/translations/spark-store_fr.ts index ded8eee..356294c 100644 --- a/translations/spark-store_fr.ts +++ b/translations/spark-store_fr.ts @@ -240,12 +240,12 @@ <context> <name>DAboutDialog</name> <message> - <location filename="../src/application.cpp" line="133"/> + <location filename="../src/application.cpp" line="138"/> <source>Version: %1</source> <translation type="unfinished"></translation> </message> <message> - <location filename="../src/application.cpp" line="143"/> + <location filename="../src/application.cpp" line="148"/> <source>%1 is released under %2</source> <translation type="unfinished"></translation> </message> @@ -452,33 +452,33 @@ <translation type="unfinished"></translation> </message> <message> - <location filename="../src/mainwindow-dtk.cpp" line="170"/> + <location filename="../src/mainwindow-dtk.cpp" line="186"/> <source>Submit App</source> <translation type="unfinished"></translation> </message> <message> - <location filename="../src/mainwindow-dtk.cpp" line="171"/> + <location filename="../src/mainwindow-dtk.cpp" line="187"/> <source>Submit App with client(Recommanded)</source> <translation type="unfinished"></translation> </message> <message> - <location filename="../src/mainwindow-dtk.cpp" line="172"/> + <location filename="../src/mainwindow-dtk.cpp" line="188"/> <source>Settings</source> <translation type="unfinished"></translation> </message> <message> - <location filename="../src/mainwindow-dtk.cpp" line="173"/> + <location filename="../src/mainwindow-dtk.cpp" line="189"/> <source>APP Upgrade and Install Settings</source> <translation type="unfinished"></translation> </message> <message> - <location filename="../src/mainwindow-dtk.cpp" line="129"/> - <location filename="../src/mainwindow-dtk.cpp" line="224"/> + <location filename="../src/mainwindow-dtk.cpp" line="145"/> + <location filename="../src/mainwindow-dtk.cpp" line="240"/> <source>Spark Store</source> <translation type="unfinished"></translation> </message> <message> - <location filename="../src/mainwindow-dtk.cpp" line="134"/> + <location filename="../src/mainwindow-dtk.cpp" line="150"/> <source>Search or enter spk://</source> <translation type="unfinished"></translation> </message> @@ -488,7 +488,7 @@ <message> <location filename="../src/application.cpp" line="33"/> <location filename="../src/application.cpp" line="34"/> - <location filename="../src/mainwindow-dtk.cpp" line="109"/> + <location filename="../src/mainwindow-dtk.cpp" line="125"/> <source>Spark Store</source> <translation type="unfinished"></translation> </message> @@ -498,17 +498,17 @@ <translation type="unfinished"></translation> </message> <message> - <location filename="../src/application.cpp" line="140"/> + <location filename="../src/application.cpp" line="145"/> <source>Spark Project</source> <translation type="unfinished"></translation> </message> <message> - <location filename="../src/widgets/downloadlistwidget.cpp" line="17"/> + <location filename="../src/widgets/downloadlistwidget.cpp" line="18"/> <source>Download list</source> <translation type="unfinished"></translation> </message> <message> - <location filename="../src/mainwindow-dtk.cpp" line="227"/> + <location filename="../src/mainwindow-dtk.cpp" line="243"/> <source>Show MainWindow</source> <translation type="unfinished"></translation> </message> @@ -619,12 +619,12 @@ <context> <name>TitleBarMenu</name> <message> - <location filename="../src/mainwindow-dtk.cpp" line="228"/> + <location filename="../src/mainwindow-dtk.cpp" line="244"/> <source>About</source> <translation type="unfinished"></translation> </message> <message> - <location filename="../src/mainwindow-dtk.cpp" line="229"/> + <location filename="../src/mainwindow-dtk.cpp" line="245"/> <source>Exit</source> <translation type="unfinished"></translation> </message> diff --git a/translations/spark-store_zh_CN.ts b/translations/spark-store_zh_CN.ts index 8617da2..491792c 100644 --- a/translations/spark-store_zh_CN.ts +++ b/translations/spark-store_zh_CN.ts @@ -240,12 +240,12 @@ <context> <name>DAboutDialog</name> <message> - <location filename="../src/application.cpp" line="133"/> + <location filename="../src/application.cpp" line="138"/> <source>Version: %1</source> <translation>版本:%1</translation> </message> <message> - <location filename="../src/application.cpp" line="143"/> + <location filename="../src/application.cpp" line="148"/> <source>%1 is released under %2</source> <translation>%1遵循%2协议发布</translation> </message> @@ -452,33 +452,33 @@ <translation>更新</translation> </message> <message> - <location filename="../src/mainwindow-dtk.cpp" line="170"/> + <location filename="../src/mainwindow-dtk.cpp" line="186"/> <source>Submit App</source> <translation>投递应用</translation> </message> <message> - <location filename="../src/mainwindow-dtk.cpp" line="171"/> + <location filename="../src/mainwindow-dtk.cpp" line="187"/> <source>Submit App with client(Recommanded)</source> <translation>使用本地投稿器投递应用(推荐)</translation> </message> <message> - <location filename="../src/mainwindow-dtk.cpp" line="172"/> + <location filename="../src/mainwindow-dtk.cpp" line="188"/> <source>Settings</source> <translation>设置</translation> </message> <message> - <location filename="../src/mainwindow-dtk.cpp" line="173"/> + <location filename="../src/mainwindow-dtk.cpp" line="189"/> <source>APP Upgrade and Install Settings</source> <translation>应用更新和安装设置</translation> </message> <message> - <location filename="../src/mainwindow-dtk.cpp" line="129"/> - <location filename="../src/mainwindow-dtk.cpp" line="224"/> + <location filename="../src/mainwindow-dtk.cpp" line="145"/> + <location filename="../src/mainwindow-dtk.cpp" line="240"/> <source>Spark Store</source> <translation>星火应用商店</translation> </message> <message> - <location filename="../src/mainwindow-dtk.cpp" line="134"/> + <location filename="../src/mainwindow-dtk.cpp" line="150"/> <source>Search or enter spk://</source> <translation>搜索或打开链接</translation> </message> @@ -488,7 +488,7 @@ <message> <location filename="../src/application.cpp" line="33"/> <location filename="../src/application.cpp" line="34"/> - <location filename="../src/mainwindow-dtk.cpp" line="109"/> + <location filename="../src/mainwindow-dtk.cpp" line="125"/> <source>Spark Store</source> <translation>星火应用商店</translation> </message> @@ -498,17 +498,17 @@ <translation><span style=' font-size:10pt;font-weight:60;'>一款由社区提供的应用商店</span><br/><a href='https://www.spark-app.store/'>https://www.spark-app.store</a><br/><span style=' font-size:12pt;'>星火计划开发者</span></translation> </message> <message> - <location filename="../src/application.cpp" line="140"/> + <location filename="../src/application.cpp" line="145"/> <source>Spark Project</source> <translation>星火计划</translation> </message> <message> - <location filename="../src/widgets/downloadlistwidget.cpp" line="17"/> + <location filename="../src/widgets/downloadlistwidget.cpp" line="18"/> <source>Download list</source> <translation>下载列表</translation> </message> <message> - <location filename="../src/mainwindow-dtk.cpp" line="227"/> + <location filename="../src/mainwindow-dtk.cpp" line="243"/> <source>Show MainWindow</source> <translation>显示主窗口</translation> </message> @@ -619,12 +619,12 @@ <context> <name>TitleBarMenu</name> <message> - <location filename="../src/mainwindow-dtk.cpp" line="228"/> + <location filename="../src/mainwindow-dtk.cpp" line="244"/> <source>About</source> <translation>关于</translation> </message> <message> - <location filename="../src/mainwindow-dtk.cpp" line="229"/> + <location filename="../src/mainwindow-dtk.cpp" line="245"/> <source>Exit</source> <translation>退出</translation> </message> diff --git a/translations/spark-store_zh_TW.ts b/translations/spark-store_zh_TW.ts index 5c4d860..64bc98e 100644 --- a/translations/spark-store_zh_TW.ts +++ b/translations/spark-store_zh_TW.ts @@ -240,12 +240,12 @@ <context> <name>DAboutDialog</name> <message> - <location filename="../src/application.cpp" line="133"/> + <location filename="../src/application.cpp" line="138"/> <source>Version: %1</source> <translation>版本:%1</translation> </message> <message> - <location filename="../src/application.cpp" line="143"/> + <location filename="../src/application.cpp" line="148"/> <source>%1 is released under %2</source> <translation>%1遵循%2协议发布</translation> </message> @@ -452,33 +452,33 @@ <translation>軟體更新</translation> </message> <message> - <location filename="../src/mainwindow-dtk.cpp" line="170"/> + <location filename="../src/mainwindow-dtk.cpp" line="186"/> <source>Submit App</source> <translation>上傳軟體</translation> </message> <message> - <location filename="../src/mainwindow-dtk.cpp" line="171"/> + <location filename="../src/mainwindow-dtk.cpp" line="187"/> <source>Submit App with client(Recommanded)</source> <translation>從客戶端上傳軟體(推薦的)</translation> </message> <message> - <location filename="../src/mainwindow-dtk.cpp" line="172"/> + <location filename="../src/mainwindow-dtk.cpp" line="188"/> <source>Settings</source> <translation>設定</translation> </message> <message> - <location filename="../src/mainwindow-dtk.cpp" line="173"/> + <location filename="../src/mainwindow-dtk.cpp" line="189"/> <source>APP Upgrade and Install Settings</source> <translation>軟體升級 和 安裝設定</translation> </message> <message> - <location filename="../src/mainwindow-dtk.cpp" line="129"/> - <location filename="../src/mainwindow-dtk.cpp" line="224"/> + <location filename="../src/mainwindow-dtk.cpp" line="145"/> + <location filename="../src/mainwindow-dtk.cpp" line="240"/> <source>Spark Store</source> <translation>星火应用商店</translation> </message> <message> - <location filename="../src/mainwindow-dtk.cpp" line="134"/> + <location filename="../src/mainwindow-dtk.cpp" line="150"/> <source>Search or enter spk://</source> <translation>搜索或打开链接</translation> </message> @@ -488,7 +488,7 @@ <message> <location filename="../src/application.cpp" line="33"/> <location filename="../src/application.cpp" line="34"/> - <location filename="../src/mainwindow-dtk.cpp" line="109"/> + <location filename="../src/mainwindow-dtk.cpp" line="125"/> <source>Spark Store</source> <translation>星火应用商店</translation> </message> @@ -498,17 +498,17 @@ <translation><span style=' font-size:10pt;font-weight:60;'>一款由社区提供的应用商店</span><br/><a href='https://www.spark-app.store/'>https://www.spark-app.store</a><br/><span style=' font-size:12pt;'>星火计划开发者</span></translation> </message> <message> - <location filename="../src/application.cpp" line="140"/> + <location filename="../src/application.cpp" line="145"/> <source>Spark Project</source> <translation>星火计划</translation> </message> <message> - <location filename="../src/widgets/downloadlistwidget.cpp" line="17"/> + <location filename="../src/widgets/downloadlistwidget.cpp" line="18"/> <source>Download list</source> <translation>下载列表</translation> </message> <message> - <location filename="../src/mainwindow-dtk.cpp" line="227"/> + <location filename="../src/mainwindow-dtk.cpp" line="243"/> <source>Show MainWindow</source> <translation>显示主窗口</translation> </message> @@ -619,12 +619,12 @@ <context> <name>TitleBarMenu</name> <message> - <location filename="../src/mainwindow-dtk.cpp" line="228"/> + <location filename="../src/mainwindow-dtk.cpp" line="244"/> <source>About</source> <translation>关于</translation> </message> <message> - <location filename="../src/mainwindow-dtk.cpp" line="229"/> + <location filename="../src/mainwindow-dtk.cpp" line="245"/> <source>Exit</source> <translation>退出</translation> </message>