Skip to content

Commit 184a149

Browse files
committed
feat: live config reload
this is a workaround for https://bugs.kde.org/show_bug.cgi?id=505251
1 parent 9128944 commit 184a149

16 files changed

Lines changed: 419 additions & 310 deletions

.clang-format

Lines changed: 89 additions & 219 deletions
Original file line numberDiff line numberDiff line change
@@ -1,225 +1,95 @@
11
---
2-
Language: Cpp
3-
# BasedOnStyle: LLVM
4-
AccessModifierOffset: -2
5-
AlignAfterOpenBracket: Align
6-
AlignArrayOfStructures: None
7-
AlignConsecutiveAssignments:
8-
Enabled: false
9-
AcrossEmptyLines: false
10-
AcrossComments: false
11-
AlignCompound: false
12-
PadOperators: true
13-
AlignConsecutiveBitFields:
14-
Enabled: false
15-
AcrossEmptyLines: false
16-
AcrossComments: false
17-
AlignCompound: false
18-
PadOperators: false
19-
AlignConsecutiveDeclarations:
20-
Enabled: false
21-
AcrossEmptyLines: false
22-
AcrossComments: false
23-
AlignCompound: false
24-
PadOperators: false
25-
AlignConsecutiveMacros:
26-
Enabled: false
27-
AcrossEmptyLines: false
28-
AcrossComments: false
29-
AlignCompound: false
30-
PadOperators: false
31-
AlignEscapedNewlines: Right
32-
AlignOperands: Align
33-
AlignTrailingComments:
34-
Kind: Always
35-
OverEmptyLines: 0
36-
AllowAllArgumentsOnNextLine: true
37-
AllowAllParametersOfDeclarationOnNextLine: true
38-
AllowShortBlocksOnASingleLine: Never
39-
AllowShortCaseLabelsOnASingleLine: false
40-
AllowShortEnumsOnASingleLine: true
41-
AllowShortFunctionsOnASingleLine: All
42-
AllowShortIfStatementsOnASingleLine: Never
43-
AllowShortLambdasOnASingleLine: All
44-
AllowShortLoopsOnASingleLine: false
45-
AlwaysBreakAfterDefinitionReturnType: None
46-
AlwaysBreakAfterReturnType: None
47-
AlwaysBreakBeforeMultilineStrings: false
48-
AlwaysBreakTemplateDeclarations: MultiLine
49-
AttributeMacros:
50-
- __capability
51-
BinPackArguments: true
52-
BinPackParameters: true
53-
BitFieldColonSpacing: Both
54-
BraceWrapping:
55-
AfterCaseLabel: false
56-
AfterClass: false
57-
AfterControlStatement: Never
58-
AfterEnum: false
59-
AfterExternBlock: false
60-
AfterFunction: false
61-
AfterNamespace: false
62-
AfterObjCDeclaration: false
63-
AfterStruct: false
64-
AfterUnion: false
65-
BeforeCatch: false
66-
BeforeElse: false
67-
BeforeLambdaBody: false
68-
BeforeWhile: false
69-
IndentBraces: false
70-
SplitEmptyFunction: true
71-
SplitEmptyRecord: true
72-
SplitEmptyNamespace: true
73-
BreakAfterAttributes: Never
74-
BreakAfterJavaFieldAnnotations: false
75-
BreakArrays: true
76-
BreakBeforeBinaryOperators: None
77-
BreakBeforeConceptDeclarations: Always
78-
BreakBeforeBraces: Attach
79-
BreakBeforeInlineASMColon: OnlyMultiline
80-
BreakBeforeTernaryOperators: true
81-
BreakConstructorInitializers: BeforeColon
82-
BreakInheritanceList: BeforeColon
83-
BreakStringLiterals: true
84-
ColumnLimit: 120
85-
CommentPragmas: "^ IWYU pragma:"
86-
CompactNamespaces: false
87-
ConstructorInitializerIndentWidth: 4
88-
ContinuationIndentWidth: 4
89-
Cpp11BracedListStyle: true
90-
DerivePointerAlignment: false
2+
# SPDX-FileCopyrightText: 2019 Christoph Cullmann <cullmann@kde.org>
3+
# SPDX-FileCopyrightText: 2019 Gernot Gebhard <gebhard@absint.com>
4+
#
5+
# SPDX-License-Identifier: MIT
6+
7+
# This file got automatically created by ECM, do not edit
8+
# See https://clang.llvm.org/docs/ClangFormatStyleOptions.html for the config options
9+
# and https://community.kde.org/Policies/Frameworks_Coding_Style#Clang-format_automatic_code_formatting
10+
# for clang-format tips & tricks
11+
---
12+
Language: JavaScript
13+
DisableFormat: true
14+
---
15+
Language: Json
9116
DisableFormat: false
92-
EmptyLineAfterAccessModifier: Never
93-
EmptyLineBeforeAccessModifier: LogicalBlock
94-
ExperimentalAutoDetectBinPacking: false
95-
FixNamespaceComments: true
96-
ForEachMacros:
97-
- foreach
98-
- Q_FOREACH
99-
- BOOST_FOREACH
100-
IfMacros:
101-
- KJ_IF_MAYBE
102-
IncludeBlocks: Preserve
103-
IncludeCategories:
104-
- Regex: '^"(llvm|llvm-c|clang|clang-c)/'
105-
Priority: 2
106-
SortPriority: 0
107-
CaseSensitive: false
108-
- Regex: '^(<|"(gtest|gmock|isl|json)/)'
109-
Priority: 3
110-
SortPriority: 0
111-
CaseSensitive: false
112-
- Regex: ".*"
113-
Priority: 1
114-
SortPriority: 0
115-
CaseSensitive: false
116-
IncludeIsMainRegex: "(Test)?$"
117-
IncludeIsMainSourceRegex: ""
118-
IndentAccessModifiers: false
119-
IndentCaseBlocks: false
120-
IndentCaseLabels: false
121-
IndentExternBlock: AfterExternBlock
122-
IndentGotoLabels: true
123-
IndentPPDirectives: None
124-
IndentRequiresClause: true
12517
IndentWidth: 4
126-
IndentWrappedFunctionNames: false
127-
InsertBraces: false
128-
InsertNewlineAtEOF: false
129-
InsertTrailingCommas: None
130-
IntegerLiteralSeparator:
131-
Binary: 0
132-
BinaryMinDigits: 0
133-
Decimal: 0
134-
DecimalMinDigits: 0
135-
Hex: 0
136-
HexMinDigits: 0
137-
JavaScriptQuotes: Leave
138-
JavaScriptWrapImports: true
139-
KeepEmptyLinesAtTheStartOfBlocks: true
140-
LambdaBodyIndentation: Signature
141-
LineEnding: DeriveLF
142-
MacroBlockBegin: ""
143-
MacroBlockEnd: ""
144-
MaxEmptyLinesToKeep: 1
145-
NamespaceIndentation: None
146-
ObjCBinPackProtocolList: Auto
147-
ObjCBlockIndentWidth: 2
148-
ObjCBreakBeforeNestedBlockParam: true
149-
ObjCSpaceAfterProperty: false
150-
ObjCSpaceBeforeProtocolList: true
151-
PackConstructorInitializers: BinPack
152-
PenaltyBreakAssignment: 2
153-
PenaltyBreakBeforeFirstCallParameter: 19
154-
PenaltyBreakComment: 300
155-
PenaltyBreakFirstLessLess: 120
156-
PenaltyBreakOpenParenthesis: 0
157-
PenaltyBreakString: 1000
158-
PenaltyBreakTemplateDeclaration: 10
159-
PenaltyExcessCharacter: 1000000
160-
PenaltyIndentedWhitespace: 0
161-
PenaltyReturnTypeOnItsOwnLine: 60
18+
---
19+
20+
# Style for C++
21+
Language: Cpp
22+
23+
# base is WebKit coding style: https://webkit.org/code-style-guidelines/
24+
# below are only things set that diverge from this style!
25+
BasedOnStyle: WebKit
26+
27+
# enforce C++11 (e.g. for std::vector<std::vector<lala>>
28+
Standard: Cpp11
29+
30+
# 4 spaces indent
31+
TabWidth: 4
32+
33+
# 2 * 80 wide lines
34+
ColumnLimit: 160
35+
36+
# sort includes inside line separated groups
37+
SortIncludes: true
38+
39+
# break before braces on function, namespace and class definitions.
40+
BreakBeforeBraces: Linux
41+
42+
# CrlInstruction *a;
16243
PointerAlignment: Right
163-
PPIndentWidth: -1
164-
QualifierAlignment: Leave
165-
ReferenceAlignment: Pointer
166-
ReflowComments: true
167-
RemoveBracesLLVM: false
168-
RemoveSemicolon: false
169-
RequiresClausePosition: OwnLine
170-
RequiresExpressionIndentation: OuterScope
171-
SeparateDefinitionBlocks: Leave
172-
ShortNamespaceLines: 1
173-
SortIncludes: CaseSensitive
174-
SortJavaStaticImport: Before
175-
SortUsingDeclarations: LexicographicNumeric
176-
SpaceAfterCStyleCast: false
177-
SpaceAfterLogicalNot: false
178-
SpaceAfterTemplateKeyword: true
179-
SpaceAroundPointerQualifiers: Default
180-
SpaceBeforeAssignmentOperators: true
181-
SpaceBeforeCaseColon: false
44+
45+
# horizontally aligns arguments after an open bracket.
46+
AlignAfterOpenBracket: Align
47+
48+
# don't move all parameters to new line
49+
AllowAllParametersOfDeclarationOnNextLine: false
50+
51+
# no single line functions
52+
AllowShortFunctionsOnASingleLine: None
53+
54+
# no single line enums
55+
AllowShortEnumsOnASingleLine: false
56+
57+
# always break before you encounter multi line strings
58+
AlwaysBreakBeforeMultilineStrings: true
59+
60+
# don't move arguments to own lines if they are not all on the same
61+
BinPackArguments: false
62+
63+
# don't move parameters to own lines if they are not all on the same
64+
BinPackParameters: false
65+
66+
# In case we have an if statement with multiple lines the operator should be at the beginning of the line
67+
# but we do not want to break assignments
68+
BreakBeforeBinaryOperators: NonAssignment
69+
70+
# format C++11 braced lists like function calls
71+
Cpp11BracedListStyle: true
72+
73+
# do not put a space before C++11 braced lists
18274
SpaceBeforeCpp11BracedList: false
183-
SpaceBeforeCtorInitializerColon: true
184-
SpaceBeforeInheritanceColon: true
185-
SpaceBeforeParens: ControlStatements
186-
SpaceBeforeParensOptions:
187-
AfterControlStatements: true
188-
AfterForeachMacros: true
189-
AfterFunctionDefinitionName: false
190-
AfterFunctionDeclarationName: false
191-
AfterIfMacros: true
192-
AfterOverloadedOperator: false
193-
AfterRequiresInClause: false
194-
AfterRequiresInExpression: false
195-
BeforeNonEmptyParentheses: false
196-
SpaceBeforeRangeBasedForLoopColon: true
197-
SpaceBeforeSquareBrackets: false
198-
SpaceInEmptyBlock: false
199-
SpaceInEmptyParentheses: false
200-
SpacesBeforeTrailingComments: 1
201-
SpacesInAngles: Never
202-
SpacesInConditionalStatement: false
203-
SpacesInContainerLiterals: true
204-
SpacesInCStyleCastParentheses: false
205-
SpacesInLineCommentPrefix:
206-
Minimum: 1
207-
Maximum: -1
208-
SpacesInParentheses: false
209-
SpacesInSquareBrackets: false
210-
Standard: Latest
211-
StatementAttributeLikeMacros:
212-
- Q_EMIT
213-
StatementMacros:
214-
- Q_UNUSED
215-
- QT_REQUIRE_VERSION
216-
TabWidth: 8
217-
UseTab: Never
218-
WhitespaceSensitiveMacros:
219-
- BOOST_PP_STRINGIZE
220-
- CF_SWIFT_NAME
221-
- NS_SWIFT_NAME
222-
- PP_STRINGIZE
223-
- STRINGIZE
224-
---
22575

76+
# remove empty lines
77+
KeepEmptyLinesAtTheStartOfBlocks: false
78+
79+
# no namespace indentation to keep indent level low
80+
NamespaceIndentation: None
81+
82+
# we use template< without space.
83+
SpaceAfterTemplateKeyword: false
84+
85+
# Always break after template declaration
86+
AlwaysBreakTemplateDeclarations: true
87+
88+
# macros for which the opening brace stays attached.
89+
ForEachMacros: [ foreach, Q_FOREACH, BOOST_FOREACH, forever, Q_FOREVER, QBENCHMARK, QBENCHMARK_ONCE , wl_resource_for_each, wl_resource_for_each_safe ]
90+
91+
# keep lambda formatting multi-line if not empty
92+
AllowShortLambdasOnASingleLine: Empty
93+
94+
# We do not want clang-format to put all arguments on a new line
95+
AllowAllArgumentsOnNextLine: false

.clangd

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
CompileFlags:
2+
Remove:
3+
- -mno-direct-extern-access

install.sh

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
#!/bin/sh
2+
set -e
23

34
if [ -d "build" ]; then
45
rm -rf build

package/contents/code/utils.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -78,7 +78,7 @@ function addTrayIcon(window) {
7878
"toolTipText": formattedWindowInfo(window),
7979
"launcherUrl": launcherUrl,
8080
"xdgName": window.desktopFileName,
81-
"countUseDot": countUseDot
81+
"countUseDot": Qt.binding(function () { return countUseDot; })
8282
});
8383
trayItem.requestShowHide.connect(toggleShowHide);
8484
trayItem.requestClose.connect(closeWindow);

package/contents/ui/main.qml

Lines changed: 19 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,17 +1,31 @@
11
import QtQuick
22
import org.kde.kwin
33
import com.github.luisbocanegra.trayicon 1.0
4+
import com.github.luisbocanegra.kwinrcwatcher 1.0
45
import "../code/utils.js" as Utils
56

67
Item {
78
id: root
8-
property bool debugEnabled: KWin.readConfig("debugEnabled", false)
9-
property var hideByDefaultClass: Utils.commaSeparate(KWin.readConfig("hideByDefaultClass", ""))
10-
property bool countUseDot: KWin.readConfig("countUseDot", false)
11-
property bool hideOnMinimize: KWin.readConfig("hideOnMinimize", false)
9+
property bool debugEnabled
10+
property var hideByDefaultClass
11+
property bool countUseDot
12+
property bool hideOnMinimize
1213
property var trayIcons: new Object()
1314
readonly property Component trayIconComponent: TrayIcon {}
1415

16+
function reloadConfig() {
17+
console.log("KWin Minimize2Tray Reloading configuration");
18+
debugEnabled = KWin.readConfig("debugEnabled", false);
19+
hideByDefaultClass = Utils.commaSeparate(KWin.readConfig("hideByDefaultClass", ""));
20+
countUseDot = KWin.readConfig("countUseDot", false);
21+
hideOnMinimize = KWin.readConfig("hideOnMinimize", false);
22+
console.log(JSON.stringify(hideByDefaultClass));
23+
}
24+
25+
KwinrcWatcher {
26+
onConfigChanged: root.reloadConfig()
27+
}
28+
1529
ShortcutHandler {
1630
name: "Minimize to tray"
1731
text: "Minimize window to tray (sets skip Taskbar, Switcher & Pager)"
@@ -29,6 +43,7 @@ Item {
2943
}
3044

3145
Component.onCompleted: {
46+
reloadConfig();
3247
Workspace.windowAdded.connect(window => Utils.setup(window));
3348
Workspace.windowAdded.connect(window => {
3449
Utils.setupAutoHide(window);

plugin/CMakeLists.txt

Lines changed: 2 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -1,16 +1,2 @@
1-
set(PLUGIN_NAME "trayiconplugin")
2-
set(LIB_NAME "trayicon")
3-
4-
add_library(${PLUGIN_NAME} SHARED ${PLUGIN_NAME}.cpp ${LIB_NAME}.cpp)
5-
find_package(Qt6 ${QT_MIN_VERSION} REQUIRED COMPONENTS DBus Qml)
6-
find_package(KF6 ${KF6_MIN_VERSION} REQUIRED COMPONENTS StatusNotifierItem Service)
7-
8-
target_link_libraries(${PLUGIN_NAME}
9-
Qt6::Qml
10-
Qt6::DBus
11-
KF6::StatusNotifierItem
12-
KF6::Service
13-
)
14-
15-
install(TARGETS ${PLUGIN_NAME} DESTINATION ${KDE_INSTALL_QMLDIR}/com/github/luisbocanegra/${LIB_NAME})
16-
install(FILES qmldir DESTINATION ${KDE_INSTALL_QMLDIR}/com/github/luisbocanegra/${LIB_NAME})
1+
add_subdirectory(kwinrcwatcher)
2+
add_subdirectory(trayicon)

0 commit comments

Comments
 (0)