22//
33// SPDX-License-Identifier: LGPL-3.0-or-later
44
5+ #include " global.h"
56#include " constant.h"
67#include " applicationchecker.h"
78#include < QDir>
@@ -15,24 +16,34 @@ namespace {
1516
1617bool hasDesktopIntersection (QStringView rawValue, const QStringList ¤tDesktops) noexcept
1718{
18- if (rawValue.isEmpty ()) {
19+ if (rawValue.isEmpty () || currentDesktops. isEmpty () ) {
1920 return false ;
2021 }
2122
22- auto tokens = qTokenize (rawValue, u' ;' , Qt::SkipEmptyParts);
23+ const auto &dde = fromStaticRaw (DesktopDDE);
24+ const auto &deepin = fromStaticRaw (DesktopDeepin);
25+
26+ bool currentHasDDE{false };
27+ for (const auto &s : currentDesktops) {
28+ if (s.compare (dde, Qt::CaseInsensitive) == 0 || s.compare (deepin, Qt::CaseInsensitive) == 0 ) {
29+ currentHasDDE = true ;
30+ break ;
31+ }
32+ }
2333
34+ auto tokens = qTokenize (rawValue, u' ;' , Qt::SkipEmptyParts);
2435 for (const auto token : tokens) {
25- const bool isDDE =
26- (token.compare (u" DDE" _sv, Qt::CaseInsensitive) == 0 || token.compare (u" deepin" _sv, Qt::CaseInsensitive) == 0 );
36+ const bool tokenIsDDE = (token.compare (dde, Qt::CaseInsensitive) == 0 || token.compare (deepin, Qt::CaseInsensitive) == 0 );
2737
28- for (const auto ¤t : currentDesktops) {
29- if (isDDE) {
30- if (current.compare (u" DDE" _sv, Qt::CaseInsensitive) == 0 ||
31- current.compare (u" deepin" _sv, Qt::CaseInsensitive) == 0 ) {
38+ if (tokenIsDDE) {
39+ if (currentHasDDE) {
40+ return true ;
41+ }
42+ } else {
43+ for (const auto ¤t : currentDesktops) {
44+ if (current.compare (token, Qt::CaseInsensitive) == 0 ) {
3245 return true ;
3346 }
34- } else if (current.compare (token, Qt::CaseInsensitive) == 0 ) {
35- return true ;
3647 }
3748 }
3849 }
@@ -51,7 +62,7 @@ bool ApplicationFilter::hiddenCheck(const DesktopEntry &entry) noexcept
5162 bool ok{false };
5263 hidden = toBoolean (hiddenVal.value (), ok);
5364 if (!ok) {
54- qCWarning (DDEAMChecker) << " invalid hidden value:" << hiddenVal.value ();
65+ qCWarning (DDEAMChecker) << " invalid hidden value:" << hiddenVal.value (). get () ;
5566 return false ;
5667 }
5768 }
@@ -60,11 +71,11 @@ bool ApplicationFilter::hiddenCheck(const DesktopEntry &entry) noexcept
6071
6172bool ApplicationFilter::tryExecCheck (const DesktopEntry &entry) noexcept
6273{
63- auto tryExecVal = entry.value (fromStaticRaw (DesktopFileEntryKey), u" TryExec " _s );
74+ auto tryExecVal = entry.value (fromStaticRaw (DesktopFileEntryKey), fromStaticRaw (DesktopEntryTryExec) );
6475 if (tryExecVal.has_value ()) {
6576 auto executable = toString (tryExecVal.value ());
6677 if (executable.isEmpty ()) {
67- qCWarning (DDEAMChecker) << " invalid TryExec value:" << tryExecVal.value ();
78+ qCWarning (DDEAMChecker) << " invalid TryExec value:" << tryExecVal.value (). get () ;
6879 return false ;
6980 }
7081
@@ -86,12 +97,12 @@ bool ApplicationFilter::showInCheck(const DesktopEntry &entry) noexcept
8697 }
8798
8899 bool showInCurrentDE{true };
89- if (auto val = entry.value (fromStaticRaw (DesktopFileEntryKey), u" OnlyShowIn " _s ); val.has_value ()) {
100+ if (auto val = entry.value (fromStaticRaw (DesktopFileEntryKey), fromStaticRaw (DesktopEntryOnlyShowIn) ); val.has_value ()) {
90101 showInCurrentDE = hasDesktopIntersection (toString (val.value ()), desktops);
91102 }
92103
93104 bool notShowInCurrentDE{false };
94- if (auto val = entry.value (fromStaticRaw (DesktopFileEntryKey), u" NotShowIn " _s ); val.has_value ()) {
105+ if (auto val = entry.value (fromStaticRaw (DesktopFileEntryKey), fromStaticRaw (DesktopEntryNotShowIn) ); val.has_value ()) {
95106 notShowInCurrentDE = hasDesktopIntersection (toString (val.value ()), desktops);
96107 }
97108
0 commit comments