Improve Features

Support tray icon;
Fix few bugs about confliction between fullscreen mode and fixsize
option.
This commit is contained in:
忘记、过去 2020-11-30 02:22:28 +08:00
parent 3b54057d49
commit 17bd206e18
8 changed files with 178 additions and 51 deletions

@ -28,6 +28,7 @@
-u, --url <url> 设置要打开的目标 URL。默认为空。 -u, --url <url> 设置要打开的目标 URL。默认为空。
-w, --width <width> 设置应用的窗口宽度。默认为 1024。 -w, --width <width> 设置应用的窗口宽度。默认为 1024。
-H, --height <height> 设置应用的窗口高度。默认为 768。 -H, --height <height> 设置应用的窗口高度。默认为 768。
-T, --tray 启用托盘图标。默认不启用。
--full-screen 以全屏模式运行。默认关闭该功能。 --full-screen 以全屏模式运行。默认关闭该功能。
--fix-size 固定窗口大小。默认关闭该功能。 --fix-size 固定窗口大小。默认关闭该功能。
--hide-buttons 隐藏控制按钮。默认关闭该功能。 --hide-buttons 隐藏控制按钮。默认关闭该功能。
@ -64,6 +65,7 @@
-u, --url <url> The target URL. Default is Blank. -u, --url <url> The target URL. Default is Blank.
-w, --width <width> The Width of Application. Default is 1024. -w, --width <width> The Width of Application. Default is 1024.
-H, --height <height> The Height of Application. Default is 768. -H, --height <height> The Height of Application. Default is 768.
-T, --tray Enable Tray Icon. Default is false.
--full-screen Run in Fullscreen Mode. Default is false. --full-screen Run in Fullscreen Mode. Default is false.
--fix-size Fix Window Size. Default is false. --fix-size Fix Window Size. Default is false.
--hide-buttons Hide Control Buttons. Default is false. --hide-buttons Hide Control Buttons. Default is false.

@ -20,8 +20,8 @@ int main(int argc, char *argv[])
DApplication a(argc, argv); DApplication a(argc, argv);
a.loadTranslator(); a.loadTranslator();
a.setAttribute(Qt::AA_UseHighDpiPixmaps); a.setAttribute(Qt::AA_UseHighDpiPixmaps);
a.setApplicationVersion(QString::number(CURRENT_VER)); a.setApplicationVersion(QString::number(CURRENT_VER));
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 中文件夹名也会被翻译
@ -86,6 +86,10 @@ int main(int argc, char *argv[])
QString::number(DEFAULT_HEIGHT)); QString::number(DEFAULT_HEIGHT));
parser.addOption(optHeight); parser.addOption(optHeight);
QCommandLineOption optTray(QStringList() << "T" << "tray",
QObject::tr("Enable Tray Icon. Default is false."));
parser.addOption(optTray);
QCommandLineOption optFullScreen("full-screen", QCommandLineOption optFullScreen("full-screen",
QObject::tr("Run in Fullscreen Mode. Default is false.")); QObject::tr("Run in Fullscreen Mode. Default is false."));
parser.addOption(optFullScreen); parser.addOption(optFullScreen);
@ -143,6 +147,7 @@ int main(int argc, char *argv[])
QString szUrl = DEFAULT_URL; QString szUrl = DEFAULT_URL;
int width = DEFAULT_WIDTH; int width = DEFAULT_WIDTH;
int height = DEFAULT_HEIGHT; int height = DEFAULT_HEIGHT;
bool tray = false;
bool fullScreen = false; bool fullScreen = false;
bool fixSize = false; bool fixSize = false;
bool hideButtons = false; bool hideButtons = false;
@ -168,6 +173,7 @@ int main(int argc, char *argv[])
szUrl = settings.value("SparkWebAppRuntime/URL", DEFAULT_TITLE).toString(); szUrl = settings.value("SparkWebAppRuntime/URL", DEFAULT_TITLE).toString();
width = settings.value("SparkWebAppRuntime/Width", DEFAULT_WIDTH).toUInt(); width = settings.value("SparkWebAppRuntime/Width", DEFAULT_WIDTH).toUInt();
height = settings.value("SparkWebAppRuntime/Height", DEFAULT_HEIGHT).toUInt(); height = settings.value("SparkWebAppRuntime/Height", DEFAULT_HEIGHT).toUInt();
tray = settings.value("SparkWebAppRunTime/Tray", false).toBool();
fullScreen = settings.value("SparkWebAppRunTime/FullScreen", false).toBool(); fullScreen = settings.value("SparkWebAppRunTime/FullScreen", false).toBool();
fixSize = settings.value("SparkWebAppRunTime/FixSize", false).toBool(); fixSize = settings.value("SparkWebAppRunTime/FixSize", false).toBool();
hideButtons = settings.value("SparkWebAppRunTime/HideButtons", false).toBool(); hideButtons = settings.value("SparkWebAppRunTime/HideButtons", false).toBool();
@ -202,6 +208,10 @@ int main(int argc, char *argv[])
height = parser.value(optHeight).toInt(); height = parser.value(optHeight).toInt();
} }
if (parser.isSet(optTray))
{
tray = true;
}
if (parser.isSet(optFullScreen)) if (parser.isSet(optFullScreen))
{ {
fullScreen = true; fullScreen = true;
@ -238,7 +248,7 @@ int main(int argc, char *argv[])
} }
#endif #endif
// 没设置 -p 并且参数个数>1 并且第一个参数不是-开始的 // 没设置 -p 并且参数个数 > 1 并且第一个参数不是 - 开始的
if (!parser.isSet(optParser) && argc > 1 && !QString(argv[1]).startsWith("-")) if (!parser.isSet(optParser) && argc > 1 && !QString(argv[1]).startsWith("-"))
{ {
// 按照固定顺序级别最优先 // 按照固定顺序级别最优先
@ -261,35 +271,39 @@ int main(int argc, char *argv[])
if (argc > 5) if (argc > 5)
{ {
fullScreen = true; tray = true;
} }
if (argc > 6) if (argc > 6)
{ {
fixSize = true; fullScreen = true;
} }
if (argc > 7) if (argc > 7)
{
fixSize = true;
}
if (argc > 8)
{ {
hideButtons = true; hideButtons = true;
} }
if (argc > 8) if (argc > 9)
{ {
szIcon = QString(argv[7]); szIcon = QString(argv[7]);
} }
if (argc > 9) if (argc > 10)
{ {
szDesc = QString("%1<br/><br/>%2").arg(QString(argv[8])).arg(szDefaultDesc); szDesc = QString("%1<br/><br/>%2").arg(QString(argv[8])).arg(szDefaultDesc);
} }
if (argc > 10) if (argc > 11)
{ {
szRootPath = QString(argv[9]); szRootPath = QString(argv[9]);
} }
if (argc > 11) if (argc > 12)
{ {
u16Port = QString(argv[10]).toUInt(); u16Port = QString(argv[10]).toUInt();
} }
#if SSL_SERVER #if SSL_SERVER
if (argc > 12) if (argc > 13)
{ {
u16sslPort = QString(argv[11]).toUInt(); u16sslPort = QString(argv[11]).toUInt();
} }
@ -298,10 +312,12 @@ int main(int argc, char *argv[])
if(fixSize) if(fixSize)
{ {
fullScreen = false; // 固定窗口大小时禁用全屏模式,避免标题栏按钮 BUG fullScreen = false; // 固定窗口大小时禁用全屏模式,避免标题栏按钮 BUG
} }
MainWindow w(szTitle, szUrl, width, height, fullScreen, fixSize, hideButtons, dialog); a.setQuitOnLastWindowClosed(!tray); // 启用托盘时,退出程序后服务不终止
MainWindow w(szTitle, szUrl, width, height, tray, fullScreen, fixSize, hideButtons, dialog);
#if SSL_SERVER #if SSL_SERVER
if (!szRootPath.isEmpty() && u16Port > 0 && u16sslPort > 0) if (!szRootPath.isEmpty() && u16Port > 0 && u16sslPort > 0)

@ -19,6 +19,7 @@ MainWindow::MainWindow(QString szTitle,
QString szUrl, QString szUrl,
int nWidth, int nWidth,
int nHeight, int nHeight,
bool tray,
bool nFullScreen, bool nFullScreen,
bool nFixSize, bool nFixSize,
bool nHideButtons, bool nHideButtons,
@ -27,6 +28,7 @@ MainWindow::MainWindow(QString szTitle,
: DMainWindow(parent) : DMainWindow(parent)
, m_widget(new Widget(szUrl)) , m_widget(new Widget(szUrl))
, m_dialog(dialog) , m_dialog(dialog)
, m_tray(new QSystemTrayIcon)
, btnBack(new DToolButton(titlebar())) , btnBack(new DToolButton(titlebar()))
, btnForward(new DToolButton(titlebar())) , btnForward(new DToolButton(titlebar()))
, btnRefresh(new DToolButton(titlebar())) , btnRefresh(new DToolButton(titlebar()))
@ -34,12 +36,19 @@ MainWindow::MainWindow(QString szTitle,
, m_fullScreen(new QAction(tr("Full Screen"))) , m_fullScreen(new QAction(tr("Full Screen")))
, m_fixSize(new QAction(tr("Fix Size"))) , m_fixSize(new QAction(tr("Fix Size")))
, m_hideButtons(new QAction(tr("Hide Buttons"))) , m_hideButtons(new QAction(tr("Hide Buttons")))
, t_menu(new QMenu)
, t_show(new QAction(tr("Show MainWindow")))
, t_about(new QAction(tr("About")))
, t_exit(new QAction(tr("Exit")))
, bar(new DProgressBar) , bar(new DProgressBar)
, message(new DFloatingMessage(DFloatingMessage::ResidentType)) , message(new DFloatingMessage(DFloatingMessage::ResidentType))
, process(new QProcess) , process(new QProcess)
, mtray(tray)
, mFixSize(nFixSize)
, m_width(nWidth) , m_width(nWidth)
, m_height(nHeight) , m_height(nHeight)
{ {
/* 初始化 MainWindow */
setCentralWidget(m_widget); setCentralWidget(m_widget);
centralWidget()->layout()->setContentsMargins(0, 0, 0, 0); centralWidget()->layout()->setContentsMargins(0, 0, 0, 0);
@ -72,17 +81,36 @@ MainWindow::MainWindow(QString szTitle,
m_hideButtons->setCheckable(true); m_hideButtons->setCheckable(true);
m_hideButtons->setChecked(nHideButtons); m_hideButtons->setChecked(nHideButtons);
m_hideButtons->setDisabled(nHideButtons); m_hideButtons->setDisabled(nHideButtons);
m_menu->addAction(m_fullScreen); /* 命令行设置参数后 GUI 中隐藏对应选项 */
m_menu->addAction(m_fixSize); if(!nFixSize)
m_menu->addAction(m_hideButtons); {
m_menu->addAction(m_fullScreen);
m_menu->addAction(m_fixSize);
}
if(!nHideButtons)
{
m_menu->addAction(m_hideButtons);
}
titlebar()->setMenu(m_menu); titlebar()->setMenu(m_menu);
titlebar()->setAutoHideOnFullscreen(true); titlebar()->setAutoHideOnFullscreen(true);
fullScreen();
fixSize(); fixSize();
hideButtons(); hideButtons();
/* 初始化 TrayIcon */
t_menu->addAction(t_show);
t_menu->addAction(t_about);
t_menu->addAction(t_exit);
m_tray->setContextMenu(t_menu);
m_tray->setToolTip(szTitle);
m_tray->setIcon(QIcon(":/images/spark-webapp-runtime.svg"));
if(tray)
{
m_tray->show(); // 启用托盘时显示
}
connect(btnBack, &DToolButton::clicked, this, [&]() connect(btnBack, &DToolButton::clicked, this, [&]()
{ {
m_widget->goBack(); m_widget->goBack();
@ -109,6 +137,22 @@ MainWindow::MainWindow(QString szTitle,
hideButtons(); hideButtons();
}); });
connect(t_show, &QAction::triggered, this, [=]()
{
this->activateWindow();
fixSize();
});
connect(t_about, &QAction::triggered, this, [=]()
{
m_dialog->activateWindow();
m_dialog->show();
});
connect(t_exit, &QAction::triggered, this, [=]()
{
exit(0);
});
connect(m_tray, &QSystemTrayIcon::activated, this, &MainWindow::trayIconActivated);
connect(m_widget->getPage()->profile(), &QWebEngineProfile::downloadRequested, this, &MainWindow::on_downloadStart); connect(m_widget->getPage()->profile(), &QWebEngineProfile::downloadRequested, this, &MainWindow::on_downloadStart);
} }
@ -117,6 +161,7 @@ MainWindow::~MainWindow()
emit sigQuit(); emit sigQuit();
delete m_widget; delete m_widget;
delete m_dialog; delete m_dialog;
delete m_tray;
} }
void MainWindow::setIcon(QString szIconPath) void MainWindow::setIcon(QString szIconPath)
@ -126,6 +171,7 @@ void MainWindow::setIcon(QString szIconPath)
{ {
titlebar()->setIcon(QIcon(szIconPath)); titlebar()->setIcon(QIcon(szIconPath));
setWindowIcon(QIcon(szIconPath)); setWindowIcon(QIcon(szIconPath));
m_tray->setIcon(QIcon(szIconPath));
qDebug() << szIconPath << "is Set!"; qDebug() << szIconPath << "is Set!";
} }
else else
@ -138,11 +184,19 @@ void MainWindow::fullScreen()
{ {
if(m_fullScreen->isChecked()) if(m_fullScreen->isChecked())
{ {
m_fixSize->setChecked(false);
m_fixSize->setDisabled(true);
m_menu->update();
showFullScreen(); showFullScreen();
DMessageManager::instance()->sendMessage(this, QIcon::fromTheme("dialog-information").pixmap(64, 64), QString(tr("%1Fullscreen Mode")).arg(" ")); DMessageManager::instance()->sendMessage(this, QIcon::fromTheme("dialog-information").pixmap(64, 64), QString(tr("%1Fullscreen Mode")).arg(" "));
} }
else else
{ {
if(!mFixSize)
{
m_fixSize->setDisabled(false); // 命令行参数没有固定窗口大小时,窗口模式下允许手动选择固定窗口大小
}
m_menu->update();
showNormal(); showNormal();
DMessageManager::instance()->sendMessage(this, QIcon::fromTheme("dialog-information").pixmap(64, 64), QString(tr("%1Windowed Mode")).arg(" ")); DMessageManager::instance()->sendMessage(this, QIcon::fromTheme("dialog-information").pixmap(64, 64), QString(tr("%1Windowed Mode")).arg(" "));
} }
@ -152,13 +206,20 @@ void MainWindow::fixSize()
{ {
if(m_fixSize->isChecked()) if(m_fixSize->isChecked())
{ {
setFixedSize(this->width(), this->height()); m_fullScreen->setChecked(false);
m_fullScreen->setDisabled(true);
m_menu->update();
setFixedSize(this->size());
/* 存在 BUG: 启用托盘图标后,若手动选择固定窗口大小,并且关闭窗口,再次打开时会丢失最大化按钮,且无法恢复。 */
} }
else else
{ {
m_fullScreen->setDisabled(false);
m_menu->update();
setMinimumSize(m_width, m_height); setMinimumSize(m_width, m_height);
setMaximumSize(QSize(QWIDGETSIZE_MAX, QWIDGETSIZE_MAX)); setMaximumSize(QSize(QWIDGETSIZE_MAX, QWIDGETSIZE_MAX));
} }
fullScreen();
} }
void MainWindow::hideButtons() void MainWindow::hideButtons()
@ -182,14 +243,13 @@ QString MainWindow::saveAs(QString fileName)
QString saveFile = QFileDialog::getSaveFileName(this, tr("Save As"), QDir::homePath() + "/Downloads/" + fileName); QString saveFile = QFileDialog::getSaveFileName(this, tr("Save As"), QDir::homePath() + "/Downloads/" + fileName);
if(!saveFile.isEmpty()) if(!saveFile.isEmpty())
{ {
// 判断上层目录是否可写入 if(QFileInfo(QFileInfo(saveFile).absolutePath()).permissions().testFlag(QFile::WriteUser)) // 判断上层目录是否可写入
if(QFileInfo(QFileInfo(saveFile).absolutePath()).permissions().testFlag(QFile::WriteUser))
{ {
return saveFile; return saveFile;
} }
else else
{ {
saveAs(fileName); return saveAs(fileName);
} }
} }
return nullptr; return nullptr;
@ -197,9 +257,9 @@ QString MainWindow::saveAs(QString fileName)
void MainWindow::keyPressEvent(QKeyEvent *event) void MainWindow::keyPressEvent(QKeyEvent *event)
{ {
if(m_fixSize->isEnabled()) if(!m_fixSize->isChecked()) // 固定窗口大小时禁止全屏
{ {
if(event->key() == Qt::Key_F11) if(event->key() == Qt::Key_F11) // 绑定键盘快捷键 F11
{ {
m_fullScreen->trigger(); m_fullScreen->trigger();
m_menu->update(); m_menu->update();
@ -210,23 +270,41 @@ void MainWindow::keyPressEvent(QKeyEvent *event)
void MainWindow::closeEvent(QCloseEvent *event) void MainWindow::closeEvent(QCloseEvent *event)
{ {
m_dialog->close(); if(!mtray)
{
m_dialog->close(); // 不启用托盘时,关闭主窗口则关闭关于窗口
}
event->accept(); event->accept();
} }
void MainWindow::trayIconActivated(QSystemTrayIcon::ActivationReason reason)
{
switch(reason)
{
/* 响应托盘点击事件 */
case QSystemTrayIcon::Trigger:
this->activateWindow();
fixSize();
break;
default:
break;
}
}
void MainWindow::on_downloadStart(QWebEngineDownloadItem *item) void MainWindow::on_downloadStart(QWebEngineDownloadItem *item)
{ {
QString fileName = QFileInfo(item->path()).fileName(); QString fileName = QFileInfo(item->path()).fileName();
if(saveAs(fileName).isEmpty()) QString filePath = saveAs(fileName);
if(filePath.isEmpty())
{ {
return; return;
} }
item->setPath(saveAs(fileName)); item->setPath(filePath);
QString filePath = QFileInfo(item->path()).absoluteFilePath(); filePath = QFileInfo(item->path()).absoluteFilePath();
connect(item, &QWebEngineDownloadItem::downloadProgress, this, &MainWindow::on_downloadProgress); connect(item, &QWebEngineDownloadItem::downloadProgress, this, &MainWindow::on_downloadProgress);
connect(item, &QWebEngineDownloadItem::finished, this, [=] connect(item, &QWebEngineDownloadItem::finished, this, [=]()
{ {
on_downloadFinish(filePath); on_downloadFinish(filePath);
}); });
@ -263,7 +341,7 @@ void MainWindow::on_downloadFinish(QString filePath)
message->setWidget(button); message->setWidget(button);
DMessageManager::instance()->sendMessage(this, message); DMessageManager::instance()->sendMessage(this, message);
connect(button, &DPushButton::clicked, this, [=] connect(button, &DPushButton::clicked, this, [=]()
{ {
process->start("dde-file-manager --show-item " + filePath); process->start("dde-file-manager --show-item " + filePath);
message->hide(); message->hide();

@ -7,6 +7,7 @@
#include <DProgressBar> #include <DProgressBar>
#include <DFloatingMessage> #include <DFloatingMessage>
#include <QSystemTrayIcon>
#include <QProcess> #include <QProcess>
#include "widget.h" #include "widget.h"
@ -23,6 +24,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,
bool tray = false,
bool nFullScreen = false, bool nFullScreen = false,
bool nFixSize = false, bool nFixSize = false,
bool nHideButtons = false, bool nHideButtons = false,
@ -35,6 +37,7 @@ public:
private: private:
Widget *m_widget; Widget *m_widget;
DAboutDialog *m_dialog; DAboutDialog *m_dialog;
QSystemTrayIcon *m_tray;
DToolButton *btnBack; DToolButton *btnBack;
DToolButton *btnForward; DToolButton *btnForward;
@ -45,11 +48,17 @@ private:
QAction *m_fixSize; QAction *m_fixSize;
QAction *m_hideButtons; QAction *m_hideButtons;
QMenu *t_menu;
QAction *t_show;
QAction *t_about;
QAction *t_exit;
DProgressBar *bar; DProgressBar *bar;
DFloatingMessage *message; DFloatingMessage *message;
QProcess *process; QProcess *process;
bool mtray, mFixSize;
int m_width, m_height; int m_width, m_height;
void fullScreen(); void fullScreen();
@ -62,6 +71,8 @@ private:
void closeEvent(QCloseEvent *event); void closeEvent(QCloseEvent *event);
private slots: private slots:
void trayIconActivated(QSystemTrayIcon::ActivationReason reason);
void on_downloadStart(QWebEngineDownloadItem *item); void on_downloadStart(QWebEngineDownloadItem *item);
void on_downloadProgress(qint64 bytesReceived, qint64 bytesTotal); void on_downloadProgress(qint64 bytesReceived, qint64 bytesTotal);
void on_downloadFinish(QString filePath); void on_downloadFinish(QString filePath);

@ -4,52 +4,67 @@
<context> <context>
<name>MainWindow</name> <name>MainWindow</name>
<message> <message>
<location filename="../mainwindow.cpp" line="34"/> <location filename="../mainwindow.cpp" line="36"/>
<source>Full Screen</source> <source>Full Screen</source>
<translation></translation> <translation></translation>
</message> </message>
<message> <message>
<location filename="../mainwindow.cpp" line="35"/> <location filename="../mainwindow.cpp" line="37"/>
<source>Fix Size</source> <source>Fix Size</source>
<translation></translation> <translation></translation>
</message> </message>
<message> <message>
<location filename="../mainwindow.cpp" line="36"/> <location filename="../mainwindow.cpp" line="38"/>
<source>Hide Buttons</source> <source>Hide Buttons</source>
<translation></translation> <translation></translation>
</message> </message>
<message> <message>
<location filename="../mainwindow.cpp" line="142"/> <location filename="../mainwindow.cpp" line="40"/>
<source>Show MainWindow</source>
<translation></translation>
</message>
<message>
<location filename="../mainwindow.cpp" line="41"/>
<source>About</source>
<translation></translation>
</message>
<message>
<location filename="../mainwindow.cpp" line="42"/>
<source>Exit</source>
<translation>退</translation>
</message>
<message>
<location filename="../mainwindow.cpp" line="191"/>
<source>%1Fullscreen Mode</source> <source>%1Fullscreen Mode</source>
<translation>%1</translation> <translation>%1</translation>
</message> </message>
<message> <message>
<location filename="../mainwindow.cpp" line="147"/> <location filename="../mainwindow.cpp" line="201"/>
<source>%1Windowed Mode</source> <source>%1Windowed Mode</source>
<translation>%1</translation> <translation>%1</translation>
</message> </message>
<message> <message>
<location filename="../mainwindow.cpp" line="182"/> <location filename="../mainwindow.cpp" line="243"/>
<source>Save As</source> <source>Save As</source>
<translation></translation> <translation></translation>
</message> </message>
<message> <message>
<location filename="../mainwindow.cpp" line="236"/> <location filename="../mainwindow.cpp" line="314"/>
<source>%1Start downloading %2</source> <source>%1Start downloading %2</source>
<translation>%1 %2</translation> <translation>%1 %2</translation>
</message> </message>
<message> <message>
<location filename="../mainwindow.cpp" line="258"/> <location filename="../mainwindow.cpp" line="336"/>
<source>Open</source> <source>Open</source>
<translation></translation> <translation></translation>
</message> </message>
<message> <message>
<location filename="../mainwindow.cpp" line="262"/> <location filename="../mainwindow.cpp" line="340"/>
<source>download finished.</source> <source>download finished.</source>
<translation></translation> <translation></translation>
</message> </message>
<message> <message>
<location filename="../mainwindow.cpp" line="262"/> <location filename="../mainwindow.cpp" line="340"/>
<source>Show in file manager?</source> <source>Show in file manager?</source>
<translation></translation> <translation></translation>
</message> </message>
@ -103,46 +118,51 @@
</message> </message>
<message> <message>
<location filename="../main.cpp" line="90"/> <location filename="../main.cpp" line="90"/>
<source>Enable Tray Icon. Default is false.</source>
<translation></translation>
</message>
<message>
<location filename="../main.cpp" line="94"/>
<source>Run in Fullscreen Mode. Default is false.</source> <source>Run in Fullscreen Mode. Default is false.</source>
<translation></translation> <translation></translation>
</message> </message>
<message> <message>
<location filename="../main.cpp" line="94"/> <location filename="../main.cpp" line="98"/>
<source>Fix Window Size. Default is false.</source> <source>Fix Window Size. Default is false.</source>
<translation></translation> <translation></translation>
</message> </message>
<message> <message>
<location filename="../main.cpp" line="98"/> <location filename="../main.cpp" line="102"/>
<source>Hide Control Buttons. Default is false.</source> <source>Hide Control Buttons. Default is false.</source>
<translation></translation> <translation></translation>
</message> </message>
<message> <message>
<location filename="../main.cpp" line="102"/> <location filename="../main.cpp" line="106"/>
<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="108"/> <location filename="../main.cpp" line="112"/>
<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="114"/> <location filename="../main.cpp" line="118"/>
<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="120"/> <location filename="../main.cpp" line="124"/>
<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="127"/> <location filename="../main.cpp" line="131"/>
<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="134"/> <location filename="../main.cpp" line="138"/>
<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>

@ -3,7 +3,6 @@
Widget::Widget(QString szUrl, QWidget *parent) Widget::Widget(QString szUrl, QWidget *parent)
: QWidget(parent) : QWidget(parent)
, m_webEngineView(new QWebEngineView) , m_webEngineView(new QWebEngineView)
, m_page(new WebEnginePage)
, m_szUrl(szUrl) , m_szUrl(szUrl)
, m_spinner(new DSpinner) , m_spinner(new DSpinner)
, main(new QHBoxLayout) , main(new QHBoxLayout)
@ -16,7 +15,9 @@ Widget::Widget(QString szUrl, QWidget *parent)
m_webEngineView->setEnabled(true); m_webEngineView->setEnabled(true);
m_webEngineView->setAutoFillBackground(false); m_webEngineView->setAutoFillBackground(false);
m_webEngineView->setZoomFactor(1); m_webEngineView->setZoomFactor(1);
m_webEngineView->setPage(m_page);
WebEnginePage *page = new WebEnginePage;
m_webEngineView->setPage(page);
m_webEngineView->setUrl(QUrl(nullptr)); m_webEngineView->setUrl(QUrl(nullptr));
if (!m_szUrl.isEmpty()) if (!m_szUrl.isEmpty())
@ -32,9 +33,9 @@ Widget::~Widget()
{ {
} }
WebEnginePage *Widget::getPage() QWebEnginePage *Widget::getPage()
{ {
return m_page; return this->m_webEngineView->page();
} }
void Widget::goBack() void Widget::goBack()

@ -21,14 +21,13 @@ public:
explicit Widget(QString szUrl = nullptr, QWidget *parent = nullptr); explicit Widget(QString szUrl = nullptr, QWidget *parent = nullptr);
~Widget(); ~Widget();
WebEnginePage *getPage(); QWebEnginePage *getPage();
void goBack(); void goBack();
void goForward(); void goForward();
void refresh(); void refresh();
private: private:
QWebEngineView *m_webEngineView; QWebEngineView *m_webEngineView;
WebEnginePage *m_page;
QString m_szUrl; QString m_szUrl;
DSpinner *m_spinner; DSpinner *m_spinner;