Debian Codegraph @

src/Config.h

raw symbols SCIP
1 // SPDX-FileCopyrightText: Nheko Contributors
2 //
3 // SPDX-License-Identifier: GPL-3.0-or-later
4
5 #pragma once
6
7 #include <QRegularExpression>
8 #include <QString>
9
10 // clazy:excludeall=non-pod-global-static
11
12 // Non-theme app configuration. Layouts, fonts spacing etc.
13 //
14 // Font sizes are in pixels.
15 namespace conf {
16
17 namespace modals {
18 inline constexpr int WIDGET_MARGIN = 20;
19 inline constexpr int WIDGET_SPACING = 15;
20
21 inline constexpr auto LABEL_MEDIUM_SIZE_RATIO = 1.3;
22 }
23
24 namespace strings {
25 inline const QString url_html = QStringLiteral("<a href=\"\\1\">\\1</a>");
26 inline const QRegularExpression url_regex(
27 // match an unquoted URL
28 []() {
29 const auto general_unicode = QStringLiteral(
30 R"((?:[^\x{0}-\x{7f}\p{Cc}\s\p{P}]|[\x{2010}\x{2011}\x{2012}\x{2013}\x{2014}\x{2015}]))");
31 const auto protocol = QStringLiteral(R"((?:[Hh][Tt][Tt][Pp][Ss]?))");
32 const auto unreserved_subdelims_colon = QStringLiteral(R"([a-zA-Z0-9\-._~!$&'()*+,;=:])");
33 const auto pct_enc = QStringLiteral(R"((?:%[[:xdigit:]]{2}))");
34 const auto userinfo =
35 "(?:" + unreserved_subdelims_colon + "*(?:" + pct_enc + unreserved_subdelims_colon + "*)*)";
36 const auto dec_octet =
37 QStringLiteral(R"((?:25[0-5]|2[0-4][0-9]|1[0-9][0-9]|[1-9][0-9]|[0-9]))");
38 const auto ipv4_addr = "(?:" + dec_octet + R"((?:\.)" + dec_octet + "){3})";
39 const auto h16 = QStringLiteral(R"((?:[[:xdigit:]]{1,4}))");
40 const auto ls32 = "(?:" + h16 + ":" + h16 + "|" + ipv4_addr + ")";
41 // clang-format off
42 const auto ipv6_addr = "(?:"
43 "(?:" + h16 + ":){6}" + ls32
44 + "|" "::(?:" + h16 + ":){5}" + ls32
45 + "|" + h16 + "?::(?:" + h16 + ":){4}" + ls32
46 + "|" "(?:" + h16 + "(?::" + h16 + "){0,1})?::(?:" + h16 + ":){3}" + ls32
47 + "|" "(?:" + h16 + "(?::" + h16 + "){0,2})?::(?:" + h16 + ":){2}" + ls32
48 + "|" "(?:" + h16 + "(?::" + h16 + "){0,3})?::" + h16 + ":" + ls32
49 + "|" "(?:" + h16 + "(?::" + h16 + "){0,4})?::" + ls32
50 + "|" "(?:" + h16 + "(?::" + h16 + "){0,5})?::" + h16
51 + "|" "(?:" + h16 + "(?::" + h16 + "){0,6})?::"
52 ")";
53 // clang-format on
54 const auto ipvfuture = R"((?:v[[:xdigit:]]+\.)" + unreserved_subdelims_colon + "+)";
55 const auto ip_literal = R"((?:\[(?:)" + ipv6_addr + "|" + ipvfuture + R"()\]))";
56 const auto host_alnum = "(?:[a-zA-Z0-9]|" + general_unicode + ")";
57 const auto host_label = "(?:" + host_alnum + "+(?:-+" + host_alnum + "+)*)";
58 const auto hostname = "(?:" + host_label + R"((?:\.)" + host_label + R"()*\.?))";
59 const auto host = "(?:" + hostname + "|" + ip_literal + ")";
60 const auto path = R"((?:/((?:[a-zA-Z0-9\-._~!$&'*+,;=:@/]|)" + pct_enc + R"(|\((?-1)\)|)" +
61 general_unicode + ")*))";
62 const auto query = R"(((?:[a-zA-Z0-9\-._~!$&'*+,;=:@/?\\{}]|)" + pct_enc +
63 R"(|\((?-1)\)|\[(?-1)\]|)" + general_unicode + ")*)";
64 // explicitly allow # in fragments because of matrix.to urls generated by some clients...
65 const auto fragment = R"(((?:[a-zA-Z0-9\-._~!$&'*+,;=:@/?\\{}#]|)" + pct_enc +
66 R"(|\((?-1)\)|\[(?-1)\]|)" + general_unicode + ")*)";
67 return R"((?<!["'\w])(?>()" + protocol + "://" + "(?:" + userinfo + "@)?" + host +
68 "(?::[0-9]+)?" + path +
69 "?"
70 R"((?:\?)" +
71 query +
72 ")?"
73 R"((?:#)" +
74 fragment +
75 ")?"
76 "(?<![.!?,;:'])"
77 R"())(?!["']))";
78 }(),
79 QRegularExpression::UseUnicodePropertiesOption);
80 // A matrix link to be converted back to markdown
81 inline const QRegularExpression
82 matrixToLink(QStringLiteral(R"(<a href=\"(https://matrix.to/#/.*?)\">(.*?)</a>)"));
83 }
84
85 // Window geometry.
86 namespace window {
87 inline constexpr int height = 600;
88 inline constexpr int width = 1066;
89
90 inline constexpr int minHeight = 340;
91 inline constexpr int minWidth = 340;
92 } // namespace window
93
94 } // namespace conf