feat: ISSUE #I62BVT 添加网页通知功能

WebEngineView 中添加 WebEngineView::present(std::unique_ptr<QWebEngineNotification> &newNotification) 函数,通过 DNotifySender 转发系统通知

Log: 添加网页通知功能,通知图片缓存在 /tmp 下;使用 DLogManager 生成日志;修复强制使用 DTK 平台插件异常问题
This commit is contained in:
zty199
2022-12-19 02:26:07 +08:00
parent fa54612642
commit faa613d671
11 changed files with 179 additions and 26 deletions

View File

@@ -3,6 +3,7 @@
#include "webengineview.h"
#include "webenginepage.h"
#include <DLog>
#include <DWidgetUtil>
#include <DTitlebar>
#include <DMessageManager>
@@ -15,6 +16,10 @@
#include <QDir>
#include <QStandardPaths>
#include <unistd.h>
DCORE_USE_NAMESPACE
MainWindow::MainWindow(QString szTitle,
QString szUrl,
int nWidth,
@@ -56,6 +61,9 @@ MainWindow::MainWindow(QString szTitle,
, btnCancel(new DPushButton(QObject::tr("Cancel"), downloadProgressWidget))
, isCanceled(false)
{
initTmpDir();
initLog();
initUI();
initTrayIcon();
initConnections();
@@ -90,6 +98,18 @@ void MainWindow::setDescription(const QString &desc)
}
}
QString MainWindow::title() const
{
return m_title;
}
QString MainWindow::tmpDir() const
{
QString orgName = qobject_cast<DApplication *>(qApp)->organizationName();
QString appName = qobject_cast<DApplication *>(qApp)->applicationName();
return QStandardPaths::writableLocation(QStandardPaths::TempLocation) + "/" + orgName + "/" + appName + "/" + m_title + "/" + QString::number(getuid());
}
void MainWindow::keyPressEvent(QKeyEvent *event)
{
if (!m_fixSize->isChecked()) // 固定窗口大小时禁止全屏
@@ -127,6 +147,29 @@ void MainWindow::closeEvent(QCloseEvent *event)
DMainWindow::closeEvent(event);
}
void MainWindow::initLog()
{
if (!QDir(tmpDir()).exists()) {
return;
}
DLogManager::setlogFilePath(tmpDir() + "/" + "log");
DLogManager::registerFileAppender();
DLogManager::registerConsoleAppender();
}
void MainWindow::initTmpDir()
{
QDir dir(tmpDir());
dir.removeRecursively();
dir.mkpath(dir.path());
if (!dir.exists()) {
qCritical() << Q_FUNC_INFO << dir.path() << "not exists";
return;
}
qDebug() << Q_FUNC_INFO << dir.path() << "created";
}
void MainWindow::initUI()
{
// 初始化 MainWindow