mirror of
https://github.com/kotatogram/kotatogram-desktop
synced 2025-08-31 06:35:14 +00:00
removed support templates from tdesktop
This commit is contained in:
@@ -22,7 +22,6 @@ Copyright (c) 2014 John Preston, https://desktop.telegram.org
|
||||
#include "pspecific.h"
|
||||
#include "fileuploader.h"
|
||||
#include "mainwidget.h"
|
||||
#include "supporttl.h"
|
||||
|
||||
#include "lang.h"
|
||||
#include "boxes/confirmbox.h"
|
||||
@@ -674,7 +673,6 @@ void Application::startApp() {
|
||||
window->init();
|
||||
|
||||
DEBUG_LOG(("Application Info: window created.."));
|
||||
readSupportTemplates();
|
||||
|
||||
MTP::start();
|
||||
|
||||
|
@@ -26,7 +26,6 @@ Copyright (c) 2014 John Preston, https://desktop.telegram.org
|
||||
#include "mainwidget.h"
|
||||
#include "window.h"
|
||||
#include "fileuploader.h"
|
||||
#include "supporttl.h"
|
||||
|
||||
#include "localstorage.h"
|
||||
|
||||
@@ -1585,7 +1584,6 @@ HistoryWidget::HistoryWidget(QWidget *parent) : QWidget(parent)
|
||||
connect(&_attachPhoto, SIGNAL(clicked()), this, SLOT(onPhotoSelect()));
|
||||
connect(&_field, SIGNAL(submitted(bool)), this, SLOT(onSend(bool)));
|
||||
connect(&_field, SIGNAL(cancelled()), this, SLOT(onCancel()));
|
||||
connect(&_field, SIGNAL(tabbed()), this, SLOT(onFieldTabbed()));
|
||||
connect(&_field, SIGNAL(resized()), this, SLOT(onFieldResize()));
|
||||
connect(&_field, SIGNAL(focused()), this, SLOT(onFieldFocused()));
|
||||
connect(&imageLoader, SIGNAL(imageReady()), this, SLOT(onPhotoReady()));
|
||||
@@ -3429,49 +3427,6 @@ void HistoryWidget::keyPressEvent(QKeyEvent *e) {
|
||||
}
|
||||
}
|
||||
|
||||
void HistoryWidget::onFieldTabbed() {
|
||||
QString v = _field.getText(), t = supportTemplate(v);
|
||||
if (!t.isEmpty()) {
|
||||
bool isImg = t.startsWith(qsl("img:")), isFile = t.startsWith(qsl("file:")), isContact = t.startsWith(qsl("contact:"));
|
||||
if (isImg || isFile) {
|
||||
QString fname = t.mid(isImg ? 4 : 5).trimmed(), text;
|
||||
int32 lineEnd = fname.indexOf(QChar('\n'));
|
||||
if (lineEnd > 0) {
|
||||
text = fname.mid(lineEnd + 1).trimmed();
|
||||
fname = fname.mid(0, lineEnd).trimmed();
|
||||
}
|
||||
if (isImg) {
|
||||
QImage img(cWorkingDir() + fname);
|
||||
if (!img.isNull()) {
|
||||
setFieldText(text);
|
||||
uploadImage(img, !text.isEmpty());
|
||||
}
|
||||
} else {
|
||||
setFieldText(text);
|
||||
uploadFile(cWorkingDir() + fname, !text.isEmpty());
|
||||
}
|
||||
} else if (isContact) {
|
||||
QString contact = t.mid(8).trimmed(), text;
|
||||
int32 lineEnd = contact.indexOf(QChar('\n'));
|
||||
if (lineEnd > 0) {
|
||||
text = contact.mid(lineEnd + 1).trimmed();
|
||||
contact = contact.mid(0, lineEnd).trimmed();
|
||||
}
|
||||
QStringList data = contact.split(QChar(' '));
|
||||
if (data.size() > 1) {
|
||||
setFieldText(text);
|
||||
QString phone = data.at(0).trimmed(), fname = data.at(1).trimmed(), lname = (data.size() > 2) ? static_cast<QStringList>(data.mid(2)).join(QChar(' ')).trimmed() : QString();
|
||||
shareContactConfirmation(phone, fname, lname, !text.isEmpty());
|
||||
}
|
||||
} else {
|
||||
setFieldText(t);
|
||||
QTextCursor c = _field.textCursor();
|
||||
c.movePosition(QTextCursor::End);
|
||||
_field.setTextCursor(c);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void HistoryWidget::onStickerSend(DocumentData *sticker) {
|
||||
if (!hist || !sticker) return;
|
||||
|
||||
|
@@ -1,115 +0,0 @@
|
||||
/*
|
||||
This file is part of Telegram Desktop,
|
||||
the official desktop version of Telegram messaging app, see https://telegram.org
|
||||
|
||||
Telegram Desktop 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 3 of the License, or
|
||||
(at your option) any later version.
|
||||
|
||||
It 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.
|
||||
|
||||
Full license: https://github.com/telegramdesktop/tdesktop/blob/master/LICENSE
|
||||
Copyright (c) 2014 John Preston, https://desktop.telegram.org
|
||||
*/
|
||||
#include "stdafx.h"
|
||||
#include "supporttl.h"
|
||||
|
||||
namespace {
|
||||
typedef QMap<QString, QString> SupportTemplates;
|
||||
SupportTemplates _supportTemplates;
|
||||
|
||||
void saveTemplate(QStringList &keys, QString &value) {
|
||||
if (!keys.isEmpty() && !value.isEmpty()) {
|
||||
if (value.at(value.size() - 1) == '\n') {
|
||||
value = value.mid(0, value.size() - 1);
|
||||
}
|
||||
for (QStringList::const_iterator i = keys.cbegin(), e = keys.cend(); i != e; ++i) {
|
||||
_supportTemplates[textSearchKey(*i)] = value;
|
||||
}
|
||||
}
|
||||
value = QString();
|
||||
}
|
||||
}
|
||||
|
||||
void readSupportTemplates() {
|
||||
QStringList files(cWorkingDir() + qsl("support_tl.txt"));
|
||||
QDir supp(cWorkingDir() + qsl("tsupport"));
|
||||
if (supp.exists()) {
|
||||
QStringList all = supp.entryList(QDir::Files);
|
||||
for (QStringList::const_iterator i = all.cbegin(), e = all.cend(); i != e; ++i) {
|
||||
if (i->startsWith(qsl("tl_"))) {
|
||||
files.push_back(cWorkingDir() + qsl("tsupport/") + *i);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
typedef QList<QByteArray> TemplatesLines;
|
||||
enum ReadingState {
|
||||
ReadingNone = 0,
|
||||
ReadingKeys = 1,
|
||||
ReadingValue = 2,
|
||||
ReadingMoreValue = 3,
|
||||
};
|
||||
|
||||
for (QStringList::const_iterator i = files.cbegin(), e = files.cend(); i != e; ++i) {
|
||||
QFile f(*i);
|
||||
if (!f.open(QIODevice::ReadOnly)) continue;
|
||||
|
||||
TemplatesLines lines = f.readAll().split('\n');
|
||||
|
||||
f.close();
|
||||
|
||||
ReadingState state = ReadingNone;
|
||||
QStringList keys;
|
||||
QString value;
|
||||
for (TemplatesLines::const_iterator i = lines.cbegin(), e = lines.cend(); i != e; ++i) {
|
||||
QString line = QString::fromUtf8(*i).trimmed();
|
||||
QRegularExpressionMatch m = QRegularExpression(qsl("^\\{([A-Z_]+)\\}$")).match(line);
|
||||
if (m.hasMatch()) {
|
||||
saveTemplate(keys, value);
|
||||
|
||||
QString token = m.captured(1);
|
||||
if (token == qsl("KEYS")) {
|
||||
keys.clear();
|
||||
state = ReadingKeys;
|
||||
} else if (token == qsl("VALUE")) {
|
||||
state = ReadingValue;
|
||||
} else {
|
||||
keys.clear();
|
||||
state = ReadingNone;
|
||||
}
|
||||
continue;
|
||||
}
|
||||
|
||||
switch (state) {
|
||||
case ReadingKeys:
|
||||
if (!line.isEmpty()) {
|
||||
keys.push_back(line);
|
||||
}
|
||||
break;
|
||||
|
||||
case ReadingMoreValue:
|
||||
value += '\n';
|
||||
case ReadingValue:
|
||||
value += line;
|
||||
state = ReadingMoreValue;
|
||||
break;
|
||||
}
|
||||
}
|
||||
saveTemplate(keys, value);
|
||||
}
|
||||
}
|
||||
|
||||
const QString &supportTemplate(const QString &key) {
|
||||
SupportTemplates::const_iterator i = _supportTemplates.constFind(textSearchKey(key));
|
||||
if (i != _supportTemplates.cend()) {
|
||||
return *i;
|
||||
}
|
||||
|
||||
static const QString _tmp;
|
||||
return _tmp;
|
||||
}
|
@@ -1,21 +0,0 @@
|
||||
/*
|
||||
This file is part of Telegram Desktop,
|
||||
the official desktop version of Telegram messaging app, see https://telegram.org
|
||||
|
||||
Telegram Desktop 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 3 of the License, or
|
||||
(at your option) any later version.
|
||||
|
||||
It 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.
|
||||
|
||||
Full license: https://github.com/telegramdesktop/tdesktop/blob/master/LICENSE
|
||||
Copyright (c) 2014 John Preston, https://desktop.telegram.org
|
||||
*/
|
||||
#pragma once
|
||||
|
||||
void readSupportTemplates();
|
||||
const QString &supportTemplate(const QString &key);
|
Reference in New Issue
Block a user