mirror of
https://github.com/august-alt/gpui.git
synced 2025-03-14 12:58:39 +03:00
Compare commits
575 Commits
0.2.0-alt5
...
master
Author | SHA1 | Date | |
---|---|---|---|
590fd624a4 | |||
|
0fcf89a56e | ||
3d461644fa | |||
|
a4e3418887 | ||
f9f3a89a19 | |||
|
05e9d713c1 | ||
|
880379fe12 | ||
|
1ed9bc7307 | ||
|
2bd46f72e7 | ||
|
989db5a752 | ||
|
9c316a77f8 | ||
|
feed81b903 | ||
|
876c340a48 | ||
|
4664941773 | ||
|
d6cc694ca8 | ||
|
54f76af358 | ||
|
c997774b35 | ||
|
024d757f97 | ||
ecbc1cbbc3 | |||
11e8095348 | |||
e9275cca3a | |||
|
6746815394 | ||
572b48b43a | |||
c60dd637d0 | |||
d8d8515b83 | |||
|
1c941347f6 | ||
3bc4a1abd8 | |||
|
721f5f764f | ||
361155f763 | |||
703563ff7b | |||
47a38be21a | |||
|
ef3db641f3 | ||
9cdd285a42 | |||
3e30fc6a15 | |||
|
c21ab68372 | ||
|
bd1640f21d | ||
|
7a078218a8 | ||
|
b79b101a43 | ||
|
7b78be2ea0 | ||
|
4af5d15a18 | ||
|
c5da19c2d4 | ||
|
71cd6973e6 | ||
|
3f13d0608c | ||
|
b0b170a9c4 | ||
|
7a667924d6 | ||
|
b2f2b02e40 | ||
|
c651dc0eb8 | ||
|
116da00491 | ||
|
37ef0bc2a5 | ||
|
9ea7f354c9 | ||
|
ea0ee4c566 | ||
|
43d4a9214a | ||
|
2f54d4955a | ||
|
9d49a58cc2 | ||
|
bbaf373dda | ||
|
572badcbcf | ||
|
7474072669 | ||
|
7d9ecaf9b3 | ||
|
a57c1c9904 | ||
|
3f8a21d360 | ||
|
0e57883d1d | ||
|
e7655efb15 | ||
|
cb6b00f180 | ||
|
e6794612de | ||
|
a33bb38d00 | ||
|
786bc372b1 | ||
|
dd4094dbd4 | ||
|
f20d43a231 | ||
|
512f19c4ec | ||
|
ea653c4013 | ||
|
d489520d30 | ||
|
2ce8fac778 | ||
|
6c53026c3c | ||
|
50d03e98a2 | ||
|
f8a0cf1a12 | ||
|
29541939a2 | ||
|
270732c429 | ||
|
28a9ba2156 | ||
|
fcc0e47f9c | ||
|
0d75f8927f | ||
|
ec545987a2 | ||
|
7c42f9b19e | ||
|
f23b5f905a | ||
|
004792536d | ||
|
65444d0218 | ||
|
5e06fff5cc | ||
|
d0e9ca45c7 | ||
|
101115b8e8 | ||
|
0cb3eb7412 | ||
|
22667dab24 | ||
|
542cc0b420 | ||
|
6c54698876 | ||
|
a9bb55ebc5 | ||
|
361d3a0944 | ||
|
915cd6a68e | ||
|
cc6efaa434 | ||
|
36da75f293 | ||
|
07b9b3b5a4 | ||
|
ac294b87e9 | ||
|
5bd75968c8 | ||
|
574e7bbe48 | ||
|
47d8c78834 | ||
|
742e30b6a4 | ||
|
0dccea4c98 | ||
|
97e22c75b5 | ||
|
6c9d4993c3 | ||
|
0638908843 | ||
|
59944735a1 | ||
|
69aaf409b5 | ||
|
68e603d4c7 | ||
|
82f40833c1 | ||
|
99caf792ff | ||
|
b56f3b2b6c | ||
|
f0c998f4f9 | ||
|
f8324b0c75 | ||
|
85d45fe0d8 | ||
|
770b326d12 | ||
|
f8df2ad964 | ||
|
517fdf5040 | ||
|
8037f35de8 | ||
|
c5a3b095d4 | ||
|
f13ddd33ad | ||
|
9a58d94c35 | ||
|
8cef289f46 | ||
|
67613c6047 | ||
|
6ca0b1e5d7 | ||
|
fec1ceb62f | ||
|
9db5f1fea5 | ||
|
df0b86ac75 | ||
|
1908488b00 | ||
|
1d36ccc503 | ||
|
fc928f54c9 | ||
|
107b270702 | ||
|
a5c5c8c9f7 | ||
|
10671172f7 | ||
|
1a6bf7bdbd | ||
|
97f3f0aef8 | ||
|
2a3de65619 | ||
|
4607d7c4fa | ||
|
e448cc35c4 | ||
|
a83ff03832 | ||
|
0fb3211b76 | ||
|
18aa62bb7a | ||
|
bcdcf6785f | ||
|
d82d055935 | ||
|
482669cb6c | ||
|
7ffdda83b5 | ||
|
010763fd72 | ||
|
16d6b29a50 | ||
|
636a6d3c7f | ||
|
0ae9861008 | ||
|
46ab925906 | ||
|
c587a4aac9 | ||
|
f00c4b3458 | ||
|
4244048b59 | ||
|
89426d98ea | ||
|
a387aa9cf7 | ||
|
974135377c | ||
|
d63a987dd5 | ||
|
9f54190fd5 | ||
|
bc00620def | ||
|
737fce25f5 | ||
|
27d7e0e19a | ||
|
36fccd01b3 | ||
|
dd3d9e9c25 | ||
|
2ae5d38b6f | ||
|
d809524132 | ||
|
b82ea3b490 | ||
|
600861c870 | ||
|
cf16d5b18a | ||
|
7030ef2eae | ||
|
5a225cd901 | ||
|
d6f0c19375 | ||
|
c72e2ffe32 | ||
|
9556de162d | ||
|
54ab6314b0 | ||
|
d182a8cc4c | ||
|
f0705aede0 | ||
|
4d72a2f91a | ||
|
5b83c5bad9 | ||
|
cb8ca9f6c3 | ||
|
2b93157be2 | ||
|
01c140957b | ||
|
62b8ec57c6 | ||
|
038aa640c0 | ||
|
f4e65035a1 | ||
|
5e4f5afbe0 | ||
|
a117f176f1 | ||
|
c28d1bcade | ||
|
4c7487dc35 | ||
|
c104378310 | ||
|
56ce03f349 | ||
|
eb4316e7da | ||
|
6e2a50de2d | ||
|
7f74dc33ed | ||
|
f52c468197 | ||
|
0ca63a56d8 | ||
|
378c994bf7 | ||
|
5111883b90 | ||
|
12c5599672 | ||
|
acd9ecb272 | ||
|
47e66146ff | ||
|
6ae7afa419 | ||
|
623848fe51 | ||
|
0afe601545 | ||
|
9eebda5cb4 | ||
|
874d5294d1 | ||
|
0aa22e6739 | ||
|
d10ea4913e | ||
|
ee85fef4fd | ||
|
c79fe9b5d2 | ||
|
be6facc00f | ||
|
6577078948 | ||
|
686fa18c8f | ||
|
425250a2df | ||
|
605945dae9 | ||
|
900b7305de | ||
|
aea8c2dbe1 | ||
|
3c0cbfe925 | ||
|
a88076439c | ||
|
c648987608 | ||
|
74020ccc6b | ||
|
be26545745 | ||
|
d0a0712d50 | ||
|
da73bf166a | ||
|
870d2ff3b9 | ||
|
e82e71e462 | ||
|
803a32ee5c | ||
|
df481efbea | ||
|
d2f03eb120 | ||
|
d1a3e0f765 | ||
854dc23085 | |||
|
49fea6c996 | ||
|
e951a732e1 | ||
|
76eb93d6d3 | ||
|
0b2c794d1e | ||
|
f364ccdfe1 | ||
|
38c226cc2d | ||
|
78a9bc093a | ||
|
e06b09dc50 | ||
|
9056c671b7 | ||
|
fa48996c3f | ||
|
d9a447f1e9 | ||
|
b2235289a5 | ||
|
2ea72f3227 | ||
|
830cc8dce2 | ||
|
ffa0adf908 | ||
|
47c9920534 | ||
|
d6152522cf | ||
|
2e7c75801d | ||
|
317eed72d8 | ||
|
9dda37fdf8 | ||
|
90545e20b9 | ||
|
6224f271de | ||
|
b66244ec0e | ||
|
8507cd2180 | ||
|
df55769f5e | ||
|
f57e0bd625 | ||
|
285c3e26f4 | ||
|
6ebb83071a | ||
|
8e2506c809 | ||
|
61e012af17 | ||
|
61364b4b84 | ||
|
1a60a3f294 | ||
|
68ff6ed8fe | ||
|
bd5ad52005 | ||
|
e0668d49df | ||
|
3077e6cf9e | ||
|
d80572515f | ||
|
7ac6ac1d9e | ||
|
b23c3bec77 | ||
|
5eedc5d9cf | ||
|
2a1a199a7b | ||
|
e31675899c | ||
|
5fabded652 | ||
|
d6f7a69889 | ||
|
2a199fa817 | ||
|
689d06bb51 | ||
|
1b65f4ad70 | ||
|
26e6d1d112 | ||
|
f9264fdaa2 | ||
|
fc90e275bd | ||
|
3bb8acda2a | ||
|
cf901b77ca | ||
|
e601430ce1 | ||
|
fb366bed62 | ||
|
48480a4075 | ||
|
a17235d53e | ||
|
0e9f1ffa1b | ||
|
dfeb6cca52 | ||
|
e705406743 | ||
|
b3631ee6f3 | ||
|
de3d75daf6 | ||
|
0c1806a5f3 | ||
|
c666d54533 | ||
|
0ec7439bbb | ||
|
5bb056cc53 | ||
|
9dd106ccb0 | ||
|
f162e30770 | ||
|
fff597fd53 | ||
|
26e665752f | ||
|
783a1440c9 | ||
|
9b6fcc5add | ||
|
b0a78b4c63 | ||
|
0ae5a7bfea | ||
|
cadd5d048f | ||
|
e000044202 | ||
|
5f8c82e3d5 | ||
|
f1bff99f44 | ||
|
275ae12822 | ||
|
318908721a | ||
|
fb5e640f05 | ||
|
f013cdb407 | ||
|
ad20e8db2e | ||
|
deadc04ba1 | ||
|
fefe8dea08 | ||
|
3b75a7fae4 | ||
|
edcb547d7c | ||
|
3d5015953d | ||
|
ff91ace771 | ||
|
acb363a231 | ||
|
270cecc60a | ||
|
2febea95dd | ||
|
8e362afdd6 | ||
|
e7f63b7181 | ||
|
1483cd32f7 | ||
|
88a462d309 | ||
|
86a4354abf | ||
|
945c25454a | ||
|
038325da46 | ||
|
93b6fb96db | ||
|
44ce73e828 | ||
|
8545f16a1d | ||
|
ed028ae035 | ||
|
7808ced8de | ||
|
add47ed7e1 | ||
|
f31ef90447 | ||
|
64cf951568 | ||
|
511f603997 | ||
|
bd3d7a0d5c | ||
|
7ab9634089 | ||
|
d58bf70f02 | ||
|
e50445f1e1 | ||
|
1b49890f9a | ||
|
dfc48059a9 | ||
|
1d1dbde398 | ||
|
3b76432064 | ||
|
7ec486a5bb | ||
|
232933d183 | ||
|
2075b36743 | ||
|
89f24f41b2 | ||
|
261b748d05 | ||
|
6c7af51291 | ||
|
ed2630344f | ||
|
05aac973c6 | ||
|
afbf8a6def | ||
|
f43429fb81 | ||
|
3401d48931 | ||
|
e5e0173559 | ||
|
bf5c3b2d27 | ||
|
407b77c184 | ||
|
45e34b2f82 | ||
|
c55186fda4 | ||
|
17e819a021 | ||
|
c5bc4c500f | ||
|
1225a7b006 | ||
|
1807308b70 | ||
|
89e793315b | ||
|
a7a7f2bd6b | ||
|
4b92ed680d | ||
|
602f8375f9 | ||
|
0e5172b641 | ||
|
e20903a71c | ||
|
0c8de12b61 | ||
|
1c5fda6c16 | ||
|
0435370b1e | ||
|
e07ed2f93d | ||
|
59091f4e38 | ||
|
5451c29442 | ||
|
dc3e667e2f | ||
4d8dcfb0b3 | |||
|
3d9ebb93bb | ||
|
16f168a4af | ||
|
4f3466bdc3 | ||
|
59a8f9d64f | ||
|
4bb2e4db04 | ||
|
e6489c0597 | ||
|
01ec337039 | ||
|
a4feec6b62 | ||
|
f3f0d78102 | ||
|
f68246190f | ||
|
deb384c9bb | ||
|
5702d4c6e4 | ||
|
88f2537bad | ||
|
dbef2f44ad | ||
|
3c203b20cb | ||
|
f4a9502b8c | ||
|
117868d273 | ||
|
9bf954c494 | ||
|
f539646075 | ||
|
4734592b46 | ||
|
d8f283dbd3 | ||
|
e952f1f8a0 | ||
|
26bde93a05 | ||
|
b2e32606ff | ||
|
8152af72fc | ||
|
a259e03453 | ||
|
bc995661a8 | ||
|
a2d3be3f14 | ||
|
e5628b78f2 | ||
|
1d3cd8fb09 | ||
|
d24cc19fa4 | ||
|
f87e3fd00d | ||
|
41186d9445 | ||
|
7d15033859 | ||
|
950abd3725 | ||
|
2cbe0830c4 | ||
|
63d15eff1f | ||
|
8673e160d4 | ||
|
78ddae3973 | ||
|
e14d73416b | ||
|
272ab6c27a | ||
|
6ef6ada76b | ||
|
6e53ee1172 | ||
|
a8413a9b49 | ||
|
90b25415b5 | ||
|
c1f990bafb | ||
|
11ffc8c694 | ||
|
31cd0004f3 | ||
|
1af67d7eb7 | ||
|
506bc2ee87 | ||
|
27e6539332 | ||
|
464daeede6 | ||
|
de659359b2 | ||
|
130751a996 | ||
|
302b891b23 | ||
|
3098e19695 | ||
|
cfd6b6e43b | ||
|
67e8d4d0d3 | ||
|
8a60e96602 | ||
|
f54ae2fc87 | ||
|
7dc1f4c872 | ||
|
a40715b8d6 | ||
|
76d4015931 | ||
|
947245e024 | ||
|
5f09243ba9 | ||
|
8d0d1ff805 | ||
|
7efa4b4be9 | ||
|
057d47135d | ||
|
270fc1b79d | ||
|
33e936b3ce | ||
|
1564eaacfe | ||
|
4e94f490a9 | ||
|
c6ff20e442 | ||
|
98e631523a | ||
|
24a3e3c65b | ||
|
533fdd0c42 | ||
|
ba9f41bb83 | ||
|
c556d9aea8 | ||
|
33ffa4e0ea | ||
|
81732d1cdd | ||
|
e045273b6c | ||
|
7eb094ba89 | ||
|
8c668fb4f6 | ||
|
b81ba916b1 | ||
|
726d11955e | ||
|
5ca4d29597 | ||
|
71bf40dead | ||
|
21a2b51cfa | ||
|
a10a5459bf | ||
|
0dc478e81a | ||
|
0d40dee78e | ||
bc88165145 | |||
|
a6a1e4fd42 | ||
|
bc33886a13 | ||
|
9963b86388 | ||
|
d18694c0f6 | ||
|
5c58b2ff1d | ||
|
f759948957 | ||
|
7dbafde441 | ||
|
581fb6713a | ||
|
4b42c16a92 | ||
|
593408e962 | ||
|
061ef86676 | ||
|
39df2e6710 | ||
|
b79935c5a0 | ||
|
a0c0a16d82 | ||
|
61677e3ea8 | ||
|
70676bcb06 | ||
|
52f0484922 | ||
|
448f281eb3 | ||
|
6aa2f4b904 | ||
|
4ed90b4455 | ||
|
f725f6831e | ||
|
65f9a4f3ab | ||
|
bd7355854b | ||
|
09d9cc75fc | ||
|
461ea1e1ff | ||
|
fa0130d852 | ||
|
9b896d3d6a | ||
|
dca9586351 | ||
|
46699ad39d | ||
|
26d3316bae | ||
|
710f36215e | ||
|
c9eca449f0 | ||
|
f953ae5986 | ||
|
cc23c3767e | ||
|
02c10cd8f7 | ||
|
18a5d6f837 | ||
|
590098fdc6 | ||
|
a5b86cb1c8 | ||
|
5bdfc9eaea | ||
|
2f116aaf2e | ||
|
479f912682 | ||
|
14e177cd56 | ||
|
9bb3459cdf | ||
|
f99a9abf0b | ||
|
53a7a19e6b | ||
|
0753181b63 | ||
|
6eb0cb8389 | ||
|
a286653c74 | ||
|
1fb53f2fda | ||
|
4bb29edc83 | ||
|
e040572c6f | ||
|
615fb033f4 | ||
|
de6ba68029 | ||
|
2a22435fc0 | ||
|
91360de39e | ||
|
befaab9f6f | ||
|
3e5a41bd9d | ||
|
2cfe8c1f8c | ||
|
9a7c72d1a2 | ||
|
968cd07b91 | ||
|
923e86f721 | ||
|
371dcecf75 | ||
|
ae9c27510e | ||
|
93d1a923c9 | ||
|
f231d723f9 | ||
|
af95c5600f | ||
|
37d988b510 | ||
|
d43838cf87 | ||
|
2d17b52bd2 | ||
|
f194f02b1a | ||
|
d5f1d19c65 | ||
|
416248c732 | ||
|
f0958d562d | ||
|
fedb753e0a | ||
|
f5ae4bdde2 | ||
|
e2b79d075d | ||
|
5e37207956 | ||
|
33843ddfc2 | ||
|
692bc9ad73 | ||
|
74b745544c | ||
|
0d50def373 | ||
|
98028a1deb | ||
|
9844858b02 | ||
|
84e239cfe8 | ||
|
5cff440559 | ||
|
c8fc6f0b4b | ||
|
ab42a8dd6d | ||
|
a506a6e5b0 | ||
|
2f07f18282 | ||
|
a50b606f2a | ||
|
7d9e30a65d | ||
|
faa58f4d3f | ||
|
8f6bd33a97 | ||
|
91e7eda788 | ||
|
18770edd4b | ||
|
2f8b6d5296 | ||
|
4e56ab11f2 | ||
|
006469792c | ||
|
dfd62c0822 | ||
|
591ea078c8 | ||
|
d8e572185f | ||
|
b39e1a25d3 |
114
.clang-format
Normal file
114
.clang-format
Normal file
@ -0,0 +1,114 @@
|
||||
# Copyright (C) 2016 Olivier Goffart <ogoffart@woboq.com>
|
||||
#
|
||||
# You may use this file under the terms of the 3-clause BSD license.
|
||||
# See the file LICENSE from this package for details.
|
||||
|
||||
# This is the clang-format configuration style to be used by Qt,
|
||||
# based on the rules from https://wiki.qt.io/Qt_Coding_Style and
|
||||
# https://wiki.qt.io/Coding_Conventions
|
||||
|
||||
---
|
||||
# Webkit style was loosely based on the Qt style
|
||||
BasedOnStyle: WebKit
|
||||
|
||||
Standard: c++17
|
||||
|
||||
# Column width is limited to 100 in accordance with Qt Coding Style.
|
||||
# https://wiki.qt.io/Qt_Coding_Style
|
||||
# Note that this may be changed at some point in the future.
|
||||
ColumnLimit: 100
|
||||
# How much weight do extra characters after the line length limit have.
|
||||
# PenaltyExcessCharacter: 4
|
||||
|
||||
# Disable reflow of some specific comments
|
||||
# qdoc comments: indentation rules are different.
|
||||
# Translation comments and SPDX license identifiers are also excluded.
|
||||
CommentPragmas: "^!|^:|^ SPDX-License-Identifier:"
|
||||
|
||||
# We want a space between the type and the star for pointer types.
|
||||
PointerBindsToType: false
|
||||
|
||||
# We generally use "template <" with space.
|
||||
SpaceAfterTemplateKeyword: true
|
||||
|
||||
# We want to break before the operators, but not before a '='.
|
||||
BreakBeforeBinaryOperators: NonAssignment
|
||||
|
||||
# Braces are usually attached, but not after functions or class declarations.
|
||||
BreakBeforeBraces: Custom
|
||||
BraceWrapping:
|
||||
AfterClass: true
|
||||
AfterControlStatement: false
|
||||
AfterEnum: false
|
||||
AfterFunction: true
|
||||
AfterNamespace: false
|
||||
AfterObjCDeclaration: false
|
||||
AfterStruct: true
|
||||
AfterUnion: false
|
||||
BeforeCatch: false
|
||||
BeforeElse: false
|
||||
IndentBraces: false
|
||||
|
||||
# When constructor initializers do not fit on one line, put them each on a new line.
|
||||
ConstructorInitializerAllOnOneLineOrOnePerLine: true
|
||||
# Indent initializers by 4 spaces
|
||||
ConstructorInitializerIndentWidth: 4
|
||||
|
||||
# Indent width for line continuations.
|
||||
ContinuationIndentWidth: 8
|
||||
|
||||
# No indentation for namespaces.
|
||||
NamespaceIndentation: None
|
||||
|
||||
# Allow indentation for preprocessing directives (if/ifdef/endif). https://reviews.llvm.org/rL312125
|
||||
IndentPPDirectives: AfterHash
|
||||
# We only indent with 2 spaces for preprocessor directives
|
||||
PPIndentWidth: 2
|
||||
|
||||
# Horizontally align arguments after an open bracket.
|
||||
# The coding style does not specify the following, but this is what gives
|
||||
# results closest to the existing code.
|
||||
AlignAfterOpenBracket: true
|
||||
AlwaysBreakTemplateDeclarations: true
|
||||
|
||||
# Ideally we should also allow less short function in a single line, but
|
||||
# clang-format does not handle that.
|
||||
AllowShortFunctionsOnASingleLine: Inline
|
||||
|
||||
# The coding style specifies some include order categories, but also tells to
|
||||
# separate categories with an empty line. It does not specify the order within
|
||||
# the categories. Since the SortInclude feature of clang-format does not
|
||||
# re-order includes separated by empty lines, the feature is not used.
|
||||
SortIncludes: false
|
||||
|
||||
# macros for which the opening brace stays attached.
|
||||
ForEachMacros: [ foreach, Q_FOREACH, BOOST_FOREACH, forever, Q_FOREVER, QBENCHMARK, QBENCHMARK_ONCE ]
|
||||
|
||||
# Break constructor initializers before the colon and after the commas.
|
||||
BreakConstructorInitializers: BeforeColon
|
||||
|
||||
# Add "// namespace <namespace>" comments on closing brace for a namespace
|
||||
# Ignored for namespaces that qualify as a short namespace,
|
||||
# see 'ShortNamespaceLines'
|
||||
FixNamespaceComments: true
|
||||
|
||||
# Definition of how short a short namespace is, default 1
|
||||
ShortNamespaceLines: 1
|
||||
|
||||
# When escaping newlines in a macro attach the '\' as far left as possible, e.g.
|
||||
##define a \
|
||||
# something; \
|
||||
# other; \
|
||||
# thelastlineislong;
|
||||
AlignEscapedNewlines: Left
|
||||
|
||||
# Avoids the addition of a space between an identifier and the
|
||||
# initializer list in list-initialization.
|
||||
SpaceBeforeCpp11BracedList: false
|
||||
|
||||
---
|
||||
# Use the Google-based style for .proto files.
|
||||
Language: Proto
|
||||
BasedOnStyle: Google
|
||||
IndentWidth: 4
|
||||
ColumnLimit: 100
|
453
.gear/gpui.spec
453
.gear/gpui.spec
@ -1,8 +1,8 @@
|
||||
%define _unpackaged_files_terminate_build 1
|
||||
|
||||
Name: gpui
|
||||
Version: 0.2.0
|
||||
Release: alt5
|
||||
Version: 0.2.55
|
||||
Release: alt1
|
||||
|
||||
Summary: Group policy editor
|
||||
License: GPLv2+
|
||||
@ -18,13 +18,28 @@ BuildRequires: qt5-declarative-devel
|
||||
BuildRequires: qt5-tools-devel
|
||||
BuildRequires: libsmbclient-devel libsmbclient
|
||||
|
||||
BuildRequires: samba-devel
|
||||
BuildRequires: libldap-devel
|
||||
BuildRequires: libsasl2-devel
|
||||
BuildRequires: libsmbclient-devel
|
||||
BuildRequires: libuuid-devel
|
||||
BuildRequires: glib2-devel
|
||||
BuildRequires: libpcre-devel
|
||||
BuildRequires: libkrb5-devel
|
||||
BuildRequires: libgtest-devel
|
||||
|
||||
BuildRequires: qt5-base-common
|
||||
BuildRequires: doxygen
|
||||
BuildRequires: libxerces-c-devel
|
||||
BuildRequires: xsd
|
||||
BuildRequires: boost-devel-headers
|
||||
|
||||
BuildRequires: desktop-file-utils ImageMagick-tools
|
||||
|
||||
BuildRequires: libqt-mvvm-devel
|
||||
|
||||
BuildRequires: xorg-xvfb xvfb-run
|
||||
|
||||
Requires: admx-basealt
|
||||
|
||||
Source0: %name-%version.tar
|
||||
@ -53,28 +68,36 @@ for size in 48 64 128 256 512; do
|
||||
%buildroot%_datadir/icons/hicolor/''${size}x''${size}/apps/gpui.png
|
||||
done
|
||||
|
||||
install -v -p -m 644 -D ../setup/man/en/gpui.1 %buildroot%_man1dir/gpui.1
|
||||
install -v -p -m 644 -D ../setup/man/ru/gpui.1 %buildroot%_mandir/ru/man1/gpui.1
|
||||
|
||||
export LD_LIBRARY_PATH=${LD_LIBRARY_PATH}:%_libdir/gpui/plugins/
|
||||
|
||||
LD_PRELOAD=%buildroot%_libdir/gpui/plugins/libadministrative-templates-plugin.so
|
||||
|
||||
%files
|
||||
%doc README.md
|
||||
%doc INSTALL.md
|
||||
%_bindir/gpui-main
|
||||
|
||||
%_libdir/libgpui-core.so
|
||||
%_libdir/libgpui-gui.so
|
||||
%_libdir/libgpui-io.so
|
||||
%_libdir/libgpui-model.so
|
||||
%_libdir/libgpui-ldap.so
|
||||
|
||||
%_libdir/gpui/plugins/libadministrative-templates-plugin.so
|
||||
%_libdir/gpui/plugins/libpreferences-plugin.so
|
||||
|
||||
%_libdir/gpui/plugins/libadml-plugin.so
|
||||
%_libdir/gpui/plugins/libadmx-plugin.so
|
||||
%_libdir/gpui/plugins/libcmtl-plugin.so
|
||||
%_libdir/gpui/plugins/libcmtx-plugin.so
|
||||
%_libdir/gpui/plugins/libinifile-plugin.so
|
||||
%_libdir/gpui/plugins/libinifile-ascii-plugin.so
|
||||
%_libdir/gpui/plugins/libreg-plugin.so
|
||||
%_libdir/gpui/plugins/libspol-plugin.so
|
||||
%_libdir/gpui/plugins/libpol-plugin.so
|
||||
|
||||
%_libdir/gpui/plugins/libdrives-plugin.so
|
||||
%_libdir/gpui/plugins/libfiles-plugin.so
|
||||
%_libdir/gpui/plugins/libfolders-plugin.so
|
||||
%_libdir/gpui/plugins/libini-plugin.so
|
||||
%_libdir/gpui/plugins/libshares-plugin.so
|
||||
%_libdir/gpui/plugins/libshortcuts-plugin.so
|
||||
%_libdir/gpui/plugins/libvariables-plugin.so
|
||||
%_libdir/gpui/plugins/libscripts-plugin.so
|
||||
|
||||
%_libdir/gpui/plugins/libsmb-storage-plugin.so
|
||||
|
||||
@ -86,7 +109,415 @@ done
|
||||
|
||||
%_desktopdir/gpui.desktop
|
||||
|
||||
%_man1dir/gpui.*
|
||||
%_mandir/ru/man1/gpui.*
|
||||
|
||||
%changelog
|
||||
* Fri Oct 11 2024 Vladimir Rubanov <august@altlinux.org> 0.2.55-alt1
|
||||
- 0.2.54-alt1
|
||||
- Fixes:
|
||||
+ Fix list values dialog (Closes: 51681).
|
||||
|
||||
* Mon Oct 4 2024 Vladimir Rubanov <august@altlinux.org> 0.2.54-alt1
|
||||
- 0.2.54-alt1
|
||||
- Fixes:
|
||||
+ Fix list values saving in administrative templates (Closes: 51587).
|
||||
|
||||
* Mon Sep 16 2024 Vladimir Rubanov <august@altlinux.org> 0.2.53-alt1
|
||||
- 0.2.53-alt1
|
||||
- Fixes:
|
||||
+ Fix add ascii ini file plugin (Closes: 51451, 51466, 47576).
|
||||
|
||||
* Fri Sep 13 2024 Vladimir Rubanov <august@altlinux.org> 0.2.52-alt1
|
||||
- 0.2.52-alt1
|
||||
- Fixes:
|
||||
+ Fix comment path on smb share.
|
||||
+ Fix group policy template name.
|
||||
|
||||
* Fri Sep 13 2024 Vladimir Rubanov <august@altlinux.org> 0.2.51-alt1
|
||||
- 0.2.51-alt1
|
||||
- Fixes:
|
||||
+ Fix group policy template name in scripts dialog.
|
||||
|
||||
* Mon Sep 2 2024 Vladimir Rubanov <august@altlinux.org> 0.2.50-alt1
|
||||
- 0.2.50-alt1
|
||||
- Fixes:
|
||||
+ Fix group policy template version update.
|
||||
|
||||
* Wed Aug 28 2024 Vladimir Rubanov <august@altlinux.org> 0.2.49-alt1
|
||||
- 0.2.49-alt1
|
||||
- Fixes:
|
||||
+ Add support for smb located comments.
|
||||
|
||||
* Tue Aug 20 2024 Vladimir Rubanov <august@altlinux.org> 0.2.48-alt1
|
||||
- 0.2.48-alt1
|
||||
- Fixes:
|
||||
+ Fix order of pol instructions in internal storage.
|
||||
+ Fix list based policies (Closes: 50123).
|
||||
+ Fix comment values (Closes: 47576).
|
||||
+ Fix script settings description (Closes: 49099).
|
||||
|
||||
* Tue Aug 6 2024 Vladimir Rubanov <august@altlinux.org> 0.2.47-alt1
|
||||
- 0.2.47-alt1
|
||||
- Fixes:
|
||||
+ Fix pol parser validation.
|
||||
|
||||
* Tue Aug 6 2024 Vladimir Rubanov <august@altlinux.org> 0.2.46-alt1
|
||||
- 0.2.46-alt1
|
||||
- Fixes:
|
||||
+ Fix saving of square brakets in pol file (Closes: 50706).
|
||||
+ Fix checkbox based policies (Closes: 48970, 47742).
|
||||
|
||||
* Fri Jun 6 2024 Vladimir Rubanov <august@altlinux.org> 0.2.45-alt1
|
||||
- 0.2.45-alt1
|
||||
- Fixes:
|
||||
+ Fix creation of gpt.ini while saving.
|
||||
|
||||
* Fri Apr 1 2024 Vladimir Rubanov <august@altlinux.org> 0.2.44-alt1
|
||||
- 0.2.44-alt1
|
||||
- Fixes:
|
||||
+ Fix admx-firefox elements order (Closes: 47727).
|
||||
+ Fix memory leak in ini plugin.
|
||||
+ Fix file widget in preferences plugin.
|
||||
|
||||
* Fri Mar 15 2024 Vladimir Rubanov <august@altlinux.org> 0.2.43-alt1
|
||||
- 0.2.43-alt1
|
||||
- Fixes:
|
||||
+ Fix build with samba 4.20.rc4.
|
||||
|
||||
* Wed Mar 6 2024 Vladimir Rubanov <august@altlinux.org> 0.2.42-alt1
|
||||
- 0.2.42-alt1
|
||||
- Features:
|
||||
+ Add environment variables dialog to preferences.
|
||||
|
||||
* Tue Feb 29 2024 Vladimir Rubanov <august@altlinux.org> 0.2.41-alt1
|
||||
- 0.2.41-alt1
|
||||
- Features:
|
||||
+ Add edit entry to preferences context menu (Closes: 49098).
|
||||
- Fixes:
|
||||
+ Fix admx-firefox elements order (Closes: 44507).
|
||||
+ Fix text elements order (Closes: 49053).
|
||||
|
||||
* Tue Dec 26 2023 Vladimir Rubanov <august@altlinux.org> 0.2.40-alt1
|
||||
- 0.2.40-alt1
|
||||
- Fixes:
|
||||
+ Fix replace path with name in script dialog.
|
||||
|
||||
* Mon Dec 25 2023 Vladimir Rubanov <august@altlinux.org> 0.2.39-alt1
|
||||
- 0.2.39-alt1
|
||||
- Fixes:
|
||||
+ Fix add script dialog.
|
||||
+ Fix script's folder creation.
|
||||
|
||||
* Fri Oct 13 2023 Vladimir Rubanov <august@altlinux.org> 0.2.38-alt1
|
||||
- 0.2.38-alt1
|
||||
- Fixes:
|
||||
+ Fix ldap guid path.
|
||||
|
||||
* Fri Oct 13 2023 Vladimir Rubanov <august@altlinux.org> 0.2.37-alt1
|
||||
- 0.2.37-alt1
|
||||
- Fixes:
|
||||
+ Fix "both" policy type.
|
||||
+ Fix extensions guid in gpc.
|
||||
|
||||
* Mon Oct 09 2023 Vladimir Rubanov <august@altlinux.org> 0.2.36-alt1
|
||||
- 0.2.36-alt1
|
||||
- Fixes:
|
||||
+ Emergency fix for invalid pol files.
|
||||
|
||||
* Thu Oct 05 2023 Vladimir Rubanov <august@altlinux.org> 0.2.35-alt1
|
||||
- 0.2.35-alt1
|
||||
- Fixes:
|
||||
+ Fix subsequent deletion of multiple elements in scripts dialog (Closes: 47553).
|
||||
+ Fix desktop file entry.
|
||||
+ Fix add folder name to script path.
|
||||
|
||||
* Mon Sep 04 2023 Vladimir Rubanov <august@altlinux.org> 0.2.34-alt1
|
||||
- 0.2.34-alt1
|
||||
- Fixes:
|
||||
+ Fix translations language list (Closes: 47437).
|
||||
+ Fix translations for comment in administrative templates plugin (Fixes: 109650).
|
||||
+ Fix scripts encoding to UTF-16LE.
|
||||
+ Remove browse button from add script widget.
|
||||
|
||||
* Fri Sep 01 2023 Vladimir Rubanov <august@altlinux.org> 0.2.33-alt1
|
||||
- 0.2.33-alt1
|
||||
- Fixes:
|
||||
+ Fix translations for path and parameters in scripts plugin (Closes: 47133).
|
||||
+ Fix show files button in scripts plugin (Closes: 47136).
|
||||
+ Fix list parameters in administrative templates plugin (Closes: 47137).
|
||||
- Features:
|
||||
+ New logging system.
|
||||
|
||||
* Fri Jul 21 2023 Vladimir Rubanov <august@altlinux.org> 0.2.32-alt1
|
||||
- 0.2.32-alt1
|
||||
- Features:
|
||||
+ Implement support of platforms in filter dialog.
|
||||
|
||||
* Wed Jul 19 2023 Vladimir Rubanov <august@altlinux.org> 0.2.31-alt1
|
||||
- 0.2.31-alt1
|
||||
- Fixes:
|
||||
+ Fix scripts plugin.
|
||||
|
||||
* Fri Jul 14 2023 Vladimir Rubanov <august@altlinux.org> 0.2.30-alt1
|
||||
- 0.2.30-alt1
|
||||
- Fixes:
|
||||
+ Fix comments plugin.
|
||||
|
||||
* Thu Jul 13 2023 Vladimir Rubanov <august@altlinux.org> 0.2.29-alt1
|
||||
- 0.2.29-alt1
|
||||
- Fixes:
|
||||
+ Add comments support.
|
||||
|
||||
* Wed Jun 21 2023 Vladimir Rubanov <august@altlinux.org> 0.2.28-alt1
|
||||
- 0.2.28-alt1
|
||||
- Fixes:
|
||||
+ Fix update of administrative templates filter dialog.
|
||||
|
||||
* Tue Jun 20 2023 Vladimir Rubanov <august@altlinux.org> 0.2.27-alt1
|
||||
- 0.2.27-alt1
|
||||
- Features:
|
||||
+ Implement administrative templates filter dialog.
|
||||
|
||||
* Wed Jun 07 2023 Vladimir Rubanov <august@altlinux.org> 0.2.26-alt1
|
||||
- 0.2.26-alt1
|
||||
- Fixes:
|
||||
+ Fix policies with value name only. (Closes: 46082).
|
||||
+ Fix namespaces. (Closes: 46282).
|
||||
|
||||
* Fri May 19 2023 Vladimir Rubanov <august@altlinux.org> 0.2.25-alt1
|
||||
- 0.2.25-alt1
|
||||
- Fixes:
|
||||
+ Fix application launch without arguments (Closes: 46189).
|
||||
|
||||
* Tue Apr 11 2023 Vladimir Rubanov <august@altlinux.org> 0.2.24-alt1
|
||||
- 0.2.24-alt1
|
||||
- Fixes:
|
||||
+ Fix laguage loading in plugins.
|
||||
+ Fix tests.
|
||||
|
||||
* Wed Apr 05 2023 Vladimir Rubanov <august@altlinux.org> 0.2.23-alt1
|
||||
- 0.2.23-alt1
|
||||
- Fixes:
|
||||
+ Fix support for files without extensions in files preference.
|
||||
|
||||
* Wed Mar 29 2023 Vladimir Rubanov <august@altlinux.org> 0.2.22-alt1
|
||||
- 0.2.22-alt1
|
||||
- Fixes:
|
||||
+ Fix policy path in scripts plugin.
|
||||
|
||||
* Mon Mar 27 2023 Vladimir Rubanov <august@altlinux.org> 0.2.21-alt1
|
||||
- 0.2.21-alt1
|
||||
- Fixes:
|
||||
+ Add button to clear key sequence in shortcuts widget.
|
||||
+ Fix typos in folder preferences.
|
||||
+ Fix writing script to smb shares.
|
||||
|
||||
* Sun Mar 05 2023 Vladimir Rubanov <august@altlinux.org> 0.2.20-alt1
|
||||
- 0.2.20-alt1
|
||||
- Fixes:
|
||||
+ Fix policy's key search for lists in administrative templates.
|
||||
|
||||
* Sun Mar 05 2023 Vladimir Rubanov <august@altlinux.org> 0.2.19-alt1
|
||||
- 0.2.19-alt1
|
||||
- Fixes:
|
||||
+ Replace std::regex with QRegularExpression in scripts module.
|
||||
|
||||
* Thu Jan 19 2023 Vladimir Rubanov <august@altlinux.org> 0.2.18-alt1
|
||||
- 0.2.18-alt1
|
||||
- Features:
|
||||
+ Implement scripts module.
|
||||
|
||||
* Thu Jan 19 2023 Vladimir Rubanov <august@altlinux.org> 0.2.17-alt18
|
||||
- 0.2.17-alt18
|
||||
- Fixes:
|
||||
+ Fix input in section field in ini widget on delete action.
|
||||
+ Fix set default setting to true for user context in user policies.
|
||||
|
||||
* Thu Jan 12 2023 Vladimir Rubanov <august@altlinux.org> 0.2.17-alt17
|
||||
- 0.2.17-alt17
|
||||
- Fixes:
|
||||
+ #91098 Fix translations for shortcuts widget on KDE systems.
|
||||
|
||||
* Tue Jan 10 2023 Vladimir Rubanov <august@altlinux.org> 0.2.17-alt16
|
||||
- 0.2.17-alt16
|
||||
- Fixes:
|
||||
+ #91098 Fix translations for shortcuts widget.
|
||||
+ #88126 Implement shortcuts key sequence encoding.
|
||||
|
||||
* Wed Dec 28 2022 Vladimir Rubanov <august@altlinux.org> 0.2.17-alt15
|
||||
- 0.2.17-alt15
|
||||
- Fixes:
|
||||
+ #91635 Fix e2k preferences build.
|
||||
+ #91629 Fix translations on e2kv4.
|
||||
+ #75874 Change spinbox behaviour to mimic windows behaviour.
|
||||
+ #89621 Fix typo in ini widget.
|
||||
+ #91060 Fix OK and Cancel buttons to work in a message box.
|
||||
|
||||
* Mon Dec 26 2022 Vladimir Rubanov <august@altlinux.org> 0.2.17-alt14
|
||||
- 0.2.17-alt14
|
||||
- Fixes:
|
||||
+ #91097 Fix names of hidden and archive fields in folder widget.
|
||||
+ #91237 Remove sorting in table header.
|
||||
+ #90987 Fix status bar message.
|
||||
+ #91312 Add translation to '-n' command line option.
|
||||
+ #91047 Fix segmentation fault in the absence of kerberos tickets.
|
||||
|
||||
* Thu Dec 15 2022 Vladimir Rubanov <august@altlinux.org> 0.2.17-alt13
|
||||
- 0.2.17-alt13
|
||||
- Fixes:
|
||||
+ Fix presentation builder to allow build on e2k.
|
||||
|
||||
* Thu Dec 15 2022 Vladimir Rubanov <august@altlinux.org> 0.2.17-alt12
|
||||
- 0.2.17-alt12
|
||||
- Fixes:
|
||||
+ Fix e2k build.
|
||||
|
||||
* Fri Dec 09 2022 Vladimir Rubanov <august@altlinux.org> 0.2.17-alt11
|
||||
- 0.2.17-alt11
|
||||
- Fixes:
|
||||
+ #89597 Fix message box.
|
||||
+ #88897 Ask to save changes.
|
||||
+ #75885 Add sort to drop down list elements.
|
||||
+ Fix set correct resource for non existent registry.pol files.
|
||||
+ Fix copy policy to copied item.
|
||||
+ #76835 Fix policy names.
|
||||
+ #88907 Fix google chrome policies handling.
|
||||
|
||||
* Tue Dec 06 2022 Vladimir Rubanov <august@altlinux.org> 0.2.17-alt10
|
||||
- 0.2.17-alt10
|
||||
- Fixes:
|
||||
+ #89553 Switch search to be case insensitive.
|
||||
+ #89558 Fix translations of shortcuts widget.
|
||||
+ #89561 Fix russian translations in properties widget.
|
||||
+ #89621 Fix ini file's widget translations.
|
||||
+ #89692 Fix translation of shortcuts widget.
|
||||
+ #89648 Fix russian translation of shares widget.
|
||||
+ #89648 Fix russian translation of common widget.
|
||||
|
||||
* Wed Nov 30 2022 Vladimir Rubanov <august@altlinux.org> 0.2.17-alt9
|
||||
- 0.2.17-alt9
|
||||
- Fixes:
|
||||
+ Fix null pointer in ldap library.
|
||||
+ Fix invalid drive name.
|
||||
|
||||
* Tue Nov 29 2022 Vladimir Rubanov <august@altlinux.org> 0.2.17-alt8
|
||||
- 0.2.17-alt8
|
||||
- Fixes:
|
||||
+ #88602 Fix creation of network share's attributes.
|
||||
+ #88794 Fix drive map's xml structure.
|
||||
+ #44378 Allow empty section name in ini widget.
|
||||
+ #74009 Remove labels in empty widget.
|
||||
+ #88711 Modify model builder of network shares to write only required fields.
|
||||
+ #88844 Fix save of admx path setting.
|
||||
|
||||
* Wed Nov 16 2022 Vladimir Rubanov <august@altlinux.org> 0.2.17-alt7
|
||||
- 0.2.17-alt7
|
||||
- Fixes:
|
||||
+ #88813 Fix restore dependency on admx-basealt.
|
||||
+ #88495 Fix translations in environment variable widget.
|
||||
+ #88226 Fix folder creation.
|
||||
+ #88143 Fix folder attributes during deletion of folders.
|
||||
+ #88586 Fix russian translation of mapped drive context menu.
|
||||
|
||||
* Wed Nov 16 2022 Vladimir Rubanov <august@altlinux.org> 0.2.17-alt6
|
||||
- 0.2.17-alt6
|
||||
Features:
|
||||
+ Add mapped drives for computers and network shares for user.
|
||||
|
||||
* Wed Nov 16 2022 Vladimir Rubanov <august@altlinux.org> 0.2.17-alt5
|
||||
- 0.2.17-alt5
|
||||
- Fixes:
|
||||
+ #88226 Fix inability to create folders.
|
||||
+ #88226 Fix inability to create files.
|
||||
+ Restore n option.
|
||||
|
||||
* Fri Nov 11 2022 Vladimir Rubanov <august@altlinux.org> 0.2.17-alt4
|
||||
- 0.2.17-alt4
|
||||
- Features:
|
||||
+ Add custom tree view for preferences.
|
||||
|
||||
* Fri Nov 11 2022 Vladimir Rubanov <august@altlinux.org> 0.2.17-alt3
|
||||
- 0.2.17-alt3
|
||||
- Fixes:
|
||||
+ #74208 Fix group policy name.
|
||||
+ Fix translations in administrative templates plugin.
|
||||
|
||||
* Thu Nov 10 2022 Vladimir Rubanov <august@altlinux.org> 0.2.17-alt2
|
||||
- 0.2.17-alt2
|
||||
|
||||
* Thu Nov 03 2022 Vladimir Rubanov <august@altlinux.org> 0.2.17-alt1
|
||||
- 0.2.17
|
||||
|
||||
* Thu Sep 29 2022 Vladimir Rubanov <august@altlinux.org> 0.2.16-alt1
|
||||
- Fixes:
|
||||
+ #84127 Fix invalid types for list enums.
|
||||
+ #76835 Fix message on policy state change.
|
||||
|
||||
* Thu Aug 04 2022 Vladimir Rubanov <august@altlinux.org> 0.2.15-alt1
|
||||
- Fixes:
|
||||
+ #81760 Fix disabled and enabled list in policies.
|
||||
|
||||
* Mon Apr 18 2022 Vladimir Rubanov <august@altlinux.org> 0.2.14-alt1
|
||||
- Fixes:
|
||||
+ Vesioning improved.
|
||||
+ Fixed build on e2k platform.
|
||||
|
||||
* Fri Apr 04 2022 Vladimir Rubanov <august@altlinux.org> 0.2.0-alt13
|
||||
- Fixes:
|
||||
+ #75065 Add workaround for bug #75065.
|
||||
|
||||
* Fri Mar 31 2022 Vladimir Rubanov <august@altlinux.org> 0.2.0-alt12
|
||||
- Fixes:
|
||||
+ Fix -n command line option.
|
||||
|
||||
* Fri Mar 30 2022 Vladimir Rubanov <august@altlinux.org> 0.2.0-alt11
|
||||
- Fixes:
|
||||
+ #74198 Improve ability to detect policy changes and notify user about them.
|
||||
+ #74149 Fix install/removal of packages through list element.
|
||||
+ #74217 Add switch between elements through keyboard.
|
||||
+ #75076 Fix -b option.
|
||||
+ #75070 Add decimal text box minimum and maximum.
|
||||
+ #75065 Add message boxes for access errors.
|
||||
+ Fix several build issues on e2k platform.
|
||||
|
||||
* Fri Mar 25 2022 Vladimir Rubanov <august@altlinux.org> 0.2.0-alt10
|
||||
- Fixes:
|
||||
+ #74754 Fix ability to generate pol setting for "both" policy type.
|
||||
+ #74151 Fix generate Chromium/Firefox start page in pol file.
|
||||
+ #75062 Prevent doubling of items in drop list.
|
||||
+ #75058 Fix command name in manual.
|
||||
+ #75062 Remove icons from OK/Cancel buttons.
|
||||
+ #75035 Set fixed container height for label.
|
||||
|
||||
* Fri Mar 18 2022 Vladimir Rubanov <august@altlinux.org> 0.2.0-alt9
|
||||
- Fixes:
|
||||
+ Fix segmentation fault on selecting new policy item.
|
||||
+ Fix translation of message box window.
|
||||
|
||||
* Wed Mar 16 2022 Vladimir Rubanov <august@altlinux.org> 0.2.0-alt8
|
||||
- Fixes:
|
||||
+ #74163 Fix segmentation fault on selecting item in "security category".
|
||||
+ #74704 Fix window resize on label resize.
|
||||
+ #74050 Fix cancel buttons translation.
|
||||
+ #74050 Man was added.
|
||||
|
||||
* Mon Mar 14 2022 Vladimir Rubanov <august@altlinux.org> 0.2.0-alt7
|
||||
- Fixes:
|
||||
+ #74215 Add message for the change of policy's state.
|
||||
+ #74217 Add ability to select policies with keyboard.
|
||||
+ #74208 Add policy name label.
|
||||
+ #74172 Make list dialog modal.
|
||||
+ #74005 Remove empty folders from tree view.
|
||||
+ #74015 Add ability to resize right frame.
|
||||
+ #74028 Remove --help-all command argument.
|
||||
+ #74046 Improve sort order of tree view.
|
||||
+ #74054 Fix ability to save integer values.
|
||||
|
||||
* Tue Mar 01 2022 Vladimir Rubanov <august@altlinux.org> 0.2.0-alt6
|
||||
- Fixes:
|
||||
+ #74114 Fix ability to load ADMX bundle.
|
||||
|
||||
* Mon Feb 28 2022 Vladimir Rubanov <august@altlinux.org> 0.2.0-alt5
|
||||
- Fixes:
|
||||
+ #73976 Correct dialog flags to provide ability to select folders.
|
||||
|
42
.github/workflows/build-container.yml
vendored
Normal file
42
.github/workflows/build-container.yml
vendored
Normal file
@ -0,0 +1,42 @@
|
||||
name: gpui-build-container
|
||||
|
||||
on:
|
||||
workflow_call:
|
||||
inputs:
|
||||
distr:
|
||||
description: "Linux distribution"
|
||||
type: string
|
||||
required: true
|
||||
architecture:
|
||||
description: "Architecture"
|
||||
type: string
|
||||
required: true
|
||||
|
||||
jobs:
|
||||
gpui-build-container:
|
||||
runs-on: ubuntu-latest
|
||||
|
||||
steps:
|
||||
- name: Checkout
|
||||
if: github.ref == 'refs/heads/master'
|
||||
uses: actions/checkout@v3
|
||||
|
||||
- name: Login to GitHub Container Registry
|
||||
if: github.ref == 'refs/heads/master'
|
||||
run: |
|
||||
docker login ghcr.io -u ${{ github.actor }} -p ${{ secrets.github_token }}
|
||||
|
||||
- name: Build container
|
||||
if: github.ref == 'refs/heads/master'
|
||||
run: |
|
||||
docker buildx build -t ghcr.io/${{ github.repository }}-${{ inputs.architecture }}:${{ github.run_number }} \
|
||||
-t ghcr.io/${{ github.repository }}-${{ inputs.architecture }}:latest \
|
||||
--cache-from type=gha,scope=$GITHUB_REF_NAME-${{ inputs.architecture }}-image \
|
||||
--cache-to type=gha,mode=max,scope=$GITHUB_REF_NAME-${{ inputs.architecture }}-image \
|
||||
--build-arg DISTR=${{ inputs.distr }} --build-arg ARCH=${{ inputs.architecture }} \
|
||||
--build-arg USER_ID=$(id -u) --build-arg GROUP_ID=$(id -g) --platform ${{ inputs.architecture }} .
|
||||
|
||||
- name: Push container
|
||||
if: github.ref == 'refs/heads/master'
|
||||
run: |
|
||||
docker push -a ghcr.io/${{ github.repository }}-${{ inputs.architecture }}
|
41
.github/workflows/build.yml
vendored
Normal file
41
.github/workflows/build.yml
vendored
Normal file
@ -0,0 +1,41 @@
|
||||
name: gpui-build
|
||||
|
||||
on:
|
||||
workflow_call:
|
||||
inputs:
|
||||
artifact:
|
||||
description: "Artifact"
|
||||
type: string
|
||||
required: true
|
||||
architecture:
|
||||
description: "Architecture"
|
||||
type: string
|
||||
required: true
|
||||
|
||||
jobs:
|
||||
gpui-build:
|
||||
runs-on: ubuntu-latest
|
||||
|
||||
steps:
|
||||
- name: Checkout
|
||||
uses: actions/checkout@v3
|
||||
|
||||
- name: Build GPUI packages
|
||||
run: |
|
||||
docker pull --platform linux/${{ inputs.architecture }} \
|
||||
ghcr.io/${{ github.repository }}-${{ inputs.architecture }}:latest
|
||||
docker run --privileged=true --name gpui-build-${{ inputs.architecture }} -i --log-driver=none \
|
||||
-a stdin -a stdout -a stderr -v "$(pwd)":/app --platform linux/${{ inputs.architecture }} \
|
||||
ghcr.io/${{ github.repository }}-${{ inputs.architecture }}:latest
|
||||
|
||||
- name: Extract fresh packages
|
||||
if: github.ref == 'refs/heads/master'
|
||||
run: |
|
||||
docker cp gpui-build-${{ inputs.architecture }}:/home/builder2/RPM/RPMS/ "$(pwd)/packages"
|
||||
|
||||
- name: Upload fresh RPM packages
|
||||
if: github.ref == 'refs/heads/master'
|
||||
uses: actions/upload-artifact@v3
|
||||
with:
|
||||
name: gpui-${{ inputs.artifact }}-${{ inputs.architecture }}
|
||||
path: ${{ github.workspace }}/packages
|
55
.github/workflows/codeql-analysis.yml
vendored
55
.github/workflows/codeql-analysis.yml
vendored
@ -1,43 +1,40 @@
|
||||
name: "CodeQL"
|
||||
name: gpui-codeql-analysis
|
||||
|
||||
on: [ push, pull_request ]
|
||||
on:
|
||||
workflow_call:
|
||||
inputs:
|
||||
architecture:
|
||||
description: "Architecture"
|
||||
type: string
|
||||
required: true
|
||||
|
||||
jobs:
|
||||
analyze:
|
||||
name: Analyze
|
||||
runs-on: ubuntu-latest
|
||||
container: alt:p9
|
||||
gpui-codeql-analysis:
|
||||
runs-on: ubuntu-20.04
|
||||
container: ghcr.io/${{ github.repository }}-${{ inputs.architecture }}:latest
|
||||
|
||||
permissions:
|
||||
actions: read
|
||||
contents: read
|
||||
security-events: write
|
||||
|
||||
strategy:
|
||||
fail-fast: false
|
||||
matrix:
|
||||
language: [ 'cpp' ]
|
||||
|
||||
steps:
|
||||
- name: Checkout repository
|
||||
uses: actions/checkout@v2
|
||||
- name: Checkout repository
|
||||
uses: actions/checkout@v3
|
||||
|
||||
- name: Initialize CodeQL
|
||||
uses: github/codeql-action/init@v1
|
||||
with:
|
||||
languages: ${{ matrix.language }}
|
||||
- name: Initialize CodeQL
|
||||
uses: github/codeql-action/init@v2
|
||||
with:
|
||||
languages: cpp
|
||||
|
||||
- name: Update software
|
||||
run: apt-get update
|
||||
- name: Configure cmake
|
||||
run: cmake -B build .
|
||||
|
||||
- name: Install software
|
||||
run: apt-get install -y git cmake rpm-macros-cmake cmake-modules gcc-c++ qt5-base-devel qt5-tools-devel qt5-base-common doxygen libxerces-c-devel xsd rpm-build
|
||||
- name: Build
|
||||
run: |
|
||||
cd build
|
||||
make -j `nproc`
|
||||
make test
|
||||
|
||||
- name: Configure cmake
|
||||
run: mkdir build && cd build && cmake -DCMAKE_C_COMPILER=`which gcc` -DCMAKE_CXX_COMPILER=`which g++` -DCMAKE_MAKE_PROGRAM=`which make` ..
|
||||
|
||||
- name: Make software
|
||||
run: cd build && make -j `nproc`
|
||||
|
||||
- name: Perform CodeQL Analysis
|
||||
uses: github/codeql-action/analyze@v1
|
||||
- name: Perform CodeQL Analysis
|
||||
uses: github/codeql-action/analyze@v2
|
||||
|
68
.github/workflows/main.yml
vendored
68
.github/workflows/main.yml
vendored
@ -1,29 +1,55 @@
|
||||
name: GPUI CI
|
||||
name: gpui-ci
|
||||
|
||||
on: [ push, pull_request ]
|
||||
on:
|
||||
workflow_dispatch:
|
||||
workflow_call:
|
||||
push:
|
||||
branches: [ "*" ]
|
||||
pull_request:
|
||||
types: [ opened, synchronize, ready_for_review ]
|
||||
|
||||
concurrency:
|
||||
group: ${{ github.workflow }}-${{ github.ref }}
|
||||
cancel-in-progress: true
|
||||
|
||||
jobs:
|
||||
build:
|
||||
runs-on: ubuntu-latest
|
||||
name: Build software using docker
|
||||
gpui-build-container:
|
||||
uses: ./.github/workflows/build-container.yml
|
||||
secrets: inherit
|
||||
strategy:
|
||||
matrix:
|
||||
alt-version: [ { dist: "alt:p10", artifact: "p10" } ]
|
||||
architecture: [ amd64 ]
|
||||
os: [ { distr: "alt:sisyphus", artifact: "sisyphus" } ]
|
||||
architecture: [ amd64, i386 ]
|
||||
with:
|
||||
distr: ${{ matrix.os.distr }}
|
||||
architecture: ${{ matrix.architecture }}
|
||||
|
||||
steps:
|
||||
- name: Checkout
|
||||
uses: actions/checkout@v2
|
||||
gpui-build:
|
||||
uses: ./.github/workflows/build.yml
|
||||
needs: [ gpui-build-container ]
|
||||
secrets: inherit
|
||||
strategy:
|
||||
matrix:
|
||||
os: [ { distr: "alt:sisyphus", artifact: "sisyphus" } ]
|
||||
architecture: [ amd64, i386 ]
|
||||
fail-fast: false
|
||||
with:
|
||||
artifact: ${{ matrix.os.artifact }}
|
||||
architecture: ${{ matrix.architecture }}
|
||||
|
||||
- run: docker build . --file Dockerfile --tag build-environment --build-arg USER_ID=$(id -u) --build-arg GROUP_ID=$(id -g) --build-arg DISTR=${{ matrix.alt-version.dist }} --build-arg ARCH=${{ matrix.architecture }}
|
||||
gpui-test:
|
||||
uses: ./.github/workflows/test.yml
|
||||
needs: [ gpui-build-container ]
|
||||
secrets: inherit
|
||||
strategy:
|
||||
matrix:
|
||||
cpp-compiler: [ "gcc", "clang" ]
|
||||
fail-fast: false
|
||||
with:
|
||||
architecture: "amd64"
|
||||
cpp-compiler: ${{ matrix.cpp-compiler }}
|
||||
|
||||
- if: ${{ matrix.architecture == 'i386' }}
|
||||
run: docker run --privileged=true -i --log-driver=none -a stdin -a stdout -a stderr -v "$(pwd)":/app build-environment --platform linux/i386
|
||||
|
||||
- if: ${{ matrix.architecture == 'amd64' }}
|
||||
run: docker run --privileged=true -i --log-driver=none -a stdin -a stdout -a stderr -v "$(pwd)":/app build-environment
|
||||
|
||||
- uses: actions/upload-artifact@v2
|
||||
with:
|
||||
name: gpui-${{ matrix.alt-version.artifact }}-${{ matrix.architecture }}
|
||||
path: RPMS/
|
||||
gpui-publish-api-docs:
|
||||
uses: ./.github/workflows/publish-api-docs.yml
|
||||
needs: [ gpui-build, gpui-test ]
|
||||
secrets: inherit
|
||||
|
57
.github/workflows/publish-api-docs.yml
vendored
57
.github/workflows/publish-api-docs.yml
vendored
@ -1,42 +1,39 @@
|
||||
name: publish-api-doc
|
||||
name: gpui-publish-api-doc
|
||||
|
||||
on:
|
||||
push:
|
||||
branches:
|
||||
- master
|
||||
on: [ workflow_call, workflow_dispatch ]
|
||||
|
||||
jobs:
|
||||
api-doc:
|
||||
gpui-publish-api-doc:
|
||||
runs-on: ubuntu-latest
|
||||
if: github.ref == 'refs/heads/master'
|
||||
|
||||
steps:
|
||||
- name: Git Checkout
|
||||
uses: actions/checkout@v2
|
||||
- name: Git Checkout
|
||||
uses: actions/checkout@v3
|
||||
|
||||
- name: Create clean documentation branch
|
||||
run: git checkout -b documentation
|
||||
- name: Create clean documentation branch
|
||||
run: git checkout -b documentation
|
||||
|
||||
- name: Install doxygen
|
||||
run: sudo apt-get install doxygen
|
||||
- name: Install doxygen
|
||||
run: sudo apt-get install doxygen
|
||||
|
||||
- name: Generate autodocs for gpui editor
|
||||
run: doxygen
|
||||
- name: Generate autodocs for gpui editor
|
||||
run: doxygen
|
||||
|
||||
- name: Add generated autodocs to Git repo in the documentation branch
|
||||
run: |
|
||||
git config --global user.email "gpui-github-bot@basealt.ru"
|
||||
git config --global user.name "$GITHUB_WORKFLOW GitHub action"
|
||||
git add -f docs
|
||||
git commit -am "docs: add auto-generated developer documentation"
|
||||
- name: Add generated autodocs to Git repo in the documentation branch
|
||||
run: |
|
||||
git config --global user.email "gpui-github-bot@basealt.ru"
|
||||
git config --global user.name "$GITHUB_WORKFLOW GitHub action"
|
||||
git add -f docs
|
||||
git commit -am "docs: add auto-generated developer documentation"
|
||||
|
||||
- name: Publish autodocs as GitHub pages
|
||||
run: git push -f origin documentation:documentation
|
||||
|
||||
- name: Result URLs
|
||||
run: |
|
||||
REPO_OWNER=$(echo $GITHUB_REPOSITORY | cut -d '/' -f 1)
|
||||
REPO_NAME=$(echo $GITHUB_REPOSITORY | cut -d '/' -f 2)
|
||||
echo "Documentation on a github.io: https://$REPO_OWNER.github.io/$REPO_NAME/docs"
|
||||
echo ""
|
||||
echo "Documentation branch: $GITHUB_SERVER_URL/$GITHUB_REPOSITORY/tree/documentation"
|
||||
- name: Publish autodocs as GitHub pages
|
||||
run: git push -f origin documentation:documentation
|
||||
|
||||
- name: Result URLs
|
||||
run: |
|
||||
REPO_OWNER=$(echo $GITHUB_REPOSITORY | cut -d '/' -f 1)
|
||||
REPO_NAME=$(echo $GITHUB_REPOSITORY | cut -d '/' -f 2)
|
||||
echo "Documentation on a github.io: https://$REPO_OWNER.github.io/$REPO_NAME/docs"
|
||||
echo ""
|
||||
echo "Documentation branch: $GITHUB_SERVER_URL/$GITHUB_REPOSITORY/tree/documentation"
|
||||
|
42
.github/workflows/test.yml
vendored
Normal file
42
.github/workflows/test.yml
vendored
Normal file
@ -0,0 +1,42 @@
|
||||
name: gpui-test
|
||||
|
||||
on:
|
||||
workflow_call:
|
||||
inputs:
|
||||
architecture:
|
||||
description: "Architecture"
|
||||
type: string
|
||||
required: true
|
||||
cpp-compiler:
|
||||
description: "C++ compiler"
|
||||
type: "string"
|
||||
default: "gcc"
|
||||
|
||||
jobs:
|
||||
gpui-test:
|
||||
runs-on: ubuntu-20.04
|
||||
container: ghcr.io/${{ github.repository }}-${{ inputs.architecture }}:latest
|
||||
|
||||
steps:
|
||||
- name: Checkout
|
||||
uses: actions/checkout@v3
|
||||
|
||||
- name: Test Clang
|
||||
if: inputs.cpp-compiler == 'clang'
|
||||
env:
|
||||
QT_QPA_PLATFORM: offscreen
|
||||
run: |
|
||||
CXX=clang++ cmake -B build -DCMAKE_BUILD_TYPE:STRING=Debug -DGPUI_BUILD_TESTS:BOOL=ON .
|
||||
cd build
|
||||
make -j `nproc`
|
||||
make test
|
||||
|
||||
- name: Test GCC
|
||||
if: inputs.cpp-compiler != 'clang'
|
||||
env:
|
||||
QT_QPA_PLATFORM: offscreen
|
||||
run: |
|
||||
cmake -B build -DCMAKE_BUILD_TYPE:STRING=Debug -DGPUI_BUILD_TESTS:BOOL=ON .
|
||||
cd build
|
||||
make -j `nproc`
|
||||
make test
|
13
.gitignore
vendored
13
.gitignore
vendored
@ -75,6 +75,19 @@ compile_commands.json
|
||||
# Qt Qml cache
|
||||
*_qmlcache.qrc
|
||||
|
||||
# VSCode Settings
|
||||
.vscode/
|
||||
|
||||
# Build directory
|
||||
build/
|
||||
docs/
|
||||
|
||||
# Generated files
|
||||
src/plugins/preferences/schemas/*.cpp
|
||||
src/plugins/preferences/schemas/*.h
|
||||
src/plugins/cmtl/schema/*.cpp
|
||||
src/plugins/cmtl/schema/*.h
|
||||
src/plugins/cmtx/schema/*.cpp
|
||||
src/plugins/cmtx/schema/*.h
|
||||
*.translations.qrc
|
||||
src/core/version.h
|
||||
|
@ -1,15 +1,28 @@
|
||||
cmake_minimum_required(VERSION 2.8)
|
||||
cmake_minimum_required(VERSION 3.14)
|
||||
|
||||
project(GPUI)
|
||||
set(CMAKE_CXX_STANDARD 17)
|
||||
|
||||
set(GPUI_VERSION_MAJOR 0)
|
||||
set(GPUI_VERSION_MINOR 1)
|
||||
execute_process(
|
||||
COMMAND
|
||||
bash -c "grep 'Version:' .gear/gpui.spec | awk -F ':' '{ print $2 }' | tr -d [:space:]"
|
||||
OUTPUT_VARIABLE GPUI_GEAR_VERSION
|
||||
WORKING_DIRECTORY ${CMAKE_SOURCE_DIR})
|
||||
|
||||
string(REPLACE "." ";" GEAR_VERSION_LIST ${GPUI_GEAR_VERSION})
|
||||
list(GET GEAR_VERSION_LIST 0 GPUI_VERSION_MAJOR)
|
||||
list(GET GEAR_VERSION_LIST 1 GPUI_VERSION_MINOR)
|
||||
list(GET GEAR_VERSION_LIST 2 GPUI_VERSION_PATCH)
|
||||
|
||||
set(CMAKE_MODULE_PATH ${GPUI_SOURCE_DIR}/cmake)
|
||||
|
||||
set(GPUI_DIR "${CMAKE_BINARY_DIR}")
|
||||
|
||||
include(TranslationUtils)
|
||||
include(FindXsd)
|
||||
include(FindLdap)
|
||||
include(XsdUtils)
|
||||
include(CheckCXXCompilerFlag)
|
||||
|
||||
if(UNIX)
|
||||
include(GNUInstallDirs)
|
||||
|
48
Dockerfile
48
Dockerfile
@ -21,9 +21,44 @@ RUN apt-get update \
|
||||
rpm-macros-generic-compat \
|
||||
apt-repo \
|
||||
apt-repo-tools \
|
||||
cmake \
|
||||
rpm-macros-cmake \
|
||||
cmake-modules \
|
||||
gcc-c++ \
|
||||
clang15.0 \
|
||||
qt5-base-devel \
|
||||
qt5-declarative-devel \
|
||||
qt5-tools-devel \
|
||||
libsmbclient-devel \
|
||||
libsmbclient \
|
||||
qt5-base-common \
|
||||
doxygen \
|
||||
samba-devel \
|
||||
catch2-devel \
|
||||
libldap-devel \
|
||||
libsasl2-devel \
|
||||
libuuid-devel \
|
||||
glib2-devel \
|
||||
libpcre-devel \
|
||||
libkrb5-devel \
|
||||
libxerces-c-devel \
|
||||
libgtest-devel \
|
||||
xsd \
|
||||
boost-devel-headers \
|
||||
desktop-file-utils \
|
||||
ImageMagick-tools \
|
||||
libqt-mvvm-devel \
|
||||
xorg-xvfb \
|
||||
xvfb-run \
|
||||
sudo \
|
||||
ctest \
|
||||
ragel \
|
||||
&& export CURRENT_PWD=`pwd` \
|
||||
&& groupadd --gid $GROUP_ID builder2 \
|
||||
&& if [ $(getent group $GROUP_ID) ]; then \
|
||||
echo "group $GROUP_ID exists."; \
|
||||
else \
|
||||
groupadd --gid $GROUP_ID builder2; \
|
||||
fi \
|
||||
&& useradd --uid $USER_ID --gid $GROUP_ID -ms /bin/bash builder2 \
|
||||
&& groupadd sudo \
|
||||
&& usermod -aG rpm builder2 \
|
||||
@ -31,18 +66,19 @@ RUN apt-get update \
|
||||
&& usermod -aG sudo builder2 \
|
||||
&& echo "root ALL=(ALL) NOPASSWD:ALL" | tee -a /etc/sudoers \
|
||||
&& echo "builder2 ALL=(ALL) NOPASSWD:ALL" | tee -a /etc/sudoers \
|
||||
&& hasher-useradd builder2 \
|
||||
&& hasher-useradd builder2 || : \
|
||||
&& mkdir /app \
|
||||
&& chown root:builder2 /app
|
||||
&& chown $USER_ID:$GROUP_ID /app
|
||||
|
||||
# Copies your code file from your action repository to the filesystem path `/` of the container
|
||||
COPY script/build.sh /build.sh
|
||||
|
||||
ARG ARCH
|
||||
RUN chmod a=rwx,u+t /tmp
|
||||
|
||||
ARG ARCH
|
||||
|
||||
RUN if [ "$ARCH" = "i386" ]; then \
|
||||
sed -i 's/gear-hsh/i586 gear-hsh/g' /build.sh; \
|
||||
sed -i 's/x86_64/i686/g' /build.sh; \
|
||||
sed -i 's/gear-rpm -ba/gear-rpm -ba --target=i386/g' build.sh; \
|
||||
fi
|
||||
|
||||
USER builder2
|
||||
|
22
INSTALL.md
22
INSTALL.md
@ -1,19 +1,25 @@
|
||||
# Building and installing on ALT-Linux
|
||||
|
||||
# Build dependencies
|
||||
|
||||
On ALT-Linux distributions all build dependencies can be installed with following command:
|
||||
All build dependencies can be installed with following command:
|
||||
|
||||
```
|
||||
apt-get install cmake gcc-c++ qt5-base-devel qt5-tools-devel qt5-base-common libxerces-c-devel xsd
|
||||
apt-get install cmake rpm-macros-cmake cmake-modules gcc-c++ qt5-base-devel qt5-declarative-devel qt5-tools-devel libsmbclient-devel libsmbclient samba-devel libldap-devel libsasl2-devel libsmbclient-devel libuuid-devel glib2-devel libpcre-devel libkrb5-devel qt5-base-common doxygen libxerces-c-devel xsd boost-devel-headers desktop-file-utils ImageMagick-tools libqt-mvvm-devel xorg-xvfb xvfb-run
|
||||
```
|
||||
|
||||
# Building with CMake and Make
|
||||
After that GPUI can be built like so:
|
||||
|
||||
```
|
||||
mkdir -p build
|
||||
cmake -B build -DGPUI_BUILD_TESTS=OFF .
|
||||
|
||||
cd build && make -j `nproc`
|
||||
cd build
|
||||
make -j `nproc`
|
||||
```
|
||||
|
||||
## ADMX
|
||||
|
||||
To use GPUI with ADMX policies, you need to also install them like so:
|
||||
|
||||
```
|
||||
apt-get install admx-msi-setup
|
||||
admx-msi-setup
|
||||
```
|
||||
|
||||
|
28
README.md
28
README.md
@ -1,9 +1,27 @@
|
||||
## GPUI
|
||||

|
||||

|
||||
|
||||
GPUI - is an open source utility for group policy management.
|
||||
# GPUI
|
||||
|
||||
## Installation and Usage
|
||||
GPUI — is an open source utility for group policy management on ALT-Linux.
|
||||
|
||||
Refer to the included INSTALL.md file for directions of how to compile, install, and
|
||||
use the GPUI.
|
||||

|
||||
|
||||
## Building and installation
|
||||
|
||||
For building and installation instructions refer to [INSTALL.md](INSTALL.md).
|
||||
|
||||
## Basic usage
|
||||
|
||||
```
|
||||
Usage: gpui-main [options]
|
||||
|
||||
Options:
|
||||
-p <path> The full path of policy to edit.
|
||||
-b <path> The full path of policy bundle to load.
|
||||
-h, --help Displays help on commandline options.
|
||||
-n <name> This options left for compatibility with ADMC. Currently it
|
||||
does nothing.
|
||||
-v, --version Displays version information.
|
||||
```
|
||||
|
||||
|
63
cmake/FindLdap.cmake
Normal file
63
cmake/FindLdap.cmake
Normal file
@ -0,0 +1,63 @@
|
||||
# Finds LDAP C Libraries
|
||||
#
|
||||
# Defined vars:
|
||||
# Ldap_FOUND
|
||||
# Ldap_INCLUDE_DIRS
|
||||
#
|
||||
# Imported targets:
|
||||
# Ldap::Ldap
|
||||
|
||||
find_path(LDAP_INCLUDE_DIR
|
||||
NAMES ldap.h
|
||||
PATHS
|
||||
/usr/include
|
||||
/usr/local/include
|
||||
/opt/local/include
|
||||
)
|
||||
find_library(LDAP_LIBRARY ldap)
|
||||
|
||||
find_path(LBER_INCLUDE_DIR
|
||||
NAMES lber.h
|
||||
PATHS
|
||||
/usr/include
|
||||
/usr/local/include
|
||||
/opt/local/include
|
||||
)
|
||||
find_library(LBER_LIBRARY lber)
|
||||
|
||||
mark_as_advanced(
|
||||
LDAP_INCLUDE_DIR
|
||||
LBER_INCLUDE_DIR
|
||||
LDAP_LIBRARY
|
||||
LBER_LIBRARY
|
||||
)
|
||||
|
||||
include(FindPackageHandleStandardArgs)
|
||||
find_package_handle_standard_args(Ldap
|
||||
FOUND_VAR Ldap_FOUND
|
||||
REQUIRED_VARS
|
||||
LDAP_INCLUDE_DIR
|
||||
LBER_INCLUDE_DIR
|
||||
LDAP_LIBRARY
|
||||
LBER_LIBRARY
|
||||
)
|
||||
|
||||
if(Ldap_FOUND)
|
||||
set(Ldap_INCLUDE_DIRS ${LDAP_INCLUDE_DIR} ${LBER_INCLUDE_DIR})
|
||||
list(REMOVE_DUPLICATES Ldap_INCLUDE_DIRS)
|
||||
endif()
|
||||
|
||||
if(Ldap_FOUND AND NOT TARGET Ldap::Ldap)
|
||||
add_library(Ldap::Ldap INTERFACE IMPORTED)
|
||||
|
||||
target_link_libraries(Ldap::Ldap
|
||||
INTERFACE
|
||||
ldap
|
||||
lber
|
||||
)
|
||||
|
||||
target_include_directories(Ldap::Ldap
|
||||
INTERFACE
|
||||
${Ldap_INCLUDE_DIRS}
|
||||
)
|
||||
endif()
|
54
cmake/FindXsd.cmake
Normal file
54
cmake/FindXsd.cmake
Normal file
@ -0,0 +1,54 @@
|
||||
# Locate Xsd from code synthesis include paths and binary
|
||||
# Xsd can be found at http://codesynthesis.com/products/xsd/
|
||||
# Written by Frederic Heem, frederic.heem _at_ telsey.it
|
||||
|
||||
# This module defines
|
||||
# XSD_INCLUDE_DIR, where to find elements.hxx, etc.
|
||||
# XSD_EXECUTABLE, where is the xsd compiler
|
||||
# XSD_FOUND, If false, don't try to use xsd
|
||||
|
||||
FIND_PATH( XSD_INCLUDE_DIR xsd/cxx/parser/elements.hxx
|
||||
"/opt/local/xsd-3.3.0-i686-macosx/libxsd"
|
||||
"C:/Programs/xsd-3.3.0/libxsd"
|
||||
"C:/Program Files/CodeSynthesis XSD 3.2/include"
|
||||
"C:/mingw/xsd-3.3.0-i686-windows/libxsd"
|
||||
$ENV{XSDDIR}/include
|
||||
$ENV{CODESYNTH}/include
|
||||
/usr/local/include /usr/include
|
||||
$ENV{XSDDIR}/libxsd
|
||||
)
|
||||
|
||||
IF( WIN32 )
|
||||
SET( XSDCXX_FILENAME1 xsd-cxx.exe )
|
||||
ELSE( )
|
||||
SET( XSDCXX_FILENAME1 xsdcxx )
|
||||
SET( XSDCXX_FILENAME2 xsd )
|
||||
ENDIF( )
|
||||
|
||||
FIND_PROGRAM( XSDCXX_EXECUTABLE
|
||||
NAMES
|
||||
${XSDCXX_FILENAME1} ${XSDCXX_FILENAME2}
|
||||
PATHS
|
||||
"/opt/local/xsd-3.3.0-i686-macosx/bin"
|
||||
"C:/Programs/xsd-3.3.0/bin"
|
||||
"C:/mingw/xsd-3.3.0-i686-windows/bin"
|
||||
"C:/Program Files/CodeSynthesis XSD 3.2/bin"
|
||||
$ENV{XSDDIR}/bin
|
||||
/usr/local/bin
|
||||
/usr/bin
|
||||
$ENV{XSDDIR}/xsd
|
||||
)
|
||||
|
||||
MESSAGE(STATUS ${XSDCXX_EXECUTABLE})
|
||||
|
||||
# if the include and the program are found then we have it
|
||||
IF( XSD_INCLUDE_DIR )
|
||||
IF( XSDCXX_EXECUTABLE )
|
||||
SET( XSD_FOUND "YES" )
|
||||
ENDIF( XSDCXX_EXECUTABLE )
|
||||
ENDIF( XSD_INCLUDE_DIR )
|
||||
|
||||
MARK_AS_ADVANCED(
|
||||
XSD_INCLUDE_DIR
|
||||
XSDCXX_EXECUTABLE
|
||||
)
|
@ -9,6 +9,8 @@ set(GPUI_LIBRARY_DIR @CMAKE_INSTALL_PREFIX@/lib)
|
||||
# set GPUI_LIBRARY variables
|
||||
set(GPUI_GUI_LIBRARY gpui-gui)
|
||||
set(GPUI_IO_LIBRARY gpui-io)
|
||||
set(GPUI_MODEL_LIBRARY gpui-model)
|
||||
set(GPUI_CORE_LIBRARY gpui-core)
|
||||
set(GPUI_LDAP_LIBRARY gpui-ldap)
|
||||
|
||||
set(GPUI_LIBRARIES ${GPUI_GUI_LIBRARY} ${GPUI_IO_LIBRARY} ${GPUI_CORE_LIBRARY} ${GPUI_LDAP_LIBRARY})
|
||||
|
||||
set(GPUI_LIBRARIES ${GPUI_GUI_LIBRARY} ${GPUI_IO_LIBRARY} ${GPUI_MODEL_LIBRARY})
|
||||
|
@ -1,6 +1,6 @@
|
||||
function(add_translation_resource out_file)
|
||||
function(add_translation_resource out_file prefix)
|
||||
set(qm_files ${ARGN})
|
||||
set(resource ${CMAKE_CURRENT_SOURCE_DIR}/translations.qrc)
|
||||
set(resource ${CMAKE_CURRENT_SOURCE_DIR}/${prefix}.translations.qrc)
|
||||
|
||||
file(WRITE ${resource} "<!DOCTYPE RCC><RCC version=\"1.0\">\n <qresource prefix=\"/\">\n")
|
||||
foreach(LANG ${qm_files})
|
||||
@ -11,3 +11,20 @@ function(add_translation_resource out_file)
|
||||
|
||||
set(${out_file} ${resource} PARENT_SCOPE)
|
||||
endfunction()
|
||||
|
||||
function(add_translation out_files)
|
||||
set(qm_files "")
|
||||
foreach(filename ${ARGN})
|
||||
get_filename_component(basename ${filename} NAME_WE)
|
||||
set(qm "${CMAKE_CURRENT_SOURCE_DIR}/${basename}.qm")
|
||||
add_custom_command(
|
||||
OUTPUT "${qm}"
|
||||
COMMAND "${Qt5_LRELEASE_EXECUTABLE}"
|
||||
ARGS -markuntranslated "Is not translated!" -nounfinished -removeidentical -compress "${filename}" -qm "${qm}"
|
||||
DEPENDS "${filename}" VERBATIM
|
||||
)
|
||||
list(APPEND qm_files "${qm}")
|
||||
endforeach()
|
||||
|
||||
set(${out_files} ${qm_files} PARENT_SCOPE)
|
||||
endfunction()
|
||||
|
45
cmake/XsdUtils.cmake
Normal file
45
cmake/XsdUtils.cmake
Normal file
@ -0,0 +1,45 @@
|
||||
cmake_policy(SET CMP0071 NEW)
|
||||
|
||||
function(add_xsd_library library_name)
|
||||
set(XSD_FILES ${ARGN})
|
||||
|
||||
foreach(FILE ${XSD_FILES})
|
||||
string(REGEX REPLACE "[.]xsd" ".h" HEADER ${FILE})
|
||||
set(XSD_HEADERS ${XSD_HEADERS} ${HEADER})
|
||||
endforeach()
|
||||
|
||||
foreach(FILE ${XSD_FILES})
|
||||
string(REGEX REPLACE "[.]xsd" ".cpp" SOURCE ${FILE})
|
||||
set(XSD_SOURCES ${XSD_SOURCES} ${SOURCE})
|
||||
endforeach()
|
||||
|
||||
set(OUT_FILES
|
||||
${XSD_HEADERS}
|
||||
${XSD_SOURCES}
|
||||
)
|
||||
|
||||
set(XSD_FLAGS cxx-tree
|
||||
--generate-doxygen
|
||||
--generate-ostream
|
||||
--generate-serialization
|
||||
--generate-polymorphic
|
||||
--polymorphic-type-all
|
||||
--generate-wildcard
|
||||
--cxx-suffix .cpp
|
||||
--hxx-suffix .h
|
||||
--std c++11
|
||||
--type-naming ucc
|
||||
--root-element-all
|
||||
)
|
||||
|
||||
add_custom_command(
|
||||
OUTPUT ${OUT_FILES}
|
||||
COMMAND ${XSDCXX_EXECUTABLE} ${XSD_FLAGS} ${XSD_FILES}
|
||||
DEPENDS ${XSD_FILES}
|
||||
COMMENT "Running ${XSDCXX_EXECUTABLE} ${XSD_FLAGS} ${XSD_FILES}"
|
||||
WORKING_DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR}
|
||||
COMMAND_EXPAND_LISTS
|
||||
)
|
||||
|
||||
add_library(${library_name} STATIC ${OUT_FILES})
|
||||
endfunction()
|
@ -1,13 +1,4 @@
|
||||
#!/bin/bash -ex
|
||||
|
||||
chown -R builder2:builder2 /app/
|
||||
mkdir -p /app/RPMS/
|
||||
|
||||
mkdir /home/builder2/hasher
|
||||
mkdir /home/builder2/.hasher
|
||||
|
||||
cp /app/hasher/config /home/builder2/.hasher/config
|
||||
hsh --initroot-only --no-wait-lock -vv /home/builder2/hasher
|
||||
|
||||
cd /app/ && gear --hasher -- hsh-rebuild /home/builder2/hasher
|
||||
cp /home/builder2/hasher/repo/x86_64/RPMS.hasher/*.rpm /app/RPMS/
|
||||
chown -R builder2 /app/
|
||||
cd /app/ && gear-rpm -ba
|
||||
|
@ -31,10 +31,10 @@ Name[zh_TW]=GPUI
|
||||
GenericName=GPUI
|
||||
GenericName[ru]=Редактор групповых политик
|
||||
X-GNOME-FullName=GPUI
|
||||
Comment=Group Policy Editor
|
||||
Comment[ru]=Редактор групповых политик
|
||||
Comment=Group Policy Editor allows user to edit group policy templates
|
||||
Comment[ru]=Редактор групповых политик позволяет редактировать шаблоны групповых политик
|
||||
Exec=gpui-main
|
||||
Terminal=false
|
||||
Type=Application
|
||||
Categories=System;
|
||||
Categories=System;FileTools;
|
||||
Icon=gpui
|
||||
|
58
setup/man/en/gpui.1
Normal file
58
setup/man/en/gpui.1
Normal file
@ -0,0 +1,58 @@
|
||||
.\" Manpage for gpui.
|
||||
.\" Contact august@altlinux.org to correct errors or typos.
|
||||
.TH man 1 "10 Nov 2022" "0.2.17" "gpui man page"
|
||||
.SH NAME
|
||||
gpui-main \- manage group policy templates
|
||||
.SH SYNOPSIS
|
||||
gpui-main [-p policy path] [-b admx path] [-n name of a policy] [-h | --help] [-v | --version]
|
||||
.SH DESCRIPTION
|
||||
gpui-main is a program for managing group policy templates.
|
||||
.SH OPTIONS
|
||||
.TP
|
||||
.if !'po4a'hide' .BR \-p
|
||||
Provide the full path of the policy to edit.
|
||||
.TP
|
||||
.if !'po4a'hide' .BR \-b
|
||||
Provide the path of admx files to load.
|
||||
.TP
|
||||
.if !'po4a'hide' .BR \-n
|
||||
Parameters provides compatibilty with ADMC, currently it performs no specific function.
|
||||
.TP
|
||||
.if !'po4a'hide' .BR \-\-log\-console
|
||||
Set log level for console. By default: "none".
|
||||
.TP
|
||||
.if !'po4a'hide' .BR \-\-log\-syslog
|
||||
Set log level for syslog. By default: "none".
|
||||
.TP
|
||||
.if !'po4a'hide' .BR \-\-log\-file
|
||||
Set log level for file in ~/.local/share/gpui/. By default: "warning".
|
||||
.TP
|
||||
.if !'po4a'hide' .BR \-h ", " \-\-help
|
||||
Show help message and exit program.
|
||||
.TP
|
||||
.if !'po4a'hide' .BR \-v ", " \-\-version
|
||||
Show version information.
|
||||
.SH LOG LEVELS
|
||||
.TP
|
||||
.if !'po4a'hide' .BR "none"
|
||||
Disable logging.
|
||||
.TP
|
||||
.if !'po4a'hide' .BR "debug"
|
||||
Log debug messages and higher.
|
||||
.TP
|
||||
.if !'po4a'hide' .BR "info"
|
||||
Log info messages and higher.
|
||||
.TP
|
||||
.if !'po4a'hide' .BR "warning"
|
||||
Log warning messages and higher.
|
||||
.TP
|
||||
.if !'po4a'hide' .BR "critical"
|
||||
Log critical messages and higher.
|
||||
.TP
|
||||
.if !'po4a'hide' .BR "fatal"
|
||||
Log fatal messages and higher.
|
||||
.SH SEE ALSO
|
||||
.SH BUGS
|
||||
Utility in a state of active development and may contain unspecified number of various bugs.
|
||||
.SH AUTHOR
|
||||
August (august@altlinux.org)
|
58
setup/man/ru/gpui.1
Normal file
58
setup/man/ru/gpui.1
Normal file
@ -0,0 +1,58 @@
|
||||
.\" Manpage for gpui.
|
||||
.\" Contact august@altlinux.org to correct errors or typos.
|
||||
.TH man 1 "29 Aug 2023" "0.2.32" "gpui man page"
|
||||
.SH NAME
|
||||
gpui-main \- редактирует шаблоны групповых политик
|
||||
.SH SYNOPSIS
|
||||
gpui-main [-p путь к политике] [-b путь к admx файлам] [-n имя политики для отображения] [-h | --help] [-v | --version]
|
||||
.SH DESCRIPTION
|
||||
gpui-main это программа для управления шаблонами групповой политики.
|
||||
.SH OPTIONS
|
||||
.TP
|
||||
.if !'po4a'hide' .BR \-p
|
||||
Позволяет указать путь к шаблону групповой политики, который нужно редактировать.
|
||||
.TP
|
||||
.if !'po4a'hide' .BR \-b
|
||||
Позволяет указать путь для загрузки admx файлов.
|
||||
.TP
|
||||
.if !'po4a'hide' .BR \-n
|
||||
Параметр оставлен для обеспечения обраной совместимости с ADMC. Он никак не влияет на работу приложения.
|
||||
.TP
|
||||
.if !'po4a'hide' .BR \-\-log\-console
|
||||
Установить уровень логирования для консоли. По умолчанию: "none".
|
||||
.TP
|
||||
.if !'po4a'hide' .BR \-\-log\-syslog
|
||||
Установить уровень логирования для syslog. По умолчанию: "none".
|
||||
.TP
|
||||
.if !'po4a'hide' .BR \-\-log\-file
|
||||
Установить уровень логирования для файла в ~/.local/share/gpui/. По умолчанию: "warning".
|
||||
.TP
|
||||
.if !'po4a'hide' .BR \-h ", " \-\-help
|
||||
Показать справочное сообщение и закончить работу.
|
||||
.TP
|
||||
.if !'po4a'hide' .BR \-v ", " \-\-version
|
||||
Показать информацию о версии.
|
||||
.SH LOG LEVELS
|
||||
.TP
|
||||
.if !'po4a'hide' .BR "none"
|
||||
Отключить логирование.
|
||||
.TP
|
||||
.if !'po4a'hide' .BR "debug"
|
||||
Логировать сообщения уровня debug и выше.
|
||||
.TP
|
||||
.if !'po4a'hide' .BR "info"
|
||||
Логировать сообщения уровня info и выше.
|
||||
.TP
|
||||
.if !'po4a'hide' .BR "warning"
|
||||
Логировать сообщения уровня warning и выше.
|
||||
.TP
|
||||
.if !'po4a'hide' .BR "critical"
|
||||
Логировать сообщения уровня critical и выше.
|
||||
.TP
|
||||
.if !'po4a'hide' .BR "fatal"
|
||||
Логировать сообщения уровня fatal.
|
||||
.SH SEE ALSO
|
||||
.SH BUGS
|
||||
Утилита находится в состоянии активной разработки и может содержать неопределенное количество различных ошибок.
|
||||
.SH AUTHOR
|
||||
August (august@altlinux.org)
|
@ -1,6 +1,20 @@
|
||||
# set compiler options
|
||||
if (CMAKE_COMPILER_IS_GNUCXX AND NOT WIN32)
|
||||
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -Wno-undef -fvisibility=hidden -fvisibility-inlines-hidden -pedantic -Wall -Wextra -Wno-long-long")
|
||||
if(${CMAKE_SYSTEM_PROCESSOR} STREQUAL "e2k")
|
||||
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -Wno-undef -fvisibility=default -pedantic -Wall")
|
||||
else()
|
||||
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -Wno-undef -fvisibility=hidden -fvisibility-inlines-hidden -pedantic -Wall\
|
||||
-Wextra -Wno-long-long -Weffc++ -Werror -Wall -Wextra -pedantic -Wcast-align -Wcast-qual -Wctor-dtor-privacy \
|
||||
-Wdisabled-optimization -Wformat=2 -Winit-self -Wlogical-op -Wmissing-include-dirs -Wnoexcept -Wold-style-cast \
|
||||
-Woverloaded-virtual -Wredundant-decls -Wshadow -Wstrict-null-sentinel -Wundef \
|
||||
-Wno-unused -Wno-variadic-macros -Wno-parentheses -Wnonnull -fdiagnostics-show-option")
|
||||
if(CMAKE_SIZEOF_VOID_P LESS_EQUAL 4)
|
||||
CHECK_CXX_COMPILER_FLAG("-march=i586" COMPILER_SUPPORTS_MARCH_I586)
|
||||
if (${COMPILER_SUPPORTS_MARCH_I586})
|
||||
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -march=i586")
|
||||
endif()
|
||||
endif()
|
||||
endif()
|
||||
endif()
|
||||
|
||||
macro(add_gpui_library name)
|
||||
@ -21,7 +35,8 @@ macro(add_gpui_library name)
|
||||
endmacro(add_gpui_library)
|
||||
|
||||
add_subdirectory(app)
|
||||
add_subdirectory(core)
|
||||
add_subdirectory(gui)
|
||||
add_subdirectory(io)
|
||||
add_subdirectory(model)
|
||||
add_subdirectory(plugins)
|
||||
add_subdirectory(ldap)
|
||||
|
@ -18,15 +18,32 @@
|
||||
**
|
||||
***********************************************************************************************************************/
|
||||
|
||||
#include "../core/compositesnapindetailsdialog.h"
|
||||
#include "../core/logger/prelude.h"
|
||||
#include "../core/pluginstorage.h"
|
||||
#include "../core/snapindetailsdialog.h"
|
||||
#include "../core/snapindetailsfactory.h"
|
||||
#include "../core/snapinloader.h"
|
||||
#include "../core/snapinmanager.h"
|
||||
#include "../core/translatorstorage.h"
|
||||
#include "../core/version.h"
|
||||
#include "../gui/commandlineparser.h"
|
||||
#include "../gui/mainwindow.h"
|
||||
#include "../model/pluginstorage.h"
|
||||
|
||||
#include <iostream>
|
||||
#include <QApplication>
|
||||
|
||||
int main(int argc, char ** argv) {
|
||||
// Load plugins.
|
||||
gpui::PluginStorage::instance()->loadDefaultPlugins();
|
||||
int main(int argc, char **argv)
|
||||
{
|
||||
// Register types for factory.
|
||||
gpui::SnapInDetailsFactory::define<gpui::SnapInDetailsDialog>("ISnapIn");
|
||||
gpui::SnapInDetailsFactory::define<gpui::CompositeSnapInDetailsDialog>("ICompositeSnapIn");
|
||||
|
||||
// Load plugins and snap-ins.
|
||||
auto snapInManager = std::make_unique<gpui::SnapInManager>();
|
||||
auto snapInLoader = std::make_unique<gpui::SnapInLoader>(snapInManager.get());
|
||||
|
||||
snapInLoader->loadDefaultSnapIns();
|
||||
|
||||
// Create window.
|
||||
QApplication app(argc, argv);
|
||||
@ -36,41 +53,51 @@ int main(int argc, char ** argv) {
|
||||
app.setOrganizationName(QCoreApplication::translate("main", "BaseALT Ltd."));
|
||||
app.setOrganizationDomain("basealt.ru");
|
||||
app.setApplicationName("GPUI");
|
||||
app.setApplicationVersion("0.2.0");
|
||||
|
||||
gpui::CommandLineParser parser(app);
|
||||
gpui::CommandLineOptions options;
|
||||
QString errorMessage;
|
||||
|
||||
gpui::CommandLineParser::CommandLineParseResult parserResult = parser.parseCommandLine(&options, &errorMessage);
|
||||
app.setApplicationVersion(getApplicationVersion());
|
||||
|
||||
QLocale locale;
|
||||
std::unique_ptr<QTranslator> qtTranslator = std::make_unique<QTranslator>();
|
||||
qtTranslator->load(locale, "gui", "_", ":/");
|
||||
std::unique_ptr<QTranslator> qtTranslator2 = std::make_unique<QTranslator>();
|
||||
qtTranslator2->load(QString("qt_").append(QLocale::system().name()),
|
||||
QLibraryInfo::location(QLibraryInfo::TranslationsPath));
|
||||
QCoreApplication::installTranslator(qtTranslator.get());
|
||||
QCoreApplication::installTranslator(qtTranslator2.get());
|
||||
QString language = locale.system().name().split("_").at(0);
|
||||
TranslatorStorage translatorStorage;
|
||||
|
||||
translatorStorage.loadTranslators(language);
|
||||
translatorStorage.loadQtTranslations(language, "qt_");
|
||||
|
||||
gpui::CommandLineParser parser(app);
|
||||
gpui::CommandLineOptions options{};
|
||||
QString errorMessage{};
|
||||
|
||||
gpui::CommandLineParser::CommandLineParseResult parserResult = parser.parseCommandLine(&options, &errorMessage);
|
||||
|
||||
switch (parserResult)
|
||||
{
|
||||
case gpui::CommandLineParser::CommandLineError:
|
||||
printf("%s \n", qPrintable(errorMessage));
|
||||
parser.showHelp();
|
||||
return 1;
|
||||
std::cerr << qPrintable(errorMessage) << std::endl;
|
||||
parser.showHelp(1); // NOTE: Exits with 1
|
||||
case gpui::CommandLineParser::CommandLineHelpRequested:
|
||||
parser.showHelp();
|
||||
return 0;
|
||||
parser.showHelp(0); // NOTE: Exits with 0
|
||||
case gpui::CommandLineParser::CommandLineVersionRequested:
|
||||
parser.showVersion();
|
||||
return 0;
|
||||
parser.showVersion(); // NOTE: Exits with 0
|
||||
case gpui::CommandLineParser::CommandLineOk:
|
||||
default:
|
||||
break;
|
||||
}
|
||||
|
||||
gpui::MainWindow window(options);
|
||||
|
||||
auto logManager = gpui::logger::LoggerManager::globalInstance();
|
||||
|
||||
if (options.consoleLogLevel != LOG_LEVEL_DISABLED)
|
||||
{
|
||||
logManager->addLogger<gpui::logger::ConsoleLogger>(options.consoleLogLevel);
|
||||
}
|
||||
if (options.consoleLogLevel != LOG_LEVEL_DISABLED)
|
||||
{
|
||||
logManager->addLogger<gpui::logger::SyslogLogger>(options.syslogLogLevel);
|
||||
}
|
||||
if (options.consoleLogLevel != LOG_LEVEL_DISABLED)
|
||||
{
|
||||
logManager->addLogger<gpui::logger::FileLogger>(options.fileLogLevel);
|
||||
}
|
||||
|
||||
gpui::MainWindow window(options, snapInManager.get(), &translatorStorage);
|
||||
window.show();
|
||||
|
||||
return app.exec();
|
||||
|
28
src/core/CMakeLists.txt
Normal file
28
src/core/CMakeLists.txt
Normal file
@ -0,0 +1,28 @@
|
||||
find_package(Qt5 COMPONENTS Core Gui Widgets REQUIRED)
|
||||
|
||||
set(CMAKE_INCLUDE_CURRENT_DIR ON)
|
||||
|
||||
set(CMAKE_AUTOMOC ON)
|
||||
set(CMAKE_AUTOUIC ON)
|
||||
|
||||
configure_file(${CMAKE_CURRENT_SOURCE_DIR}/version.h.in
|
||||
${CMAKE_CURRENT_SOURCE_DIR}/version.h)
|
||||
|
||||
file(GLOB HEADERS "*.h")
|
||||
|
||||
file(GLOB SOURCES "*.cpp")
|
||||
|
||||
file(GLOB UIFORMS "*.ui")
|
||||
|
||||
set(SOURCES ${HEADERS} ${SOURCES} ${UIFORMS})
|
||||
|
||||
add_definitions(
|
||||
-DGPUI_CORE_LIBRARY
|
||||
)
|
||||
|
||||
add_gpui_library(gpui-core ${SOURCES})
|
||||
add_subdirectory(logger)
|
||||
target_link_libraries(gpui-core gpui-logger)
|
||||
|
||||
target_link_libraries(gpui-core Qt5::Core Qt5::Gui Qt5::Widgets)
|
||||
|
65
src/core/abstractcompositesnapin.cpp
Normal file
65
src/core/abstractcompositesnapin.cpp
Normal file
@ -0,0 +1,65 @@
|
||||
/***********************************************************************************************************************
|
||||
**
|
||||
** Copyright (C) 2022 BaseALT Ltd. <org@basealt.ru>
|
||||
**
|
||||
** This program is free software; you can redistribute it and/or
|
||||
** modify it under the terms of the GNU General Public License
|
||||
** as published by the Free Software Foundation; either version 2
|
||||
** of the License, or (at your option) any later version.
|
||||
**
|
||||
** This program is distributed in the hope that it will be useful,
|
||||
** but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
** GNU General Public License for more details.
|
||||
**
|
||||
** You should have received a copy of the GNU General Public License
|
||||
** along with this program; if not, write to the Free Software
|
||||
** Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
|
||||
**
|
||||
***********************************************************************************************************************/
|
||||
|
||||
#include "abstractcompositesnapin.h"
|
||||
|
||||
#include <QMap>
|
||||
#include <QString>
|
||||
#include <QVersionNumber>
|
||||
|
||||
namespace gpui
|
||||
{
|
||||
class AbstractCompositeSnapInPrivate
|
||||
{
|
||||
public:
|
||||
QMap<QString, QVersionNumber> dependencies{};
|
||||
};
|
||||
|
||||
QMap<QString, QVersionNumber> AbstractCompositeSnapIn::getDependencies() const
|
||||
{
|
||||
return d->dependencies;
|
||||
}
|
||||
|
||||
AbstractCompositeSnapIn::AbstractCompositeSnapIn(QString type,
|
||||
QString name,
|
||||
QString helpText,
|
||||
QVersionNumber version,
|
||||
QString license,
|
||||
QString copyright)
|
||||
: AbstractSnapIn(type, name, helpText, version, license, copyright)
|
||||
, d(new AbstractCompositeSnapInPrivate())
|
||||
{}
|
||||
|
||||
AbstractCompositeSnapIn::~AbstractCompositeSnapIn()
|
||||
{
|
||||
delete d;
|
||||
}
|
||||
|
||||
void AbstractCompositeSnapIn::addDependency(const QString &name, const QVersionNumber &version)
|
||||
{
|
||||
d->dependencies.insert(name, version);
|
||||
}
|
||||
|
||||
void AbstractCompositeSnapIn::removeDependency(const QString &name)
|
||||
{
|
||||
d->dependencies.remove(name);
|
||||
}
|
||||
|
||||
} // namespace gpui
|
65
src/core/abstractcompositesnapin.h
Normal file
65
src/core/abstractcompositesnapin.h
Normal file
@ -0,0 +1,65 @@
|
||||
/***********************************************************************************************************************
|
||||
**
|
||||
** Copyright (C) 2022 BaseALT Ltd. <org@basealt.ru>
|
||||
**
|
||||
** This program is free software; you can redistribute it and/or
|
||||
** modify it under the terms of the GNU General Public License
|
||||
** as published by the Free Software Foundation; either version 2
|
||||
** of the License, or (at your option) any later version.
|
||||
**
|
||||
** This program is distributed in the hope that it will be useful,
|
||||
** but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
** GNU General Public License for more details.
|
||||
**
|
||||
** You should have received a copy of the GNU General Public License
|
||||
** along with this program; if not, write to the Free Software
|
||||
** Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
|
||||
**
|
||||
***********************************************************************************************************************/
|
||||
|
||||
#ifndef _ABSTRACTCOMPOSITESNAPIN_H
|
||||
#define _ABSTRACTCOMPOSITESNAPIN_H
|
||||
|
||||
#include "core.h"
|
||||
|
||||
#include "icompositesnapin.h"
|
||||
|
||||
#include "abstractsnapin.h"
|
||||
|
||||
namespace gpui
|
||||
{
|
||||
class AbstractCompositeSnapInPrivate;
|
||||
|
||||
class GPUI_CORE_EXPORT AbstractCompositeSnapIn : public ICompositeSnapIn, public AbstractSnapIn
|
||||
{
|
||||
public:
|
||||
QMap<QString, QVersionNumber> getDependencies() const override final;
|
||||
|
||||
protected:
|
||||
AbstractCompositeSnapIn(QString type,
|
||||
QString name,
|
||||
QString helpText = {},
|
||||
QVersionNumber version = {},
|
||||
QString license = {},
|
||||
QString copyright = {});
|
||||
~AbstractCompositeSnapIn();
|
||||
|
||||
protected:
|
||||
void addDependency(const QString &name, const QVersionNumber &version);
|
||||
|
||||
void removeDependency(const QString &name);
|
||||
|
||||
private:
|
||||
AbstractCompositeSnapIn(const AbstractCompositeSnapIn &) = delete; // copy ctor
|
||||
AbstractCompositeSnapIn(AbstractCompositeSnapIn &&) = delete; // move ctor
|
||||
AbstractCompositeSnapIn &operator=(const AbstractCompositeSnapIn &) = delete; // copy assignment
|
||||
AbstractCompositeSnapIn &operator=(AbstractCompositeSnapIn &&) = delete; // move assignment
|
||||
|
||||
private:
|
||||
AbstractCompositeSnapInPrivate *d;
|
||||
};
|
||||
|
||||
} // namespace gpui
|
||||
|
||||
#endif //_ABSTRACTCOMPOSITESNAPIN_H
|
131
src/core/abstractsnapin.cpp
Normal file
131
src/core/abstractsnapin.cpp
Normal file
@ -0,0 +1,131 @@
|
||||
/***********************************************************************************************************************
|
||||
**
|
||||
** Copyright (C) 2022 BaseALT Ltd. <org@basealt.ru>
|
||||
**
|
||||
** This program is free software; you can redistribute it and/or
|
||||
** modify it under the terms of the GNU General Public License
|
||||
** as published by the Free Software Foundation; either version 2
|
||||
** of the License, or (at your option) any later version.
|
||||
**
|
||||
** This program is distributed in the hope that it will be useful,
|
||||
** but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
** GNU General Public License for more details.
|
||||
**
|
||||
** You should have received a copy of the GNU General Public License
|
||||
** along with this program; if not, write to the Free Software
|
||||
** Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
|
||||
**
|
||||
***********************************************************************************************************************/
|
||||
|
||||
#include "abstractsnapin.h"
|
||||
|
||||
#include <qstandarditemmodel.h>
|
||||
|
||||
namespace gpui
|
||||
{
|
||||
class AbstractSnapInPrivate
|
||||
{
|
||||
public:
|
||||
QString name{};
|
||||
QUuid id{};
|
||||
QAbstractItemModel *rootNode{nullptr};
|
||||
QString type{};
|
||||
QString helpText{};
|
||||
QVersionNumber version{};
|
||||
QString license{};
|
||||
QString copyright{};
|
||||
};
|
||||
|
||||
QUuid AbstractSnapIn::getId() const
|
||||
{
|
||||
return d->id;
|
||||
}
|
||||
|
||||
QAbstractItemModel *AbstractSnapIn::getRootNode() const
|
||||
{
|
||||
return d->rootNode;
|
||||
}
|
||||
|
||||
QString AbstractSnapIn::getDisplayName() const
|
||||
{
|
||||
return d->name;
|
||||
}
|
||||
|
||||
QString AbstractSnapIn::getType() const
|
||||
{
|
||||
return d->type;
|
||||
}
|
||||
|
||||
QString AbstractSnapIn::getHelpText() const
|
||||
{
|
||||
return d->helpText;
|
||||
}
|
||||
|
||||
QVersionNumber AbstractSnapIn::getVersion() const
|
||||
{
|
||||
return d->version;
|
||||
}
|
||||
|
||||
QString AbstractSnapIn::getLicense() const
|
||||
{
|
||||
return d->license;
|
||||
}
|
||||
|
||||
QString AbstractSnapIn::getCopyright() const
|
||||
{
|
||||
return d->copyright;
|
||||
}
|
||||
|
||||
AbstractSnapIn::AbstractSnapIn(QString type,
|
||||
QString name,
|
||||
QString helpText,
|
||||
QVersionNumber version,
|
||||
QString license,
|
||||
QString copyright)
|
||||
: d(new AbstractSnapInPrivate())
|
||||
{
|
||||
d->name = name;
|
||||
d->type = type;
|
||||
d->helpText = helpText;
|
||||
d->version = version;
|
||||
d->license = license;
|
||||
d->copyright = copyright;
|
||||
}
|
||||
|
||||
AbstractSnapIn::~AbstractSnapIn()
|
||||
{
|
||||
delete d;
|
||||
}
|
||||
|
||||
void AbstractSnapIn::setId(QUuid id)
|
||||
{
|
||||
d->id = id;
|
||||
}
|
||||
|
||||
void AbstractSnapIn::setRootNode(QAbstractItemModel *rootNode)
|
||||
{
|
||||
d->rootNode = rootNode;
|
||||
}
|
||||
|
||||
void AbstractSnapIn::setHelpText(QString text)
|
||||
{
|
||||
d->helpText = text;
|
||||
}
|
||||
|
||||
void AbstractSnapIn::setVersion(QVersionNumber version)
|
||||
{
|
||||
d->version = version;
|
||||
}
|
||||
|
||||
void AbstractSnapIn::setLicense(QString license)
|
||||
{
|
||||
d->license = license;
|
||||
}
|
||||
|
||||
void AbstractSnapIn::setCopyright(QString copyright)
|
||||
{
|
||||
d->copyright = copyright;
|
||||
}
|
||||
|
||||
} // namespace gpui
|
93
src/core/abstractsnapin.h
Normal file
93
src/core/abstractsnapin.h
Normal file
@ -0,0 +1,93 @@
|
||||
/***********************************************************************************************************************
|
||||
**
|
||||
** Copyright (C) 2022 BaseALT Ltd. <org@basealt.ru>
|
||||
**
|
||||
** This program is free software; you can redistribute it and/or
|
||||
** modify it under the terms of the GNU General Public License
|
||||
** as published by the Free Software Foundation; either version 2
|
||||
** of the License, or (at your option) any later version.
|
||||
**
|
||||
** This program is distributed in the hope that it will be useful,
|
||||
** but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
** GNU General Public License for more details.
|
||||
**
|
||||
** You should have received a copy of the GNU General Public License
|
||||
** along with this program; if not, write to the Free Software
|
||||
** Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
|
||||
**
|
||||
***********************************************************************************************************************/
|
||||
|
||||
#ifndef _ABSTRACTSNAPIN_H
|
||||
#define _ABSTRACTSNAPIN_H
|
||||
|
||||
#include "core.h"
|
||||
|
||||
#include "isnapin.h"
|
||||
#include "plugin.h"
|
||||
|
||||
#include <QAbstractItemModel>
|
||||
#include <QUuid>
|
||||
#include <QVersionNumber>
|
||||
|
||||
namespace gpui
|
||||
{
|
||||
class AbstractSnapInPrivate;
|
||||
|
||||
/**
|
||||
* @brief Adapts interface of a ISnapIn for a plugin.
|
||||
*/
|
||||
class GPUI_CORE_EXPORT AbstractSnapIn : public virtual ISnapIn
|
||||
{
|
||||
public:
|
||||
QUuid getId() const override;
|
||||
|
||||
QString getType() const override;
|
||||
|
||||
QAbstractItemModel *getRootNode() const override;
|
||||
|
||||
QString getDisplayName() const override;
|
||||
|
||||
QString getHelpText() const override;
|
||||
|
||||
QVersionNumber getVersion() const override;
|
||||
|
||||
QString getLicense() const override;
|
||||
|
||||
QString getCopyright() const override;
|
||||
|
||||
protected:
|
||||
AbstractSnapIn(QString type,
|
||||
QString name,
|
||||
QString helpText = {},
|
||||
QVersionNumber version = {},
|
||||
QString license = {},
|
||||
QString copyright = {});
|
||||
~AbstractSnapIn();
|
||||
|
||||
protected:
|
||||
void setId(QUuid id);
|
||||
|
||||
void setRootNode(QAbstractItemModel *rootNode);
|
||||
|
||||
void setHelpText(QString text);
|
||||
|
||||
void setVersion(QVersionNumber version);
|
||||
|
||||
void setLicense(QString license);
|
||||
|
||||
void setCopyright(QString copyright);
|
||||
|
||||
private:
|
||||
AbstractSnapIn(const AbstractSnapIn &) = delete; // copy ctor
|
||||
AbstractSnapIn(AbstractSnapIn &&) = delete; // move ctor
|
||||
AbstractSnapIn &operator=(const AbstractSnapIn &) = delete; // copy assignment
|
||||
AbstractSnapIn &operator=(AbstractSnapIn &&) = delete; // move assignment
|
||||
|
||||
private:
|
||||
AbstractSnapInPrivate *d;
|
||||
};
|
||||
|
||||
} // namespace gpui
|
||||
|
||||
#endif //_ABSTRACTSNAPIN_H
|
@ -25,7 +25,13 @@
|
||||
#define GPUI_SYMBOL_EXPORT __attribute__((__dllexport__))
|
||||
#define GPUI_SYMBOL_IMPORT __attribute__((__dllimport__))
|
||||
#else
|
||||
|
||||
#if defined (__LCC__)
|
||||
#define GPUI_SYMBOL_EXPORT
|
||||
#else
|
||||
#define GPUI_SYMBOL_EXPORT __attribute__((__visibility__("default")))
|
||||
#endif
|
||||
|
||||
#define GPUI_SYMBOL_IMPORT
|
||||
#endif
|
||||
|
78
src/core/compositesnapindetailsdialog.cpp
Normal file
78
src/core/compositesnapindetailsdialog.cpp
Normal file
@ -0,0 +1,78 @@
|
||||
/***********************************************************************************************************************
|
||||
**
|
||||
** Copyright (C) 2022 BaseALT Ltd. <org@basealt.ru>
|
||||
**
|
||||
** This program is free software; you can redistribute it and/or
|
||||
** modify it under the terms of the GNU General Public License
|
||||
** as published by the Free Software Foundation; either version 2
|
||||
** of the License, or (at your option) any later version.
|
||||
**
|
||||
** This program is distributed in the hope that it will be useful,
|
||||
** but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
** GNU General Public License for more details.
|
||||
**
|
||||
** You should have received a copy of the GNU General Public License
|
||||
** along with this program; if not, write to the Free Software
|
||||
** Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
|
||||
**
|
||||
***********************************************************************************************************************/
|
||||
|
||||
#include "compositesnapindetailsdialog.h"
|
||||
#include "ui_compositesnapindetailsdialog.h"
|
||||
|
||||
#include "icompositesnapin.h"
|
||||
|
||||
#include <QTableWidget>
|
||||
|
||||
namespace gpui
|
||||
{
|
||||
CompositeSnapInDetailsDialog::CompositeSnapInDetailsDialog(QWidget *parent,
|
||||
::gpui::ISnapIn *snapIn)
|
||||
: CompositeSnapInDetailsDialog(parent)
|
||||
{
|
||||
setSnapIn(snapIn);
|
||||
}
|
||||
|
||||
CompositeSnapInDetailsDialog::CompositeSnapInDetailsDialog(QWidget *parent)
|
||||
: ISnapInDetailsDialog(parent)
|
||||
, ui(new Ui::CompositeSnapInDetailsDialog())
|
||||
{
|
||||
ui->setupUi(this);
|
||||
}
|
||||
|
||||
CompositeSnapInDetailsDialog::~CompositeSnapInDetailsDialog()
|
||||
{
|
||||
delete ui;
|
||||
}
|
||||
|
||||
void CompositeSnapInDetailsDialog::setSnapIn(ISnapIn *snapIn)
|
||||
{
|
||||
ui->snapInWidget->setSnapIn(snapIn);
|
||||
|
||||
auto compositeSnapIn = dynamic_cast<ICompositeSnapIn *>(snapIn);
|
||||
|
||||
if (compositeSnapIn)
|
||||
{
|
||||
QMapIterator<QString, QVersionNumber> iterator(compositeSnapIn->getDependencies());
|
||||
|
||||
int row = 0;
|
||||
|
||||
while (iterator.hasNext())
|
||||
{
|
||||
iterator.next();
|
||||
|
||||
QTableWidgetItem *nameItem = new QTableWidgetItem(iterator.key());
|
||||
QTableWidgetItem *versionItem = new QTableWidgetItem(iterator.value().toString());
|
||||
|
||||
ui->tableWidget->insertRow(row);
|
||||
|
||||
ui->tableWidget->setItem(row, 0, nameItem);
|
||||
ui->tableWidget->setItem(row, 1, versionItem);
|
||||
|
||||
++row;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
} // namespace gpui
|
62
src/core/compositesnapindetailsdialog.h
Normal file
62
src/core/compositesnapindetailsdialog.h
Normal file
@ -0,0 +1,62 @@
|
||||
/***********************************************************************************************************************
|
||||
**
|
||||
** Copyright (C) 2022 BaseALT Ltd. <org@basealt.ru>
|
||||
**
|
||||
** This program is free software; you can redistribute it and/or
|
||||
** modify it under the terms of the GNU General Public License
|
||||
** as published by the Free Software Foundation; either version 2
|
||||
** of the License, or (at your option) any later version.
|
||||
**
|
||||
** This program is distributed in the hope that it will be useful,
|
||||
** but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
** GNU General Public License for more details.
|
||||
**
|
||||
** You should have received a copy of the GNU General Public License
|
||||
** along with this program; if not, write to the Free Software
|
||||
** Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
|
||||
**
|
||||
***********************************************************************************************************************/
|
||||
|
||||
#ifndef _COMPOSITESNAPINDETAILSDIALOG_H
|
||||
#define _COMPOSITESNAPINDETAILSDIALOG_H
|
||||
|
||||
#include "core.h"
|
||||
|
||||
#include "isnapin.h"
|
||||
#include "isnapindetailsdialog.h"
|
||||
|
||||
namespace Ui
|
||||
{
|
||||
class CompositeSnapInDetailsDialog;
|
||||
}
|
||||
|
||||
namespace gpui
|
||||
{
|
||||
/**
|
||||
* @brief Shows properties and dependencies of composite snap-in.
|
||||
*/
|
||||
class GPUI_CORE_EXPORT CompositeSnapInDetailsDialog : public ISnapInDetailsDialog
|
||||
{
|
||||
Q_OBJECT
|
||||
|
||||
public:
|
||||
CompositeSnapInDetailsDialog(QWidget *parent, ISnapIn *snapIn);
|
||||
CompositeSnapInDetailsDialog(QWidget *parent = nullptr);
|
||||
~CompositeSnapInDetailsDialog();
|
||||
|
||||
void setSnapIn(ISnapIn *snapIn) override;
|
||||
|
||||
private:
|
||||
CompositeSnapInDetailsDialog(const CompositeSnapInDetailsDialog &) = delete; // copy ctor
|
||||
CompositeSnapInDetailsDialog(CompositeSnapInDetailsDialog &&) = delete; // move ctor
|
||||
CompositeSnapInDetailsDialog &operator=(const CompositeSnapInDetailsDialog &) = delete; // copy assignment
|
||||
CompositeSnapInDetailsDialog &operator=(CompositeSnapInDetailsDialog &&) = delete; // move assignment
|
||||
|
||||
private:
|
||||
Ui::CompositeSnapInDetailsDialog *ui;
|
||||
};
|
||||
|
||||
} // namespace gpui
|
||||
|
||||
#endif //_COMPOSITESNAPINDETAILSDIALOG_H
|
94
src/core/compositesnapindetailsdialog.ui
Normal file
94
src/core/compositesnapindetailsdialog.ui
Normal file
@ -0,0 +1,94 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<ui version="4.0">
|
||||
<class>CompositeSnapInDetailsDialog</class>
|
||||
<widget class="QDialog" name="CompositeSnapInDetailsDialog">
|
||||
<property name="geometry">
|
||||
<rect>
|
||||
<x>0</x>
|
||||
<y>0</y>
|
||||
<width>419</width>
|
||||
<height>572</height>
|
||||
</rect>
|
||||
</property>
|
||||
<property name="windowTitle">
|
||||
<string>Dialog</string>
|
||||
</property>
|
||||
<layout class="QGridLayout" name="gridLayout">
|
||||
<item row="2" column="0">
|
||||
<widget class="QLabel" name="label">
|
||||
<property name="text">
|
||||
<string>Dependencies:</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="4" column="0">
|
||||
<widget class="QDialogButtonBox" name="buttonBox">
|
||||
<property name="standardButtons">
|
||||
<set>QDialogButtonBox::Close</set>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="3" column="0">
|
||||
<widget class="QTableWidget" name="tableWidget">
|
||||
<attribute name="horizontalHeaderStretchLastSection">
|
||||
<bool>true</bool>
|
||||
</attribute>
|
||||
<column>
|
||||
<property name="text">
|
||||
<string>Name</string>
|
||||
</property>
|
||||
</column>
|
||||
<column>
|
||||
<property name="text">
|
||||
<string>Version</string>
|
||||
</property>
|
||||
</column>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="1" column="0">
|
||||
<widget class="::gpui::SnapInDetailsWidget" name="snapInWidget" native="true">
|
||||
<property name="minimumSize">
|
||||
<size>
|
||||
<width>400</width>
|
||||
<height>300</height>
|
||||
</size>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="0" column="0">
|
||||
<widget class="QLabel" name="label_2">
|
||||
<property name="text">
|
||||
<string>Snap-In Details:</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
</layout>
|
||||
</widget>
|
||||
<customwidgets>
|
||||
<customwidget>
|
||||
<class>::gpui::SnapInDetailsWidget</class>
|
||||
<extends>QWidget</extends>
|
||||
<header>snapindetailswidget.h</header>
|
||||
<container>1</container>
|
||||
</customwidget>
|
||||
</customwidgets>
|
||||
<resources/>
|
||||
<connections>
|
||||
<connection>
|
||||
<sender>buttonBox</sender>
|
||||
<signal>clicked(QAbstractButton*)</signal>
|
||||
<receiver>CompositeSnapInDetailsDialog</receiver>
|
||||
<slot>close()</slot>
|
||||
<hints>
|
||||
<hint type="sourcelabel">
|
||||
<x>209</x>
|
||||
<y>550</y>
|
||||
</hint>
|
||||
<hint type="destinationlabel">
|
||||
<x>209</x>
|
||||
<y>285</y>
|
||||
</hint>
|
||||
</hints>
|
||||
</connection>
|
||||
</connections>
|
||||
</ui>
|
@ -18,7 +18,7 @@
|
||||
**
|
||||
***********************************************************************************************************************/
|
||||
|
||||
#include "model.h"
|
||||
#include "core.h"
|
||||
|
||||
namespace gpui {
|
||||
|
@ -23,14 +23,13 @@
|
||||
|
||||
#include "common.h"
|
||||
|
||||
#ifdef GPUI_MODEL_LIBRARY
|
||||
#define GPUI_MODEL_EXPORT GPUI_SYMBOL_EXPORT
|
||||
#ifdef GPUI_CORE_LIBRARY
|
||||
#define GPUI_CORE_EXPORT GPUI_SYMBOL_EXPORT
|
||||
#else
|
||||
#define GPUI_MODEL_EXPORT GPUI_SYMBOL_IMPORT
|
||||
#define GPUI_CORE_EXPORT GPUI_SYMBOL_IMPORT
|
||||
#endif
|
||||
|
||||
namespace gpui {
|
||||
|
||||
}
|
||||
namespace gpui
|
||||
{}
|
||||
|
||||
#endif // GPUI_MODEL_H
|
85
src/core/factory.h
Normal file
85
src/core/factory.h
Normal file
@ -0,0 +1,85 @@
|
||||
/***********************************************************************************************************************
|
||||
**
|
||||
** Copyright (C) 2022 BaseALT Ltd. <org@basealt.ru>
|
||||
**
|
||||
** This program is free software; you can redistribute it and/or
|
||||
** modify it under the terms of the GNU General Public License
|
||||
** as published by the Free Software Foundation; either version 2
|
||||
** of the License, or (at your option) any later version.
|
||||
**
|
||||
** This program is distributed in the hope that it will be useful,
|
||||
** but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
** GNU General Public License for more details.
|
||||
**
|
||||
** You should have received a copy of the GNU General Public License
|
||||
** along with this program; if not, write to the Free Software
|
||||
** Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
|
||||
**
|
||||
***********************************************************************************************************************/
|
||||
|
||||
#ifndef _FACTORY_H
|
||||
#define _FACTORY_H
|
||||
|
||||
#include <map>
|
||||
#include <memory>
|
||||
#include <stdexcept>
|
||||
|
||||
namespace gpui
|
||||
{
|
||||
/**
|
||||
* @brief Implementation of abstract factory pattern.
|
||||
*/
|
||||
template<typename Interface, typename TKey = std::string>
|
||||
class Factory
|
||||
{
|
||||
public:
|
||||
typedef TKey Key;
|
||||
typedef std::unique_ptr<Interface> Type;
|
||||
typedef Type (*ConcreteFactory)();
|
||||
|
||||
/**
|
||||
* @brief define Defines new pair constructor and key if already not present.
|
||||
* @param key Key of an element.
|
||||
* @param value Factory that constructs the element.
|
||||
* @return True on success.
|
||||
*/
|
||||
bool define(Key const &key, ConcreteFactory const &value)
|
||||
{
|
||||
return storage.insert(typename Storage::value_type(key, value)).second;
|
||||
}
|
||||
|
||||
/**
|
||||
* @brief create Creates element of given Type.
|
||||
* @param key Key of element ot construct.
|
||||
* @return Element of given type.
|
||||
*/
|
||||
Type create(Key const &key)
|
||||
{
|
||||
typename Storage::const_iterator i = storage.find(key);
|
||||
if (i == storage.end())
|
||||
{
|
||||
throw std::invalid_argument(std::string(__PRETTY_FUNCTION__)
|
||||
+ ": key is not registered!");
|
||||
}
|
||||
|
||||
return i->second();
|
||||
}
|
||||
|
||||
/**
|
||||
* @brief
|
||||
*/
|
||||
template<class Base, class Actual>
|
||||
static std::unique_ptr<Base> create_func()
|
||||
{
|
||||
return std::unique_ptr<Base>(new Actual());
|
||||
}
|
||||
|
||||
private:
|
||||
typedef std::map<Key, ConcreteFactory> Storage;
|
||||
Storage storage{};
|
||||
};
|
||||
|
||||
} // namespace gpui
|
||||
|
||||
#endif //_FACTORY_H
|
41
src/core/icompositesnapin.h
Normal file
41
src/core/icompositesnapin.h
Normal file
@ -0,0 +1,41 @@
|
||||
/***********************************************************************************************************************
|
||||
**
|
||||
** Copyright (C) 2022 BaseALT Ltd. <org@basealt.ru>
|
||||
**
|
||||
** This program is free software; you can redistribute it and/or
|
||||
** modify it under the terms of the GNU General Public License
|
||||
** as published by the Free Software Foundation; either version 2
|
||||
** of the License, or (at your option) any later version.
|
||||
**
|
||||
** This program is distributed in the hope that it will be useful,
|
||||
** but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
** GNU General Public License for more details.
|
||||
**
|
||||
** You should have received a copy of the GNU General Public License
|
||||
** along with this program; if not, write to the Free Software
|
||||
** Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
|
||||
**
|
||||
***********************************************************************************************************************/
|
||||
|
||||
#ifndef _ICOMPOSITESNAPIN_H
|
||||
#define _ICOMPOSITESNAPIN_H
|
||||
|
||||
#include "core.h"
|
||||
|
||||
#include "isnapin.h"
|
||||
|
||||
namespace gpui
|
||||
{
|
||||
/**
|
||||
* @brief Composite snap-in requires list of dependencies to operate.
|
||||
*/
|
||||
class GPUI_CORE_EXPORT ICompositeSnapIn : public virtual ISnapIn
|
||||
{
|
||||
public:
|
||||
virtual QMap<QString, QVersionNumber> getDependencies() const = 0;
|
||||
};
|
||||
|
||||
} // namespace gpui
|
||||
|
||||
#endif //_ICOMPOSITESNAPIN_H
|
120
src/core/isnapin.h
Normal file
120
src/core/isnapin.h
Normal file
@ -0,0 +1,120 @@
|
||||
/***********************************************************************************************************************
|
||||
**
|
||||
** Copyright (C) 2022 BaseALT Ltd. <org@basealt.ru>
|
||||
**
|
||||
** This program is free software; you can redistribute it and/or
|
||||
** modify it under the terms of the GNU General Public License
|
||||
** as published by the Free Software Foundation; either version 2
|
||||
** of the License, or (at your option) any later version.
|
||||
**
|
||||
** This program is distributed in the hope that it will be useful,
|
||||
** but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
** GNU General Public License for more details.
|
||||
**
|
||||
** You should have received a copy of the GNU General Public License
|
||||
** along with this program; if not, write to the Free Software
|
||||
** Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
|
||||
**
|
||||
***********************************************************************************************************************/
|
||||
|
||||
#ifndef _ISNAPIN_H
|
||||
#define _ISNAPIN_H
|
||||
|
||||
#include "core.h"
|
||||
|
||||
#include <QAbstractItemModel>
|
||||
#include <QMainWindow>
|
||||
#include <QUuid>
|
||||
#include <QVersionNumber>
|
||||
|
||||
namespace gpui
|
||||
{
|
||||
/**
|
||||
* @brief The ISnapIn interface is a base for all snap-ins in a system.
|
||||
*/
|
||||
class GPUI_CORE_EXPORT ISnapIn
|
||||
{
|
||||
public:
|
||||
virtual ~ISnapIn() = default;
|
||||
|
||||
/**
|
||||
* @brief Called when a snap-in is initialized.
|
||||
* It allows derived classes to provide additional initialization.
|
||||
*/
|
||||
virtual void onInitialize(QMainWindow *mainWindow) = 0;
|
||||
|
||||
/**
|
||||
* @brief onShutdown Called when the snap-in is shutting down.
|
||||
* Once this call returns, actions which modify the application, such as adding nodes,
|
||||
* or modifying view descriptions, are not honored.
|
||||
*/
|
||||
virtual void onShutdown() = 0;
|
||||
|
||||
/**
|
||||
* @brief onDataLoad Called when snap-in loads data from policy folder.
|
||||
* @param policyPath Path to load policy data from.
|
||||
* @param locale Locale to use.
|
||||
*/
|
||||
virtual void onDataLoad(const std::string &policyPath, const std::string &locale) = 0;
|
||||
|
||||
/**
|
||||
* @brief onDataSave Called when snap-in saves data.
|
||||
*/
|
||||
virtual void onDataSave() = 0;
|
||||
|
||||
/**
|
||||
* @brief Gets the identifier for the instance of the snap-in.
|
||||
* The identifier is unique across snap-in instances within a application.
|
||||
*/
|
||||
virtual QUuid getId() const = 0;
|
||||
|
||||
/**
|
||||
* @brief getType Returns a type of a snap-in.
|
||||
*/
|
||||
virtual QString getType() const = 0;
|
||||
|
||||
/**
|
||||
* @brief Gets the identifier for the instance of the snap-in.
|
||||
* The identifier is unique across snap-in instances within a application.
|
||||
* This value can never be a null value or invalid.
|
||||
*/
|
||||
virtual QAbstractItemModel *getRootNode() const = 0;
|
||||
|
||||
/**
|
||||
* @brief getDisplayName Returns display name of a snap-in.
|
||||
*/
|
||||
virtual QString getDisplayName() const = 0;
|
||||
|
||||
/**
|
||||
* @brief getHelpText Returns the help text for the instance of the snap-in.
|
||||
* @return
|
||||
*/
|
||||
virtual QString getHelpText() const = 0;
|
||||
|
||||
/**
|
||||
* @brief getVersion Returns version of a snap-in.
|
||||
* @return
|
||||
*/
|
||||
virtual QVersionNumber getVersion() const = 0;
|
||||
|
||||
/**
|
||||
* @brief getLicense Returns license assosiated with the snap-in.
|
||||
*/
|
||||
virtual QString getLicense() const = 0;
|
||||
|
||||
/**
|
||||
* @brief getCopyright Returns copyright of snap-in.
|
||||
*/
|
||||
virtual QString getCopyright() const = 0;
|
||||
|
||||
/**
|
||||
* @brief onRetranslateUI Retranslate UI
|
||||
* @param locale locale to use in current snap-in.
|
||||
*/
|
||||
virtual void onRetranslateUI(const std::string &locale) = 0;
|
||||
};
|
||||
|
||||
} // namespace gpui
|
||||
|
||||
#endif //_ISNAPIN_H
|
49
src/core/isnapindetailsdialog.h
Normal file
49
src/core/isnapindetailsdialog.h
Normal file
@ -0,0 +1,49 @@
|
||||
/***********************************************************************************************************************
|
||||
**
|
||||
** Copyright (C) 2022 BaseALT Ltd. <org@basealt.ru>
|
||||
**
|
||||
** This program is free software; you can redistribute it and/or
|
||||
** modify it under the terms of the GNU General Public License
|
||||
** as published by the Free Software Foundation; either version 2
|
||||
** of the License, or (at your option) any later version.
|
||||
**
|
||||
** This program is distributed in the hope that it will be useful,
|
||||
** but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
** GNU General Public License for more details.
|
||||
**
|
||||
** You should have received a copy of the GNU General Public License
|
||||
** along with this program; if not, write to the Free Software
|
||||
** Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
|
||||
**
|
||||
***********************************************************************************************************************/
|
||||
|
||||
#ifndef _ISNAPINDETAILSDIALOG_H
|
||||
#define _ISNAPINDETAILSDIALOG_H
|
||||
|
||||
#include "core.h"
|
||||
|
||||
#include <QDialog>
|
||||
|
||||
#include "isnapin.h"
|
||||
|
||||
namespace gpui
|
||||
{
|
||||
/**
|
||||
* @brief Common interface for a details dialog.
|
||||
*/
|
||||
class GPUI_CORE_EXPORT ISnapInDetailsDialog : public QDialog
|
||||
{
|
||||
Q_OBJECT
|
||||
|
||||
public:
|
||||
explicit ISnapInDetailsDialog(QWidget *parent = nullptr, Qt::WindowFlags f = Qt::WindowFlags())
|
||||
: QDialog(parent, f)
|
||||
{}
|
||||
|
||||
virtual void setSnapIn(ISnapIn *snapIn) = 0;
|
||||
};
|
||||
|
||||
} // namespace gpui
|
||||
|
||||
#endif //_ISNAPINDETAILSDIALOG_H
|
67
src/core/isnapinmanager.h
Normal file
67
src/core/isnapinmanager.h
Normal file
@ -0,0 +1,67 @@
|
||||
/***********************************************************************************************************************
|
||||
**
|
||||
** Copyright (C) 2022 BaseALT Ltd. <org@basealt.ru>
|
||||
**
|
||||
** This program is free software; you can redistribute it and/or
|
||||
** modify it under the terms of the GNU General Public License
|
||||
** as published by the Free Software Foundation; either version 2
|
||||
** of the License, or (at your option) any later version.
|
||||
**
|
||||
** This program is distributed in the hope that it will be useful,
|
||||
** but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
** GNU General Public License for more details.
|
||||
**
|
||||
** You should have received a copy of the GNU General Public License
|
||||
** along with this program; if not, write to the Free Software
|
||||
** Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
|
||||
**
|
||||
***********************************************************************************************************************/
|
||||
|
||||
#ifndef _ISNAPINMANAGER_H
|
||||
#define _ISNAPINMANAGER_H
|
||||
|
||||
#include "core.h"
|
||||
|
||||
#include <vector>
|
||||
|
||||
#include "isnapin.h"
|
||||
|
||||
namespace gpui
|
||||
{
|
||||
/**
|
||||
* @brief class ISnapInManager Manages all the snap-ins in an application.
|
||||
*/
|
||||
class GPUI_CORE_EXPORT ISnapInManager
|
||||
{
|
||||
public:
|
||||
virtual ~ISnapInManager() = default;
|
||||
|
||||
/**
|
||||
* @brief addSnapIn Adds a snap-in to the manager.
|
||||
* @param snapIn Snap-In to add.
|
||||
*/
|
||||
virtual void addSnapIn(ISnapIn *snapIn) = 0;
|
||||
|
||||
//
|
||||
/**
|
||||
* @brief removeSnapIn Removes a snap-in from the manager.
|
||||
* @param snapIn Snap-In to remove.
|
||||
*/
|
||||
virtual void removeSnapIn(ISnapIn *snapIn) = 0;
|
||||
|
||||
/**
|
||||
* @brief getSnapIns Get a list of all snap-ins associated with this manager.
|
||||
* @return List of all snap-ins.
|
||||
*/
|
||||
virtual std::vector<ISnapIn *> getSnapIns() const = 0;
|
||||
|
||||
/**
|
||||
* @brief Unload all the snap-ins from the manager.
|
||||
*/
|
||||
virtual void clear() = 0;
|
||||
};
|
||||
|
||||
} // namespace gpui
|
||||
|
||||
#endif //_ISNAPINMANAGER_H
|
28
src/core/logger/CMakeLists.txt
Normal file
28
src/core/logger/CMakeLists.txt
Normal file
@ -0,0 +1,28 @@
|
||||
find_package(Qt5 COMPONENTS Core REQUIRED)
|
||||
|
||||
set(CMAKE_INCLUDE_CURRENT_DIR ON)
|
||||
|
||||
set(HEADERS
|
||||
loggermanager.h
|
||||
loggermessage.h
|
||||
logger.h
|
||||
consolelogger.h
|
||||
filelogger.h
|
||||
sysloglogger.h
|
||||
)
|
||||
|
||||
set(SOURCES
|
||||
loggermanager.cpp
|
||||
logger.cpp
|
||||
consolelogger.cpp
|
||||
filelogger.cpp
|
||||
sysloglogger.cpp
|
||||
)
|
||||
|
||||
add_definitions(
|
||||
-DGPUI_CORE_LIBRARY
|
||||
)
|
||||
|
||||
add_library(gpui-logger STATIC ${SOURCES} ${HEADERS})
|
||||
target_include_directories(gpui-logger PUBLIC ${Qt5Gui_INCLUDE_DIRS})
|
||||
target_link_libraries(gpui-logger Qt5::Core)
|
112
src/core/logger/consolelogger.cpp
Normal file
112
src/core/logger/consolelogger.cpp
Normal file
@ -0,0 +1,112 @@
|
||||
/***********************************************************************************************************************
|
||||
**
|
||||
** Copyright (C) 2022 BaseALT Ltd. <org@basealt.ru>
|
||||
**
|
||||
** This program is free software; you can redistribute it and/or
|
||||
** modify it under the terms of the GNU General Public License
|
||||
** as published by the Free Software Foundation; either version 2
|
||||
** of the License, or (at your option) any later version.
|
||||
**
|
||||
** This program is distributed in the hope that it will be useful,
|
||||
** but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
** GNU General Public License for more details.
|
||||
**
|
||||
** You should have received a copy of the GNU General Public License
|
||||
** along with this program; if not, write to the Free Software
|
||||
** Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
|
||||
**
|
||||
***********************************************************************************************************************/
|
||||
|
||||
#include "consolelogger.h"
|
||||
|
||||
#include <cstring>
|
||||
#include <fstream>
|
||||
#include <iostream>
|
||||
#include <unistd.h>
|
||||
|
||||
/*!
|
||||
* \brief checkColorSupport Checks if console supports colored output.
|
||||
* \param fd File descriptor.
|
||||
* \return True if console supports colored output.
|
||||
*/
|
||||
static bool checkColorSupport(int fd)
|
||||
{
|
||||
// TODO(mchernigin): use `tput colors`, and use method bellow only if `tput` returns !0
|
||||
|
||||
bool is_tty = isatty(fd);
|
||||
const char *TERM = std::getenv("TERM");
|
||||
|
||||
return is_tty && TERM != NULL && strcmp(TERM, "dumb") != 0;
|
||||
}
|
||||
|
||||
/*!
|
||||
* \brief colorize Colorizes given text using escape sequences.
|
||||
* \param text Text to colorize.
|
||||
* \param params String which describes styling in escape sequence.
|
||||
* \return Colorized text.
|
||||
*/
|
||||
static std::string colorize(const std::string &text, const char *params)
|
||||
{
|
||||
return std::string("\033[") + params + "m" + text + "\033[0m";
|
||||
}
|
||||
|
||||
namespace gpui
|
||||
{
|
||||
namespace logger
|
||||
{
|
||||
/*!
|
||||
* \class ConsoleLogger consolelogger.h
|
||||
* \brief Implementation of logger which logs messages to console.
|
||||
* \ingroup logger
|
||||
*
|
||||
* Logs messages to std::clog.
|
||||
*/
|
||||
|
||||
/*!
|
||||
* \brief ConsoleLogger Create new console logger.
|
||||
*
|
||||
* Checks if stderr supports color.
|
||||
*/
|
||||
ConsoleLogger::ConsoleLogger()
|
||||
{
|
||||
this->hasColorSupport = checkColorSupport(STDERR_FILENO);
|
||||
}
|
||||
|
||||
/*!
|
||||
* \brief ConsoleLogger::log Send message to console.
|
||||
* \param message Message.
|
||||
*
|
||||
* Formats and sends message to std::clog.
|
||||
*/
|
||||
void ConsoleLogger::log(const LoggerMessage &message)
|
||||
{
|
||||
std::string prefix = this->logLevelMap.at(message.msgType);
|
||||
|
||||
if (this->hasColorSupport)
|
||||
{
|
||||
switch (message.msgType)
|
||||
{
|
||||
case QtDebugMsg:
|
||||
prefix = this->hasColorSupport ? colorize(prefix, "1;96") : prefix;
|
||||
break;
|
||||
case QtInfoMsg:
|
||||
prefix = this->hasColorSupport ? colorize(prefix, "1;34") : prefix;
|
||||
break;
|
||||
case QtWarningMsg:
|
||||
prefix = this->hasColorSupport ? colorize(prefix, "1;33") : prefix;
|
||||
break;
|
||||
case QtCriticalMsg:
|
||||
prefix = this->hasColorSupport ? colorize(prefix, "1;31") : prefix;
|
||||
break;
|
||||
case QtFatalMsg:
|
||||
prefix = this->hasColorSupport ? colorize(prefix, "1;91") : prefix;
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
std::clog << message.getTimeFormatted("%H:%M:%S") << " | " << prefix << ": " << message.message << " ("
|
||||
<< message.filePath << ":" << message.line << ")" << std::endl;
|
||||
}
|
||||
} // namespace logger
|
||||
} // namespace gpui
|
45
src/core/logger/consolelogger.h
Normal file
45
src/core/logger/consolelogger.h
Normal file
@ -0,0 +1,45 @@
|
||||
/***********************************************************************************************************************
|
||||
**
|
||||
** Copyright (C) 2022 BaseALT Ltd. <org@basealt.ru>
|
||||
**
|
||||
** This program is free software; you can redistribute it and/or
|
||||
** modify it under the terms of the GNU General Public License
|
||||
** as published by the Free Software Foundation; either version 2
|
||||
** of the License, or (at your option) any later version.
|
||||
**
|
||||
** This program is distributed in the hope that it will be useful,
|
||||
** but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
** GNU General Public License for more details.
|
||||
**
|
||||
** You should have received a copy of the GNU General Public License
|
||||
** along with this program; if not, write to the Free Software
|
||||
** Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
|
||||
**
|
||||
***********************************************************************************************************************/
|
||||
|
||||
#ifndef GPUI_CONSOLE_LOGGER_H
|
||||
#define GPUI_CONSOLE_LOGGER_H
|
||||
|
||||
#include "logger.h"
|
||||
#include "loggermessage.h"
|
||||
#include "../core.h"
|
||||
|
||||
namespace gpui
|
||||
{
|
||||
namespace logger
|
||||
{
|
||||
class GPUI_CORE_EXPORT ConsoleLogger : public Logger
|
||||
{
|
||||
public:
|
||||
ConsoleLogger();
|
||||
|
||||
private:
|
||||
void log(const LoggerMessage &message) override;
|
||||
|
||||
bool hasColorSupport = false;
|
||||
};
|
||||
} // namespace logger
|
||||
} // namespace gpui
|
||||
|
||||
#endif // GPUI_CONSOLE_LOGGER_H
|
140
src/core/logger/filelogger.cpp
Normal file
140
src/core/logger/filelogger.cpp
Normal file
@ -0,0 +1,140 @@
|
||||
/***********************************************************************************************************************
|
||||
**
|
||||
** Copyright (C) 2022 BaseALT Ltd. <org@basealt.ru>
|
||||
**
|
||||
** This program is free software; you can redistribute it and/or
|
||||
** modify it under the terms of the GNU General Public License
|
||||
** as published by the Free Software Foundation; either version 2
|
||||
** of the License, or (at your option) any later version.
|
||||
**
|
||||
** This program is distributed in the hope that it will be useful,
|
||||
** but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
** GNU General Public License for more details.
|
||||
**
|
||||
** You should have received a copy of the GNU General Public License
|
||||
** along with this program; if not, write to the Free Software
|
||||
** Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
|
||||
**
|
||||
***********************************************************************************************************************/
|
||||
|
||||
#include "filelogger.h"
|
||||
|
||||
#include <iostream>
|
||||
#include <pwd.h>
|
||||
#include <sys/stat.h>
|
||||
#include <sys/types.h>
|
||||
#include <unistd.h>
|
||||
|
||||
namespace gpui
|
||||
{
|
||||
namespace logger
|
||||
{
|
||||
/*!
|
||||
* \class FileLogger filelogger.h
|
||||
* \brief Implementation of logger which logs messages to a file.
|
||||
* \ingroup logger
|
||||
*
|
||||
* Writes logs to ~/.local/share/gpui/<filename>.
|
||||
*/
|
||||
|
||||
/*!
|
||||
* \brief FileLogger::FileLogger Creates FileLogger
|
||||
* \param filename Name of a file for logs. By default "gpui.log".
|
||||
*
|
||||
* File logger writes to a file in ~/.local/share/gpui/<filename>.
|
||||
* If given path does not exist, it will create needed directories.
|
||||
*
|
||||
* Opens a file stream to log file.
|
||||
*/
|
||||
FileLogger::FileLogger(const char *filename)
|
||||
{
|
||||
// TODO(mchernigin): timestamp on creation/editing log file is UTC and not local timezone
|
||||
std::string homeDir = getHomeDir();
|
||||
std::string logDir = homeDir + "/.local/share/gpui/";
|
||||
ensureDir(logDir.c_str());
|
||||
|
||||
std::string logFile = logDir + filename;
|
||||
this->logFileStream.open(logFile, std::fstream::out | std::fstream::app);
|
||||
}
|
||||
|
||||
/*!
|
||||
* \brief FileLogger::~FileLogger Destroys a file logger.
|
||||
*
|
||||
* Closes file stream to log file.
|
||||
*/
|
||||
FileLogger::~FileLogger()
|
||||
{
|
||||
this->logFileStream.close();
|
||||
}
|
||||
|
||||
/*!
|
||||
* \brief FileLogger::log Format and log given message to log file.
|
||||
* \param message Message.
|
||||
*/
|
||||
void FileLogger::log(const LoggerMessage &message)
|
||||
{
|
||||
const char *prefix = this->logLevelMap.at(message.msgType);
|
||||
this->logFileStream << message.getTimeFormatted("%H:%M:%S") << " | " << prefix << ": " << message.message << " ("
|
||||
<< message.filePath << ":" << message.line << ")" << std::endl;
|
||||
}
|
||||
|
||||
/*!
|
||||
* \brief FileLogger::getHomeDir Gets current user home directory.
|
||||
* \return Absolute path to home directory.
|
||||
*
|
||||
* Gets home directory from $HOME. If $HOME is not set, uses `getpwuid`.
|
||||
*/
|
||||
std::string FileLogger::getHomeDir()
|
||||
{
|
||||
const char *HOME = getenv("HOME");
|
||||
if (HOME != NULL)
|
||||
{
|
||||
return HOME;
|
||||
}
|
||||
|
||||
long bufsize = sysconf(_SC_GETPW_R_SIZE_MAX);
|
||||
if (bufsize == -1)
|
||||
{
|
||||
bufsize = 1 << 14;
|
||||
}
|
||||
|
||||
char *resultBuf = new char[bufsize];
|
||||
passwd pwd;
|
||||
passwd *result;
|
||||
getpwuid_r(getuid(), &pwd, resultBuf, bufsize, &result);
|
||||
|
||||
std::string homeDir;
|
||||
if (result != NULL)
|
||||
{
|
||||
homeDir = result->pw_dir;
|
||||
}
|
||||
else
|
||||
{
|
||||
homeDir = "/root";
|
||||
std::cerr << "FileLogger Error: cannot determine home directory, defaulting to " << homeDir << std::endl;
|
||||
}
|
||||
|
||||
delete[] resultBuf;
|
||||
|
||||
return homeDir;
|
||||
}
|
||||
|
||||
/*!
|
||||
* \brief FileLogger::ensureDir Ensure if given path exists.
|
||||
* \param path Path
|
||||
* \return True, if dir already exists or was created successfully.
|
||||
*/
|
||||
bool FileLogger::ensureDir(const char *path)
|
||||
{
|
||||
struct stat sb;
|
||||
if (stat(path, &sb) != 0 && mkdir(path, 0750) != 0)
|
||||
{
|
||||
std::cerr << "FileLogger Error: Cannot create log directory (" << path << ")" << std::endl;
|
||||
return false;
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
} // namespace logger
|
||||
} // namespace gpui
|
51
src/core/logger/filelogger.h
Normal file
51
src/core/logger/filelogger.h
Normal file
@ -0,0 +1,51 @@
|
||||
/***********************************************************************************************************************
|
||||
**
|
||||
** Copyright (C) 2022 BaseALT Ltd. <org@basealt.ru>
|
||||
**
|
||||
** This program is free software; you can redistribute it and/or
|
||||
** modify it under the terms of the GNU General Public License
|
||||
** as published by the Free Software Foundation; either version 2
|
||||
** of the License, or (at your option) any later version.
|
||||
**
|
||||
** This program is distributed in the hope that it will be useful,
|
||||
** but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
** GNU General Public License for more details.
|
||||
**
|
||||
** You should have received a copy of the GNU General Public License
|
||||
** along with this program; if not, write to the Free Software
|
||||
** Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
|
||||
**
|
||||
***********************************************************************************************************************/
|
||||
|
||||
#ifndef GPUI_FILE_LOGGER_H
|
||||
#define GPUI_FILE_LOGGER_H
|
||||
|
||||
#include "logger.h"
|
||||
#include "loggermessage.h"
|
||||
#include "../core.h"
|
||||
|
||||
#include <fstream>
|
||||
|
||||
namespace gpui
|
||||
{
|
||||
namespace logger
|
||||
{
|
||||
class GPUI_CORE_EXPORT FileLogger : public Logger
|
||||
{
|
||||
public:
|
||||
explicit FileLogger(const char *filename = "gpui.log");
|
||||
~FileLogger();
|
||||
|
||||
private:
|
||||
void log(const LoggerMessage &message) override;
|
||||
|
||||
static std::string getHomeDir();
|
||||
static bool ensureDir(const char *path);
|
||||
|
||||
std::fstream logFileStream = {};
|
||||
};
|
||||
} // namespace logger
|
||||
} // namespace gpui
|
||||
|
||||
#endif // GPUI_FILE_LOGGER_H
|
66
src/core/logger/logger.cpp
Normal file
66
src/core/logger/logger.cpp
Normal file
@ -0,0 +1,66 @@
|
||||
/***********************************************************************************************************************
|
||||
**
|
||||
** Copyright (C) 2022 BaseALT Ltd. <org@basealt.ru>
|
||||
**
|
||||
** This program is free software; you can redistribute it and/or
|
||||
** modify it under the terms of the GNU General Public License
|
||||
** as published by the Free Software Foundation; either version 2
|
||||
** of the License, or (at your option) any later version.
|
||||
**
|
||||
** This program is distributed in the hope that it will be useful,
|
||||
** but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
** GNU General Public License for more details.
|
||||
**
|
||||
** You should have received a copy of the GNU General Public License
|
||||
** along with this program; if not, write to the Free Software
|
||||
** Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
|
||||
**
|
||||
***********************************************************************************************************************/
|
||||
|
||||
#include "logger.h"
|
||||
|
||||
namespace gpui
|
||||
{
|
||||
namespace logger
|
||||
{
|
||||
/*!
|
||||
* \class Logger logger.h
|
||||
* \brief Abstract logger.
|
||||
* \ingroup logger
|
||||
*/
|
||||
|
||||
/*!
|
||||
* \brief Logger::setLogLevel Set minimum logging level.
|
||||
* \param level Minimum logging level.
|
||||
*/
|
||||
void Logger::setLogLevel(QtMsgType level)
|
||||
{
|
||||
this->minLogLevel = level;
|
||||
}
|
||||
|
||||
/*!
|
||||
* \brief Logger::isLogLevel Check if log level will be logged.
|
||||
* \param level Logging level.
|
||||
* \return Returns true if givven logging level will be logged.
|
||||
*/
|
||||
bool Logger::isLogLevel(QtMsgType level)
|
||||
{
|
||||
return level >= this->minLogLevel;
|
||||
}
|
||||
|
||||
/*!
|
||||
* \brief Logger::logMessage Log message.
|
||||
* \param message Message.
|
||||
*
|
||||
* Logs only message logging level equals or above minimum logging level.
|
||||
*/
|
||||
void Logger::logMessage(const LoggerMessage &message)
|
||||
{
|
||||
if (isLogLevel(message.msgType))
|
||||
{
|
||||
log(message);
|
||||
}
|
||||
}
|
||||
} // namespace logger
|
||||
} // namespace gpui
|
71
src/core/logger/logger.h
Normal file
71
src/core/logger/logger.h
Normal file
@ -0,0 +1,71 @@
|
||||
/***********************************************************************************************************************
|
||||
**
|
||||
** Copyright (C) 2022 BaseALT Ltd. <org@basealt.ru>
|
||||
**
|
||||
** This program is free software; you can redistribute it and/or
|
||||
** modify it under the terms of the GNU General Public License
|
||||
** as published by the Free Software Foundation; either version 2
|
||||
** of the License, or (at your option) any later version.
|
||||
**
|
||||
** This program is distributed in the hope that it will be useful,
|
||||
** but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
** GNU General Public License for more details.
|
||||
**
|
||||
** You should have received a copy of the GNU General Public License
|
||||
** along with this program; if not, write to the Free Software
|
||||
** Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
|
||||
**
|
||||
***********************************************************************************************************************/
|
||||
|
||||
#ifndef GPUI_ABSTRACT_LOGGER_H
|
||||
#define GPUI_ABSTRACT_LOGGER_H
|
||||
|
||||
#include "../core.h"
|
||||
#include "loggermessage.h"
|
||||
|
||||
#include <fstream>
|
||||
#include <unordered_map>
|
||||
#include <QtMsgHandler>
|
||||
|
||||
#define LOG_LEVEL_DISABLED static_cast<QtMsgType>(-1)
|
||||
|
||||
namespace gpui
|
||||
{
|
||||
namespace logger
|
||||
{
|
||||
class GPUI_CORE_EXPORT Logger
|
||||
{
|
||||
public:
|
||||
Logger() = default;
|
||||
virtual ~Logger() = default;
|
||||
|
||||
void setLogLevel(QtMsgType level);
|
||||
bool isLogLevel(QtMsgType level);
|
||||
|
||||
void logMessage(const LoggerMessage &message);
|
||||
|
||||
private:
|
||||
Logger(const Logger &) = delete; // copy ctor
|
||||
Logger(Logger &&) = delete; // move ctor
|
||||
Logger &operator=(const Logger &) = delete; // copy assignment
|
||||
Logger &operator=(Logger &&) = delete; // move assignment
|
||||
|
||||
private:
|
||||
virtual void log(const LoggerMessage &message) = 0;
|
||||
|
||||
QtMsgType minLogLevel = QtDebugMsg;
|
||||
|
||||
protected:
|
||||
const std::unordered_map<QtMsgType, const char *> logLevelMap = {
|
||||
{QtDebugMsg, "DEBUG"},
|
||||
{QtInfoMsg, "INFO"},
|
||||
{QtWarningMsg, "WARNING"},
|
||||
{QtCriticalMsg, "CRITICAL"},
|
||||
{QtFatalMsg, "FATAL"},
|
||||
};
|
||||
};
|
||||
} // namespace logger
|
||||
} // namespace gpui
|
||||
|
||||
#endif // GPUI_ABSTRACT_LOGGER_H
|
184
src/core/logger/loggermanager.cpp
Normal file
184
src/core/logger/loggermanager.cpp
Normal file
@ -0,0 +1,184 @@
|
||||
/***********************************************************************************************************************
|
||||
**
|
||||
** Copyright (C) 2022 BaseALT Ltd. <org@basealt.ru>
|
||||
**
|
||||
** This program is free software; you can redistribute it and/or
|
||||
** modify it under the terms of the GNU General Public License
|
||||
** as published by the Free Software Foundation; either version 2
|
||||
** of the License, or (at your option) any later version.
|
||||
**
|
||||
** This program is distributed in the hope that it will be useful,
|
||||
** but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
** GNU General Public License for more details.
|
||||
**
|
||||
** You should have received a copy of the GNU General Public License
|
||||
** along with this program; if not, write to the Free Software
|
||||
** Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
|
||||
**
|
||||
***********************************************************************************************************************/
|
||||
|
||||
#include "loggermanager.h"
|
||||
|
||||
#include <algorithm>
|
||||
#include <iostream>
|
||||
|
||||
/*!
|
||||
* \brief getCurrentTime Returns current system time.
|
||||
* \return Time struct.
|
||||
*/
|
||||
static std::tm getCurrentTime()
|
||||
{
|
||||
time_t time;
|
||||
std::time(&time);
|
||||
|
||||
// NOTE: localtime returns a pointer to a statically allocated object
|
||||
return *std::localtime(&time);
|
||||
}
|
||||
|
||||
namespace gpui
|
||||
{
|
||||
namespace logger
|
||||
{
|
||||
class LoggerManagerPrivate
|
||||
{
|
||||
public:
|
||||
std::vector<std::shared_ptr<Logger>> loggers = {};
|
||||
mutable std::mutex loggerMutex = {};
|
||||
};
|
||||
|
||||
/*!
|
||||
* \class LoggerManager loggermanager.h
|
||||
* \brief Class for managing loggers.
|
||||
* \ingroup logger
|
||||
*
|
||||
* Provides ability to enable new loggers.
|
||||
*/
|
||||
|
||||
std::shared_ptr<LoggerManager> LoggerManager::instance{nullptr};
|
||||
|
||||
/*!
|
||||
* \brief LoggerManager::LoggerManager Create new LoggerManager.
|
||||
*
|
||||
* Installs qt message handler to its own static function.
|
||||
*/
|
||||
LoggerManager::LoggerManager()
|
||||
: d(new LoggerManagerPrivate)
|
||||
{
|
||||
qInstallMessageHandler(LoggerManager::messageHandler);
|
||||
}
|
||||
|
||||
/*!
|
||||
* \brief LoggerManager::~LoggerManager Destroy logger manager.
|
||||
*/
|
||||
LoggerManager::~LoggerManager()
|
||||
{
|
||||
delete d;
|
||||
}
|
||||
|
||||
/*!
|
||||
* \brief LoggerManager::destroyInstance Destroy global logger manager instance.
|
||||
*/
|
||||
void LoggerManager::destroyInstance()
|
||||
{
|
||||
instance.reset();
|
||||
}
|
||||
|
||||
/*!
|
||||
* \brief LoggerManager::addLogger Add new logger.
|
||||
* \param logger New logger.
|
||||
*
|
||||
* Enables given logger.
|
||||
*/
|
||||
void LoggerManager::addLogger(std::shared_ptr<Logger> logger)
|
||||
{
|
||||
std::lock_guard<std::mutex> lockGuardLogger(d->loggerMutex);
|
||||
d->loggers.push_back(logger);
|
||||
}
|
||||
|
||||
/*!
|
||||
* \brief LoggerManager::removeLogger Remove logger.
|
||||
* \param logger Logger.
|
||||
*
|
||||
* Disables given logger.
|
||||
*/
|
||||
void LoggerManager::removeLogger(std::shared_ptr<Logger> logger)
|
||||
{
|
||||
std::lock_guard<std::mutex> lockGuardLogger(d->loggerMutex);
|
||||
const auto search = std::find(d->loggers.begin(), d->loggers.end(), logger);
|
||||
|
||||
if (search != d->loggers.end())
|
||||
{
|
||||
d->loggers.erase(search);
|
||||
}
|
||||
}
|
||||
|
||||
/*!
|
||||
* \brief LoggerManager::clearLoggers Remove all logger.
|
||||
*
|
||||
* Disables all loggers.
|
||||
*/
|
||||
void LoggerManager::clearLoggers()
|
||||
{
|
||||
d->loggers.clear();
|
||||
}
|
||||
|
||||
/*!
|
||||
* \brief LoggerManager::log Log message to all loggers.
|
||||
* \param msgType Log level.
|
||||
* \param message Message text.
|
||||
* \param file File where logger was invoked.
|
||||
* \param function Function where logger was invoked.
|
||||
* \param line Line where logger was invoked.
|
||||
*/
|
||||
void LoggerManager::log(const QtMsgType &msgType,
|
||||
const std::string &message,
|
||||
const std::string &file,
|
||||
const std::string &function,
|
||||
const uint32_t line)
|
||||
{
|
||||
std::lock_guard<std::mutex> lockGuardLogger(d->loggerMutex);
|
||||
for (const auto &logger : d->loggers)
|
||||
{
|
||||
logger->logMessage(
|
||||
LoggerMessage(msgType, message, file, function, line, getCurrentTime(), std::this_thread::get_id()));
|
||||
}
|
||||
}
|
||||
|
||||
/*!
|
||||
* \brief LoggerManager::getLoggerCount Get number of enabled loggers.
|
||||
* \return Number of loggers.
|
||||
*/
|
||||
size_t LoggerManager::getLoggerCount() const
|
||||
{
|
||||
std::lock_guard<std::mutex> lockGuardLogger(d->loggerMutex);
|
||||
return d->loggers.size();
|
||||
}
|
||||
|
||||
/*!
|
||||
* \brief LoggerManager::messageHandler Handler of all log messages.
|
||||
* \param msgType Log level.
|
||||
* \param context Qt context.
|
||||
* \param msg Message text.
|
||||
*/
|
||||
void LoggerManager::messageHandler(QtMsgType msgType, const QMessageLogContext &context, const QString &msg)
|
||||
{
|
||||
auto logger = globalInstance();
|
||||
std::string file = context.file ? context.file : "";
|
||||
std::string function = context.function ? context.function : "";
|
||||
int line = context.line;
|
||||
|
||||
logger->log(msgType, msg.toStdString(), file, function, line);
|
||||
}
|
||||
|
||||
Q_GLOBAL_STATIC(LoggerManager, loggerInstance)
|
||||
/*!
|
||||
* \brief LoggerManager::globalInstance Get global instance of logger manager.
|
||||
* \return Pointer to logger manager.
|
||||
*/
|
||||
LoggerManager *LoggerManager::globalInstance()
|
||||
{
|
||||
return loggerInstance();
|
||||
}
|
||||
} // namespace logger
|
||||
} // namespace gpui
|
82
src/core/logger/loggermanager.h
Normal file
82
src/core/logger/loggermanager.h
Normal file
@ -0,0 +1,82 @@
|
||||
/***********************************************************************************************************************
|
||||
**
|
||||
** Copyright (C) 2022 BaseALT Ltd. <org@basealt.ru>
|
||||
**
|
||||
** This program is free software; you can redistribute it and/or
|
||||
** modify it under the terms of the GNU General Public License
|
||||
** as published by the Free Software Foundation; either version 2
|
||||
** of the License, or (at your option) any later version.
|
||||
**
|
||||
** This program is distributed in the hope that it will be useful,
|
||||
** but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
** GNU General Public License for more details.
|
||||
**
|
||||
** You should have received a copy of the GNU General Public License
|
||||
** along with this program; if not, write to the Free Software
|
||||
** Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
|
||||
**
|
||||
***********************************************************************************************************************/
|
||||
|
||||
#ifndef GPUI_LOGGER_MANAGER_H
|
||||
#define GPUI_LOGGER_MANAGER_H
|
||||
|
||||
#include "../core.h"
|
||||
#include "logger.h"
|
||||
|
||||
#include <memory>
|
||||
#include <mutex>
|
||||
#include <vector>
|
||||
|
||||
#include <QString>
|
||||
|
||||
namespace gpui
|
||||
{
|
||||
namespace logger
|
||||
{
|
||||
class LoggerManagerPrivate;
|
||||
|
||||
class GPUI_CORE_EXPORT LoggerManager
|
||||
{
|
||||
public:
|
||||
static LoggerManager *globalInstance();
|
||||
static void destroyInstance();
|
||||
|
||||
LoggerManager();
|
||||
~LoggerManager();
|
||||
|
||||
void addLogger(std::shared_ptr<Logger> logger);
|
||||
void removeLogger(std::shared_ptr<Logger> logger);
|
||||
void clearLoggers();
|
||||
size_t getLoggerCount() const;
|
||||
|
||||
void log(const QtMsgType &msgType,
|
||||
const std::string &message,
|
||||
const std::string &file,
|
||||
const std::string &function,
|
||||
const uint32_t line);
|
||||
|
||||
template<typename T>
|
||||
void addLogger(const QtMsgType &level)
|
||||
{
|
||||
auto logger = std::make_shared<T>();
|
||||
logger->setLogLevel(level);
|
||||
this->addLogger(logger);
|
||||
}
|
||||
|
||||
private:
|
||||
LoggerManager(const LoggerManager &) = delete; // copy ctor
|
||||
LoggerManager(LoggerManager &&) = delete; // move ctor
|
||||
LoggerManager &operator=(const LoggerManager &) = delete; // copy assignment
|
||||
LoggerManager &operator=(LoggerManager &&) = delete; // move assignment
|
||||
|
||||
private:
|
||||
static void messageHandler(QtMsgType type, const QMessageLogContext &context, const QString &msg);
|
||||
|
||||
static std::shared_ptr<LoggerManager> instance;
|
||||
LoggerManagerPrivate *d;
|
||||
};
|
||||
} // namespace logger
|
||||
} // namespace gpui
|
||||
|
||||
#endif // GPUI_LOGGER_MANAGER_H
|
75
src/core/logger/loggermessage.h
Normal file
75
src/core/logger/loggermessage.h
Normal file
@ -0,0 +1,75 @@
|
||||
/***********************************************************************************************************************
|
||||
**
|
||||
** Copyright (C) 2022 BaseALT Ltd. <org@basealt.ru>
|
||||
**
|
||||
** This program is free software; you can redistribute it and/or
|
||||
** modify it under the terms of the GNU General Public License
|
||||
** as published by the Free Software Foundation; either version 2
|
||||
** of the License, or (at your option) any later version.
|
||||
**
|
||||
** This program is distributed in the hope that it will be useful,
|
||||
** but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
** GNU General Public License for more details.
|
||||
**
|
||||
** You should have received a copy of the GNU General Public License
|
||||
** along with this program; if not, write to the Free Software
|
||||
** Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
|
||||
**
|
||||
***********************************************************************************************************************/
|
||||
|
||||
#ifndef GPUI_LOGGER_MESSAGE_H
|
||||
#define GPUI_LOGGER_MESSAGE_H
|
||||
|
||||
#include <ctime>
|
||||
#include <string>
|
||||
#include <thread>
|
||||
|
||||
#include <QtMsgHandler>
|
||||
|
||||
namespace gpui
|
||||
{
|
||||
namespace logger
|
||||
{
|
||||
class LoggerMessage
|
||||
{
|
||||
public:
|
||||
LoggerMessage(const QtMsgType &msgType_,
|
||||
const std::string &message_,
|
||||
const std::string &filePath_,
|
||||
const std::string &functionName_,
|
||||
const uint32_t line_,
|
||||
const std::tm &time_,
|
||||
const std::thread::id &threadId_)
|
||||
: msgType(msgType_)
|
||||
, message(message_)
|
||||
, filePath(filePath_)
|
||||
, functionName(functionName_)
|
||||
, line(line_)
|
||||
, time(time_)
|
||||
, threadId(threadId_)
|
||||
{}
|
||||
|
||||
std::string getTimeFormatted(const char *format) const
|
||||
{
|
||||
char timeString[50];
|
||||
// NOTE(mchernigin): do all compilers actually support this?
|
||||
#pragma GCC diagnostic push
|
||||
#pragma GCC diagnostic ignored "-Wformat-nonliteral"
|
||||
strftime(timeString, 50, format, &time);
|
||||
#pragma GCC diagnostic pop
|
||||
return std::string(timeString);
|
||||
}
|
||||
|
||||
const QtMsgType &msgType;
|
||||
const std::string message;
|
||||
const std::string filePath;
|
||||
const std::string functionName;
|
||||
const uint32_t line;
|
||||
const std::tm time;
|
||||
const std::thread::id threadId;
|
||||
};
|
||||
} // namespace logger
|
||||
} // namespace gpui
|
||||
|
||||
#endif // GPUI_LOGGER_MESSAGE_H
|
30
src/core/logger/prelude.h
Normal file
30
src/core/logger/prelude.h
Normal file
@ -0,0 +1,30 @@
|
||||
/***********************************************************************************************************************
|
||||
**
|
||||
** Copyright (C) 2022 BaseALT Ltd. <org@basealt.ru>
|
||||
**
|
||||
** This program is free software; you can redistribute it and/or
|
||||
** modify it under the terms of the GNU General Public License
|
||||
** as published by the Free Software Foundation; either version 2
|
||||
** of the License, or (at your option) any later version.
|
||||
**
|
||||
** This program is distributed in the hope that it will be useful,
|
||||
** but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
** GNU General Public License for more details.
|
||||
**
|
||||
** You should have received a copy of the GNU General Public License
|
||||
** along with this program; if not, write to the Free Software
|
||||
** Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
|
||||
**
|
||||
***********************************************************************************************************************/
|
||||
|
||||
#ifndef GPUI_LOGGERS_H
|
||||
#define GPUI_LOGGERS_H
|
||||
|
||||
#include "loggermanager.h"
|
||||
|
||||
#include "consolelogger.h"
|
||||
#include "filelogger.h"
|
||||
#include "sysloglogger.h"
|
||||
|
||||
#endif // GPUI_LOGGERS_H
|
86
src/core/logger/sysloglogger.cpp
Normal file
86
src/core/logger/sysloglogger.cpp
Normal file
@ -0,0 +1,86 @@
|
||||
/***********************************************************************************************************************
|
||||
**
|
||||
** Copyright (C) 2022 BaseALT Ltd. <org@basealt.ru>
|
||||
**
|
||||
** This program is free software; you can redistribute it and/or
|
||||
** modify it under the terms of the GNU General Public License
|
||||
** as published by the Free Software Foundation; either version 2
|
||||
** of the License, or (at your option) any later version.
|
||||
**
|
||||
** This program is distributed in the hope that it will be useful,
|
||||
** but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
** GNU General Public License for more details.
|
||||
**
|
||||
** You should have received a copy of the GNU General Public License
|
||||
** along with this program; if not, write to the Free Software
|
||||
** Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
|
||||
**
|
||||
***********************************************************************************************************************/
|
||||
|
||||
#include "sysloglogger.h"
|
||||
|
||||
#include <sstream>
|
||||
#include <syslog.h>
|
||||
|
||||
namespace gpui
|
||||
{
|
||||
namespace logger
|
||||
{
|
||||
/*!
|
||||
* \class SyslogLogger syslogger.h
|
||||
* \brief Implementation of logger which logs messages to syslog.
|
||||
* \ingroup logger
|
||||
*/
|
||||
|
||||
/*!
|
||||
* \brief SyslogLogger::SyslogLogger Create new syslog logger.
|
||||
*
|
||||
* Opens syslog connection.
|
||||
*/
|
||||
SyslogLogger::SyslogLogger()
|
||||
{
|
||||
openlog("gpui", (LOG_CONS | LOG_PID), LOG_USER);
|
||||
}
|
||||
|
||||
/*!
|
||||
* \brief SyslogLogger::~SyslogLogger Destroy syslog logger.
|
||||
*
|
||||
* Closes syslog connection.
|
||||
*/
|
||||
SyslogLogger::~SyslogLogger()
|
||||
{
|
||||
closelog();
|
||||
}
|
||||
|
||||
/*!
|
||||
* \brief SyslogLogger::log Send message to syslog.
|
||||
* \param message Message.
|
||||
*/
|
||||
void SyslogLogger::log(const LoggerMessage &message)
|
||||
{
|
||||
const char *prefix = this->logLevelMap.at(message.msgType);
|
||||
|
||||
int logFlag = LOG_DEBUG;
|
||||
switch (message.msgType)
|
||||
{
|
||||
case QtInfoMsg:
|
||||
logFlag = LOG_INFO;
|
||||
break;
|
||||
case QtWarningMsg:
|
||||
logFlag = LOG_WARNING;
|
||||
break;
|
||||
case QtCriticalMsg:
|
||||
logFlag = LOG_ERR;
|
||||
break;
|
||||
case QtFatalMsg:
|
||||
logFlag = LOG_CRIT;
|
||||
break;
|
||||
default:
|
||||
break;
|
||||
}
|
||||
|
||||
syslog(logFlag, "%s: %s (%s:%u)", prefix, message.message.c_str(), message.filePath.c_str(), message.line);
|
||||
}
|
||||
} // namespace logger
|
||||
} // namespace gpui
|
46
src/core/logger/sysloglogger.h
Normal file
46
src/core/logger/sysloglogger.h
Normal file
@ -0,0 +1,46 @@
|
||||
/***********************************************************************************************************************
|
||||
**
|
||||
** Copyright (C) 2022 BaseALT Ltd. <org@basealt.ru>
|
||||
**
|
||||
** This program is free software; you can redistribute it and/or
|
||||
** modify it under the terms of the GNU General Public License
|
||||
** as published by the Free Software Foundation; either version 2
|
||||
** of the License, or (at your option) any later version.
|
||||
**
|
||||
** This program is distributed in the hope that it will be useful,
|
||||
** but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
** GNU General Public License for more details.
|
||||
**
|
||||
** You should have received a copy of the GNU General Public License
|
||||
** along with this program; if not, write to the Free Software
|
||||
** Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
|
||||
**
|
||||
***********************************************************************************************************************/
|
||||
|
||||
#ifndef GPUI_SYSLOG_LOGGER_H
|
||||
#define GPUI_SYSLOG_LOGGER_H
|
||||
|
||||
#include "logger.h"
|
||||
#include "loggermessage.h"
|
||||
#include "../core.h"
|
||||
|
||||
#include <fstream>
|
||||
|
||||
namespace gpui
|
||||
{
|
||||
namespace logger
|
||||
{
|
||||
class GPUI_CORE_EXPORT SyslogLogger : public Logger
|
||||
{
|
||||
public:
|
||||
SyslogLogger();
|
||||
~SyslogLogger();
|
||||
|
||||
private:
|
||||
void log(const LoggerMessage &message) override;
|
||||
};
|
||||
} // namespace logger
|
||||
} // namespace gpui
|
||||
|
||||
#endif // GPUI_SYSLOG_LOGGER_H
|
75
src/core/plugin.cpp
Normal file
75
src/core/plugin.cpp
Normal file
@ -0,0 +1,75 @@
|
||||
/***********************************************************************************************************************
|
||||
**
|
||||
** Copyright (C) 2022 BaseALT Ltd. <org@basealt.ru>
|
||||
**
|
||||
** This program is free software; you can redistribute it and/or
|
||||
** modify it under the terms of the GNU General Public License
|
||||
** as published by the Free Software Foundation; either version 2
|
||||
** of the License, or (at your option) any later version.
|
||||
**
|
||||
** This program is distributed in the hope that it will be useful,
|
||||
** but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
** GNU General Public License for more details.
|
||||
**
|
||||
** You should have received a copy of the GNU General Public License
|
||||
** along with this program; if not, write to the Free Software
|
||||
** Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
|
||||
**
|
||||
***********************************************************************************************************************/
|
||||
|
||||
#include "plugin.h"
|
||||
#include "pluginstorage.h"
|
||||
|
||||
#include <QLibrary>
|
||||
|
||||
namespace gpui
|
||||
{
|
||||
class PluginPrivate
|
||||
{
|
||||
public:
|
||||
QString name = {};
|
||||
std::unique_ptr<QLibrary> library = nullptr;
|
||||
std::map<QString, std::function<void *()>> pluginClasses = {};
|
||||
};
|
||||
|
||||
Plugin::~Plugin()
|
||||
{
|
||||
delete d;
|
||||
}
|
||||
|
||||
const QString &Plugin::getName() const
|
||||
{
|
||||
return d->name;
|
||||
}
|
||||
|
||||
void Plugin::setLibrary(std::unique_ptr<QLibrary> library)
|
||||
{
|
||||
d->library = std::move(library);
|
||||
}
|
||||
|
||||
QLibrary *Plugin::getLibrary() const
|
||||
{
|
||||
return d->library.get();
|
||||
}
|
||||
|
||||
const std::map<QString, std::function<void *()>> &Plugin::getPluginClasses() const
|
||||
{
|
||||
return d->pluginClasses;
|
||||
}
|
||||
|
||||
Plugin::Plugin(const QString &name)
|
||||
: d(new PluginPrivate())
|
||||
{
|
||||
d->name = name;
|
||||
}
|
||||
|
||||
Plugin::Plugin(const char *name)
|
||||
: Plugin(QString(name))
|
||||
{}
|
||||
|
||||
void Plugin::registerPluginClass(const QString &name, std::function<void *()> constructor)
|
||||
{
|
||||
d->pluginClasses[name] = constructor;
|
||||
}
|
||||
} // namespace gpui
|
@ -1,6 +1,6 @@
|
||||
/***********************************************************************************************************************
|
||||
**
|
||||
** Copyright (C) 2021 BaseALT Ltd. <org@basealt.ru>
|
||||
** Copyright (C) 2022 BaseALT Ltd. <org@basealt.ru>
|
||||
**
|
||||
** This program is free software; you can redistribute it and/or
|
||||
** modify it under the terms of the GNU General Public License
|
||||
@ -21,7 +21,7 @@
|
||||
#ifndef GPUI_PLUGIN_H
|
||||
#define GPUI_PLUGIN_H
|
||||
|
||||
#include "model.h"
|
||||
#include "core.h"
|
||||
|
||||
#include "common.h"
|
||||
|
||||
@ -32,40 +32,43 @@
|
||||
class QLibrary;
|
||||
class QString;
|
||||
|
||||
namespace gpui {
|
||||
class PluginPrivate;
|
||||
class PluginStorage;
|
||||
namespace gpui
|
||||
{
|
||||
class PluginPrivate;
|
||||
class PluginStorage;
|
||||
|
||||
class GPUI_MODEL_EXPORT Plugin
|
||||
{
|
||||
public:
|
||||
virtual ~Plugin();
|
||||
class GPUI_CORE_EXPORT Plugin
|
||||
{
|
||||
public:
|
||||
virtual ~Plugin();
|
||||
|
||||
const QString& getName() const;
|
||||
const QString &getName() const;
|
||||
|
||||
void setLibrary(std::unique_ptr<QLibrary> library);
|
||||
QLibrary* getLibrary() const;
|
||||
void setLibrary(std::unique_ptr<QLibrary> library);
|
||||
QLibrary *getLibrary() const;
|
||||
|
||||
const std::map<QString, std::function<void *()> > &getPluginClasses() const;
|
||||
const std::map<QString, std::function<void *()>> &getPluginClasses() const;
|
||||
|
||||
protected:
|
||||
explicit Plugin(const QString& name);
|
||||
explicit Plugin(const char* name);
|
||||
protected:
|
||||
explicit Plugin(const QString &name);
|
||||
explicit Plugin(const char *name);
|
||||
|
||||
void registerPluginClass(const QString& name, std::function<void*()> constructor);
|
||||
void registerPluginClass(const QString &name, std::function<void *()> constructor);
|
||||
|
||||
private:
|
||||
PluginPrivate* d;
|
||||
};
|
||||
}
|
||||
private:
|
||||
Plugin(const Plugin &) = delete; // copy ctor
|
||||
Plugin(Plugin &&) = delete; // move ctor
|
||||
Plugin &operator=(const Plugin &) = delete; // copy assignment
|
||||
Plugin &operator=(Plugin &&) = delete; // move assignment
|
||||
|
||||
private:
|
||||
PluginPrivate *d;
|
||||
};
|
||||
} // namespace gpui
|
||||
|
||||
#define GPUI_EXPORT_PLUGIN(name, className) \
|
||||
extern "C" GPUI_SYMBOL_EXPORT gpui::Plugin* gpui_plugin_init() \
|
||||
{ \
|
||||
return new className; \
|
||||
}
|
||||
extern "C" GPUI_SYMBOL_EXPORT ::gpui::Plugin *gpui_plugin_init() { return new className; }
|
||||
|
||||
#define GPUI_REGISTER_PLUGIN_CLASS(name, pluginClass) \
|
||||
registerPluginClass(name, [](){ return new pluginClass(); })
|
||||
#define GPUI_REGISTER_PLUGIN_CLASS(name, pluginClass) registerPluginClass(name, []() { return new pluginClass(); })
|
||||
|
||||
#endif // GPUI_PLUGIN_H
|
@ -1,6 +1,6 @@
|
||||
/***********************************************************************************************************************
|
||||
**
|
||||
** Copyright (C) 2021 BaseALT Ltd. <org@basealt.ru>
|
||||
** Copyright (C) 2022 BaseALT Ltd. <org@basealt.ru>
|
||||
**
|
||||
** This program is free software; you can redistribute it and/or
|
||||
** modify it under the terms of the GNU General Public License
|
||||
@ -27,23 +27,22 @@
|
||||
#include <map>
|
||||
#include <memory>
|
||||
|
||||
namespace gpui {
|
||||
|
||||
namespace gpui
|
||||
{
|
||||
class PluginStoragePrivate
|
||||
{
|
||||
public:
|
||||
std::map<QString, std::unique_ptr<Plugin> > pluginMap;
|
||||
std::map<QString, std::map<QString, std::function<void*()> > > classMap;
|
||||
public:
|
||||
std::map<QString, std::unique_ptr<Plugin>> pluginMap = {};
|
||||
std::map<QString, std::map<QString, std::function<void *()>>> classMap = {};
|
||||
};
|
||||
|
||||
PluginStorage::PluginStorage()
|
||||
: d(new PluginStoragePrivate())
|
||||
{
|
||||
}
|
||||
{}
|
||||
|
||||
PluginStorage::~PluginStorage()
|
||||
{
|
||||
for (auto& plugin : d->pluginMap)
|
||||
for (auto &plugin : d->pluginMap)
|
||||
{
|
||||
unloadPlugin(plugin.first);
|
||||
}
|
||||
@ -51,24 +50,25 @@ PluginStorage::~PluginStorage()
|
||||
delete d;
|
||||
}
|
||||
|
||||
Plugin* PluginStorage::getPlugin(const QString& pluginName)
|
||||
Plugin *PluginStorage::getPlugin(const QString &pluginName)
|
||||
{
|
||||
auto search = d->pluginMap.find(pluginName);
|
||||
if (search != d->pluginMap.end()) {
|
||||
if (search != d->pluginMap.end())
|
||||
{
|
||||
return search->second.get();
|
||||
}
|
||||
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
PluginStorage* PluginStorage::instance()
|
||||
{
|
||||
PluginStorage *PluginStorage::instance()
|
||||
{
|
||||
static PluginStorage instance;
|
||||
|
||||
return &instance;
|
||||
}
|
||||
|
||||
bool PluginStorage::loadPlugin(const QFileInfo& fileName)
|
||||
bool PluginStorage::loadPlugin(const QFileInfo &fileName, QString &pluginName)
|
||||
{
|
||||
std::unique_ptr<QLibrary> pluginLibrary = std::make_unique<QLibrary>(fileName.absoluteFilePath());
|
||||
if (!pluginLibrary->load())
|
||||
@ -78,8 +78,8 @@ bool PluginStorage::loadPlugin(const QFileInfo& fileName)
|
||||
return false;
|
||||
}
|
||||
|
||||
typedef gpui::Plugin* (*gpui_plugin_init)();
|
||||
gpui_plugin_init initFunction = (gpui_plugin_init)pluginLibrary->resolve("gpui_plugin_init");
|
||||
typedef ::gpui::Plugin *(*gpui_plugin_init)();
|
||||
gpui_plugin_init initFunction = reinterpret_cast<gpui_plugin_init>(pluginLibrary->resolve("gpui_plugin_init"));
|
||||
|
||||
if (!initFunction)
|
||||
{
|
||||
@ -88,17 +88,20 @@ bool PluginStorage::loadPlugin(const QFileInfo& fileName)
|
||||
return false;
|
||||
}
|
||||
|
||||
Plugin* plugin = initFunction();
|
||||
Plugin *plugin = initFunction();
|
||||
|
||||
if (!plugin) {
|
||||
if (!plugin)
|
||||
{
|
||||
// TODO: Log results.
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
pluginName = plugin->getName();
|
||||
|
||||
plugin->setLibrary(std::move(pluginLibrary));
|
||||
|
||||
for (const auto& entry : plugin->getPluginClasses())
|
||||
for (const auto &entry : plugin->getPluginClasses())
|
||||
{
|
||||
registerPluginClass(plugin->getName(), entry.first, entry.second);
|
||||
}
|
||||
@ -108,22 +111,24 @@ bool PluginStorage::loadPlugin(const QFileInfo& fileName)
|
||||
return true;
|
||||
}
|
||||
|
||||
void PluginStorage::loadPluginDirectory(const QString& directoryName)
|
||||
void PluginStorage::loadPluginDirectory(const QString &directoryName)
|
||||
{
|
||||
QDir directory(directoryName);
|
||||
const QFileInfoList files = directory.entryInfoList();
|
||||
QString pluginName;
|
||||
|
||||
for (const QFileInfo& file : files) {
|
||||
loadPlugin(file);
|
||||
for (const QFileInfo &file : files)
|
||||
{
|
||||
loadPlugin(file, pluginName);
|
||||
}
|
||||
}
|
||||
|
||||
bool PluginStorage::unloadPlugin(const QString& pluginName)
|
||||
bool PluginStorage::unloadPlugin(const QString &pluginName)
|
||||
{
|
||||
auto search = d->pluginMap.find(pluginName);
|
||||
if (search != d->pluginMap.end())
|
||||
{
|
||||
for (const auto& entry : search->second->getPluginClasses())
|
||||
for (const auto &entry : search->second->getPluginClasses())
|
||||
{
|
||||
unregisterPluginClass(search->second->getName(), entry.first);
|
||||
}
|
||||
@ -136,7 +141,7 @@ bool PluginStorage::unloadPlugin(const QString& pluginName)
|
||||
return false;
|
||||
}
|
||||
|
||||
bool PluginStorage::unloadPlugin(Plugin* plugin)
|
||||
bool PluginStorage::unloadPlugin(Plugin *plugin)
|
||||
{
|
||||
if (plugin)
|
||||
{
|
||||
@ -147,29 +152,38 @@ bool PluginStorage::unloadPlugin(Plugin* plugin)
|
||||
}
|
||||
|
||||
void PluginStorage::loadDefaultPlugins()
|
||||
{
|
||||
{
|
||||
loadPluginDirectory("/usr/lib/gpui/plugins/");
|
||||
loadPluginDirectory("/usr/lib64/gpui/plugins/");
|
||||
|
||||
QString customPluginDir = qgetenv("GPUI_PLUGIN_DIRECTORY");
|
||||
if (!customPluginDir.isEmpty())
|
||||
{
|
||||
loadPluginDirectory(customPluginDir);
|
||||
}
|
||||
}
|
||||
|
||||
void PluginStorage::registerPluginClass(const QString& pluginName, const QString& className, std::function<void*()> constructor)
|
||||
void PluginStorage::registerPluginClass(const QString &pluginName,
|
||||
const QString &className,
|
||||
std::function<void *()> constructor)
|
||||
{
|
||||
auto search = d->classMap.find(pluginName);
|
||||
if (search == d->classMap.end())
|
||||
{
|
||||
d->classMap[pluginName] = std::map<QString, std::function<void*()> >();
|
||||
d->classMap[pluginName] = std::map<QString, std::function<void *()>>();
|
||||
}
|
||||
std::map<QString, std::function<void*()> >& pluginConstructors = d->classMap[pluginName];
|
||||
pluginConstructors[className] = constructor;
|
||||
std::map<QString, std::function<void *()>> &pluginConstructors = d->classMap[pluginName];
|
||||
pluginConstructors[className] = constructor;
|
||||
}
|
||||
|
||||
bool PluginStorage::unregisterPluginClass(const QString& pluginName, const QString& className)
|
||||
bool PluginStorage::unregisterPluginClass(const QString &pluginName, const QString &className)
|
||||
{
|
||||
auto plugin = d->classMap.find(pluginName);
|
||||
if (plugin != d->classMap.end())
|
||||
{
|
||||
auto search = plugin->second.find(className);
|
||||
if (search != plugin->second.end()) {
|
||||
if (search != plugin->second.end())
|
||||
{
|
||||
d->classMap[pluginName].erase(search);
|
||||
return true;
|
||||
}
|
||||
@ -178,15 +192,19 @@ bool PluginStorage::unregisterPluginClass(const QString& pluginName, const QStri
|
||||
return false;
|
||||
}
|
||||
|
||||
void* PluginStorage::createPluginClass(const QString &className, const QString &pluginName)
|
||||
void *PluginStorage::createPluginClass(const QString &className, const QString &pluginName)
|
||||
{
|
||||
auto search = d->classMap.find(pluginName);
|
||||
if (search != d->classMap.end())
|
||||
{
|
||||
return search->second[className]();
|
||||
auto classType = search->second.find(className);
|
||||
if (classType != search->second.end())
|
||||
{
|
||||
return search->second[className]();
|
||||
}
|
||||
}
|
||||
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
}
|
||||
} // namespace gpui
|
@ -1,6 +1,6 @@
|
||||
/***********************************************************************************************************************
|
||||
**
|
||||
** Copyright (C) 2021 BaseALT Ltd. <org@basealt.ru>
|
||||
** Copyright (C) 2022 BaseALT Ltd. <org@basealt.ru>
|
||||
**
|
||||
** This program is free software; you can redistribute it and/or
|
||||
** modify it under the terms of the GNU General Public License
|
||||
@ -21,7 +21,7 @@
|
||||
#ifndef GPUI_PLUGINSTORAGE_H
|
||||
#define GPUI_PLUGINSTORAGE_H
|
||||
|
||||
#include "model.h"
|
||||
#include "core.h"
|
||||
|
||||
#include <QString>
|
||||
|
||||
@ -30,8 +30,8 @@
|
||||
|
||||
class QFileInfo;
|
||||
|
||||
namespace gpui {
|
||||
|
||||
namespace gpui
|
||||
{
|
||||
class Plugin;
|
||||
class PluginStoragePrivate;
|
||||
|
||||
@ -41,7 +41,7 @@ class PluginStoragePrivate;
|
||||
*
|
||||
* \ingroup gpui
|
||||
*/
|
||||
class GPUI_MODEL_EXPORT PluginStorage
|
||||
class GPUI_CORE_EXPORT PluginStorage
|
||||
{
|
||||
public:
|
||||
/*!
|
||||
@ -49,34 +49,35 @@ public:
|
||||
* \param pluginName
|
||||
* \return
|
||||
*/
|
||||
Plugin *getPlugin(const QString& pluginName);
|
||||
Plugin *getPlugin(const QString &pluginName);
|
||||
|
||||
/*!
|
||||
* \brief loadPlugin
|
||||
* \param fileName
|
||||
* \param pluginName - If load operation was successfull contains name of a plugin.
|
||||
* \return
|
||||
*/
|
||||
bool loadPlugin(const QFileInfo &fileName);
|
||||
bool loadPlugin(const QFileInfo &fileName, QString &pluginName);
|
||||
|
||||
/*!
|
||||
* \brief loadPluginDirectory
|
||||
* \param directoryName
|
||||
*/
|
||||
void loadPluginDirectory(const QString& directoryName);
|
||||
void loadPluginDirectory(const QString &directoryName);
|
||||
|
||||
/*!
|
||||
* \brief unloadPlugin
|
||||
* \param pluginName
|
||||
* \return
|
||||
*/
|
||||
bool unloadPlugin(const QString& pluginName);
|
||||
bool unloadPlugin(const QString &pluginName);
|
||||
|
||||
/*!
|
||||
* \brief unloadPlugin
|
||||
* \param plugin
|
||||
* \return
|
||||
*/
|
||||
bool unloadPlugin(Plugin* plugin);
|
||||
bool unloadPlugin(Plugin *plugin);
|
||||
|
||||
/**
|
||||
* @brief loadDefaultPlugins
|
||||
@ -87,26 +88,32 @@ public:
|
||||
* \brief createPluginClass
|
||||
*/
|
||||
template<typename T>
|
||||
T* createPluginClass(const QString& pluginName)
|
||||
T *createPluginClass(const QString &pluginName)
|
||||
{
|
||||
return reinterpret_cast<T*>(createPluginClass(typeid(T).name(), pluginName));
|
||||
return reinterpret_cast<T *>(createPluginClass(typeid(T).name(), pluginName));
|
||||
}
|
||||
|
||||
static PluginStorage* instance();
|
||||
static PluginStorage *instance();
|
||||
|
||||
private:
|
||||
void registerPluginClass(const QString& pluginName, const QString& className, std::function<void*()> constructor);
|
||||
bool unregisterPluginClass(const QString& pluginName, const QString& className);
|
||||
void registerPluginClass(const QString &pluginName, const QString &className, std::function<void *()> constructor);
|
||||
bool unregisterPluginClass(const QString &pluginName, const QString &className);
|
||||
|
||||
void *createPluginClass(const QString& className, const QString& pluginName);
|
||||
void *createPluginClass(const QString &className, const QString &pluginName);
|
||||
|
||||
PluginStorage();
|
||||
~PluginStorage();
|
||||
|
||||
private:
|
||||
PluginStoragePrivate* d;
|
||||
PluginStorage(const PluginStorage &) = delete; // copy ctor
|
||||
PluginStorage(PluginStorage &&) = delete; // move ctor
|
||||
PluginStorage &operator=(const PluginStorage &) = delete; // copy assignment
|
||||
PluginStorage &operator=(PluginStorage &&) = delete; // move assignment
|
||||
|
||||
private:
|
||||
PluginStoragePrivate *d;
|
||||
};
|
||||
|
||||
}
|
||||
} // namespace gpui
|
||||
|
||||
#endif // GPUI_PLUGINSTORAGE_H
|
50
src/core/snapindetailsdialog.cpp
Normal file
50
src/core/snapindetailsdialog.cpp
Normal file
@ -0,0 +1,50 @@
|
||||
/***********************************************************************************************************************
|
||||
**
|
||||
** Copyright (C) 2022 BaseALT Ltd. <org@basealt.ru>
|
||||
**
|
||||
** This program is free software; you can redistribute it and/or
|
||||
** modify it under the terms of the GNU General Public License
|
||||
** as published by the Free Software Foundation; either version 2
|
||||
** of the License, or (at your option) any later version.
|
||||
**
|
||||
** This program is distributed in the hope that it will be useful,
|
||||
** but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
** GNU General Public License for more details.
|
||||
**
|
||||
** You should have received a copy of the GNU General Public License
|
||||
** along with this program; if not, write to the Free Software
|
||||
** Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
|
||||
**
|
||||
***********************************************************************************************************************/
|
||||
|
||||
#include "snapindetailsdialog.h"
|
||||
#include "ui_snapindetailsdialog.h"
|
||||
|
||||
#include <QDialog>
|
||||
|
||||
namespace gpui
|
||||
{
|
||||
SnapInDetailsDialog::SnapInDetailsDialog(QWidget *parent, ::gpui::ISnapIn *snapIn)
|
||||
: SnapInDetailsDialog(parent)
|
||||
{
|
||||
setSnapIn(snapIn);
|
||||
}
|
||||
|
||||
SnapInDetailsDialog::SnapInDetailsDialog(QWidget *parent)
|
||||
: ISnapInDetailsDialog(parent)
|
||||
, ui(new Ui::SnapInDetailsDialog())
|
||||
{
|
||||
ui->setupUi(this);
|
||||
}
|
||||
|
||||
SnapInDetailsDialog::~SnapInDetailsDialog()
|
||||
{
|
||||
delete ui;
|
||||
}
|
||||
|
||||
void SnapInDetailsDialog::setSnapIn(ISnapIn *snapIn)
|
||||
{
|
||||
ui->snapInWidget->setSnapIn(snapIn);
|
||||
}
|
||||
} // namespace gpui
|
64
src/core/snapindetailsdialog.h
Normal file
64
src/core/snapindetailsdialog.h
Normal file
@ -0,0 +1,64 @@
|
||||
/***********************************************************************************************************************
|
||||
**
|
||||
** Copyright (C) 2022 BaseALT Ltd. <org@basealt.ru>
|
||||
**
|
||||
** This program is free software; you can redistribute it and/or
|
||||
** modify it under the terms of the GNU General Public License
|
||||
** as published by the Free Software Foundation; either version 2
|
||||
** of the License, or (at your option) any later version.
|
||||
**
|
||||
** This program is distributed in the hope that it will be useful,
|
||||
** but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
** GNU General Public License for more details.
|
||||
**
|
||||
** You should have received a copy of the GNU General Public License
|
||||
** along with this program; if not, write to the Free Software
|
||||
** Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
|
||||
**
|
||||
***********************************************************************************************************************/
|
||||
|
||||
#ifndef _SNAPINDETAILSDIALOG_H
|
||||
#define _SNAPINDETAILSDIALOG_H
|
||||
|
||||
#include "core.h"
|
||||
|
||||
#include "isnapin.h"
|
||||
#include "isnapindetailsdialog.h"
|
||||
|
||||
namespace Ui
|
||||
{
|
||||
class SnapInDetailsDialog;
|
||||
}
|
||||
|
||||
namespace gpui
|
||||
{
|
||||
/**
|
||||
* @brief class SnapInDetailsDialog Shows properties of a snap-in.
|
||||
* Provides information on snap-in name, description, version, copyright, lisense.
|
||||
*/
|
||||
class GPUI_CORE_EXPORT SnapInDetailsDialog : public ISnapInDetailsDialog
|
||||
{
|
||||
private:
|
||||
Q_OBJECT
|
||||
|
||||
public:
|
||||
SnapInDetailsDialog(QWidget *parent, ISnapIn *snapIn);
|
||||
SnapInDetailsDialog(QWidget *parent = nullptr);
|
||||
~SnapInDetailsDialog();
|
||||
|
||||
void setSnapIn(ISnapIn *snapIn) override;
|
||||
|
||||
private:
|
||||
SnapInDetailsDialog(const SnapInDetailsDialog &) = delete; // copy ctor
|
||||
SnapInDetailsDialog(SnapInDetailsDialog &&) = delete; // move ctor
|
||||
SnapInDetailsDialog &operator=(const SnapInDetailsDialog &) = delete; // copy assignment
|
||||
SnapInDetailsDialog &operator=(SnapInDetailsDialog &&) = delete; // move assignment
|
||||
|
||||
private:
|
||||
Ui::SnapInDetailsDialog *ui;
|
||||
};
|
||||
|
||||
} // namespace gpui
|
||||
|
||||
#endif //_SNAPINDETAILSDIALOG_H
|
63
src/core/snapindetailsdialog.ui
Normal file
63
src/core/snapindetailsdialog.ui
Normal file
@ -0,0 +1,63 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<ui version="4.0">
|
||||
<class>SnapInDetailsDialog</class>
|
||||
<widget class="QDialog" name="SnapInDetailsDialog">
|
||||
<property name="geometry">
|
||||
<rect>
|
||||
<x>0</x>
|
||||
<y>0</y>
|
||||
<width>500</width>
|
||||
<height>400</height>
|
||||
</rect>
|
||||
</property>
|
||||
<property name="windowTitle">
|
||||
<string>Dialog</string>
|
||||
</property>
|
||||
<layout class="QGridLayout" name="gridLayout">
|
||||
<item row="0" column="0">
|
||||
<widget class="::gpui::SnapInDetailsWidget" name="snapInWidget" native="true">
|
||||
<property name="minimumSize">
|
||||
<size>
|
||||
<width>400</width>
|
||||
<height>300</height>
|
||||
</size>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="1" column="0">
|
||||
<widget class="QDialogButtonBox" name="buttonBox">
|
||||
<property name="standardButtons">
|
||||
<set>QDialogButtonBox::Close</set>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
</layout>
|
||||
</widget>
|
||||
<customwidgets>
|
||||
<customwidget>
|
||||
<class>::gpui::SnapInDetailsWidget</class>
|
||||
<extends>QWidget</extends>
|
||||
<header>snapindetailswidget.h</header>
|
||||
<container>1</container>
|
||||
</customwidget>
|
||||
</customwidgets>
|
||||
<resources/>
|
||||
<connections>
|
||||
<connection>
|
||||
<sender>buttonBox</sender>
|
||||
<signal>clicked(QAbstractButton*)</signal>
|
||||
<receiver>SnapInDetailsDialog</receiver>
|
||||
<slot>close()</slot>
|
||||
<hints>
|
||||
<hint type="sourcelabel">
|
||||
<x>241</x>
|
||||
<y>281</y>
|
||||
</hint>
|
||||
<hint type="destinationlabel">
|
||||
<x>199</x>
|
||||
<y>150</y>
|
||||
</hint>
|
||||
</hints>
|
||||
</connection>
|
||||
</connections>
|
||||
</ui>
|
27
src/core/snapindetailsfactory.cpp
Normal file
27
src/core/snapindetailsfactory.cpp
Normal file
@ -0,0 +1,27 @@
|
||||
/***********************************************************************************************************************
|
||||
**
|
||||
** Copyright (C) 2022 BaseALT Ltd. <org@basealt.ru>
|
||||
**
|
||||
** This program is free software; you can redistribute it and/or
|
||||
** modify it under the terms of the GNU General Public License
|
||||
** as published by the Free Software Foundation; either version 2
|
||||
** of the License, or (at your option) any later version.
|
||||
**
|
||||
** This program is distributed in the hope that it will be useful,
|
||||
** but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
** GNU General Public License for more details.
|
||||
**
|
||||
** You should have received a copy of the GNU General Public License
|
||||
** along with this program; if not, write to the Free Software
|
||||
** Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
|
||||
**
|
||||
***********************************************************************************************************************/
|
||||
|
||||
#include "snapindetailsfactory.h"
|
||||
|
||||
namespace gpui
|
||||
{
|
||||
::gpui::Factory<ISnapInDetailsDialog, QString> SnapInDetailsFactory::factory
|
||||
= ::gpui::Factory<ISnapInDetailsDialog, QString>();
|
||||
}
|
60
src/core/snapindetailsfactory.h
Normal file
60
src/core/snapindetailsfactory.h
Normal file
@ -0,0 +1,60 @@
|
||||
/***********************************************************************************************************************
|
||||
**
|
||||
** Copyright (C) 2022 BaseALT Ltd. <org@basealt.ru>
|
||||
**
|
||||
** This program is free software; you can redistribute it and/or
|
||||
** modify it under the terms of the GNU General Public License
|
||||
** as published by the Free Software Foundation; either version 2
|
||||
** of the License, or (at your option) any later version.
|
||||
**
|
||||
** This program is distributed in the hope that it will be useful,
|
||||
** but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
** GNU General Public License for more details.
|
||||
**
|
||||
** You should have received a copy of the GNU General Public License
|
||||
** along with this program; if not, write to the Free Software
|
||||
** Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
|
||||
**
|
||||
***********************************************************************************************************************/
|
||||
|
||||
#ifndef _SNAPINDETAILSFACTORYBASE_H
|
||||
#define _SNAPINDETAILSFACTORYBASE_H
|
||||
|
||||
#include "core.h"
|
||||
|
||||
#include "factory.h"
|
||||
#include "isnapindetailsdialog.h"
|
||||
|
||||
namespace gpui
|
||||
{
|
||||
/**
|
||||
* @brief Base for all for snap-in dialog factories.
|
||||
*/
|
||||
class GPUI_CORE_EXPORT SnapInDetailsFactory
|
||||
{
|
||||
public:
|
||||
typedef ::gpui::Factory<ISnapInDetailsDialog, QString> Factory;
|
||||
virtual ~SnapInDetailsFactory() = default;
|
||||
|
||||
static Factory::Type create(Factory::Key const &name) { return factory.create(name); }
|
||||
|
||||
template<class Derived>
|
||||
static void define(Factory::Key const &name)
|
||||
{
|
||||
bool new_key = factory.define(name, &Factory::template create_func<ISnapInDetailsDialog, Derived>);
|
||||
if (!new_key)
|
||||
{
|
||||
throw std::logic_error(std::string(__PRETTY_FUNCTION__) + ": name is already registered!");
|
||||
}
|
||||
}
|
||||
|
||||
private:
|
||||
static Factory factory;
|
||||
};
|
||||
|
||||
} // namespace gpui
|
||||
|
||||
#define REGISTER_DETAILS_DIALOG_CLASS(cls) static SnapInDetailsFactory myfactory::define<#cls>(new #cls().getType());
|
||||
|
||||
#endif //_SNAPINDETAILSFACTORYBASE_H
|
56
src/core/snapindetailswidget.cpp
Normal file
56
src/core/snapindetailswidget.cpp
Normal file
@ -0,0 +1,56 @@
|
||||
/***********************************************************************************************************************
|
||||
**
|
||||
** Copyright (C) 2022 BaseALT Ltd. <org@basealt.ru>
|
||||
**
|
||||
** This program is free software; you can redistribute it and/or
|
||||
** modify it under the terms of the GNU General Public License
|
||||
** as published by the Free Software Foundation; either version 2
|
||||
** of the License, or (at your option) any later version.
|
||||
**
|
||||
** This program is distributed in the hope that it will be useful,
|
||||
** but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
** GNU General Public License for more details.
|
||||
**
|
||||
** You should have received a copy of the GNU General Public License
|
||||
** along with this program; if not, write to the Free Software
|
||||
** Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
|
||||
**
|
||||
***********************************************************************************************************************/
|
||||
|
||||
#include "snapindetailswidget.h"
|
||||
#include "ui_snapindetailswidget.h"
|
||||
|
||||
#include <QWidget>
|
||||
|
||||
namespace gpui
|
||||
{
|
||||
SnapInDetailsWidget::SnapInDetailsWidget(QWidget *parent, ::gpui::ISnapIn *snapIn)
|
||||
: SnapInDetailsWidget(parent)
|
||||
{
|
||||
setSnapIn(snapIn);
|
||||
}
|
||||
|
||||
SnapInDetailsWidget::SnapInDetailsWidget(QWidget *parent)
|
||||
: QWidget(parent)
|
||||
, ui(new Ui::SnapInDetailsWidget())
|
||||
{
|
||||
ui->setupUi(this);
|
||||
}
|
||||
|
||||
SnapInDetailsWidget::~SnapInDetailsWidget()
|
||||
{
|
||||
delete ui;
|
||||
}
|
||||
|
||||
void SnapInDetailsWidget::setSnapIn(const ISnapIn *snapIn)
|
||||
{
|
||||
ui->categoryLineEdit->setText(snapIn->getId().toString());
|
||||
ui->copyrightLineEdit->setText(snapIn->getCopyright());
|
||||
ui->descriptionPlainTextEdit->setPlainText(snapIn->getHelpText());
|
||||
ui->licensePlainTextEdit->setPlainText(snapIn->getLicense());
|
||||
ui->nameLineEdit->setText(snapIn->getDisplayName());
|
||||
ui->versionLineEdit->setText(snapIn->getVersion().toString());
|
||||
}
|
||||
|
||||
} // namespace gpui
|
65
src/core/snapindetailswidget.h
Normal file
65
src/core/snapindetailswidget.h
Normal file
@ -0,0 +1,65 @@
|
||||
/***********************************************************************************************************************
|
||||
**
|
||||
** Copyright (C) 2022 BaseALT Ltd. <org@basealt.ru>
|
||||
**
|
||||
** This program is free software; you can redistribute it and/or
|
||||
** modify it under the terms of the GNU General Public License
|
||||
** as published by the Free Software Foundation; either version 2
|
||||
** of the License, or (at your option) any later version.
|
||||
**
|
||||
** This program is distributed in the hope that it will be useful,
|
||||
** but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
** GNU General Public License for more details.
|
||||
**
|
||||
** You should have received a copy of the GNU General Public License
|
||||
** along with this program; if not, write to the Free Software
|
||||
** Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
|
||||
**
|
||||
***********************************************************************************************************************/
|
||||
|
||||
#ifndef _SNAPINDETAILSWIDGET_H
|
||||
#define _SNAPINDETAILSWIDGET_H
|
||||
|
||||
#include "core.h"
|
||||
|
||||
#include <QWidget>
|
||||
|
||||
#include "isnapin.h"
|
||||
|
||||
namespace Ui
|
||||
{
|
||||
class SnapInDetailsWidget;
|
||||
}
|
||||
|
||||
namespace gpui
|
||||
{
|
||||
/**
|
||||
* @brief class SnapInDetailsWidget Shows properties of a snap-in.
|
||||
* Provides information on snap-in name, description, version, copyright, lisense.
|
||||
*/
|
||||
class GPUI_CORE_EXPORT SnapInDetailsWidget : public QWidget
|
||||
{
|
||||
private:
|
||||
Q_OBJECT
|
||||
|
||||
public:
|
||||
SnapInDetailsWidget(QWidget *parent, ISnapIn *snapIn);
|
||||
SnapInDetailsWidget(QWidget *parent);
|
||||
~SnapInDetailsWidget();
|
||||
|
||||
void setSnapIn(const ISnapIn *snapIn);
|
||||
|
||||
private:
|
||||
SnapInDetailsWidget(const SnapInDetailsWidget &) = delete; // copy ctor
|
||||
SnapInDetailsWidget(SnapInDetailsWidget &&) = delete; // move ctor
|
||||
SnapInDetailsWidget &operator=(const SnapInDetailsWidget &) = delete; // copy assignment
|
||||
SnapInDetailsWidget &operator=(SnapInDetailsWidget &&) = delete; // move assignment
|
||||
|
||||
private:
|
||||
Ui::SnapInDetailsWidget *ui;
|
||||
};
|
||||
|
||||
} // namespace gpui
|
||||
|
||||
#endif //_SNAPINDETAILSWIDGET_H
|
120
src/core/snapindetailswidget.ui
Normal file
120
src/core/snapindetailswidget.ui
Normal file
@ -0,0 +1,120 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<ui version="4.0">
|
||||
<class>SnapInDetailsWidget</class>
|
||||
<widget class="QWidget" name="SnapInDetailsWidget">
|
||||
<property name="geometry">
|
||||
<rect>
|
||||
<x>0</x>
|
||||
<y>0</y>
|
||||
<width>400</width>
|
||||
<height>300</height>
|
||||
</rect>
|
||||
</property>
|
||||
<property name="windowTitle">
|
||||
<string>Form</string>
|
||||
</property>
|
||||
<layout class="QGridLayout" name="gridLayout">
|
||||
<item row="3" column="0">
|
||||
<widget class="QLabel" name="descriptionLabel">
|
||||
<property name="text">
|
||||
<string>Description:</string>
|
||||
</property>
|
||||
<property name="buddy">
|
||||
<cstring>descriptionPlainTextEdit</cstring>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="4" column="1">
|
||||
<widget class="QPlainTextEdit" name="licensePlainTextEdit">
|
||||
<property name="readOnly">
|
||||
<bool>true</bool>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="3" column="1">
|
||||
<widget class="QPlainTextEdit" name="descriptionPlainTextEdit">
|
||||
<property name="undoRedoEnabled">
|
||||
<bool>true</bool>
|
||||
</property>
|
||||
<property name="readOnly">
|
||||
<bool>true</bool>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="1" column="0">
|
||||
<widget class="QLabel" name="versionLabel">
|
||||
<property name="text">
|
||||
<string>Version:</string>
|
||||
</property>
|
||||
<property name="buddy">
|
||||
<cstring>versionLineEdit</cstring>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="2" column="1">
|
||||
<widget class="QLineEdit" name="categoryLineEdit">
|
||||
<property name="readOnly">
|
||||
<bool>true</bool>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="1" column="1">
|
||||
<widget class="QLineEdit" name="versionLineEdit">
|
||||
<property name="readOnly">
|
||||
<bool>true</bool>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="5" column="1">
|
||||
<widget class="QLineEdit" name="copyrightLineEdit">
|
||||
<property name="readOnly">
|
||||
<bool>true</bool>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="2" column="0">
|
||||
<widget class="QLabel" name="categoryLabel">
|
||||
<property name="text">
|
||||
<string>Category:</string>
|
||||
</property>
|
||||
<property name="buddy">
|
||||
<cstring>categoryLineEdit</cstring>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="0" column="1">
|
||||
<widget class="QLineEdit" name="nameLineEdit">
|
||||
<property name="readOnly">
|
||||
<bool>true</bool>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="5" column="0">
|
||||
<widget class="QLabel" name="copyrightLabel">
|
||||
<property name="text">
|
||||
<string>Copyright:</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="4" column="0">
|
||||
<widget class="QLabel" name="licenseLabel">
|
||||
<property name="text">
|
||||
<string>License:</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="0" column="0">
|
||||
<widget class="QLabel" name="nameLabel">
|
||||
<property name="text">
|
||||
<string>Name:</string>
|
||||
</property>
|
||||
<property name="buddy">
|
||||
<cstring>nameLineEdit</cstring>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
</layout>
|
||||
</widget>
|
||||
<resources/>
|
||||
<connections/>
|
||||
</ui>
|
83
src/core/snapinloader.cpp
Normal file
83
src/core/snapinloader.cpp
Normal file
@ -0,0 +1,83 @@
|
||||
/***********************************************************************************************************************
|
||||
**
|
||||
** Copyright (C) 2022 BaseALT Ltd. <org@basealt.ru>
|
||||
**
|
||||
** This program is free software; you can redistribute it and/or
|
||||
** modify it under the terms of the GNU General Public License
|
||||
** as published by the Free Software Foundation; either version 2
|
||||
** of the License, or (at your option) any later version.
|
||||
**
|
||||
** This program is distributed in the hope that it will be useful,
|
||||
** but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
** GNU General Public License for more details.
|
||||
**
|
||||
** You should have received a copy of the GNU General Public License
|
||||
** along with this program; if not, write to the Free Software
|
||||
** Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
|
||||
**
|
||||
***********************************************************************************************************************/
|
||||
|
||||
#include "snapinloader.h"
|
||||
|
||||
#include "plugin.h"
|
||||
#include "pluginstorage.h"
|
||||
|
||||
#include "isnapin.h"
|
||||
#include "isnapinmanager.h"
|
||||
|
||||
namespace gpui
|
||||
{
|
||||
class SnapInLoaderPrivate
|
||||
{
|
||||
public:
|
||||
ISnapInManager *manager{nullptr};
|
||||
|
||||
SnapInLoaderPrivate(ISnapInManager *existingManager)
|
||||
: manager(existingManager)
|
||||
{}
|
||||
};
|
||||
|
||||
SnapInLoader::SnapInLoader(ISnapInManager *manager)
|
||||
: d(new SnapInLoaderPrivate(manager))
|
||||
{}
|
||||
|
||||
SnapInLoader::~SnapInLoader()
|
||||
{
|
||||
delete d;
|
||||
}
|
||||
|
||||
void SnapInLoader::loadSnapIns(const QDir &snapInDirectory)
|
||||
{
|
||||
const QFileInfoList files = snapInDirectory.entryInfoList();
|
||||
QString pluginName;
|
||||
|
||||
for (const QFileInfo &file : files)
|
||||
{
|
||||
if (PluginStorage::instance()->loadPlugin(file, pluginName))
|
||||
{
|
||||
auto snapIn = PluginStorage::instance()->createPluginClass<ISnapIn>(pluginName);
|
||||
|
||||
if (snapIn)
|
||||
{
|
||||
d->manager->addSnapIn(snapIn);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void SnapInLoader::loadDefaultSnapIns()
|
||||
{
|
||||
QString customPluginDir = qgetenv("GPUI_PLUGIN_DIRECTORY");
|
||||
if (!customPluginDir.isEmpty())
|
||||
{
|
||||
loadSnapIns(QDir(customPluginDir));
|
||||
}
|
||||
else
|
||||
{
|
||||
loadSnapIns(QDir("/usr/lib/gpui/plugins/"));
|
||||
loadSnapIns(QDir("/usr/lib64/gpui/plugins/"));
|
||||
}
|
||||
}
|
||||
|
||||
} // namespace gpui
|
56
src/core/snapinloader.h
Normal file
56
src/core/snapinloader.h
Normal file
@ -0,0 +1,56 @@
|
||||
/***********************************************************************************************************************
|
||||
**
|
||||
** Copyright (C) 2022 BaseALT Ltd. <org@basealt.ru>
|
||||
**
|
||||
** This program is free software; you can redistribute it and/or
|
||||
** modify it under the terms of the GNU General Public License
|
||||
** as published by the Free Software Foundation; either version 2
|
||||
** of the License, or (at your option) any later version.
|
||||
**
|
||||
** This program is distributed in the hope that it will be useful,
|
||||
** but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
** GNU General Public License for more details.
|
||||
**
|
||||
** You should have received a copy of the GNU General Public License
|
||||
** along with this program; if not, write to the Free Software
|
||||
** Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
|
||||
**
|
||||
***********************************************************************************************************************/
|
||||
|
||||
#ifndef SNAP_IN_LOADER_H
|
||||
#define SNAP_IN_LOADER_H
|
||||
|
||||
#include "core.h"
|
||||
|
||||
#include <QDir>
|
||||
|
||||
namespace gpui
|
||||
{
|
||||
class ISnapInManager;
|
||||
|
||||
class SnapInLoaderPrivate;
|
||||
|
||||
class GPUI_CORE_EXPORT SnapInLoader
|
||||
{
|
||||
public:
|
||||
SnapInLoader(ISnapInManager *manager);
|
||||
~SnapInLoader();
|
||||
|
||||
void loadSnapIns(const QDir &snapInDirectory);
|
||||
|
||||
void loadDefaultSnapIns();
|
||||
|
||||
private:
|
||||
SnapInLoader(const SnapInLoader &) = delete; // copy ctor
|
||||
SnapInLoader(SnapInLoader &&) = delete; // move ctor
|
||||
SnapInLoader &operator=(const SnapInLoader &) = delete; // copy assignment
|
||||
SnapInLoader &operator=(SnapInLoader &&) = delete; // move assignment
|
||||
|
||||
private:
|
||||
SnapInLoaderPrivate *d;
|
||||
};
|
||||
|
||||
} // namespace gpui
|
||||
|
||||
#endif //SNAP_IN_LOADER_H
|
38
src/core/snapinmanagementsettings.h
Normal file
38
src/core/snapinmanagementsettings.h
Normal file
@ -0,0 +1,38 @@
|
||||
/***********************************************************************************************************************
|
||||
**
|
||||
** Copyright (C) 2022 BaseALT Ltd. <org@basealt.ru>
|
||||
**
|
||||
** This program is free software; you can redistribute it and/or
|
||||
** modify it under the terms of the GNU General Public License
|
||||
** as published by the Free Software Foundation; either version 2
|
||||
** of the License, or (at your option) any later version.
|
||||
**
|
||||
** This program is distributed in the hope that it will be useful,
|
||||
** but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
** GNU General Public License for more details.
|
||||
**
|
||||
** You should have received a copy of the GNU General Public License
|
||||
** along with this program; if not, write to the Free Software
|
||||
** Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
|
||||
**
|
||||
***********************************************************************************************************************/
|
||||
|
||||
#ifndef _SNAPINMANAGEMENTSETTINGS_H
|
||||
#define _SNAPINMANAGEMENTSETTINGS_H
|
||||
|
||||
#include "core.h"
|
||||
|
||||
#include <QSettings>
|
||||
|
||||
namespace gpui
|
||||
{
|
||||
class GPUI_CORE_EXPORT SnapInManagementSettings
|
||||
{
|
||||
private:
|
||||
QSettings settings;
|
||||
};
|
||||
|
||||
} // namespace gpui
|
||||
|
||||
#endif //_SNAPINMANAGEMENTSETTINGS_H
|
134
src/core/snapinmanagementwidget.cpp
Normal file
134
src/core/snapinmanagementwidget.cpp
Normal file
@ -0,0 +1,134 @@
|
||||
/***********************************************************************************************************************
|
||||
**
|
||||
** Copyright (C) 2022 BaseALT Ltd. <org@basealt.ru>
|
||||
**
|
||||
** This program is free software; you can redistribute it and/or
|
||||
** modify it under the terms of the GNU General Public License
|
||||
** as published by the Free Software Foundation; either version 2
|
||||
** of the License, or (at your option) any later version.
|
||||
**
|
||||
** This program is distributed in the hope that it will be useful,
|
||||
** but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
** GNU General Public License for more details.
|
||||
**
|
||||
** You should have received a copy of the GNU General Public License
|
||||
** along with this program; if not, write to the Free Software
|
||||
** Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
|
||||
**
|
||||
***********************************************************************************************************************/
|
||||
|
||||
#include "snapinmanagementwidget.h"
|
||||
#include "ui_snapinmanagementwidget.h"
|
||||
|
||||
#include "isnapin.h"
|
||||
#include "snapindetailsfactory.h"
|
||||
|
||||
#include <QTableWidget>
|
||||
#include <QTreeWidgetItem>
|
||||
|
||||
#include <QMessageBox>
|
||||
|
||||
#include <memory>
|
||||
|
||||
Q_DECLARE_METATYPE(::gpui::ISnapIn *)
|
||||
|
||||
namespace gpui
|
||||
{
|
||||
enum TreeItemColumn
|
||||
{
|
||||
FIRST = 0,
|
||||
ENABLED = 0,
|
||||
NAME = 1,
|
||||
VERSION = 2,
|
||||
};
|
||||
|
||||
class SnapInManagementWidgetPrivate
|
||||
{
|
||||
public:
|
||||
Ui::SnapInManagementWidget *ui = nullptr;
|
||||
ISnapInManager *manager = nullptr;
|
||||
std::unique_ptr<SnapInDetailsFactory> factory = nullptr;
|
||||
|
||||
SnapInManagementWidgetPrivate()
|
||||
: ui(new Ui::SnapInManagementWidget())
|
||||
, factory(new SnapInDetailsFactory())
|
||||
{}
|
||||
|
||||
~SnapInManagementWidgetPrivate() { delete ui; }
|
||||
|
||||
private:
|
||||
SnapInManagementWidgetPrivate(const SnapInManagementWidgetPrivate &) = delete; // copy ctor
|
||||
SnapInManagementWidgetPrivate(SnapInManagementWidgetPrivate &&) = delete; // move ctor
|
||||
SnapInManagementWidgetPrivate &operator=(const SnapInManagementWidgetPrivate &)
|
||||
= delete; // copy assignment
|
||||
SnapInManagementWidgetPrivate &operator=(SnapInManagementWidgetPrivate &&)
|
||||
= delete; // move assignment
|
||||
};
|
||||
|
||||
SnapInManagementWidget::SnapInManagementWidget(QWidget *parent, ISnapInManager *manager)
|
||||
: QWidget(parent)
|
||||
, d(new SnapInManagementWidgetPrivate())
|
||||
{
|
||||
d->manager = manager;
|
||||
d->ui->setupUi(this);
|
||||
|
||||
for (ISnapIn *snapIn : manager->getSnapIns())
|
||||
{
|
||||
auto snapInItem = new QTreeWidgetItem();
|
||||
|
||||
auto enabled = true;
|
||||
auto version = snapIn->getVersion();
|
||||
auto displayName = snapIn->getDisplayName();
|
||||
|
||||
snapInItem->setText(ENABLED, enabled ? "Yes" : "No");
|
||||
snapInItem->setText(NAME, displayName);
|
||||
snapInItem->setText(VERSION, version.toString());
|
||||
|
||||
snapInItem->setData(FIRST, Qt::UserRole, QVariant::fromValue(snapIn));
|
||||
|
||||
d->ui->treeWidget->addTopLevelItem(snapInItem);
|
||||
}
|
||||
|
||||
d->ui->treeWidget->expandAll();
|
||||
}
|
||||
|
||||
SnapInManagementWidget::~SnapInManagementWidget()
|
||||
{
|
||||
delete d;
|
||||
}
|
||||
|
||||
void SnapInManagementWidget::on_treeWidget_itemDoubleClicked(QTreeWidgetItem *item, int column)
|
||||
{
|
||||
Q_UNUSED(column);
|
||||
|
||||
if (!item)
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
auto snapIn = item->data(FIRST, Qt::UserRole).value<ISnapIn *>();
|
||||
|
||||
if (snapIn)
|
||||
{
|
||||
try
|
||||
{
|
||||
auto snapInDetailsDialog = d->factory->create(snapIn->getType());
|
||||
if (snapInDetailsDialog)
|
||||
{
|
||||
snapInDetailsDialog->setSnapIn(snapIn);
|
||||
snapInDetailsDialog->exec();
|
||||
}
|
||||
}
|
||||
catch (const std::exception &error)
|
||||
{
|
||||
QMessageBox mb(QMessageBox::Critical,
|
||||
"Error while creating dialog widget",
|
||||
error.what(),
|
||||
QMessageBox::Ok);
|
||||
mb.exec();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
} // namespace gpui
|
67
src/core/snapinmanagementwidget.h
Normal file
67
src/core/snapinmanagementwidget.h
Normal file
@ -0,0 +1,67 @@
|
||||
/***********************************************************************************************************************
|
||||
**
|
||||
** Copyright (C) 2022 BaseALT Ltd. <org@basealt.ru>
|
||||
**
|
||||
** This program is free software; you can redistribute it and/or
|
||||
** modify it under the terms of the GNU General Public License
|
||||
** as published by the Free Software Foundation; either version 2
|
||||
** of the License, or (at your option) any later version.
|
||||
**
|
||||
** This program is distributed in the hope that it will be useful,
|
||||
** but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
** GNU General Public License for more details.
|
||||
**
|
||||
** You should have received a copy of the GNU General Public License
|
||||
** along with this program; if not, write to the Free Software
|
||||
** Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
|
||||
**
|
||||
***********************************************************************************************************************/
|
||||
|
||||
#ifndef _SNAPINMANAGEMENTWIDGET_H
|
||||
#define _SNAPINMANAGEMENTWIDGET_H
|
||||
|
||||
#include "core.h"
|
||||
|
||||
#include <QWidget>
|
||||
|
||||
#include "isnapinmanager.h"
|
||||
|
||||
namespace Ui
|
||||
{
|
||||
class SnapInManagementWidget;
|
||||
}
|
||||
|
||||
class QTreeWidgetItem;
|
||||
|
||||
namespace gpui
|
||||
{
|
||||
class SnapInManagementWidgetPrivate;
|
||||
|
||||
/**
|
||||
* @brief The SnapInManagementWidget class Shows tree of available snap-ins. Enables and disables snap-ins.
|
||||
*/
|
||||
class GPUI_CORE_EXPORT SnapInManagementWidget : public QWidget
|
||||
{
|
||||
Q_OBJECT
|
||||
|
||||
public:
|
||||
SnapInManagementWidget(QWidget *parent, ISnapInManager *manager);
|
||||
~SnapInManagementWidget();
|
||||
|
||||
private slots:
|
||||
void on_treeWidget_itemDoubleClicked(QTreeWidgetItem *item, int column);
|
||||
|
||||
private:
|
||||
SnapInManagementWidget(const SnapInManagementWidget &) = delete; // copy ctor
|
||||
SnapInManagementWidget(SnapInManagementWidget &&) = delete; // move ctor
|
||||
SnapInManagementWidget &operator=(const SnapInManagementWidget &) = delete; // copy assignment
|
||||
SnapInManagementWidget &operator=(SnapInManagementWidget &&) = delete; // move assignment
|
||||
|
||||
private:
|
||||
SnapInManagementWidgetPrivate *d;
|
||||
};
|
||||
|
||||
} // namespace gpui
|
||||
|
||||
#endif //_SNAPINMANAGEMENTWIDGET_H
|
43
src/core/snapinmanagementwidget.ui
Normal file
43
src/core/snapinmanagementwidget.ui
Normal file
@ -0,0 +1,43 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<ui version="4.0">
|
||||
<class>SnapInManagementWidget</class>
|
||||
<widget class="QWidget" name="SnapInManagementWidget">
|
||||
<property name="geometry">
|
||||
<rect>
|
||||
<x>0</x>
|
||||
<y>0</y>
|
||||
<width>412</width>
|
||||
<height>300</height>
|
||||
</rect>
|
||||
</property>
|
||||
<property name="windowTitle">
|
||||
<string>Form</string>
|
||||
</property>
|
||||
<layout class="QGridLayout" name="gridLayout">
|
||||
<item row="0" column="0">
|
||||
<widget class="QTreeWidget" name="treeWidget">
|
||||
<property name="columnCount">
|
||||
<number>3</number>
|
||||
</property>
|
||||
<column>
|
||||
<property name="text">
|
||||
<string>Enabled</string>
|
||||
</property>
|
||||
</column>
|
||||
<column>
|
||||
<property name="text">
|
||||
<string>Name</string>
|
||||
</property>
|
||||
</column>
|
||||
<column>
|
||||
<property name="text">
|
||||
<string>Version</string>
|
||||
</property>
|
||||
</column>
|
||||
</widget>
|
||||
</item>
|
||||
</layout>
|
||||
</widget>
|
||||
<resources/>
|
||||
<connections/>
|
||||
</ui>
|
78
src/core/snapinmanager.cpp
Normal file
78
src/core/snapinmanager.cpp
Normal file
@ -0,0 +1,78 @@
|
||||
/***********************************************************************************************************************
|
||||
**
|
||||
** Copyright (C) 2022 BaseALT Ltd. <org@basealt.ru>
|
||||
**
|
||||
** This program is free software; you can redistribute it and/or
|
||||
** modify it under the terms of the GNU General Public License
|
||||
** as published by the Free Software Foundation; either version 2
|
||||
** of the License, or (at your option) any later version.
|
||||
**
|
||||
** This program is distributed in the hope that it will be useful,
|
||||
** but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
** GNU General Public License for more details.
|
||||
**
|
||||
** You should have received a copy of the GNU General Public License
|
||||
** along with this program; if not, write to the Free Software
|
||||
** Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
|
||||
**
|
||||
***********************************************************************************************************************/
|
||||
|
||||
#include "snapinmanager.h"
|
||||
#include "isnapin.h"
|
||||
|
||||
#include "pluginstorage.h"
|
||||
|
||||
#include <algorithm>
|
||||
|
||||
namespace gpui
|
||||
{
|
||||
class SnapInManagerPrivate
|
||||
{
|
||||
public:
|
||||
std::vector<ISnapIn *> snapIns{};
|
||||
};
|
||||
|
||||
SnapInManager::SnapInManager()
|
||||
: d(new SnapInManagerPrivate())
|
||||
{}
|
||||
|
||||
SnapInManager::~SnapInManager()
|
||||
{
|
||||
for (auto &snapIn : d->snapIns)
|
||||
{
|
||||
if (snapIn)
|
||||
{
|
||||
delete snapIn;
|
||||
snapIn = nullptr;
|
||||
}
|
||||
}
|
||||
|
||||
delete d;
|
||||
}
|
||||
|
||||
void SnapInManager::addSnapIn(ISnapIn *snapIn)
|
||||
{
|
||||
d->snapIns.push_back(snapIn);
|
||||
}
|
||||
|
||||
void SnapInManager::removeSnapIn(ISnapIn *snapIn)
|
||||
{
|
||||
auto element = std::find(d->snapIns.begin(), d->snapIns.end(), snapIn);
|
||||
if (element != d->snapIns.end())
|
||||
{
|
||||
d->snapIns.erase(element);
|
||||
}
|
||||
}
|
||||
|
||||
std::vector<ISnapIn *> SnapInManager::getSnapIns() const
|
||||
{
|
||||
return d->snapIns;
|
||||
}
|
||||
|
||||
void SnapInManager::clear()
|
||||
{
|
||||
d->snapIns.clear();
|
||||
}
|
||||
|
||||
} // namespace gpui
|
62
src/core/snapinmanager.h
Normal file
62
src/core/snapinmanager.h
Normal file
@ -0,0 +1,62 @@
|
||||
/***********************************************************************************************************************
|
||||
**
|
||||
** Copyright (C) 2022 BaseALT Ltd. <org@basealt.ru>
|
||||
**
|
||||
** This program is free software; you can redistribute it and/or
|
||||
** modify it under the terms of the GNU General Public License
|
||||
** as published by the Free Software Foundation; either version 2
|
||||
** of the License, or (at your option) any later version.
|
||||
**
|
||||
** This program is distributed in the hope that it will be useful,
|
||||
** but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
** GNU General Public License for more details.
|
||||
**
|
||||
** You should have received a copy of the GNU General Public License
|
||||
** along with this program; if not, write to the Free Software
|
||||
** Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
|
||||
**
|
||||
***********************************************************************************************************************/
|
||||
|
||||
#ifndef _SnapInManager_H
|
||||
#define _SnapInManager_H
|
||||
|
||||
#include "core.h"
|
||||
|
||||
#include "isnapin.h"
|
||||
#include "isnapinmanager.h"
|
||||
|
||||
namespace gpui
|
||||
{
|
||||
class SnapInManagerPrivate;
|
||||
|
||||
/**
|
||||
* @brief The SnapInManager class provides implementation of ISnapInManager interface.
|
||||
*/
|
||||
class GPUI_CORE_EXPORT SnapInManager final : public ISnapInManager
|
||||
{
|
||||
public:
|
||||
SnapInManager();
|
||||
~SnapInManager();
|
||||
|
||||
void addSnapIn(ISnapIn *snapIn) override final;
|
||||
|
||||
void removeSnapIn(ISnapIn *snapIn) override final;
|
||||
|
||||
std::vector<ISnapIn *> getSnapIns() const override final;
|
||||
|
||||
void clear() override final;
|
||||
|
||||
private:
|
||||
SnapInManager(const SnapInManager &) = delete; // copy ctor
|
||||
SnapInManager(SnapInManager &&) = delete; // move ctor
|
||||
SnapInManager &operator=(const SnapInManager &) = delete; // copy assignment
|
||||
SnapInManager &operator=(SnapInManager &&) = delete; // move assignment
|
||||
|
||||
private:
|
||||
SnapInManagerPrivate *d;
|
||||
};
|
||||
|
||||
} // namespace gpui
|
||||
|
||||
#endif //_SnapInManager_H
|
99
src/core/translatorstorage.cpp
Normal file
99
src/core/translatorstorage.cpp
Normal file
@ -0,0 +1,99 @@
|
||||
/***********************************************************************************************************************
|
||||
**
|
||||
** Copyright (C) 2023 BaseALT Ltd. <org@basealt.ru>
|
||||
**
|
||||
** This program is free software; you can redistribute it and/or
|
||||
** modify it under the terms of the GNU General Public License
|
||||
** as published by the Free Software Foundation; either version 2
|
||||
** of the License, or (at your option) any later version.
|
||||
**
|
||||
** This program is distributed in the hope that it will be useful,
|
||||
** but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
** GNU General Public License for more details.
|
||||
**
|
||||
** You should have received a copy of the GNU General Public License
|
||||
** along with this program; if not, write to the Free Software
|
||||
** Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
|
||||
**
|
||||
***********************************************************************************************************************/
|
||||
|
||||
#include "translatorstorage.h"
|
||||
|
||||
#include <QCoreApplication>
|
||||
#include <QDebug>
|
||||
#include <QDirIterator>
|
||||
#include <QLibraryInfo>
|
||||
|
||||
class TranslatorStoragePrivate
|
||||
{
|
||||
public:
|
||||
std::vector<std::unique_ptr<QTranslator>> translators = {};
|
||||
QString m_errorString = {};
|
||||
};
|
||||
|
||||
TranslatorStorage::TranslatorStorage()
|
||||
: d(new TranslatorStoragePrivate())
|
||||
{}
|
||||
|
||||
TranslatorStorage::~TranslatorStorage()
|
||||
{}
|
||||
|
||||
bool TranslatorStorage::loadTranslators(const QString &language)
|
||||
{
|
||||
return loadTranslators(language, ":/");
|
||||
}
|
||||
|
||||
bool TranslatorStorage::loadTranslators(const QString &language, const QString &path)
|
||||
{
|
||||
QString languageToLoad = language.split("-").at(0);
|
||||
|
||||
QDir dir(path);
|
||||
|
||||
for (auto &entry : dir.entryList())
|
||||
{
|
||||
if (entry.endsWith(languageToLoad + ".qm"))
|
||||
{
|
||||
std::unique_ptr<QTranslator> translator = std::make_unique<QTranslator>();
|
||||
|
||||
if (translator->load(entry, path))
|
||||
{
|
||||
QCoreApplication::installTranslator(translator.get());
|
||||
d->translators.push_back(std::move(translator));
|
||||
}
|
||||
else
|
||||
{
|
||||
setErrorString("WARNING! Can't load translate from file: " + entry);
|
||||
|
||||
return false;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
bool TranslatorStorage::loadQtTranslations(const QString &language, const QString &prefix)
|
||||
{
|
||||
return loadTranslators(QString(prefix + "%1").arg(language), QLibraryInfo::location(QLibraryInfo::TranslationsPath));
|
||||
}
|
||||
|
||||
void TranslatorStorage::clearTranslators()
|
||||
{
|
||||
for (const auto &translator : d->translators)
|
||||
{
|
||||
QCoreApplication::removeTranslator(translator.get());
|
||||
}
|
||||
|
||||
d->translators.clear();
|
||||
}
|
||||
|
||||
void TranslatorStorage::setErrorString(const QString &error)
|
||||
{
|
||||
d->m_errorString = error;
|
||||
}
|
||||
|
||||
QString TranslatorStorage::getErrorString() const
|
||||
{
|
||||
return d->m_errorString;
|
||||
}
|
89
src/core/translatorstorage.h
Normal file
89
src/core/translatorstorage.h
Normal file
@ -0,0 +1,89 @@
|
||||
/***********************************************************************************************************************
|
||||
**
|
||||
** Copyright (C) 2022 BaseALT Ltd. <org@basealt.ru>
|
||||
**
|
||||
** This program is free software; you can redistribute it and/or
|
||||
** modify it under the terms of the GNU General Public License
|
||||
** as published by the Free Software Foundation; either version 2
|
||||
** of the License, or (at your option) any later version.
|
||||
**
|
||||
** This program is distributed in the hope that it will be useful,
|
||||
** but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
** GNU General Public License for more details.
|
||||
**
|
||||
** You should have received a copy of the GNU General Public License
|
||||
** along with this program; if not, write to the Free Software
|
||||
** Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
|
||||
**
|
||||
***********************************************************************************************************************/
|
||||
|
||||
#ifndef GPUI_TRANSLATOR_STORAGE_H
|
||||
#define GPUI_TRANSLATOR_STORAGE_H
|
||||
|
||||
#include "core.h"
|
||||
|
||||
#include <memory>
|
||||
#include <QString>
|
||||
#include <QTranslator>
|
||||
|
||||
class TranslatorStoragePrivate;
|
||||
|
||||
/**
|
||||
* @brief The TranslatorStorage class provides for loading and storing translation files.
|
||||
*/
|
||||
class GPUI_CORE_EXPORT TranslatorStorage
|
||||
{
|
||||
public:
|
||||
TranslatorStorage();
|
||||
~TranslatorStorage();
|
||||
|
||||
/**
|
||||
* @brief loads and install a list of translation files from resources that end with the name of the language from the current directory
|
||||
* @param language to be loaded
|
||||
*/
|
||||
|
||||
bool loadTranslators(const QString &language);
|
||||
|
||||
/**
|
||||
* @brief loads and installs a list of translation files from resources that end with the name of the language from the specified directory
|
||||
* @param language to be loaded
|
||||
* @param path of translation file to be loaded
|
||||
*/
|
||||
bool loadTranslators(const QString &language, const QString &path);
|
||||
|
||||
/**
|
||||
* @brief loads and installs a list of translation qt files from resources that begins with prefix and end with the name of the language in current directory
|
||||
* @param language to be loaded
|
||||
* @param prefix of the file name to be loaded
|
||||
*/
|
||||
bool loadQtTranslations(const QString &language, const QString &prefix);
|
||||
|
||||
/**
|
||||
* @brief removes and uninstalls all translations
|
||||
*/
|
||||
void clearTranslators();
|
||||
|
||||
/**
|
||||
* @brief gets a control error string that might be reused in a different context
|
||||
*/
|
||||
QString getErrorString() const;
|
||||
|
||||
private:
|
||||
std::unique_ptr<TranslatorStoragePrivate> d;
|
||||
|
||||
private:
|
||||
/**
|
||||
* @brief sets a control error string that might be reused in a different context
|
||||
* @param error string
|
||||
*/
|
||||
void setErrorString(const QString &error);
|
||||
|
||||
private:
|
||||
TranslatorStorage(const TranslatorStorage &) = delete;
|
||||
TranslatorStorage(TranslatorStorage &&) = delete;
|
||||
TranslatorStorage &operator=(const TranslatorStorage &) = delete;
|
||||
TranslatorStorage &operator=(TranslatorStorage &&) = delete;
|
||||
};
|
||||
|
||||
#endif // GPUI_TRANSLATOR_STORAGE_H
|
33
src/core/version.h.in
Normal file
33
src/core/version.h.in
Normal file
@ -0,0 +1,33 @@
|
||||
/***********************************************************************************************************************
|
||||
**
|
||||
** Copyright (C) 2021 BaseALT Ltd. <org@basealt.ru>
|
||||
**
|
||||
** This program is free software; you can redistribute it and/or
|
||||
** modify it under the terms of the GNU General Public License
|
||||
** as published by the Free Software Foundation; either version 2
|
||||
** of the License, or (at your option) any later version.
|
||||
**
|
||||
** This program is distributed in the hope that it will be useful,
|
||||
** but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
** GNU General Public License for more details.
|
||||
**
|
||||
** You should have received a copy of the GNU General Public License
|
||||
** along with this program; if not, write to the Free Software
|
||||
** Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
|
||||
**
|
||||
***********************************************************************************************************************/
|
||||
|
||||
#ifndef VERSION_H
|
||||
#define VERSION_H
|
||||
|
||||
const int GPUI_VERSION_MAJOR = ${GPUI_VERSION_MAJOR};
|
||||
const int GPUI_VERSION_MINOR = ${GPUI_VERSION_MINOR};
|
||||
const int GPUI_VERSION_PATCH = ${GPUI_VERSION_PATCH};
|
||||
|
||||
inline QString getApplicationVersion()
|
||||
{
|
||||
return QString("%1.%2.%3").arg(GPUI_VERSION_MAJOR).arg(GPUI_VERSION_MINOR).arg(GPUI_VERSION_PATCH);
|
||||
}
|
||||
|
||||
#endif //VERSION_H
|
@ -4,40 +4,52 @@ set(CMAKE_INCLUDE_CURRENT_DIR ON)
|
||||
|
||||
set(HEADERS
|
||||
aboutdialog.h
|
||||
altspinbox.h
|
||||
contentwidget.h
|
||||
commandlineoptions.h
|
||||
commandlineparser.h
|
||||
filedialogutils.h
|
||||
gptiniutil.h
|
||||
gui.h
|
||||
listboxdialog.h
|
||||
mainwindow.h
|
||||
mainwindowsettings.h
|
||||
presentationbuilder.h
|
||||
pluginwidgetinterface.h
|
||||
treevieweventfilter.h
|
||||
)
|
||||
|
||||
set(SOURCES
|
||||
aboutdialog.cpp
|
||||
altspinbox.cpp
|
||||
commandlineparser.cpp
|
||||
contentwidget.cpp
|
||||
filedialogutils.cpp
|
||||
gptiniutil.cpp
|
||||
gui.cpp
|
||||
listboxdialog.cpp
|
||||
mainwindow.cpp
|
||||
mainwindowsettings.cpp
|
||||
presentationbuilder.cpp
|
||||
treevieweventfilter.cpp
|
||||
)
|
||||
|
||||
set(UI_FORMS
|
||||
aboutdialog.ui
|
||||
contentwidget.ui
|
||||
listboxdialog.ui
|
||||
mainwindow.ui
|
||||
mainwindow.ui
|
||||
)
|
||||
|
||||
set(MOC_HEADERS
|
||||
aboutdialog.h
|
||||
altspinbox.h
|
||||
contentwidget.h
|
||||
gptiniutil.h
|
||||
listboxdialog.h
|
||||
mainwindow.h
|
||||
mainwindowsettings.h
|
||||
pluginwidgetinterface.h
|
||||
treevieweventfilter.h
|
||||
)
|
||||
|
||||
set(TS_FILES
|
||||
@ -60,11 +72,11 @@ add_definitions(
|
||||
-DGPUI_GUI_LIBRARY
|
||||
)
|
||||
|
||||
add_translation_resource(RESOURCES_SRC ${QM_FILES})
|
||||
add_translation_resource(RESOURCES_SRC "gui" ${QM_FILES})
|
||||
|
||||
qt5_add_resources(LIB_RESOURCES ${RESOURCES_SRC} ${ICON_RESOURCES})
|
||||
|
||||
add_gpui_library(gpui-gui ${UI_SOURCES} ${MOC_SOURCES} ${SOURCES} ${LIB_RESOURCES})
|
||||
target_link_libraries(gpui-gui Qt5::Widgets Qt5::Qml)
|
||||
target_link_libraries(gpui-gui gpui-model gpui-io)
|
||||
target_link_libraries(gpui-gui gpui-core gpui-io gpui-ldap)
|
||||
target_link_libraries(gpui-gui smb-storage-static)
|
||||
|
@ -19,17 +19,23 @@
|
||||
***********************************************************************************************************************/
|
||||
|
||||
#include "aboutdialog.h"
|
||||
#include "../core/version.h"
|
||||
|
||||
#include "ui_aboutdialog.h"
|
||||
|
||||
namespace gpui
|
||||
{
|
||||
|
||||
AboutDialog::AboutDialog(QWidget* parent)
|
||||
: QDialog(parent)
|
||||
, ui(new Ui::AboutDialog())
|
||||
{
|
||||
ui->setupUi(this);
|
||||
|
||||
QString text = ui->versionLabel->text();
|
||||
|
||||
text = text.append(getApplicationVersion());
|
||||
|
||||
ui->versionLabel->setText(text);
|
||||
}
|
||||
|
||||
AboutDialog::~AboutDialog()
|
||||
@ -37,5 +43,4 @@ AboutDialog::~AboutDialog()
|
||||
delete ui;
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
@ -39,6 +39,12 @@ namespace gpui
|
||||
AboutDialog(QWidget *parent);
|
||||
~AboutDialog();
|
||||
|
||||
private:
|
||||
AboutDialog(const AboutDialog&) = delete; // copy ctor
|
||||
AboutDialog(AboutDialog&&) = delete; // move ctor
|
||||
AboutDialog& operator=(const AboutDialog&) = delete; // copy assignment
|
||||
AboutDialog& operator=(AboutDialog&&) = delete; // move assignment
|
||||
|
||||
private:
|
||||
Ui::AboutDialog *ui;
|
||||
};
|
||||
|
@ -57,7 +57,7 @@
|
||||
<item>
|
||||
<widget class="QLabel" name="versionLabel">
|
||||
<property name="text">
|
||||
<string>Version 0.2.0</string>
|
||||
<string>Version </string>
|
||||
</property>
|
||||
<property name="alignment">
|
||||
<set>Qt::AlignCenter</set>
|
||||
|
112
src/gui/altspinbox.cpp
Normal file
112
src/gui/altspinbox.cpp
Normal file
@ -0,0 +1,112 @@
|
||||
/***********************************************************************************************************************
|
||||
**
|
||||
** Copyright (C) 2021 BaseALT Ltd. <org@basealt.ru>
|
||||
**
|
||||
** This program is free software; you can redistribute it and/or
|
||||
** modify it under the terms of the GNU General Public License
|
||||
** as published by the Free Software Foundation; either version 2
|
||||
** of the License, or (at your option) any later version.
|
||||
**
|
||||
** This program is distributed in the hope that it will be useful,
|
||||
** but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
** GNU General Public License for more details.
|
||||
**
|
||||
** You should have received a copy of the GNU General Public License
|
||||
** along with this program; if not, write to the Free Software
|
||||
** Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
|
||||
**
|
||||
***********************************************************************************************************************/
|
||||
|
||||
#include "altspinbox.h"
|
||||
|
||||
#include <QDebug>
|
||||
#include <QMessageBox>
|
||||
|
||||
namespace gui
|
||||
{
|
||||
AltSpinBox::AltSpinBox(QWidget *parent)
|
||||
: QSpinBox(parent)
|
||||
{
|
||||
connect(this, &AltSpinBox::fixStringInput, this, &AltSpinBox::onFixStringInput);
|
||||
connect(this, &AltSpinBox::fixToValidRange, this, &AltSpinBox::onFixToValidRange);
|
||||
}
|
||||
|
||||
void AltSpinBox::fixup(QString &input) const
|
||||
{
|
||||
QRegExp regExp("(-?)(\\+?)\\d+");
|
||||
if (!regExp.exactMatch(input))
|
||||
{
|
||||
QSpinBox::fixup(input);
|
||||
return;
|
||||
}
|
||||
bool isOk = false;
|
||||
int value = input.toInt(&isOk);
|
||||
if (isOk)
|
||||
{
|
||||
int boundValue = qBound(minimum(), value, maximum());
|
||||
if (boundValue != value)
|
||||
{
|
||||
emit fixToValidRange(value, boundValue);
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
emit fixStringInput(input);
|
||||
}
|
||||
}
|
||||
|
||||
QValidator::State AltSpinBox::validate(QString &text, int &) const
|
||||
{
|
||||
auto isOk = false;
|
||||
auto value = text.toInt(&isOk, displayIntegerBase());
|
||||
|
||||
if (isOk)
|
||||
{
|
||||
if (value >= minimum() && value <= maximum())
|
||||
{
|
||||
return QValidator::Acceptable;
|
||||
}
|
||||
}
|
||||
|
||||
return QValidator::Intermediate;
|
||||
}
|
||||
|
||||
void AltSpinBox::onFixStringInput(const QString &wrongInput)
|
||||
{
|
||||
int value = wrongInput.contains('-') ? this->minimum() : this->maximum();
|
||||
this->setValue(value);
|
||||
openMessageBox(wrongInput, value == this->maximum());
|
||||
}
|
||||
|
||||
void AltSpinBox::onFixToValidRange(const int currentValue, const int boundValue)
|
||||
{
|
||||
bool isMaximum = boundValue == maximum();
|
||||
this->setValue(boundValue);
|
||||
openMessageBox(QString::number(currentValue, displayIntegerBase()), isMaximum);
|
||||
}
|
||||
|
||||
void AltSpinBox::openMessageBox(const QString &value, bool isMaximum)
|
||||
{
|
||||
if (isMaximum)
|
||||
{
|
||||
QMessageBox::information(nullptr,
|
||||
QObject::tr("Information message"),
|
||||
QObject::tr("Value: ") + value
|
||||
+ QObject::tr(" is greater than maximum allowed value of: ")
|
||||
+ QString::number(this->maximum())
|
||||
+ QObject::tr(". Maximum allowed value has been set."),
|
||||
QMessageBox::Ok);
|
||||
}
|
||||
else
|
||||
{
|
||||
QMessageBox::information(nullptr,
|
||||
QObject::tr("Information message"),
|
||||
QObject::tr("Value: ") + value + QObject::tr(" is less than minimum allowed value of: ")
|
||||
+ QString::number(this->minimum())
|
||||
+ QObject::tr(". Minimum allowed value has been set."),
|
||||
QMessageBox::Ok);
|
||||
}
|
||||
}
|
||||
|
||||
} // namespace gui
|
54
src/gui/altspinbox.h
Normal file
54
src/gui/altspinbox.h
Normal file
@ -0,0 +1,54 @@
|
||||
/***********************************************************************************************************************
|
||||
**
|
||||
** Copyright (C) 2021 BaseALT Ltd. <org@basealt.ru>
|
||||
**
|
||||
** This program is free software; you can redistribute it and/or
|
||||
** modify it under the terms of the GNU General Public License
|
||||
** as published by the Free Software Foundation; either version 2
|
||||
** of the License, or (at your option) any later version.
|
||||
**
|
||||
** This program is distributed in the hope that it will be useful,
|
||||
** but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
** GNU General Public License for more details.
|
||||
**
|
||||
** You should have received a copy of the GNU General Public License
|
||||
** along with this program; if not, write to the Free Software
|
||||
** Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
|
||||
**
|
||||
***********************************************************************************************************************/
|
||||
|
||||
#ifndef GPUI_ALT_SPIN_BOX_H
|
||||
#define GPUI_ALT_SPIN_BOX_H
|
||||
|
||||
#include "gui.h"
|
||||
|
||||
#include <QSpinBox>
|
||||
|
||||
namespace gui
|
||||
{
|
||||
class GPUI_GUI_EXPORT AltSpinBox final : public QSpinBox
|
||||
{
|
||||
Q_OBJECT
|
||||
public:
|
||||
AltSpinBox(QWidget *parent = nullptr);
|
||||
|
||||
protected:
|
||||
void fixup(QString &input) const override;
|
||||
QValidator::State validate(QString &text, int &pos) const override;
|
||||
|
||||
signals:
|
||||
void fixStringInput(const QString &wrongInput) const;
|
||||
void fixToValidRange(const int currentValue, const int boundValue) const;
|
||||
|
||||
private slots:
|
||||
void onFixStringInput(const QString &wrongInput);
|
||||
void onFixToValidRange(const int currentValue, const int boundValue);
|
||||
|
||||
private:
|
||||
void openMessageBox(const QString &value, bool isMaximum);
|
||||
};
|
||||
|
||||
} // namespace gui
|
||||
|
||||
#endif //GPUI_ALT_SPIN_BOX_H
|
@ -23,14 +23,20 @@
|
||||
|
||||
#include <QString>
|
||||
#include <QUuid>
|
||||
#include <QtMessageHandler>
|
||||
|
||||
namespace gpui {
|
||||
class CommandLineOptions
|
||||
{
|
||||
public:
|
||||
QString policyBundle;
|
||||
QString path;
|
||||
};
|
||||
}
|
||||
namespace gpui
|
||||
{
|
||||
class CommandLineOptions
|
||||
{
|
||||
public:
|
||||
QString path{};
|
||||
QString policyBundle{};
|
||||
QString policyName{};
|
||||
QtMsgType consoleLogLevel{};
|
||||
QtMsgType syslogLogLevel{};
|
||||
QtMsgType fileLogLevel{};
|
||||
};
|
||||
} // namespace gpui
|
||||
|
||||
#endif // GPUI_COMMAND_LINE_OPTIONS_H
|
||||
|
@ -20,40 +20,45 @@
|
||||
|
||||
#include "commandlineparser.h"
|
||||
|
||||
#include <iostream>
|
||||
#include <memory>
|
||||
|
||||
#include <QUuid>
|
||||
#include <QCommandLineParser>
|
||||
#include <QTranslator>
|
||||
#include <QLibraryInfo>
|
||||
#include <QTranslator>
|
||||
#include <QUuid>
|
||||
|
||||
namespace gpui
|
||||
{
|
||||
|
||||
class CommandLineParserPrivate
|
||||
{
|
||||
public:
|
||||
QApplication& application;
|
||||
QApplication &application;
|
||||
std::unique_ptr<QCommandLineParser> parser;
|
||||
|
||||
CommandLineParserPrivate(QApplication &application)
|
||||
: application(application)
|
||||
{
|
||||
parser = std::make_unique<QCommandLineParser>();
|
||||
}
|
||||
CommandLineParserPrivate(QApplication ¤tApplication)
|
||||
: application(currentApplication)
|
||||
, parser(std::make_unique<QCommandLineParser>())
|
||||
{}
|
||||
|
||||
private:
|
||||
CommandLineParserPrivate(const CommandLineParserPrivate &) = delete; // copy ctor
|
||||
CommandLineParserPrivate(CommandLineParserPrivate &&) = delete; // move ctor
|
||||
CommandLineParserPrivate &operator=(const CommandLineParserPrivate &) = delete; // copy assignment
|
||||
CommandLineParserPrivate &operator=(CommandLineParserPrivate &&) = delete; // move assignment
|
||||
};
|
||||
|
||||
CommandLineParser::CommandLineParser(QApplication &application)
|
||||
: d(new CommandLineParserPrivate(application))
|
||||
{
|
||||
}
|
||||
{}
|
||||
|
||||
CommandLineParser::~CommandLineParser()
|
||||
{
|
||||
delete d;
|
||||
}
|
||||
|
||||
CommandLineParser::CommandLineParseResult CommandLineParser::parseCommandLine(CommandLineOptions *options, QString *errorMessage)
|
||||
CommandLineParser::CommandLineParseResult CommandLineParser::parseCommandLine(CommandLineOptions *options,
|
||||
QString *errorMessage)
|
||||
{
|
||||
QLocale locale;
|
||||
std::unique_ptr<QTranslator> qtTranslator = std::make_unique<QTranslator>();
|
||||
@ -65,13 +70,55 @@ CommandLineParser::CommandLineParseResult CommandLineParser::parseCommandLine(Co
|
||||
QCoreApplication::installTranslator(qtTranslator2.get());
|
||||
|
||||
const QCommandLineOption pathOption("p", QObject::tr("The full path of policy to edit."), QObject::tr("path"));
|
||||
const QCommandLineOption bundleOption("b", QObject::tr("The full path of policy bundle to load."), QObject::tr("path"));
|
||||
const QCommandLineOption bundleOption("b",
|
||||
QObject::tr("The full path of policy bundle to load."),
|
||||
QObject::tr("path"));
|
||||
const QCommandLineOption nameOption("n",
|
||||
QObject::tr("This options left for compatibility with ADMC. "
|
||||
"Currently it does nothing."),
|
||||
QObject::tr("name"));
|
||||
const QCommandLineOption helpOption(QStringList()
|
||||
#ifdef Q_OS_WIN
|
||||
<< QStringLiteral("?")
|
||||
#endif
|
||||
<< QStringLiteral("h") << QStringLiteral("help"),
|
||||
QObject::tr("Displays help on commandline options."));
|
||||
|
||||
#ifdef QT_DEBUG
|
||||
#define CONSOLE_LOG_LEVEL_DEFAULT "debug"
|
||||
#define SYSLOG_LOG_LEVEL_DEFAULT "none"
|
||||
#define FILE_LOG_LEVEL_DEFAULT "debug"
|
||||
#else
|
||||
#define CONSOLE_LOG_LEVEL_DEFAULT "none"
|
||||
#define SYSLOG_LOG_LEVEL_DEFAULT "none"
|
||||
#define FILE_LOG_LEVEL_DEFAULT "warning"
|
||||
#endif
|
||||
|
||||
const QCommandLineOption consoleLogLevelOpion("log-console",
|
||||
QObject::tr("Set log level for console. ") + QObject::tr("Default")
|
||||
+ ": \"" CONSOLE_LOG_LEVEL_DEFAULT "\".",
|
||||
QObject::tr("level"),
|
||||
CONSOLE_LOG_LEVEL_DEFAULT);
|
||||
const QCommandLineOption syslogLogLevelOpion("log-syslog",
|
||||
QObject::tr("Set log level for syslog. ") + QObject::tr("Default")
|
||||
+ ": \"" SYSLOG_LOG_LEVEL_DEFAULT "\".",
|
||||
QObject::tr("level"),
|
||||
SYSLOG_LOG_LEVEL_DEFAULT);
|
||||
const QCommandLineOption fileLogLevelOpion("log-file",
|
||||
QObject::tr("Set log level for file in ~/.local/share/gpui/. ")
|
||||
+ QObject::tr("Default") + ": \"" FILE_LOG_LEVEL_DEFAULT "\".",
|
||||
QObject::tr("level"),
|
||||
FILE_LOG_LEVEL_DEFAULT);
|
||||
|
||||
d->parser->setSingleDashWordOptionMode(QCommandLineParser::ParseAsLongOptions);
|
||||
d->parser->addOption(pathOption);
|
||||
d->parser->addOption(bundleOption);
|
||||
d->parser->addOption(helpOption);
|
||||
d->parser->addOption(nameOption);
|
||||
d->parser->addOption(consoleLogLevelOpion);
|
||||
d->parser->addOption(syslogLogLevelOpion);
|
||||
d->parser->addOption(fileLogLevelOpion);
|
||||
|
||||
const QCommandLineOption helpOption = d->parser->addHelpOption();
|
||||
const QCommandLineOption versionOption = d->parser->addVersionOption();
|
||||
|
||||
if (!d->parser->parse(d->application.arguments()))
|
||||
@ -93,7 +140,7 @@ CommandLineParser::CommandLineParseResult CommandLineParser::parseCommandLine(Co
|
||||
if (d->parser->isSet(pathOption))
|
||||
{
|
||||
const QString path = d->parser->value(pathOption);
|
||||
options->path = path;
|
||||
options->path = path;
|
||||
|
||||
if (options->path.isNull() || options->path.isEmpty())
|
||||
{
|
||||
@ -104,7 +151,7 @@ CommandLineParser::CommandLineParseResult CommandLineParser::parseCommandLine(Co
|
||||
|
||||
if (d->parser->isSet(bundleOption))
|
||||
{
|
||||
const QString path = d->parser->value(bundleOption);
|
||||
const QString path = d->parser->value(bundleOption);
|
||||
options->policyBundle = path;
|
||||
|
||||
if (options->policyBundle.isNull() || options->policyBundle.isEmpty())
|
||||
@ -114,12 +161,59 @@ CommandLineParser::CommandLineParseResult CommandLineParser::parseCommandLine(Co
|
||||
}
|
||||
}
|
||||
|
||||
if (!handleLoggerOption(consoleLogLevelOpion, options->consoleLogLevel, errorMessage)
|
||||
|| !handleLoggerOption(syslogLogLevelOpion, options->syslogLogLevel, errorMessage)
|
||||
|| !handleLoggerOption(fileLogLevelOpion, options->fileLogLevel, errorMessage))
|
||||
{
|
||||
return CommandLineError;
|
||||
}
|
||||
|
||||
return CommandLineOk;
|
||||
}
|
||||
|
||||
void CommandLineParser::showHelp() const
|
||||
bool CommandLineParser::handleLoggerOption(const QCommandLineOption &option, QtMsgType &result, QString *errorMessage)
|
||||
{
|
||||
d->parser->showHelp();
|
||||
if (d->parser->isSet(option))
|
||||
{
|
||||
const QString logString = d->parser->value(option);
|
||||
|
||||
if (logString == "none")
|
||||
{
|
||||
result = LOG_LEVEL_DISABLED;
|
||||
}
|
||||
else if (logString == "debug")
|
||||
{
|
||||
result = QtDebugMsg;
|
||||
}
|
||||
else if (logString == "info")
|
||||
{
|
||||
result = QtInfoMsg;
|
||||
}
|
||||
else if (logString == "warning")
|
||||
{
|
||||
result = QtWarningMsg;
|
||||
}
|
||||
else if (logString == "critical")
|
||||
{
|
||||
result = QtCriticalMsg;
|
||||
}
|
||||
else if (logString == "fatal")
|
||||
{
|
||||
result = QtFatalMsg;
|
||||
}
|
||||
else
|
||||
{
|
||||
*errorMessage = QObject::tr("Bad log level: ") + logString;
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
void CommandLineParser::showHelp(int exitCode) const
|
||||
{
|
||||
d->parser->showHelp(exitCode);
|
||||
}
|
||||
|
||||
void CommandLineParser::showVersion() const
|
||||
@ -127,4 +221,4 @@ void CommandLineParser::showVersion() const
|
||||
d->parser->showVersion();
|
||||
}
|
||||
|
||||
}
|
||||
} // namespace gpui
|
||||
|
@ -24,6 +24,7 @@
|
||||
#include "gui.h"
|
||||
|
||||
#include "../gui/commandlineoptions.h"
|
||||
#include "../core/logger/prelude.h"
|
||||
|
||||
#include <QApplication>
|
||||
#include <QCommandLineParser>
|
||||
@ -48,8 +49,16 @@ namespace gpui {
|
||||
|
||||
CommandLineParseResult parseCommandLine(CommandLineOptions *options, QString *errorMessage);
|
||||
|
||||
void showHelp() const;
|
||||
void showVersion() const;
|
||||
Q_NORETURN void showHelp(int exitCode) const;
|
||||
Q_NORETURN void showVersion() const;
|
||||
|
||||
private:
|
||||
CommandLineParser(const CommandLineParser&) = delete; // copy ctor
|
||||
CommandLineParser(CommandLineParser&&) = delete; // move ctor
|
||||
CommandLineParser& operator=(const CommandLineParser&) = delete; // copy assignment
|
||||
CommandLineParser& operator=(CommandLineParser&&) = delete; // move assignment
|
||||
|
||||
bool handleLoggerOption(const QCommandLineOption &option, QtMsgType &result, QString *errorMessage);
|
||||
|
||||
private:
|
||||
CommandLineParserPrivate* d;
|
||||
|
@ -22,41 +22,33 @@
|
||||
|
||||
#include "ui_contentwidget.h"
|
||||
|
||||
#include "presentationbuilder.h"
|
||||
#include "../plugins/administrative_templates/admx/policy.h"
|
||||
#include "../plugins/administrative_templates/admx/policyelement.h"
|
||||
#include "../plugins/administrative_templates/bundle/itemtype.h"
|
||||
#include "../plugins/administrative_templates/bundle/policyroles.h"
|
||||
#include "../plugins/administrative_templates/presentation/presentation.h"
|
||||
|
||||
#include "../model/registry/abstractregistrysource.h"
|
||||
#include "../model/registry/policystatemanager.h"
|
||||
#include "../model/admx/policy.h"
|
||||
|
||||
#include "../model/bundle/policyroles.h"
|
||||
#include "../model/commands/commandgroup.h"
|
||||
#include "pluginwidgetinterface.h"
|
||||
|
||||
using namespace ::model::bundle;
|
||||
|
||||
namespace gpui {
|
||||
namespace
|
||||
{
|
||||
const int LIST_PAGE_INDEX = 0;
|
||||
const int DATA_PAGE_INDEX = 1;
|
||||
} // namespace
|
||||
|
||||
namespace gpui
|
||||
{
|
||||
typedef std::shared_ptr<::model::presentation::Presentation> PresentationPtr;
|
||||
typedef std::shared_ptr<::model::admx::Policy> PolicyPtr;
|
||||
|
||||
class ContentWidgetPrivate
|
||||
{
|
||||
public:
|
||||
model::registry::AbstractRegistrySource* userSource = nullptr;
|
||||
model::registry::AbstractRegistrySource* machineSource = nullptr;
|
||||
|
||||
std::unique_ptr<model::registry::PolicyStateManager> manager;
|
||||
bool dataChanged = false;
|
||||
bool stateEnabled = false;
|
||||
QModelIndex currentIndex;
|
||||
ContentWidget::PolicyWidgetState state = ContentWidget::PolicyWidgetState::STATE_NOT_CONFIGURED;
|
||||
QModelIndex currentIndex{};
|
||||
};
|
||||
|
||||
void gpui::ContentWidget::connectDialogBoxSignals()
|
||||
{
|
||||
connect(ui->policyStateButtonBox, &QDialogButtonBox::accepted, this, &ContentWidget::onApplyClicked);
|
||||
connect(ui->policyStateButtonBox, &QDialogButtonBox::rejected, this, &ContentWidget::onCancelClicked);
|
||||
}
|
||||
|
||||
ContentWidget::ContentWidget(QWidget *parent)
|
||||
: QWidget(parent)
|
||||
, ui(new Ui::ContentWidget())
|
||||
@ -64,46 +56,7 @@ ContentWidget::ContentWidget(QWidget *parent)
|
||||
{
|
||||
ui->setupUi(this);
|
||||
|
||||
setPolicyWidgetsVisible(false);
|
||||
|
||||
connect(ui->contentListView, &QListView::clicked, this, &ContentWidget::onListItemClicked);
|
||||
connect(this, &ContentWidget::modelItemSelected, this, &ContentWidget::onListItemClicked);
|
||||
|
||||
connect(ui->notConfiguredRadioButton, &QRadioButton::toggled, this, [=](bool checked) {
|
||||
if (checked)
|
||||
{
|
||||
setPolicyWidgetState(STATE_NOT_CONFIGURED);
|
||||
qWarning() << "Setting state not configured" << d->manager.get();
|
||||
if (d->manager)
|
||||
{
|
||||
d->manager->setupPolicyState(model::registry::PolicyStateManager::STATE_NOT_CONFIGURED);
|
||||
}
|
||||
}
|
||||
});
|
||||
connect(ui->enabledRadioButton, &QRadioButton::toggled, this, [=](bool checked) {
|
||||
if (checked)
|
||||
{
|
||||
setPolicyWidgetState(STATE_ENABLED);
|
||||
qWarning() << "Setting state enabled" << d->manager.get();
|
||||
if (d->manager)
|
||||
{
|
||||
d->manager->setupPolicyState(model::registry::PolicyStateManager::STATE_ENABLED);
|
||||
}
|
||||
}
|
||||
});
|
||||
connect(ui->disabledRadioButton, &QRadioButton::toggled, this, [=](bool checked) {
|
||||
if (checked)
|
||||
{
|
||||
setPolicyWidgetState(STATE_DISABLED);
|
||||
qWarning() << "Setting state disabled" << d->manager.get();
|
||||
if (d->manager)
|
||||
{
|
||||
d->manager->setupPolicyState(model::registry::PolicyStateManager::STATE_DISABLED);
|
||||
}
|
||||
}
|
||||
});
|
||||
|
||||
connectDialogBoxSignals();
|
||||
}
|
||||
|
||||
ContentWidget::~ContentWidget()
|
||||
@ -112,181 +65,131 @@ ContentWidget::~ContentWidget()
|
||||
delete d;
|
||||
}
|
||||
|
||||
void ContentWidget::setModel(QAbstractItemModel* model)
|
||||
{
|
||||
ui->contentListView->setModel(model);
|
||||
}
|
||||
|
||||
void ContentWidget::setSelectionModel(QItemSelectionModel* selectionModel)
|
||||
{
|
||||
ui->contentListView->setSelectionModel(selectionModel);
|
||||
}
|
||||
|
||||
void ContentWidget::setUserRegistrySource(model::registry::AbstractRegistrySource *registrySource)
|
||||
{
|
||||
d->userSource = registrySource;
|
||||
}
|
||||
|
||||
void ContentWidget::setMachineRegistrySource(model::registry::AbstractRegistrySource *registrySource)
|
||||
{
|
||||
d->machineSource = registrySource;
|
||||
}
|
||||
|
||||
void ContentWidget::setPolicyWidgetState(ContentWidget::PolicyWidgetState state)
|
||||
{
|
||||
switch (state) {
|
||||
case STATE_ENABLED:
|
||||
{
|
||||
d->stateEnabled = true;
|
||||
ui->contentScrollArea->setDisabled(false);
|
||||
}break;
|
||||
case STATE_DISABLED:
|
||||
case STATE_NOT_CONFIGURED:
|
||||
default:
|
||||
d->stateEnabled = false;
|
||||
ui->contentScrollArea->setDisabled(true);
|
||||
break;
|
||||
}
|
||||
|
||||
d->state = state;
|
||||
}
|
||||
|
||||
void ContentWidget::onLanguageChaged()
|
||||
void ContentWidget::onLanguageChanged()
|
||||
{
|
||||
ui->retranslateUi(this);
|
||||
}
|
||||
|
||||
void ContentWidget::setEventFilter(QObject *eventFilter)
|
||||
{
|
||||
ui->contentListView->installEventFilter(eventFilter);
|
||||
}
|
||||
|
||||
void ContentWidget::setModel(QAbstractItemModel *model)
|
||||
{
|
||||
ui->contentListView->setModel(model);
|
||||
}
|
||||
|
||||
void ContentWidget::setSelectionModel(QItemSelectionModel *selectionModel)
|
||||
{
|
||||
if (ui->contentListView->selectionModel())
|
||||
{
|
||||
disconnect(ui->contentListView->selectionModel());
|
||||
}
|
||||
|
||||
ui->contentListView->setSelectionModel(selectionModel);
|
||||
connect(ui->contentListView->selectionModel(),
|
||||
&QItemSelectionModel::selectionChanged,
|
||||
this,
|
||||
[&](const QItemSelection &selected, const QItemSelection &deselected) {
|
||||
Q_UNUSED(deselected);
|
||||
if (selected.isEmpty() || selected.first().indexes().isEmpty())
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
auto modelIndex = selected.first().indexes().first();
|
||||
|
||||
ui->descriptionTextEdit->setText(modelIndex.data(PolicyRoles::EXPLAIN_TEXT).toString());
|
||||
if (modelIndex.data(PolicyRoles::ITEM_TYPE).value<uint>() != ItemType::ITEM_TYPE_POLICY)
|
||||
{
|
||||
ui->contentListView->setRootIndex(modelIndex);
|
||||
}
|
||||
else
|
||||
{
|
||||
if (modelIndex.parent().isValid())
|
||||
{
|
||||
ui->contentListView->setRootIndex(modelIndex.parent());
|
||||
}
|
||||
}
|
||||
|
||||
modelItemSelected(modelIndex);
|
||||
});
|
||||
}
|
||||
|
||||
void ContentWidget::onListItemClicked(const QModelIndex &index)
|
||||
{
|
||||
d->currentIndex = index;
|
||||
|
||||
const QAbstractItemModel* model = index.model();
|
||||
|
||||
if (d->dataChanged)
|
||||
{
|
||||
QMessageBox::StandardButton reply;
|
||||
reply = QMessageBox::question(this, QObject::tr("Save settings dialog"),
|
||||
QObject::tr("Policy settings were modified do you want to save them?"),
|
||||
QMessageBox::Yes | QMessageBox::No);
|
||||
switch (reply)
|
||||
{
|
||||
case QMessageBox::Yes:
|
||||
emit ui->policyStateButtonBox->accepted();
|
||||
onApplyClicked();
|
||||
break;
|
||||
case QMessageBox::No:
|
||||
onCancelClicked();
|
||||
break;
|
||||
default:
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
d->dataChanged = false;
|
||||
|
||||
if (ui->contentScrollArea->widget()->layout())
|
||||
{
|
||||
delete ui->contentScrollArea->takeWidget();
|
||||
|
||||
ui->contentScrollArea->setWidget(new QWidget(this));
|
||||
}
|
||||
const QAbstractItemModel *model = index.model();
|
||||
|
||||
if (model)
|
||||
{
|
||||
ui->descriptionTextEdit->setText(model->data(index, PolicyRoles::EXPLAIN_TEXT).value<QString>());
|
||||
|
||||
d->manager = nullptr;
|
||||
auto widget = ui->scrollArea->takeWidget();
|
||||
|
||||
if (model->data(index, PolicyRoles::ITEM_TYPE).value<uint>() == 1)
|
||||
bool deleteWidget = true;
|
||||
|
||||
auto pluginWidget = dynamic_cast<gui::PluginWidgetInterface *>(widget);
|
||||
if (pluginWidget && pluginWidget->hasDataChanged())
|
||||
{
|
||||
setPolicyWidgetsVisible(true);
|
||||
setPolicyWidgetState(STATE_NOT_CONFIGURED);
|
||||
ui->scrollArea->setWidget(pluginWidget);
|
||||
setWidgetSignals(pluginWidget);
|
||||
|
||||
ui->notConfiguredRadioButton->setChecked(true);
|
||||
ui->supportedOnTextEdit->setText(model->data(index, PolicyRoles::SUPPORTED_ON).value<QString>());
|
||||
connect(pluginWidget, &gui::PluginWidgetInterface::rejectPressed, [&deleteWidget]() {
|
||||
deleteWidget = false;
|
||||
});
|
||||
}
|
||||
|
||||
auto presentation = model->data(index, PolicyRoles::PRESENTATION).value<PresentationPtr>();
|
||||
auto policy = model->data(index, PolicyRoles::POLICY).value<PolicyPtr>();
|
||||
model::registry::AbstractRegistrySource* source = d->userSource;
|
||||
if (deleteWidget && widget)
|
||||
{
|
||||
delete widget;
|
||||
}
|
||||
|
||||
if (policy && d->machineSource)
|
||||
if (model->data(index, PolicyRoles::ITEM_TYPE).value<uint>() == ItemType::ITEM_TYPE_POLICY)
|
||||
{
|
||||
auto policyWidget = model->data(index, PolicyRoles::POLICY_WIDGET).value<std::function<QWidget *()>>();
|
||||
|
||||
if (deleteWidget && policyWidget)
|
||||
{
|
||||
if (policy->policyType == model::admx::PolicyType::Machine)
|
||||
{
|
||||
source = d->machineSource;
|
||||
}
|
||||
ui->scrollArea->setWidget(policyWidget());
|
||||
}
|
||||
|
||||
if (source && policy)
|
||||
{
|
||||
d->manager = std::make_unique<model::registry::PolicyStateManager>(*source, *policy);
|
||||
|
||||
auto state = d->manager->determinePolicyState();
|
||||
if (state == model::registry::PolicyStateManager::STATE_ENABLED)
|
||||
{
|
||||
ui->enabledRadioButton->setChecked(true);
|
||||
}
|
||||
|
||||
if (state == model::registry::PolicyStateManager::STATE_DISABLED)
|
||||
{
|
||||
ui->disabledRadioButton->setChecked(true);
|
||||
}
|
||||
|
||||
if (state == model::registry::PolicyStateManager::STATE_NOT_CONFIGURED)
|
||||
{
|
||||
ui->notConfiguredRadioButton->setChecked(true);
|
||||
}
|
||||
}
|
||||
|
||||
if (presentation && policy)
|
||||
{
|
||||
ui->policyStateButtonBox->disconnect();
|
||||
auto layout = ::gui::PresentationBuilder::build({
|
||||
*presentation, *policy, *source,
|
||||
*ui->policyStateButtonBox, d->dataChanged,
|
||||
d->stateEnabled
|
||||
});
|
||||
connectDialogBoxSignals();
|
||||
|
||||
ui->contentScrollArea->widget()->setLayout(layout);
|
||||
}
|
||||
ui->stackedWidget->setCurrentIndex(DATA_PAGE_INDEX);
|
||||
}
|
||||
else
|
||||
{
|
||||
setPolicyWidgetsVisible(false);
|
||||
|
||||
ui->contentListView->setRootIndex(index);
|
||||
ui->stackedWidget->setCurrentIndex(LIST_PAGE_INDEX);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void ContentWidget::onApplyClicked()
|
||||
void ContentWidget::setWidgetSignals(gui::PluginWidgetInterface *pluginWidget)
|
||||
{
|
||||
d->dataChanged = false;
|
||||
savePolicyChanges();
|
||||
QMessageBox messageBox(QMessageBox::Question,
|
||||
QObject::tr("Save settings dialog"),
|
||||
QObject::tr("Policy settings were modified do you want to save them?"),
|
||||
QMessageBox::Yes | QMessageBox::No,
|
||||
this);
|
||||
messageBox.setButtonText(QMessageBox::Yes, tr("Yes"));
|
||||
messageBox.setButtonText(QMessageBox::No, tr("No"));
|
||||
int reply = messageBox.exec();
|
||||
|
||||
switch (reply)
|
||||
{
|
||||
case QMessageBox::Yes:
|
||||
emit pluginWidget->acceptPressed();
|
||||
break;
|
||||
case QMessageBox::No:
|
||||
emit pluginWidget->rejectPressed();
|
||||
break;
|
||||
default:
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
void ContentWidget::onCancelClicked()
|
||||
{
|
||||
d->dataChanged = false;
|
||||
onListItemClicked(d->currentIndex);
|
||||
}
|
||||
|
||||
|
||||
void gpui::ContentWidget::setPolicyWidgetsVisible(bool visible)
|
||||
{
|
||||
ui->supportedOnLabel->setVisible(visible);
|
||||
ui->supportedOnTextEdit->setVisible(visible);
|
||||
|
||||
ui->groupBox->setVisible(visible);
|
||||
|
||||
ui->contentScrollArea->setVisible(visible);
|
||||
ui->contentListView->setVisible(!visible);
|
||||
ui->policyStateButtonBox->setVisible(visible);
|
||||
ui->contentWidget->setVisible(visible);
|
||||
}
|
||||
|
||||
}
|
||||
} // namespace gpui
|
||||
|
||||
Q_DECLARE_METATYPE(std::function<QWidget *()>)
|
||||
Q_DECLARE_METATYPE(std::shared_ptr<::model::presentation::Presentation>)
|
||||
Q_DECLARE_METATYPE(std::shared_ptr<::model::admx::Policy>)
|
||||
|
@ -26,61 +26,71 @@
|
||||
#include <QtWidgets>
|
||||
|
||||
QT_BEGIN_NAMESPACE
|
||||
namespace Ui { class ContentWidget; }
|
||||
namespace Ui
|
||||
{
|
||||
class ContentWidget;
|
||||
}
|
||||
QT_END_NAMESPACE
|
||||
|
||||
namespace model {
|
||||
namespace registry {
|
||||
class AbstractRegistrySource;
|
||||
}
|
||||
namespace model
|
||||
{
|
||||
namespace registry
|
||||
{
|
||||
class AbstractRegistrySource;
|
||||
}
|
||||
} // namespace model
|
||||
|
||||
namespace gui
|
||||
{
|
||||
class PluginWidgetInterface;
|
||||
}
|
||||
|
||||
namespace gpui {
|
||||
class ContentWidgetPrivate;
|
||||
namespace gpui
|
||||
{
|
||||
class ContentWidgetPrivate;
|
||||
|
||||
class GPUI_GUI_EXPORT ContentWidget : public QWidget {
|
||||
Q_OBJECT
|
||||
public:
|
||||
enum PolicyWidgetState
|
||||
{
|
||||
STATE_NOT_CONFIGURED = 0,
|
||||
STATE_ENABLED = 1,
|
||||
STATE_DISABLED = 2
|
||||
};
|
||||
|
||||
public:
|
||||
// construction and destruction
|
||||
ContentWidget(QWidget *parent = 0);
|
||||
~ContentWidget();
|
||||
|
||||
void setModel(QAbstractItemModel *model);
|
||||
void setSelectionModel(QItemSelectionModel* selectionModel);
|
||||
|
||||
void setUserRegistrySource(model::registry::AbstractRegistrySource* registrySource);
|
||||
void setMachineRegistrySource(model::registry::AbstractRegistrySource* registrySource);
|
||||
|
||||
void setPolicyWidgetState(PolicyWidgetState state);
|
||||
|
||||
void onLanguageChaged();
|
||||
|
||||
signals:
|
||||
void modelItemSelected(const QModelIndex& index);
|
||||
void savePolicyChanges();
|
||||
|
||||
private:
|
||||
Ui::ContentWidget *ui;
|
||||
ContentWidgetPrivate* d;
|
||||
|
||||
private slots:
|
||||
void onListItemClicked(const QModelIndex &index);
|
||||
|
||||
void onApplyClicked();
|
||||
void onCancelClicked();
|
||||
|
||||
private:
|
||||
void setPolicyWidgetsVisible(bool visible);
|
||||
void connectDialogBoxSignals();
|
||||
class GPUI_GUI_EXPORT ContentWidget : public QWidget
|
||||
{
|
||||
Q_OBJECT
|
||||
public:
|
||||
enum PolicyWidgetState
|
||||
{
|
||||
STATE_NOT_CONFIGURED = 0,
|
||||
STATE_ENABLED = 1,
|
||||
STATE_DISABLED = 2
|
||||
};
|
||||
}
|
||||
|
||||
public:
|
||||
// construction and destruction
|
||||
ContentWidget(QWidget *parent = 0);
|
||||
~ContentWidget();
|
||||
|
||||
void setEventFilter(QObject *eventFilter);
|
||||
|
||||
void setModel(QAbstractItemModel *model);
|
||||
void setSelectionModel(QItemSelectionModel *selectionModel);
|
||||
|
||||
void onLanguageChanged();
|
||||
|
||||
signals:
|
||||
void modelItemSelected(const QModelIndex &index);
|
||||
|
||||
private:
|
||||
Ui::ContentWidget *ui;
|
||||
ContentWidgetPrivate *d;
|
||||
|
||||
private slots:
|
||||
void onListItemClicked(const QModelIndex &index);
|
||||
|
||||
private:
|
||||
void setWidgetSignals(gui::PluginWidgetInterface *pluginWidget);
|
||||
|
||||
private:
|
||||
ContentWidget(const ContentWidget &) = delete; // copy ctor
|
||||
ContentWidget(ContentWidget &&) = delete; // move ctor
|
||||
ContentWidget &operator=(const ContentWidget &) = delete; // copy assignment
|
||||
ContentWidget &operator=(ContentWidget &&) = delete; // move assignment
|
||||
};
|
||||
} // namespace gpui
|
||||
|
||||
#endif // GPUI_CONTENT_WIDGET_H
|
||||
|
@ -6,14 +6,14 @@
|
||||
<rect>
|
||||
<x>0</x>
|
||||
<y>0</y>
|
||||
<width>770</width>
|
||||
<height>488</height>
|
||||
<width>736</width>
|
||||
<height>595</height>
|
||||
</rect>
|
||||
</property>
|
||||
<property name="windowTitle">
|
||||
<string>Form</string>
|
||||
</property>
|
||||
<layout class="QHBoxLayout" name="horizontalLayout">
|
||||
<layout class="QGridLayout" name="gridLayout">
|
||||
<property name="leftMargin">
|
||||
<number>0</number>
|
||||
</property>
|
||||
@ -26,194 +26,126 @@
|
||||
<property name="bottomMargin">
|
||||
<number>0</number>
|
||||
</property>
|
||||
<item>
|
||||
<widget class="QListView" name="contentListView"/>
|
||||
</item>
|
||||
<item>
|
||||
<widget class="QWidget" name="widget" native="true">
|
||||
<layout class="QGridLayout" name="gridLayout_4">
|
||||
<property name="leftMargin">
|
||||
<number>0</number>
|
||||
</property>
|
||||
<property name="topMargin">
|
||||
<number>0</number>
|
||||
</property>
|
||||
<property name="rightMargin">
|
||||
<number>5</number>
|
||||
</property>
|
||||
<property name="bottomMargin">
|
||||
<number>0</number>
|
||||
</property>
|
||||
<item row="0" column="0">
|
||||
<widget class="QWidget" name="contentWidget" native="true">
|
||||
<property name="sizePolicy">
|
||||
<sizepolicy hsizetype="Preferred" vsizetype="Expanding">
|
||||
<horstretch>0</horstretch>
|
||||
<verstretch>0</verstretch>
|
||||
</sizepolicy>
|
||||
</property>
|
||||
<property name="minimumSize">
|
||||
<size>
|
||||
<width>225</width>
|
||||
<height>0</height>
|
||||
</size>
|
||||
</property>
|
||||
<layout class="QVBoxLayout" name="verticalLayout">
|
||||
<property name="leftMargin">
|
||||
<item row="0" column="0">
|
||||
<widget class="QStackedWidget" name="stackedWidget">
|
||||
<property name="currentIndex">
|
||||
<number>1</number>
|
||||
</property>
|
||||
<widget class="QWidget" name="policyListWidget">
|
||||
<layout class="QGridLayout" name="gridLayout_2">
|
||||
<property name="leftMargin">
|
||||
<number>0</number>
|
||||
</property>
|
||||
<property name="topMargin">
|
||||
<number>0</number>
|
||||
</property>
|
||||
<property name="rightMargin">
|
||||
<number>0</number>
|
||||
</property>
|
||||
<property name="bottomMargin">
|
||||
<number>0</number>
|
||||
</property>
|
||||
<item row="0" column="0">
|
||||
<widget class="QSplitter" name="splitter">
|
||||
<property name="orientation">
|
||||
<enum>Qt::Horizontal</enum>
|
||||
</property>
|
||||
<widget class="QListView" name="contentListView">
|
||||
<property name="sizePolicy">
|
||||
<sizepolicy hsizetype="MinimumExpanding" vsizetype="Expanding">
|
||||
<horstretch>4</horstretch>
|
||||
<verstretch>0</verstretch>
|
||||
</sizepolicy>
|
||||
</property>
|
||||
<property name="minimumSize">
|
||||
<size>
|
||||
<width>200</width>
|
||||
<height>0</height>
|
||||
</size>
|
||||
</property>
|
||||
</widget>
|
||||
<widget class="QWidget" name="layoutWidget">
|
||||
<layout class="QVBoxLayout" name="verticalLayout">
|
||||
<item>
|
||||
<widget class="QLabel" name="label">
|
||||
<property name="text">
|
||||
<string>Help:</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item>
|
||||
<widget class="QTextEdit" name="descriptionTextEdit">
|
||||
<property name="sizePolicy">
|
||||
<sizepolicy hsizetype="Expanding" vsizetype="Expanding">
|
||||
<horstretch>0</horstretch>
|
||||
<verstretch>4</verstretch>
|
||||
</sizepolicy>
|
||||
</property>
|
||||
<property name="minimumSize">
|
||||
<size>
|
||||
<width>215</width>
|
||||
<height>0</height>
|
||||
</size>
|
||||
</property>
|
||||
<property name="focusPolicy">
|
||||
<enum>Qt::NoFocus</enum>
|
||||
</property>
|
||||
<property name="readOnly">
|
||||
<bool>true</bool>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
</layout>
|
||||
</widget>
|
||||
</widget>
|
||||
</item>
|
||||
</layout>
|
||||
</widget>
|
||||
<widget class="QWidget" name="emptyWidget">
|
||||
<layout class="QGridLayout" name="gridLayout_3">
|
||||
<property name="leftMargin">
|
||||
<number>0</number>
|
||||
</property>
|
||||
<property name="topMargin">
|
||||
<number>0</number>
|
||||
</property>
|
||||
<property name="rightMargin">
|
||||
<number>0</number>
|
||||
</property>
|
||||
<property name="bottomMargin">
|
||||
<number>0</number>
|
||||
</property>
|
||||
<property name="spacing">
|
||||
<number>0</number>
|
||||
</property>
|
||||
<item row="0" column="0">
|
||||
<widget class="QScrollArea" name="scrollArea">
|
||||
<property name="frameShape">
|
||||
<enum>QFrame::NoFrame</enum>
|
||||
</property>
|
||||
<property name="frameShadow">
|
||||
<enum>QFrame::Plain</enum>
|
||||
</property>
|
||||
<property name="lineWidth">
|
||||
<number>0</number>
|
||||
</property>
|
||||
<property name="rightMargin">
|
||||
<number>0</number>
|
||||
<property name="widgetResizable">
|
||||
<bool>true</bool>
|
||||
</property>
|
||||
<property name="bottomMargin">
|
||||
<number>0</number>
|
||||
</property>
|
||||
<item>
|
||||
<widget class="QGroupBox" name="groupBox">
|
||||
<property name="title">
|
||||
<string>Policy State</string>
|
||||
</property>
|
||||
<property name="flat">
|
||||
<bool>false</bool>
|
||||
</property>
|
||||
<layout class="QGridLayout" name="gridLayout_2">
|
||||
<item row="0" column="0">
|
||||
<widget class="QRadioButton" name="notConfiguredRadioButton">
|
||||
<property name="text">
|
||||
<string>Not Configured</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="1" column="0">
|
||||
<widget class="QRadioButton" name="enabledRadioButton">
|
||||
<property name="text">
|
||||
<string>Enabled</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="2" column="0">
|
||||
<widget class="QRadioButton" name="disabledRadioButton">
|
||||
<property name="text">
|
||||
<string>Disabled</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
</layout>
|
||||
</widget>
|
||||
</item>
|
||||
<item>
|
||||
<widget class="QScrollArea" name="contentScrollArea">
|
||||
<property name="widgetResizable">
|
||||
<bool>true</bool>
|
||||
</property>
|
||||
<widget class="QWidget" name="scrollAreaWidgetContents">
|
||||
<property name="geometry">
|
||||
<rect>
|
||||
<x>0</x>
|
||||
<y>0</y>
|
||||
<width>221</width>
|
||||
<height>327</height>
|
||||
</rect>
|
||||
</property>
|
||||
</widget>
|
||||
</widget>
|
||||
</item>
|
||||
</layout>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="0" column="1">
|
||||
<widget class="QWidget" name="rightContainer" native="true">
|
||||
<property name="sizePolicy">
|
||||
<sizepolicy hsizetype="Fixed" vsizetype="Preferred">
|
||||
<horstretch>0</horstretch>
|
||||
<verstretch>0</verstretch>
|
||||
</sizepolicy>
|
||||
</property>
|
||||
<property name="minimumSize">
|
||||
<size>
|
||||
<width>215</width>
|
||||
<height>442</height>
|
||||
</size>
|
||||
</property>
|
||||
<layout class="QGridLayout" name="gridLayout_3">
|
||||
<property name="leftMargin">
|
||||
<number>0</number>
|
||||
</property>
|
||||
<property name="topMargin">
|
||||
<number>8</number>
|
||||
</property>
|
||||
<property name="rightMargin">
|
||||
<number>0</number>
|
||||
</property>
|
||||
<property name="bottomMargin">
|
||||
<number>0</number>
|
||||
</property>
|
||||
<item row="2" column="0">
|
||||
<widget class="QTextEdit" name="supportedOnTextEdit">
|
||||
<property name="sizePolicy">
|
||||
<sizepolicy hsizetype="Expanding" vsizetype="Expanding">
|
||||
<horstretch>0</horstretch>
|
||||
<verstretch>1</verstretch>
|
||||
</sizepolicy>
|
||||
</property>
|
||||
<property name="frameShape">
|
||||
<enum>QFrame::Box</enum>
|
||||
</property>
|
||||
<property name="readOnly">
|
||||
<bool>true</bool>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="1" column="0">
|
||||
<widget class="QLabel" name="supportedOnLabel">
|
||||
<property name="text">
|
||||
<string>Supported on:</string>
|
||||
</property>
|
||||
<property name="buddy">
|
||||
<cstring>supportedOnTextEdit</cstring>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="3" column="0">
|
||||
<widget class="QLabel" name="helpLabel">
|
||||
<property name="text">
|
||||
<string>Help:</string>
|
||||
</property>
|
||||
<property name="buddy">
|
||||
<cstring>descriptionTextEdit</cstring>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="4" column="0">
|
||||
<widget class="QTextEdit" name="descriptionTextEdit">
|
||||
<property name="sizePolicy">
|
||||
<sizepolicy hsizetype="Fixed" vsizetype="Expanding">
|
||||
<horstretch>0</horstretch>
|
||||
<verstretch>4</verstretch>
|
||||
</sizepolicy>
|
||||
</property>
|
||||
<property name="minimumSize">
|
||||
<size>
|
||||
<width>215</width>
|
||||
<height>0</height>
|
||||
</size>
|
||||
</property>
|
||||
<property name="readOnly">
|
||||
<bool>true</bool>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
</layout>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="1" column="0" colspan="2">
|
||||
<widget class="QDialogButtonBox" name="policyStateButtonBox">
|
||||
<property name="standardButtons">
|
||||
<set>QDialogButtonBox::Cancel|QDialogButtonBox::Ok</set>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
</layout>
|
||||
<widget class="QWidget" name="scrollAreaWidgetContents">
|
||||
<property name="geometry">
|
||||
<rect>
|
||||
<x>0</x>
|
||||
<y>0</y>
|
||||
<width>736</width>
|
||||
<height>595</height>
|
||||
</rect>
|
||||
</property>
|
||||
</widget>
|
||||
</widget>
|
||||
</item>
|
||||
</layout>
|
||||
</widget>
|
||||
</widget>
|
||||
</item>
|
||||
</layout>
|
||||
|
88
src/gui/filedialogutils.cpp
Normal file
88
src/gui/filedialogutils.cpp
Normal file
@ -0,0 +1,88 @@
|
||||
/***********************************************************************************************************************
|
||||
**
|
||||
** Copyright (C) 2021 BaseALT Ltd. <org@basealt.ru>
|
||||
**
|
||||
** This program is free software; you can redistribute it and/or
|
||||
** modify it under the terms of the GNU General Public License
|
||||
** as published by the Free Software Foundation; either version 2
|
||||
** of the License, or (at your option) any later version.
|
||||
**
|
||||
** This program is distributed in the hope that it will be useful,
|
||||
** but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
** GNU General Public License for more details.
|
||||
**
|
||||
** You should have received a copy of the GNU General Public License
|
||||
** along with this program; if not, write to the Free Software
|
||||
** Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
|
||||
**
|
||||
***********************************************************************************************************************/
|
||||
|
||||
#include "filedialogutils.h"
|
||||
|
||||
#include <QFileDialog>
|
||||
|
||||
#include <memory>
|
||||
|
||||
namespace gpui
|
||||
{
|
||||
bool FileDialogUtils::getOpenFileName(QString& fileName, QWidget *parent, const QString &filter)
|
||||
{
|
||||
std::unique_ptr<QFileDialog> fileDialog = std::make_unique<QFileDialog>(parent);
|
||||
|
||||
fileDialog->setDirectory(QDir::homePath());
|
||||
fileDialog->setFileMode(QFileDialog::AnyFile);
|
||||
fileDialog->setSupportedSchemes(QStringList(QStringLiteral("file")));
|
||||
|
||||
fileDialog->setLabelText(QFileDialog::Accept, QObject::tr("Open"));
|
||||
fileDialog->setLabelText(QFileDialog::FileName, QObject::tr("File name"));
|
||||
fileDialog->setLabelText(QFileDialog::LookIn, QObject::tr("Look in"));
|
||||
fileDialog->setLabelText(QFileDialog::Reject, QObject::tr("Cancel"));
|
||||
fileDialog->setLabelText(QFileDialog::FileType, QObject::tr("File type"));
|
||||
|
||||
fileDialog->setNameFilter(filter);
|
||||
fileDialog->setOptions(QFileDialog::DontResolveSymlinks | QFileDialog::DontUseNativeDialog);
|
||||
|
||||
fileDialog->setWindowTitle(QObject::tr("Open File"));
|
||||
|
||||
bool dialogState = fileDialog->exec() == QDialog::Accepted;
|
||||
|
||||
if (dialogState)
|
||||
{
|
||||
fileName = fileDialog->selectedUrls()[0].toLocalFile();
|
||||
}
|
||||
|
||||
return dialogState;
|
||||
}
|
||||
|
||||
bool FileDialogUtils::getOpenDirectoryName(QString& directoryName, QWidget *parent, const QString &filter)
|
||||
{
|
||||
std::unique_ptr<QFileDialog> fileDialog = std::make_unique<QFileDialog>(parent);
|
||||
|
||||
fileDialog->setDirectory(QDir::homePath());
|
||||
fileDialog->setFileMode(QFileDialog::Directory);
|
||||
fileDialog->setSupportedSchemes(QStringList(QStringLiteral("file")));
|
||||
|
||||
fileDialog->setLabelText(QFileDialog::Accept, QObject::tr("Open"));
|
||||
fileDialog->setLabelText(QFileDialog::FileName, QObject::tr("File name"));
|
||||
fileDialog->setLabelText(QFileDialog::LookIn, QObject::tr("Look in"));
|
||||
fileDialog->setLabelText(QFileDialog::Reject, QObject::tr("Cancel"));
|
||||
fileDialog->setLabelText(QFileDialog::FileType, QObject::tr("File type"));
|
||||
|
||||
fileDialog->setNameFilter(filter);
|
||||
fileDialog->setOptions(QFileDialog::ShowDirsOnly | QFileDialog::DontResolveSymlinks
|
||||
| QFileDialog::DontUseNativeDialog);
|
||||
|
||||
fileDialog->setWindowTitle(QObject::tr("Open Directory"));
|
||||
|
||||
bool dialogState = fileDialog->exec() == QDialog::Accepted;
|
||||
|
||||
if (dialogState)
|
||||
{
|
||||
directoryName = fileDialog->selectedUrls()[0].toLocalFile();
|
||||
}
|
||||
|
||||
return dialogState;
|
||||
}
|
||||
|
||||
} // namespace gpui
|
@ -18,27 +18,23 @@
|
||||
**
|
||||
***********************************************************************************************************************/
|
||||
|
||||
#include "modelbuilder.h"
|
||||
#ifndef GPUI_FILE_DIALOG_UTILS_H
|
||||
#define GPUI_FILE_DIALOG_UTILS_H
|
||||
|
||||
#include "gui.h"
|
||||
|
||||
#include <QWidget>
|
||||
|
||||
namespace gpui
|
||||
{
|
||||
|
||||
std::unique_ptr<QStandardItemModel> ModelBuilder::schemaToModel(std::unique_ptr<NetworkShares> &shares)
|
||||
class GPUI_GUI_EXPORT FileDialogUtils
|
||||
{
|
||||
Q_UNUSED(shares);
|
||||
public:
|
||||
static bool getOpenFileName(QString &fileName, QWidget *parent = nullptr, const QString &filter = QString());
|
||||
|
||||
// TODO: Implement.
|
||||
static bool getOpenDirectoryName(QString &directoryName, QWidget *parent = nullptr, const QString &filter = QString());
|
||||
};
|
||||
|
||||
return nullptr;
|
||||
}
|
||||
} // namespace gpui
|
||||
|
||||
std::unique_ptr<NetworkShares> ModelBuilder::modelToSchema(std::unique_ptr<QStandardItemModel> &model)
|
||||
{
|
||||
Q_UNUSED(model);
|
||||
|
||||
// TODO: Implement.
|
||||
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
}
|
||||
#endif //GPUI_FILE_DIALOG_UTILS_H
|
206
src/gui/gptiniutil.cpp
Normal file
206
src/gui/gptiniutil.cpp
Normal file
@ -0,0 +1,206 @@
|
||||
/***********************************************************************************************************************
|
||||
**
|
||||
** Copyright (C) 2024 BaseALT Ltd. <org@basealt.ru>
|
||||
**
|
||||
** This program is free software; you can redistribute it and/or
|
||||
** modify it under the terms of the GNU General Public License
|
||||
** as published by the Free Software Foundation; either version 2
|
||||
** of the License, or (at your option) any later version.
|
||||
**
|
||||
** This program is distributed in the hope that it will be useful,
|
||||
** but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
** GNU General Public License for more details.
|
||||
**
|
||||
** You should have received a copy of the GNU General Public License
|
||||
** along with this program; if not, write to the Free Software
|
||||
** Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
|
||||
**
|
||||
***********************************************************************************************************************/
|
||||
|
||||
#include "gptiniutil.h"
|
||||
|
||||
#include <QFileDialog>
|
||||
#include <QDebug>
|
||||
#include <QMessageBox>
|
||||
|
||||
#include <stdexcept>
|
||||
#include <memory>
|
||||
|
||||
#include "../io/genericreader.h"
|
||||
#include "../io/registryfile.h"
|
||||
#include "../io/registryfileformat.h"
|
||||
|
||||
#include "../io/policydefinitionsfile.h"
|
||||
#include "../io/policyfileformat.h"
|
||||
|
||||
#include "../io/inifile.h"
|
||||
#include "../plugins/ini/iniformat.h"
|
||||
|
||||
#include "../plugins/storage/smb/smbfile.h"
|
||||
|
||||
namespace gpui
|
||||
{
|
||||
|
||||
bool GptIniUtils::onIniFileOpen(const QString &path, QString &policyName, int &machineVersion, int &userVersion)
|
||||
{
|
||||
qWarning() << "Path recieved: " << path;
|
||||
|
||||
auto stringvalues = std::make_unique<std::string>();
|
||||
|
||||
try {
|
||||
if (path.startsWith("smb://"))
|
||||
{
|
||||
gpui::smb::SmbFile smbLocationItemFile(path);
|
||||
smbLocationItemFile.open(QFile::ReadOnly);
|
||||
stringvalues->resize(smbLocationItemFile.size(), 0);
|
||||
smbLocationItemFile.read(&stringvalues->at(0), smbLocationItemFile.size());
|
||||
smbLocationItemFile.close();
|
||||
}
|
||||
else
|
||||
{
|
||||
QFile registryFile(path);
|
||||
registryFile.open(QFile::ReadWrite);
|
||||
stringvalues->resize(registryFile.size(), 0);
|
||||
registryFile.read(&stringvalues->at(0), registryFile.size());
|
||||
registryFile.close();
|
||||
}
|
||||
|
||||
auto iss = std::make_unique<std::istringstream>(*stringvalues);
|
||||
std::string pluginName("ini_ascii");
|
||||
|
||||
auto reader = std::make_unique<io::GenericReader>();
|
||||
auto iniFile = reader->load<io::IniFile, io::PolicyFileFormat<io::IniFile> >(*iss, pluginName);
|
||||
if (!iniFile)
|
||||
{
|
||||
qWarning() << "Unable to load registry file contents.";
|
||||
return false;
|
||||
}
|
||||
|
||||
auto sections = iniFile->getAllSections();
|
||||
|
||||
if (sections->find("General") != sections->end())
|
||||
{
|
||||
auto& generalValues = (*sections)["General"];
|
||||
|
||||
auto displayName = generalValues.find("displayName");
|
||||
|
||||
if (displayName != generalValues.end())
|
||||
{
|
||||
policyName = QString::fromStdString(*displayName);
|
||||
}
|
||||
|
||||
auto version = generalValues.find("Version");
|
||||
if (version != generalValues.end())
|
||||
{
|
||||
int intVersion = QString::fromStdString(*version).toInt();
|
||||
machineVersion = intVersion & 0x0000FFFF;
|
||||
userVersion = (intVersion & 0xFFFF0000) >> 16;
|
||||
}
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
catch (std::exception& e)
|
||||
{
|
||||
QMessageBox messageBox(QMessageBox::Critical,
|
||||
QObject::tr("Error"),
|
||||
QObject::tr("Error reading file:") + "\n" + qPrintable(path),
|
||||
QMessageBox::Ok,
|
||||
nullptr);
|
||||
messageBox.exec();
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
bool GptIniUtils::onIniFileSave(const QString &path, const QString &policyName, const int machineVersion, const int userVersion)
|
||||
{
|
||||
std::unique_ptr<io::IniFile> fileData = std::make_unique<io::IniFile>();
|
||||
fileData->addValue("General", "DisplayName", policyName.toStdString());
|
||||
int version = (userVersion << 16) + machineVersion;
|
||||
fileData->addValue("General", "Version", std::to_string(version));
|
||||
|
||||
QString pluginName = path;
|
||||
pluginName = "ini_ascii";
|
||||
|
||||
io::PolicyFileFormat<io::IniFile> *format = gpui::PluginStorage::instance()->createPluginClass<io::PolicyFileFormat<io::IniFile>>(pluginName);
|
||||
|
||||
if (!format)
|
||||
{
|
||||
qWarning() << "Format supporting: " << pluginName << " not found.";
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
auto oss = std::make_unique<std::ostringstream>();
|
||||
|
||||
if (!format->write(*oss, fileData.get()))
|
||||
{
|
||||
qWarning() << path << " " << format->getErrorString().c_str();
|
||||
}
|
||||
|
||||
oss->flush();
|
||||
|
||||
qWarning() << "Current string values." << oss->str().c_str();
|
||||
|
||||
bool ifShowError = false;
|
||||
|
||||
auto showMessageFunction = [&path]() {
|
||||
QMessageBox messageBox(QMessageBox::Critical,
|
||||
QObject::tr("Error"),
|
||||
QObject::tr("Error writing file:") + "\n" + qPrintable(path),
|
||||
QMessageBox::Ok);
|
||||
messageBox.exec();
|
||||
};
|
||||
|
||||
try
|
||||
{
|
||||
if (path.startsWith("smb://"))
|
||||
{
|
||||
gpui::smb::SmbFile smbLocationItemFile(path);
|
||||
ifShowError = smbLocationItemFile.open(QFile::WriteOnly | QFile::Truncate);
|
||||
if (!ifShowError)
|
||||
{
|
||||
ifShowError = smbLocationItemFile.open(QFile::NewOnly | QFile::WriteOnly);
|
||||
}
|
||||
if (ifShowError && oss->str().size() > 0)
|
||||
{
|
||||
smbLocationItemFile.write(&oss->str().at(0), oss->str().size());
|
||||
}
|
||||
smbLocationItemFile.close();
|
||||
}
|
||||
else
|
||||
{
|
||||
QFile registryFile(path);
|
||||
ifShowError = registryFile.open(QFile::WriteOnly | QFile::Truncate);
|
||||
if (!ifShowError)
|
||||
{
|
||||
ifShowError = registryFile.open(QFile::NewOnly | QFile::WriteOnly);
|
||||
}
|
||||
if (ifShowError && registryFile.isWritable() && oss->str().size() > 0)
|
||||
{
|
||||
registryFile.write(&oss->str().at(0), oss->str().size());
|
||||
}
|
||||
registryFile.close();
|
||||
}
|
||||
}
|
||||
catch (std::exception &e)
|
||||
{
|
||||
ifShowError = true;
|
||||
showMessageFunction();
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
if (!ifShowError)
|
||||
{
|
||||
showMessageFunction();
|
||||
}
|
||||
|
||||
delete format;
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
}
|
40
src/gui/gptiniutil.h
Normal file
40
src/gui/gptiniutil.h
Normal file
@ -0,0 +1,40 @@
|
||||
/***********************************************************************************************************************
|
||||
**
|
||||
** Copyright (C) 2024 BaseALT Ltd. <org@basealt.ru>
|
||||
**
|
||||
** This program is free software; you can redistribute it and/or
|
||||
** modify it under the terms of the GNU General Public License
|
||||
** as published by the Free Software Foundation; either version 2
|
||||
** of the License, or (at your option) any later version.
|
||||
**
|
||||
** This program is distributed in the hope that it will be useful,
|
||||
** but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
** GNU General Public License for more details.
|
||||
**
|
||||
** You should have received a copy of the GNU General Public License
|
||||
** along with this program; if not, write to the Free Software
|
||||
** Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
|
||||
**
|
||||
***********************************************************************************************************************/
|
||||
|
||||
#ifndef GPUI_GPT_INI_UTILS_H
|
||||
#define GPUI_GPT_INI_UTILS_H
|
||||
|
||||
#include "gui.h"
|
||||
|
||||
#include <QWidget>
|
||||
|
||||
namespace gpui
|
||||
{
|
||||
class GPUI_GUI_EXPORT GptIniUtils
|
||||
{
|
||||
public:
|
||||
bool onIniFileOpen(const QString &path, QString& policyName, int& machineVersion, int& userVersion);
|
||||
|
||||
bool onIniFileSave(const QString &path, const QString& policyName, const int machineVersion, const int userVersion);
|
||||
};
|
||||
|
||||
} // namespace gpui
|
||||
|
||||
#endif //GPUI_GPT_INI_UTILS_H
|
@ -21,16 +21,15 @@
|
||||
#ifndef GPUI_GUI_H
|
||||
#define GPUI_GUI_H
|
||||
|
||||
#include "../model/common.h"
|
||||
#include "../core/common.h"
|
||||
|
||||
#ifdef GPUI_GUI_LIBRARY
|
||||
#define GPUI_GUI_EXPORT GPUI_SYMBOL_EXPORT
|
||||
#define GPUI_GUI_EXPORT GPUI_SYMBOL_EXPORT
|
||||
#else
|
||||
#define GPUI_GUI_EXPORT GPUI_SYMBOL_IMPORT
|
||||
#define GPUI_GUI_EXPORT GPUI_SYMBOL_IMPORT
|
||||
#endif
|
||||
|
||||
namespace gpui {
|
||||
|
||||
}
|
||||
namespace gpui
|
||||
{}
|
||||
|
||||
#endif // GPUI_GUI_H
|
||||
|
File diff suppressed because it is too large
Load Diff
File diff suppressed because it is too large
Load Diff
@ -40,19 +40,29 @@ ListBoxDialog::ListBoxDialog(const QString &dialogTitle)
|
||||
connect(ui->newButton, &QPushButton::clicked, this, &ListBoxDialog::onNew);
|
||||
connect(ui->deleteButton, &QPushButton::clicked, this, &ListBoxDialog::onDelete);
|
||||
|
||||
connect(ui->buttonBox, &QDialogButtonBox::accepted, this,
|
||||
connect(ui->okPushButton, &QPushButton::clicked, this,
|
||||
[&](){
|
||||
QStringList items;
|
||||
QMap<std::string, QString> items;
|
||||
for(int i = 0; i < ui->tableWidget->rowCount(); ++i)
|
||||
{
|
||||
QTableWidgetItem* item = ui->tableWidget->item(i, 1);
|
||||
if (item && item->data(Qt::DisplayRole).isValid())
|
||||
QTableWidgetItem* key = ui->tableWidget->item(i, 0);
|
||||
QTableWidgetItem* value = ui->tableWidget->item(i, 1);
|
||||
if (value && value->data(Qt::DisplayRole).isValid())
|
||||
{
|
||||
items.push_back(item->text());
|
||||
if (key && key->data(Qt::DisplayRole).isValid())
|
||||
{
|
||||
items[key->text().toStdString()] = (value->text());
|
||||
}
|
||||
else
|
||||
{
|
||||
items[std::to_string(i)] = (value->text());
|
||||
}
|
||||
}
|
||||
}
|
||||
itemsEditingFinished(items);
|
||||
});
|
||||
connect(ui->cancelPushButton, &QPushButton::clicked, this, &ListBoxDialog::close);
|
||||
connect(ui->okPushButton, &QPushButton::clicked, this, &ListBoxDialog::close);
|
||||
}
|
||||
|
||||
ListBoxDialog::~ListBoxDialog()
|
||||
@ -63,6 +73,7 @@ ListBoxDialog::~ListBoxDialog()
|
||||
void ListBoxDialog::setItems(const QStringList &items)
|
||||
{
|
||||
int index = 0;
|
||||
ui->tableWidget->hideColumn(0);
|
||||
ui->tableWidget->setRowCount(items.size());
|
||||
for (const auto& itemString : items)
|
||||
{
|
||||
@ -71,6 +82,24 @@ void ListBoxDialog::setItems(const QStringList &items)
|
||||
}
|
||||
}
|
||||
|
||||
void ListBoxDialog::setItems(const QMap<std::string, QString> &items)
|
||||
{
|
||||
int index = 0;
|
||||
ui->tableWidget->showColumn(0);
|
||||
ui->tableWidget->setRowCount(items.size());
|
||||
for (const auto& key : items.keys())
|
||||
{
|
||||
ui->tableWidget->setItem(index, 0, new QTableWidgetItem(QString::fromStdString(key)));
|
||||
index++;
|
||||
}
|
||||
|
||||
for (const auto& value : items.values())
|
||||
{
|
||||
ui->tableWidget->setItem(index, 1, new QTableWidgetItem(value));
|
||||
index++;
|
||||
}
|
||||
}
|
||||
|
||||
void ListBoxDialog::clearItems()
|
||||
{
|
||||
ui->tableWidget->clearContents();
|
||||
|
@ -24,13 +24,16 @@
|
||||
#include "gui.h"
|
||||
|
||||
#include <QDialog>
|
||||
#include <QMap>
|
||||
|
||||
#include <string>
|
||||
|
||||
QT_BEGIN_NAMESPACE
|
||||
namespace Ui { class ListBoxDialog; }
|
||||
QT_END_NAMESPACE
|
||||
|
||||
namespace gpui {
|
||||
class ListBoxDialog : public QDialog
|
||||
class GPUI_GUI_EXPORT ListBoxDialog : public QDialog
|
||||
{
|
||||
Q_OBJECT
|
||||
public:
|
||||
@ -39,10 +42,11 @@ namespace gpui {
|
||||
~ListBoxDialog();
|
||||
|
||||
void setItems(const QStringList& items);
|
||||
void setItems(const QMap<std::string, QString>& items);
|
||||
void clearItems();
|
||||
|
||||
signals:
|
||||
void itemsEditingFinished(QStringList items);
|
||||
void itemsEditingFinished(QMap<std::string, QString> items);
|
||||
|
||||
private:
|
||||
Ui::ListBoxDialog *ui;
|
||||
@ -53,6 +57,12 @@ namespace gpui {
|
||||
private slots:
|
||||
void onNew();
|
||||
void onDelete();
|
||||
|
||||
private:
|
||||
ListBoxDialog(const ListBoxDialog&) = delete; // copy ctor
|
||||
ListBoxDialog(ListBoxDialog&&) = delete; // move ctor
|
||||
ListBoxDialog& operator=(const ListBoxDialog&) = delete; // copy assignment
|
||||
ListBoxDialog& operator=(ListBoxDialog&&) = delete; // move assignment
|
||||
};
|
||||
}
|
||||
|
||||
|
@ -13,6 +13,9 @@
|
||||
<property name="windowTitle">
|
||||
<string>Dialog</string>
|
||||
</property>
|
||||
<property name="modal">
|
||||
<bool>true</bool>
|
||||
</property>
|
||||
<layout class="QGridLayout" name="gridLayout">
|
||||
<item row="0" column="0">
|
||||
<widget class="QLabel" name="nameLabel">
|
||||
@ -54,12 +57,16 @@
|
||||
</spacer>
|
||||
</item>
|
||||
<item>
|
||||
<widget class="QDialogButtonBox" name="buttonBox">
|
||||
<property name="orientation">
|
||||
<enum>Qt::Horizontal</enum>
|
||||
<widget class="QPushButton" name="cancelPushButton">
|
||||
<property name="text">
|
||||
<string>&Cancel</string>
|
||||
</property>
|
||||
<property name="standardButtons">
|
||||
<set>QDialogButtonBox::Cancel|QDialogButtonBox::Ok</set>
|
||||
</widget>
|
||||
</item>
|
||||
<item>
|
||||
<widget class="QPushButton" name="okPushButton">
|
||||
<property name="text">
|
||||
<string>&OK</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
@ -68,38 +75,5 @@
|
||||
</layout>
|
||||
</widget>
|
||||
<resources/>
|
||||
<connections>
|
||||
<connection>
|
||||
<sender>buttonBox</sender>
|
||||
<signal>accepted()</signal>
|
||||
<receiver>ListBoxDialog</receiver>
|
||||
<slot>accept()</slot>
|
||||
<hints>
|
||||
<hint type="sourcelabel">
|
||||
<x>248</x>
|
||||
<y>254</y>
|
||||
</hint>
|
||||
<hint type="destinationlabel">
|
||||
<x>157</x>
|
||||
<y>274</y>
|
||||
</hint>
|
||||
</hints>
|
||||
</connection>
|
||||
<connection>
|
||||
<sender>buttonBox</sender>
|
||||
<signal>rejected()</signal>
|
||||
<receiver>ListBoxDialog</receiver>
|
||||
<slot>reject()</slot>
|
||||
<hints>
|
||||
<hint type="sourcelabel">
|
||||
<x>316</x>
|
||||
<y>260</y>
|
||||
</hint>
|
||||
<hint type="destinationlabel">
|
||||
<x>286</x>
|
||||
<y>274</y>
|
||||
</hint>
|
||||
</hints>
|
||||
</connection>
|
||||
</connections>
|
||||
<connections/>
|
||||
</ui>
|
||||
|
@ -19,8 +19,8 @@
|
||||
***********************************************************************************************************************/
|
||||
|
||||
#include "mainwindow.h"
|
||||
#include "ui_mainwindow.h"
|
||||
#include "mainwindowsettings.h"
|
||||
#include "ui_mainwindow.h"
|
||||
|
||||
#include "aboutdialog.h"
|
||||
|
||||
@ -28,10 +28,21 @@
|
||||
|
||||
#include "contentwidget.h"
|
||||
|
||||
#include "../model/bundle/policybundle.h"
|
||||
#include "gptiniutil.h"
|
||||
|
||||
#include "../model/registry/registry.h"
|
||||
#include "../model/registry/polregistrysource.h"
|
||||
#include "treevieweventfilter.h"
|
||||
|
||||
#include "../core/isnapin.h"
|
||||
#include "../core/isnapinmanager.h"
|
||||
|
||||
#include "../core/translatorstorage.h"
|
||||
|
||||
#include "../plugins/administrative_templates/bundle/itemtype.h"
|
||||
#include "../plugins/administrative_templates/bundle/policybundle.h"
|
||||
#include "../plugins/administrative_templates/bundle/policyroles.h"
|
||||
|
||||
#include "../plugins/administrative_templates/registry/polregistrysource.h"
|
||||
#include "../plugins/administrative_templates/registry/registry.h"
|
||||
|
||||
#include "../io/registryfileformat.h"
|
||||
|
||||
@ -39,142 +50,214 @@
|
||||
#include "../io/registryfile.h"
|
||||
#include "../io/registryfileformat.h"
|
||||
|
||||
#include "../io/policydefinitionsfile.h"
|
||||
#include "../io/policyfileformat.h"
|
||||
|
||||
#include "../io/inifile.h"
|
||||
|
||||
#include "../plugins/storage/smb/smbfile.h"
|
||||
|
||||
void registerResources()
|
||||
#include "../plugins/administrative_templates/bundle/policyroles.h"
|
||||
|
||||
#include "../ldap/ldapimpl.h"
|
||||
|
||||
#include <stack>
|
||||
|
||||
namespace gpui
|
||||
{
|
||||
class MainWindowPrivate
|
||||
{
|
||||
Q_INIT_RESOURCE(translations);
|
||||
}
|
||||
|
||||
namespace gpui {
|
||||
|
||||
class MainWindowPrivate {
|
||||
public:
|
||||
std::unique_ptr<QStandardItemModel> model = nullptr;
|
||||
ContentWidget* contentWidget;
|
||||
std::unique_ptr<QAbstractItemModel> model = nullptr;
|
||||
ContentWidget *contentWidget = nullptr;
|
||||
std::unique_ptr<MainWindowSettings> settings = nullptr;
|
||||
ISnapInManager *manager = nullptr;
|
||||
|
||||
std::shared_ptr<model::registry::Registry> userRegistry;
|
||||
std::unique_ptr<model::registry::AbstractRegistrySource> userRegistrySource;
|
||||
QString userRegistryPath;
|
||||
std::unique_ptr<QSortFilterProxyModel> itemNameSortModel = nullptr;
|
||||
std::unique_ptr<QSortFilterProxyModel> itemRoleSortModel = nullptr;
|
||||
std::unique_ptr<QSortFilterProxyModel> searchModel = nullptr;
|
||||
|
||||
std::shared_ptr<model::registry::Registry> machineRegistry;
|
||||
std::unique_ptr<model::registry::AbstractRegistrySource> machineRegistrySource;
|
||||
QString machineRegistryPath;
|
||||
std::vector<std::unique_ptr<QTranslator>> translators{};
|
||||
QString localeName{};
|
||||
|
||||
std::unique_ptr<QSortFilterProxyModel> sortModel = nullptr;
|
||||
QString itemName{};
|
||||
|
||||
std::vector<std::unique_ptr<QTranslator>> translators;
|
||||
QString localeName;
|
||||
QIcon windowIcon{};
|
||||
|
||||
QIcon windowIcon;
|
||||
CommandLineOptions options{};
|
||||
|
||||
CommandLineOptions options;
|
||||
std::unique_ptr<TreeViewEventFilter> eventFilter = nullptr;
|
||||
|
||||
std::unique_ptr<ldap::LDAPContract> ldapImpl = nullptr;
|
||||
|
||||
TranslatorStorage *translatorStorage = nullptr;
|
||||
|
||||
std::vector<QAction*> languageActions{};
|
||||
|
||||
int machineVersion = 0;
|
||||
int userVersion = 0;
|
||||
|
||||
MainWindowPrivate()
|
||||
: userRegistry(new model::registry::Registry())
|
||||
, userRegistrySource(new model::registry::PolRegistrySource(userRegistry))
|
||||
, machineRegistry(new model::registry::Registry())
|
||||
, machineRegistrySource(new model::registry::PolRegistrySource(machineRegistry))
|
||||
: eventFilter(new TreeViewEventFilter())
|
||||
, ldapImpl(new ldap::LDAPImpl())
|
||||
{}
|
||||
|
||||
private:
|
||||
MainWindowPrivate(const MainWindowPrivate &) = delete; // copy ctor
|
||||
MainWindowPrivate(MainWindowPrivate &&) = delete; // move ctor
|
||||
MainWindowPrivate &operator=(const MainWindowPrivate &) = delete; // copy assignment
|
||||
MainWindowPrivate &operator=(MainWindowPrivate &&) = delete; // move assignment
|
||||
};
|
||||
|
||||
void save(const std::string &fileName, std::shared_ptr<model::registry::Registry> registry)
|
||||
QModelIndex findParent(QAbstractItemModel *model, const QModelIndex &parent, const QUuid &id)
|
||||
{
|
||||
std::unique_ptr<io::RegistryFile> fileData = std::make_unique<io::RegistryFile>();
|
||||
fileData->setRegistry(registry);
|
||||
auto stack = std::make_unique<std::stack<QModelIndex>>();
|
||||
stack->push(parent);
|
||||
|
||||
QString pluginName = QString::fromStdString(fileName);
|
||||
pluginName = pluginName.mid(pluginName.lastIndexOf('.') + 1);
|
||||
|
||||
io::RegistryFileFormat<io::RegistryFile>* format = gpui::PluginStorage::instance()->createPluginClass<io::RegistryFileFormat<io::RegistryFile> >(pluginName);
|
||||
|
||||
if (!format)
|
||||
while (!stack->empty())
|
||||
{
|
||||
qWarning() << "Format supporting: " << pluginName << " not found.";
|
||||
auto current = stack->top();
|
||||
stack->pop();
|
||||
|
||||
return;
|
||||
auto currentId = current.data(model::bundle::CURRENT_UUID).value<QUuid>();
|
||||
if (currentId == id)
|
||||
{
|
||||
return current;
|
||||
}
|
||||
|
||||
for (int row = 0; row < model->rowCount(current); ++row)
|
||||
{
|
||||
QModelIndex index = model->index(row, 0, current);
|
||||
auto indexId = index.data(model::bundle::CURRENT_UUID).value<QUuid>();
|
||||
if (indexId == id)
|
||||
{
|
||||
return index;
|
||||
}
|
||||
|
||||
if (model->hasChildren(index))
|
||||
{
|
||||
for (int childRow = 0; childRow < model->rowCount(index); ++childRow)
|
||||
{
|
||||
QModelIndex childIndex = model->index(childRow, 0, index);
|
||||
stack->push(childIndex);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
auto oss = std::make_unique<std::ostringstream>();
|
||||
|
||||
if (!format->write(*oss, fileData.get()))
|
||||
{
|
||||
qWarning() << fileName.c_str() << " " << format->getErrorString().c_str();
|
||||
}
|
||||
|
||||
oss->flush();
|
||||
|
||||
qWarning() << "Current string values." << oss->str().c_str();
|
||||
|
||||
if (QString::fromStdString(fileName).startsWith("smb://"))
|
||||
{
|
||||
gpui::smb::SmbFile smbLocationItemFile(QString::fromStdString(fileName));
|
||||
bool isOpen = smbLocationItemFile.open(QFile::WriteOnly | QFile::Truncate);
|
||||
if (!isOpen)
|
||||
{
|
||||
isOpen = smbLocationItemFile.open(QFile::NewOnly | QFile::WriteOnly);
|
||||
}
|
||||
if (isOpen && oss->str().size() > 0)
|
||||
{
|
||||
smbLocationItemFile.write(&oss->str().at(0), oss->str().size());
|
||||
}
|
||||
smbLocationItemFile.close();
|
||||
}
|
||||
else
|
||||
{
|
||||
QFile registryFile(QString::fromStdString(fileName));
|
||||
registryFile.open(QFile::WriteOnly | QFile::Truncate);
|
||||
if (!registryFile.isOpen())
|
||||
{
|
||||
registryFile.open(QFile::NewOnly | QFile::WriteOnly);
|
||||
}
|
||||
if (registryFile.isOpen() && registryFile.isWritable() && oss->str().size() > 0)
|
||||
{
|
||||
registryFile.write(&oss->str().at(0), oss->str().size());
|
||||
}
|
||||
registryFile.close();
|
||||
}
|
||||
|
||||
|
||||
delete format;
|
||||
return QModelIndex();
|
||||
}
|
||||
|
||||
MainWindow::MainWindow(CommandLineOptions &options, QWidget *parent)
|
||||
void appendModel(QStandardItem *target, const QAbstractItemModel *model, const QModelIndex &parent)
|
||||
{
|
||||
for (int rowIndex = 0; rowIndex < model->rowCount(parent); ++rowIndex)
|
||||
{
|
||||
QModelIndex index = model->index(rowIndex, 0, parent);
|
||||
|
||||
auto parentId = index.data(model::bundle::PARENT_UUID).value<QUuid>();
|
||||
auto parentIndex = QModelIndex();
|
||||
auto currentId = index.data(model::bundle::CURRENT_UUID).value<QUuid>();
|
||||
|
||||
auto currentIndex = findParent(target->model(), target->model()->index(0, 0).parent(), currentId);
|
||||
QStandardItem *child = nullptr;
|
||||
|
||||
if (!currentIndex.isValid())
|
||||
{
|
||||
if (!currentId.isNull())
|
||||
{
|
||||
qWarning() << "Current id: " << currentId;
|
||||
}
|
||||
if (!parentId.isNull())
|
||||
{
|
||||
qWarning() << "Non null uuid" << index.data() << parentId;
|
||||
parentIndex = findParent(target->model(), target->model()->index(0, 0), parentId);
|
||||
}
|
||||
|
||||
child = new QStandardItem();
|
||||
child->setData(index.data(Qt::DisplayRole), Qt::DisplayRole);
|
||||
child->setData(index.data(Qt::DecorationRole), Qt::DecorationRole);
|
||||
child->setData(index.data(model::bundle::ITEM_TYPE), model::bundle::ITEM_TYPE);
|
||||
child->setData(index.data(model::bundle::EXPLAIN_TEXT), model::bundle::EXPLAIN_TEXT);
|
||||
child->setData(index.data(model::bundle::SUPPORTED_ON), model::bundle::SUPPORTED_ON);
|
||||
child->setData(index.data(model::bundle::PRESENTATION), model::bundle::PRESENTATION);
|
||||
child->setData(index.data(model::bundle::POLICY), model::bundle::POLICY);
|
||||
child->setData(index.data(model::bundle::POLICY_TYPE), model::bundle::POLICY_TYPE);
|
||||
child->setData(index.data(model::bundle::POLICY_WIDGET), model::bundle::POLICY_WIDGET);
|
||||
child->setData(index.data(model::bundle::CURRENT_UUID), model::bundle::CURRENT_UUID);
|
||||
child->setData(index.data(model::bundle::PARENT_UUID), model::bundle::PARENT_UUID);
|
||||
|
||||
if (parentIndex.isValid())
|
||||
{
|
||||
qWarning() << "Found valid index" << parentIndex.data();
|
||||
target->model()->itemFromIndex(parentIndex)->appendRow(child);
|
||||
}
|
||||
else
|
||||
{
|
||||
target->insertRow(rowIndex, child);
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
child = target->model()->itemFromIndex(currentIndex);
|
||||
}
|
||||
|
||||
if (model->hasChildren(index))
|
||||
{
|
||||
appendModel(child, model, index);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
MainWindow::MainWindow(CommandLineOptions &options,
|
||||
ISnapInManager *manager,
|
||||
TranslatorStorage *translatorStorage,
|
||||
QWidget *parent)
|
||||
: QMainWindow(parent)
|
||||
, d(new MainWindowPrivate())
|
||||
, ui(new Ui::MainWindow())
|
||||
{
|
||||
registerResources();
|
||||
d->manager = manager;
|
||||
|
||||
d->options = options;
|
||||
|
||||
d->translatorStorage = translatorStorage;
|
||||
|
||||
ui->setupUi(this);
|
||||
|
||||
ui->treeView->installEventFilter(d->eventFilter.get());
|
||||
|
||||
d->ldapImpl->initialize();
|
||||
|
||||
d->settings = std::make_unique<MainWindowSettings>(this, ui);
|
||||
d->settings->restoreSettings();
|
||||
|
||||
createLanguageMenu();
|
||||
|
||||
d->contentWidget = new ContentWidget(this);
|
||||
d->contentWidget->setMachineRegistrySource(d->machineRegistrySource.get());
|
||||
d->contentWidget->setUserRegistrySource(d->userRegistrySource.get());
|
||||
d->contentWidget->setEventFilter(d->eventFilter.get());
|
||||
|
||||
ui->splitter->addWidget(d->contentWidget);
|
||||
|
||||
connect(ui->actionOpenPolicyDirectory, &QAction::triggered, this, &MainWindow::onDirectoryOpen);
|
||||
connect(ui->actionSaveRegistrySource, &QAction::triggered, this, &MainWindow::onRegistrySourceSave);
|
||||
connect(ui->treeView, &QTreeView::clicked, d->contentWidget, &ContentWidget::modelItemSelected);
|
||||
connect(d->eventFilter.get(), &TreeViewEventFilter::onEnter, this, [&]() {
|
||||
ui->treeView->clicked(ui->treeView->currentIndex());
|
||||
});
|
||||
|
||||
QLocale locale(!d->localeName.trimmed().isEmpty() ? d->localeName.replace("-","_") : "");
|
||||
std::unique_ptr<QTranslator> qtTranslator = std::make_unique<QTranslator>();
|
||||
qtTranslator->load(locale, "gui", "_", ":/");
|
||||
QCoreApplication::installTranslator(qtTranslator.get());
|
||||
d->translators.push_back(std::move(qtTranslator));
|
||||
d->localeName = locale.name().replace("_","-");
|
||||
d->contentWidget->onLanguageChaged();
|
||||
connect(ui->actionOpenPolicyDirectory, &QAction::triggered, this, &MainWindow::onDirectoryOpen);
|
||||
connect(ui->actionSaveRegistrySource, &QAction::triggered, this, &MainWindow::updateStatusBar);
|
||||
connect(ui->treeView, &QTreeView::clicked, d->contentWidget, &ContentWidget::modelItemSelected);
|
||||
connect(d->contentWidget, &ContentWidget::modelItemSelected, [&](const QModelIndex ¤t) {
|
||||
d->itemName = current.data().toString();
|
||||
});
|
||||
|
||||
QLocale locale(!d->localeName.trimmed().isEmpty() ? d->localeName.replace("-", "_")
|
||||
: QLocale::system().name().replace("-", "_"));
|
||||
QString language = locale.name().split("_").at(0);
|
||||
loadTranslations(language);
|
||||
|
||||
d->localeName = locale.name().replace("_", "-");
|
||||
d->contentWidget->onLanguageChanged();
|
||||
ui->retranslateUi(this);
|
||||
retranslateLanguageActions();
|
||||
|
||||
d->windowIcon = QIcon(":gpui.png");
|
||||
|
||||
@ -185,27 +268,44 @@ MainWindow::MainWindow(CommandLineOptions &options, QWidget *parent)
|
||||
d->options.policyBundle = "/usr/share/PolicyDefinitions";
|
||||
}
|
||||
|
||||
loadPolicyBundleFolder(d->options.policyBundle, d->localeName);
|
||||
if (d->options.path.isEmpty())
|
||||
{
|
||||
d->options.path = QDir::currentPath();
|
||||
}
|
||||
|
||||
for (auto &snapIn : manager->getSnapIns())
|
||||
{
|
||||
qWarning() << "Loading model from: " << snapIn->getDisplayName();
|
||||
snapIn->onInitialize(this);
|
||||
}
|
||||
|
||||
if (!d->options.path.isEmpty())
|
||||
{
|
||||
d->userRegistryPath = d->options.path + "/User/Registry.pol";
|
||||
d->machineRegistryPath = d->options.path + "/Machine/Registry.pol";
|
||||
|
||||
onPolFileOpen(d->userRegistryPath, d->userRegistry, d->userRegistrySource,
|
||||
[&](model::registry::AbstractRegistrySource* source)
|
||||
for (auto &snapIn : manager->getSnapIns())
|
||||
{
|
||||
d->contentWidget->setUserRegistrySource(source);
|
||||
});
|
||||
|
||||
onPolFileOpen(d->machineRegistryPath, d->machineRegistry, d->machineRegistrySource,
|
||||
[&](model::registry::AbstractRegistrySource* source)
|
||||
{
|
||||
d->contentWidget->setMachineRegistrySource(source);
|
||||
});
|
||||
snapIn->onDataLoad(d->options.path.toStdString(), d->localeName.toStdString());
|
||||
}
|
||||
}
|
||||
|
||||
connect(d->contentWidget, &ContentWidget::savePolicyChanges, this, &MainWindow::onRegistrySourceSave);
|
||||
QString guid = isAnyGUID(d->options.path);
|
||||
|
||||
qWarning() << "Guid: " << guid;
|
||||
|
||||
if (guid != "")
|
||||
{
|
||||
d->options.policyName = d->ldapImpl.get()->getDisplayNameGPO(guid);
|
||||
|
||||
int version = d->ldapImpl->getGPOVersion(guid);
|
||||
|
||||
d->machineVersion = version & 0x0000FFFF;
|
||||
d->userVersion = (version & 0xFFFF0000) >> 16;
|
||||
}
|
||||
|
||||
loadPolicyModel(manager);
|
||||
|
||||
connect(ui->searchLineEdit, &QLineEdit::textChanged, [&](const QString &text) {
|
||||
d->searchModel->setFilterFixedString(text);
|
||||
});
|
||||
}
|
||||
|
||||
MainWindow::~MainWindow()
|
||||
@ -228,6 +328,7 @@ QString MainWindow::getLanguage() const
|
||||
void MainWindow::setAdmxPath(const QString &admxPath)
|
||||
{
|
||||
d->options.policyBundle = admxPath;
|
||||
admxPathChanged(admxPath);
|
||||
}
|
||||
|
||||
QString MainWindow::getAdmxPath() const
|
||||
@ -235,6 +336,11 @@ QString MainWindow::getAdmxPath() const
|
||||
return d->options.policyBundle;
|
||||
}
|
||||
|
||||
QString MainWindow::getPolicyName() const
|
||||
{
|
||||
return d->options.policyName;
|
||||
}
|
||||
|
||||
void MainWindow::closeEvent(QCloseEvent *event)
|
||||
{
|
||||
d->settings->saveSettings();
|
||||
@ -242,28 +348,98 @@ void MainWindow::closeEvent(QCloseEvent *event)
|
||||
QMainWindow::closeEvent(event);
|
||||
}
|
||||
|
||||
void gpui::MainWindow::loadPolicyBundleFolder(const QString& path, const QString &locale)
|
||||
void MainWindow::loadPolicyModel(ISnapInManager *manager)
|
||||
{
|
||||
auto bundle = std::make_unique<model::bundle::PolicyBundle>();
|
||||
d->model = bundle->loadFolder(path.toStdString(), locale.toStdString());
|
||||
auto concatenateRowsModel = std::make_unique<QStandardItemModel>();
|
||||
|
||||
d->sortModel = std::make_unique<QSortFilterProxyModel>();
|
||||
d->sortModel->setSourceModel(d->model.get());
|
||||
d->sortModel->setSortLocaleAware(true);
|
||||
d->sortModel->setSortRole(Qt::DisplayRole);
|
||||
d->sortModel->sort(0);
|
||||
QStandardItem *rootItem = concatenateRowsModel->invisibleRootItem();
|
||||
rootItem->setData("Root Item", Qt::DisplayRole);
|
||||
|
||||
ui->treeView->setModel(d->sortModel.get());
|
||||
d->contentWidget->setModel(d->sortModel.get());
|
||||
QStandardItem *visibleRootItem = new QStandardItem();
|
||||
visibleRootItem->setData(QIcon::fromTheme("text-x-generic-template"), Qt::DecorationRole);
|
||||
visibleRootItem->setData(static_cast<uint>(model::bundle::ItemType::ITEM_TYPE_CATEGORY), model::bundle::ITEM_TYPE);
|
||||
visibleRootItem->setData(QObject::tr("Local group policies"), model::bundle::EXPLAIN_TEXT);
|
||||
visibleRootItem->setData(static_cast<uint>(model::admx::PolicyType::Both), model::bundle::POLICY_TYPE);
|
||||
|
||||
QString adjustedPolicyName = d->options.policyName.isEmpty()
|
||||
? d->options.policyName
|
||||
: QString(" - %1").arg(d->options.policyName);
|
||||
|
||||
if (d->options.path.startsWith("smb://"))
|
||||
{
|
||||
QRegExp domainRegexp("^(?:smb?:\\/\\/)?([^:\\/\\n?]+)");
|
||||
if (domainRegexp.indexIn(d->options.path) != -1)
|
||||
{
|
||||
visibleRootItem->setData('[' + domainRegexp.cap() + ']' + adjustedPolicyName, Qt::DisplayRole);
|
||||
}
|
||||
else
|
||||
{
|
||||
visibleRootItem->setData(QObject::tr("[Domain Group Policy]") + adjustedPolicyName, Qt::DisplayRole);
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
visibleRootItem->setData(QObject::tr("[Local Group Policy]") + adjustedPolicyName, Qt::DisplayRole);
|
||||
}
|
||||
|
||||
rootItem->appendRow(visibleRootItem);
|
||||
|
||||
for (auto &snapIn : manager->getSnapIns())
|
||||
{
|
||||
if (snapIn->getRootNode())
|
||||
{
|
||||
QAbstractItemModel *snapInModel = snapIn->getRootNode();
|
||||
qWarning() << "Appending model from: " << snapIn->getDisplayName();
|
||||
appendModel(visibleRootItem, snapInModel, snapInModel->index(0, 0));
|
||||
}
|
||||
}
|
||||
|
||||
d->model = std::move(concatenateRowsModel);
|
||||
|
||||
d->itemNameSortModel = std::make_unique<QSortFilterProxyModel>();
|
||||
d->itemNameSortModel->setSourceModel(d->model.get());
|
||||
d->itemNameSortModel->setSortLocaleAware(true);
|
||||
d->itemNameSortModel->setSortRole(Qt::DisplayRole);
|
||||
d->itemNameSortModel->sort(0);
|
||||
|
||||
d->itemRoleSortModel = std::make_unique<QSortFilterProxyModel>();
|
||||
d->itemRoleSortModel->setSourceModel(d->itemNameSortModel.get());
|
||||
d->itemRoleSortModel->setSortRole(model::bundle::PolicyRoles::ITEM_TYPE);
|
||||
d->itemRoleSortModel->sort(0);
|
||||
|
||||
d->searchModel = std::make_unique<QSortFilterProxyModel>();
|
||||
d->searchModel->setSourceModel(d->itemRoleSortModel.get());
|
||||
d->searchModel->setFilterRole(Qt::DisplayRole);
|
||||
d->searchModel->setFilterFixedString("");
|
||||
d->searchModel->setFilterCaseSensitivity(Qt::CaseInsensitive);
|
||||
d->searchModel->setRecursiveFilteringEnabled(true);
|
||||
|
||||
ui->treeView->setModel(d->searchModel.get());
|
||||
ui->treeView->setEditTriggers(QAbstractItemView::NoEditTriggers);
|
||||
|
||||
d->contentWidget->setModel(d->searchModel.get());
|
||||
|
||||
d->contentWidget->setSelectionModel(ui->treeView->selectionModel());
|
||||
|
||||
d->contentWidget->modelItemSelected(d->sortModel->index(0, 0));
|
||||
ui->treeView->expand(d->searchModel->index(0, 0));
|
||||
ui->treeView->setColumnHidden(1, true);
|
||||
|
||||
d->contentWidget->modelItemSelected(d->searchModel->index(0, 0));
|
||||
|
||||
int gptIniMachineVersion = 0;
|
||||
int gptIniUserVersion = 0;
|
||||
QString gptIniPolicyName;
|
||||
|
||||
GptIniUtils gptUtils;
|
||||
|
||||
gptUtils.onIniFileOpen(d->options.path + "/gpt.ini", gptIniPolicyName, gptIniMachineVersion, gptIniUserVersion);
|
||||
|
||||
d->machineVersion = d->machineVersion >= gptIniMachineVersion ? d->machineVersion : gptIniMachineVersion;
|
||||
d->userVersion = d->userVersion >= gptIniUserVersion ? d->userVersion : gptIniUserVersion;
|
||||
}
|
||||
|
||||
void MainWindow::onDirectoryOpen()
|
||||
{
|
||||
|
||||
{
|
||||
std::unique_ptr<QFileDialog> fileDialog = std::make_unique<QFileDialog>(this);
|
||||
|
||||
fileDialog->setDirectory(QDir::homePath());
|
||||
@ -274,10 +450,10 @@ void MainWindow::onDirectoryOpen()
|
||||
fileDialog->setLabelText(QFileDialog::FileName, tr("File name"));
|
||||
fileDialog->setLabelText(QFileDialog::LookIn, tr("Look in"));
|
||||
fileDialog->setLabelText(QFileDialog::Reject, tr("Cancel"));
|
||||
fileDialog->setLabelText(QFileDialog::FileType, tr("File type"));
|
||||
|
||||
fileDialog->setNameFilter(QObject::tr("All files (*.*)"));
|
||||
fileDialog->setOptions(QFileDialog::ShowDirsOnly
|
||||
| QFileDialog::DontResolveSymlinks
|
||||
fileDialog->setOptions(QFileDialog::ShowDirsOnly | QFileDialog::DontResolveSymlinks
|
||||
| QFileDialog::DontUseNativeDialog);
|
||||
|
||||
fileDialog->setWindowIcon(d->windowIcon);
|
||||
@ -285,32 +461,48 @@ void MainWindow::onDirectoryOpen()
|
||||
|
||||
if (fileDialog->exec() == QDialog::Accepted)
|
||||
{
|
||||
d->options.policyBundle = fileDialog->selectedUrls().value(0).toLocalFile();
|
||||
loadPolicyBundleFolder(d->options.policyBundle, d->localeName);
|
||||
setAdmxPath(fileDialog->selectedUrls().value(0).toLocalFile());
|
||||
loadPolicyModel(d->manager);
|
||||
}
|
||||
}
|
||||
|
||||
void MainWindow::onRegistrySourceSave()
|
||||
void MainWindow::updateStatusBar()
|
||||
{
|
||||
if (!d->machineRegistryPath.isEmpty())
|
||||
QString guid = isAnyGUID(d->options.path);
|
||||
|
||||
const QString preferecnes {
|
||||
"[{5794DAFD-BE60-433f-88A2-1A31939AC01F}{2EA1A81B-48E5-45E9-8BB7-A6E3AC170006}]" // Preference CSE GUID Drives
|
||||
"[{0E28E245-9368-4853-AD84-6DA3BA35BB75}{35141B6B-498A-4CC7-AD59-CEF93D89B2CE}]" // Preference CSE GUID Environment Variables
|
||||
"[{7150F9BF-48AD-4da4-A49C-29EF4A8369BA}{3BAE7E51-E3F4-41D0-853D-9BB9FD47605F}]" // Preference CSE GUID Files
|
||||
"[{6232C319-91AC-4931-9385-E70C2B099F0E}{3EC4E9D3-714D-471F-88DC-4DD4471AAB47}]" // Preference CSE GUID Folders
|
||||
"[{74EE6C03-5363-4554-B161-627540339CAB}{516FC620-5D34-4B08-8165-6A06B623EDEB}]" // Preference CSE GUID Ini Files
|
||||
"[{6A4C88C6-C502-4f74-8F60-2CB23EDC24E2}{BFCBBEB0-9DF4-4c0c-A728-434EA66A0373}]" // Preference CSE GUID Network Shares
|
||||
"[{B087BE9D-ED37-454f-AF9C-04291E351182}{BEE07A6A-EC9F-4659-B8C9-0B1937907C83}]" // Preference CSE GUID Registry
|
||||
"[{6A4C88C6-C502-4f74-8F60-2CB23EDC24E2}{BFCBBEB0-9DF4-4c0c-A728-434EA66A0373}]" // Preference CSE GUID Network Shares";
|
||||
};
|
||||
|
||||
const QString machineAdministrativeTemplates = "[{35378EAC-683F-11D2-A89A-00C04FBBCFA2}{D02B1F72-3407-48AE-BA88-E8213C6761F1}]";
|
||||
const QString machineScripts = "[{42B5FAAE-6536-11d2-AE5A-0000F87571E3}{40B6664F-4972-11D1-A7CA-0000F87571E3}]";
|
||||
|
||||
const QString userAdministrativeTemplates = "[{35378EAC-683F-11D2-A89A-00C04FBBCFA2}{D02B1F73-3407-48AE-BA88-E8213C6761F1}]";
|
||||
const QString userScripts = "[{42B5FAAE-6536-11d2-AE5A-0000F87571E3}{40B66650-4972-11D1-A7CA-0000F87571E3}]";
|
||||
|
||||
QString machineExtensions = machineAdministrativeTemplates + preferecnes + machineScripts;
|
||||
QString userExtensions = userAdministrativeTemplates + preferecnes + userScripts;
|
||||
|
||||
++d->machineVersion;
|
||||
++d->userVersion;
|
||||
|
||||
if (guid != "")
|
||||
{
|
||||
qWarning() << "Saving machine registry to: " << d->machineRegistryPath;
|
||||
save(d->machineRegistryPath.toStdString(), d->machineRegistry);
|
||||
}
|
||||
else
|
||||
{
|
||||
qWarning() << "Unable to save machine registry path is empty!";
|
||||
d->ldapImpl->setExtensions(guid, machineExtensions, userExtensions, d->machineVersion, d->userVersion);
|
||||
}
|
||||
|
||||
if (!d->userRegistryPath.isEmpty())
|
||||
{
|
||||
qWarning() << "Saving user registry to: " << d->userRegistryPath;
|
||||
save(d->userRegistryPath.toStdString(), d->userRegistry);
|
||||
}
|
||||
else
|
||||
{
|
||||
qWarning() << "Unable to save user registry path is empty!";
|
||||
}
|
||||
GptIniUtils gptUtils;
|
||||
|
||||
gptUtils.onIniFileSave(d->options.path + "/gpt.ini", d->options.policyName, d->machineVersion, d->userVersion);
|
||||
|
||||
ui->statusbar->showMessage(tr("Applied changes for policy: ") + d->itemName);
|
||||
}
|
||||
|
||||
void MainWindow::on_actionExit_triggered()
|
||||
@ -320,7 +512,9 @@ void MainWindow::on_actionExit_triggered()
|
||||
|
||||
void MainWindow::on_actionManual_triggered()
|
||||
{
|
||||
const QUrl manual_url = QUrl("https://www.altlinux.org/%D0%93%D1%80%D1%83%D0%BF%D0%BF%D0%BE%D0%B2%D1%8B%D0%B5_%D0%BF%D0%BE%D0%BB%D0%B8%D1%82%D0%B8%D0%BA%D0%B8/GPUI");
|
||||
const QUrl manual_url = QUrl("https://www.altlinux.org/"
|
||||
"%D0%93%D1%80%D1%83%D0%BF%D0%BF%D0%BE%D0%B2%D1%8B%D0%B5_%D0%BF%D0%"
|
||||
"BE%D0%BB%D0%B8%D1%82%D0%B8%D0%BA%D0%B8/GPUI");
|
||||
QDesktopServices::openUrl(manual_url);
|
||||
}
|
||||
|
||||
@ -330,88 +524,46 @@ void MainWindow::on_actionAbout_triggered()
|
||||
about->show();
|
||||
}
|
||||
|
||||
void gpui::MainWindow::retranslateLanguageActions()
|
||||
{
|
||||
for (auto& languageAction : d->languageActions)
|
||||
{
|
||||
languageAction->setText(selectTranslationForLanguageName(languageAction->data().toString()));
|
||||
}
|
||||
}
|
||||
|
||||
void MainWindow::onLanguageChanged(QAction *action)
|
||||
{
|
||||
for (const auto& translator : d->translators)
|
||||
{
|
||||
qApp->removeTranslator(translator.get());
|
||||
}
|
||||
d->translators.clear();
|
||||
d->translatorStorage->clearTranslators();
|
||||
|
||||
QString language = action->data().toString();
|
||||
|
||||
std::unique_ptr<QTranslator> qtTranslator = std::make_unique<QTranslator>();
|
||||
bool loadResult = qtTranslator->load("gui_" + language + ".qm", ":/");
|
||||
QCoreApplication::installTranslator(qtTranslator.get());
|
||||
d->translators.push_back(std::move(qtTranslator));
|
||||
qWarning() << "Load language " << language << loadResult;
|
||||
loadTranslations(language);
|
||||
|
||||
QLocale locale(language);
|
||||
|
||||
d->localeName = locale.name().replace("_", "-");
|
||||
|
||||
loadPolicyBundleFolder(d->options.policyBundle, d->localeName);
|
||||
for (auto &snapIn : d->manager->getSnapIns())
|
||||
{
|
||||
snapIn->onRetranslateUI(d->localeName.toStdString());
|
||||
qWarning() << d->localeName;
|
||||
}
|
||||
|
||||
d->contentWidget->onLanguageChaged();
|
||||
d->contentWidget->onLanguageChanged();
|
||||
ui->retranslateUi(this);
|
||||
|
||||
loadPolicyModel(d->manager);
|
||||
|
||||
ui->treeView->selectionModel()->clearSelection();
|
||||
}
|
||||
|
||||
void MainWindow::onPolFileOpen(const QString &path,
|
||||
std::shared_ptr<model::registry::Registry> ®istry,
|
||||
std::unique_ptr<model::registry::AbstractRegistrySource> &source,
|
||||
std::function<void (model::registry::AbstractRegistrySource *)> callback)
|
||||
{
|
||||
qWarning() << "Path recieved: " << path;
|
||||
ui->searchLineEdit->clear();
|
||||
|
||||
auto stringvalues = std::make_unique<std::string>();
|
||||
|
||||
try {
|
||||
|
||||
if (path.startsWith("smb://"))
|
||||
{
|
||||
gpui::smb::SmbFile smbLocationItemFile(path);
|
||||
smbLocationItemFile.open(QFile::ReadOnly);
|
||||
stringvalues->resize(smbLocationItemFile.size(), 0);
|
||||
smbLocationItemFile.read(&stringvalues->at(0), smbLocationItemFile.size());
|
||||
smbLocationItemFile.close();
|
||||
}
|
||||
else
|
||||
{
|
||||
QFile registryFile(path);
|
||||
registryFile.open(QFile::ReadWrite);
|
||||
stringvalues->resize(registryFile.size(), 0);
|
||||
registryFile.read(&stringvalues->at(0), registryFile.size());
|
||||
registryFile.close();
|
||||
}
|
||||
|
||||
auto iss = std::make_unique<std::istringstream>(*stringvalues);
|
||||
std::string pluginName("pol");
|
||||
|
||||
auto reader = std::make_unique<io::GenericReader>();
|
||||
auto registryFile = reader->load<io::RegistryFile, io::RegistryFileFormat<io::RegistryFile> >(*iss, pluginName);
|
||||
if (!registryFile)
|
||||
{
|
||||
qWarning() << "Unable to load registry file contents.";
|
||||
return;
|
||||
}
|
||||
|
||||
registry = registryFile->getRegistry();
|
||||
|
||||
source = std::make_unique<model::registry::PolRegistrySource>(registry);
|
||||
|
||||
callback(source.get());
|
||||
}
|
||||
catch (std::exception& e)
|
||||
{
|
||||
qWarning() << "Unable to read file: " << qPrintable(path) << " Error: " << e.what();
|
||||
}
|
||||
retranslateLanguageActions();
|
||||
}
|
||||
|
||||
void MainWindow::createLanguageMenu()
|
||||
{
|
||||
QActionGroup* langGroup = new QActionGroup(this);
|
||||
QActionGroup *langGroup = new QActionGroup(this);
|
||||
langGroup->setExclusive(true);
|
||||
|
||||
connect(langGroup, &QActionGroup::triggered, this, &MainWindow::onLanguageChanged);
|
||||
@ -420,7 +572,7 @@ void MainWindow::createLanguageMenu()
|
||||
QDir dir(":/");
|
||||
QStringList fileNames = dir.entryList(QStringList("gui_*.qm"));
|
||||
|
||||
QMenu* menu = new QMenu(this);
|
||||
QMenu *menu = new QMenu(this);
|
||||
ui->actionLanguage->setMenu(menu);
|
||||
|
||||
for (QString locale : fileNames)
|
||||
@ -441,7 +593,69 @@ void MainWindow::createLanguageMenu()
|
||||
{
|
||||
action->setChecked(true);
|
||||
}
|
||||
|
||||
d->languageActions.emplace_back(action);
|
||||
}
|
||||
}
|
||||
|
||||
QString MainWindow::isAnyGUID(QString &path)
|
||||
{
|
||||
QRegExp lastPartOfPath("/\\{([^/]+)\\}/?$");
|
||||
QRegExp regExpGuid("^([a-fA-F0-9]{8}-[a-fA-F0-9]{4}-[a-fA-F0-9]{4}-[a-fA-F0-9]{4}-[a-fA-F0-9]{12})$");
|
||||
|
||||
qWarning() << lastPartOfPath.indexIn(path);
|
||||
|
||||
if (lastPartOfPath.indexIn(path) != -1)
|
||||
{
|
||||
QStringList lastPart = lastPartOfPath.capturedTexts();
|
||||
|
||||
QString preGuid = lastPart[lastPart.size() - 1];
|
||||
|
||||
if (regExpGuid.indexIn(preGuid) != -1)
|
||||
{
|
||||
return preGuid;
|
||||
}
|
||||
else
|
||||
{
|
||||
return QString();
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
return QString();
|
||||
}
|
||||
}
|
||||
|
||||
void MainWindow::loadTranslations(QString &language)
|
||||
{
|
||||
d->translatorStorage->clearTranslators();
|
||||
|
||||
d->translatorStorage->loadTranslators(language);
|
||||
|
||||
d->translatorStorage->loadQtTranslations(language, QString("qtbase_%2").arg(language));
|
||||
d->translatorStorage->loadQtTranslations(language, "qt_");
|
||||
}
|
||||
|
||||
QString MainWindow::selectTranslationForLanguageName(const QString &name)
|
||||
{
|
||||
qWarning() << "Trying to select name for language: " << name;
|
||||
|
||||
if (name.compare("en") == 0)
|
||||
{
|
||||
return QObject::tr("English");
|
||||
}
|
||||
|
||||
if (name.compare("ru") == 0)
|
||||
{
|
||||
return QObject::tr("Russian");
|
||||
}
|
||||
|
||||
return "";
|
||||
}
|
||||
|
||||
void MainWindow::updateFilterModel()
|
||||
{
|
||||
loadPolicyModel(d->manager);
|
||||
}
|
||||
|
||||
} // namespace gpui
|
||||
|
@ -23,69 +23,109 @@
|
||||
|
||||
#include "gui.h"
|
||||
|
||||
#include "../core/translatorstorage.h"
|
||||
#include <QtWidgets>
|
||||
|
||||
#include "../ldap/ldapcontract.h"
|
||||
#include "../ldap/ldapimpl.h"
|
||||
|
||||
QT_BEGIN_NAMESPACE
|
||||
namespace Ui { class MainWindow; }
|
||||
namespace Ui
|
||||
{
|
||||
class MainWindow;
|
||||
}
|
||||
QT_END_NAMESPACE
|
||||
|
||||
namespace model {
|
||||
namespace registry {
|
||||
class AbstractRegistrySource;
|
||||
class Registry;
|
||||
}
|
||||
}
|
||||
namespace model
|
||||
{
|
||||
namespace registry
|
||||
{
|
||||
class AbstractRegistrySource;
|
||||
class Registry;
|
||||
} // namespace registry
|
||||
} // namespace model
|
||||
|
||||
namespace gpui {
|
||||
namespace gpui
|
||||
{
|
||||
class CommandLineOptions;
|
||||
class MainWindowPrivate;
|
||||
class ISnapInManager;
|
||||
class ISnapIn;
|
||||
|
||||
class CommandLineOptions;
|
||||
class MainWindowPrivate;
|
||||
class GPUI_GUI_EXPORT MainWindow : public QMainWindow
|
||||
{
|
||||
Q_OBJECT
|
||||
public:
|
||||
// construction and destruction
|
||||
MainWindow(CommandLineOptions &options,
|
||||
ISnapInManager *manager,
|
||||
TranslatorStorage *translatorStorage,
|
||||
QWidget *parent = 0);
|
||||
~MainWindow();
|
||||
|
||||
class GPUI_GUI_EXPORT MainWindow : public QMainWindow {
|
||||
Q_OBJECT
|
||||
void setLanguage(const QString &language);
|
||||
QString getLanguage() const;
|
||||
|
||||
public:
|
||||
// construction and destruction
|
||||
MainWindow(CommandLineOptions& options, QWidget *parent = 0);
|
||||
~MainWindow();
|
||||
void setAdmxPath(const QString &admxPath);
|
||||
QString getAdmxPath() const;
|
||||
|
||||
void setLanguage(const QString& language);
|
||||
QString getLanguage() const;
|
||||
QString getPolicyName() const;
|
||||
|
||||
void setAdmxPath(const QString& admxPath);
|
||||
QString getAdmxPath() const;
|
||||
signals:
|
||||
void admxPathChanged(const QString &admxPath);
|
||||
|
||||
protected:
|
||||
void closeEvent(QCloseEvent *event) override;
|
||||
public slots:
|
||||
void updateStatusBar();
|
||||
|
||||
private slots:
|
||||
void on_actionManual_triggered();
|
||||
void updateFilterModel();
|
||||
|
||||
private:
|
||||
protected:
|
||||
void closeEvent(QCloseEvent *event) override;
|
||||
|
||||
MainWindowPrivate* const d;
|
||||
private slots:
|
||||
void on_actionManual_triggered();
|
||||
|
||||
Ui::MainWindow *ui;
|
||||
private:
|
||||
MainWindowPrivate *const d;
|
||||
|
||||
private slots:
|
||||
void onDirectoryOpen();
|
||||
void onRegistrySourceSave();
|
||||
Ui::MainWindow *ui;
|
||||
|
||||
void on_actionExit_triggered();
|
||||
void on_actionAbout_triggered();
|
||||
private slots:
|
||||
void onDirectoryOpen();
|
||||
|
||||
void onLanguageChanged(QAction *action);
|
||||
void on_actionExit_triggered();
|
||||
void on_actionAbout_triggered();
|
||||
|
||||
private:
|
||||
void onPolFileOpen(const QString& path,
|
||||
std::shared_ptr<model::registry::Registry>& registry,
|
||||
std::unique_ptr<model::registry::AbstractRegistrySource>& source,
|
||||
std::function<void(model::registry::AbstractRegistrySource* source)> callback);
|
||||
void onLanguageChanged(QAction *action);
|
||||
|
||||
void loadPolicyBundleFolder(const QString& path, const QString& locale);
|
||||
private:
|
||||
void onIniFileOpen(const QString &path);
|
||||
|
||||
void createLanguageMenu();
|
||||
};
|
||||
}
|
||||
void loadPolicyModel(ISnapInManager *manager);
|
||||
|
||||
void createLanguageMenu();
|
||||
|
||||
QString isAnyIPAddress(const QString &path);
|
||||
|
||||
QString isAnyDomainName(const QString &path);
|
||||
|
||||
QString isAnyGUID(const QString &path);
|
||||
|
||||
void loadTranslations(QString &language);
|
||||
|
||||
QString selectTranslationForLanguageName(const QString& name);
|
||||
|
||||
void retranslateLanguageActions();
|
||||
|
||||
private:
|
||||
MainWindow(const MainWindow &) = delete; // copy ctor
|
||||
MainWindow(MainWindow &&) = delete; // move ctor
|
||||
MainWindow &operator=(const MainWindow &) = delete; // copy assignment
|
||||
MainWindow &operator=(MainWindow &&) = delete; // move assignment
|
||||
|
||||
private:
|
||||
QString isAnyGUID(QString &path);
|
||||
};
|
||||
} // namespace gpui
|
||||
|
||||
#endif // GPUI_MAINWINDOW_H
|
||||
|
Some files were not shown because too many files have changed in this diff Show More
Loading…
x
Reference in New Issue
Block a user