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