version 2.0

This commit is contained in:
何承原 2023-12-11 10:38:27 +08:00
parent 0198c1051a
commit c9d6a8ba85
306 changed files with 23649 additions and 434 deletions

View File

@ -1,10 +1,8 @@
CC = g++
all: plugins notify
all: origin immutability
plugins:
cd plugin && qmake .
cd plugin && make -j8
notify:
cd notification && cmake .
cd notification && make -j8
origin:
cd initial && make -j4
immutability:
cd immutable && make -j4

16
immutable/Makefile Normal file
View File

@ -0,0 +1,16 @@
CC = g++
all: plugins notify newnotify send
plugins:
cd plugin && qmake .
cd plugin && make -j8
notify:
cd notification && cmake .
cd notification && make -j8
newnotify:
cd upgradenote/RebootAttention && qmake .
cd upgradenote/RebootAttention && make -j8
send:
cd NotifySend && qmake .
cd NotifySend && make -j8

View File

@ -0,0 +1,2 @@
#! /bin/bash
systemctl --user start kylin-stepinstall-notify.service

View File

@ -0,0 +1,3 @@
#! /bin/bash
NotifySend --PowercheckNotify
gdbus call --system --dest com.kylin.systemupgrade --object-path /com/kylin/systemupgrade --method com.kylin.systemupgrade.interface.TriggerInstallOnShutdown "reboot"

View File

@ -0,0 +1,8 @@
[Desktop Entry]
Name=kylin-reboot-installlnotify
X-UKUI-Autostart-Phase=Notification
Exec=/usr/bin/NotifySend --DesktopNotify
Type=Application
NoDisplay=true
Comment=kylin-DesktopNotify-notify
Name[zh_CN]=重启立即检测是否弹窗

View File

@ -0,0 +1,8 @@
[Desktop Entry]
Name=kylin-stepinstall-notify
X-UKUI-Autostart-Phase=Notification
Exec=/usr/bin/NotifySendStart
Type=Application
NoDisplay=true
Comment=kylin-stepinstall-notify
Name[zh_CN]=分步更新重启提示

View File

@ -0,0 +1,8 @@
[Unit]
Description=Daily update attention when user login
#ConditionACPower=true
After=systemd-user-sessions.service
[Service]
ExecStart=/usr/bin/NotifySend --WaitSignalNotify
[Install]
WantedBy=graphical-session.target

View File

@ -0,0 +1,52 @@
QT += core dbus gui widgets
#CONFIG += console
greaterThan(QT_MAJOR_VERSION, 4): QT += widgets
CONFIG += c++11
MOC_DIR = ./moctmp
UI_DIR = ./uitmp
RCC_DIR = ./rcctmp
OBJECTS_DIR = ./objtmp
!contains(QMAKE_HOST.arch, sw_64){
LIBS += -L$$[QT_INSTALL_LIBS] -lukui-log4qt
}
DEFINES+=WITHKYSEC KYDEBUG
#DEFINES+=WITHKYSEC KYDEBUG
# The following define makes your compiler emit warnings if you use
# any Qt feature that has been marked deprecated (the exact warnings
# depend on your compiler). Please consult the documentation of the
# deprecated API in order to know how to port your code away from it.
DEFINES += QT_DEPRECATED_WARNINGS
# You can also make your code fail to compile if it uses deprecated APIs.
# In order to do so, uncomment the following line.
# You can also select to disable deprecated APIs only up to a certain version of Qt.
#DEFINES += QT_DISABLE_DEPRECATED_BEFORE=0x060000 # disables all the APIs deprecated before Qt 6.0.0
SOURCES += \
checkpower.cpp \
desktopnotify.cpp \
main.cpp \
mainwindow.cpp \
rebootinstallnotify.cpp
HEADERS += \
checkpower.h \
desktopnotify.h \
mainwindow.h \
rebootinstallnotify.h
TRANSLATIONS += \
translations/zh_CN.ts \
translations/tr.ts \
translations/bo.ts \
translations/en_US.ts \
translations/bo_CN.ts \
translations/mn.ts
# Default rules for deployment.
qnx: target.path = /tmp/$${TARGET}/bin
else: unix:!android: target.path = /opt/$${TARGET}/bin
!isEmpty(target.path): INSTALLS += target

View File

@ -0,0 +1,314 @@
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE QtCreatorProject>
<!-- Written by QtCreator 4.11.0, 2023-12-01T13:49:25. -->
<qtcreator>
<data>
<variable>EnvironmentId</variable>
<value type="QByteArray">{e2626406-5b30-4653-bbdc-5f44d69e770a}</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">{3206ba71-3ff7-4f65-a816-e5c227657c1c}</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/hechengyuan/project/study/demo/NotifySend/build-NotifySend-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/hechengyuan/project/study/demo/NotifySend/build-NotifySend-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">true</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/hechengyuan/project/study/demo/NotifySend/build-NotifySend-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">true</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/hechengyuan/project/study/demo/NotifySend/NotifySend/NotifySend.pro</value>
<value type="QString" key="ProjectExplorer.RunConfiguration.BuildKey">/home/hechengyuan/project/study/demo/NotifySend/NotifySend/NotifySend.pro</value>
<value type="QString" key="RunConfiguration.Arguments"></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"></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

@ -0,0 +1,16 @@
#include "checkpower.h"
CheckPower::CheckPower()
{
QDBusInterface upgrade_interface( "com.kylin.systemupgrade",
"/com/kylin/systemupgrade",
"com.kylin.systemupgrade.interface",
QDBusConnection::systemBus() );
QDBusMessage rebootresult = upgrade_interface.call("DeployLatestUpdate","reboot");
int reboot =rebootresult.arguments().value(0).toInt();
QString reason = rebootresult.arguments().value(1).toString();
if(!reboot)
{
qInfo()<<"reboot success!";
}
}

View File

@ -0,0 +1,24 @@
#ifndef CHECKPOWER_H
#define CHECKPOWER_H
#include <QObject>
#include <QWidget>
#include <QDBusMessage>
#include <QtDBus/QtDBus>
#include <QSettings>
#include <QDBusInterface>
#include <QStandardPaths>
#include <QDir>
#include <QFile>
#include <QDebug>
#include <QObject>
#include <QTranslator>
#include <QMetaType>
class CheckPower: public QWidget
{
Q_OBJECT
public:
CheckPower();
};
#endif // CHECKPOWER_H

View File

@ -0,0 +1,226 @@
#include "desktopnotify.h"
DesktopNotify::DesktopNotify(QWidget *parent) : QWidget(parent)
{
version=getVersion();
QDBusInterface iface("com.kylin.systemupgrade",
"/com/kylin/systemupgrade",
"com.kylin.systemupgrade.interface",
QDBusConnection::systemBus());
QDBusMessage result = iface.call("CheckInstallRequired");
int reboot =result.arguments().value(0).toInt();
qInfo()<<"reboot result is"<<reboot;
if(reboot)
{
DesktopNotify::RebootNotify();
}
}
void DesktopNotify::RebootNotify()
{
qInfo()<<"[INFO]get signal UpdateDownloadFinished, come into DesktopNotify's RebootNotify";
QStringList actions;
actions.append("NotifySend --PowercheckNotify");
actions.append(QObject::tr("Reboot"));
actions.append("NotifySend --RebootInstallNotify");
actions.append(QObject::tr("Later"));
QDBusInterface iface("org.freedesktop.Notifications",
"/org/freedesktop/Notifications",
"org.freedesktop.Notifications",
QDBusConnection::sessionBus());
if(version.isEmpty())// == "2107"||version == "2203"||version == "2303"
{
qInfo()<<"DesktopNotify 2107";
QList<QVariant> args;
QVariantMap hints;
args<<(QObject::tr("System-Upgrade"))
<<((unsigned int) 0)
<<("ukui-control-center")
<<QObject::tr("Update download completed, do you want to restart the system?") //控制面板-更新提示
<<QObject::tr("After restarting, the new system will be used.") //显示的具体信息
<<actions
<<hints
<<(int)0;
QDBusMessage response = iface.callWithArgumentList(QDBus::AutoDetect,"Notify",args);
if (response.type() == QDBusMessage::ReplyMessage)
{ //判断method的返回值
qInfo() << "发送成功ID" << response.arguments().takeFirst().toString();
ID = response.arguments().takeFirst().toUInt(); //保存消息ID
qInfo()<<"消息ID "<<ID;
}
else
{
qInfo() << "发送失败:" << response.type();
}
}
else
{
qInfo()<<"DesktopNotify 2309";
QList<QVariant> args;
QVariantMap hints;
hints.insert("sound-name","Complete");
hints.insert("x-ukui-popup-timeout",-1);
args<<(QObject::tr("System-Upgrade"))
<<((unsigned int) 0)
<<("ukui-control-center")
<<QObject::tr("Update download completed, do you want to restart the system?") //控制面板-更新提示
<<QObject::tr("After restarting, the new system will be used.") //显示的具体信息
<<actions
<<hints
<<(int)0;
QDBusMessage response = iface.callWithArgumentList(QDBus::AutoDetect,"Notify",args);
qInfo()<<" 2309 buttonaction conenct"
<<QDBusConnection::sessionBus().connect("org.freedesktop.Notifications",
"/org/freedesktop/Notifications",
"org.freedesktop.Notifications",
"ActionInvoked",this,SLOT(ButtonAction_2309(uint,QString)));
if (response.type() == QDBusMessage::ReplyMessage)
{ //判断method的返回值
qInfo() << "发送成功ID" << response.arguments().takeFirst().toString();
ID = response.arguments().takeFirst().toUInt(); //保存消息ID
qInfo()<<"消息ID "<<ID;
}
else
{
qInfo() << "发送失败:" << response.type();
}
}
return ;
}
void DesktopNotify::ButtonAction_2309(uint id, QString key)
{
qInfo()<<"the id is" << id <<"and ID is "<<ID;
if(id == ID)
{
if(key=="NotifySend --PowercheckNotify")
{
qInfo()<<"立即重启";
QDBusInterface upgrade_interface( "com.kylin.systemupgrade",
"/com/kylin/systemupgrade",
"com.kylin.systemupgrade.interface",
QDBusConnection::systemBus() );
QDBusMessage rebootresult = upgrade_interface.call("DeployLatestUpdate","reboot");
int reboot =rebootresult.arguments().value(0).toInt();
QString reason = rebootresult.arguments().value(1).toString();
if(!reboot)
{
qInfo()<<"reboot success!";
}
QDBusConnection::sessionBus().disconnect("org.freedesktop.Notifications",
"/org/freedesktop/Notifications",
"org.freedesktop.Notifications",
"ActionInvoked",this,SLOT(ButtonAction_2309(uint,QString)));
return;
}
else if(key == "NotifySend --RebootInstallNotify")
{
qInfo()<<"稍后重启24小时提醒功能添加";
timer = new QTimer(this);
qInfo()<<connect(timer,&QTimer::timeout,this,&DesktopNotify::timenotification_2309);
QDBusConnection::sessionBus().disconnect("org.freedesktop.Notifications",
"/org/freedesktop/Notifications",
"org.freedesktop.Notifications",
"ActionInvoked",this,SLOT(ButtonAction_2309(uint,QString)));
timer->start(24*60*60*1000);
// timer->start(2*60*1000);
return;
}
}
}
void DesktopNotify::timenotification_2309()
{
timer->stop();
qInfo()<<"[INFO]timenotification_2309 timeout";
qInfo()<<"DesktopNotify timenotification_2309";
QStringList actions;
actions.append("NotifySend --PowercheckNotify");
actions.append(QObject::tr("Reboot"));
actions.append("NotifySend --RebootInstallNotify");
actions.append(QObject::tr("Later"));
QDBusInterface iface("org.freedesktop.Notifications",
"/org/freedesktop/Notifications",
"org.freedesktop.Notifications",
QDBusConnection::sessionBus());
QList<QVariant> args;
QVariantMap hints;
hints.insert("sound-name","Complete");
hints.insert("x-ukui-popup-timeout",-1);
args<<(QObject::tr("System-Upgrade"))
<<((unsigned int) 0)
<<("ukui-control-center")
<<QObject::tr("Update download completed, do you want to restart the system?") //控制面板-更新提示
<<QObject::tr("After restarting, the new system will be used.") //显示的具体信息
<<actions
<<hints
<<(int)0;
QDBusMessage response = iface.callWithArgumentList(QDBus::AutoDetect,"Notify",args);
qInfo() <<QDBusConnection::sessionBus().connect("org.freedesktop.Notifications",
"/org/freedesktop/Notifications",
"org.freedesktop.Notifications",
"ActionInvoked",this,SLOT(ButtonAction_2309(uint,QString)));
if (response.type() == QDBusMessage::ReplyMessage)
{ //判断method的返回值
qInfo() << "发送成功ID" << response.arguments().takeFirst().toString();
ID = response.arguments().takeFirst().toUInt(); //保存消息ID
qInfo()<<"消息ID "<<ID;
}
else
{
qInfo() << "发送失败:" << response.type();
}
return ;
}
QString DesktopNotify::getVersion()
{
// QFile file("/etc/os-release");
// if (!file.open(QIODevice::ReadOnly | QIODevice::Text))
// {
// // 文件无法打开,处理错误
// return version_t;
// }
// // 使用 QTextStream 读取文件内容
// QTextStream in(&file);
// while (!in.atEnd())
// {
// QString line = in.readLine();
// if(line.contains("KYLIN_RELEASE_ID"))
// {
// QStringList versionlist = line.split("=");
// QString version1 = versionlist.at(1);
// QString version2 = version1.remove(QChar('"'));
//// qDebug()<<"version2 is "<<version2;
// version_t = version2;
// }
//// qDebug() << line; // 将每一行的内容打印出来
// }
// // 关闭文件
// file.close();
// return version_t;
QDBusInterface iface("org.freedesktop.Notifications",
"/org/freedesktop/Notifications",
"org.freedesktop.Notifications",
QDBusConnection::sessionBus());
QDBusMessage result = iface.call("GetServerInformation");
if (!result.errorMessage().isEmpty())
{
qInfo() << "DBus调用失败" << result.errorMessage();
return version_t;
}
else
{
qInfo() << "DBus调用成功";
version_t = result.arguments().value(2).toString();
qInfo()<< version_t;
return version_t;
}
}
DesktopNotify::~DesktopNotify()
{
}

View File

@ -0,0 +1,38 @@
#ifndef DESKTOPNOTIFY_H
#define DESKTOPNOTIFY_H
#include <QObject>
#include <QWidget>
#include <QDBusMessage>
#include <QtDBus/QtDBus>
#include <QSettings>
#include <QDBusInterface>
#include <QStandardPaths>
#include <QDir>
#include <QFile>
#include <QDebug>
#include <QObject>
#include <QTranslator>
#include <QMetaType>
class DesktopNotify : public QWidget
{
Q_OBJECT
public:
explicit DesktopNotify(QWidget *parent = nullptr);
~DesktopNotify();
int ID=0;
QTimer *timer;
QString getVersion();
QString version_t = "";
QString version;
signals:
public Q_SLOTS:
void RebootNotify();
public slots:
void ButtonAction_2309(uint id, QString key);
void timenotification_2309();
};
#endif // DESKTOPNOTIFY_H

View File

@ -0,0 +1,6 @@
#include "getversion.h"
GetVersion::GetVersion()
{
}

View File

@ -0,0 +1,13 @@
#ifndef GETVERSION_H
#define GETVERSION_H
#include <QObject>
class GetVersion
{
Q_OBJECT
public:
GetVersion();
};
#endif // GETVERSION_H

View File

@ -0,0 +1,103 @@
#include "mainwindow.h"
#include "rebootinstallnotify.h"
#include "desktopnotify.h"
#include "checkpower.h"
#include <QApplication>
#include <QCommandLineOption>
#include <QCommandLineParser>
#include <QDebug>
#include <QTranslator>
#include <qlogging.h>
#include <sys/types.h>
#include <stdio.h>
#include <unistd.h>
#ifdef KYDEBUG
#ifndef __sw_64__
#include <ukui-log4qt.h>
#endif
#endif
int main(int argc, char *argv[])
{
setenv("QT_DEBUG_PLUGINS", "1", 0);
QApplication a(argc, argv);
/*mainwindows为service弹窗
desktopnotify为desktop弹窗
*/
#ifdef KYDEBUG
#ifndef __sw_64__
initUkuiLog4qt("kylin-update-frontend-notifysend");
#endif
#endif
/*以后需要写配置文件,通过标志位判断某个弹窗是否弹窗*/
/*此部分为demo
QCommandLineOption op1("a");// 短名称,无参数
QCommandLineOption op2("BBB");// 长名称,无参数
QCommandLineOption op3(QStringList() << "c" << "CCC");// 多个名称,无参数
QCommandLineOption op4("D", "", "Name");// 短名称,有参数,无默认值
QCommandLineOption op5("Age", "", "", "18");// 长名称,有参数,有默认值
QCommandLineOption op6("m", "", "."); // 短名称,有参数,无默认值
QCommandLineParser parser;
parser.addOption(op1);
parser.addOption(op2);
parser.addOption(op3);
parser.addOption(op4);
parser.addOption(op5);
parser.addOption(op6);
parser.process(a);
qInfo() << parser.isSet(op1); // true
qInfo() << parser.isSet("BBB"); // true
qInfo() << parser.isSet("CCC"); // true
qInfo() << parser.value(op4); // "Jack"
qInfo() << parser.value(op5); // "18"
qInfo() << parser.values(op6);// ("Hello", "World")
qInfo() << parser.helpText();
*/
QTranslator translator ;
qInfo()<<"the system.name is "<<QLocale::system().name();
translator.load("/usr/share/upgradenotifysend/translations/" + QLocale::system().name() +".qm");
a.installTranslator(&translator);
QCommandLineParser parser;
QCommandLineOption waitsignalnotify("WaitSignalNotify");
QCommandLineOption rebootinstallnotify("RebootInstallNotify");
QCommandLineOption desktopnotify("DesktopNotify");
QCommandLineOption powerchecknotify("PowercheckNotify");
parser.addOption(waitsignalnotify);
parser.addOption(rebootinstallnotify);
parser.addOption(desktopnotify);
parser.addOption(powerchecknotify);
parser.process(a);
qInfo() << parser.isSet(waitsignalnotify);
qInfo() << parser.isSet(rebootinstallnotify); // true
qInfo() << parser.isSet(desktopnotify);
qInfo() << parser.isSet(powerchecknotify);
qInfo() << parser.helpText();
/*分步更新的稍后提醒功能*/
if(parser.isSet(rebootinstallnotify))
{/*24小时等待*/
qInfo()<<"[INFO]get in rebootinstallnotify";
RebootInstallNotify *Rebootinstallnotify = new RebootInstallNotify();
}
if(parser.isSet(desktopnotify))
{/*开机自启检测是否需要重启*/
qInfo()<<"[INFO]get in desktopnotify";
DesktopNotify *Desktopnotify = new DesktopNotify();
}
if(parser.isSet(powerchecknotify))
{/*电量检测*/
qInfo()<<"[INFO]get in powerchecknotify";
CheckPower *Powerchecknotify = new CheckPower();
}
if(parser.isSet(waitsignalnotify))
{/*接受信号弹窗*/
qInfo()<<"[INFO] get in MainWindow";
MainWindow *w = new MainWindow();
}
// w.show();
return a.exec();
}

View File

@ -0,0 +1,324 @@
#include "mainwindow.h"
MainWindow::MainWindow(QWidget *parent)
: QMainWindow(parent)
{
/*分步更新的下载完成弹窗功能*/
QDBusConnection::systemBus().connect("com.kylin.systemupgrade",
"/com/kylin/systemupgrade",
"com.kylin.systemupgrade.interface",
"UpdateDownloadFinished",this,SLOT(RebootNotify(bool)));
QDBusConnection::systemBus().connect("com.kylin.systemupgrade",
"/com/kylin/systemupgrade",
"com.kylin.systemupgrade.interface",
"ErrorFeedbackBeforeInstallation",this,SLOT(RebootResult(bool,QString,QString)));
version=getVersion();
}
void MainWindow::RebootNotify(bool success)
{
qInfo()<<"[INFO]get signal UpdateDownloadFinished, come into Mainwindow's RebootNotify";
qInfo()<<"the bool is "<<success;
qInfo()<<version;
if(success)
{
QStringList actions;
actions.append("NotifySend --PowercheckNotify");
actions.append(QObject::tr("Reboot"));
actions.append("NotifySend --RebootInstallNotify");
actions.append(QObject::tr("Later"));
QDBusInterface iface("org.freedesktop.Notifications",
"/org/freedesktop/Notifications",
"org.freedesktop.Notifications",
QDBusConnection::sessionBus());
if(version.isEmpty())
{
qInfo()<<"mainwindow 2107 reboot notification";
QList<QVariant> args;
QVariantMap hints;
args<<(QObject::tr("System-Upgrade"))
<<((unsigned int) 0)
<<("ukui-control-center")
<<QObject::tr("Update download completed, do you want to restart the system?") //控制面板-更新提示
<<QObject::tr("After restarting, the new system will be used.") //显示的具体信息
<<actions
<<hints
<<(int)0;
QDBusMessage response = iface.callWithArgumentList(QDBus::AutoDetect,"Notify",args);
if (response.type() == QDBusMessage::ReplyMessage)
{ //判断method的返回值
qInfo() << "发送成功ID" << response.arguments().takeFirst().toString();
ID = response.arguments().takeFirst().toUInt(); //保存消息ID
qInfo()<<"消息ID "<<ID;
}
else
{
qInfo() << "发送失败:" << response.type();
}
}
else/*2309+*/
{
qInfo()<<"mainwindow 2309 reboot notification";
QList<QVariant> args;
QVariantMap hints;
hints.insert("sound-name","Complete");
hints.insert("x-ukui-popup-timeout",-1);
args<<(QObject::tr("System-Upgrade"))
<<((unsigned int) 0)
<<("ukui-control-center")
<<QObject::tr("Update download completed, do you want to restart the system?") //控制面板-更新提示
<<QObject::tr("After restarting, the new system will be used.") //显示的具体信息
<<actions
<<hints
<<(int)0;
QDBusMessage response = iface.callWithArgumentList(QDBus::AutoDetect,"Notify",args);
qInfo()<<" 2309 buttonaction conenct"
<<QDBusConnection::sessionBus().connect("org.freedesktop.Notifications",
"/org/freedesktop/Notifications",
"org.freedesktop.Notifications",
"ActionInvoked",this,SLOT(ButtonAction_2309(uint,QString)));
if (response.type() == QDBusMessage::ReplyMessage)
{ //判断method的返回值
qInfo() << "发送成功ID" << response.arguments().takeFirst().toString();
ID = response.arguments().takeFirst().toUInt(); //保存消息ID
qInfo()<<"消息ID "<<ID;
}
else
{
qInfo() << "发送失败:" << response.type();
}
}
return ;
}
}
void MainWindow::ButtonAction_2309(uint id, QString key)
{
qInfo()<<"the id is" << id <<"and ID is "<<ID;
if(id == ID)
{
if(key=="NotifySend --PowercheckNotify")
{
qInfo()<<"立即重启";
QDBusInterface upgrade_interface( "com.kylin.systemupgrade",
"/com/kylin/systemupgrade",
"com.kylin.systemupgrade.interface",
QDBusConnection::systemBus() );
QDBusMessage rebootresult = upgrade_interface.call("DeployLatestUpdate","reboot");
int reboot =rebootresult.arguments().value(0).toInt();
QString reason = rebootresult.arguments().value(1).toString();
if(!reboot)
{
qInfo()<<"reboot success!";
}
QDBusConnection::sessionBus().disconnect("org.freedesktop.Notifications",
"/org/freedesktop/Notifications",
"org.freedesktop.Notifications",
"ActionInvoked",this,SLOT(ButtonAction_2309(uint,QString)));
return;
}
else if(key == "NotifySend --RebootInstallNotify")
{
qInfo()<<"稍后重启24小时提醒功能添加";
timer = new QTimer(this);
qInfo()<<connect(timer,&QTimer::timeout,this,&MainWindow::timenotification_2309);
QDBusConnection::sessionBus().disconnect("org.freedesktop.Notifications",
"/org/freedesktop/Notifications",
"org.freedesktop.Notifications",
"ActionInvoked",this,SLOT(ButtonAction_2309(uint,QString)));
timer->start(24*60*60*1000);
// timer->start(2*60*1000);
return;
}
}
}
void MainWindow::RebootResult(bool success,QString error_code, QString reason)
{
if(!success)
{
if(error_code == "#0208")
{
QDBusInterface iface("org.freedesktop.Notifications",
"/org/freedesktop/Notifications",
"org.freedesktop.Notifications",
QDBusConnection::sessionBus());
QList<QVariant> args;
args<<(QObject::tr("System-Upgrade"))
<<((unsigned int) 0)
<<("ukui-control-center")
<<QObject::tr("Low battery level, system update terminated") //控制面板-更新提示
<<QObject::tr("System updates are carried out when the battery level is not less than 50%.") //显示的具体信息
<<QStringList()
<<QVariantMap()
<<(int)0;
QDBusMessage response = iface.callWithArgumentList(QDBus::AutoDetect,"Notify",args);
if (response.type() == QDBusMessage::ReplyMessage)
{ //判断method的返回值
qInfo() << "发送成功ID" << response.arguments().takeFirst().toString();
int ID = response.arguments().takeFirst().toUInt(); //保存消息ID
qInfo()<<"消息ID "<<ID;
}
else
{
qInfo() << "发送失败:" << response.type();
}
return ;
}
else if(error_code == "#0204")
{
QDBusInterface iface("org.freedesktop.Notifications",
"/org/freedesktop/Notifications",
"org.freedesktop.Notifications",
QDBusConnection::sessionBus());
QList<QVariant> args;
args<<(QObject::tr("System-Upgrade"))
<<((unsigned int) 0)
<<("ukui-control-center")
<<QObject::tr("The system disk space is insufficient to complete the update.") //控制面板-更新提示
<<""
<<QStringList()
<<QVariantMap()
<<(int)0;
QDBusMessage response = iface.callWithArgumentList(QDBus::AutoDetect,"Notify",args);
if (response.type() == QDBusMessage::ReplyMessage)
{ //判断method的返回值
qInfo() << "发送成功ID" << response.arguments().takeFirst().toString();
int ID = response.arguments().takeFirst().toUInt(); //保存消息ID
qInfo()<<"消息ID "<<ID;
}
else
{
qInfo() << "发送失败:" << response.type();
}
return ;
}
else
{
QDBusInterface iface("org.freedesktop.Notifications",
"/org/freedesktop/Notifications",
"org.freedesktop.Notifications",
QDBusConnection::sessionBus());
QList<QVariant> args;
args<<(QObject::tr("System-Upgrade"))
<<((unsigned int) 0)
<<("ukui-control-center")
<<QObject::tr("Reboot failed.") //控制面板-更新提示
<<""
<<QStringList()
<<QVariantMap()
<<(int)0;
QDBusMessage response = iface.callWithArgumentList(QDBus::AutoDetect,"Notify",args);
if (response.type() == QDBusMessage::ReplyMessage)
{ //判断method的返回值
qInfo() << "发送成功ID" << response.arguments().takeFirst().toString();
int ID = response.arguments().takeFirst().toUInt(); //保存消息ID
qInfo()<<"消息ID "<<ID;
}
else
{
qInfo() << "发送失败:" << response.type();
}
return ;
}
}
}
void MainWindow::timenotification_2309()
{
timer->stop();
qInfo()<<"[INFO]timenotification timeout";
qInfo()<<"mainwindow timenotification_2309";
QStringList actions;
actions.append("NotifySend --PowercheckNotify");
actions.append(QObject::tr("Reboot"));
actions.append("NotifySend --RebootInstallNotify");
actions.append(QObject::tr("Later"));
QDBusInterface iface("org.freedesktop.Notifications",
"/org/freedesktop/Notifications",
"org.freedesktop.Notifications",
QDBusConnection::sessionBus());
QList<QVariant> args;
QVariantMap hints;
hints.insert("sound-name","Complete");
hints.insert("x-ukui-popup-timeout",-1);
args<<(QObject::tr("System-Upgrade"))
<<((unsigned int) 0)
<<("ukui-control-center")
<<QObject::tr("Update download completed, do you want to restart the system?") //控制面板-更新提示
<<QObject::tr("After restarting, the new system will be used.") //显示的具体信息
<<actions
<<hints
<<(int)0;
QDBusMessage response = iface.callWithArgumentList(QDBus::AutoDetect,"Notify",args);
qInfo() <<QDBusConnection::sessionBus().connect("org.freedesktop.Notifications",
"/org/freedesktop/Notifications",
"org.freedesktop.Notifications",
"ActionInvoked",this,SLOT(ButtonAction_2309(uint,QString)));
if (response.type() == QDBusMessage::ReplyMessage)
{ //判断method的返回值
qInfo() << "发送成功ID" << response.arguments().takeFirst().toString();
ID = response.arguments().takeFirst().toUInt(); //保存消息ID
qInfo()<<"消息ID "<<ID;
}
else
{
qInfo() << "发送失败:" << response.type();
}
return ;
}
QString MainWindow::getVersion()
{
// QFile file("/etc/os-release");
// if (!file.open(QIODevice::ReadOnly | QIODevice::Text))
// {
// // 文件无法打开,处理错误
// return version_t;
// }
// // 使用 QTextStream 读取文件内容
// QTextStream in(&file);
// while (!in.atEnd())
// {
// QString line = in.readLine();
// if(line.contains("KYLIN_RELEASE_ID"))
// {
// QStringList versionlist = line.split("=");
// QString version1 = versionlist.at(1);
// QString version2 = version1.remove(QChar('"'));
//// qDebug()<<"version2 is "<<version2;
// version_t = version2;
// qDebug()<<"version is "<<version_t;
// }
//// qDebug() << line; // 将每一行的内容打印出来
// }
// // 关闭文件
// file.close();
// return version_t;
QDBusInterface iface("org.freedesktop.Notifications",
"/org/freedesktop/Notifications",
"org.freedesktop.Notifications",
QDBusConnection::sessionBus());
QDBusMessage result = iface.call("GetServerInformation");
if (!result.errorMessage().isEmpty())
{
qInfo() << "DBus调用失败" << result.errorMessage();
return version_t;
}
else
{
qInfo() << "DBus调用成功";
version_t = result.arguments().value(2).toString();
qInfo()<< version_t;
return version_t;
}
}
MainWindow::~MainWindow()
{
}

View File

@ -0,0 +1,37 @@
#ifndef MAINWINDOW_H
#define MAINWINDOW_H
#include <QMainWindow>
#include <QDBusMessage>
#include <QtDBus/QtDBus>
#include <QSettings>
#include <QDBusInterface>
#include <QStandardPaths>
#include <QDir>
#include <QFile>
#include <QDebug>
#include <QObject>
#include <QTranslator>
#include <QMetaType>
#include <QTimer>
class MainWindow : public QMainWindow
{
Q_OBJECT
public:
MainWindow(QWidget *parent = nullptr);
~MainWindow();
int ID=0;
QTimer *timer;
QString getVersion();
QString version_t = "";
QString version;
public Q_SLOTS:
void RebootNotify(bool success);
void RebootResult(bool success,QString error_code,QString reason);
public slots:
void ButtonAction_2309(uint id, QString key);
void timenotification_2309();
};
#endif // MAINWINDOW_H

View File

@ -0,0 +1,95 @@
#include "rebootinstallnotify.h"
/*2309以下版本使用(不含)*/
RebootInstallNotify::RebootInstallNotify(QWidget *parent) : QWidget(parent)
{
qInfo()<<"[INFO]get in RebootInstallNotify";
timer = new QTimer(this);
timer1 = new QTimer(this);
// timer->setInterval(10);
qInfo()<<connect(timer,&QTimer::timeout,this,&RebootInstallNotify::timenotification_2107);
connect(timer1,&QTimer::timeout,this,&RebootInstallNotify::hourdebug);
qInfo()<<"[INFO]finish dbus connection";
timer->start(24*60*60*1000);
// timer->start(2*60*1000);
timer1->start(60*60*1000);
}
void RebootInstallNotify::timenotification_2107()
{
timer->stop();
qInfo()<<"[INFO]timenotification_2107 timeout";
qInfo()<<"RebootInstallNotify timenotification_2107";
QStringList actions;
actions.append("NotifySend --PowercheckNotify");
actions.append(QObject::tr("Reboot"));
actions.append("NotifySend --RebootInstallNotify");
actions.append(QObject::tr("Later"));
QDBusInterface iface("org.freedesktop.Notifications",
"/org/freedesktop/Notifications",
"org.freedesktop.Notifications",
QDBusConnection::sessionBus());
QList<QVariant> args;
QVariantMap hints;
args<<(QObject::tr("System-Upgrade"))
<<((unsigned int) 0)
<<("ukui-control-center")
<<QObject::tr("Update download completed, do you want to restart the system?") //控制面板-更新提示
<<QObject::tr("After restarting, the new system will be used.") //显示的具体信息
<<actions
<<hints
<<(int)0;
QDBusMessage response = iface.callWithArgumentList(QDBus::AutoDetect,"Notify",args);
if (response.type() == QDBusMessage::ReplyMessage)
{ //判断method的返回值
qInfo() << "发送成功ID" << response.arguments().takeFirst().toString();
ID = response.arguments().takeFirst().toUInt(); //保存消息ID
qInfo()<<"消息ID "<<ID;
}
else
{
qInfo() << "发送失败:" << response.type();
}
return ;
}
void RebootInstallNotify::ButtonAction(int id, QString key)
{
if(id == ID)
{
if(key=="NotifySend --PowercheckNotify")
{
QDBusInterface upgrade_interface( "com.kylin.systemupgrade",
"/com/kylin/systemupgrade",
"com.kylin.systemupgrade.interface",
QDBusConnection::systemBus() );
QDBusMessage rebootresult = upgrade_interface.call("DeployLatestUpdate","reboot");
int reboot =rebootresult.arguments().value(0).toInt();
QString reason = rebootresult.arguments().value(1).toString();
if(!reboot)
{
qInfo()<<"reboot success!";
}
QDBusConnection::systemBus().disconnect("org.freedesktop.Notifications",
"/org/freedesktop/Notifications",
"org.freedesktop.Notifications",
"ActionInvoked",this,SLOT(ButtonAction(int,QString)));
return;
}
else
{
QDBusConnection::systemBus().disconnect("org.freedesktop.Notifications",
"/org/freedesktop/Notifications",
"org.freedesktop.Notifications",
"ActionInvoked",this,SLOT(ButtonAction(int,QString)));
return;
}
}
}
void RebootInstallNotify::hourdebug()
{
qInfo()<<"hourdebug";
timer1->stop();
timer1->start(60*60*1000);
}

View File

@ -0,0 +1,35 @@
#ifndef REBOOTINSTALLNOTIFY_H
#define REBOOTINSTALLNOTIFY_H
#include <QObject>
#include <QWidget>
#include <QDBusMessage>
#include <QtDBus/QtDBus>
#include <QTime>
#include <QSettings>
#include <QStandardPaths>
#include <QDir>
#include <QFile>
#include <QDebug>
#include <QObject>
#include <QTranslator>
#include <QDBusInterface>
#include <QTimer>
#include <QMetaType>
class RebootInstallNotify : public QWidget
{
Q_OBJECT
public:
explicit RebootInstallNotify(QWidget *parent = nullptr);
QTimer *timer;
QTimer *timer1;
int ID = 0;
public slots:
void timenotification_2107();
void hourdebug();
void ButtonAction(int id ,QString key);
signals:
};
#endif // REBOOTINSTALLNOTIFY_H

View File

@ -0,0 +1,75 @@
<?xml version="1.0" encoding="utf-8"?>
<!DOCTYPE TS>
<TS version="2.1">
<context>
<name>QObject</name>
<message>
<location filename="../desktopnotify.cpp" line="23"/>
<location filename="../mainwindow.cpp" line="25"/>
<location filename="../mainwindow.cpp" line="197"/>
<location filename="../rebootinstallnotify.cpp" line="21"/>
<source>Reboot</source>
<translation type="unfinished"></translation>
</message>
<message>
<location filename="../desktopnotify.cpp" line="25"/>
<location filename="../mainwindow.cpp" line="27"/>
<location filename="../mainwindow.cpp" line="199"/>
<location filename="../rebootinstallnotify.cpp" line="23"/>
<source>Later</source>
<translation type="unfinished"></translation>
</message>
<message>
<location filename="../desktopnotify.cpp" line="33"/>
<location filename="../mainwindow.cpp" line="35"/>
<location filename="../mainwindow.cpp" line="112"/>
<location filename="../mainwindow.cpp" line="140"/>
<location filename="../mainwindow.cpp" line="168"/>
<location filename="../mainwindow.cpp" line="207"/>
<location filename="../rebootinstallnotify.cpp" line="31"/>
<source>System-Upgrade</source>
<translation type="unfinished"></translation>
</message>
<message>
<location filename="../desktopnotify.cpp" line="37"/>
<location filename="../mainwindow.cpp" line="39"/>
<location filename="../mainwindow.cpp" line="211"/>
<location filename="../rebootinstallnotify.cpp" line="35"/>
<source>After restarting, the new system will be used.</source>
<translation type="unfinished"></translation>
</message>
<message>
<location filename="../mainwindow.cpp" line="115"/>
<source>Low battery level, system update terminated</source>
<translation type="unfinished"></translation>
</message>
<message>
<location filename="../mainwindow.cpp" line="116"/>
<source>System updates are carried out when the battery level is not less than 50%.</source>
<translation type="unfinished"></translation>
</message>
<message>
<location filename="../mainwindow.cpp" line="143"/>
<source>The system disk space is insufficient to complete the update.</source>
<translation type="unfinished"></translation>
</message>
<message>
<location filename="../mainwindow.cpp" line="171"/>
<source>ukui-control-center-upgrade</source>
<translation type="unfinished"></translation>
</message>
<message>
<location filename="../desktopnotify.cpp" line="36"/>
<location filename="../mainwindow.cpp" line="38"/>
<location filename="../mainwindow.cpp" line="210"/>
<location filename="../rebootinstallnotify.cpp" line="34"/>
<source>Update download completed, do you want to restart the system?</source>
<translation type="unfinished"></translation>
</message>
<message>
<location filename="../mainwindow.cpp" line="172"/>
<source>Reboot failed.</source>
<translation type="unfinished"></translation>
</message>
</context>
</TS>

Binary file not shown.

View File

@ -0,0 +1,87 @@
<?xml version="1.0" encoding="utf-8"?>
<!DOCTYPE TS>
<TS version="2.1" language="bo_CN">
<context>
<name>QObject</name>
<message>
<location filename="../desktopnotify.cpp" line="23"/>
<location filename="../mainwindow.cpp" line="25"/>
<location filename="../mainwindow.cpp" line="197"/>
<location filename="../rebootinstallnotify.cpp" line="21"/>
<source>Reboot</source>
<translation></translation>
</message>
<message>
<location filename="../desktopnotify.cpp" line="25"/>
<location filename="../mainwindow.cpp" line="27"/>
<location filename="../mainwindow.cpp" line="199"/>
<location filename="../rebootinstallnotify.cpp" line="23"/>
<source>Later</source>
<translation></translation>
</message>
<message>
<location filename="../desktopnotify.cpp" line="33"/>
<location filename="../mainwindow.cpp" line="35"/>
<location filename="../mainwindow.cpp" line="112"/>
<location filename="../mainwindow.cpp" line="140"/>
<location filename="../mainwindow.cpp" line="168"/>
<location filename="../mainwindow.cpp" line="207"/>
<location filename="../rebootinstallnotify.cpp" line="31"/>
<source>System-Upgrade</source>
<translation></translation>
</message>
<message>
<location filename="../desktopnotify.cpp" line="37"/>
<location filename="../mainwindow.cpp" line="39"/>
<location filename="../mainwindow.cpp" line="211"/>
<location filename="../rebootinstallnotify.cpp" line="35"/>
<source>After restarting, the new system will be used.</source>
<translation type="unfinished"></translation>
</message>
<message>
<location filename="../mainwindow.cpp" line="115"/>
<source>Low battery level, system update terminated</source>
<translation type="unfinished"></translation>
</message>
<message>
<location filename="../mainwindow.cpp" line="116"/>
<source>System updates are carried out when the battery level is not less than 50%.</source>
<translation type="unfinished"></translation>
</message>
<message>
<location filename="../mainwindow.cpp" line="143"/>
<source>The system disk space is insufficient to complete the update.</source>
<translation type="unfinished"></translation>
</message>
<message>
<location filename="../mainwindow.cpp" line="171"/>
<source>ukui-control-center-upgrade</source>
<translation>ukui-control-center-update</translation>
</message>
<message>
<location filename="../desktopnotify.cpp" line="36"/>
<location filename="../mainwindow.cpp" line="38"/>
<location filename="../mainwindow.cpp" line="210"/>
<location filename="../rebootinstallnotify.cpp" line="34"/>
<source>Update download completed, do you want to restart the system?</source>
<translation type="unfinished"></translation>
</message>
<message>
<source>Reboot failed because battery power is lower than 50%.</source>
<translation type="vanished"></translation>
</message>
<message>
<source>Backup room is poor.</source>
<translation type="vanished"></translation>
</message>
<message>
<location filename="../mainwindow.cpp" line="172"/>
<source>Reboot failed.</source>
<translation></translation>
</message>
<message>
<source>It&apos;s suggested to reboot.</source>
<translation type="vanished"></translation>
</message>
</context>
</TS>

View File

@ -0,0 +1,75 @@
<?xml version="1.0" encoding="utf-8"?>
<!DOCTYPE TS>
<TS version="2.1">
<context>
<name>QObject</name>
<message>
<location filename="../desktopnotify.cpp" line="23"/>
<location filename="../mainwindow.cpp" line="25"/>
<location filename="../mainwindow.cpp" line="197"/>
<location filename="../rebootinstallnotify.cpp" line="21"/>
<source>Reboot</source>
<translation type="unfinished"></translation>
</message>
<message>
<location filename="../desktopnotify.cpp" line="25"/>
<location filename="../mainwindow.cpp" line="27"/>
<location filename="../mainwindow.cpp" line="199"/>
<location filename="../rebootinstallnotify.cpp" line="23"/>
<source>Later</source>
<translation type="unfinished"></translation>
</message>
<message>
<location filename="../desktopnotify.cpp" line="33"/>
<location filename="../mainwindow.cpp" line="35"/>
<location filename="../mainwindow.cpp" line="112"/>
<location filename="../mainwindow.cpp" line="140"/>
<location filename="../mainwindow.cpp" line="168"/>
<location filename="../mainwindow.cpp" line="207"/>
<location filename="../rebootinstallnotify.cpp" line="31"/>
<source>System-Upgrade</source>
<translation type="unfinished"></translation>
</message>
<message>
<location filename="../desktopnotify.cpp" line="37"/>
<location filename="../mainwindow.cpp" line="39"/>
<location filename="../mainwindow.cpp" line="211"/>
<location filename="../rebootinstallnotify.cpp" line="35"/>
<source>After restarting, the new system will be used.</source>
<translation type="unfinished"></translation>
</message>
<message>
<location filename="../mainwindow.cpp" line="115"/>
<source>Low battery level, system update terminated</source>
<translation type="unfinished"></translation>
</message>
<message>
<location filename="../mainwindow.cpp" line="116"/>
<source>System updates are carried out when the battery level is not less than 50%.</source>
<translation type="unfinished"></translation>
</message>
<message>
<location filename="../mainwindow.cpp" line="143"/>
<source>The system disk space is insufficient to complete the update.</source>
<translation type="unfinished"></translation>
</message>
<message>
<location filename="../mainwindow.cpp" line="171"/>
<source>ukui-control-center-upgrade</source>
<translation type="unfinished"></translation>
</message>
<message>
<location filename="../desktopnotify.cpp" line="36"/>
<location filename="../mainwindow.cpp" line="38"/>
<location filename="../mainwindow.cpp" line="210"/>
<location filename="../rebootinstallnotify.cpp" line="34"/>
<source>Update download completed, do you want to restart the system?</source>
<translation type="unfinished"></translation>
</message>
<message>
<location filename="../mainwindow.cpp" line="172"/>
<source>Reboot failed.</source>
<translation type="unfinished"></translation>
</message>
</context>
</TS>

View File

@ -0,0 +1,87 @@
<?xml version="1.0" encoding="utf-8"?>
<!DOCTYPE TS>
<TS version="2.1" language="mn">
<context>
<name>QObject</name>
<message>
<location filename="../desktopnotify.cpp" line="23"/>
<location filename="../mainwindow.cpp" line="25"/>
<location filename="../mainwindow.cpp" line="197"/>
<location filename="../rebootinstallnotify.cpp" line="21"/>
<source>Reboot</source>
<translation> </translation>
</message>
<message>
<location filename="../desktopnotify.cpp" line="25"/>
<location filename="../mainwindow.cpp" line="27"/>
<location filename="../mainwindow.cpp" line="199"/>
<location filename="../rebootinstallnotify.cpp" line="23"/>
<source>Later</source>
<translation> </translation>
</message>
<message>
<location filename="../desktopnotify.cpp" line="33"/>
<location filename="../mainwindow.cpp" line="35"/>
<location filename="../mainwindow.cpp" line="112"/>
<location filename="../mainwindow.cpp" line="140"/>
<location filename="../mainwindow.cpp" line="168"/>
<location filename="../mainwindow.cpp" line="207"/>
<location filename="../rebootinstallnotify.cpp" line="31"/>
<source>System-Upgrade</source>
<translation> </translation>
</message>
<message>
<location filename="../desktopnotify.cpp" line="37"/>
<location filename="../mainwindow.cpp" line="39"/>
<location filename="../mainwindow.cpp" line="211"/>
<location filename="../rebootinstallnotify.cpp" line="35"/>
<source>After restarting, the new system will be used.</source>
<translation type="unfinished"></translation>
</message>
<message>
<location filename="../mainwindow.cpp" line="115"/>
<source>Low battery level, system update terminated</source>
<translation type="unfinished"></translation>
</message>
<message>
<location filename="../mainwindow.cpp" line="116"/>
<source>System updates are carried out when the battery level is not less than 50%.</source>
<translation type="unfinished"></translation>
</message>
<message>
<location filename="../mainwindow.cpp" line="143"/>
<source>The system disk space is insufficient to complete the update.</source>
<translation type="unfinished"></translation>
</message>
<message>
<location filename="../mainwindow.cpp" line="171"/>
<source>ukui-control-center-upgrade</source>
<translation>- </translation>
</message>
<message>
<location filename="../desktopnotify.cpp" line="36"/>
<location filename="../mainwindow.cpp" line="38"/>
<location filename="../mainwindow.cpp" line="210"/>
<location filename="../rebootinstallnotify.cpp" line="34"/>
<source>Update download completed, do you want to restart the system?</source>
<translation type="unfinished"></translation>
</message>
<message>
<source>Reboot failed because battery power is lower than 50%.</source>
<translation type="vanished"> </translation>
</message>
<message>
<source>Backup room is poor.</source>
<translation type="vanished"> </translation>
</message>
<message>
<location filename="../mainwindow.cpp" line="172"/>
<source>Reboot failed.</source>
<translation> </translation>
</message>
<message>
<source>It&apos;s suggested to reboot.</source>
<translation type="vanished"> </translation>
</message>
</context>
</TS>

View File

@ -0,0 +1,75 @@
<?xml version="1.0" encoding="utf-8"?>
<!DOCTYPE TS>
<TS version="2.1">
<context>
<name>QObject</name>
<message>
<location filename="../desktopnotify.cpp" line="23"/>
<location filename="../mainwindow.cpp" line="25"/>
<location filename="../mainwindow.cpp" line="197"/>
<location filename="../rebootinstallnotify.cpp" line="21"/>
<source>Reboot</source>
<translation type="unfinished"></translation>
</message>
<message>
<location filename="../desktopnotify.cpp" line="25"/>
<location filename="../mainwindow.cpp" line="27"/>
<location filename="../mainwindow.cpp" line="199"/>
<location filename="../rebootinstallnotify.cpp" line="23"/>
<source>Later</source>
<translation type="unfinished"></translation>
</message>
<message>
<location filename="../desktopnotify.cpp" line="33"/>
<location filename="../mainwindow.cpp" line="35"/>
<location filename="../mainwindow.cpp" line="112"/>
<location filename="../mainwindow.cpp" line="140"/>
<location filename="../mainwindow.cpp" line="168"/>
<location filename="../mainwindow.cpp" line="207"/>
<location filename="../rebootinstallnotify.cpp" line="31"/>
<source>System-Upgrade</source>
<translation type="unfinished"></translation>
</message>
<message>
<location filename="../desktopnotify.cpp" line="37"/>
<location filename="../mainwindow.cpp" line="39"/>
<location filename="../mainwindow.cpp" line="211"/>
<location filename="../rebootinstallnotify.cpp" line="35"/>
<source>After restarting, the new system will be used.</source>
<translation type="unfinished"></translation>
</message>
<message>
<location filename="../mainwindow.cpp" line="115"/>
<source>Low battery level, system update terminated</source>
<translation type="unfinished"></translation>
</message>
<message>
<location filename="../mainwindow.cpp" line="116"/>
<source>System updates are carried out when the battery level is not less than 50%.</source>
<translation type="unfinished"></translation>
</message>
<message>
<location filename="../mainwindow.cpp" line="143"/>
<source>The system disk space is insufficient to complete the update.</source>
<translation type="unfinished"></translation>
</message>
<message>
<location filename="../mainwindow.cpp" line="171"/>
<source>ukui-control-center-upgrade</source>
<translation type="unfinished"></translation>
</message>
<message>
<location filename="../desktopnotify.cpp" line="36"/>
<location filename="../mainwindow.cpp" line="38"/>
<location filename="../mainwindow.cpp" line="210"/>
<location filename="../rebootinstallnotify.cpp" line="34"/>
<source>Update download completed, do you want to restart the system?</source>
<translation type="unfinished"></translation>
</message>
<message>
<location filename="../mainwindow.cpp" line="172"/>
<source>Reboot failed.</source>
<translation type="unfinished"></translation>
</message>
</context>
</TS>

Binary file not shown.

View File

@ -0,0 +1,87 @@
<?xml version="1.0" encoding="utf-8"?>
<!DOCTYPE TS>
<TS version="2.1" language="zh_CN">
<context>
<name>QObject</name>
<message>
<location filename="../desktopnotify.cpp" line="23"/>
<location filename="../mainwindow.cpp" line="25"/>
<location filename="../mainwindow.cpp" line="197"/>
<location filename="../rebootinstallnotify.cpp" line="21"/>
<source>Reboot</source>
<translation></translation>
</message>
<message>
<location filename="../desktopnotify.cpp" line="25"/>
<location filename="../mainwindow.cpp" line="27"/>
<location filename="../mainwindow.cpp" line="199"/>
<location filename="../rebootinstallnotify.cpp" line="23"/>
<source>Later</source>
<translation></translation>
</message>
<message>
<location filename="../desktopnotify.cpp" line="33"/>
<location filename="../mainwindow.cpp" line="35"/>
<location filename="../mainwindow.cpp" line="112"/>
<location filename="../mainwindow.cpp" line="140"/>
<location filename="../mainwindow.cpp" line="168"/>
<location filename="../mainwindow.cpp" line="207"/>
<location filename="../rebootinstallnotify.cpp" line="31"/>
<source>System-Upgrade</source>
<translation></translation>
</message>
<message>
<location filename="../desktopnotify.cpp" line="37"/>
<location filename="../mainwindow.cpp" line="39"/>
<location filename="../mainwindow.cpp" line="211"/>
<location filename="../rebootinstallnotify.cpp" line="35"/>
<source>After restarting, the new system will be used.</source>
<translation>使</translation>
</message>
<message>
<location filename="../mainwindow.cpp" line="115"/>
<source>Low battery level, system update terminated</source>
<translation></translation>
</message>
<message>
<location filename="../mainwindow.cpp" line="116"/>
<source>System updates are carried out when the battery level is not less than 50%.</source>
<translation>50%</translation>
</message>
<message>
<location filename="../mainwindow.cpp" line="143"/>
<source>The system disk space is insufficient to complete the update.</source>
<translation></translation>
</message>
<message>
<location filename="../mainwindow.cpp" line="171"/>
<source>ukui-control-center-upgrade</source>
<translation>-</translation>
</message>
<message>
<location filename="../desktopnotify.cpp" line="36"/>
<location filename="../mainwindow.cpp" line="38"/>
<location filename="../mainwindow.cpp" line="210"/>
<location filename="../rebootinstallnotify.cpp" line="34"/>
<source>Update download completed, do you want to restart the system?</source>
<translation>,</translation>
</message>
<message>
<source>Reboot failed because battery power is lower than 50%.</source>
<translation type="vanished">50%</translation>
</message>
<message>
<source>Backup room is poor.</source>
<translation type="vanished"></translation>
</message>
<message>
<location filename="../mainwindow.cpp" line="172"/>
<source>Reboot failed.</source>
<translation></translation>
</message>
<message>
<source>It&apos;s suggested to reboot.</source>
<translation type="vanished"></translation>
</message>
</context>
</TS>

View File

@ -0,0 +1,52 @@
#!/usr/bin/python3
import os
import sys
import apt_pkg
import apt
def ReadOsReleaseFile():
file = ''
os_release_info={}
try:
if os.path.exists('/etc/os-release'):
file = '/etc/os-release'
elif os.path.exists('/usr/lib/os-release'):
file = '/usr/lib/os-release'
else:
return os_release_info
with open(file) as f:
lines = f.readlines()
for line in lines:
ls = line.strip().split('=',1)
os_release_info.update({ls[0]:ls[1].strip('\"').strip()})
except Exception:
pass
return os_release_info
def get_package_version(packagename):
cache = apt.Cache()
if packagename in cache:
pkg = cache[packagename]
return pkg.installed.version
else:
return ''
def compare_package_version(v1,v2):
return apt_pkg.version_compare(v1,v2)
if __name__ == "__main__":
os_release_info = ReadOsReleaseFile()
kylin_release_id = ''
ret = 0
try:
if 'KYLIN_RELEASE_ID' in os_release_info:
kylin_release_id = os_release_info['KYLIN_RELEASE_ID']
ukui_control_center_version = get_package_version('ukui-control-center')
res = compare_package_version(ukui_control_center_version,sys.argv[1])#'3.1.1+2022-0324'
if kylin_release_id in ["2203","2209"] or res >= 0:
ret = 1
else:
pass
except Exception as e:
print(e)
print(ret)

View File

@ -0,0 +1,56 @@
# CMake
cmake_minimum_required (VERSION 2.8)
#
project (kylin-update-notify)
#
find_package(PkgConfig)
#
pkg_check_modules(GLib REQUIRED glib-2.0)
if(GLib_FOUND)
include_directories(${GLib_INCLUDE_DIRS})
link_libraries(${GLib_LIBRARIES})
endif(GLib_FOUND)
pkg_check_modules(DBus REQUIRED dbus-1)
if(DBus_FOUND)
include_directories(${DBus_INCLUDE_DIRS})
link_libraries(${DBus_LIBRARIES})
endif(DBus_FOUND)
pkg_check_modules(GObject REQUIRED gobject-2.0)
if(GObject_FOUND)
include_directories(${GObject_INCLUDE_DIRS})
link_libraries(${GObject_LIBRARIES})
endif(GObject_FOUND)
pkg_check_modules(Libnotify REQUIRED libnotify)
if(Libnotify_FOUND)
include_directories(${Libnotify_INCLUDE_DIRS})
link_libraries(${Libnotify_LIBRARIES})
endif(Libnotify_FOUND)
aux_source_directory(./src SRC_MAIN)
aux_source_directory(./kylin-updateresult-notify/src SRC_MAIN1)
add_definitions("-Wall -g")
#
add_executable(kylin-updatefinish-notify-new ${SRC_MAIN})
add_executable(kylin-updateresult-notify-new ${SRC_MAIN1})
#
target_link_libraries(kylin-updatefinish-notify-new libglib-2.0.so libnotify.so libgobject-2.0.so)
target_link_libraries(kylin-updateresult-notify-new libglib-2.0.so libnotify.so libgobject-2.0.so)
#
set_target_properties(
kylin-updatefinish-notify-new
PROPERTIES
RUNTIME_OUTPUT_DIRECTORY "${CMAKE_BINARY_DIR}/../"
)
set_target_properties(
kylin-updateresult-notify-new
PROPERTIES
RUNTIME_OUTPUT_DIRECTORY "${CMAKE_BINARY_DIR}/../"
)

View File

@ -0,0 +1,8 @@
[Desktop Entry]
Name=kylin-updatefinish-notify-new
Exec=/usr/bin/kylin-updatefinish-notify-new
Type=Application
NoDisplay=true
Comment=kylin-updatefinish-notify
Name[zh_CN]=更新重启提示
Name[bo_CN]=གསར་བརྗེ་བསྐྱར་དུ་བྱེད་མགོ་བཙུགས་སྣེ་སྟོན།

View File

@ -0,0 +1,8 @@
[Desktop Entry]
Name=kylin-updateresult-notify
Exec=kylin-updateresult-notify-new
Type=Application
X-UKUI-Autostart-Phase=Notification
NoDisplay=true
Comment=kylin-updateresult-notify
Name[zh_CN]=更新结果提示

Binary file not shown.

View File

@ -0,0 +1,8 @@
{
"files.associations": {
"notify.h": "c",
"notify-enum-types.h": "c",
"dbus.h": "c",
"system_error": "c"
}
}

View File

@ -0,0 +1,105 @@
#include <stdio.h>
#include <unistd.h>
// #include <string.h>
// #include <stdbool.h>
// #include <dbus-1.0/dbus/dbus.h>
// #include <stdlib.h>
// #include <sys/types.h>
#include "notifications.h"
#include <glib.h>
#include <gio/gio.h>
int main(void)
{
FILE *fp;
if( (fp=fopen("/tmp/kylin-updateresult-notify.log","a+")) == NULL )
{
fprintf(fp,"Fail to open file!\n");
return -2;
}
fprintf (fp,"prepare to popup notification in 50s\n");
sleep(50);
// DBusConnection *connection;
// DBusError error;
// DBusMessage *message;
// DBusMessageIter iter;
// DBusPendingCall *call;
// char *sigvalue;
// dbus_error_init(&error);
GDBusProxy *login_proxy = NULL;
GVariant *listsession_var = NULL;
GError *error = NULL;
login_proxy = g_dbus_proxy_new_for_bus_sync(G_BUS_TYPE_SYSTEM,
G_DBUS_PROXY_FLAGS_NONE,
NULL,
"com.kylin.systemupgrade",
"/com/kylin/systemupgrade",
"com.kylin.systemupgrade.interface",
NULL,
&error);
if (error != NULL) {
fprintf(fp,"error!\n");
g_error_free(error);
notifications("error");
return 1;
}
error = NULL;
listsession_var = g_dbus_proxy_call_sync (login_proxy,
"CheckPopupOnPoweroffInstalled",
NULL,
G_DBUS_CALL_FLAGS_NONE,
-1,
NULL,
&error);
if (listsession_var == NULL) {
g_object_unref(login_proxy);
fprintf(fp,"error2!\n");
notifications("error");
return 1;
}
// GVariantIter *iter;
// g_variant_get(listsession_var, "(a(susso))", &iter);
// gchar *sessionId, *userName, *seatId;
// guint32 userId;
// GObject *objectPath;
gchar* content;
gboolean type = TRUE;
content = g_variant_print(listsession_var,type);
fprintf (fp,"the type is %d\n", type);
fprintf (fp,"the content is %s\n", content);
//gboolean result;
gchar* result;
// result = g_variant_get_boolean(listsession_var);
// while (g_variant_iter_loop (iter, "(susso)", &sessionId, &userId, &userName, &seatId, &objectPath))
// {
// printf ("the result is %d\n", g_variant_get_boolean(listsession_var));
g_variant_get(listsession_var, "(s)", &result);
// g_variant_iter_loop (iter, "(b)", result);
fprintf (fp,"the result is %s\n", result);
// }
// while (g_variant_iter_loop (iter, "b", &result))
// {
// qCritical() << sessionId << userName << seatId << userId;
// }
g_object_unref(login_proxy);
//g_variant_iter_free (iter);
g_variant_unref(listsession_var);
if(strcmp(result,"success") == 0)
notifications("success");
else if(strcmp(result,"none") == 0)
return 0;
else
notifications(result);
fflush(fp);
fclose(fp);
return 0;
}

View File

@ -0,0 +1,46 @@
# SOME DESCRIPTIVE TITLE.
# Copyright (C) YEAR THE PACKAGE'S COPYRIGHT HOLDER
# This file is distributed under the same license as the PACKAGE package.
# FIRST AUTHOR <EMAIL@ADDRESS>, YEAR.
#
#, fuzzy
msgid ""
msgstr ""
"Project-Id-Version: PACKAGE VERSION\n"
"Report-Msgid-Bugs-To: \n"
"POT-Creation-Date: 2023-07-31 09:33+0800\n"
"PO-Revision-Date: YEAR-MO-DA HO:MI+ZONE\n"
"Last-Translator: FULL NAME <EMAIL@ADDRESS>\n"
"Language-Team: LANGUAGE <LL@li.org>\n"
"Language: zh_CN\n"
"MIME-Version: 1.0\n"
"Content-Type: text/plain; charset=UTF-8\n"
"Content-Transfer-Encoding: 8bit\n"
#: notifications.c:17
msgid "System Update"
msgstr "系统更新"
#: notifications.c:25
msgid "Download finish, do you want to reboot?"
msgstr "更新下载完成,是否重启系统?"
#: notifications.c:26
msgid "The system will use the new system after restarting."
msgstr "系统将在重启后使用更新应用。"
#: notifications.c:29 notifications.c:39 notifications.c:50 notifications.c:63
msgid "OK"
msgstr "确定"
#: notifications.c:36
msgid "Update Failed!"
msgstr "更新失败!"
#: notifications.c:47
msgid "The backend is abnormal,please check for updates on settings."
msgstr "后台程序异常,请手动打开更新-设置查找问题"
#: notifications.c:55
msgid "upgrade fail! Error code("
msgstr "更新失败!错误码("

View File

@ -0,0 +1,42 @@
# SOME DESCRIPTIVE TITLE.
# Copyright (C) YEAR THE PACKAGE'S COPYRIGHT HOLDER
# This file is distributed under the same license as the PACKAGE package.
# FIRST AUTHOR <EMAIL@ADDRESS>, YEAR.
#
#, fuzzy
msgid ""
msgstr ""
"Project-Id-Version: PACKAGE VERSION\n"
"Report-Msgid-Bugs-To: \n"
"POT-Creation-Date: 2023-07-31 09:49+0800\n"
"PO-Revision-Date: YEAR-MO-DA HO:MI+ZONE\n"
"Last-Translator: FULL NAME <EMAIL@ADDRESS>\n"
"Language-Team: LANGUAGE <LL@li.org>\n"
"Language:zh_CN \n"
"MIME-Version: 1.0\n"
"Content-Type: text/plain; charset=UTF-8\n"
"Content-Transfer-Encoding: 8bit\n"
#: notifications.c:17
msgid "System Update"
msgstr "系统更新"
#: notifications.c:28
msgid "Update Success!"
msgstr "更新成功!"
#: notifications.c:31 notifications.c:41 notifications.c:52 notifications.c:65
msgid "OK"
msgstr "确定"
#: notifications.c:38
msgid "Update Failed!"
msgstr "更新失败!"
#: notifications.c:49
msgid "The backend is abnormal,please check for updates on settings."
msgstr "后台程序异常,请手动检查更新确定升级是否成功。"
#: notifications.c:57
msgid "upgrade fail! Error code("
msgstr "更新失败!错误码("

View File

@ -0,0 +1,104 @@
#include "notifications.h"
int notifications (char *sigvalue)
{
FILE *fp;
if( (fp=fopen("/tmp/kylin-updateresult-notify.log","a+")) == NULL )
{
fprintf(fp,"Fail to open file!\n");
return -2;
}
setlocale(LC_ALL, "");
bindtextdomain("kylin-updateresult-notify","/usr/share/locale");
textdomain("kylin-updateresult-notify");
NotifyNotification* notification;
gboolean success;
GError* error = NULL;
if (!notify_init (gettext("System Update")))
{
fprintf(fp,"notify_init failed!\n");
return 1;
}
if(strcmp(sigvalue,"success") == 0){
fprintf(fp,"upgrade success!\n");
notification = notify_notification_new (
// gettext("Download finish, do you want to reboot?"),
// gettext("The system will use the new system after restarting."),
NULL,
gettext("Update Success!"),
"/usr/share/icons/ukui-icon-theme-default/16x16/apps/ukui-control-center.png");
notify_notification_set_timeout(notification, 0);
notify_notification_add_action(notification, "OK", gettext("OK"),
(NotifyActionCallback)actionClose ,NULL, NULL);
notify_notification_set_hint_int32(notification,"x-ukui-popup-timeout",-1);
}
else if(strcmp(sigvalue,"failed") == 0){
fprintf(fp,"upgrade fail!\n");
notification = notify_notification_new (
NULL,
gettext("Update Failed!"),
"/usr/share/icons/ukui-icon-theme-default/16x16/apps/ukui-control-center.png");
notify_notification_set_timeout(notification, 0);
notify_notification_add_action(notification, "OK", gettext("OK"),
(NotifyActionCallback)actionClose ,NULL, NULL);
notify_notification_set_hint_int32(notification,"x-ukui-popup-timeout",-1);
}
else if(strcmp(sigvalue,"error") == 0){
fprintf(fp,"upgrade error!\n");
notification = notify_notification_new (
//gettext("System Update"),
NULL,
gettext("The backend is abnormal,please check for updates on settings."),
"/usr/share/icons/ukui-icon-theme-default/16x16/apps/ukui-control-center.png");
notify_notification_set_timeout(notification, 0);
notify_notification_add_action(notification, "OK", gettext("OK"),
(NotifyActionCallback)actionClose ,NULL, NULL);
}
else{
fprintf(fp,"upgrade fail!\n");
char str[50];
memset(str,0,sizeof(str));
char *str1 = gettext("upgrade fail! Error code(");
fprintf(fp,"error code is %s\n",sigvalue);
strcat(str,str1);
strcat(str,sigvalue);
strcat(str,")");
notification = notify_notification_new (
NULL,
gettext(str),
"/usr/share/icons/ukui-icon-theme-default/16x16/apps/ukui-control-center.png");
notify_notification_set_timeout(notification, 0);
notify_notification_add_action(notification, "OK", gettext("OK"),
(NotifyActionCallback)actionClose ,NULL, NULL);
notify_notification_set_hint_int32(notification,"x-ukui-popup-timeout",-1);
}
error = NULL;
success = notify_notification_show (notification, &error);
if (!success){
//g_print ("That did not work ... \"%s\".\n", error->message);
fprintf (fp,"That did not work ... \"%s\".\n", error->message);
g_error_free (error);
}
g_signal_connect (G_OBJECT (notification),
"closed",
G_CALLBACK (closed_handler),
NULL);
mainloop=g_main_loop_new(NULL, false);
g_main_loop_run(mainloop);
notify_uninit ();
return 0;
}
void closed_handler(NotifyNotification* notification, gpointer data){
notify_uninit ();
g_print ("closed_handler() called\n");
g_main_loop_quit(mainloop);
return;
}
void actionClose(NotifyNotification* notification,char *action, gpointer data){
g_print("Closed\n");
g_print ("dbus_method_called to change the sigvalue");
return;
}

View File

@ -0,0 +1,26 @@
#include <string.h>
#include <stdbool.h>
#include <dbus/dbus.h>
#include <stdlib.h>
#include <sys/types.h>
#include <stdio.h>
#include <unistd.h>
#include <glib-2.0/glib.h>
#include <libnotify/notification.h>
#include <libnotify/notify.h>
#include <libnotify/notify-enum-types.h>
#include <libnotify/notify-features.h>
#include <dbus/dbus.h>
#include <dbus/dbus-glib-lowlevel.h> //for mainloop
#include <error.h>
#include <stdlib.h>
#include <stdbool.h>
#include <libintl.h>//gettext
#include <locale.h>
#include <stdint.h>
#define false 0
int notifications(char *sigvalue);
void closed_handler(NotifyNotification* notification,gpointer data);
void actionClose(NotifyNotification* notification,char *action, gpointer data);
GMainLoop* mainloop;

View File

@ -0,0 +1 @@
gcc `pkg-config --cflags --libs dbus-1` main.c -o main -ldbus-1

View File

@ -0,0 +1,174 @@
#include <stdio.h>
#include <unistd.h>
#include <glib-2.0/glib.h>
#include <libnotify/notification.h>
#include <libnotify/notify.h>
#include <libnotify/notify-enum-types.h>
#include <libnotify/notify-features.h>
#include <dbus/dbus.h>
#include <dbus/dbus-glib-lowlevel.h> //for mainloop
#include <error.h>
#include <stdlib.h>
#include <stdbool.h>
#include <libintl.h>//gettext
#include <locale.h>
#include <stdint.h>
#define false 0
//#define _(string) gettext(string)
void closed_handler(NotifyNotification* notification,gpointer data);
void actionClose(NotifyNotification* notification,char *action, gpointer data);
void actionReboot(NotifyNotification* notification,char *action, gpointer data);
void actionLogout(NotifyNotification* notification,char *action, gpointer data);
GMainLoop* mainloop;
int notifications (char *sigvalue)
{
setlocale(LC_ALL, "");//yuyanshezhi
bindtextdomain("kylin-system-updater-notify","/usr/share/locale");
textdomain("kylin-system-updater-notify");
NotifyNotification* notification;
gboolean success;
GError* error = NULL;
printf("2\n");
if (!notify_init (gettext("Update Finished!")))//zhuti
return 1;
// /* try the icon-summary-body case */
// notification = notify_notification_new (
// gettext("Update Finished!"),//biaoti
// gettext("It's suggested to reboot immediately."),//neirong
// "");//icon
// notify_notification_set_timeout(notification, 10*1000);//shijian yijing bei xiesi
if(strcmp(sigvalue,"reboot") == 0)
{
printf("It should reboot\n");
/* try the icon-summary-body case */
notification = notify_notification_new (
gettext("Update Finished!"),//biaoti
gettext("It's suggested to reboot immediately."),//neirong
"/usr/share/icons/ukui-icon-theme-default/16x16/apps/ukui-control-center.png");//icon
notify_notification_set_timeout(notification, 0);//shijian yijing bei xiesi
notify_notification_add_action(notification, "Reboot", gettext("Reboot") , (NotifyActionCallback)actionReboot , NULL, NULL);
notify_notification_add_action(notification, "Closed", gettext("Closed"), (NotifyActionCallback)actionClose , NULL, NULL);
notify_notification_set_hint_string(notification,"Reboot","reboot");
//notify_notification_set_hint(notification,"","");
}
if(strcmp(sigvalue,"logout") == 0)
{
/* try the icon-summary-body case */
notification = notify_notification_new (
gettext("Update Finished!"),//title
gettext("It's suggested to logout immediately."),//content
"");//icon
notify_notification_set_timeout(notification, 0);//shijian yijing bei xiesi
notify_notification_add_action(notification, "Logout", gettext("Logout") , (NotifyActionCallback)actionLogout , NULL, NULL);
notify_notification_add_action(notification, "Closed", gettext("Closed"), (NotifyActionCallback)actionClose , NULL, NULL);
notify_notification_set_hint_string(notification,"Logout","logout");
//notify_notification_set_hint(notification,"","");
}
error = NULL;
success = notify_notification_show (notification, &error);
if (!success)
{
g_print ("That did not work ... \"%s\".\n", error->message);
g_error_free (error);
}
g_signal_connect (G_OBJECT (notification),
"closed",
G_CALLBACK (closed_handler),
NULL);
mainloop=g_main_loop_new(NULL, false);
g_main_loop_run(mainloop);
notify_uninit ();
return 0;
}
void closed_handler(NotifyNotification* notification, gpointer data)
{ notify_uninit ();
g_print ("closed_handler() called\n");
g_main_loop_quit(mainloop);
return;
}
void actionClose(NotifyNotification* notification,char *action, gpointer data)
{
g_print("Closed\n");
return;
}
void actionReboot(NotifyNotification* notification,char *action, gpointer data)
{
g_print ("get signal to reboot\n");
system("ukui-session-tools --reboot");
return;
// g_print("Reboot\n");
// //dbus_reboot_method_call();
// DBusConnection *connection;
// DBusMessage *message;
// DBusError err ;
// DBusMessageIter iter;
// dbus_bool_t reboot=false;//dbus 内部bool型
// dbus_error_init(&err);
// connection = dbus_bus_get(DBUS_BUS_SYSTEM, &err);
// if(!connection)
// {
// fprintf(stderr, "Fail to get a system dbus connection: %s\n", err.message);
// exit(1);
// }
// message = dbus_message_new_method_call("org.freedesktop.login1",
// "/org/freedesktop/login1", //object
// "org.freedesktop.login1.Manager",//interface
// "Reboot");//method name
// if (NULL == message)
// {
// fprintf(stderr, "Message Null\n");
// exit(1);
// }
// dbus_message_iter_init_append(message, &iter);
// if( !dbus_message_iter_append_basic(&iter, DBUS_TYPE_BOOLEAN, &reboot))
// {
// fprintf(stderr, "Out of Memory!\n");
// exit(1);
// }
// dbus_connection_send(connection,message,NULL);
// dbus_connection_flush(connection);
// dbus_message_unref(message);
// return;
}
void actionLogout(NotifyNotification* notification,char *action, gpointer data)
{
g_print("Logout\n");
system("ukui-session-tools --logout");
return;
}

View File

Before

Width:  |  Height:  |  Size: 399 B

After

Width:  |  Height:  |  Size: 399 B

View File

Before

Width:  |  Height:  |  Size: 20 KiB

After

Width:  |  Height:  |  Size: 20 KiB

View File

Before

Width:  |  Height:  |  Size: 310 B

After

Width:  |  Height:  |  Size: 310 B

View File

@ -0,0 +1 @@
<クd<>箆!ソ`。スン

View File

@ -0,0 +1,28 @@
<RCC>
<qresource prefix="/img">
<file>upgrade/kylin-update-desktop-app.png</file>
<file>upgrade/kylin-update-desktop-kernel-3a4000.png</file>
<file>upgrade/kylin-update-desktop-kernel.png</file>
<file>upgrade/kylin-update-desktop-security.png</file>
<file>upgrade/kylin-update-desktop-support.png</file>
<file>upgrade/kylin-update-desktop-ukui.png</file>
<file>upgrade/linux-generic.png</file>
<file>upgrade/loading10.svg</file>
<file>upgrade/loading11.svg</file>
<file>upgrade/loading12.svg</file>
<file>upgrade/loading13.svg</file>
<file>upgrade/loading14.svg</file>
<file>upgrade/loading15.svg</file>
<file>upgrade/loading16.svg</file>
<file>upgrade/loading17.svg</file>
<file>upgrade/normal.png</file>
<file>upgrade/refresh.png</file>
<file>upgrade/update.png</file>
<file>upgrade/no_content_light.svg</file>
<file>upgrade/no_content_dark.svg</file>
</qresource>
<qresource prefix="/">
<file>upgrade/no_content_light.svg</file>
<file>upgrade/no_content_dark.svg</file>
</qresource>
</RCC>

View File

Before

Width:  |  Height:  |  Size: 871 B

After

Width:  |  Height:  |  Size: 871 B

View File

Before

Width:  |  Height:  |  Size: 1.2 KiB

After

Width:  |  Height:  |  Size: 1.2 KiB

View File

Before

Width:  |  Height:  |  Size: 1.2 KiB

After

Width:  |  Height:  |  Size: 1.2 KiB

View File

Before

Width:  |  Height:  |  Size: 1.2 KiB

After

Width:  |  Height:  |  Size: 1.2 KiB

View File

Before

Width:  |  Height:  |  Size: 1.0 KiB

After

Width:  |  Height:  |  Size: 1.0 KiB

View File

Before

Width:  |  Height:  |  Size: 481 B

After

Width:  |  Height:  |  Size: 481 B

View File

Before

Width:  |  Height:  |  Size: 1.2 KiB

After

Width:  |  Height:  |  Size: 1.2 KiB

View File

Before

Width:  |  Height:  |  Size: 1.0 KiB

After

Width:  |  Height:  |  Size: 1.0 KiB

View File

Before

Width:  |  Height:  |  Size: 1.0 KiB

After

Width:  |  Height:  |  Size: 1.0 KiB

View File

Before

Width:  |  Height:  |  Size: 1002 B

After

Width:  |  Height:  |  Size: 1002 B

View File

Before

Width:  |  Height:  |  Size: 943 B

After

Width:  |  Height:  |  Size: 943 B

View File

Before

Width:  |  Height:  |  Size: 1.0 KiB

After

Width:  |  Height:  |  Size: 1.0 KiB

View File

Before

Width:  |  Height:  |  Size: 1.0 KiB

After

Width:  |  Height:  |  Size: 1.0 KiB

View File

Before

Width:  |  Height:  |  Size: 1.0 KiB

After

Width:  |  Height:  |  Size: 1.0 KiB

View File

Before

Width:  |  Height:  |  Size: 1.1 KiB

After

Width:  |  Height:  |  Size: 1.1 KiB

View File

@ -0,0 +1,22 @@
<?xml version="1.0" encoding="UTF-8"?>
<svg width="128px" height="128px" viewBox="0 0 128 128" version="1.1" xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink">
<title>灰色/通用/无数据-深色模式@3x</title>
<g id="页面-1" stroke="none" stroke-width="1" fill="none" fill-rule="evenodd" opacity="0.8">
<g id="灰色占位图-深色" transform="translate(-1662.000000, -1927.000000)">
<g id="灰色/通用/无数据-深色模式" transform="translate(1662.000000, 1927.000000)">
<rect id="矩形" fill-opacity="0" fill="#FFFFFF" x="0" y="0" width="128" height="128"></rect>
<g id="empty" transform="translate(18.000000, 6.000000)" fill="#D4E8FF" fill-rule="nonzero">
<g id="空">
<path d="M13.333,68.168 L13.333,79 L0.333333333,79 L13.333,68.168 Z M77.333,67.336 L91.3333333,79 L77.333,79 L77.333,67.336 Z" id="形状结合" fill-opacity="0.2"></path>
<path d="M74.3333333,29 C74.8531244,28.9990692 75.7115407,29.2647114 76.3333333,30 C76.977622,30.2120727 77.3333333,30.8549176 77.3333333,32 L77.3333243,78.9999976 L69.0011522,79 C66.6351815,79 64.9519462,80.9583755 64.854979,83.1965034 L64.8505589,83.4006936 C64.8505589,85.7413887 62.8627552,87.5133066 60.4235318,87.5133066 L31.2431351,87.5133066 C28.7763739,87.4925611 26.7945193,85.726434 26.8161081,83.4268142 L26.8161081,83.3963401 C26.8161081,81.0716076 24.8500971,79 22.4124303,79 L13.3333243,78.9999976 L13.3333333,32 C13.3312647,30.8601686 13.6856303,30.2161728 14.3333333,30 C14.9508089,29.2664102 15.8096089,29 16.3333333,29 L74.3333333,29 Z M66.4640112,73 L24.2026555,73 C23.1617125,73.0309949 22.3333333,73.9172832 22.3333333,75 C22.3333333,76.0827168 23.1617125,76.9690051 24.2026555,77 L66.4640112,77 C67.5049542,76.9690051 68.3333333,76.0827168 68.3333333,75 C68.3333333,73.9172832 67.5049542,73.0309949 66.4640112,73 Z M66.4149618,65 L24.2517049,65 C23.1922175,65 22.3333333,65.8954305 22.3333333,67 C22.3333333,68.1045695 23.1922175,69 24.2517049,69 L66.4149618,69 C67.4744491,69 68.3333333,68.1045695 68.3333333,67 C68.3333333,65.8954305 67.4744491,65 66.4149618,65 Z M66.6368571,37 L24.0298096,37 C23.0934858,37 22.3342019,37.7413433 22.3333333,38.6563922 L22.3333333,59.3420698 C22.3333333,60.2577194 23.0928716,61 24.0298096,61 L66.6368571,61 C67.5737951,61 68.3333333,60.2577194 68.3333333,59.3420698 L68.3333333,38.6563922 C68.3324648,37.7413433 67.5731808,37 66.6368571,37 Z" id="形状结合" fill-opacity="0.4"></path>
<path d="M24.0298096,37 L66.6368571,37 C67.5731808,37 68.3324648,37.7413433 68.3333333,38.6563922 L68.3333333,59.3420698 C68.3333333,60.2577194 67.5737951,61 66.6368571,61 L24.0298096,61 C23.0928716,61 22.3333333,60.2577194 22.3333333,59.3420698 L22.3333333,38.6563922 C22.3342019,37.7413433 23.0934858,37 24.0298096,37 Z" id="路径备份-18" fill-opacity="0.25"></path>
<path d="M24.2517049,65 L66.4149618,65 C67.4744491,65 68.3333333,65.8954305 68.3333333,67 C68.3333333,68.1045695 67.4744491,69 66.4149618,69 L24.2517049,69 C23.1922175,69 22.3333333,68.1045695 22.3333333,67 C22.3333333,65.8954305 23.1922175,65 24.2517049,65 Z" id="路径" fill-opacity="0.25"></path>
<path d="M24.2026555,73 L66.4640112,73 C67.5049542,73.0309949 68.3333333,73.9172832 68.3333333,75 C68.3333333,76.0827168 67.5049542,76.9690051 66.4640112,77 L24.2026555,77 C23.1617125,76.9690051 22.3333333,76.0827168 22.3333333,75 C22.3333333,73.9172832 23.1617125,73.0309949 24.2026555,73 L24.2026555,73 Z" id="路径" fill-opacity="0.25"></path>
<path d="M85.4975653,111 L6.16910162,111 C3.45279988,111 1.16923848,109.209288 0.520127976,106.809096 C0.395932467,106.351318 0.333333333,105.880935 0.333333333,105.408742 L0.333333333,79 L22.4124303,79 C24.8500971,79 26.8161081,81.0716076 26.8161081,83.3963401 L26.8161081,83.4268142 C26.7945193,85.726434 28.7763739,87.4925611 31.2431351,87.5133066 L60.4235318,87.5133066 C62.8627552,87.5133066 64.8505589,85.7413887 64.8505589,83.4094004 L64.8505589,83.4006936 C64.8505589,81.0788633 66.5634854,79 69.0011522,79 L91.1480956,79 L91.3333333,105.408742 C91.3333333,105.880826 91.2709241,106.35111 91.1480956,106.809096 C90.4974284,109.21074 88.213867,111 85.4975653,111 Z" id="路径" fill-opacity="0.15"></path>
<path d="M87.3333333,0 C95.6197279,0 102.333333,5.37180337 102.333333,12 C102.333333,18.6278294 95.6184963,23.9996327 87.3333333,24 C84.501497,24.0178516 81.7065079,23.3579991 79.3333333,22 L74.3333333,24 C74.4123056,23.9247408 74.1425897,23.8729257 73.3333333,24 C73.7697002,23.5250757 73.6995096,23.2598089 73.3333333,23 L75.3333333,19 C73.3371103,16.9483718 72.3333333,14.5688327 72.3333333,12 C72.3333333,5.37180337 79.049402,0 87.3333333,0 Z M80.3333333,10 C79.2287638,10 78.3333333,10.8954305 78.3333333,12 C78.3333333,13.1045695 79.2287638,14 80.3333333,14 C81.4379028,14 82.3333333,13.1045695 82.3333333,12 C82.3333333,10.8954305 81.4379028,10 80.3333333,10 Z M87.3333333,10 C86.2287638,10 85.3333333,10.8954305 85.3333333,12 C85.3333333,13.1045695 86.2287638,14 87.3333333,14 C88.4379028,14 89.3333333,13.1045695 89.3333333,12 C89.3333333,10.8954305 88.4379028,10 87.3333333,10 Z M95.3333333,10 C94.2287638,10 93.3333333,10.8954305 93.3333333,12 C93.3333333,13.1045695 94.2287638,14 95.3333333,14 C96.4379028,14 97.3333333,13.1045695 97.3333333,12 C97.3333333,10.8954305 96.4379028,10 95.3333333,10 Z" id="形状结合" fill-opacity="0.2"></path>
</g>
</g>
</g>
</g>
</g>
</svg>

After

Width:  |  Height:  |  Size: 5.5 KiB

View File

@ -0,0 +1,17 @@
<?xml version="1.0" encoding="UTF-8"?>
<svg width="128px" height="128px" viewBox="0 0 128 128" version="1.1" xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink">
<title>灰色/通用/无数据-浅色模式</title>
<g id="页面-1" stroke="none" stroke-width="1" fill="none" fill-rule="evenodd">
<g id="灰色占位图-浅色" transform="translate(-1651.000000, -1927.000000)" fill="#425369" fill-rule="nonzero">
<g id="空" transform="translate(1651.000000, 1927.000000)">
<path d="M31.999,73.801 L31.999,85 L18,85 L31.999,73.801 Z M95.999,74.6 L109,85 L95.999,85 L95.999,74.6 Z" id="形状结合" fill-opacity="0.15"></path>
<path d="M92.6251593,35 C93.519791,34.9990692 94.3782074,35.2647114 95.011248,35.738392 C95.6442887,36.2120727 96,36.8549176 96,37.5252697 L96,84.9999976 L109,85 L109,111.381334 C109,111.855732 108.937591,112.328322 108.814762,112.788553 C108.164095,115.201969 105.880534,117 103.164232,117 L23.8357683,117 C21.1194665,117 18.8359051,115.20051 18.1867946,112.788553 C18.0625991,112.32853 18,111.855842 18,111.381334 L18,85.0014583 L32,85.0009976 L32,37.5311288 C31.9979314,36.8601686 32.352297,36.2161728 32.9848863,35.7412915 C33.6174755,35.2664102 34.4762755,35 35.371722,35 L92.6251593,35 Z" id="形状结合" fill-opacity="0.05"></path>
<path d="M42.6964762,43 L85.3035238,43 C86.2398475,43 86.9991314,43.7413433 87,44.6563922 L87,65.3420698 C87,66.2577194 86.2404617,67 85.3035238,67 L42.6964762,67 C41.7595383,67 41,66.2577194 41,65.3420698 L41,44.6563922 C41.0008686,43.7413433 41.7601525,43 42.6964762,43 Z" id="路径" fill-opacity="0.15"></path>
<path d="M42.9183715,71 L85.0816285,71 C86.1411158,71 87,71.8954305 87,73 C87,74.1045695 86.1411158,75 85.0816285,75 L42.9183715,75 C41.8588842,75 41,74.1045695 41,73 C41,71.8954305 41.8588842,71 42.9183715,71 Z" id="路径" fill-opacity="0.15"></path>
<path d="M42.8693222,79 L85.1306778,79 C86.1716209,79.0309949 87,79.9172832 87,81 C87,82.0827168 86.1716209,82.9690051 85.1306778,83 L42.8693222,83 C41.8283791,82.9690051 41,82.0827168 41,81 C41,79.9172832 41.8283791,79.0309949 42.8693222,79 L42.8693222,79 Z" id="路径" fill-opacity="0.15"></path>
<path d="M108.814762,112.788553 C108.164095,115.201969 105.880534,117 103.164232,117 L23.8357683,117 C21.1194665,117 18.8359051,115.20051 18.1867946,112.788553 C18.0625991,112.32853 18,111.855842 18,111.381334 L18,85.0014583 L40.079097,85.0014583 C42.5167638,85.0014583 44.4827747,86.9248997 44.4827747,89.2610281 L44.4827747,89.2916515 C44.461186,91.602544 46.4430406,93.4924594 48.9098017,93.5133066 L78.0901985,93.5133066 C80.5294219,93.5133066 82.5172255,91.617572 82.5172255,89.2741524 L82.5172255,89.2654028 C82.5172255,86.932191 84.4832365,85 86.9209032,85 L109,85 L109,111.381334 C109,111.855732 108.937591,112.328322 108.814762,112.788553 L108.814762,112.788553 Z" id="路径" fill-opacity="0.25"></path>
<path d="M105,6 C113.286395,6 120,11.3718034 120,18 C120,24.6278294 113.285163,29.9996327 105,30 C102.168164,30.0178516 99.3731746,29.3579991 97,28 L92,30 C92.0789723,29.9247408 91.8092563,29.8729257 91,30 C91.4363669,29.5250757 91.3661762,29.2598089 91,29 L93,25 C91.003777,22.9483718 90,20.5688327 90,18 C90,11.3718034 96.7160686,6 105,6 Z M98,16 C96.8954305,16 96,16.8954305 96,18 C96,19.1045695 96.8954305,20 98,20 C99.1045695,20 100,19.1045695 100,18 C100,16.8954305 99.1045695,16 98,16 Z M105,16 C103.895431,16 103,16.8954305 103,18 C103,19.1045695 103.895431,20 105,20 C106.104569,20 107,19.1045695 107,18 C107,16.8954305 106.104569,16 105,16 Z M113,16 C111.895431,16 111,16.8954305 111,18 C111,19.1045695 111.895431,20 113,20 C114.104569,20 115,19.1045695 115,18 C115,16.8954305 114.104569,16 113,16 Z" id="形状结合" fill-opacity="0.15"></path>
</g>
</g>
</g>
</svg>

After

Width:  |  Height:  |  Size: 3.8 KiB

View File

Before

Width:  |  Height:  |  Size: 7.6 KiB

After

Width:  |  Height:  |  Size: 7.6 KiB

View File

Before

Width:  |  Height:  |  Size: 20 KiB

After

Width:  |  Height:  |  Size: 20 KiB

View File

Before

Width:  |  Height:  |  Size: 7.9 KiB

After

Width:  |  Height:  |  Size: 7.9 KiB

View File

@ -0,0 +1,136 @@
#include "datetimeutils.h"
#include <QDBusReply>
#include <QDebug>
#include <locale.h>
#include <libintl.h>
DateTimeUtils* DateTimeUtils::m_dataTimeInstance = nullptr;
DateTimeUtils *DateTimeUtils::get_instance()
{
if(m_dataTimeInstance == nullptr){
m_dataTimeInstance = new DateTimeUtils;
}
return m_dataTimeInstance;
}
DateTimeUtils::DateTimeUtils(QObject *parent /*= nullptr*/): QObject(parent)
{
WatchingTimeFormat();
}
void DateTimeUtils::WatchingTimeFormat()
{
//监听系统时间格式转换
m_dateSessionDbus = new QDBusInterface("com.kylin.kysdk.DateServer",
"/com/kylin/kysdk/Date",
"com.kylin.kysdk.DateInterface",
QDBusConnection::sessionBus(),
this);
if (m_dateSessionDbus->isValid()) {
connect(m_dateSessionDbus, SIGNAL(DateSignal(QString)), this, SLOT(TranslationTime(QString)));
connect(m_dateSessionDbus, SIGNAL(ShortDateSignal(QString)), this, SLOT(TranslationTime(QString)));
connect(m_dateSessionDbus, SIGNAL(LongDateSignal(QString)), this, SLOT(TranslationTime(QString)));
connect(m_dateSessionDbus, SIGNAL(TimeSignal(QString)), this, SLOT(TranslationTime(QString)));
}
// m_dateFormatOld = "yyyy-MM-dd";
// m_dateFormatNow = kdk_system_get_shortformat();
// m_timeFormatOld = "hh:mm:ss";
// QString newTimeFormat(kdk_system_get_now_timeformat());//这个接口会影响安全中心翻译
// setLanguage(); //重新加载翻译
// if (newTimeFormat.contains("12")) {
// m_timeFormatNow = "ap hh:mm:ss";
// } else {
// m_timeFormatNow = "hh:mm:ss";
// }
}
//void DateTimeUtils::DateFormatChange(QString dateFormat)
//{
// Q_UNUSED(dateFormat)
// QString shortDateFormat(kdk_system_get_shortformat());
// if (m_dateFormatNow != shortDateFormat) {
// m_dateFormatOld = m_dateFormatNow;
// m_dateFormatNow = shortDateFormat;
// emit this->ShortDateSignal();
// qDebug()<<"emit ShortDateSignal";
// }
//}
//struct tm DateTimeUtils::QDateTimeToCtm(const QDateTime &datetime)
//{
// struct tm c_time;
// c_time.tm_year = datetime.date().year();
// c_time.tm_mon = datetime.date().month();
// c_time.tm_mday = datetime.date().day();
// c_time.tm_hour = datetime.time().hour();
// c_time.tm_min = datetime.time().minute();
// c_time.tm_sec = datetime.time().second();
// return c_time;
//}
QString DateTimeUtils::TranslationTime(QString time)
{
qInfo()<<"sdk====>TranslationTime function";
if(time == tr("No information!"))
{
return time;
}
if(time == NULL)
{
return time;
}
if(!time.contains(" "))
{
return time;
}
if(!time.contains("-"))
{
return time;
}
if(!time.contains(":"))
{
return time;
}
struct tm timestruct;
// time = "2022-08-01 22:00:00";
QStringList timelist = time.split(" ");
qDebug()<<"timelist is"<<timelist;
QString datesplit = timelist.at(0);
QString timesplit = timelist.at(1);
qDebug()<<datesplit<<timesplit;
/*日期处理*/
QStringList datedoublesplit = datesplit.split("-");
QString year = datedoublesplit.at(0);
timestruct.tm_year = year.toInt();
QString month = datedoublesplit.at(1);
timestruct.tm_mon = month.toInt();
QString day = datedoublesplit.at(2);
timestruct.tm_mday = day.toInt();
char* sdkdate = kdk_system_shortformat_transform(&timestruct);
QString sdkdatestring = QString::fromUtf8(sdkdate);
qDebug()<<sdkdatestring;
/*时间处理*/
QStringList timedoublesplit = timesplit.split(":");
QString hour = timedoublesplit.at(0);
timestruct.tm_hour = hour.toInt();
QString minute = timedoublesplit.at(1);
timestruct.tm_min = minute.toInt();
QString seconds = timedoublesplit.at(2);
timestruct.tm_sec = seconds.toInt();
kdk_timeinfo *kdk_timestruct =kdk_system_timeformat_transform(&timestruct);
qDebug()<<kdk_timestruct->time;
qDebug()<<kdk_timestruct->timesec;
QString sdktime = kdk_timestruct->timesec;
QString sdk_time = sdkdatestring + " " +sdktime;
qInfo()<<"finish tanslationtime";
return sdk_time;
}
DateTimeUtils::~DateTimeUtils()
{
// if (m_dateSessionDbus)
// delete m_dateSessionDbus;
}

View File

@ -0,0 +1,35 @@
#ifndef DATETIMEUTILS_H
#define DATETIMEUTILS_H
#include <QObject>
#include <QDBusInterface>
#include <libkydate.h>
#include <QDateTime>
class DateTimeUtils : public QObject
{
Q_OBJECT
public:
DateTimeUtils(QObject *parent = nullptr);
virtual ~DateTimeUtils();
void WatchingTimeFormat();
static DateTimeUtils* get_instance();
QString TranslationTime(QString time);
public slots:
void DateFormatChange(QString dateFormat);
void TimeFormatChange(QString timeFormat);
// QString TranslationTime(QString time);
private:
static DateTimeUtils *m_dataTimeInstance;
QString m_dateFormatNow;
QString m_dateFormatOld;
QString m_timeFormatNow;
QString m_timeFormatOld;
struct tm QDateTimeToCtm(const QDateTime &datetime);
QDBusInterface * m_dateSessionDbus = nullptr;
signals:
void ShortDateSignal();
};
#endif // DATETIMEUTILS_H

View File

@ -0,0 +1,15 @@
#include "global.h"
Global::Global()
{
}
Global::~Global()
{
}
QString Global::UpdateMode = "True";
QString Global::Version ="";
int Global::ServerNum = 0;

View File

@ -0,0 +1,19 @@
#ifndef GLOBAL_H
#define GLOBAL_H
#include <qstring.h>
class Global
{
public:
Global();
~Global();
public:
static QString UpdateMode;
static QString Version;
static int ServerNum;
};
#endif // GLOBAL_H

View File

@ -0,0 +1,342 @@
#include "setwidget.h"
#include "src/xatom-helper.h"
SetWidget::SetWidget(QWidget* parent):QDialog(parent)
{
this->setAutoFillBackground(true);
this->setBackgroundRole(QPalette::Base);
this->setWindowModality(Qt::ApplicationModal);
this->setWindowFlag(Qt::Tool);
this->setFixedWidth(550);
MotifWmHints hints;
hints.flags = MWM_HINTS_FUNCTIONS|MWM_HINTS_DECORATIONS;
hints.functions = MWM_FUNC_ALL;
hints.decorations = MWM_DECOR_BORDER;
XAtomHelper::getInstance()->setWindowMotifHint(this->winId(), hints);
// this->setFixedSize(450,560);
showAreaWidget = new QWidget(this);
showAreaWidget->setObjectName("showArea");
scrollArea = new QScrollArea(this);
scrollArea->setObjectName("scroll");
this->setFixedHeight(560);
// this->setFixedSize(450,560);
scrollArea->setHorizontalScrollBarPolicy(Qt::ScrollBarAlwaysOff);
scrollArea->setVerticalScrollBarPolicy(Qt::ScrollBarAsNeeded);
scrollArea->horizontalScrollBar()->setEnabled(false);
scrollArea->setFixedHeight(this->height());
scrollArea->setWidget(showAreaWidget);
scrollArea->setWidgetResizable(true);
// scrollArea->viewport()->setAttribute(Qt::WA_TranslucentBackground);
scrollArea->setStyleSheet("QScrollArea#scroll{background-color: transparent;}");
scrollArea->viewport()->setStyleSheet("QWidget#showArea{background-color: transparent;}");
scrollArea->verticalScrollBar()->setProperty("drawScrollBarGroove",false);
QVBoxLayout *mainlyt = new QVBoxLayout();
QHBoxLayout *titleLyt = initTitleBar();
QVBoxLayout *bodylyt = initBody();
QHBoxLayout *btnlyt = initButton();
mainlyt->setMargin(0);
mainlyt->addLayout(titleLyt);
mainlyt->addWidget(scrollArea);
mainlyt->addLayout(btnlyt);
mainlyt->addSpacing(25);
mainlyt->addStretch();
mainlyt->setSpacing(0);
mainlyt->setContentsMargins(0,0,0,0);
this->setLayout(mainlyt);
showAreaWidget->setLayout(bodylyt);
// showAreaWidget->setFixedWidth(this->width());
scrollArea->setFixedHeight(this->height() - cancelBtn->height() - 30 -10- 25);
getInitialData();
}
QHBoxLayout* SetWidget::initTitleBar()
{
titleText = new QLabel(showAreaWidget);
titleIcon = new QPushButton(showAreaWidget);
titleBtnClose = new QPushButton(showAreaWidget);
titleBtnClose->setToolTip(tr("Close"));
titleIcon->setObjectName("titleIcon");
titleIcon->setFixedSize(24,24);
titleIcon->setIconSize(QSize(25,25));
//TODO直接从主题调图标不会QIcon转qpixmap所以暂时从本地拿
// titleIcon->setPixmap(QPixmap::fromImage(QImage(iconPath)));
titleIcon->setIcon(QIcon::fromTheme("ukui-control-center"));
titleIcon->setFlat(true);
// titleIcon->setProperty("useButtonPalette", true);
titleIcon->setFocusPolicy(Qt::NoFocus);
titleIcon->setStyleSheet("QPushButton#titleIcon{border:0px;border-radius:4px;background:transparent;}"
"QPushButton#titleIcon::hover{border:0px;border-radius:4px;background:transparent;}"
"QPushButton#titleIcon::pressed{border:0px;border-radius:4px;background:transparent;}");
titleBtnClose->setFixedSize(30,30);
titleBtnClose->setToolTip(tr("Close"));
titleBtnClose->setIcon(QIcon::fromTheme("window-close-symbolic"));
titleBtnClose->setProperty("isWindowButton",0x2);
titleBtnClose->setProperty("useIconHighlightEffect",0x8);
titleBtnClose->setFlat(true);
connect(titleBtnClose,&QPushButton::clicked,[=](){this->close();});
QHBoxLayout *hlyt = new QHBoxLayout;
titleText->setText(tr("Advanced Option"));
hlyt->setSpacing(0);
hlyt->setMargin(4);
hlyt->addSpacing(4);
hlyt->addWidget(titleIcon); //居下显示
hlyt->addSpacing(8);
hlyt->addWidget(titleText);//,0,Qt::AlignBottom
hlyt->addStretch();
hlyt->addWidget(titleBtnClose);
return hlyt;
}
QVBoxLayout* SetWidget::initBody()
{
QVBoxLayout *vLayout4 = initServerAddress();
QVBoxLayout *vlyt = new QVBoxLayout;
vlyt->setMargin(0);
vlyt->setSpacing(0);
vlyt->addLayout(vLayout4);
vlyt->addStretch();
vlyt->setContentsMargins(24,10,24,10);
return vlyt;
}
QVBoxLayout* SetWidget::initServerAddress()
{
serverAddressTitleLabel = new QLabel(showAreaWidget);
serverAddressTitleLabel->setAlignment(Qt::AlignLeft);
serverAddressTitleLabel->setText(tr("Server address settings"));
tipsTextLabel = new QLabel(showAreaWidget);
tipsTextLabel->setAlignment(Qt::AlignLeft);
tipsTextLabel->setText(tr("If internal services, change the server address."));
// ProtocolLabel = new QLabel(showAreaWidget);
// ProtocolLabel->setAlignment(Qt::AlignLeft);
// ProtocolLabel->setFixedWidth(80);
// ProtocolLabel->setText(tr("Protocal"));
ProtocolComboBox = new QComboBox(showAreaWidget);
ProtocolComboBox->setFixedWidth(112);
ProtocolComboBox->setEditable(false);
ProtocolComboBox->setObjectName("comboBox1");
ProtocolComboBox->addItem("https://");
ProtocolComboBox->addItem("http://");
PortLabel = new QLabel(showAreaWidget);
PortLabel->setAlignment(Qt::AlignLeft);
PortLabel->setFixedWidth(80);
PortLabel->setText(tr("Port ID "));
PortEdit = new QLineEdit(showAreaWidget);
PortEdit->setFixedWidth(112);
PortEdit->setObjectName("PortEdit");
QRegExp regx("[0-9]+$");
QValidator* validator = new QRegExpValidator(regx, PortEdit);
PortEdit->setValidator(validator);
AddressLabel = new QLabel(showAreaWidget);
AddressLabel->setAlignment(Qt::AlignLeft);
AddressLabel->setText(tr("Address"));
AddressLabel->setFixedWidth(80);
IPEdit = new QLineEdit(showAreaWidget);
IPEdit->setObjectName("IPEdit");
IPEdit->setFixedWidth(250);
QHBoxLayout *hlayout1 = new QHBoxLayout();
hlayout1->addWidget(serverAddressTitleLabel,0,Qt::AlignLeft);
hlayout1->addStretch();
hlayout1->setSpacing(0);
hlayout1->setContentsMargins(0,0,0,0);
QHBoxLayout *hlayout2 = new QHBoxLayout();
hlayout2->addWidget(tipsTextLabel,0,Qt::AlignLeft);
hlayout2->addStretch();
hlayout2->setSpacing(0);
hlayout2->setContentsMargins(0,0,0,0);
QHBoxLayout *hlayout3 = new QHBoxLayout();
hlayout3->addWidget(AddressLabel,0,Qt::AlignLeft);
hlayout3->addSpacing(4);
// hlayout3->addWidget(ProtocolLabel,0,Qt::AlignLeft);
// hlayout3->addSpacing(4);
hlayout3->addWidget(ProtocolComboBox,0,Qt::AlignLeft);
hlayout3->addSpacing(4);
hlayout3->addWidget(IPEdit);
hlayout3->addStretch();
hlayout3->setSpacing(0);
hlayout3->setContentsMargins(0,0,0,0);
QHBoxLayout *hlayout4 = new QHBoxLayout();
hlayout4->addWidget(PortLabel);
hlayout4->addSpacing(4);
hlayout4->addWidget(PortEdit);
hlayout4->setSpacing(0);
hlayout4->addStretch();
hlayout4->setContentsMargins(0,0,0,0);
// QHBoxLayout *hlayout5 = new QHBoxLayout();
// hlayout5->addWidget(AddressLabel);
// hlayout5->addSpacing(4);
// hlayout5->addWidget(IPEdit);
// hlayout5->addStretch();
// hlayout5->setSpacing(0);
// hlayout5->setContentsMargins(0,0,0,0);
QVBoxLayout *vlayout = new QVBoxLayout();
vlayout->addLayout(hlayout1);
vlayout->addSpacing(12);
vlayout->addLayout(hlayout2);
vlayout->addSpacing(8);
vlayout->addLayout(hlayout3);
vlayout->addSpacing(8);
vlayout->addLayout(hlayout4);
// vlayout->addSpacing(8);
// vlayout->addLayout(hlayout5);
vlayout->setSpacing(0);
vlayout->setContentsMargins(0,0,0,0);
return vlayout;
}
QHBoxLayout *SetWidget::initButton()
{
resetBtn = new QPushButton(this);
resetBtn->setText(tr("reset"));
// resetBtn->setFlat(true);
// resetBtn->setText(tr("Restore default settings"));
resetBtn->setObjectName("resetBtn");
connect(resetBtn,SIGNAL(clicked()),this,SLOT(slotRestoreDefaultSettings()));
cancelBtn = new QPushButton(this);
cancelBtn->setText(tr("Cancel"));
connect(cancelBtn,&QPushButton::clicked,[=](){this->close();});
determineBtn = new QPushButton(this);
determineBtn->setText(tr("OK"));
connect(determineBtn,SIGNAL(clicked(bool)),this,SLOT(slotModifysettings()));
QHBoxLayout *hlayout = new QHBoxLayout();
hlayout->addWidget(resetBtn,0,Qt::AlignVCenter);
hlayout->addStretch();
hlayout->addWidget(cancelBtn,0,Qt::AlignVCenter);
hlayout->addSpacing(10);
hlayout->addWidget(determineBtn,0,Qt::AlignVCenter);
hlayout->setSpacing(0);
hlayout->setContentsMargins(24,0,24,0);
return hlayout;
}
/*****************获取数据********************/
void SetWidget::getInitialData()
{
QString filename = "/var/lib/kylin-software-properties/template/kylin-source-update.conf";
QSettings *setting = new QSettings(filename, QSettings::IniFormat);
setting->setIniCodec("utf8");
QStringList group = setting->childGroups();
int num = group.count();
int Priority;
int tmp = 0;
int i;
for(i=0; i<num; )
{
QString Service = group.at(i);
qDebug()<<"The Service is "<< Service;
setting->beginGroup(Service);
Priority = setting->value("Priority").toInt();
qDebug()<<"the Priority is "<<Priority;
setting->endGroup();
if(Priority > tmp)
{
tmp = Priority;
flag = Service;
}
i++;
}
if(Priority == 0)
{
qInfo()<<"Priority is 0,find priority";
qInfo()<<"==================";
for(i=0; i<num; )
{
QString Service = group.at(i);
qDebug()<<"The Service is "<< Service;
setting->beginGroup(Service);
Priority = setting->value("priority").toInt();
qDebug()<<"the priority is "<<Priority;
setting->endGroup();
if(Priority > tmp)
{
tmp = Priority;
flag = Service;
}
i++;
}
qInfo()<<"==================";
}
qDebug()<<"the tmp is" <<tmp <<flag;
/*Port ID initial*/
setting->beginGroup(flag);
QString Port = setting->value("Port").toString();
qDebug()<<"the Port is "<< Port;
PortEdit->setText(Port);
/*IP Address initial*/
QString fullname = setting->value("Address").toString();
qDebug()<<"the fullname is "<<fullname;
QStringList namelist = fullname.split("://");
qDebug()<<"the namelist is "<< namelist;
QString networkprotocal = namelist.at(0);
qDebug()<<"the networkprotocal is "<<networkprotocal;
if(networkprotocal != "http" && networkprotocal != "https")
{
qDebug()<<"the network protocal is error";
ProtocolComboBox->setCurrentText("https://");
}
else
{
ProtocolComboBox->setCurrentText(networkprotocal+"://");
}
QString domainname = namelist.at(1);
qDebug()<<"the domainname is "<< domainname;
IPEdit->setText(domainname);
}
/**********************************槽函数***********************************/
void SetWidget::slotRestoreDefaultSettings()
{
qDebug()<<"reset the default setting";
// QDBusInterface modify_interface( "com.kylin.software.properties",
// "/com/kylin/software/properties",
// "com.kylin.software.properties.interface",
// QDBusConnection::systemBus() );
ProtocolComboBox->setCurrentText("http://");
PortEdit->setText("59546");
IPEdit->setText("archive1.kylinos.cn");
// QDBusMessage modelist = modify_interface.call("setServerAddressConf","Server","http://archive1.kylinos.cn","59546");
// QDBusMessage modelist1 = modify_interface.call("setServerAddressConf","Server1","https://archive1.kylinos.cn","59546");
}
void SetWidget::slotModifysettings()
{
QString group = flag;
QString protocol = ProtocolComboBox->currentText();
QString domainname = IPEdit->text();
QString IP = protocol+domainname;
QString port = PortEdit->text();
qDebug()<<group<<IP<<port;
QDBusInterface modify_interface( "com.kylin.software.properties",
"/com/kylin/software/properties",
"com.kylin.software.properties.interface",
QDBusConnection::systemBus() );
QDBusMessage modelist = modify_interface.call("setServerAddressConf",group,IP,port);
int result =modelist.arguments().value(0).toInt();
qDebug()<<result;
if(result)
{
qDebug()<<"error in modify!";
QMessageBox msgBox(qApp->activeModalWidget());
msgBox.setText(tr("Modification failed!"));
msgBox.setWindowTitle(tr("Attention"));
msgBox.setIcon(QMessageBox::Icon::Warning);
msgBox.addButton(tr("OK"), QMessageBox::YesRole);
}
else
{
this->close();
}
}

View File

@ -0,0 +1,80 @@
#ifndef SETWIDGET_H
#define SETWIDGET_H
#include <QWidget>
#include <QHBoxLayout>
#include <QPushButton>
#include <QToolButton>
#include <QCheckBox>
#include <QDebug>
#include <QString>
#include <QScrollArea>
#include <QScrollBar>
#include <QLabel>
#include <QVBoxLayout>
#include <QRadioButton>
#include <QHBoxLayout>
#include <QLineEdit>
#include <QEvent>
#include <QComboBox>
#include <QAbstractItemView>
#include <QDBusPendingCall>
#include <QDBusInterface>
#include <QDBusMessage>
#include <QMessageBox>
#include <QUrl>
#include <QSettings>
#include <QDialog>
#include <QApplication>
class SetWidget : public QDialog
{
Q_OBJECT
public:
QMap<QString,QVariant> serverMap;
QString flag = nullptr;
QWidget *showAreaWidget = nullptr;
QScrollArea *scrollArea = nullptr;
QLabel *titleText = nullptr;
QPushButton* titleIcon = nullptr;
QPushButton *titleBtnClose = nullptr;
QLabel *serverAddressTitleLabel = nullptr;
QLabel *tipsTextLabel = nullptr;
// QLabel *ProtocolLabel = nullptr;
QComboBox *ProtocolComboBox = nullptr;
QLabel *PortLabel = nullptr;
QLineEdit *PortEdit = nullptr;
QLabel *AddressLabel = nullptr;
QLineEdit *IPEdit = nullptr;
QPushButton *resetBtn = nullptr;
QPushButton *cancelBtn = nullptr;
QPushButton *determineBtn = nullptr;
QHBoxLayout* initTitleBar();
QVBoxLayout* initBody();
QVBoxLayout* initDownloadDir(); //初始化设置界面下载路径模块
QVBoxLayout* initPackageClean(); //初始化设置界面包清理模块
QVBoxLayout* initUpdatePackage(); //初始化设置界面包清理模块
QVBoxLayout* initServerAddress(); //初始化服务器地址
QHBoxLayout* initButton();
void getInitialData(); //获取初始数据
void slotClickComboBox1(); //combox1添加item
void slotClickLineEdit1(); //combox1添加item
SetWidget(QWidget* parent = nullptr);
public Q_SLOTS:
void slotSoftUpdateCheckBox5(); //处理应用更新处按钮的点击
void slotSoftUpdateCheckBox6(); //处理应用更新处按钮的点击
void slotRestoreDefaultSettings(); //恢复默认设置
void slotModifysettings(); //修改设置
};
#endif // SETWIDGET_H

View File

@ -0,0 +1,238 @@
#include "appupdate.h"
#include <QPixmap>
#include <stdio.h>
#include <QLocale>
#include <QScrollBar>
#include <QJsonDocument>
#include <QJsonObject>
#include <QJsonArray>
#include <QJsonParseError>
using namespace std;
#define JSON_FILE_PATH "/var/cache/kylin-system-updater/json/"
AppUpdateWid::AppUpdateWid(AppAllMsg msg,QWidget *parent):QWidget(parent)
{
m_updateMutual = UpdateDbus::getInstance(this);
qRegisterMetaType<AppMsg>("AppMsg"); //注册信号槽类型
qRegisterMetaType<AppAllMsg>("AppAllMsg"); //注册信号槽类型
appAllMsg = msg;
updateAppUi(appAllMsg.name);
this->setObjectName("AppUpdateWid");
initConnect();
}
void AppUpdateWid::updateAppUi(QString name)
{
this->setFixedHeight(60);
appname.clear();
appname = name;
frameLayout = new QHBoxLayout();
frameLayout->setContentsMargins(0,0,0,0); //更新信息之间的间距
frameLayout->setSpacing(0);
this->setLayout(frameLayout);
AppFrame = new QFrame(this); //最外层窗口适配主题样式
AppFrame->setFrameShape(QFrame::Box);
AppFrame->setMaximumSize(QSize(16777215, 16777215));
frameLayout->addWidget(AppFrame);
mainVLayout = new QHBoxLayout();
// smallHLayout = new QHBoxLayout();
appTitleWid = new QWidget();
iconNameLayout = new QHBoxLayout();
appIconName = new QLabel(this);
appIconName->setFixedWidth(200);
appIcon = new QLabel(appIconName);
appNameLab = new MyLabel(appIconName);
appIconName->setLayout(iconNameLayout);
appIcon->setFixedSize(32,32);
iconNameLayout->addSpacing(6);
iconNameLayout->addWidget(appIcon,1);
iconNameLayout->addSpacing(8);
iconNameLayout->addWidget(appNameLab,10);
appVersion = new FixLabel(this);
appVersion ->setFixedWidth(250);
detaileInfo = new KBorderlessButton(this);
// detaileInfo->setText(tr("详情"));
detaileInfo->setText(tr("details"));
QPalette palette_datailInfo = detaileInfo->palette();
palette_datailInfo.setColor(QPalette::ButtonText,QColor(55,144,250));
detaileInfo->setPalette(palette_datailInfo);
updateAPPBtn = new QPushButton(this);
// updateAPPBtn->setText(tr("更新"));
updateAPPBtn->setText(tr("Update"));
updateAPPBtn->setFixedWidth(95);
updateAPPBtn->hide();
mainVLayout->addWidget(appIconName,1,Qt::AlignLeft);
mainVLayout->addWidget(appVersion,1,Qt::AlignLeft);
mainVLayout->addWidget(detaileInfo,0,Qt::AlignHCenter);
mainVLayout->addSpacing(60);
mainVLayout->addWidget(updateAPPBtn,0,Qt::AlignHCenter);
mainVLayout->setContentsMargins(0,0,10,0);
// appTitleWid->setLayout(smallHLayout);
// mainVLayout->addWidget(appTitleWid);
mainVLayout->setMargin(0);
mainVLayout->setSpacing(0);
AppFrame->setLayout(mainVLayout);
QMap<QString, QString> map = getNameAndIconFromJson(name);
if (!map.value("name").isNull())
{
dispalyName = map.value("name");
qInfo()<<"map.value.isNull()"<<dispalyName;
}
appNameLab->setText(dispalyName);
/*判断图标,优先级: JSON文件指定 > qrc资源文件中 > 主题 > 默认*/
if (!map.value("icon").isNull()) {
haveThemeIcon = true;
appIcon->setPixmap(QPixmap(map.value("icon")));
} else if (name.contains("kylin-update-desktop-")||name == "linux-generic") {
qInfo()<<"app exsist icon";
haveThemeIcon = true;
pkgIconPath = QString(":/img/upgrade/%1.png").arg(name);
appIcon->setPixmap(QPixmap(pkgIconPath));
} else if (QIcon::fromTheme(name).hasThemeIcon(name)) { //判断是否有主题图标并输出
haveThemeIcon = true;
qInfo()<<"theme exsist icon";
QIcon icon = QIcon::fromTheme(name);
QPixmap pixmap = icon.pixmap(icon.actualSize(QSize(32, 32)));
appIcon->setPixmap(pixmap);
} else {
qInfo()<<"else exsist icon";
QIcon icon = QIcon::fromTheme("application-x-desktop");
QPixmap pixmap = icon.pixmap(icon.actualSize(QSize(32, 32)));
appIcon->setPixmap(pixmap);
}
QString newStrMsg = appAllMsg.availableVersion;
if(newStrMsg.size()>16)
{
appVersion->setText(tr("Version:")+newStrMsg);
appVersion->setToolTip(tr("Version:")+newStrMsg);
}
else
{
// appVersion->setText(tr("最新:")+newStrMsg);
appVersion->setText(tr("Version:")+newStrMsg);
appVersion->setToolTip("");
}
}
AppUpdateWid::~AppUpdateWid()
{
}
void AppUpdateWid::initConnect()
{
connect(detaileInfo,&QPushButton::clicked,this,&AppUpdateWid::showDetails);
}
QMap<QString, QString> AppUpdateWid::getNameAndIconFromJson(QString pkgname)
{
QMap <QString, QString> nameIconList;
/*判断json文件是否存在*/
QString filename = QString(JSON_FILE_PATH) +pkgname +".json";
qInfo()<<"getNameAndIconFromJson's filename is "<<filename;
QFile file(filename);
if (!file.open(QIODevice::ReadOnly)){
qInfo() << "JSON file open failed! ";
file.close();
return nameIconList;
}
QByteArray jsonData = file.readAll();
QJsonParseError err_rpt;
QJsonDocument root_Doc = QJsonDocument::fromJson(jsonData, &err_rpt); // 字符串格式化为JSON
if (!root_Doc.isNull() && (err_rpt.error == QJsonParseError::NoError)) { // 解析未发生错误
if (root_Doc.isObject()) { // JSON 文档为对象
QJsonObject object = root_Doc.object(); // 转化为对象
if (QLocale::system().name() == "zh_CN"){
QString name = object.value("name").toObject().value("zh_CN").toString();
if (!name.isNull()) {
nameIconList.insert("name", name);
}
}else {
QString name = object.value("name").toObject().value("en_US").toString();
if (!name.isNull()) {
nameIconList.insert("name", name);
}
}
QString iconPath = object.value("icon").toString();
if (!iconPath.isNull())
nameIconList.insert("icon", iconPath);
}
}else{
qInfo() << "JSON文件格式错误";
file.close();
return nameIconList;
}
file.close();
return nameIconList;
}
void AppUpdateWid::showDetails()
{
qInfo()<<"show details in app";
Detaildialog *detaillog=new Detaildialog();
detaillog->setFixedSize(420,314);
detaillog->logContent->clear();
detaillog->setContentsMargins(24,24,24,24);
QPoint detail_pos = detaileInfo->mapToGlobal(detaileInfo->pos());
detaillog->move(QCursor().pos().x()-detaillog->width(),detail_pos.y()+detaileInfo->height());
QString appname_lab = appNameLab->text();
qInfo()<<"the appname_lab is"<< appname_lab;
QString filename = "/var/cache/kylin-system-updater/json/"+appname+".json";
qInfo()<<"file name is: "<<filename;
QFile file(filename);
if (!file.open(QIODevice::ReadOnly)){
qInfo() << "JSON file open failed! "<<file.errorString();
return ;
}
QByteArray jsonData = file.readAll();
QJsonParseError err_rpt;
QJsonDocument root_Doc = QJsonDocument::fromJson(jsonData, &err_rpt); // 字符串格式化为JSON
if (!root_Doc.isNull() && (err_rpt.error == QJsonParseError::NoError))
{ // 解析未发生错误
if (root_Doc.isObject())
{ // JSON 文档为对象
QJsonObject object = root_Doc.object(); // 转化为对象
if (QLocale::system().name() == "zh_CN")
{
QString name = object.value("name").toObject().value("zh_CN").toString();
QString description = object.value("description").toObject().value("zh_CN").toString();
if (!description.isNull()) {
detaillog->logContent->append(description);
// msg->shortDescription=description;
}
else
{
detaillog->logContent->append(tr("Cumulative updates"));
}
}
else
{
QString name = object.value("name").toObject().value("en_US").toString();
QString description = object.value("description").toObject().value("en_US").toString();
if (!description.isNull()) {
// msg->shortDescription=description;
detaillog->logContent->append(description);
}
else
{
detaillog->logContent->append(tr("Cumulative updates"));
}
}
}
}
file.close();
detaillog->show();
}

View File

@ -0,0 +1,148 @@
#ifndef APPUPDATE_H
#define APPUPDATE_H
#include <QPushButton>
#include <QWidget>
#include <QLabel>
#include <QHBoxLayout>
#include <QVBoxLayout>
#include <QDateTime>
#include <QTextEdit>
#include <QToolTip>
#include "utils.h"
#include "updatelog.h"
#include <QMetaType>
#include <QTimer>
#include "updatedbus.h"
#include <QCheckBox>
#include "mylabel.h"
#include "src/Data/global.h"
#include <kborderbutton.h>
#include <kborderlessbutton.h>
#include <kdialog.h>
#include "detaildialog.h"
#include <stdio.h>
#include <iostream>
#include <yaml-cpp/yaml.h>
#include <yaml-cpp/exceptions.h>
//#include <ukcc/interface/ukcccommon.h>
#include "ukcc/interface/upgradeukcccommon.h"
//#include <ukcc/widgets/lightlabel.h>
#include "ukcc/widgets/lightlabel.h"
class Detaildialog;
class UpdateLog;
using namespace kdk;
class AppUpdateWid : public QWidget
{
Q_OBJECT
public:
explicit AppUpdateWid(AppAllMsg msg, QWidget *parent = nullptr);
~AppUpdateWid();
// Detaildialog *detaillog;
QString appname = nullptr;
QFrame *AppFrame;
UpdateLog *updatelog1;
UpdateDbus *m_updateMutual;
//缩略界面
QLabel *appIcon;
QLabel *appIconName;
MyLabel *appNameLab;
FixLabel *appVersion;
QLabel *appVersionIcon;
QLabel *progressLab; //进度
QLabel *otherBtnLab;
QLabel *versionLab;
KBorderlessButton *detaileInfo;
QPushButton *updateAPPBtn;
QWidget *appTitleWid;
QHBoxLayout *frameLayout;
QHBoxLayout *iconNameLayout;
QHBoxLayout *smallHLayout;
QVBoxLayout *largeVLayout;
QHBoxLayout *versionlabLayout;
QHBoxLayout *otherBtnLayout;
QWidget *largeWidget;
QHBoxLayout *mainVLayout;
//展开界面
QTextEdit *someInfoEdit; //详情内容
QPushButton *updatelogBtn;
// AppMsg *thisAppMessage;
QString chlog; //更新日志完整内容
QString description; //更新包描述
QString setDefaultDescription(QString str); //将虚包包名汉化
void updateOneApp(bool status); //控制更新单个app
QString dispalyName;
QString modifySpeedUnit(long size, float time);
void distUpgradePartial(bool status);
void updateaccept();
void updatecancel();
private:
bool isCancel = false;
int connectTimes = 0;
bool downloadFinish = false;
bool stopTimer = false;
UrlMsg urlmsg;
QString path;
QString currentPackage;
QStringList downloadList;
QStringList downloadPackages;
AppAllMsg appAllMsg;
QProcess *downloadProcess;
QProcess *workProcess;
QTimer *timer;
QString downloadPath;
bool execFun = true;
public:
bool isUpdateAll = false;
bool isAutoUpgrade = false;
bool haveThemeIcon = false;
bool downloadstart = false;
bool shutdown_install = false;
public slots:
void showDetails();
void updateAllApp();
private:
void wgetDownload(UrlMsg msg, QString path); //断点续传下载
bool getDownloadSpeed(QString appName, QString fullName, int fileSize); //获取下载速度
void initConnect(); //初始化信号槽
void changeDownloadState(int state);
type checkSourcesType();
QStringList analysis_config_file(char *p_file_path);
void remove_last_enter(char *p_src_in_out);
void enableupdateAPPBtn(bool enabled);//取消按钮是否置灰
QMap<QString, QString> getNameAndIconFromJson(QString pkgname);
enum Environment{
en,
zh_cn
}environment;
signals:
void startWork(QString appName);
void startMove(QStringList list, QString appName);
void oneappUpdateResultSignal(bool state,QStringList pkgname,QString error,QString reason);
void changeUpdateAllSignal(bool isUpdate);
void downloadFailedSignal(int exitCode); //网络异常或者其他情况下下载失败时
void appupdateiscancel();
void sendProgress(QString pkgName, int Progress, QString type);
void changeupdateall();
void allappupdatefinishsignal();
void startoneappupdate();
void ShutdowninstallFinishSignal();//shutdownfinishsignal
private:
void updateAppUi(QString name);
QString translationVirtualPackage(QString str);
QString pkgIconPath = "";
};
#endif // APPUPDATE_H

View File

@ -0,0 +1,53 @@
#include "detaildialog.h"
/*点击appwidget详情的弹窗*/
Detaildialog::Detaildialog(QWidget *parent) : QDialog(parent)
//Detaildialog::Detaildialog(QWidget *parent,AppAllMsg msg) : QDialog(parent)
{
qRegisterMetaType<AppMsg>("AppMsg"); //注册信号槽类型
qRegisterMetaType<AppAllMsg>("AppAllMsg"); //注册信号槽类型
MotifWmHints hints;
hints.flags = MWM_HINTS_FUNCTIONS|MWM_HINTS_DECORATIONS;
hints.functions = MWM_FUNC_ALL;
hints.decorations = MWM_DECOR_BORDER;
XAtomHelper::getInstance()->setWindowMotifHint(this->winId(), hints);
logUi();
}
void Detaildialog::logUi()
{
// this->setWindowFlags(Qt::Popup);
// |Qt::FramelessWindowHint|Qt::NoDropShadowWindowHint
logContent = new QTextEdit(this);
logContent->setReadOnly(true);
logContent->lineWrapMode();
installContent = new FixLabel(this);
installContent->setFixedHeight(26);
logMainLayout = new QVBoxLayout(this);
this->setLayout(logMainLayout);
logMainLayout->addWidget(logContent,Qt::AlignCenter);
logMainLayout->addStretch(1);
logMainLayout->addWidget(installContent,Qt::AlignLeft|Qt::AlignBottom);
}
bool Detaildialog::event(QEvent *event)
{
if(QEvent::WindowDeactivate == event->type())
{
qDebug()<<"焦点在窗口之外";
this->close();
}
else
{
qDebug()<<"焦点在窗口里面";
}
return QWidget::event(event);
}
Detaildialog::~Detaildialog()
{
}

View File

@ -0,0 +1,53 @@
#ifndef DETAILDIALOG_H
#define DETAILDIALOG_H
/*点击appwidget详情的弹窗*/
#include <QWidget>
#include <QLabel>
#include <QScrollArea>
#include <QTextEdit>
#include <QPushButton>
#include <QHBoxLayout>
#include <QVBoxLayout>
#include <QDialog>
#include <QLineEdit>
//#include <ukcc/widgets/fixlabel.h>
#include "ukcc/widgets/fixlabel.h"
#include "appupdate.h"
class Detaildialog : public QDialog
{
Q_OBJECT
public:
explicit Detaildialog(QWidget *parent = nullptr);
void logUi();
~Detaildialog();
QLabel *logAppIcon;
QLabel *logAppName;
QLabel *logAppVerson;
QWidget *logWidget;
QWidget *logAppWidget;
QHBoxLayout *logAppHLayout;
QVBoxLayout *logAppVLayout;
QVBoxLayout *logVLayout;
QVBoxLayout *logMainLayout;
QTextEdit *logContent;
FixLabel *installContent;
QFrame *contentFrame;
protected:
// void mousePressEvent(QMouseEvent *event) override;
bool event(QEvent *event) override;
// bool eventFilter(QObject *, QEvent *);
// bool eventFilter(QObject *obj,QEvent *event);
};
#endif // DETAILDIALOG_H

Some files were not shown because too many files have changed in this diff Show More