2
0
mirror of https://github.com/kotatogram/kotatogram-desktop synced 2025-08-31 22:55:11 +00:00

Highlight timestamps in video captions.

This commit is contained in:
John Preston
2019-12-25 18:20:02 +03:00
parent e9620af6fb
commit 3e3e1d628c
10 changed files with 210 additions and 18 deletions

View File

@@ -583,27 +583,36 @@ void Application::checkStartUrl() {
}
bool Application::openLocalUrl(const QString &url, QVariant context) {
auto urlTrimmed = url.trimmed();
if (urlTrimmed.size() > 8192) urlTrimmed = urlTrimmed.mid(0, 8192);
return openCustomUrl("tg://", LocalUrlHandlers(), url, context);
}
const auto protocol = qstr("tg://");
bool Application::openInternalUrl(const QString &url, QVariant context) {
return openCustomUrl("internal:", InternalUrlHandlers(), url, context);
}
bool Application::openCustomUrl(
const QString &protocol,
const std::vector<LocalUrlHandler> &handlers,
const QString &url,
const QVariant &context) {
const auto urlTrimmed = url.trimmed();
if (!urlTrimmed.startsWith(protocol, Qt::CaseInsensitive) || locked()) {
return false;
}
auto command = urlTrimmed.midRef(protocol.size());
const auto command = urlTrimmed.midRef(protocol.size(), 8192);
const auto session = activeAccount().sessionExists()
? &activeAccount().session()
: nullptr;
using namespace qthelp;
const auto options = RegExOption::CaseInsensitive;
for (const auto &[expression, handler] : LocalUrlHandlers()) {
for (const auto &[expression, handler] : handlers) {
const auto match = regex_match(expression, command, options);
if (match) {
return handler(session, match, context);
}
}
return false;
}
void Application::lockByPasscode() {