diff --git a/spark-webapp-runtime/main.cpp b/spark-webapp-runtime/main.cpp index 83bc329..c53ff92 100644 --- a/spark-webapp-runtime/main.cpp +++ b/spark-webapp-runtime/main.cpp @@ -164,8 +164,7 @@ int main(int argc, char *argv[]) szCfgFile = parser.value(optCfgFile); if (!szCfgFile.isEmpty()) { - QFileInfo fi(szCfgFile); - if (fi.exists()) + if (QFileInfo(szCfgFile).exists()) { QSettings settings(szCfgFile, QSettings::IniFormat); szTitle = settings.value("SparkWebAppRuntime/Title", DEFAULT_TITLE).toString(); diff --git a/spark-webapp-runtime/mainwindow.cpp b/spark-webapp-runtime/mainwindow.cpp index c231fcd..5dc8453 100644 --- a/spark-webapp-runtime/mainwindow.cpp +++ b/spark-webapp-runtime/mainwindow.cpp @@ -1,15 +1,14 @@ #include "mainwindow.h" -#include <DMainWindow> #include <DWidgetUtil> #include <DTitlebar> #include <DMessageManager> +#include <DDesktopServices> #include <QFileInfo> #include <QFileDialog> #include <QDir> #include <QCloseEvent> -#include <QDebug> #include "webenginepage.h" @@ -45,7 +44,6 @@ MainWindow::MainWindow(QString szTitle, , cancel(new DPushButton(tr("Cancel"))) , progress(new QHBoxLayout) , message(new DFloatingMessage(DFloatingMessage::ResidentType)) - , process(new QProcess) , isCanceled(false) , mtray(tray) , mFixSize(nFixSize) @@ -181,17 +179,11 @@ MainWindow::~MainWindow() void MainWindow::setIcon(QString szIconPath) { - QFileInfo fi(szIconPath); - if (fi.exists()) + if (QFileInfo(szIconPath).exists()) { titlebar()->setIcon(QIcon(szIconPath)); setWindowIcon(QIcon(szIconPath)); m_tray->setIcon(QIcon(szIconPath)); - qDebug() << szIconPath << "is Set!"; - } - else - { - qDebug() << szIconPath << "is Not Exists!"; } } @@ -386,7 +378,7 @@ void MainWindow::on_downloadFinish(QString filePath) connect(button, &DPushButton::clicked, this, [=]() { - process->start("dde-file-manager --show-item " + filePath); + DDesktopServices::showFileItem(filePath); message->hide(); }); } diff --git a/spark-webapp-runtime/mainwindow.h b/spark-webapp-runtime/mainwindow.h index 2f4c139..450ebf4 100644 --- a/spark-webapp-runtime/mainwindow.h +++ b/spark-webapp-runtime/mainwindow.h @@ -9,7 +9,6 @@ #include <DFloatingMessage> #include <QSystemTrayIcon> -#include <QLayout> #include <QProcess> #include <QMutex> @@ -64,8 +63,6 @@ private: QHBoxLayout *progress; DFloatingMessage *message; - QProcess *process; - QMutex mutex; // 通过 Mutex 互斥量禁止同时下载多个文件(使用简单的 bool 变量应该也可以实现该功能?) bool isCanceled; // 判断是否为取消下载 diff --git a/spark-webapp-runtime/translations/spark-webapp-runtime_zh_CN.ts b/spark-webapp-runtime/translations/spark-webapp-runtime_zh_CN.ts index 031f6ab..69a97be 100644 --- a/spark-webapp-runtime/translations/spark-webapp-runtime_zh_CN.ts +++ b/spark-webapp-runtime/translations/spark-webapp-runtime_zh_CN.ts @@ -4,92 +4,92 @@ <context> <name>MainWindow</name> <message> - <location filename="../mainwindow.cpp" line="34"/> + <location filename="../mainwindow.cpp" line="33"/> <source>Full Screen</source> <translation>全屏显示</translation> </message> <message> - <location filename="../mainwindow.cpp" line="35"/> + <location filename="../mainwindow.cpp" line="34"/> <source>Fix Size</source> <translation>固定大小</translation> </message> <message> - <location filename="../mainwindow.cpp" line="36"/> + <location filename="../mainwindow.cpp" line="35"/> <source>Hide Buttons</source> <translation>隐藏按钮</translation> </message> <message> - <location filename="../mainwindow.cpp" line="38"/> + <location filename="../mainwindow.cpp" line="37"/> <source>Show MainWindow</source> <translation>显示主界面</translation> </message> <message> - <location filename="../mainwindow.cpp" line="39"/> + <location filename="../mainwindow.cpp" line="38"/> <source>About</source> <translation>关于</translation> </message> <message> - <location filename="../mainwindow.cpp" line="40"/> + <location filename="../mainwindow.cpp" line="39"/> <source>Exit</source> <translation>退出</translation> </message> <message> - <location filename="../mainwindow.cpp" line="43"/> + <location filename="../mainwindow.cpp" line="42"/> <source>Pause</source> <translation>暂停</translation> </message> <message> - <location filename="../mainwindow.cpp" line="44"/> + <location filename="../mainwindow.cpp" line="43"/> <source>Resume</source> <translation>继续</translation> </message> <message> - <location filename="../mainwindow.cpp" line="45"/> + <location filename="../mainwindow.cpp" line="44"/> <source>Cancel</source> <translation>取消</translation> </message> <message> - <location filename="../mainwindow.cpp" line="206"/> + <location filename="../mainwindow.cpp" line="198"/> <source>%1Fullscreen Mode</source> <translation>%1全屏模式</translation> </message> <message> - <location filename="../mainwindow.cpp" line="216"/> + <location filename="../mainwindow.cpp" line="208"/> <source>%1Windowed Mode</source> <translation>%1窗口模式</translation> </message> <message> - <location filename="../mainwindow.cpp" line="258"/> + <location filename="../mainwindow.cpp" line="250"/> <source>Save As</source> <translation>另存为</translation> </message> <message> - <location filename="../mainwindow.cpp" line="344"/> + <location filename="../mainwindow.cpp" line="336"/> <source>%1Start downloading %2</source> <translation>%1开始下载 %2</translation> </message> <message> - <location filename="../mainwindow.cpp" line="357"/> + <location filename="../mainwindow.cpp" line="349"/> <source>%1Wait for previous download to complete!</source> <translation>%1请等待上一个下载任务完成!</translation> </message> <message> - <location filename="../mainwindow.cpp" line="379"/> + <location filename="../mainwindow.cpp" line="371"/> <source>Open</source> <translation>打开</translation> </message> <message> - <location filename="../mainwindow.cpp" line="383"/> + <location filename="../mainwindow.cpp" line="375"/> <source>download finished.</source> <translation>下载完成。</translation> </message> <message> - <location filename="../mainwindow.cpp" line="383"/> + <location filename="../mainwindow.cpp" line="375"/> <source>Show in file manager?</source> <translation>是否在文件管理器中显示?</translation> </message> <message> - <location filename="../mainwindow.cpp" line="421"/> + <location filename="../mainwindow.cpp" line="413"/> <source>%1Download canceled!</source> <translation>%1下载取消!</translation> </message> diff --git a/spark-webapp-runtime/webenginepage.cpp b/spark-webapp-runtime/webenginepage.cpp index 29bc26e..3e9e94a 100644 --- a/spark-webapp-runtime/webenginepage.cpp +++ b/spark-webapp-runtime/webenginepage.cpp @@ -1,12 +1,5 @@ #include "webenginepage.h" -#include <QDir> -#include <QDebug> - -#include <DMessageManager> - -DWIDGET_USE_NAMESPACE - WebEnginePage::WebEnginePage(QObject *parent) : QWebEnginePage(parent) { diff --git a/spark-webapp-runtime/webenginepage.h b/spark-webapp-runtime/webenginepage.h index f36bd17..afa2d05 100644 --- a/spark-webapp-runtime/webenginepage.h +++ b/spark-webapp-runtime/webenginepage.h @@ -2,6 +2,7 @@ #define WEBENGINEPAGE_H #include <QWebEnginePage> +#include <QWebEngineProfile> #include <QObject> class WebEnginePage : public QWebEnginePage diff --git a/spark-webapp-runtime/widget.h b/spark-webapp-runtime/widget.h index 5c6f174..ba41739 100644 --- a/spark-webapp-runtime/widget.h +++ b/spark-webapp-runtime/widget.h @@ -3,8 +3,6 @@ #include <QWidget> #include <QWebEngineView> -#include <QWebEnginePage> -#include <QWebEngineProfile> #include <QLayout> #include <DSpinner>