Skip to content

Commit

Permalink
Merge 7adf966 into ed0e5b9
Browse files Browse the repository at this point in the history
  • Loading branch information
leha-bot authored Apr 18, 2018
2 parents ed0e5b9 + 7adf966 commit 7674997
Show file tree
Hide file tree
Showing 7 changed files with 27 additions and 3 deletions.
2 changes: 2 additions & 0 deletions Telegram/Resources/langs/lang.strings
Original file line number Diff line number Diff line change
Expand Up @@ -313,6 +313,8 @@ Copyright (c) 2014-2017 John Preston, https://desktop.telegram.org

"lng_settings_section_chat_settings" = "Chat Settings";
"lng_settings_replace_emojis" = "Replace emoji";
"lng_settings_message_formatting" = "Replace double chars (<<, >>, --)";
"lng_settings_suggest_by_emoji" = "Suggest popular stickers by emoji";
"lng_settings_view_emojis" = "View list";
"lng_settings_send_enter" = "Send by Enter";
"lng_settings_send_ctrlenter" = "Send by Ctrl+Enter";
Expand Down
1 change: 1 addition & 0 deletions Telegram/SourceFiles/settings.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -58,6 +58,7 @@ qint32 gLastUpdateCheck = 0;
bool gNoStartUpdate = false;
bool gStartToSettings = false;
bool gReplaceEmojis = true;
bool gMessageFormatting = true;

bool gCtrlEnter = false;

Expand Down
1 change: 1 addition & 0 deletions Telegram/SourceFiles/settings.h
Original file line number Diff line number Diff line change
Expand Up @@ -121,6 +121,7 @@ DeclareSetting(qint32, LastUpdateCheck);
DeclareSetting(bool, NoStartUpdate);
DeclareSetting(bool, StartToSettings);
DeclareSetting(bool, ReplaceEmojis);
DeclareSetting(bool, MessageFormatting);
DeclareReadSetting(bool, ManyInstance);

DeclareSetting(QByteArray, LocalSalt);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -154,6 +154,7 @@ void ChatSettingsWidget::createControls() {
style::margins slidedPadding(0, marginSub.bottom() / 2, 0, marginSub.bottom() - (marginSub.bottom() / 2));

addChildRow(_replaceEmoji, marginSkip, lang(lng_settings_replace_emojis), [this](bool) { onReplaceEmoji(); }, cReplaceEmojis());
addChildRow(_messageFormat, marginSmall, lang(lng_settings_message_formatting), [this](bool) { toggleMessageFormat(); }, cMessageFormatting());

#ifndef OS_WIN_STORE
auto pathMargin = marginSub;
Expand Down Expand Up @@ -186,6 +187,11 @@ void ChatSettingsWidget::onReplaceEmoji() {
Local::writeUserSettings();
}

void ChatSettingsWidget::toggleMessageFormat() {
cSetMessageFormatting(_messageFormat->checked());
Local::writeUserSettings();
}

void ChatSettingsWidget::onDontAskDownloadPath() {
Global::SetAskDownloadPath(!_dontAskDownloadPath->checked());
Local::writeUserSettings();
Expand Down
2 changes: 2 additions & 0 deletions Telegram/SourceFiles/settings/settings_chat_settings_widget.h
Original file line number Diff line number Diff line change
Expand Up @@ -107,7 +107,9 @@ private slots:
void createControls();

object_ptr<Ui::Checkbox> _replaceEmoji = { nullptr };
object_ptr<Ui::Checkbox> _messageFormat = { nullptr };
object_ptr<Ui::Checkbox> _dontAskDownloadPath = { nullptr };
void toggleMessageFormat();

#ifndef OS_WIN_STORE
object_ptr<Ui::WidgetSlideWrap<DownloadPathState>> _downloadPath = { nullptr };
Expand Down
10 changes: 10 additions & 0 deletions Telegram/SourceFiles/storage/localstorage.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -551,6 +551,7 @@ enum {
dbiDcOptionOld = 0x27,
dbiTryIPv6 = 0x28,
dbiSongVolume = 0x29,
dbiMessageFormatting = 0x2a,
dbiWindowsNotificationsOld = 0x30,
dbiIncludeMuted = 0x31,
dbiMegagroupSizeMax = 0x32,
Expand Down Expand Up @@ -1360,6 +1361,14 @@ bool _readSetting(quint32 blockId, QDataStream &stream, int version, ReadSetting
cSetReplaceEmojis(v == 1);
} break;

case dbiMessageFormatting: {
qint32 v;
stream >> v;
if (!_checkStreamStatus(stream)) return false;

cSetMessageFormatting(v == 1);
} break;

case dbiDefaultAttach: {
qint32 v;
stream >> v;
Expand Down Expand Up @@ -1800,6 +1809,7 @@ void _writeUserSettings() {
data.stream << quint32(dbiAdaptiveForWide) << qint32(Global::AdaptiveForWide() ? 1 : 0);
data.stream << quint32(dbiAutoLock) << qint32(Global::AutoLock());
data.stream << quint32(dbiReplaceEmojis) << qint32(cReplaceEmojis() ? 1 : 0);
data.stream << quint32(dbiMessageFormatting) << qint32(cMessageFormatting() ? 1 : 0);
data.stream << quint32(dbiSoundNotify) << qint32(Global::SoundNotify());
data.stream << quint32(dbiIncludeMuted) << qint32(Global::IncludeMuted());
data.stream << quint32(dbiDesktopNotify) << qint32(Global::DesktopNotify());
Expand Down
8 changes: 5 additions & 3 deletions Telegram/SourceFiles/ui/text/text_entity.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -2120,9 +2120,11 @@ void PrepareForSending(TextWithEntities &result, qint32 flags) {
ParseEntities(result, flags);
}

ReplaceStringWithChar(qstr("--"), QChar(8212), result, true);
ReplaceStringWithChar(qstr("<<"), QChar(171), result);
ReplaceStringWithChar(qstr(">>"), QChar(187), result);
if (cMessageFormatting()) {
ReplaceStringWithChar(qstr("--"), QChar(8212), result, true);
ReplaceStringWithChar(qstr("<<"), QChar(171), result);
ReplaceStringWithChar(qstr(">>"), QChar(187), result);
}

if (cReplaceEmojis()) {
Ui::Emoji::ReplaceInText(result);
Expand Down

0 comments on commit 7674997

Please sign in to comment.