mirror of
https://gitee.com/spark-store-project/spark-web-app-runtime.git
synced 2025-07-03 20:26:02 +08:00
Fix Bugs
Fix a bug when MainWindow is closed, AboutDialog still exists; Resize Logo-Spark.png to 142x51.
This commit is contained in:
parent
0a3b1d9960
commit
c826db09c1
spark-webapp-runtime
Binary file not shown.
Before ![]() (image error) Size: 43 KiB After ![]() (image error) Size: 17 KiB ![]() ![]() |
BIN
spark-webapp-runtime/images/Logo-Spark.png.bak
Normal file
BIN
spark-webapp-runtime/images/Logo-Spark.png.bak
Normal file
Binary file not shown.
After ![]() (image error) Size: 43 KiB |
@ -6,9 +6,9 @@
|
|||||||
* 社区项目投递地址:https://gitee.com/deepin-opensource
|
* 社区项目投递地址:https://gitee.com/deepin-opensource
|
||||||
*/
|
*/
|
||||||
#include "mainwindow.h"
|
#include "mainwindow.h"
|
||||||
|
|
||||||
#include <DApplication>
|
#include <DApplication>
|
||||||
#include <DWidgetUtil>
|
#include <DWidgetUtil>
|
||||||
#include <DAboutDialog>
|
|
||||||
#include <DMainWindow>
|
#include <DMainWindow>
|
||||||
|
|
||||||
#include <QCommandLineParser>
|
#include <QCommandLineParser>
|
||||||
@ -19,43 +19,41 @@
|
|||||||
#include "globaldefine.h"
|
#include "globaldefine.h"
|
||||||
#include "httpd.h"
|
#include "httpd.h"
|
||||||
|
|
||||||
DWIDGET_USE_NAMESPACE
|
|
||||||
|
|
||||||
int main(int argc, char *argv[])
|
int main(int argc, char *argv[])
|
||||||
{
|
{
|
||||||
DApplication a(argc, argv);
|
DApplication a(argc, argv);
|
||||||
DAboutDialog dialog;
|
|
||||||
a.loadTranslator();
|
a.loadTranslator();
|
||||||
|
|
||||||
a.setAttribute(Qt::AA_UseHighDpiPixmaps);
|
a.setAttribute(Qt::AA_UseHighDpiPixmaps);
|
||||||
a.setOrganizationName("spark-union"); // 添加组织名称,和商店主体的文件夹同在 ~/.local/share/spark-union 文件夹下
|
a.setOrganizationName("spark-union"); // 添加组织名称,和商店主体的文件夹同在 ~/.local/share/spark-union 文件夹下
|
||||||
a.setApplicationName("SparkWebAppRuntime"); // 这里不要翻译,否则 ~/.local/share 中文件夹名也会被翻译
|
a.setApplicationName("SparkWebAppRuntime"); // 这里不要翻译,否则 ~/.local/share 中文件夹名也会被翻译
|
||||||
a.setProductName(DEFAULT_TITLE);
|
|
||||||
a.setAboutDialog(&dialog);
|
|
||||||
|
|
||||||
//License
|
DAboutDialog *dialog = new DAboutDialog;
|
||||||
dialog.setLicense(QObject::tr("This program is open source under GPLv3")); // 本程序按GPL第三版开源
|
a.setAboutDialog(dialog);
|
||||||
|
|
||||||
//Title
|
// WindowIcon
|
||||||
dialog.setWindowTitle(DEFAULT_TITLE);
|
dialog->setWindowIcon(QIcon(":/images/spark-webapp-runtime.svg"));
|
||||||
//descrition
|
// ProductIcon
|
||||||
dialog.setProductName(QString("<span>%1</span>").arg(DEFAULT_TITLE));
|
dialog->setProductIcon(QIcon(":/images/spark-webapp-runtime.svg"));
|
||||||
//Icons
|
// ProductName
|
||||||
dialog.setProductIcon(QIcon(":/images/spark-webapp-runtime.svg"));
|
dialog->setProductName(QString("<span>%1</span>").arg(DEFAULT_TITLE));
|
||||||
//Organization logo
|
// Version
|
||||||
dialog.setCompanyLogo(QPixmap(":/images/Logo-Spark.png"));
|
dialog->setVersion(DApplication::buildVersion(QString("%1 %2").arg(QObject::tr("Version")).arg("1.5")));
|
||||||
//about
|
// CompanyLogo
|
||||||
QString szDefaultDesc = QString("<span style=' font-size:12pt;font-weight:500;'>%1</span><br/>"
|
dialog->setCompanyLogo(QPixmap(":/images/Logo-Spark.png"));
|
||||||
"<a href='https://gitee.com/deepin-community-store'>https://gitee.com/deepin-community-store</a><br/>"
|
// Description
|
||||||
"<span style=' font-size:12pt;'>%2</span>")
|
QString szDefaultDesc = QString("<a href='https://gitee.com/deepin-community-store/spark-web-app-runtime'><span style='font-size:12pt;font-weight:500;'>%1</span></a><br/>"
|
||||||
|
"<span style='font-size:12pt;'>%2</span>")
|
||||||
.arg(DEFAULT_TITLE)
|
.arg(DEFAULT_TITLE)
|
||||||
.arg(QObject::tr("Presented By Spark developers # HadesStudio"));
|
.arg(QObject::tr("Presented By Spark developers # HadesStudio"));
|
||||||
dialog.setDescription(szDefaultDesc);
|
dialog->setDescription(szDefaultDesc);
|
||||||
//Version
|
// WebsiteName
|
||||||
dialog.setVersion(DApplication::buildVersion(QString("%1 %2").arg(QObject::tr("Version")).arg("1.4")));
|
dialog->setWebsiteName("spark-app.store");
|
||||||
//Website name
|
// WebsiteLink
|
||||||
dialog.setWebsiteName("spark-app.store");
|
dialog->setWebsiteLink("https://www.spark-app.store/");
|
||||||
//Website link
|
// License
|
||||||
dialog.setWebsiteLink("https://www.spark-app.store/");
|
dialog->setLicense(QObject::tr("This program is open source under GPLv3")); // 本程序按GPL第三版开源
|
||||||
|
|
||||||
QCommandLineParser parser;
|
QCommandLineParser parser;
|
||||||
|
|
||||||
@ -255,7 +253,7 @@ int main(int argc, char *argv[])
|
|||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
|
|
||||||
MainWindow w(szTitle, szUrl, width, height);
|
MainWindow w(szTitle, szUrl, width, height, dialog);
|
||||||
|
|
||||||
#if SSL_SERVER
|
#if SSL_SERVER
|
||||||
if (!szRootPath.isEmpty() && u16Port > 0 && u16sslPort > 0)
|
if (!szRootPath.isEmpty() && u16Port > 0 && u16sslPort > 0)
|
||||||
@ -279,13 +277,13 @@ int main(int argc, char *argv[])
|
|||||||
|
|
||||||
if (!szIcon.isEmpty())
|
if (!szIcon.isEmpty())
|
||||||
{
|
{
|
||||||
dialog.setIcon(QIcon(szIcon));
|
dialog->setWindowIcon(QIcon(szIcon));
|
||||||
dialog.setProductIcon(QIcon(szIcon));
|
dialog->setProductIcon(QIcon(szIcon));
|
||||||
w.setIcon(szIcon);
|
w.setIcon(szIcon);
|
||||||
}
|
}
|
||||||
if (!szDesc.isEmpty())
|
if (!szDesc.isEmpty())
|
||||||
{
|
{
|
||||||
dialog.setDescription(szDesc);
|
dialog->setDescription(szDesc);
|
||||||
}
|
}
|
||||||
|
|
||||||
w.show();
|
w.show();
|
||||||
|
@ -1,37 +1,38 @@
|
|||||||
#include "mainwindow.h"
|
#include "mainwindow.h"
|
||||||
|
|
||||||
#include <DMainWindow>
|
#include <DMainWindow>
|
||||||
#include <DTitlebar>
|
#include <DTitlebar>
|
||||||
#include <DToolButton>
|
#include <DToolButton>
|
||||||
|
|
||||||
#include <QLayout>
|
#include <QLayout>
|
||||||
#include <QFileInfo>
|
#include <QFileInfo>
|
||||||
|
#include <QCloseEvent>
|
||||||
DWIDGET_USE_NAMESPACE
|
|
||||||
|
|
||||||
MainWindow::MainWindow(QString szTitle,
|
MainWindow::MainWindow(QString szTitle,
|
||||||
QString szUrl,
|
QString szUrl,
|
||||||
int nWidth,
|
int nWidth,
|
||||||
int nHeight,
|
int nHeight,
|
||||||
|
DAboutDialog *dialog,
|
||||||
QWidget *parent)
|
QWidget *parent)
|
||||||
: DMainWindow(parent)
|
: DMainWindow(parent)
|
||||||
, m_widget(nullptr)
|
, m_widget(new Widget(szUrl))
|
||||||
|
, m_dialog(dialog)
|
||||||
{
|
{
|
||||||
m_widget = new Widget(szUrl);
|
|
||||||
|
|
||||||
// setFixedSize(nWidth, nHeight);
|
// setFixedSize(nWidth, nHeight);
|
||||||
// 应 shenmo 要求改成设置最小尺寸试试效果
|
// 应 shenmo 要求改成设置最小尺寸试试效果
|
||||||
setMinimumSize(nWidth, nHeight);
|
setMinimumSize(nWidth, nHeight);
|
||||||
|
|
||||||
titlebar()->setTitle(szTitle);
|
|
||||||
|
|
||||||
setCentralWidget(m_widget);
|
setCentralWidget(m_widget);
|
||||||
centralWidget()->layout()->setContentsMargins(0, 0, 0, 0);
|
centralWidget()->layout()->setContentsMargins(0, 0, 0, 0);
|
||||||
|
|
||||||
|
setWindowIcon(QIcon(":/images/spark-webapp-runtime.svg"));
|
||||||
|
|
||||||
|
titlebar()->setTitle(szTitle);
|
||||||
titlebar()->setIcon(QIcon(":/images/spark-webapp-runtime.svg"));
|
titlebar()->setIcon(QIcon(":/images/spark-webapp-runtime.svg"));
|
||||||
|
|
||||||
DToolButton *btnBack = new DToolButton(titlebar());
|
DToolButton *btnBackward = new DToolButton(titlebar());
|
||||||
btnBack->setIcon(QIcon(":/images/go-previous-24.svg"));
|
btnBackward->setIcon(QIcon(":/images/go-previous-24.svg"));
|
||||||
btnBack->setIconSize(QSize(36, 36));
|
btnBackward->setIconSize(QSize(36, 36));
|
||||||
DToolButton *btnForward = new DToolButton(titlebar());
|
DToolButton *btnForward = new DToolButton(titlebar());
|
||||||
btnForward->setIcon(QIcon(":/images/go-next-24.svg"));
|
btnForward->setIcon(QIcon(":/images/go-next-24.svg"));
|
||||||
btnForward->setIconSize(QSize(36, 36));
|
btnForward->setIconSize(QSize(36, 36));
|
||||||
@ -39,7 +40,11 @@ MainWindow::MainWindow(QString szTitle,
|
|||||||
btnRefresh->setIcon(QIcon(":/images/view-refresh.svg"));
|
btnRefresh->setIcon(QIcon(":/images/view-refresh.svg"));
|
||||||
btnRefresh->setIconSize(QSize(36, 36));
|
btnRefresh->setIconSize(QSize(36, 36));
|
||||||
|
|
||||||
connect(btnBack, &DToolButton::clicked, this, [&]()
|
titlebar()->addWidget(btnBackward, Qt::AlignLeft);
|
||||||
|
titlebar()->addWidget(btnForward, Qt::AlignLeft);
|
||||||
|
titlebar()->addWidget(btnRefresh, Qt::AlignLeft);
|
||||||
|
|
||||||
|
connect(btnBackward, &DToolButton::clicked, this, [&]()
|
||||||
{
|
{
|
||||||
if (m_widget)
|
if (m_widget)
|
||||||
{
|
{
|
||||||
@ -60,10 +65,6 @@ MainWindow::MainWindow(QString szTitle,
|
|||||||
m_widget->refresh();
|
m_widget->refresh();
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
titlebar()->addWidget(btnBack, Qt::AlignLeft);
|
|
||||||
titlebar()->addWidget(btnForward, Qt::AlignLeft);
|
|
||||||
titlebar()->addWidget(btnRefresh, Qt::AlignLeft);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
MainWindow::~MainWindow()
|
MainWindow::~MainWindow()
|
||||||
@ -74,6 +75,11 @@ MainWindow::~MainWindow()
|
|||||||
delete m_widget;
|
delete m_widget;
|
||||||
m_widget = nullptr;
|
m_widget = nullptr;
|
||||||
}
|
}
|
||||||
|
if (m_dialog)
|
||||||
|
{
|
||||||
|
delete m_dialog;
|
||||||
|
m_dialog = nullptr;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void MainWindow::setIcon(QString szIconPath)
|
void MainWindow::setIcon(QString szIconPath)
|
||||||
@ -82,6 +88,7 @@ void MainWindow::setIcon(QString szIconPath)
|
|||||||
if (fi.exists())
|
if (fi.exists())
|
||||||
{
|
{
|
||||||
titlebar()->setIcon(QIcon(szIconPath));
|
titlebar()->setIcon(QIcon(szIconPath));
|
||||||
|
setWindowIcon(QIcon(szIconPath));
|
||||||
qDebug() << szIconPath << "is Set!";
|
qDebug() << szIconPath << "is Set!";
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
@ -89,3 +96,9 @@ void MainWindow::setIcon(QString szIconPath)
|
|||||||
qDebug() << szIconPath << "is Not Exists!";
|
qDebug() << szIconPath << "is Not Exists!";
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void MainWindow::closeEvent(QCloseEvent *event)
|
||||||
|
{
|
||||||
|
m_dialog->close();
|
||||||
|
event->accept();
|
||||||
|
}
|
||||||
|
@ -2,6 +2,7 @@
|
|||||||
#define MAINWINDOW_H
|
#define MAINWINDOW_H
|
||||||
|
|
||||||
#include <DMainWindow>
|
#include <DMainWindow>
|
||||||
|
#include <DAboutDialog>
|
||||||
|
|
||||||
#include "widget.h"
|
#include "widget.h"
|
||||||
#include "globaldefine.h"
|
#include "globaldefine.h"
|
||||||
@ -17,6 +18,7 @@ public:
|
|||||||
QString szUrl = DEFAULT_URL,
|
QString szUrl = DEFAULT_URL,
|
||||||
int nWidth = DEFAULT_WIDTH,
|
int nWidth = DEFAULT_WIDTH,
|
||||||
int nHeight = DEFAULT_HEIGHT,
|
int nHeight = DEFAULT_HEIGHT,
|
||||||
|
DAboutDialog *dialog = nullptr,
|
||||||
QWidget *parent = nullptr);
|
QWidget *parent = nullptr);
|
||||||
~MainWindow();
|
~MainWindow();
|
||||||
|
|
||||||
@ -27,6 +29,10 @@ signals:
|
|||||||
|
|
||||||
private:
|
private:
|
||||||
Widget *m_widget;
|
Widget *m_widget;
|
||||||
|
DAboutDialog *m_dialog;
|
||||||
|
|
||||||
|
void closeEvent(QCloseEvent *event);
|
||||||
|
|
||||||
};
|
};
|
||||||
|
|
||||||
#endif // MAINWINDOW_H
|
#endif // MAINWINDOW_H
|
||||||
|
@ -1,4 +1,4 @@
|
|||||||
QT += core widgets gui webengine webenginewidgets svg concurrent
|
QT += core gui webengine webenginewidgets svg concurrent
|
||||||
|
|
||||||
greaterThan(QT_MAJOR_VERSION, 5): QT += widgets
|
greaterThan(QT_MAJOR_VERSION, 5): QT += widgets
|
||||||
|
|
||||||
|
@ -4,77 +4,77 @@
|
|||||||
<context>
|
<context>
|
||||||
<name>QObject</name>
|
<name>QObject</name>
|
||||||
<message>
|
<message>
|
||||||
<location filename="../main.cpp" line="51"/>
|
<location filename="../main.cpp" line="49"/>
|
||||||
<source>Presented By Spark developers # HadesStudio</source>
|
<source>Presented By Spark developers # HadesStudio</source>
|
||||||
<translation>由 星火开发者联盟 @ 花心胡萝卜 提供</translation>
|
<translation>由 星火开发者联盟 @ 花心胡萝卜 提供</translation>
|
||||||
</message>
|
</message>
|
||||||
<message>
|
<message>
|
||||||
<location filename="../main.cpp" line="36"/>
|
<location filename="../main.cpp" line="56"/>
|
||||||
<source>This program is open source under GPLv3</source>
|
<source>This program is open source under GPLv3</source>
|
||||||
<translation>本程序按GPL第三版开源</translation>
|
<translation>本程序按GPL第三版开源</translation>
|
||||||
</message>
|
</message>
|
||||||
<message>
|
<message>
|
||||||
<location filename="../main.cpp" line="54"/>
|
<location filename="../main.cpp" line="42"/>
|
||||||
<source>Version</source>
|
<source>Version</source>
|
||||||
<translation>版本</translation>
|
<translation>版本</translation>
|
||||||
</message>
|
</message>
|
||||||
<message>
|
<message>
|
||||||
<location filename="../main.cpp" line="62"/>
|
<location filename="../main.cpp" line="60"/>
|
||||||
<source>Description: %1</source>
|
<source>Description: %1</source>
|
||||||
<translation>描述:%1</translation>
|
<translation>描述:%1</translation>
|
||||||
</message>
|
</message>
|
||||||
<message>
|
<message>
|
||||||
<location filename="../main.cpp" line="67"/>
|
<location filename="../main.cpp" line="65"/>
|
||||||
<source>Enable CommandLineParser. Default is false.</source>
|
<source>Enable CommandLineParser. Default is false.</source>
|
||||||
<translation>启用参数解析方式。默认顺序解析方式。</translation>
|
<translation>启用参数解析方式。默认顺序解析方式。</translation>
|
||||||
</message>
|
</message>
|
||||||
<message>
|
<message>
|
||||||
<location filename="../main.cpp" line="71"/>
|
<location filename="../main.cpp" line="69"/>
|
||||||
<source>The Title of Application. Default is %1.</source>
|
<source>The Title of Application. Default is %1.</source>
|
||||||
<translation>设置程序的运行标题。默认是 %1。</translation>
|
<translation>设置程序的运行标题。默认是 %1。</translation>
|
||||||
</message>
|
</message>
|
||||||
<message>
|
<message>
|
||||||
<location filename="../main.cpp" line="77"/>
|
<location filename="../main.cpp" line="75"/>
|
||||||
<source>The target URL. Default is Blank.</source>
|
<source>The target URL. Default is Blank.</source>
|
||||||
<translation>设置要打开的目标 URL。默认是空。</translation>
|
<translation>设置要打开的目标 URL。默认是空。</translation>
|
||||||
</message>
|
</message>
|
||||||
<message>
|
<message>
|
||||||
<location filename="../main.cpp" line="83"/>
|
<location filename="../main.cpp" line="81"/>
|
||||||
<source>The Width of Application. Default is %1.</source>
|
<source>The Width of Application. Default is %1.</source>
|
||||||
<translation>设置应用的窗口宽度。默认是 %1。</translation>
|
<translation>设置应用的窗口宽度。默认是 %1。</translation>
|
||||||
</message>
|
</message>
|
||||||
<message>
|
<message>
|
||||||
<location filename="../main.cpp" line="89"/>
|
<location filename="../main.cpp" line="87"/>
|
||||||
<source>The Height of Application. Default is %1.</source>
|
<source>The Height of Application. Default is %1.</source>
|
||||||
<translation>设置应用的窗口高度。默认是 %1。</translation>
|
<translation>设置应用的窗口高度。默认是 %1。</translation>
|
||||||
</message>
|
</message>
|
||||||
<message>
|
<message>
|
||||||
<location filename="../main.cpp" line="95"/>
|
<location filename="../main.cpp" line="93"/>
|
||||||
<source>The ICON of Application.</source>
|
<source>The ICON of Application.</source>
|
||||||
<translation>设置应用的图标。</translation>
|
<translation>设置应用的图标。</translation>
|
||||||
</message>
|
</message>
|
||||||
<message>
|
<message>
|
||||||
<location filename="../main.cpp" line="101"/>
|
<location filename="../main.cpp" line="99"/>
|
||||||
<source>The Description of Application.</source>
|
<source>The Description of Application.</source>
|
||||||
<translation>设置应用的描述信息。</translation>
|
<translation>设置应用的描述信息。</translation>
|
||||||
</message>
|
</message>
|
||||||
<message>
|
<message>
|
||||||
<location filename="../main.cpp" line="107"/>
|
<location filename="../main.cpp" line="105"/>
|
||||||
<source>The Configuration file of Application.</source>
|
<source>The Configuration file of Application.</source>
|
||||||
<translation>设置应用的配置文件。</translation>
|
<translation>设置应用的配置文件。</translation>
|
||||||
</message>
|
</message>
|
||||||
<message>
|
<message>
|
||||||
<location filename="../main.cpp" line="113"/>
|
<location filename="../main.cpp" line="111"/>
|
||||||
<source>The root path of the program web service.</source>
|
<source>The root path of the program web service.</source>
|
||||||
<translation>设置内置 WebServer 的根路径。</translation>
|
<translation>设置内置 WebServer 的根路径。</translation>
|
||||||
</message>
|
</message>
|
||||||
<message>
|
<message>
|
||||||
<location filename="../main.cpp" line="120"/>
|
<location filename="../main.cpp" line="118"/>
|
||||||
<source>The port number of the program web service.</source>
|
<source>The port number of the program web service.</source>
|
||||||
<translation>设置内置 WebServer 的监听端口号。</translation>
|
<translation>设置内置 WebServer 的监听端口号。</translation>
|
||||||
</message>
|
</message>
|
||||||
<message>
|
<message>
|
||||||
<location filename="../main.cpp" line="127"/>
|
<location filename="../main.cpp" line="125"/>
|
||||||
<source>The ssl port number of the program web service.</source>
|
<source>The ssl port number of the program web service.</source>
|
||||||
<translation>设置内置 WebServer 的 SSL 协议的监听端口号。</translation>
|
<translation>设置内置 WebServer 的 SSL 协议的监听端口号。</translation>
|
||||||
</message>
|
</message>
|
||||||
|
@ -23,9 +23,10 @@ public:
|
|||||||
void refresh();
|
void refresh();
|
||||||
|
|
||||||
private:
|
private:
|
||||||
Ui::Widget *ui;
|
Ui::Widget *ui;
|
||||||
|
|
||||||
QWebEngineView *m_webEngineView;
|
QWebEngineView *m_webEngineView;
|
||||||
QString m_szUrl;
|
QString m_szUrl;
|
||||||
};
|
};
|
||||||
|
|
||||||
#endif // WIDGET_H
|
#endif // WIDGET_H
|
||||||
|
Loading…
x
Reference in New Issue
Block a user