合并主线代码

This commit is contained in:
luoxueyi 2023-06-08 19:43:56 +08:00
parent 3daa623084
commit 4644bba1c6
32 changed files with 1193 additions and 345 deletions

View File

@ -2,5 +2,7 @@
<qresource prefix="/json"/>
<qresource prefix="/">
<file>update.png</file>
<file>background_upgrade_icon.png</file>
<file>close.png</file>
</qresource>
</RCC>

Binary file not shown.

After

Width:  |  Height:  |  Size: 5.1 KiB

BIN
data/close.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 957 B

View File

@ -1,10 +1,10 @@
[Unit]
Description=系统升级后台检测程序
[Service]
Type=forking
TimeoutStartSec=infinity
ExecStartPre=apt update
ExecStart=/usr/share/kylin-update-notify/checkUpdate.py
ExecStart=/usr/bin/kylin-background-upgrade --check-upgrade

View File

@ -2,10 +2,11 @@
Description=系统升级定时检测
[Timer]
OnCalendar=*-*-* 14:00
RandomizedDelaySec=2h
Persistent=true
OnStartupSec=5min 10s
OnUnitInactiveSec=5min 10s
AccuracySec=5s
Unit=kylin-background-upgrade-manul.service
[Install]
WantedBy=timers.target
WantedBy=default.target

View File

@ -0,0 +1,10 @@
[Unit]
Description=自动更新托盘更新程序
[Service]
Type=forking
TimeoutStartSec=infinity
ExecStart=/usr/bin/kylin-background-upgrade

View File

@ -0,0 +1,12 @@
[Unit]
Description=静默更新定时检测
[Timer]
OnStartupSec=30min
OnUnitInactiveSec=2h
AccuracySec=20s
Unit=kylin-background-upgrade-silent.service
[Install]
WantedBy=default.target

View File

@ -0,0 +1,10 @@
[Desktop Entry]
Name=kylin-background-upgrade
Name[zh_CN]=更新管理器托盘程序
Exec=/usr/bin/kylin-background-upgrade --check-immediately
Icon=kylin-update-manager
Type=Application
X-UKUI-AutoRestart=true
OnlyShowIn=UKUI
X-UKUI-Autostart-Phase=Application
NoDisplay=true

Binary file not shown.

Before

Width:  |  Height:  |  Size: 715 B

After

Width:  |  Height:  |  Size: 7.9 KiB

135
debian/changelog vendored
View File

@ -1,39 +1,142 @@
kylin-update-notify (1.3.2.1-ok4) yangtze; urgency=medium
kylin-background-upgrade (1.3.2.9-0k0.7) v101; urgency=medium
*BUG号135671 【wayland】【更新升级】设置推迟时间不生效到推迟的时间后没有再次出现自动更新弹窗
*BUG号: 170221 【在线更新】藏文环境下,字号大于“小”时,系统升级提示更新窗口按钮文字显示不全
*需求号:无
*其他改动说明:无
*影响域: 无
-- luoxueyi <luoxueyi@kylinos.cn> Tue, 18 Apr 2023 09:46:45 +0800
-- luoxueyi <luoxueyi@kylinos.cn> Sat, 20 May 2023 19:30:19 +0800
kylin-update-notify (1.3.2.1-ok3) yangtze; urgency=medium
kylin-background-upgrade (1.3.2.9-0k0.6) v101; urgency=medium
* patch from zhangdongwei
*BUG号: 167695 【可信开发试点】kylin-background-upgrade 内存泄露类安全编码规范问题整改
*需求号:无
*其他改动说明:无
*影响域: 无
-- Xie Wei <xiewei@kylinos.cn> Thu, 21 Jul 2022 19:41:21 +0800
-- luoxueyi <luoxueyi@kylinos.cn> Wed, 10 May 2023 09:50:19 +0800
kylin-update-notify (1.3.2.1-ok2) yangtze; urgency=medium
kylin-background-upgrade (1.3.2.9-0k0.5) v101; urgency=medium
* add BR: python2.7-dev
*BUG号: 167695 【可信开发试点】kylin-background-upgrade 内存泄露类安全编码规范问题整改
169646 【更新升级】系统有更新的提示窗口关闭按钮无hover状态和悬浮提示
*需求号:无
*其他改动说明:无
*影响域: 无
-- Xie Wei <xiewei@kylinos.cn> Thu, 21 Jul 2022 18:26:14 +0800
-- luoxueyi <luoxueyi@kylinos.cn> Wed, 10 May 2023 09:50:19 +0800
kylin-update-notify (1.3.2.1-ok1) yangtze; urgency=medium
kylin-background-upgrade (1.3.2.9-0k0.4) v101; urgency=medium
* build for openKylin
* 修改为quilt格式
*BUG号: 163745 【在线更新】藏文系统下,系统升级提示更新窗口未完全藏化
*需求号:无
*其他改动说明:无
*影响域: 无
-- Xie Wei <xiewei@kylinos.cn> Thu, 21 Jul 2022 18:08:51 +0800
-- luoxueyi <luoxueyi@kylinos.cn> Mon, 10 Apr 2023 16:45:56 +0800
kylin-update-notify (1.3.2.1) yangtze; urgency=medium
kylin-background-upgrade (1.3.2.9-0k0.3) v101; urgency=medium
*BUG号
*BUG号: 164842 【系统更新】系统还原至出厂备份成功后不登录进桌面放置机器一段时间查看日志发现生成多次kylin-background-upgrade崩溃的core文件
*需求号:无
*其他改动说明:无
*影响域: 无
-- luoxueyi <luoxueyi@kylinos.cn> Wed, 29 Mar 2023 17:17:34 +0800
kylin-background-upgrade (1.3.2.9-0k0.2) v101; urgency=medium
*BUG号: 127614 【更新升级】在源管理服务器上将需要安装依赖的包添加到静默更新,静默更新成功但是通知显示为失败
*需求号:无
*其他改动说明:无
*影响域: 无
-- luoxueyi <luoxueyi@kylinos.cn> Wed, 23 Nov 2022 18:15:12 +0800
kylin-background-upgrade (1.3.2.9-0k0.1) v101; urgency=medium
*BUG号: 无
*需求号:无
*其他改动说明:版本号整改
*影响域: 无
-- luoxueyi <luoxueyi@kylinos.cn> Wed, 23 Nov 2022 18:15:12 +0800
kylin-background-upgrade (1.3.2.9) v101; urgency=medium
*BUG号: 无
*需求号:无
*其他改动说明:优化升级功能增加异常处理
*影响域: 系统更新-静默升级
-- luoxueyi <luoxueyi@kylinos.cn> Wed, 02 Nov 2022 18:15:12 +0800
kylin-background-upgrade (1.3.2.8) v101; urgency=medium
*BUG号: #144997 【2203自适应升级2209】系统更新提示弹窗未汉化
#144104 【在线更新】【2107在线升级2203-update1-RC6】升完基础组件立即重启登录系统后第二阶段提示窗口中点击立即更新后弹窗未消失
*需求号:无
*其他改动说明:无
*影响域: 系统更新-静默升级
-- luoxueyi <luoxueyi@kylinos.cn> Thu, 21 Jul 2022 17:57:12 +0800
-- luoxueyi <luoxueyi@kylinos.cn> Fri, 21 Oct 2022 20:46:42 +0800
kylin-background-upgrade (1.3.2.7) v101; urgency=medium
*BUG号: 无
*需求号:无
*其他改动说明:修复立即更新托盘不退出
*影响域: 系统更新-静默升级
-- luoxueyi <luoxueyi@kylinos.cn> Tue, 18 Oct 2022 09:25:31 +0800
kylin-background-upgrade (1.3.2.6) v101; urgency=medium
*BUG号: 无
*需求号:无
*其他改动说明同步2107自适应升级的问题
*影响域: 系统更新-静默升级
-- luoxueyi <luoxueyi@kylinos.cn> Tue, 18 Oct 2022 09:25:31 +0800
kylin-background-upgrade (1.3.2.5) v101; urgency=medium
*BUG号: #bug#140139 在定时弹窗中选择推迟三十分钟,三十分钟后弹窗未弹出
*需求号:无
*其他改动说明:无
*影响域: 系统更新-静默升级
-- luoxueyi <luoxueyi@kylinos.cn> Thu, 13 Oct 2022 16:53:39 +0800
kylin-background-upgrade (1.3.2.4) v101; urgency=medium
*BUG号: #136765 【离线更新】使用U盘源时控制面板-更新中,“有更新应用时通知”打开无效果
#140203 【在线更新】【PTOF】在规定时间段内桌面右下角未弹出更新通知
*需求号:无
*其他改动说明:无
*影响域: 系统更新-静默升级
-- luoxueyi <luoxueyi@kylinos.cn> Fri, 16 Sep 2022 17:59:09 +0800
kylin-background-upgrade (1.3.2.3) v101; urgency=medium
*BUG号: #134834 【在线更新】【PTOF】http源-定时更新-推迟后,未弹出托盘
#129698 【在线更新】1430~1630点外仍会弹出更新通知
#122183 【在线更新】上午8-12点外仍会弹出更新通知
*需求号:无
*其他改动说明:无
*影响域: 系统更新-静默升级
-- luoxueyi <luoxueyi@kylinos.cn> Mon, 29 Aug 2022 17:32:49 +0800
kylin-background-upgrade (1.3.2.2) v101; urgency=medium
*BUG号: #122425 【在线更新】设置每隔1min38s弹出通知在弹出的通知弹窗中点击推迟1min38s后再次弹出更新通知
*需求号:无
*其他改动说明:无
*影响域: 系统更新-静默升级
-- luoxueyi <luoxueyi@kylinos.cn> Wed, 10 Aug 2022 16:56:28 +0800
kylin-background-upgrade (1.3.2.1) v101; urgency=medium

8
debian/control vendored
View File

@ -1,4 +1,4 @@
Source: kylin-update-notify
Source: kylin-background-upgrade
Maintainer: kylin <kylin@kylinos.cn>
Section: universe/admin
Priority: optional
@ -21,10 +21,12 @@ Build-Depends: debhelper-compat(=12),
libukui-log4qt-dev,
Standards-Version: 4.1.3
Package: kylin-update-notify
Package: kylin-background-upgrade
Architecture: any
Section: universe/admin
Priority: optional
Depends: ${shlibs:Depends},
Breaks:
kylin-software-properties ( >= 0.0.1-55 ),
kylin-system-updater ( >= 2.0.5.1 )
Breaks: kylin-update-tray
Description: kylin background upgrade

5
debian/postinst vendored
View File

@ -1,4 +1,5 @@
#!/bin/bash
systemctl daemon-reload
systemctl enable kylin-background-upgrade-manul.timer
systemctl --user daemon-reload
systemctl --global enable kylin-background-upgrade-silent.timer
systemctl --global enable kylin-background-upgrade-manul.timer

4
env.pri Normal file
View File

@ -0,0 +1,4 @@
PROJECT_ROOTDIR = $$PWD
INCLUDEPATH = ./widgets
include(./widgets/widgets.pri)

View File

@ -4,7 +4,7 @@ greaterThan(QT_MAJOR_VERSION, 4): QT += widgets
CONFIG += c++11 link_pkgconfig
# 项目名
TARGET = kylin-update-notify
TARGET = kylin-background-upgrade
TEMPLATE = app
LIBS +=-lukui-log4qt
@ -13,6 +13,9 @@ LIBS +=-lukui-log4qt
target.path = /usr/bin
target.source += $$TARGET
include(env.pri)
INCLUDEPATH +=./widgets
SOURCES += \
./src/core.cpp \
./src/main.cpp \
@ -28,15 +31,27 @@ HEADERS += \
./src/updatehandle.h \
./src/updatewidget.h
# service文件装载 silent
service.files = ./data/kylin-background-upgrade-silent.service
service.path = /usr/lib/systemd/user/
# timer文件装载
timer.files = ./data/kylin-background-upgrade-silent.timer
timer.path = /usr/lib/systemd/user/
# service文件装载 manul
service_manul.files = ./data/kylin-background-upgrade-manul.service
service_manul.path = /usr/lib/systemd/system/
service_manul.path = /usr/lib/systemd/user/
# timer文件装载
timer_manul.files = ./data/kylin-background-upgrade-manul.timer
timer_manul.path = /usr/lib/systemd/system/
timer_manul.path = /usr/lib/systemd/user/
# desktop文件装载
desktop.files = ./data/kylin-background-upgrade.desktop
desktop.path = /etc/xdg/autostart
conf.files = ./data/kylin-background-upgrade-template.conf
conf.path = /var/lib/kylin-background-upgrade/
@ -45,14 +60,15 @@ schemes.files += data/org.ukui.log4qt.kylin-background-upgrade.gschema.xml
schemes.path = /usr/share/glib-2.0/schemas/
TRANSLATIONS += translations/kylin-background-upgrade_zh_CN.ts
TRANSLATIONS += translations/kylin-background-upgrade_zh_CN.ts \
translations/kylin-background-upgrade_bo_CN.ts
translation.path = /usr/share/kylin-background-upgrade
translation.files += translations/kylin-background-upgrade_zh_CN.qm
translation.files += translations/kylin-background-upgrade_bo_CN.qm
translation.path = /usr/share/kylin-background-upgrade
translation.files += translations/kylin-background-upgrade_zh_CN.qm
translation.files += translations/kylin-background-upgrade_bo_CN.qm
INSTALLS += target conf translation schemes service_manul timer_manul
INSTALLS += service target desktop timer conf translation schemes service_manul timer_manul
PKGCONFIG += gsettings-qt
@ -64,6 +80,3 @@ RESOURCES += \
DISTFILES += \
./data/update.png
DISTFILES += \
checkUpdate.py

View File

@ -1,10 +1,10 @@
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE QtCreatorProject>
<!-- Written by QtCreator 4.11.0, 2022-08-23T14:03:45. -->
<!-- Written by QtCreator 4.11.0, 2023-05-20T19:07:34. -->
<qtcreator>
<data>
<variable>EnvironmentId</variable>
<value type="QByteArray">{3d34bcf0-6a81-46d0-90d9-4cc7667111f8}</value>
<value type="QByteArray">{d65ece66-fdbd-4e6d-96fa-dd17567c5b6f}</value>
</data>
<data>
<variable>ProjectExplorer.Project.ActiveTarget</variable>
@ -54,19 +54,22 @@
</data>
<data>
<variable>ProjectExplorer.Project.PluginSettings</variable>
<valuemap type="QVariantMap"/>
<valuemap type="QVariantMap">
<valuelist type="QVariantList" key="ClangCodeModel.CustomCommandLineKey"/>
<value type="bool" key="ClangCodeModel.UseGlobalConfig">true</value>
</valuemap>
</data>
<data>
<variable>ProjectExplorer.Project.Target.0</variable>
<valuemap type="QVariantMap">
<value type="QString" key="ProjectExplorer.ProjectConfiguration.DefaultDisplayName">桌面</value>
<value type="QString" key="ProjectExplorer.ProjectConfiguration.DisplayName">桌面</value>
<value type="QString" key="ProjectExplorer.ProjectConfiguration.Id">{fb955230-392d-4c01-8fb0-8bfc9c0d7279}</value>
<value type="QString" key="ProjectExplorer.ProjectConfiguration.Id">{93f11d50-6f62-41c4-8ce9-7bf187ad830b}</value>
<value type="int" key="ProjectExplorer.Target.ActiveBuildConfiguration">0</value>
<value type="int" key="ProjectExplorer.Target.ActiveDeployConfiguration">0</value>
<value type="int" key="ProjectExplorer.Target.ActiveRunConfiguration">0</value>
<valuemap type="QVariantMap" key="ProjectExplorer.Target.BuildConfiguration.0">
<value type="QString" key="ProjectExplorer.BuildConfiguration.BuildDirectory">/home/lxy/kylin-background-upgrade/sp3/build-kylin-background-upgrade-unknown-Debug</value>
<value type="QString" key="ProjectExplorer.BuildConfiguration.BuildDirectory">/home/lxy/project/kylin-background-upgrade/1.3.2.0/build-kylin-background-upgrade-unknown-Debug</value>
<valuemap type="QVariantMap" key="ProjectExplorer.BuildConfiguration.BuildStepList.0">
<valuemap type="QVariantMap" key="ProjectExplorer.BuildStepList.Step.0">
<value type="bool" key="ProjectExplorer.BuildStep.Enabled">true</value>
@ -114,7 +117,7 @@
<value type="int" key="Qt4ProjectManager.Qt4BuildConfiguration.BuildConfiguration">2</value>
</valuemap>
<valuemap type="QVariantMap" key="ProjectExplorer.Target.BuildConfiguration.1">
<value type="QString" key="ProjectExplorer.BuildConfiguration.BuildDirectory">/home/lxy/kylin-background-upgrade/sp3/build-kylin-background-upgrade-unknown-Release</value>
<value type="QString" key="ProjectExplorer.BuildConfiguration.BuildDirectory">/home/lxy/project/kylin-background-upgrade/1.3.2.0/build-kylin-background-upgrade-unknown-Release</value>
<valuemap type="QVariantMap" key="ProjectExplorer.BuildConfiguration.BuildStepList.0">
<valuemap type="QVariantMap" key="ProjectExplorer.BuildStepList.Step.0">
<value type="bool" key="ProjectExplorer.BuildStep.Enabled">true</value>
@ -162,7 +165,7 @@
<value type="int" key="Qt4ProjectManager.Qt4BuildConfiguration.BuildConfiguration">0</value>
</valuemap>
<valuemap type="QVariantMap" key="ProjectExplorer.Target.BuildConfiguration.2">
<value type="QString" key="ProjectExplorer.BuildConfiguration.BuildDirectory">/home/lxy/kylin-background-upgrade/sp3/build-kylin-background-upgrade-unknown-Profile</value>
<value type="QString" key="ProjectExplorer.BuildConfiguration.BuildDirectory">/home/lxy/project/kylin-background-upgrade/1.3.2.0/build-kylin-background-upgrade-unknown-Profile</value>
<valuemap type="QVariantMap" key="ProjectExplorer.BuildConfiguration.BuildStepList.0">
<valuemap type="QVariantMap" key="ProjectExplorer.BuildStepList.Step.0">
<value type="bool" key="ProjectExplorer.BuildStep.Enabled">true</value>
@ -282,8 +285,9 @@
</valuelist>
<value type="int" key="PE.EnvironmentAspect.Base">2</value>
<valuelist type="QVariantList" key="PE.EnvironmentAspect.Changes"/>
<value type="QString" key="ProjectExplorer.ProjectConfiguration.Id">Qt4ProjectManager.Qt4RunConfiguration:/home/lxy/project/kylin-background-upgrade/openKylin/kylin-background-upgrade/kylin-background-upgrade.pro</value>
<value type="QString" key="ProjectExplorer.RunConfiguration.BuildKey">/home/lxy/project/kylin-background-upgrade/openKylin/kylin-background-upgrade/kylin-background-upgrade.pro</value>
<value type="QString" key="ProjectExplorer.ProjectConfiguration.DisplayName">kylin-background-upgrade2</value>
<value type="QString" key="ProjectExplorer.ProjectConfiguration.Id">Qt4ProjectManager.Qt4RunConfiguration:/home/lxy/project/kylin-background-upgrade/yhkylin-v101/kylin-background-upgrade/kylin-background-upgrade.pro</value>
<value type="QString" key="ProjectExplorer.RunConfiguration.BuildKey">/home/lxy/project/kylin-background-upgrade/yhkylin-v101/kylin-background-upgrade/kylin-background-upgrade.pro</value>
<value type="QString" key="RunConfiguration.Arguments">--check-upgrade</value>
<value type="bool" key="RunConfiguration.Arguments.multi">false</value>
<value type="QString" key="RunConfiguration.OverrideDebuggerStartup"></value>
@ -294,7 +298,7 @@
<value type="bool" key="RunConfiguration.UseQmlDebugger">false</value>
<value type="bool" key="RunConfiguration.UseQmlDebuggerAuto">true</value>
<value type="QString" key="RunConfiguration.WorkingDirectory"></value>
<value type="QString" key="RunConfiguration.WorkingDirectory.default">/home/lxy/kylin-background-upgrade/sp3/build-kylin-background-upgrade-unknown-Debug</value>
<value type="QString" key="RunConfiguration.WorkingDirectory.default">/home/lxy/project/kylin-background-upgrade/1.3.2.0/build-kylin-background-upgrade-unknown-Debug</value>
</valuemap>
<value type="int" key="ProjectExplorer.Target.RunConfigurationCount">1</value>
</valuemap>

View File

@ -0,0 +1,314 @@
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE QtCreatorProject>
<!-- Written by QtCreator 4.11.0, 2022-08-23T14:03:45. -->
<qtcreator>
<data>
<variable>EnvironmentId</variable>
<value type="QByteArray">{3d34bcf0-6a81-46d0-90d9-4cc7667111f8}</value>
</data>
<data>
<variable>ProjectExplorer.Project.ActiveTarget</variable>
<value type="int">0</value>
</data>
<data>
<variable>ProjectExplorer.Project.EditorSettings</variable>
<valuemap type="QVariantMap">
<value type="bool" key="EditorConfiguration.AutoIndent">true</value>
<value type="bool" key="EditorConfiguration.AutoSpacesForTabs">false</value>
<value type="bool" key="EditorConfiguration.CamelCaseNavigation">true</value>
<valuemap type="QVariantMap" key="EditorConfiguration.CodeStyle.0">
<value type="QString" key="language">Cpp</value>
<valuemap type="QVariantMap" key="value">
<value type="QByteArray" key="CurrentPreferences">CppGlobal</value>
</valuemap>
</valuemap>
<valuemap type="QVariantMap" key="EditorConfiguration.CodeStyle.1">
<value type="QString" key="language">QmlJS</value>
<valuemap type="QVariantMap" key="value">
<value type="QByteArray" key="CurrentPreferences">QmlJSGlobal</value>
</valuemap>
</valuemap>
<value type="int" key="EditorConfiguration.CodeStyle.Count">2</value>
<value type="QByteArray" key="EditorConfiguration.Codec">UTF-8</value>
<value type="bool" key="EditorConfiguration.ConstrainTooltips">false</value>
<value type="int" key="EditorConfiguration.IndentSize">4</value>
<value type="bool" key="EditorConfiguration.KeyboardTooltips">false</value>
<value type="int" key="EditorConfiguration.MarginColumn">80</value>
<value type="bool" key="EditorConfiguration.MouseHiding">true</value>
<value type="bool" key="EditorConfiguration.MouseNavigation">true</value>
<value type="int" key="EditorConfiguration.PaddingMode">1</value>
<value type="bool" key="EditorConfiguration.ScrollWheelZooming">true</value>
<value type="bool" key="EditorConfiguration.ShowMargin">false</value>
<value type="int" key="EditorConfiguration.SmartBackspaceBehavior">0</value>
<value type="bool" key="EditorConfiguration.SmartSelectionChanging">true</value>
<value type="bool" key="EditorConfiguration.SpacesForTabs">true</value>
<value type="int" key="EditorConfiguration.TabKeyBehavior">0</value>
<value type="int" key="EditorConfiguration.TabSize">8</value>
<value type="bool" key="EditorConfiguration.UseGlobal">true</value>
<value type="int" key="EditorConfiguration.Utf8BomBehavior">1</value>
<value type="bool" key="EditorConfiguration.addFinalNewLine">true</value>
<value type="bool" key="EditorConfiguration.cleanIndentation">true</value>
<value type="bool" key="EditorConfiguration.cleanWhitespace">true</value>
<value type="bool" key="EditorConfiguration.inEntireDocument">false</value>
</valuemap>
</data>
<data>
<variable>ProjectExplorer.Project.PluginSettings</variable>
<valuemap type="QVariantMap"/>
</data>
<data>
<variable>ProjectExplorer.Project.Target.0</variable>
<valuemap type="QVariantMap">
<value type="QString" key="ProjectExplorer.ProjectConfiguration.DefaultDisplayName">桌面</value>
<value type="QString" key="ProjectExplorer.ProjectConfiguration.DisplayName">桌面</value>
<value type="QString" key="ProjectExplorer.ProjectConfiguration.Id">{fb955230-392d-4c01-8fb0-8bfc9c0d7279}</value>
<value type="int" key="ProjectExplorer.Target.ActiveBuildConfiguration">0</value>
<value type="int" key="ProjectExplorer.Target.ActiveDeployConfiguration">0</value>
<value type="int" key="ProjectExplorer.Target.ActiveRunConfiguration">0</value>
<valuemap type="QVariantMap" key="ProjectExplorer.Target.BuildConfiguration.0">
<value type="QString" key="ProjectExplorer.BuildConfiguration.BuildDirectory">/home/lxy/kylin-background-upgrade/sp3/build-kylin-background-upgrade-unknown-Debug</value>
<valuemap type="QVariantMap" key="ProjectExplorer.BuildConfiguration.BuildStepList.0">
<valuemap type="QVariantMap" key="ProjectExplorer.BuildStepList.Step.0">
<value type="bool" key="ProjectExplorer.BuildStep.Enabled">true</value>
<value type="QString" key="ProjectExplorer.ProjectConfiguration.Id">QtProjectManager.QMakeBuildStep</value>
<value type="bool" key="QtProjectManager.QMakeBuildStep.LinkQmlDebuggingLibrary">true</value>
<value type="QString" key="QtProjectManager.QMakeBuildStep.QMakeArguments"></value>
<value type="bool" key="QtProjectManager.QMakeBuildStep.QMakeForced">false</value>
<value type="bool" key="QtProjectManager.QMakeBuildStep.SeparateDebugInfo">false</value>
<value type="bool" key="QtProjectManager.QMakeBuildStep.UseQtQuickCompiler">false</value>
</valuemap>
<valuemap type="QVariantMap" key="ProjectExplorer.BuildStepList.Step.1">
<value type="bool" key="ProjectExplorer.BuildStep.Enabled">true</value>
<value type="QString" key="ProjectExplorer.ProjectConfiguration.Id">Qt4ProjectManager.MakeStep</value>
<valuelist type="QVariantList" key="Qt4ProjectManager.MakeStep.BuildTargets"/>
<value type="bool" key="Qt4ProjectManager.MakeStep.Clean">false</value>
<value type="QString" key="Qt4ProjectManager.MakeStep.MakeArguments"></value>
<value type="QString" key="Qt4ProjectManager.MakeStep.MakeCommand"></value>
<value type="bool" key="Qt4ProjectManager.MakeStep.OverrideMakeflags">false</value>
</valuemap>
<value type="int" key="ProjectExplorer.BuildStepList.StepsCount">2</value>
<value type="QString" key="ProjectExplorer.ProjectConfiguration.DefaultDisplayName">Build</value>
<value type="QString" key="ProjectExplorer.ProjectConfiguration.DisplayName">Build</value>
<value type="QString" key="ProjectExplorer.ProjectConfiguration.Id">ProjectExplorer.BuildSteps.Build</value>
</valuemap>
<valuemap type="QVariantMap" key="ProjectExplorer.BuildConfiguration.BuildStepList.1">
<valuemap type="QVariantMap" key="ProjectExplorer.BuildStepList.Step.0">
<value type="bool" key="ProjectExplorer.BuildStep.Enabled">true</value>
<value type="QString" key="ProjectExplorer.ProjectConfiguration.Id">Qt4ProjectManager.MakeStep</value>
<valuelist type="QVariantList" key="Qt4ProjectManager.MakeStep.BuildTargets"/>
<value type="bool" key="Qt4ProjectManager.MakeStep.Clean">true</value>
<value type="QString" key="Qt4ProjectManager.MakeStep.MakeArguments">clean</value>
<value type="QString" key="Qt4ProjectManager.MakeStep.MakeCommand"></value>
<value type="bool" key="Qt4ProjectManager.MakeStep.OverrideMakeflags">false</value>
</valuemap>
<value type="int" key="ProjectExplorer.BuildStepList.StepsCount">1</value>
<value type="QString" key="ProjectExplorer.ProjectConfiguration.DefaultDisplayName">Clean</value>
<value type="QString" key="ProjectExplorer.ProjectConfiguration.DisplayName">Clean</value>
<value type="QString" key="ProjectExplorer.ProjectConfiguration.Id">ProjectExplorer.BuildSteps.Clean</value>
</valuemap>
<value type="int" key="ProjectExplorer.BuildConfiguration.BuildStepListCount">2</value>
<value type="bool" key="ProjectExplorer.BuildConfiguration.ClearSystemEnvironment">false</value>
<valuelist type="QVariantList" key="ProjectExplorer.BuildConfiguration.UserEnvironmentChanges"/>
<value type="QString" key="ProjectExplorer.ProjectConfiguration.DisplayName">Debug</value>
<value type="QString" key="ProjectExplorer.ProjectConfiguration.Id">Qt4ProjectManager.Qt4BuildConfiguration</value>
<value type="int" key="Qt4ProjectManager.Qt4BuildConfiguration.BuildConfiguration">2</value>
</valuemap>
<valuemap type="QVariantMap" key="ProjectExplorer.Target.BuildConfiguration.1">
<value type="QString" key="ProjectExplorer.BuildConfiguration.BuildDirectory">/home/lxy/kylin-background-upgrade/sp3/build-kylin-background-upgrade-unknown-Release</value>
<valuemap type="QVariantMap" key="ProjectExplorer.BuildConfiguration.BuildStepList.0">
<valuemap type="QVariantMap" key="ProjectExplorer.BuildStepList.Step.0">
<value type="bool" key="ProjectExplorer.BuildStep.Enabled">true</value>
<value type="QString" key="ProjectExplorer.ProjectConfiguration.Id">QtProjectManager.QMakeBuildStep</value>
<value type="bool" key="QtProjectManager.QMakeBuildStep.LinkQmlDebuggingLibrary">false</value>
<value type="QString" key="QtProjectManager.QMakeBuildStep.QMakeArguments"></value>
<value type="bool" key="QtProjectManager.QMakeBuildStep.QMakeForced">false</value>
<value type="bool" key="QtProjectManager.QMakeBuildStep.SeparateDebugInfo">false</value>
<value type="bool" key="QtProjectManager.QMakeBuildStep.UseQtQuickCompiler">false</value>
</valuemap>
<valuemap type="QVariantMap" key="ProjectExplorer.BuildStepList.Step.1">
<value type="bool" key="ProjectExplorer.BuildStep.Enabled">true</value>
<value type="QString" key="ProjectExplorer.ProjectConfiguration.Id">Qt4ProjectManager.MakeStep</value>
<valuelist type="QVariantList" key="Qt4ProjectManager.MakeStep.BuildTargets"/>
<value type="bool" key="Qt4ProjectManager.MakeStep.Clean">false</value>
<value type="QString" key="Qt4ProjectManager.MakeStep.MakeArguments"></value>
<value type="QString" key="Qt4ProjectManager.MakeStep.MakeCommand"></value>
<value type="bool" key="Qt4ProjectManager.MakeStep.OverrideMakeflags">false</value>
</valuemap>
<value type="int" key="ProjectExplorer.BuildStepList.StepsCount">2</value>
<value type="QString" key="ProjectExplorer.ProjectConfiguration.DefaultDisplayName">Build</value>
<value type="QString" key="ProjectExplorer.ProjectConfiguration.DisplayName">Build</value>
<value type="QString" key="ProjectExplorer.ProjectConfiguration.Id">ProjectExplorer.BuildSteps.Build</value>
</valuemap>
<valuemap type="QVariantMap" key="ProjectExplorer.BuildConfiguration.BuildStepList.1">
<valuemap type="QVariantMap" key="ProjectExplorer.BuildStepList.Step.0">
<value type="bool" key="ProjectExplorer.BuildStep.Enabled">true</value>
<value type="QString" key="ProjectExplorer.ProjectConfiguration.Id">Qt4ProjectManager.MakeStep</value>
<valuelist type="QVariantList" key="Qt4ProjectManager.MakeStep.BuildTargets"/>
<value type="bool" key="Qt4ProjectManager.MakeStep.Clean">true</value>
<value type="QString" key="Qt4ProjectManager.MakeStep.MakeArguments">clean</value>
<value type="QString" key="Qt4ProjectManager.MakeStep.MakeCommand"></value>
<value type="bool" key="Qt4ProjectManager.MakeStep.OverrideMakeflags">false</value>
</valuemap>
<value type="int" key="ProjectExplorer.BuildStepList.StepsCount">1</value>
<value type="QString" key="ProjectExplorer.ProjectConfiguration.DefaultDisplayName">Clean</value>
<value type="QString" key="ProjectExplorer.ProjectConfiguration.DisplayName">Clean</value>
<value type="QString" key="ProjectExplorer.ProjectConfiguration.Id">ProjectExplorer.BuildSteps.Clean</value>
</valuemap>
<value type="int" key="ProjectExplorer.BuildConfiguration.BuildStepListCount">2</value>
<value type="bool" key="ProjectExplorer.BuildConfiguration.ClearSystemEnvironment">false</value>
<valuelist type="QVariantList" key="ProjectExplorer.BuildConfiguration.UserEnvironmentChanges"/>
<value type="QString" key="ProjectExplorer.ProjectConfiguration.DisplayName">Release</value>
<value type="QString" key="ProjectExplorer.ProjectConfiguration.Id">Qt4ProjectManager.Qt4BuildConfiguration</value>
<value type="int" key="Qt4ProjectManager.Qt4BuildConfiguration.BuildConfiguration">0</value>
</valuemap>
<valuemap type="QVariantMap" key="ProjectExplorer.Target.BuildConfiguration.2">
<value type="QString" key="ProjectExplorer.BuildConfiguration.BuildDirectory">/home/lxy/kylin-background-upgrade/sp3/build-kylin-background-upgrade-unknown-Profile</value>
<valuemap type="QVariantMap" key="ProjectExplorer.BuildConfiguration.BuildStepList.0">
<valuemap type="QVariantMap" key="ProjectExplorer.BuildStepList.Step.0">
<value type="bool" key="ProjectExplorer.BuildStep.Enabled">true</value>
<value type="QString" key="ProjectExplorer.ProjectConfiguration.Id">QtProjectManager.QMakeBuildStep</value>
<value type="bool" key="QtProjectManager.QMakeBuildStep.LinkQmlDebuggingLibrary">true</value>
<value type="QString" key="QtProjectManager.QMakeBuildStep.QMakeArguments"></value>
<value type="bool" key="QtProjectManager.QMakeBuildStep.QMakeForced">false</value>
<value type="bool" key="QtProjectManager.QMakeBuildStep.SeparateDebugInfo">true</value>
<value type="bool" key="QtProjectManager.QMakeBuildStep.UseQtQuickCompiler">false</value>
</valuemap>
<valuemap type="QVariantMap" key="ProjectExplorer.BuildStepList.Step.1">
<value type="bool" key="ProjectExplorer.BuildStep.Enabled">true</value>
<value type="QString" key="ProjectExplorer.ProjectConfiguration.Id">Qt4ProjectManager.MakeStep</value>
<valuelist type="QVariantList" key="Qt4ProjectManager.MakeStep.BuildTargets"/>
<value type="bool" key="Qt4ProjectManager.MakeStep.Clean">false</value>
<value type="QString" key="Qt4ProjectManager.MakeStep.MakeArguments"></value>
<value type="QString" key="Qt4ProjectManager.MakeStep.MakeCommand"></value>
<value type="bool" key="Qt4ProjectManager.MakeStep.OverrideMakeflags">false</value>
</valuemap>
<value type="int" key="ProjectExplorer.BuildStepList.StepsCount">2</value>
<value type="QString" key="ProjectExplorer.ProjectConfiguration.DefaultDisplayName">Build</value>
<value type="QString" key="ProjectExplorer.ProjectConfiguration.DisplayName">Build</value>
<value type="QString" key="ProjectExplorer.ProjectConfiguration.Id">ProjectExplorer.BuildSteps.Build</value>
</valuemap>
<valuemap type="QVariantMap" key="ProjectExplorer.BuildConfiguration.BuildStepList.1">
<valuemap type="QVariantMap" key="ProjectExplorer.BuildStepList.Step.0">
<value type="bool" key="ProjectExplorer.BuildStep.Enabled">true</value>
<value type="QString" key="ProjectExplorer.ProjectConfiguration.Id">Qt4ProjectManager.MakeStep</value>
<valuelist type="QVariantList" key="Qt4ProjectManager.MakeStep.BuildTargets"/>
<value type="bool" key="Qt4ProjectManager.MakeStep.Clean">true</value>
<value type="QString" key="Qt4ProjectManager.MakeStep.MakeArguments">clean</value>
<value type="QString" key="Qt4ProjectManager.MakeStep.MakeCommand"></value>
<value type="bool" key="Qt4ProjectManager.MakeStep.OverrideMakeflags">false</value>
</valuemap>
<value type="int" key="ProjectExplorer.BuildStepList.StepsCount">1</value>
<value type="QString" key="ProjectExplorer.ProjectConfiguration.DefaultDisplayName">Clean</value>
<value type="QString" key="ProjectExplorer.ProjectConfiguration.DisplayName">Clean</value>
<value type="QString" key="ProjectExplorer.ProjectConfiguration.Id">ProjectExplorer.BuildSteps.Clean</value>
</valuemap>
<value type="int" key="ProjectExplorer.BuildConfiguration.BuildStepListCount">2</value>
<value type="bool" key="ProjectExplorer.BuildConfiguration.ClearSystemEnvironment">false</value>
<valuelist type="QVariantList" key="ProjectExplorer.BuildConfiguration.UserEnvironmentChanges"/>
<value type="QString" key="ProjectExplorer.ProjectConfiguration.DisplayName">Profile</value>
<value type="QString" key="ProjectExplorer.ProjectConfiguration.Id">Qt4ProjectManager.Qt4BuildConfiguration</value>
<value type="int" key="Qt4ProjectManager.Qt4BuildConfiguration.BuildConfiguration">0</value>
</valuemap>
<value type="int" key="ProjectExplorer.Target.BuildConfigurationCount">3</value>
<valuemap type="QVariantMap" key="ProjectExplorer.Target.DeployConfiguration.0">
<valuemap type="QVariantMap" key="ProjectExplorer.BuildConfiguration.BuildStepList.0">
<value type="int" key="ProjectExplorer.BuildStepList.StepsCount">0</value>
<value type="QString" key="ProjectExplorer.ProjectConfiguration.DefaultDisplayName">Deploy</value>
<value type="QString" key="ProjectExplorer.ProjectConfiguration.DisplayName">Deploy</value>
<value type="QString" key="ProjectExplorer.ProjectConfiguration.Id">ProjectExplorer.BuildSteps.Deploy</value>
</valuemap>
<value type="int" key="ProjectExplorer.BuildConfiguration.BuildStepListCount">1</value>
<value type="QString" key="ProjectExplorer.ProjectConfiguration.Id">ProjectExplorer.DefaultDeployConfiguration</value>
</valuemap>
<value type="int" key="ProjectExplorer.Target.DeployConfigurationCount">1</value>
<valuemap type="QVariantMap" key="ProjectExplorer.Target.PluginSettings"/>
<valuemap type="QVariantMap" key="ProjectExplorer.Target.RunConfiguration.0">
<value type="QString" key="Analyzer.Perf.CallgraphMode">dwarf</value>
<valuelist type="QVariantList" key="Analyzer.Perf.Events">
<value type="QString">cpu-cycles</value>
</valuelist>
<valuelist type="QVariantList" key="Analyzer.Perf.ExtraArguments"/>
<value type="int" key="Analyzer.Perf.Frequency">250</value>
<valuelist type="QVariantList" key="Analyzer.Perf.RecordArguments">
<value type="QString">-e</value>
<value type="QString">cpu-cycles</value>
<value type="QString">--call-graph</value>
<value type="QString">dwarf,4096</value>
<value type="QString">-F</value>
<value type="QString">250</value>
</valuelist>
<value type="QString" key="Analyzer.Perf.SampleMode">-F</value>
<value type="bool" key="Analyzer.Perf.Settings.UseGlobalSettings">true</value>
<value type="int" key="Analyzer.Perf.StackSize">4096</value>
<value type="bool" key="Analyzer.QmlProfiler.AggregateTraces">false</value>
<value type="bool" key="Analyzer.QmlProfiler.FlushEnabled">false</value>
<value type="uint" key="Analyzer.QmlProfiler.FlushInterval">1000</value>
<value type="QString" key="Analyzer.QmlProfiler.LastTraceFile"></value>
<value type="bool" key="Analyzer.QmlProfiler.Settings.UseGlobalSettings">true</value>
<valuelist type="QVariantList" key="Analyzer.Valgrind.AddedSuppressionFiles"/>
<value type="bool" key="Analyzer.Valgrind.Callgrind.CollectBusEvents">false</value>
<value type="bool" key="Analyzer.Valgrind.Callgrind.CollectSystime">false</value>
<value type="bool" key="Analyzer.Valgrind.Callgrind.EnableBranchSim">false</value>
<value type="bool" key="Analyzer.Valgrind.Callgrind.EnableCacheSim">false</value>
<value type="bool" key="Analyzer.Valgrind.Callgrind.EnableEventToolTips">true</value>
<value type="double" key="Analyzer.Valgrind.Callgrind.MinimumCostRatio">0.01</value>
<value type="double" key="Analyzer.Valgrind.Callgrind.VisualisationMinimumCostRatio">10</value>
<value type="bool" key="Analyzer.Valgrind.FilterExternalIssues">true</value>
<value type="QString" key="Analyzer.Valgrind.KCachegrindExecutable">kcachegrind</value>
<value type="int" key="Analyzer.Valgrind.LeakCheckOnFinish">1</value>
<value type="int" key="Analyzer.Valgrind.NumCallers">25</value>
<valuelist type="QVariantList" key="Analyzer.Valgrind.RemovedSuppressionFiles"/>
<value type="int" key="Analyzer.Valgrind.SelfModifyingCodeDetection">1</value>
<value type="bool" key="Analyzer.Valgrind.Settings.UseGlobalSettings">true</value>
<value type="bool" key="Analyzer.Valgrind.ShowReachable">false</value>
<value type="bool" key="Analyzer.Valgrind.TrackOrigins">true</value>
<value type="QString" key="Analyzer.Valgrind.ValgrindExecutable">valgrind</value>
<valuelist type="QVariantList" key="Analyzer.Valgrind.VisibleErrorKinds">
<value type="int">0</value>
<value type="int">1</value>
<value type="int">2</value>
<value type="int">3</value>
<value type="int">4</value>
<value type="int">5</value>
<value type="int">6</value>
<value type="int">7</value>
<value type="int">8</value>
<value type="int">9</value>
<value type="int">10</value>
<value type="int">11</value>
<value type="int">12</value>
<value type="int">13</value>
<value type="int">14</value>
</valuelist>
<value type="int" key="PE.EnvironmentAspect.Base">2</value>
<valuelist type="QVariantList" key="PE.EnvironmentAspect.Changes"/>
<value type="QString" key="ProjectExplorer.ProjectConfiguration.Id">Qt4ProjectManager.Qt4RunConfiguration:/home/lxy/project/kylin-background-upgrade/openKylin/kylin-background-upgrade/kylin-background-upgrade.pro</value>
<value type="QString" key="ProjectExplorer.RunConfiguration.BuildKey">/home/lxy/project/kylin-background-upgrade/openKylin/kylin-background-upgrade/kylin-background-upgrade.pro</value>
<value type="QString" key="RunConfiguration.Arguments">--check-upgrade</value>
<value type="bool" key="RunConfiguration.Arguments.multi">false</value>
<value type="QString" key="RunConfiguration.OverrideDebuggerStartup"></value>
<value type="bool" key="RunConfiguration.UseCppDebugger">false</value>
<value type="bool" key="RunConfiguration.UseCppDebuggerAuto">true</value>
<value type="bool" key="RunConfiguration.UseLibrarySearchPath">true</value>
<value type="bool" key="RunConfiguration.UseMultiProcess">false</value>
<value type="bool" key="RunConfiguration.UseQmlDebugger">false</value>
<value type="bool" key="RunConfiguration.UseQmlDebuggerAuto">true</value>
<value type="QString" key="RunConfiguration.WorkingDirectory"></value>
<value type="QString" key="RunConfiguration.WorkingDirectory.default">/home/lxy/kylin-background-upgrade/sp3/build-kylin-background-upgrade-unknown-Debug</value>
</valuemap>
<value type="int" key="ProjectExplorer.Target.RunConfigurationCount">1</value>
</valuemap>
</data>
<data>
<variable>ProjectExplorer.Project.TargetCount</variable>
<value type="int">1</value>
</data>
<data>
<variable>ProjectExplorer.Project.Updater.FileVersion</variable>
<value type="int">22</value>
</data>
<data>
<variable>Version</variable>
<value type="int">22</value>
</data>
</qtcreator>

View File

@ -11,7 +11,7 @@ core::core(QString getnum, QWidget *parent)
core::~core()
{
qDebug() << Q_FUNC_INFO << __LINE__;
}
void core::execSlots()

View File

@ -6,42 +6,50 @@
#include <iostream>
#include <ukui-log4qt.h>
#include<qdebug.h>
#include <QLockFile>
#define PROGRAM_NAME "kylin-background-upgrade"
#define LOG_NAME "/.config/kylin-background-upgrade/kylin-background-upgrade.log"
#define LOG_SILENT_NAME "/.config/kylin-background-upgrade/kylin-background-upgrade-silent.log"
#define LOG_MANUL_NAME "/.config/kylin-background-upgrade/kylin-background-upgrade-manul.log"
static FILE *fp = NULL;
QString toDir;
static bool _silentOrManul = true;
void msgHandler(QtMsgType type, const QMessageLogContext& context, const QString& msg)
{
static char logPath[255] = {0};
static int uid = -1;
int uid = -1;
static int pid = 0;
Q_UNUSED(context);
QDateTime currentTime = QDateTime::currentDateTime();
QString timeStr = currentTime.toString("yy.MM.dd hh:mm:ss +zzz");
pid = (int)getpid();
uid = (int)getuid();
// 获取用于控制命令行输出的环境变量
char *ctrlEnv = getenv("XXXX_DEBUG");
char *ctrlEnv = getenv("BACKGROUND_UPGRADE_DEBUG");
QString env;
// 格式化输出字符串,添加消息发生时间、消息等级
QString outMsg;
switch (type) {
case QtDebugMsg:
outMsg = QString("[%1 D]: %2").arg(timeStr).arg(msg);
outMsg = QString("[%1 D .%2 :%4]: %3").arg(timeStr).arg(pid).arg(msg).arg(uid);
break;
case QtInfoMsg:
outMsg = QString("[%1 I]: %2").arg(timeStr).arg(msg);
outMsg = QString("[%1 D .%2 :%4]: %3").arg(timeStr).arg(pid).arg(msg).arg(uid);
break;
case QtWarningMsg:
outMsg = QString("[%1 W]: %2").arg(timeStr).arg(msg);
outMsg = QString("[%1 D .%2 :%4]: %3").arg(timeStr).arg(pid).arg(msg).arg(uid);
break;
case QtCriticalMsg:
outMsg = QString("[%1 C]: %2").arg(timeStr).arg(msg);
outMsg = QString("[%1 D .%2 :%4]: %3").arg(timeStr).arg(pid).arg(msg).arg(uid);
break;
case QtFatalMsg:
outMsg = QString("[%1 F]: %2").arg(timeStr).arg(msg);
outMsg = QString("[%1 D .%2 :%4]: %3").arg(timeStr).arg(pid).arg(msg).arg(uid);
}
if (fp != NULL) {
@ -64,31 +72,43 @@ void msgHandler(QtMsgType type, const QMessageLogContext& context, const QString
abort();
}
void log_env_init(){
void log_env_init(QString arg){
static int uid = -1;
static char logPath[255] = {0};
static char logPath[98] = {0};
bool _is_root = false;
toDir = QDir::homePath();
toDir += "/.config/kylin-background-upgrade/";
QDir dir(toDir);
if(!dir.exists()) {
dir.mkdir(toDir);
}
// 初始执行时设置log文件路径
if (uid == -1) {
uid = getuid();
}
if (uid == 0) {
// root user
sprintf(logPath, "/var/log/kylin-background-upgrade/kylin-background-upgrade.log", uid, PROGRAM_NAME);
sprintf(logPath, "/var/log/kylin-background-upgrade/kylin-background-upgrade.log");
_is_root = true;
} else {
// normal user
sprintf(logPath, "/run/user/%d/%s.log", uid, PROGRAM_NAME);
// sprintf(logPath, "/run/user/%d/%s.log", uid, PROGRAM_NAME);
//QString 转 const char*
std::string str = QDir::homePath().toStdString();
const char* ch = str.c_str();
if (arg == "--check-upgrade" || arg == "--check-immediately") {
sprintf(logPath, "%s%s", ch, LOG_MANUL_NAME);
} else {
sprintf(logPath, "%s%s", ch, LOG_SILENT_NAME);
}
}
printf("Logfile path: %s\n", logPath);
if (access(logPath, F_OK|W_OK) == 0) { // log文件存在且可写
if (fp == NULL)
fp = fopen(logPath, "a+");
QFileInfo info(logPath);
if (info.size() > 1024*1024*200) { //200MB
if (info.size() > 1024*1024*20) { //20MB
fclose(fp); fp = NULL;
QFile fileclean(logPath);
fileclean.open(QIODevice::WriteOnly | QIODevice::Text | QFile::Truncate);
@ -123,32 +143,47 @@ void log_env_init(){
int main(int argc, char *argv[])
{
QString arg=QString::fromLatin1(argv[1]);
// initUkuiLog4qt("kylin-background-upgrade");
log_env_init();
log_env_init(arg);
qInstallMessageHandler(msgHandler);
char *x=getenv("DISPLAY");
char *dis_env=getenv("DISPLAY");
QString display_env(dis_env);
if(display_env != NULL){
qDebug()<<"The desktop graphics environment is normal, DISPLAY="<<dis_env;
} else {
qDebug()<<"The desktop graphics environment is abnormal, DISPLAY="<<dis_env<<", exit!";
exit(0);
}
QLockFile manul_lock(toDir+"manul.lock");
QLockFile silent_lock(toDir+"silent.lock");
qDebug()<<"";
qDebug()<<"---------------------------------------------------------------------------------------------------";
qDebug()<<"Start check upgradable ...";
QString s1(x);
if(s1 != NULL){
qDebug()<<"The desktop graphics environment is normal .";
if (arg == "--check-upgrade" || arg == "--check-immediately") {
qDebug()<<"Start check upgradable ...";
if (arg == "--check-immediately") {
qDebug()<<"Perform a boot update check ...";
}
if (!manul_lock.tryLock(0)) {
qDebug()<<"Another process is checking for updates, exit!";
exit(0);
}
} else {
qDebug()<<"The desktop graphics environment is abnormal .";
putenv("DISPLAY=:0");
qDebug()<<"Start silent upgrade ...";
if (!silent_lock.tryLock(0)) {
qDebug()<<"Another process is silently upgrading, exit!";
exit(0);
}
}
#if (QT_VERSION >= QT_VERSION_CHECK(5, 6, 0))
QApplication::setAttribute(Qt::AA_EnableHighDpiScaling);
QApplication::setAttribute(Qt::AA_UseHighDpiPixmaps);
#endif
// callPyFunc *lxy = new callPyFunc();
setenv("QT_QPA_PLATFORMTHEME","ukui",true);
qunsetenv("SESSION_MANAGER");
QApplication a(argc, argv);
core *m_core= new core(arg);
core m_core(arg);
// QObject::connect(m_core,SIGNAL(execSignal()),&a,SLOT(quit()));
return a.exec();
}

View File

@ -70,12 +70,12 @@ source_dbus::source_dbus(QObject *parent)
:QObject(parent)
{
connectTimer = new QTimer(this);
// connect(connectTimer, SIGNAL(timeout()), this, SLOT(connectDbus()));
connect(connectTimer, SIGNAL(timeout()), this, SLOT(connectDbus()));
}
source_dbus::~source_dbus()
{
qDebug() << Q_FUNC_INFO << __LINE__;
}
/**
@ -164,7 +164,7 @@ update_dbus* update_dbus::getInstance()
update_dbus::update_dbus(QObject *parent)
:QObject(parent)
{
// initUpdate_Dbus();
initUpdate_Dbus();
}
@ -270,17 +270,9 @@ QStringList update_dbus::checkForUpdates(QStringList arg)
bool update_dbus::checkForUpdateDect()
{
qDebug()<<"Start to check system upgrade ...";
// connect(interface,SIGNAL(UpdateDetectFinished(bool, QStringList, QString, QString)),this,SLOT(UpdateDectSlot(bool, QStringList, QString, QString)));
// QDBusReply<QVariantList> res = interface->call("UpdateDetect");
// QProcess process;
// process.start("/home/lxy/kylin-background-upgrade/OpenKylin/kylin-background-upgrade/checkUpdate.py");
// process.waitForStarted();
// process.waitForFinished();//以阻塞的方式等待释放
// QStringList updatelists;
// updatelists.append("kylin-video");
// QString errorcode = "";
// QString errorstring = "";
// UpdateDectSlot(true,updatelists,errorcode, errorstring);
connect(interface,SIGNAL(UpdateDetectFinished(bool, QStringList, QString, QString)),this,SLOT(UpdateDectSlot(bool, QStringList, QString, QString)));
QDBusReply<QVariantList> res = interface->asyncCall("UpdateDetect");
qDebug() << "UpdateDetect (mode: MODE_UPDATE_DETECT) ...";
return true;
}

View File

@ -11,7 +11,7 @@
#include <QDebug>
#include <QFile>
#include <QMutexLocker>
#include <QProcess>
#include <sys/stat.h>
#include <unistd.h>

View File

@ -1,5 +1,6 @@
#include "updatehandle.h"
#include <iostream>
#include <QProcess>
updatehandle::updatehandle(QString getnum1,QWidget *parent) : QWidget(parent)
{
@ -14,7 +15,7 @@ updatehandle::updatehandle(QString getnum1,QWidget *parent) : QWidget(parent)
updatehandle::~updatehandle()
{
qDebug() << Q_FUNC_INFO << __LINE__;
}
/**
@ -73,16 +74,31 @@ void updatehandle::initUI(QString argnum)
timerDownload = new QTimer(this);
connect(timerDownload, SIGNAL(timeout()), this, SLOT(downloadTimeout()));
if(argnum.contains("--check-immediately")){
qDebug()<<"exec --check-immediately";
} else if(argnum.contains("--check-upgrade")) {
qDebug()<<"exec --check-upgrade";
} else {
qDebug()<<"exec slient.";
}
trayIcon = new trayicon(this);
choice_window = new updatewidget();//更新选择页面
bool ignore_or_delay = ignoreOrDelay(argnum.contains("--check-immediately",Qt::CaseInsensitive));
choice_window = new updatewidget(ignore_or_delay);//更新选择页面
tip_window = new updateTip(); //静默升级提示
if (argnum.contains("--check-upgrade",Qt::CaseInsensitive)) {
if (argnum == "") {
//监听连接源管理器d-bus
//监听托盘点击事件3单击2双击1右键
connect(trayIcon,&trayicon::activated, this,&updatehandle::onActivated);
connect(m_sourceMutual,&source_dbus::ready,this,&updatehandle::getTemplateList);
m_sourceMutual->connectDbus();
} else if (argnum.contains("--check-upgrade",Qt::CaseInsensitive)||ignore_or_delay) {
//连接关闭功能槽函数
connect(choice_window,&updatewidget::disAgreeBtnSignals,this,&updatehandle::execslots);
UpdateDectCheck();
UpdateDectCheck(ignore_or_delay);
} else {
qDebug()<<"no --check-upgrade, exit.";
qDebug()<<"No updateexit!";
exit(0);
}
}
@ -97,7 +113,7 @@ void updatehandle::tray_Show()
if (!m_updateMutual->listenState()) {
if (m_getsql()) {
qDebug()<<"m_getsql 的值为true";
choice_window->update_lab->setText(tr("System update detected"));
choice_window->update_lab->setText(tr("System update"));
if (argnum != "update") {
choice_window->show();
}
@ -203,8 +219,10 @@ void updatehandle::getTemplateList()
QString str2;
QStringList m_crucial;
QFile file1("/var/lib/kylin-software-properties/template/crucial.list");
if (!file1.open(QIODevice::ReadOnly | QIODevice::Text))
return ;
if (!file1.open(QIODevice::ReadOnly | QIODevice::Text)){
qDebug()<<"cat not open file crucial.list";
exit(0);
}
while (!file1.atEnd()) {
QByteArray line = file1.readLine();
str1 += QString(line);
@ -216,8 +234,10 @@ void updatehandle::getTemplateList()
QStringList m_important;
QFile file2("/var/lib/kylin-software-properties/template/important.list");
if (!file2.open(QIODevice::ReadOnly | QIODevice::Text))
return ;
if (!file2.open(QIODevice::ReadOnly | QIODevice::Text)) {
qDebug()<<"cat not open file important.list";
exit(0);
}
while (!file2.atEnd()) {
QByteArray line = file2.readLine();
str2 += QString(line);
@ -289,6 +309,7 @@ void updatehandle::handleCrucial(QStringList checkCrucialAll)
for (int i=1;i<checkCrucialAll.count();i+=2) {
crucialPackageSize.append(checkCrucialAll.at(i));
}
checkCrucial = crucialPackage;
qDebug()<<"Checking for inactivity in silent upgrading ...";
timerDownload->start(20*60*1000);
if (powerState) { //判断是否获取到电量
@ -312,31 +333,31 @@ void updatehandle::handleCrucial(QStringList checkCrucialAll)
notify_send(tr("The system is updating silently"));
trayIcon->setVisible(true);
qDebug()<<"The system is updating silently ...";
// m_updateMutual->installAndUpgrade(crucialPackage);
m_updateMutual->installAndUpgrade(crucialPackage);
}
}
}
/**
* @brief updatehandle::handleImportant
* @brief updatehandle::UpdateDectSlot
*
*/
void updatehandle::UpdateDectSlot()
void updatehandle::UpdateDectSlot(bool status,QStringList list,QString errorstring,QString errorcode)
{
// if (!status) {
//// qDebug() << "Update Detect failed: " << QString("%1 %2").arg(errorstring).arg(errorcode);
// exit(0);
// } else {
// if (list.length() == 0) {
// qDebug() << "The software on this computer is up to date, exit!";
// exit(0);
// } else {
choice_window->update_lab->setText(tr("System update detected"));
if (!status) {
qDebug() << "Update Detect failed: " << QString("%1 %2").arg(errorstring).arg(errorcode);
exit(0);
} else {
if (list.length() == 0) {
qDebug() << "The software on this computer is up to date, exit!";
exit(0);
} else {
choice_window->update_lab->setText(tr("System update"));
if (argnum != "update") {
choice_window->show();
}
// }
// }
}
}
//完成检测,刷新下次更新标志位
timersetting->beginGroup(QString::fromLocal8Bit("Timer"));
timersetting->setValue("GeneratRandomTime",true);
@ -349,31 +370,11 @@ void updatehandle::UpdateDectSlot()
* @brief updatehandle::UpdateDectCheck
*
*/
void updatehandle::UpdateDectCheck()
void updatehandle::UpdateDectCheck(bool _check_immediately)
{
//判断是否有系统更新
// if(!checktime()){
qDebug()<<"wait for upgrade ...";
// connect(m_updateMutual,&update_dbus::UpdateDectFinished,this,&updatehandle::UpdateDectSlot);
QDBusConnection::systemBus().connect(QString(),QString("/"),"com.kylin.update.notification","DownloadFinish",this,SLOT(UpdateDectSlot()));
// bool ret= m_updateMutual->checkForUpdateDect();
// } else {
// qDebug()<<"The scheduled time is not reached, exit.";
// exit(0);
// }
}
/**
* @brief updatehandle::handleImportant
*
*/
void updatehandle::handleImportant()
{
//判断是否需要检查系统更新
if(checktime()){
if (!m_updateMutual->listenState()) {
if (m_getsql()) {
if(checktime() || !RandomizedExecute || _check_immediately){
if (m_getsql() || _check_immediately) {
qDebug()<<"Detection update has been opened ...";
connect(m_updateMutual,&update_dbus::UpdateDectFinished,this,&updatehandle::UpdateDectSlot);
bool ret= m_updateMutual->checkForUpdateDect();
@ -382,13 +383,48 @@ void updatehandle::handleImportant()
exit(0);
}
} else {
qDebug()<<"更新管理器已运行,程序退出";
qDebug()<<"The scheduled time is not reached, exit.";
exit(0);
}
}
/**
* @brief updatehandle::ignoreOrDelays
*
*/
bool updatehandle::ignoreOrDelay(bool mode)
{
static char flagPath[64] = {0};
sprintf(flagPath, "/var/cache/kylin-update-manager/ignoreOrDelay");
bool ignore_or_delay = false;
QFile file(flagPath);
//判断是否完成第一步更新
if (access(flagPath, F_OK) == 0) { // flag文件存在且可写
qDebug()<<flagPath<<"is found!";
if (!file.open(QIODevice::ReadOnly | QIODevice::Text))
ignore_or_delay = false;
QByteArray line = file.readLine();
if(QString(line).contains("2107",Qt::CaseInsensitive)) {
ignore_or_delay = true;
qDebug()<<"The first step of the upgrade has been completed, Detection of the second step of the upgrade! [2107]";
// //需要清空文件
// file.close();
// file.open(QIODevice::Truncate);
// file.close();
// file.open(QIODevice::WriteOnly);
} else if (QString(line).contains("2203",Qt::CaseInsensitive)) {
ignore_or_delay = true;
qDebug()<<"The first step of the upgrade has been completed, Detection of the second step of the upgrade! [2203]";
}
} else {
qDebug()<<"The scheduled time is not reached, exit.";
exit(0);
qDebug()<<flagPath<<"isn't found!";
ignore_or_delay = false;
}
file.close();
return ignore_or_delay&&mode;
}
/**
@ -464,10 +500,14 @@ void updatehandle::d_busStatus(QString arg,int32_t args,QString state)
void updatehandle::InstallFinsih(bool state,QStringList pkgname,QString error,QString reason)
{
bool _check_status;
timerDownload->stop();
if(state){
//apt返回失败时判断是否安装成功
if (!state)
_check_status = package_installation_status(checkCrucial);
if(state || _check_status){
qDebug() << "Silent upgrade is complete, exit.";
// qDebug() << (tr("The system has completed an important update, It is recommended that you restart immediately."));
notify_send(tr("The system has completed an important update, It is recommended that you restart immediately."));
}else{
QString errorstate = tr("update error");
@ -481,16 +521,56 @@ void updatehandle::InstallFinsih(bool state,QStringList pkgname,QString error,QS
exit(0);
}
bool updatehandle::package_installation_status(QStringList pkgs)
{
QString pkgname;
QString cmd;
QProcess process;
bool status,status_single;
for (QStringList::iterator it = pkgs.begin(); it != pkgs.end(); ++it) {
pkgname = *it;
status_single = false;
cmd = QString("dpkg -l %1").arg(pkgname);
process.start(cmd);
process.waitForFinished();
QByteArray result_ = process.readAllStandardOutput();
if (QString::fromLocal8Bit(result_) != "") {
QStringList rets = QString::fromLocal8Bit(result_).split(QRegExp("[\n]"),QString::SkipEmptyParts);
for (QStringList::iterator it_ret = rets.begin(); it_ret != rets.end(); ++it_ret) {
QString ret;
ret = *it_ret;
if (ret.contains(pkgname) && ret.startsWith("ii")) {
status_single = true;
qDebug() << "pkg "<<pkgname<<"Installation succeeded.";
}
}
if (!status_single) { //install failed
status = false;
break;
}
} else {
status = false;
break;
}
if (status_single)
status = true;
}
return status;
}
/**
* @brief updatehandle::execslots
*
*/
void updatehandle::execslots()
{
choice_window->comboBox->setCurrentIndex(0);
choice_window->hide();
qDebug()<<"Hide choice_window.";
// emit execSignal();
//设置推迟检测,更新标志位
timersetting->beginGroup(QString::fromLocal8Bit("Timer"));
timersetting->setValue("CheckCompleted",false);
timersetting->setValue("GeneratRandomTime",false);
timersetting->sync();
timersetting->endGroup();
emit execSignal();
}
/**

View File

@ -86,7 +86,9 @@ public:
void readconf(); //读取配置文件
int _secsTo(QString,QString); //时间差
void getpower(); //获取电量值
void UpdateDectCheck(); //调用后端UpdateDetect
void UpdateDectCheck(bool); //调用后端UpdateDetect
bool ignoreOrDelay(bool mode); //是否开机检查检查弹窗
bool package_installation_status(QStringList);
signals:
void execSignal(); //关闭窗口信号
@ -97,7 +99,7 @@ protected slots:
void d_busStatus(QString,int32_t,QString); //判断下载状态的槽函数
void InstallFinsih(bool,QStringList,QString,QString); //状态槽函数
void downloadTimeout(); //延时检测下载状态
void UpdateDectSlot(); //updatedetect回调函数
void UpdateDectSlot(bool,QStringList,QString,QString); //updatedetect回调函数
};
#endif // TRAY_H

View File

@ -1,6 +1,8 @@
#include "updatewidget.h"
#include "ui_updatewidget.h"
#include <QPainterPath>
#include <QToolTip>
#include <QHoverEvent>
#define PANEL_DBUS_SERVICE "com.ukui.panel.desktop"
#define PANEL_DBUS_PATH "/"
#define PANEL_DBUS_INTERFACE "com.ukui.panel.desktop"
@ -10,7 +12,7 @@
#define DBUS_PATH "/org/ukui/SettingsDaemon/wayland"
#define DBUS_INTERFACE "org.ukui.SettingsDaemon.wayland"
updatewidget::updatewidget(QWidget *parent) :
updatewidget::updatewidget(bool check_Tips, QWidget *parent) :
QWidget(parent),
ui(new Ui::Form)
{
@ -30,68 +32,166 @@ updatewidget::updatewidget(QWidget *parent) :
GetsAvailableAreaScreen();
qDebug()<<"wayland";
}
_check_Tips = check_Tips;
//设置任务栏无显示
setWindowFlags(Qt::FramelessWindowHint | Qt::X11BypassWindowManagerHint);
setWindowFlags(windowFlags() | Qt::WindowStaysOnTopHint);
update_lab = new QLabel();
icon_lab = new QLabel();
tip_lab = new QLabel();
tip_lab->setText(tr("at"));
tip_lab1 = new QLabel();
tip_lab1->setText(tr("No reminders"));
agreebtn = new QPushButton();
disagreebtn = new QPushButton();
tip_lab->setText(tr(" Updatable app detected on your system!"));
agreebtn = new FixButton();
delaybtn = new FixButton();
window_close = new QPushButton(this);
window_close->setIcon(QIcon::fromTheme("window-close-symbolic"));
window_close->setProperty("isWindowButton", 0x2);
window_close->setProperty("useIconHighlightEffect", 0x8);
window_close->setFlat(true);
window_close->setToolTip(tr("Close"));
window_close->installEventFilter(this);
connect(window_close, &QPushButton::clicked, this, &updatewidget::onClick_close_btn);
QPixmap icon(QIcon::fromTheme("ukui-control-center").pixmap(QSize(26,26)));
m_pfirstlayout = new QVBoxLayout();
m_labellayout = new QHBoxLayout();
m_psecondlayout = new QHBoxLayout();
m_pselectlayout = new QHBoxLayout();
comboBox = new QComboBox();
comboBox->clear();
strList<<tr("In 30 minutes")<<tr("three hours later")<<tr("one day later");
strList<<tr("30 minutes later")<<tr("1 hour later")<<tr("5 hours later")<<tr("1 day later")<<tr("3 days later");
comboBox->addItems(strList);
comboBox->installEventFilter(this);
labelwidget = new QWidget();
statwidget = new QWidget();
selectWidget = new QWidget();
statwidget = new QWidget();
agreebtn->setText(tr("Update"));
disagreebtn->setText(tr("Delay"));
agreebtn->setText(tr("Update"),1);
agreebtn->installEventFilter(this);
delaybtn->setText(tr("Delay"),1);
delaybtn->installEventFilter(this);
connect(agreebtn,&QPushButton::clicked,this,&updatewidget::agreeBtnClicked);
connect(disagreebtn,&QPushButton::clicked,this,&updatewidget::disAgreeBtnClicked);
connect(comboBox,SIGNAL(activated(int)),this,SLOT(comboBoxClicked(int)));
connect(delaybtn,&QPushButton::clicked,this,&updatewidget::delayBtnClicked);
icon_lab->setPixmap(icon);
icon_lab->setScaledContents(true);
icon_lab->setMaximumSize(26,26);
update_lab->setMaximumHeight(26);
update_lab->setContentsMargins(0,0,0,3);
window_close->setFixedSize(24,24);
window_close->setContentsMargins(0,0,0,3);
m_labellayout->addWidget(icon_lab);
m_labellayout->addWidget(update_lab);
m_labellayout->addStretch();
m_labellayout->addWidget(window_close);
m_labellayout->setContentsMargins(0,0,0,20);
labelwidget->setLayout(m_labellayout);
m_pselectlayout->addWidget(tip_lab);
m_pselectlayout->addWidget(comboBox);
m_pselectlayout->addWidget(tip_lab1);
m_pselectlayout->addStretch();
m_pselectlayout->setContentsMargins(0,0,0,25);
selectWidget->setLayout(m_pselectlayout);
m_psecondlayout->addWidget(disagreebtn);
m_psecondlayout->addStretch();
comboBox->setFixedHeight(35);
comboBox->setMinimumWidth(135);
comboBox->setMaximumWidth(155);
agreebtn->setFixedSize(100,35);
if (_check_Tips)
m_psecondlayout->addWidget(delaybtn);
else
m_psecondlayout->addWidget(comboBox);
m_psecondlayout->addWidget(agreebtn);
m_psecondlayout->setSpacing(15); //set space between comboBox and btn
m_psecondlayout->setContentsMargins(0,0,12,12);
statwidget->setLayout(m_psecondlayout);
m_pfirstlayout->addWidget(labelwidget);
m_pfirstlayout->addWidget(selectWidget);
m_pfirstlayout->addWidget(statwidget);
this->setLayout(m_pfirstlayout);
this->setAttribute(Qt::WA_TranslucentBackground);
this->setFixedSize(330,180);
m_pfirstlayout->setSpacing(2);
this->setLayout(m_pfirstlayout);
this->setFixedSize(435,160);
// QGSettings *settings;
// if(QGSettings::isSchemaInstalled("org.ukui.style")){
// settings = new QGSettings("org.ukui.style");
// connect(settings,&QGSettings::changed,this,&ActiveConnectionWidget::GSettingsChanges);
// }
// const QByteArray transparency_id(TRANSPARENCY_SETTINGS);
// if(QGSettings::isSchemaInstalled(transparency_id)) {
// transparency = new QGSettings(transparency_id);
// }
// if(QGSettings::isSchemaInstalled(transparency_id)) {
// getTransparency();
// connect(transparency,&QGSettings::changed,this,&ActiveConnectionWidget::GSettingsChanges);
// }
this->setProperty("useStyleWindowManager", false);
this->setProperty("useSystemStyleBlur", true);
this->setAttribute(Qt::WA_TranslucentBackground, true);
this->setWindowOpacity(0.9);
// labelwidget->setStyleSheet("background-color:green;");
// update_lab->setStyleSheet("background-color:blue;");
// selectWidget->setStyleSheet("background-color:red;");
// statwidget->setStyleSheet("background-color:orange;");
// comboBox->setStyleSheet("background-color:violet;");
// agreebtn->setStyleSheet("background-color:yellow;");
}
updatewidget::~updatewidget()
{
qDebug() << Q_FUNC_INFO << __LINE__;
delete ui;
}
void updatewidget::onClick_close_btn()
{
// emit disAgreeBtnSignals();
qDebug()<<"User Cancel reminder, exit tray program!";
// exit(0);
qApp->quit();
}
/**
* @brief updatewidget::eventFilter
*
*/
bool updatewidget::eventFilter(QObject *obj, QEvent *event)
{
if (obj == this->window_close) { //指定window_close
if (event->type() == QEvent::HoverMove) {
QPushButton *close_btn = qobject_cast<QPushButton *>(obj);
if (close_btn) {
QToolTip::showText(QCursor::pos(), close_btn->toolTip());
}
}
} else if (obj == this->agreebtn || obj == this->delaybtn) {
if (event->type() == QEvent::HoverMove) {
FixButton *btn = qobject_cast<FixButton *>(obj);
if (btn) {
QToolTip::showText(QCursor::pos(), btn->toolTip());
}
}
} else if (obj == this->comboBox) {
if (event->type() == QEvent::HoverMove) {
QComboBox *comboBox = qobject_cast<QComboBox *>(obj);
if (comboBox) {
QToolTip::showText(QCursor::pos(), comboBox->toolTip());
}
}
}
return QWidget::eventFilter(obj, event);
}
/**
* @brief updatewidget::initPanelDbusGsetting
* gsetting和dbus
@ -181,26 +281,26 @@ void updatewidget::GetsAvailableAreaScreen()
{
case updatewidget::PanelDown :
{
this->setGeometry(m_nScreenWidth - 340,m_nScreenHeight - h - 190,300,150-100);
qDebug()<<"Taskbar coordinates: [ '"<<m_nScreenWidth-340<<"','"<< m_nScreenHeight-h-190<<"','"<<300<<"','"<<150 - 100<<"']";
this->setGeometry(m_nScreenWidth - 445,m_nScreenHeight - h - 170,300,150-100);
qDebug()<<"Taskbar coordinates: [ '"<<m_nScreenWidth-445<<"','"<< m_nScreenHeight-h-170<<"','"<<300<<"','"<<150 - 100<<"']";
}
break;
case updatewidget::PanelUp:
{
this->setGeometry(m_nScreenWidth - 340,m_nScreenHeight - 190,300,150-100);
qDebug()<<"任务栏在上方: 显示坐标为: "<<m_nScreenWidth - 340 << m_nScreenHeight - 190 << 300 << 150 - 100;
this->setGeometry(m_nScreenWidth - 445,m_nScreenHeight - 170,300,150-100);
qDebug()<<"任务栏在上方: 显示坐标为: "<<m_nScreenWidth - 445 << m_nScreenHeight - 170 << 300 << 150 - 100;
}
break;
case updatewidget::PanelLeft:
{
this->setGeometry(m_nScreenWidth - 340,m_nScreenHeight - 190,300,150-100);
qDebug()<<"任务栏在左侧: 显示坐标为: "<<m_nScreenWidth - 340 << m_nScreenHeight - 190 << 300 << 150 - 100;
this->setGeometry(m_nScreenWidth - 445,m_nScreenHeight - 170,300,150-100);
qDebug()<<"任务栏在左侧: 显示坐标为: "<<m_nScreenWidth - 445 << m_nScreenHeight - 170 << 300 << 150 - 100;
}
break;
case updatewidget::PanelRight:
{
this->setGeometry(m_nScreenWidth - 340 - h,m_nScreenHeight - 190,300,150-100);
qDebug()<<"任务栏在右侧: 显示坐标为: "<<m_nScreenWidth - 340 - h << m_nScreenHeight - 190 << 300 << 150 - 100;
this->setGeometry(m_nScreenWidth - 445 - h,m_nScreenHeight - 170,300,150-100);
qDebug()<<"任务栏在右侧: 显示坐标为: "<<m_nScreenWidth - 445 - h << m_nScreenHeight - 170 << 300 << 150 - 100;
}
break;
default:
@ -289,20 +389,20 @@ void updatewidget::set_window_position()
m = getTaskbarHeight("height");
if(n == 0){
//任务栏在下侧
this->setGeometry(priWid-330-distance,availableHeight-180-m-distance,this->width(),this->height());
qDebug()<<"任务栏在下侧"<<priWid-330-distance<<" "<<availableHeight-180-m-distance <<" "<<this->width()<<" "<<this->height();
this->setGeometry(priWid-435-distance,availableHeight-160-m-distance,this->width(),this->height());
qDebug()<<"任务栏在下侧"<<priWid-435-distance<<" "<<availableHeight-160-m-distance <<" "<<this->width()<<" "<<this->height();
}else if(n == 1){
//任务栏在上侧
this->setGeometry(priWid-330-distance,availableHeight-180-distance,this->width(),this->height());
qDebug()<<"任务栏在上侧"<<priWid-330-distance<<" "<<availableHeight-180-distance <<" "<<this->width()<<" "<<this->height();
this->setGeometry(priWid-435-distance,availableHeight-160-distance,this->width(),this->height());
qDebug()<<"任务栏在上侧"<<priWid-435-distance<<" "<<availableHeight-160-distance <<" "<<this->width()<<" "<<this->height();
} else if (n == 2){
//任务栏在左侧
this->setGeometry(priWid-330-distance,availableHeight-180-distance,this->width(),this->height());
qDebug()<<"任务栏在左侧"<<priWid-330-distance<<" "<<availableHeight-180-distance <<" "<<this->width()<<" "<<this->height();
this->setGeometry(priWid-435-distance,availableHeight-160-distance,this->width(),this->height());
qDebug()<<"任务栏在左侧"<<priWid-435-distance<<" "<<availableHeight-160-distance <<" "<<this->width()<<" "<<this->height();
} else if (n == 3){
//任务栏在右侧
this->setGeometry(availableWidth-330-m-distance,availableHeight-180-distance,this->width(),this->height());
qDebug()<<"任务栏在右侧"<<availableWidth-330-m-distance<<" "<<availableHeight-180-distance <<" "<<this->width()<<" "<<this->height();
this->setGeometry(availableWidth-435-m-distance,availableHeight-160-distance,this->width(),this->height());
qDebug()<<"任务栏在右侧"<<availableWidth-435-m-distance<<" "<<availableHeight-160-distance <<" "<<this->width()<<" "<<this->height();
}
}
@ -313,53 +413,55 @@ void updatewidget::set_window_position()
*/
char *updatewidget::insideTime()
{
qDebug()<<"Current index: "<<comboBox->currentText();
qDebug()<<"current select: "<<this->comboBox->currentText();
QDateTime time = QDateTime::currentDateTime(); //获取系统现在的时间
QString str = time.toString("yyyy-MM-dd hh:mm:ss"); //设置显示格式
QByteArray str2char2 = str.toLatin1(); // must
char *nowtime = str2char2.data();
delayTimer = new QTimer();
delayTimer_Checker = new QTimer();
connect(delayTimer, SIGNAL(timeout()), this, SLOT(delayTimeout()));
connect(delayTimer_Checker, SIGNAL(timeout()), this, SLOT(delayTimeOutChecker()));
if(comboBox->currentText() == strList.at(0)) {
QDateTime time = QDateTime::currentDateTime(); //获取系统现在的时间
QString str = time.toString("yyyy-MM-dd hh:mm:ss"); //设置显示格式
QDateTime bojb = QDateTime::fromString(str,"yyyy-MM-dd hh:mm:ss").addSecs(1800);
QString str1 = bojb.toString("yyyy-MM-dd hh:mm:ss");
QByteArray str2char2 = str1.toLatin1(); // must
nowtime = str2char2.data();
delaytime = 1800;
delayTimer->start(delaytime * 1000);
delayTimer_Checker->start(60 * 1000);
return nowtime;
} else if (comboBox->currentText() == strList.at(1)) {
QDateTime bojb = QDateTime::fromString(str,"yyyy-MM-dd hh:mm:ss").addSecs(3600 * 3);
QDateTime time = QDateTime::currentDateTime(); //获取系统现在的时间
QString str = time.toString("yyyy-MM-dd hh:mm:ss"); //设置显示格式
QDateTime bojb = QDateTime::fromString(str,"yyyy-MM-dd hh:mm:ss").addSecs(3600);
QString str1 = bojb.toString("yyyy-MM-dd hh:mm:ss");
QByteArray str2char2 = str1.toLatin1(); // must
nowtime = str2char2.data();
delaytime = 3600 * 3;
delayTimer->start(delaytime * 1000);
delayTimer_Checker->start(60 * 1000);
return nowtime;
} else if (comboBox->currentText() == strList.at(2)) {
QDateTime time = QDateTime::currentDateTime(); //获取系统现在的时间
QString str = time.toString("yyyy-MM-dd hh:mm:ss"); //设置显示格式
QDateTime bojb = QDateTime::fromString(str,"yyyy-MM-dd hh:mm:ss").addSecs(18000);
QString str1 = bojb.toString("yyyy-MM-dd hh:mm:ss");
QByteArray str2char2 = str1.toLatin1(); // must
nowtime = str2char2.data();
return nowtime;
} else if (comboBox->currentText() == strList.at(3)) {
QDateTime time = QDateTime::currentDateTime(); //获取系统现在的时间
QString str = time.toString("yyyy-MM-dd hh:mm:ss"); //设置显示格式
QDateTime bojb = QDateTime::fromString(str,"yyyy-MM-dd hh:mm:ss").addDays(1);
QString str1 = bojb.toString("yyyy-MM-dd hh:mm:ss");
QByteArray str2char2 = str1.toLatin1(); // must
nowtime = str2char2.data();
return nowtime;
} else if (comboBox->currentText() == strList.at(4)) {
QDateTime time = QDateTime::currentDateTime(); //获取系统现在的时间
QString str = time.toString("yyyy-MM-dd hh:mm:ss"); //设置显示格式
QDateTime bojb = QDateTime::fromString(str,"yyyy-MM-dd hh:mm:ss").addDays(3);
QString str1 = bojb.toString("yyyy-MM-dd hh:mm:ss");
QByteArray str2char2 = str1.toLatin1(); // must
nowtime = str2char2.data();
return nowtime;
}
qDebug()<<"delay trigger for: "<<delaytime;
return nowtime;
}
/**
* @brief updatehandle::delayTimeout
*
*/
void updatewidget::delayTimeout()
{
qDebug() << "delayTimeout, Redetect the update ...";
delayTimer->stop();
delayTimer_Checker->stop();
QProcess p(0);
p.startDetached("/usr/share/kylin-update-notify/checkUpdate.py");
p.waitForStarted();
}
void updatewidget::delayTimeOutChecker()
{
qDebug()<< qSetFieldWidth(0) << "delayTimeoutChecker remainingTime: "<<delayTimer->remainingTime()/1000<<"s";
}
/**
@ -369,19 +471,38 @@ void updatewidget::delayTimeOutChecker()
void updatewidget::agreeBtnClicked()
{
emit agreeBtnSignals();
// qDebug()<<"WifiButtonClickSlot is running";
bool _is_2107 = true;
QFile file("/etc/os-release");
if (file.open(QIODevice::ReadOnly | QIODevice::Text)) {
QString line;
QTextStream in(&file);
line = in.readLine();
while(!line.isNull()) {
line = in.readLine();
if(line.contains("KYLIN_RELEASE_ID")) {
_is_2107 = false;
}
}
}
file.close();
QProcess p(0);
p.startDetached("update-manager");
if (_is_2107) {
p.startDetached("ukui-control-center --upgrade");
qDebug()<<"exec --upgrade";
} else {
p.startDetached("ukui-control-center -m upgrade");
qDebug()<<"exec -m upgrade";
}
p.waitForStarted();
qDebug()<<"Open the control panel and start updating immediately, exit tray program!";
this->hide();
exit(0);
}
/**
* @brief updatewidget::disAgreeBtnClicked
*
* @brief updatewidget::comboBoxClicked
*
*/
void updatewidget::disAgreeBtnClicked()
void updatewidget::comboBoxClicked(int num)
{
//判断是否有kylin-background-upgrade目录没有则创建
QString toDir = QDir::homePath();
@ -398,7 +519,7 @@ void updatewidget::disAgreeBtnClicked()
exit(0);
} else {
char *nowtime=insideTime();
qDebug() << "nowtime "<<nowtime;
qDebug() << "current timing: "<<nowtime;
timersettings = new QSettings(toDir,QSettings::IniFormat);
timersettings->beginGroup(QString::fromLocal8Bit("Timer"));
timersettings->setValue("CheckUpgradeTime",nowtime);
@ -406,8 +527,18 @@ void updatewidget::disAgreeBtnClicked()
timersettings->endGroup();
}
emit disAgreeBtnSignals();
qDebug()<<"Delay updating the system.";
// exit(0);
qDebug()<<"Users do not update, exit tray program!";
exit(0);
}
/**
* @brief updatewidget::delayBtnClicked
* 退
*/
void updatewidget::delayBtnClicked()
{
qDebug() << "User deferred updates, exit!";
exit(0);
}
/**
@ -434,6 +565,16 @@ void updatewidget::paintEvent(QPaintEvent *e)
p.drawRoundedRect(opt.rect,12,12);
setProperty("blurRegion",QRegion(path.toFillPolygon().toPolygon()));
style()->drawPrimitive(QStyle::PE_Widget, &opt, &p, this);
QFontMetrics fontMetrics(this->font());
QString current_str = comboBox->currentText();
int fontSize = fontMetrics.width(current_str);
int showTextSize = comboBox->width() - 32;
if (fontSize > showTextSize) {
QString elidedText = fontMetrics.elidedText(comboBox->currentText(), Qt::ElideRight, showTextSize);
comboBox->setItemText(comboBox->currentIndex(), elidedText);
comboBox->setToolTip(current_str);
}
QWidget::paintEvent(e);
}
@ -454,7 +595,9 @@ updateTip::updateTip(QWidget *parent) :
tipLabel->setText(tr("The system is updating silently"));
m_layout->addWidget(tipLabel);
this->setLayout(m_layout);
this->setAttribute(Qt::WA_TranslucentBackground);
this->setProperty("useSystemStyleBlur", true);
this->setAttribute(Qt::WA_TranslucentBackground, true);
this->setWindowOpacity(0.9);
}
updateTip::~updateTip()
@ -489,3 +632,4 @@ void updateTip::paintEvent(QPaintEvent *e)
QWidget::paintEvent(e);
}

View File

@ -19,9 +19,10 @@
#include <QScreen>
#include <QDBusReply>
#include <QSettings>
#include <QTimer>
#include <sys/stat.h>
#include <unistd.h>
#include <QMouseEvent>
#include "Button/fixbutton.h"
namespace Ui {
class Form;
@ -32,7 +33,7 @@ class updatewidget : public QWidget
Q_OBJECT
public:
explicit updatewidget(QWidget *parent = nullptr);
explicit updatewidget(bool check_Tips, QWidget *parent = nullptr);
~updatewidget();
enum PanelStatePosition
@ -43,19 +44,20 @@ public:
PanelRight
};
bool _check_Tips;
QLabel *update_lab;
QLabel *icon_lab;
QLabel *tip_lab;
QLabel *tip_lab1;
QTimer *delayTimer;
QTimer *delayTimer_Checker;
unsigned int delaytime;
QLabel *close_lab;
QPushButton *agreebtn;
QPushButton *disagreebtn;
FixButton *agreebtn;
FixButton *delaybtn;
QPushButton *window_close;
QWidget *labelwidget;
QWidget *statwidget;
QWidget *selectWidget;
QStringList strList;
QPixmap *icon;
QVBoxLayout *m_pfirstlayout = nullptr;
QHBoxLayout *m_labellayout = nullptr;
@ -82,9 +84,8 @@ public:
void initset_window_position();
void listenPanelChange();
void initPanelDbusGsetting(); // 初始化与任务栏gsetting和dbus
public slots:
void delayTimeout();
void delayTimeOutChecker();
bool eventFilter(QObject *, QEvent *); // 添加事件过滤器声明
private:
Ui::Form *ui;
void paintEvent(QPaintEvent *e);
@ -95,8 +96,9 @@ signals:
protected slots:
void agreeBtnClicked();
void disAgreeBtnClicked();
void comboBoxClicked(int);
void delayBtnClicked();
void onClick_close_btn();
};

View File

@ -2,91 +2,111 @@
<!DOCTYPE TS>
<TS version="2.1" language="bo_CN">
<context>
<name>updatewidget</name>
<name>Form</name>
<message>
<source>at</source>
<translation></translation>
</message>
<message>
<source>Delay</source>
<translation></translation>
</message>
<message>
<source>five hours later</source>
<translation>%d</translation>
</message>
<message>
<source>one hours later</source>
<translation></translation>
</message>
<message>
<source>three day later</source>
<translation></translation>
</message>
<message>
<source>In 30 minutes</source>
<translation></translation>
</message>
<message>
<source>Update</source>
<translation></translation>
</message>
<message>
<source>No reminders</source>
<translation></translation>
</message>
<message>
<source>five day later</source>
<translation></translation>
</message>
<message>
<source>one day later</source>
<translation></translation>
</message>
</context>
<context>
<name>updatehandle</name>
<message>
<source>update error</source>
<translation></translation>
</message>
<message>
<source>kylin-background-upgrade</source>
<translation></translation>
</message>
<message>
<source>The system is updating silently</source>
<translation></translation>
</message>
<message>
<source>update</source>
<translation></translation>
</message>
<message>
<source>The system has completed an important update. It is recommended that you restart immediately</source>
<translation> </translation>
</message>
<message>
<source>System update detected</source>
<translation></translation>
</message>
<message>
<source>The system has completed a critical update, and some software packages failed to update. It is recommended that you restart immediately</source>
<translation> </translation>
<location filename="../src/updatewidget.ui" line="16"/>
<source>Form</source>
<translation type="unfinished"></translation>
</message>
</context>
<context>
<name>trayicon</name>
<message>
<location filename="../src/trayicon.cpp" line="10"/>
<source>The system is updating silently</source>
<translation></translation>
<translation type="unfinished"></translation>
</message>
</context>
<context>
<name>updateTip</name>
<message>
<location filename="../src/updatewidget.cpp" line="548"/>
<source>The system is updating silently</source>
<translation></translation>
<translation type="unfinished"></translation>
</message>
</context>
<context>
<name>updatehandle</name>
<message>
<location filename="../src/updatehandle.cpp" line="116"/>
<location filename="../src/updatehandle.cpp" line="355"/>
<source>System update</source>
<translation type="unfinished"></translation>
</message>
<message>
<location filename="../src/updatehandle.cpp" line="319"/>
<location filename="../src/updatehandle.cpp" line="327"/>
<location filename="../src/updatehandle.cpp" line="333"/>
<source>The system is updating silently</source>
<translation type="unfinished"></translation>
</message>
<message>
<location filename="../src/updatehandle.cpp" line="511"/>
<source>The system has completed an important update, It is recommended that you restart immediately.</source>
<translation type="unfinished"></translation>
</message>
<message>
<location filename="../src/updatehandle.cpp" line="513"/>
<source>update error</source>
<translation type="unfinished"></translation>
</message>
<message>
<location filename="../src/updatehandle.cpp" line="589"/>
<source>kylin-background-upgrade</source>
<translation type="unfinished"></translation>
</message>
<message>
<location filename="../src/updatehandle.cpp" line="592"/>
<source>update</source>
<translation type="unfinished"></translation>
</message>
</context>
<context>
<name>updatewidget</name>
<message>
<location filename="../src/updatewidget.cpp" line="42"/>
<source> Updatable app detected on your system!</source>
<translation type="unfinished"> </translation>
</message>
<message>
<location filename="../src/updatewidget.cpp" line="51"/>
<source>Close</source>
<translation type="unfinished"></translation>
</message>
<message>
<location filename="../src/updatewidget.cpp" line="62"/>
<source>30 minutes later</source>
<translation type="unfinished">30</translation>
</message>
<message>
<location filename="../src/updatewidget.cpp" line="62"/>
<source>1 hour later</source>
<translation type="unfinished"></translation>
</message>
<message>
<location filename="../src/updatewidget.cpp" line="62"/>
<source>5 hours later</source>
<translation type="unfinished">5</translation>
</message>
<message>
<location filename="../src/updatewidget.cpp" line="62"/>
<source>1 day later</source>
<translation type="unfinished"></translation>
</message>
<message>
<location filename="../src/updatewidget.cpp" line="62"/>
<source>3 days later</source>
<translation type="unfinished"></translation>
</message>
<message>
<location filename="../src/updatewidget.cpp" line="69"/>
<source>Update</source>
<translation type="unfinished"></translation>
</message>
<message>
<location filename="../src/updatewidget.cpp" line="70"/>
<source>Delay</source>
<translation type="unfinished"></translation>
</message>
</context>
</TS>

View File

@ -27,7 +27,7 @@
<context>
<name>updateTip</name>
<message>
<location filename="../src/updatewidget.cpp" line="445"/>
<location filename="../src/updatewidget.cpp" line="548"/>
<source>The system is updating silently</source>
<translation></translation>
</message>
@ -39,9 +39,9 @@
<translation type="vanished"></translation>
</message>
<message>
<location filename="../src/updatehandle.cpp" line="298"/>
<location filename="../src/updatehandle.cpp" line="306"/>
<location filename="../src/updatehandle.cpp" line="312"/>
<location filename="../src/updatehandle.cpp" line="319"/>
<location filename="../src/updatehandle.cpp" line="327"/>
<location filename="../src/updatehandle.cpp" line="333"/>
<source>The system is updating silently</source>
<translation></translation>
</message>
@ -50,32 +50,36 @@
<translation type="vanished"></translation>
</message>
<message>
<location filename="../src/updatehandle.cpp" line="100"/>
<location filename="../src/updatehandle.cpp" line="334"/>
<source>System update detected</source>
<translation></translation>
<translation type="vanished"></translation>
</message>
<message>
<source>The system has completed a critical update, and some software packages failed to update. It is recommended that you restart immediately</source>
<translation type="obsolete"></translation>
</message>
<message>
<location filename="../src/updatehandle.cpp" line="471"/>
<location filename="../src/updatehandle.cpp" line="116"/>
<location filename="../src/updatehandle.cpp" line="355"/>
<source>System update</source>
<translation></translation>
</message>
<message>
<location filename="../src/updatehandle.cpp" line="511"/>
<source>The system has completed an important update, It is recommended that you restart immediately.</source>
<translation></translation>
</message>
<message>
<location filename="../src/updatehandle.cpp" line="473"/>
<location filename="../src/updatehandle.cpp" line="513"/>
<source>update error</source>
<translation></translation>
</message>
<message>
<location filename="../src/updatehandle.cpp" line="508"/>
<location filename="../src/updatehandle.cpp" line="589"/>
<source>kylin-background-upgrade</source>
<translation></translation>
</message>
<message>
<location filename="../src/updatehandle.cpp" line="511"/>
<location filename="../src/updatehandle.cpp" line="592"/>
<source>update</source>
<translation></translation>
</message>
@ -83,39 +87,65 @@
<context>
<name>updatewidget</name>
<message>
<location filename="../src/updatewidget.cpp" line="40"/>
<source>Please remind me later</source>
<translation type="vanished"></translation>
</message>
<message>
<source>at</source>
<translation></translation>
<translation type="vanished"></translation>
</message>
<message>
<source>No more reminders</source>
<translation type="vanished"></translation>
</message>
<message>
<source>No reminders</source>
<translation type="vanished"></translation>
</message>
<message>
<location filename="../src/updatewidget.cpp" line="42"/>
<source>No reminders</source>
<translation></translation>
<source> Updatable app detected on your system!</source>
<translation type="unfinished"> </translation>
</message>
<message>
<location filename="../src/updatewidget.cpp" line="53"/>
<source>In 30 minutes</source>
<translation></translation>
<location filename="../src/updatewidget.cpp" line="51"/>
<source>Close</source>
<translation type="unfinished"></translation>
</message>
<message>
<location filename="../src/updatewidget.cpp" line="53"/>
<source>three hours later</source>
<translation></translation>
<location filename="../src/updatewidget.cpp" line="62"/>
<source>30 minutes later</source>
<translation> 30 </translation>
</message>
<message>
<location filename="../src/updatewidget.cpp" line="60"/>
<location filename="../src/updatewidget.cpp" line="62"/>
<source>1 hour later</source>
<translation type="unfinished"> 1 </translation>
</message>
<message>
<location filename="../src/updatewidget.cpp" line="62"/>
<source>3 days later</source>
<translation type="unfinished"> 3 </translation>
</message>
<message>
<location filename="../src/updatewidget.cpp" line="70"/>
<source>Delay</source>
<translation type="unfinished"></translation>
</message>
<message>
<location filename="../src/updatewidget.cpp" line="62"/>
<source>5 hours later</source>
<translation> 5 </translation>
</message>
<message>
<location filename="../src/updatewidget.cpp" line="62"/>
<source>1 day later</source>
<translation> 1 </translation>
</message>
<message>
<location filename="../src/updatewidget.cpp" line="69"/>
<source>Update</source>
<translation></translation>
</message>
<message>
<location filename="../src/updatewidget.cpp" line="61"/>
<source>Delay</source>
<translation></translation>
</message>
<message>
<location filename="../src/updatewidget.cpp" line="53"/>
<source>one day later</source>
<translation></translation>
</message>
</context>
</TS>

View File

@ -0,0 +1,6 @@
SOURCES += \
$$PWD/fixbutton.cpp \
HEADERS += \
$$PWD/fixbutton.h \

View File

@ -0,0 +1,36 @@
#include "fixbutton.h"
#include <QFontMetrics>
#include <QDebug>
FixButton::FixButton(QWidget *parent):
QPushButton(parent)
{
}
FixButton::~FixButton()
{
}
void FixButton::paintEvent(QPaintEvent *event)
{
QFontMetrics fontMetrics(this->font());
int fontSize = fontMetrics.width(mStr);
int showTextSize = this->width() - 32;
if (fontSize > showTextSize) {
this->setText(fontMetrics.elidedText(mStr, Qt::ElideRight, showTextSize), false);
this->setToolTip(mStr);
} else {
this->setText(mStr, false);
this->setToolTip("");
}
QPushButton::paintEvent(event);
}
void FixButton::setText(const QString & text, bool saveTextFlag)
{
if (saveTextFlag)
mStr = text;
QPushButton::setText(text);
}

View File

@ -0,0 +1,21 @@
#ifndef _FIXBUTTON_H_
#define _FIXBUTTON_H_
#include <QPushButton>
class FixButton : public QPushButton
{
Q_OBJECT
public:
FixButton(QWidget *parent = nullptr);
~FixButton();
void setText(const QString &text, bool saveTextFlag = true);
private:
void paintEvent(QPaintEvent *event);
private:
QString mStr;
};
#endif

4
widgets/widgets.pri Normal file
View File

@ -0,0 +1,4 @@
INCLUDEPATH += $$PWD
include(Button/button.pri)
include(ComboBox/comboBox.pri)