mirror of
https://gitee.com/spark-store-project/spark-web-app-runtime.git
synced 2025-12-15 03:22:05 +08:00
fix: 修复退出全屏模式后菜单状态不同步的问题
重载 resizeEvent,根据窗口状态手动同步菜单状态。 Log: 修复退出全屏模式后菜单状态不同步的问题
This commit is contained in:
@@ -22,7 +22,7 @@ int main(int argc, char *argv[])
|
||||
a.setAttribute(Qt::AA_UseHighDpiPixmaps);
|
||||
|
||||
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 中文件夹名也会被翻译
|
||||
|
||||
DAboutDialog *dialog = new DAboutDialog;
|
||||
@@ -41,15 +41,15 @@ int main(int argc, char *argv[])
|
||||
// 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"));
|
||||
.arg(DEFAULT_TITLE)
|
||||
.arg(QObject::tr("Presented By Spark developers # HadesStudio"));
|
||||
dialog->setDescription(szDefaultDesc);
|
||||
// WebsiteName
|
||||
dialog->setWebsiteName("Spark Project");
|
||||
// WebsiteLink
|
||||
dialog->setWebsiteLink("https://gitee.com/deepin-community-store/");
|
||||
// License
|
||||
dialog->setLicense(QObject::tr("This program is open source under GPLv3")); // 本程序按GPL第三版开源
|
||||
dialog->setLicense(QObject::tr("This program is open source under GPLv3")); // 本程序按GPL第三版开源
|
||||
|
||||
QCommandLineParser parser;
|
||||
|
||||
@@ -57,40 +57,46 @@ int main(int argc, char *argv[])
|
||||
parser.addHelpOption();
|
||||
parser.addVersionOption();
|
||||
|
||||
QCommandLineOption optParser(QStringList() << "p" << "parser",
|
||||
QCommandLineOption optParser(QStringList() << "p"
|
||||
<< "parser",
|
||||
QObject::tr("Enable CommandLineParser. Default is false."));
|
||||
parser.addOption(optParser);
|
||||
|
||||
QCommandLineOption optTitle(QStringList() << "t" << "title",
|
||||
QCommandLineOption optTitle(QStringList() << "t"
|
||||
<< "title",
|
||||
QObject::tr("The Title of Application. Default is %1.").arg(DEFAULT_TITLE),
|
||||
"title",
|
||||
DEFAULT_TITLE);
|
||||
parser.addOption(optTitle);
|
||||
|
||||
QCommandLineOption optUrl(QStringList() << "u" << "url",
|
||||
QCommandLineOption optUrl(QStringList() << "u"
|
||||
<< "url",
|
||||
QObject::tr("The target URL. Default is Blank."),
|
||||
"url",
|
||||
DEFAULT_URL);
|
||||
parser.addOption(optUrl);
|
||||
|
||||
QCommandLineOption optWidth(QStringList() << "w" << "width",
|
||||
QCommandLineOption optWidth(QStringList() << "w"
|
||||
<< "width",
|
||||
QObject::tr("The Width of Application. Default is %1.").arg(DEFAULT_WIDTH),
|
||||
"width",
|
||||
QString::number(DEFAULT_WIDTH));
|
||||
parser.addOption(optWidth);
|
||||
|
||||
QCommandLineOption optHeight(QStringList() << "H" << "height",
|
||||
QCommandLineOption optHeight(QStringList() << "H"
|
||||
<< "height",
|
||||
QObject::tr("The Height of Application. Default is %1.").arg(DEFAULT_HEIGHT),
|
||||
"height",
|
||||
QString::number(DEFAULT_HEIGHT));
|
||||
parser.addOption(optHeight);
|
||||
|
||||
QCommandLineOption optTray(QStringList() << "T" << "tray",
|
||||
QObject::tr("Enable Tray Icon. Default is false."));
|
||||
QCommandLineOption optTray(QStringList() << "T"
|
||||
<< "tray",
|
||||
QObject::tr("Enable Tray Icon. Default is false."));
|
||||
parser.addOption(optTray);
|
||||
|
||||
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);
|
||||
|
||||
QCommandLineOption optFixSize("fix-size",
|
||||
@@ -98,42 +104,47 @@ int main(int argc, char *argv[])
|
||||
parser.addOption(optFixSize);
|
||||
|
||||
QCommandLineOption optHideButtons("hide-buttons",
|
||||
QObject::tr("Hide Control Buttons. Default is false."));
|
||||
QObject::tr("Hide Control Buttons. Default is false."));
|
||||
parser.addOption(optHideButtons);
|
||||
|
||||
QCommandLineOption optIcon(QStringList() << "i" << "ico",
|
||||
QCommandLineOption optIcon(QStringList() << "i"
|
||||
<< "ico",
|
||||
QObject::tr("The ICON of Application."),
|
||||
"ico",
|
||||
DEFAULT_ICON);
|
||||
parser.addOption(optIcon);
|
||||
|
||||
QCommandLineOption optDesc(QStringList() << "d" << "desc",
|
||||
QCommandLineOption optDesc(QStringList() << "d"
|
||||
<< "desc",
|
||||
QObject::tr("The Description of Application."),
|
||||
"desc",
|
||||
DEFAULT_DESC);
|
||||
parser.addOption(optDesc);
|
||||
|
||||
QCommandLineOption optCfgFile(QStringList() << "c" << "cfg",
|
||||
QCommandLineOption optCfgFile(QStringList() << "c"
|
||||
<< "cfg",
|
||||
QObject::tr("The Configuration file of Application."),
|
||||
"cfg",
|
||||
DEFAULT_CFG);
|
||||
parser.addOption(optCfgFile);
|
||||
|
||||
QCommandLineOption optRootPath(QStringList() << "r" << "root",
|
||||
QCommandLineOption optRootPath(QStringList() << "r"
|
||||
<< "root",
|
||||
QObject::tr("The root path of the program web service."),
|
||||
"root",
|
||||
DEFAULT_ROOT);
|
||||
parser.addOption(optRootPath);
|
||||
|
||||
|
||||
QCommandLineOption optPort(QStringList() << "P" << "port",
|
||||
QCommandLineOption optPort(QStringList() << "P"
|
||||
<< "port",
|
||||
QObject::tr("The port number of the program web service."),
|
||||
"port",
|
||||
DEFAULT_PORT);
|
||||
parser.addOption(optPort);
|
||||
|
||||
#if SSL_SERVER
|
||||
QCommandLineOption optSSLPort(QStringList() << "s" << "sslport",
|
||||
QCommandLineOption optSSLPort(QStringList() << "s"
|
||||
<< "sslport",
|
||||
QObject::tr("The ssl port number of the program web service."),
|
||||
"sslport",
|
||||
DEFAULT_PORT);
|
||||
@@ -159,13 +170,10 @@ int main(int argc, char *argv[])
|
||||
#endif
|
||||
|
||||
QString szCfgFile = DEFAULT_CFG;
|
||||
if (parser.isSet(optCfgFile))
|
||||
{
|
||||
if (parser.isSet(optCfgFile)) {
|
||||
szCfgFile = parser.value(optCfgFile);
|
||||
if (!szCfgFile.isEmpty())
|
||||
{
|
||||
if (QFileInfo(szCfgFile).exists())
|
||||
{
|
||||
if (!szCfgFile.isEmpty()) {
|
||||
if (QFileInfo(szCfgFile).exists()) {
|
||||
QSettings settings(szCfgFile, QSettings::IniFormat);
|
||||
szTitle = settings.value("SparkWebAppRuntime/Title", DEFAULT_TITLE).toString();
|
||||
szUrl = settings.value("SparkWebAppRuntime/URL", DEFAULT_TITLE).toString();
|
||||
@@ -177,8 +185,8 @@ int main(int argc, char *argv[])
|
||||
hideButtons = settings.value("SparkWebAppRunTime/HideButtons", false).toBool();
|
||||
szIcon = settings.value("SparkWebAppRuntime/Ico", DEFAULT_ICON).toString();
|
||||
szDesc = QString("%1<br/><br/>%2")
|
||||
.arg(settings.value("SparkWebAppRuntime/Desc", QString()).toString())
|
||||
.arg(szDefaultDesc);
|
||||
.arg(settings.value("SparkWebAppRuntime/Desc", QString()).toString())
|
||||
.arg(szDefaultDesc);
|
||||
szRootPath = settings.value("SparkWebAppRuntime/RootPath", QString()).toString();
|
||||
u16Port = settings.value("SparkWebAppRuntime/Port", 0).toUInt();
|
||||
#if SSL_SERVER
|
||||
@@ -189,162 +197,130 @@ int main(int argc, char *argv[])
|
||||
}
|
||||
|
||||
// 命令行级别优先, 覆盖配置文件的设置
|
||||
if (parser.isSet(optTitle))
|
||||
{
|
||||
if (parser.isSet(optTitle)) {
|
||||
szTitle = parser.value(optTitle);
|
||||
}
|
||||
if (parser.isSet(optUrl))
|
||||
{
|
||||
if (parser.isSet(optUrl)) {
|
||||
szUrl = parser.value(optUrl);
|
||||
}
|
||||
if (parser.isSet(optWidth))
|
||||
{
|
||||
if (parser.isSet(optWidth)) {
|
||||
width = parser.value(optWidth).toInt();
|
||||
}
|
||||
if (parser.isSet(optHeight))
|
||||
{
|
||||
if (parser.isSet(optHeight)) {
|
||||
height = parser.value(optHeight).toInt();
|
||||
}
|
||||
|
||||
if (parser.isSet(optTray))
|
||||
{
|
||||
if (parser.isSet(optTray)) {
|
||||
tray = true;
|
||||
}
|
||||
if (parser.isSet(optFullScreen))
|
||||
{
|
||||
if (parser.isSet(optFullScreen)) {
|
||||
fullScreen = true;
|
||||
}
|
||||
if (parser.isSet(optFixSize))
|
||||
{
|
||||
if (parser.isSet(optFixSize)) {
|
||||
fixSize = true;
|
||||
}
|
||||
if (parser.isSet(optHideButtons))
|
||||
{
|
||||
if (parser.isSet(optHideButtons)) {
|
||||
hideButtons = true;
|
||||
}
|
||||
|
||||
if (parser.isSet(optDesc))
|
||||
{
|
||||
szDesc = QString("%1<br/><br/>%2").arg(parser.value(optDesc))
|
||||
.arg(szDefaultDesc);
|
||||
if (parser.isSet(optDesc)) {
|
||||
szDesc = QString("%1<br/><br/>%2").arg(parser.value(optDesc)).arg(szDefaultDesc);
|
||||
}
|
||||
|
||||
if (parser.isSet(optRootPath))
|
||||
{
|
||||
if (parser.isSet(optRootPath)) {
|
||||
szRootPath = parser.value(optRootPath);
|
||||
}
|
||||
|
||||
if (parser.isSet(optPort))
|
||||
{
|
||||
if (parser.isSet(optPort)) {
|
||||
u16Port = parser.value(optPort).toUInt();
|
||||
}
|
||||
|
||||
#if SSL_SERVER
|
||||
if (parser.isSet(optSSLPort))
|
||||
{
|
||||
if (parser.isSet(optSSLPort)) {
|
||||
u16sslPort = parser.value(optSSLPort).toUInt();
|
||||
}
|
||||
#endif
|
||||
|
||||
// 没设置 -p 并且参数个数 > 1 并且第一个参数不是 - 开始的
|
||||
if (!parser.isSet(optParser) && argc > 1 && !QString(argv[1]).startsWith("-"))
|
||||
{
|
||||
if (!parser.isSet(optParser) && argc > 1 && !QString(argv[1]).startsWith("-")) {
|
||||
// 按照固定顺序级别最优先
|
||||
if (argc > 1)
|
||||
{
|
||||
if (argc > 1) {
|
||||
szTitle = argv[1];
|
||||
}
|
||||
if (argc > 2)
|
||||
{
|
||||
if (argc > 2) {
|
||||
szUrl = argv[2];
|
||||
}
|
||||
if (argc > 3)
|
||||
{
|
||||
if (argc > 3) {
|
||||
width = QString(argv[3]).toInt();
|
||||
}
|
||||
if (argc > 4)
|
||||
{
|
||||
if (argc > 4) {
|
||||
height = QString(argv[4]).toInt();
|
||||
}
|
||||
|
||||
if (argc > 5)
|
||||
{
|
||||
if (argc > 5) {
|
||||
tray = true;
|
||||
}
|
||||
if (argc > 6)
|
||||
{
|
||||
if (argc > 6) {
|
||||
fullScreen = true;
|
||||
}
|
||||
if (argc > 7)
|
||||
{
|
||||
if (argc > 7) {
|
||||
fixSize = true;
|
||||
}
|
||||
if (argc > 8)
|
||||
{
|
||||
if (argc > 8) {
|
||||
hideButtons = true;
|
||||
}
|
||||
|
||||
if (argc > 9)
|
||||
{
|
||||
if (argc > 9) {
|
||||
szIcon = QString(argv[9]);
|
||||
}
|
||||
if (argc > 10)
|
||||
{
|
||||
if (argc > 10) {
|
||||
szDesc = QString("%1<br/><br/>%2").arg(QString(argv[10])).arg(szDefaultDesc);
|
||||
}
|
||||
if (argc > 11)
|
||||
{
|
||||
if (argc > 11) {
|
||||
szRootPath = QString(argv[11]);
|
||||
}
|
||||
if (argc > 12)
|
||||
{
|
||||
if (argc > 12) {
|
||||
u16Port = QString(argv[12]).toUInt();
|
||||
}
|
||||
#if SSL_SERVER
|
||||
if (argc > 13)
|
||||
{
|
||||
if (argc > 13) {
|
||||
u16sslPort = QString(argv[13]).toUInt();
|
||||
}
|
||||
#endif
|
||||
}
|
||||
|
||||
if(fixSize)
|
||||
{
|
||||
fullScreen = false; // 固定窗口大小时禁用全屏模式,避免标题栏按钮 BUG
|
||||
if (fixSize) {
|
||||
fullScreen = false; // 固定窗口大小时禁用全屏模式,避免标题栏按钮 BUG
|
||||
}
|
||||
|
||||
a.setQuitOnLastWindowClosed(!tray); // 启用托盘时,退出程序后服务不终止
|
||||
|
||||
MainWindow w(szTitle, szUrl, width, height, tray, fullScreen, fixSize, hideButtons, dialog);
|
||||
// qputenv("QTWEBENGINE_CHROMIUM_FLAGS", "--disable-features=UseModernMediaControls");
|
||||
|
||||
#if SSL_SERVER
|
||||
if (!szRootPath.isEmpty() && u16Port > 0 && u16sslPort > 0)
|
||||
{
|
||||
if (!szRootPath.isEmpty() && u16Port > 0 && u16sslPort > 0) {
|
||||
HttpD httpd(szRootPath, u16Port, u16sslPort);
|
||||
httpd.start();
|
||||
}
|
||||
#else
|
||||
if (!szRootPath.isEmpty() && u16Port > 0)
|
||||
{
|
||||
if (!szRootPath.isEmpty() && u16Port > 0) {
|
||||
static HttpD httpd(szRootPath, u16Port);
|
||||
QObject::connect(&w, &MainWindow::sigQuit, &httpd, &HttpD::stop);
|
||||
httpd.start();
|
||||
}
|
||||
#endif
|
||||
|
||||
if (parser.isSet(optIcon))
|
||||
{
|
||||
if (parser.isSet(optIcon)) {
|
||||
szIcon = parser.value(optIcon);
|
||||
}
|
||||
|
||||
if (!szIcon.isEmpty())
|
||||
{
|
||||
if (!szIcon.isEmpty()) {
|
||||
dialog->setWindowIcon(QIcon(szIcon));
|
||||
dialog->setProductIcon(QIcon(szIcon));
|
||||
w.setIcon(szIcon);
|
||||
}
|
||||
if (!szDesc.isEmpty())
|
||||
{
|
||||
if (!szDesc.isEmpty()) {
|
||||
dialog->setDescription(szDesc);
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user