2021-03-05 02:35:15 +03:00
|
|
|
// SPDX-FileCopyrightText: 2021 Nheko Contributors
|
2022-01-01 06:57:53 +03:00
|
|
|
// SPDX-FileCopyrightText: 2022 Nheko Contributors
|
2023-01-02 06:25:33 +03:00
|
|
|
// SPDX-FileCopyrightText: 2023 Nheko Contributors
|
2021-03-05 02:35:15 +03:00
|
|
|
//
|
|
|
|
// SPDX-License-Identifier: GPL-3.0-or-later
|
|
|
|
|
2017-07-15 17:11:46 +03:00
|
|
|
#pragma once
|
|
|
|
|
2019-05-01 13:11:19 +03:00
|
|
|
#include <QRegularExpression>
|
2017-12-24 14:13:07 +03:00
|
|
|
#include <QString>
|
|
|
|
|
2021-12-29 00:30:12 +03:00
|
|
|
// clazy:excludeall=non-pod-global-static
|
|
|
|
|
2017-07-15 17:11:46 +03:00
|
|
|
// Non-theme app configuration. Layouts, fonts spacing etc.
|
|
|
|
//
|
|
|
|
// Font sizes are in pixels.
|
2017-10-15 22:08:51 +03:00
|
|
|
namespace conf {
|
2018-05-16 20:40:42 +03:00
|
|
|
|
|
|
|
namespace modals {
|
2022-03-30 07:53:55 +03:00
|
|
|
constexpr int WIDGET_MARGIN = 20;
|
|
|
|
constexpr int WIDGET_SPACING = 15;
|
2018-07-22 18:03:12 +03:00
|
|
|
|
2018-09-25 14:41:47 +03:00
|
|
|
constexpr auto LABEL_MEDIUM_SIZE_RATIO = 1.3;
|
2018-07-22 18:03:12 +03:00
|
|
|
}
|
|
|
|
|
2017-12-24 14:13:07 +03:00
|
|
|
namespace strings {
|
2021-12-29 00:30:12 +03:00
|
|
|
const QString url_html = QStringLiteral("<a href=\"\\1\">\\1</a>");
|
2023-02-02 03:21:23 +03:00
|
|
|
const QRegularExpression
|
|
|
|
url_regex(
|
2023-02-01 23:14:14 +03:00
|
|
|
// match an unquoted URL
|
2023-02-02 03:21:23 +03:00
|
|
|
[]() {
|
|
|
|
const auto general_unicode = QStringLiteral(
|
|
|
|
R"((?:[^\x{0}-\x{7f}\p{Cc}\s\p{P}]|[\x{2010}\x{2011}\x{2012}\x{2013}\x{2014}\x{2015}]))");
|
|
|
|
const auto protocol = QStringLiteral(R"((?:[Hh][Tt][Tt][Pp][Ss]?))");
|
|
|
|
const auto unreserved_subdelims_colon = QStringLiteral(R"([a-zA-Z0-9\-._~!$&'()*+,;=:])");
|
|
|
|
const auto pct_enc = QStringLiteral(R"((?:%[[:xdigit:]]{2}))");
|
|
|
|
const auto userinfo = "(?:" + unreserved_subdelims_colon + "*(?:" + pct_enc +
|
|
|
|
unreserved_subdelims_colon + "*)*)";
|
|
|
|
const auto dec_octet =
|
|
|
|
QStringLiteral(R"((?:25[0-5]|2[0-4][0-9]|1[0-9][0-9]|[1-9][0-9]|[0-9]))");
|
|
|
|
const auto ipv4_addr = "(?:" + dec_octet + R"((?:\.)" + dec_octet + "){3})";
|
|
|
|
const auto h16 = QStringLiteral(R"((?:[[:xdigit:]]{1,4}))");
|
|
|
|
const auto ls32 = "(?:" + h16 + ":" + h16 + "|" + ipv4_addr + ")";
|
|
|
|
// clang-format off
|
|
|
|
const auto ipv6_addr = "(?:"
|
|
|
|
"(?:" + h16 + ":){6}" + ls32
|
|
|
|
+ "|" "::(?:" + h16 + ":){5}" + ls32
|
|
|
|
+ "|" + h16 + "?::(?:" + h16 + ":){4}" + ls32
|
|
|
|
+ "|" "(?:" + h16 + "(?::" + h16 + "){0,1})?::(?:" + h16 + ":){3}" + ls32
|
|
|
|
+ "|" "(?:" + h16 + "(?::" + h16 + "){0,2})?::(?:" + h16 + ":){2}" + ls32
|
|
|
|
+ "|" "(?:" + h16 + "(?::" + h16 + "){0,3})?::" + h16 + ":" + ls32
|
|
|
|
+ "|" "(?:" + h16 + "(?::" + h16 + "){0,4})?::" + ls32
|
|
|
|
+ "|" "(?:" + h16 + "(?::" + h16 + "){0,5})?::" + h16
|
|
|
|
+ "|" "(?:" + h16 + "(?::" + h16 + "){0,6})?::"
|
|
|
|
")";
|
|
|
|
// clang-format on
|
|
|
|
const auto ipvfuture = R"((?:v[[:xdigit:]]+\.)" + unreserved_subdelims_colon + "+)";
|
|
|
|
const auto ip_literal = R"((?:\[(?:)" + ipv6_addr + "|" + ipvfuture + R"()\]))";
|
|
|
|
const auto host_alnum = "(?:[a-zA-Z0-9]|" + general_unicode + ")";
|
|
|
|
const auto host_label = "(?:" + host_alnum + "+(?:-+" + host_alnum + "+)*)";
|
|
|
|
const auto hostname = "(?:" + host_label + R"((?:\.)" + host_label + R"()*\.?))";
|
|
|
|
const auto host = "(?:" + hostname + "|" + ip_literal + ")";
|
|
|
|
const auto path = R"((?:/((?:[a-zA-Z0-9\-._~!$&'*+,;=:@/]|)" + pct_enc + R"(|\((?-1)\)|)" +
|
|
|
|
general_unicode + ")*))";
|
|
|
|
const auto query = R"(((?:[a-zA-Z0-9\-._~!$&'*+,;=:@/?\\{}]|)" + pct_enc +
|
|
|
|
R"(|\((?-1)\)|\[(?-1)\]|)" + general_unicode + ")*)";
|
|
|
|
const auto &fragment = query;
|
2023-02-01 23:14:14 +03:00
|
|
|
return
|
|
|
|
R"((?<!["'\w])(?>()"
|
|
|
|
+ protocol + "://"
|
|
|
|
+ "(?:" + userinfo + "@)?"
|
|
|
|
+ host + "(?::[0-9]+)?"
|
|
|
|
+ path + "?"
|
|
|
|
R"((?:\?)" + query + ")?"
|
|
|
|
R"((?:#)" + fragment + ")?"
|
|
|
|
"(?<![.!?,;:'])"
|
|
|
|
R"())(?!["']))";
|
|
|
|
}(),
|
2023-02-02 03:21:23 +03:00
|
|
|
QRegularExpression::UseUnicodePropertiesOption);
|
2022-07-20 14:52:13 +03:00
|
|
|
// A matrix link to be converted back to markdown
|
2021-12-29 02:36:43 +03:00
|
|
|
static const QRegularExpression
|
|
|
|
matrixToLink(QStringLiteral(R"(<a href=\"(https://matrix.to/#/.*?)\">(.*?)</a>)"));
|
2017-12-24 14:13:07 +03:00
|
|
|
}
|
|
|
|
|
2017-07-30 13:59:28 +03:00
|
|
|
// Window geometry.
|
2017-10-15 22:08:51 +03:00
|
|
|
namespace window {
|
2022-03-30 07:53:55 +03:00
|
|
|
constexpr int height = 600;
|
|
|
|
constexpr int width = 1066;
|
2017-07-30 13:59:28 +03:00
|
|
|
|
2022-02-15 00:56:35 +03:00
|
|
|
constexpr int minHeight = 340;
|
|
|
|
constexpr int minWidth = 340;
|
2017-10-15 22:08:51 +03:00
|
|
|
} // namespace window
|
|
|
|
|
2017-08-20 13:47:22 +03:00
|
|
|
} // namespace conf
|