feat: ISSUE #I69IJI 自动关闭到托盘以防止下载和安装中断

添加托盘图标,主窗口关闭后仍然在后台运行;左键单机托盘图标显示主窗口

Log: 添加托盘图标;重构 MainWindow 构造函数,拆分 UI 初始化代码至单独函数;修改启动时窗口渐变动画初始化位置至 showEvent 中
This commit is contained in:
zty199
2023-01-30 18:30:43 +08:00
parent 4b40e3caca
commit cf549c540d
9 changed files with 443 additions and 279 deletions

View File

@@ -1,15 +1,37 @@
#include "basewidgetopacity.h"
#include "utils/widgetanimation.h"
#include <QCloseEvent>
#include <QSettings>
#include <QStandardPaths>
#include <QPropertyAnimation>
#include <QCloseEvent>
BaseWidgetOpacity::BaseWidgetOpacity(QWidget *parent) : DBlurEffectWidget(parent)
{
// WidgetAnimation::widgetOpacity(this,true);
}
/**
* @brief 窗口显示事件
* @param event
*/
void BaseWidgetOpacity::showEvent(QShowEvent *event)
{
// FIXME: wayland 不支持直接设置窗口透明度,需要调用 wayland 相关库(考虑抄控制中心“窗口移动时启用透明特效”代码?)
QSettings config(QStandardPaths::writableLocation(QStandardPaths::AppConfigLocation) + "/config.ini", QSettings::IniFormat);
bool isWayland = config.value("build/isWayland").toBool();
if (!isWayland)
{
if (!showWindowAnimation)
{
showWindowAnimation = true;
WidgetAnimation::widgetOpacity(this, true);
}
}
DBlurEffectWidget::showEvent(event);
}
/// @brief 窗口关闭事件
/// @param event
void BaseWidgetOpacity::closeEvent(QCloseEvent *event)
@@ -17,7 +39,7 @@ void BaseWidgetOpacity::closeEvent(QCloseEvent *event)
// FIXME: wayland 不支持直接设置窗口透明度,需要调用 wayland 相关库(考虑抄控制中心“窗口移动时启用透明特效”代码?)
QSettings config(QStandardPaths::writableLocation(QStandardPaths::AppConfigLocation) + "/config.ini", QSettings::IniFormat);
bool isWayland = config.value("build/isWayland").toBool();
if(isWayland)
if (isWayland)
{
return DBlurEffectWidget::closeEvent(event);
}

View File

@@ -8,17 +8,17 @@ DWIDGET_USE_NAMESPACE
class BaseWidgetOpacity : public DBlurEffectWidget
{
Q_OBJECT
public:
explicit BaseWidgetOpacity(QWidget *parent = nullptr);
signals:
public slots:
// QWidget interface
protected:
bool closeWindowAnimation = false;
void showEvent(QShowEvent *event) override;
void closeEvent(QCloseEvent *event) override;
protected:
bool showWindowAnimation = false;
bool closeWindowAnimation = false;
};
#endif // BASEWIDGETOPACITY_H