diff --git a/Telegram/SourceFiles/application.cpp b/Telegram/SourceFiles/application.cpp index be5f8cc575..4054c98b64 100644 --- a/Telegram/SourceFiles/application.cpp +++ b/Telegram/SourceFiles/application.cpp @@ -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(); diff --git a/Telegram/SourceFiles/historywidget.cpp b/Telegram/SourceFiles/historywidget.cpp index bcc7f40e30..dc169aa8a6 100644 --- a/Telegram/SourceFiles/historywidget.cpp +++ b/Telegram/SourceFiles/historywidget.cpp @@ -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(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; diff --git a/Telegram/SourceFiles/historywidget.h b/Telegram/SourceFiles/historywidget.h index c0215fe9d1..951fea0a7d 100644 --- a/Telegram/SourceFiles/historywidget.h +++ b/Telegram/SourceFiles/historywidget.h @@ -382,7 +382,6 @@ public slots: void activate(); void onTextChange(); - void onFieldTabbed(); void onStickerSend(DocumentData *sticker); void onVisibleChanged(); diff --git a/Telegram/SourceFiles/supporttl.cpp b/Telegram/SourceFiles/supporttl.cpp deleted file mode 100644 index bea949fd80..0000000000 --- a/Telegram/SourceFiles/supporttl.cpp +++ /dev/null @@ -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 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 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; -} diff --git a/Telegram/SourceFiles/supporttl.h b/Telegram/SourceFiles/supporttl.h deleted file mode 100644 index 974a825951..0000000000 --- a/Telegram/SourceFiles/supporttl.h +++ /dev/null @@ -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); diff --git a/Telegram/Telegram.pro b/Telegram/Telegram.pro index e63f924556..43dd72f219 100644 --- a/Telegram/Telegram.pro +++ b/Telegram/Telegram.pro @@ -99,7 +99,6 @@ SOURCES += \ ./SourceFiles/mainwidget.cpp \ ./SourceFiles/settings.cpp \ ./SourceFiles/settingswidget.cpp \ - ./SourceFiles/supporttl.cpp \ ./SourceFiles/sysbuttons.cpp \ ./SourceFiles/title.cpp \ ./SourceFiles/types.cpp \ @@ -179,7 +178,6 @@ HEADERS += \ ./SourceFiles/settings.h \ ./SourceFiles/settingswidget.h \ ./SourceFiles/style.h \ - ./SourceFiles/supporttl.h \ ./SourceFiles/sysbuttons.h \ ./SourceFiles/title.h \ ./SourceFiles/types.h \ diff --git a/Telegram/Telegram.vcxproj b/Telegram/Telegram.vcxproj index b9b00a9a08..e58af33576 100644 --- a/Telegram/Telegram.vcxproj +++ b/Telegram/Telegram.vcxproj @@ -914,7 +914,6 @@ Create Create - @@ -1749,7 +1748,6 @@ - Moc%27ing sysbuttons.h... .\GeneratedFiles\$(ConfigurationName)\moc_%(Filename).cpp @@ -1819,4 +1817,4 @@ - \ No newline at end of file + diff --git a/Telegram/Telegram.vcxproj.filters b/Telegram/Telegram.vcxproj.filters index 2a3ce62281..9960516b14 100644 --- a/Telegram/Telegram.vcxproj.filters +++ b/Telegram/Telegram.vcxproj.filters @@ -150,9 +150,6 @@ gui - - Source Files - gui @@ -839,9 +836,6 @@ gui - - Source Files - gui @@ -1079,4 +1073,4 @@ langs - \ No newline at end of file + diff --git a/Telegram/Telegram.xcodeproj/project.pbxproj b/Telegram/Telegram.xcodeproj/project.pbxproj index 443f232df3..769c4f64e8 100644 --- a/Telegram/Telegram.xcodeproj/project.pbxproj +++ b/Telegram/Telegram.xcodeproj/project.pbxproj @@ -127,7 +127,6 @@ 830CB6F547B8C80A569A0271 /* addparticipantbox.cpp in Compile Sources */ = {isa = PBXBuildFile; fileRef = 40E88FBA282991C8CBDFE94D /* addparticipantbox.cpp */; settings = {ATTRIBUTES = (); }; }; 832C50BFD7D09AF042A51D4F /* flatbutton.cpp in Compile Sources */ = {isa = PBXBuildFile; fileRef = F1A04BDB750C2AE652797B04 /* flatbutton.cpp */; settings = {ATTRIBUTES = (); }; }; 8771A8C96E9C391044035D99 /* OpenGL.framework in Link Binary With Libraries */ = {isa = PBXBuildFile; fileRef = D4B32C2222F82AC56BADEB21 /* OpenGL.framework */; }; - 878DCAF0C5B0DB2EB4EDFD3D /* supporttl.cpp in Compile Sources */ = {isa = PBXBuildFile; fileRef = 0B2F770F53FBB0DBF738D89B /* supporttl.cpp */; settings = {ATTRIBUTES = (); }; }; 8883FF366F2623E89D90A9E6 /* qgenericbearer in Link Binary With Libraries */ = {isa = PBXBuildFile; fileRef = 9A55B8F7C143D66AD9EAE304 /* qgenericbearer */; }; 89ADB41E48A3B5E24ABB626C /* profilewidget.cpp in Compile Sources */ = {isa = PBXBuildFile; fileRef = CF32DF59C7823E4F3397EF3C /* profilewidget.cpp */; settings = {ATTRIBUTES = (); }; }; 8B22E794EFF0EAFF964A3043 /* introsteps.cpp in Compile Sources */ = {isa = PBXBuildFile; fileRef = C34459FA465B57DF4DB80D12 /* introsteps.cpp */; settings = {ATTRIBUTES = (); }; }; @@ -311,7 +310,6 @@ 098EA7CE256AAFAE4A17EB77 /* introcode.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; name = introcode.h; path = SourceFiles/intro/introcode.h; sourceTree = ""; }; 09FD01F2BD652EB838A296D8 /* application.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; name = application.h; path = SourceFiles/application.h; sourceTree = ""; }; 0ABCEA8D0DD45589040B0AF2 /* /usr/local/Qt-5.4.0/mkspecs/common/unix.conf */ = {isa = PBXFileReference; lastKnownFileType = text; path = "/usr/local/Qt-5.4.0/mkspecs/common/unix.conf"; sourceTree = ""; }; - 0B2F770F53FBB0DBF738D89B /* supporttl.cpp */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.cpp.cpp; name = supporttl.cpp; path = SourceFiles/supporttl.cpp; sourceTree = ""; }; 0BDE09020E45EFA57DCB2E25 /* photosendbox.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; name = photosendbox.h; path = SourceFiles/boxes/photosendbox.h; sourceTree = ""; }; 0C0DC15EB416789673526AA5 /* moc_emojibox.cpp */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.cpp.cpp; name = moc_emojibox.cpp; path = GeneratedFiles/Debug/moc_emojibox.cpp; sourceTree = ""; }; 0CAA815FFFEDCD84808E11F5 /* logs.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; name = logs.h; path = SourceFiles/logs.h; sourceTree = ""; }; @@ -387,7 +385,6 @@ 3F08D430CEC8D2117735CCB4 /* /usr/local/Qt-5.4.0/mkspecs/modules/qt_plugin_qmldbg_tcp_qtdeclarative.pri */ = {isa = PBXFileReference; lastKnownFileType = text; path = "/usr/local/Qt-5.4.0/mkspecs/modules/qt_plugin_qmldbg_tcp_qtdeclarative.pri"; sourceTree = ""; }; 40E88FBA282991C8CBDFE94D /* addparticipantbox.cpp */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.cpp.cpp; name = addparticipantbox.cpp; path = SourceFiles/boxes/addparticipantbox.cpp; sourceTree = ""; }; 420A06A32B66D250142B4B6D /* style_core.cpp */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.cpp.cpp; name = style_core.cpp; path = SourceFiles/gui/style_core.cpp; sourceTree = ""; }; - 42FA90460B1A91C414157EAC /* supporttl.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; name = supporttl.h; path = SourceFiles/supporttl.h; sourceTree = ""; }; 45B95DB3B70B47A910FC847B /* /usr/local/Qt-5.4.0/mkspecs/common/gcc-base.conf */ = {isa = PBXFileReference; lastKnownFileType = text; path = "/usr/local/Qt-5.4.0/mkspecs/common/gcc-base.conf"; sourceTree = ""; }; 45DB132B756499D4DF38430E /* /usr/local/Qt-5.4.0/mkspecs/modules/qt_plugin_qjp2.pri */ = {isa = PBXFileReference; lastKnownFileType = text; path = "/usr/local/Qt-5.4.0/mkspecs/modules/qt_plugin_qjp2.pri"; sourceTree = ""; }; 4604687EBA85611C9E8A9CDF /* button.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; name = button.h; path = SourceFiles/gui/button.h; sourceTree = ""; }; @@ -891,7 +888,6 @@ 047DAFB0A7DE92C63033A43C /* mainwidget.cpp */, 8A28F7789408AA839F48A5F2 /* settings.cpp */, 8CCCACE96535180FEB557712 /* settingswidget.cpp */, - 0B2F770F53FBB0DBF738D89B /* supporttl.cpp */, 6B90F69947805586A6FAE80E /* sysbuttons.cpp */, 2BB2A1BB8DB0993F78F4E3C7 /* title.cpp */, 7D075A915E8739C1B6BC5F43 /* types.cpp */, @@ -927,7 +923,6 @@ 2EA58EF6CDF368B0132BAEB9 /* settings.h */, F80095A026AF9453E9C2B8BD /* settingswidget.h */, C913E6A1001E07EE7C13CE93 /* style.h */, - 42FA90460B1A91C414157EAC /* supporttl.h */, 3BE70E2A82DC2BF402165ED5 /* sysbuttons.h */, 4D504A849F15EB58E53A4E5F /* title.h */, 1DC02F674A7192FF8BE391A7 /* types.h */, @@ -1476,7 +1471,6 @@ E3194392BD6D0726F75FA72E /* mainwidget.cpp in Compile Sources */, DF36EA42D67ED39E58CB7DF9 /* settings.cpp in Compile Sources */, B99CCE43EEFCD3E18F6D16D1 /* settingswidget.cpp in Compile Sources */, - 878DCAF0C5B0DB2EB4EDFD3D /* supporttl.cpp in Compile Sources */, B8DA82DA1B195A933A0805E7 /* sysbuttons.cpp in Compile Sources */, 5CE57D44510AB2A11886AB52 /* title.cpp in Compile Sources */, 4078D5D614EB3ECF7F1848C7 /* types.cpp in Compile Sources */,