diff --git a/Telegram/Resources/icons/menu/quality_sd.svg b/Telegram/Resources/icons/menu/quality_sd.svg
deleted file mode 100644
index e1ef219e0d..0000000000
--- a/Telegram/Resources/icons/menu/quality_sd.svg
+++ /dev/null
@@ -1,6 +0,0 @@
-
-
diff --git a/Telegram/Resources/icons/menu/spoiler_off.png b/Telegram/Resources/icons/menu/spoiler_off.png
deleted file mode 100644
index c694fd15da..0000000000
Binary files a/Telegram/Resources/icons/menu/spoiler_off.png and /dev/null differ
diff --git a/Telegram/Resources/icons/menu/spoiler_off@2x.png b/Telegram/Resources/icons/menu/spoiler_off@2x.png
deleted file mode 100644
index 9400628b8d..0000000000
Binary files a/Telegram/Resources/icons/menu/spoiler_off@2x.png and /dev/null differ
diff --git a/Telegram/Resources/icons/menu/spoiler_off@3x.png b/Telegram/Resources/icons/menu/spoiler_off@3x.png
deleted file mode 100644
index ce6598ad85..0000000000
Binary files a/Telegram/Resources/icons/menu/spoiler_off@3x.png and /dev/null differ
diff --git a/Telegram/Resources/langs/lang.strings b/Telegram/Resources/langs/lang.strings
index ee7750d1d3..c959d4b667 100644
--- a/Telegram/Resources/langs/lang.strings
+++ b/Telegram/Resources/langs/lang.strings
@@ -5054,7 +5054,6 @@ https://github.com/telegramdesktop/tdesktop/blob/master/LEGAL
"lng_context_noforwards_info_mine" = "You disabled copying and forwarding in this chat.";
"lng_context_spoiler_effect" = "Hide with Spoiler";
-"lng_context_disable_spoiler" = "Remove Spoiler";
"lng_context_make_paid" = "Make This Content Paid";
"lng_context_change_price" = "Change Price";
"lng_context_edit_cover" = "Edit Cover";
@@ -5171,10 +5170,9 @@ https://github.com/telegramdesktop/tdesktop/blob/master/LEGAL
"lng_send_grouped" = "Group items";
"lng_send_compressed_one" = "Compress the image";
"lng_send_compressed" = "Compress images";
-"lng_send_high_quality" = "Send in High Quality";
+"lng_send_high_quality" = "High Quality";
"lng_send_as_documents_one" = "Send as a document";
"lng_send_as_documents" = "Send as documents";
-"lng_send_standard_quality" = "Standard Quality";
"lng_send_media_invalid_files" = "Sorry, no valid files found.";
"lng_send_image" = "Send an image";
"lng_send_file" = "Send as a file";
diff --git a/Telegram/SourceFiles/boxes/edit_caption_box.cpp b/Telegram/SourceFiles/boxes/edit_caption_box.cpp
index d929632061..92243777ac 100644
--- a/Telegram/SourceFiles/boxes/edit_caption_box.cpp
+++ b/Telegram/SourceFiles/boxes/edit_caption_box.cpp
@@ -36,6 +36,7 @@ https://github.com/telegramdesktop/tdesktop/blob/master/LEGAL
#include "history/history_item.h"
#include "history/history.h"
#include "lang/lang_keys.h"
+#include "menu/menu_checked_action.h"
#include "main/main_session.h"
#include "main/main_session_settings.h"
#include "mainwidget.h" // controller->content() -> QWidget*
@@ -760,36 +761,30 @@ void EditCaptionBox::setupEditEventHandler() {
if (!_asFile && (_isPhoto || _isVideo)) {
if (hasSendLargePhotosOption()) {
const auto enabled = _sendLargePhotos;
- (*menu)->addAction(
- (enabled
- ? tr::lng_send_standard_quality(tr::now)
- : tr::lng_send_high_quality(tr::now)),
+ Menu::AddCheckedAction(
+ menu->get(),
+ tr::lng_send_high_quality(tr::now),
[=] {
_sendLargePhotos = !enabled;
rebuildPreview();
},
- enabled
- ? &st::menuIconQualityStandard
- : &st::menuIconQualityHigh);
+ &st::menuIconQualityHigh,
+ enabled);
}
if (_preparedList.hasSpoilerMenu(!_asFile)) {
const auto spoilered = hasSpoiler();
- auto text = spoilered
- ? tr::lng_context_disable_spoiler(tr::now)
- : tr::lng_context_spoiler_effect(tr::now);
- auto callback = [=] {
- _mediaEditManager.apply({ .type = spoilered
- ? SendMenu::ActionType::SpoilerOff
- : SendMenu::ActionType::SpoilerOn
- });
- rebuildPreview();
- };
- (*menu)->addAction(
- std::move(text),
- std::move(callback),
- spoilered
- ? &st::menuIconSpoilerOff
- : &st::menuIconSpoiler);
+ Menu::AddCheckedAction(
+ menu->get(),
+ tr::lng_context_spoiler_effect(tr::now),
+ [=] {
+ _mediaEditManager.apply({ .type = spoilered
+ ? SendMenu::ActionType::SpoilerOff
+ : SendMenu::ActionType::SpoilerOn
+ });
+ rebuildPreview();
+ },
+ &st::menuIconSpoiler,
+ spoilered);
}
if (_isVideo && !_preparedList.files.empty()) {
(*menu)->addAction(tr::lng_context_edit_cover(tr::now), [=] {
diff --git a/Telegram/SourceFiles/boxes/send_files_box.cpp b/Telegram/SourceFiles/boxes/send_files_box.cpp
index 145212de9b..767509869e 100644
--- a/Telegram/SourceFiles/boxes/send_files_box.cpp
+++ b/Telegram/SourceFiles/boxes/send_files_box.cpp
@@ -18,6 +18,7 @@ https://github.com/telegramdesktop/tdesktop/blob/master/LEGAL
#include "main/main_session_settings.h"
#include "mtproto/mtproto_config.h"
#include "chat_helpers/message_field.h"
+#include "menu/menu_checked_action.h"
#include "menu/menu_send.h"
#include "chat_helpers/emoji_suggestions_widget.h"
#include "chat_helpers/field_autocomplete.h"
@@ -1496,15 +1497,18 @@ void SendFilesBox::pushBlock(int from, int till) {
if (canToggleSpoiler) {
const auto spoilered = file.spoiler;
const auto &icons = _st.tabbed.icons;
- state->menu->addAction(spoilered
- ? tr::lng_context_disable_spoiler(tr::now)
- : tr::lng_context_spoiler_effect(tr::now), [=] {
- applyBlockChanges();
- refreshAllAfterChanges(from, [&] {
- auto &entry = _list.files[fileIndex];
- entry.spoiler = !spoilered;
- });
- }, spoilered ? &icons.menuSpoilerOff : &icons.menuSpoiler);
+ Menu::AddCheckedAction(
+ state->menu.get(),
+ tr::lng_context_spoiler_effect(tr::now),
+ [=] {
+ applyBlockChanges();
+ refreshAllAfterChanges(from, [&] {
+ auto &entry = _list.files[fileIndex];
+ entry.spoiler = !spoilered;
+ });
+ },
+ &icons.menuSpoiler,
+ spoilered);
}
const auto canEditCover = file.isVideoFile()
&& (_toPeer->isBroadcast() || _toPeer->isSelf());
diff --git a/Telegram/SourceFiles/boxes/send_gif_with_caption_box.cpp b/Telegram/SourceFiles/boxes/send_gif_with_caption_box.cpp
index 3c4a6ca823..a0492408ef 100644
--- a/Telegram/SourceFiles/boxes/send_gif_with_caption_box.cpp
+++ b/Telegram/SourceFiles/boxes/send_gif_with_caption_box.cpp
@@ -33,6 +33,7 @@ https://github.com/telegramdesktop/tdesktop/blob/master/LEGAL
#include "lang/lang_keys.h"
#include "main/main_session.h"
#include "media/clip/media_clip_reader.h"
+#include "menu/menu_checked_action.h"
#include "menu/menu_send.h"
#include "ui/controls/emoji_button.h"
#include "ui/controls/emoji_button_factory.h"
@@ -257,10 +258,9 @@ struct State final {
const auto menu = Ui::CreateChild(
widget,
st::popupMenuWithIcons);
- menu->addAction(
- state->hasSpoiler
- ? tr::lng_context_disable_spoiler(tr::now)
- : tr::lng_context_spoiler_effect(tr::now),
+ ::Menu::AddCheckedAction(
+ menu,
+ tr::lng_context_spoiler_effect(tr::now),
[=] {
state->hasSpoiler = !state->hasSpoiler;
if (!state->hasSpoiler) {
@@ -273,9 +273,8 @@ struct State final {
}
widget->update();
},
- state->hasSpoiler
- ? &st::menuIconSpoilerOff
- : &st::menuIconSpoiler);
+ &st::menuIconSpoiler,
+ state->hasSpoiler);
menu->popup(QCursor::pos());
return base::EventFilterResult::Cancel;
}
diff --git a/Telegram/SourceFiles/chat_helpers/chat_helpers.style b/Telegram/SourceFiles/chat_helpers/chat_helpers.style
index a851b3ff84..48acb15505 100644
--- a/Telegram/SourceFiles/chat_helpers/chat_helpers.style
+++ b/Telegram/SourceFiles/chat_helpers/chat_helpers.style
@@ -69,11 +69,9 @@ ComposeIcons {
menuSchedule: icon;
menuWhenOnline: icon;
menuSpoiler: icon;
- menuSpoilerOff: icon;
menuBelow: icon;
menuAbove: icon;
menuQualityHigh: icon;
- menuQualityStandard: icon;
menuPrice: icon;
menuEditStars: icon;
@@ -657,11 +655,9 @@ defaultComposeIcons: ComposeIcons {
menuSchedule: menuIconSchedule;
menuWhenOnline: menuIconWhenOnline;
menuSpoiler: menuIconSpoiler;
- menuSpoilerOff: menuIconSpoilerOff;
menuBelow: menuIconBelow;
menuAbove: menuIconAbove;
menuQualityHigh: menuIconQualityHigh;
- menuQualityStandard: menuIconQualityStandard;
menuPrice: menuIconEarn;
stripBubble: icon{
diff --git a/Telegram/SourceFiles/history/view/controls/history_view_compose_controls.cpp b/Telegram/SourceFiles/history/view/controls/history_view_compose_controls.cpp
index 94c62567c5..15edeeddc2 100644
--- a/Telegram/SourceFiles/history/view/controls/history_view_compose_controls.cpp
+++ b/Telegram/SourceFiles/history/view/controls/history_view_compose_controls.cpp
@@ -75,6 +75,7 @@ https://github.com/telegramdesktop/tdesktop/blob/master/LEGAL
#include "main/session/send_as_peers.h"
#include "media/audio/media_audio_capture.h"
#include "media/audio/media_audio.h"
+#include "menu/menu_checked_action.h"
#include "menu/menu_send.h"
#include "settings/sections/settings_premium.h"
#include "ui/item_text_options.h"
@@ -4367,12 +4368,12 @@ void ShowPhotoEditSpoilerMenu(
const auto menu = Ui::CreateChild(
parent,
st::popupMenuWithIcons);
- menu->addAction(
- spoilered
- ? tr::lng_context_disable_spoiler(tr::now)
- : tr::lng_context_spoiler_effect(tr::now),
+ Menu::AddCheckedAction(
+ menu,
+ tr::lng_context_spoiler_effect(tr::now),
[=] { callback(!spoilered); },
- spoilered ? &st::menuIconSpoilerOff : &st::menuIconSpoiler);
+ &st::menuIconSpoiler,
+ spoilered);
menu->popup(QCursor::pos());
}
diff --git a/Telegram/SourceFiles/media/view/media_view.style b/Telegram/SourceFiles/media/view/media_view.style
index cae366abd0..18afb14c84 100644
--- a/Telegram/SourceFiles/media/view/media_view.style
+++ b/Telegram/SourceFiles/media/view/media_view.style
@@ -656,11 +656,9 @@ storiesEmojiPan: EmojiPan(defaultEmojiPan) {
menuSchedule: icon {{ "menu/calendar", storiesComposeWhiteText }};
menuWhenOnline: icon {{ "menu/send_when_online", storiesComposeWhiteText }};
menuSpoiler: icon {{ "menu/spoiler_on", storiesComposeWhiteText }};
- menuSpoilerOff: icon {{ "menu/spoiler_off", storiesComposeWhiteText }};
menuBelow: icon {{ "menu/link_below", storiesComposeWhiteText }};
menuAbove: icon {{ "menu/link_above", storiesComposeWhiteText }};
menuQualityHigh: icon {{ "menu/quality_hd", storiesComposeWhiteText }};
- menuQualityStandard: icon {{ "menu/quality_sd", storiesComposeWhiteText }};
menuPrice: icon {{ "menu/earn", storiesComposeWhiteText }};
menuEditStars: icon {{ "chat/input_paid", storiesComposeWhiteText, point(-8px, -8px) }};
diff --git a/Telegram/SourceFiles/menu/menu_checked_action.cpp b/Telegram/SourceFiles/menu/menu_checked_action.cpp
new file mode 100644
index 0000000000..7285204ce6
--- /dev/null
+++ b/Telegram/SourceFiles/menu/menu_checked_action.cpp
@@ -0,0 +1,83 @@
+/*
+This file is part of Telegram Desktop,
+the official desktop application for the Telegram messaging service.
+
+For license and copyright information please follow this link:
+https://github.com/telegramdesktop/tdesktop/blob/master/LEGAL
+*/
+#include "menu/menu_checked_action.h"
+
+#include "base/unique_qptr.h"
+#include "ui/widgets/menu/menu_action.h"
+#include "ui/widgets/menu/menu_common.h"
+#include "ui/widgets/popup_menu.h"
+#include "ui/painter.h"
+
+#include "styles/style_media_player.h"
+
+namespace {
+
+class CheckedAction final : public Ui::Menu::Action {
+public:
+ CheckedAction(
+ not_null parent,
+ const style::Menu &st,
+ not_null action,
+ const style::icon *icon,
+ bool checked);
+
+private:
+ void paintEvent(QPaintEvent *e) override;
+
+ const bool _checked = false;
+
+};
+
+CheckedAction::CheckedAction(
+ not_null parent,
+ const style::Menu &st,
+ not_null action,
+ const style::icon *icon,
+ bool checked)
+: Ui::Menu::Action(parent, st, action, icon, icon)
+, _checked(checked) {
+ setMinWidth(minWidth() + st.itemRightSkip + st::mediaPlayerMenuCheck.width());
+}
+
+void CheckedAction::paintEvent(QPaintEvent *e) {
+ Ui::Menu::Action::paintEvent(e);
+
+ if (!_checked) {
+ return;
+ }
+
+ Painter p(this);
+ const auto &icon = st::mediaPlayerMenuCheck;
+ const auto left = width() - st().itemRightSkip - icon.width();
+ const auto top = (height() - icon.height()) / 2;
+ icon.paint(p, left, top, width());
+}
+
+} // namespace
+
+namespace Menu {
+
+not_null AddCheckedAction(
+ not_null menu,
+ const QString &text,
+ Fn callback,
+ const style::icon *icon,
+ bool checked) {
+ auto item = base::make_unique_q(
+ menu->menu(),
+ menu->st().menu,
+ Ui::Menu::CreateAction(
+ menu->menu().get(),
+ text,
+ std::move(callback)),
+ icon,
+ checked);
+ return menu->addAction(std::move(item));
+}
+
+} // namespace Menu
diff --git a/Telegram/SourceFiles/menu/menu_checked_action.h b/Telegram/SourceFiles/menu/menu_checked_action.h
new file mode 100644
index 0000000000..6426c1770a
--- /dev/null
+++ b/Telegram/SourceFiles/menu/menu_checked_action.h
@@ -0,0 +1,28 @@
+/*
+This file is part of Telegram Desktop,
+the official desktop application for the Telegram messaging service.
+
+For license and copyright information please follow this link:
+https://github.com/telegramdesktop/tdesktop/blob/master/LEGAL
+*/
+#pragma once
+
+#include "base/basic_types.h"
+#include "ui/style/style_core_types.h"
+
+class QAction;
+
+namespace Ui {
+class PopupMenu;
+} // namespace Ui
+
+namespace Menu {
+
+not_null AddCheckedAction(
+ not_null menu,
+ const QString &text,
+ Fn callback,
+ const style::icon *icon,
+ bool checked);
+
+} // namespace Menu
diff --git a/Telegram/SourceFiles/menu/menu_send.cpp b/Telegram/SourceFiles/menu/menu_send.cpp
index d2fc93e2fe..8f423fa3a7 100644
--- a/Telegram/SourceFiles/menu/menu_send.cpp
+++ b/Telegram/SourceFiles/menu/menu_send.cpp
@@ -7,6 +7,8 @@ https://github.com/telegramdesktop/tdesktop/blob/master/LEGAL
*/
#include "menu/menu_send.h"
+#include "menu/menu_checked_action.h"
+
#include "api/api_common.h"
#include "base/event_filter.h"
#include "base/unixtime.h"
@@ -771,29 +773,27 @@ FillMenuResult FillSendMenu(
}
if (details.photoQuality != PhotoQualityState::None) {
const auto high = (details.photoQuality == PhotoQualityState::High);
- menu->addAction(
- (high
- ? tr::lng_send_standard_quality(tr::now)
- : tr::lng_send_high_quality(tr::now)),
+ Menu::AddCheckedAction(
+ menu,
+ tr::lng_send_high_quality(tr::now),
[=] { action({ .type = high
? ActionType::PhotoQualityOff
: ActionType::PhotoQualityOn
}, details); },
- (high
- ? &icons.menuQualityStandard
- : &icons.menuQualityHigh));
+ &icons.menuQualityHigh,
+ high);
}
if (details.spoiler != SpoilerState::None) {
const auto spoilered = (details.spoiler == SpoilerState::Enabled);
- menu->addAction(
- (spoilered
- ? tr::lng_context_disable_spoiler(tr::now)
- : tr::lng_context_spoiler_effect(tr::now)),
+ Menu::AddCheckedAction(
+ menu,
+ tr::lng_context_spoiler_effect(tr::now),
[=] { action({ .type = spoilered
? ActionType::SpoilerOff
: ActionType::SpoilerOn
}, details); },
- spoilered ? &icons.menuSpoilerOff : &icons.menuSpoiler);
+ &icons.menuSpoiler,
+ spoilered);
}
if (details.caption != CaptionState::None) {
const auto above = (details.caption == CaptionState::Above);
diff --git a/Telegram/SourceFiles/ui/chat/attach/attach_abstract_single_media_preview.cpp b/Telegram/SourceFiles/ui/chat/attach/attach_abstract_single_media_preview.cpp
index da2bc305fe..f46c551d18 100644
--- a/Telegram/SourceFiles/ui/chat/attach/attach_abstract_single_media_preview.cpp
+++ b/Telegram/SourceFiles/ui/chat/attach/attach_abstract_single_media_preview.cpp
@@ -9,6 +9,7 @@ https://github.com/telegramdesktop/tdesktop/blob/master/LEGAL
#include "editor/photo_editor_common.h"
#include "lang/lang_keys.h"
+#include "menu/menu_checked_action.h"
#include "ui/chat/attach/attach_controls.h"
#include "ui/chat/attach/attach_prepare.h"
#include "ui/effects/spoiler_mess.h"
@@ -301,12 +302,15 @@ void AbstractSingleMediaPreview::showContextMenu(QPoint position) {
&& _sendWay.sendImagesAsPhotos()
&& supportsSpoilers()) {
const auto spoilered = hasSpoiler();
- _menu->addAction(spoilered
- ? tr::lng_context_disable_spoiler(tr::now)
- : tr::lng_context_spoiler_effect(tr::now), [=] {
- setSpoiler(!spoilered);
- _spoileredChanges.fire_copy(!spoilered);
- }, spoilered ? &icons.menuSpoilerOff : &icons.menuSpoiler);
+ ::Menu::AddCheckedAction(
+ _menu.get(),
+ tr::lng_context_spoiler_effect(tr::now),
+ [=] {
+ setSpoiler(!spoilered);
+ _spoileredChanges.fire_copy(!spoilered);
+ },
+ &icons.menuSpoiler,
+ spoilered);
}
if (_actionAllowed(AttachActionType::EditCover)) {
_menu->addAction(tr::lng_context_edit_cover(tr::now), [=] {
diff --git a/Telegram/SourceFiles/ui/chat/attach/attach_album_preview.cpp b/Telegram/SourceFiles/ui/chat/attach/attach_album_preview.cpp
index cd2dc1d616..58ef4b6476 100644
--- a/Telegram/SourceFiles/ui/chat/attach/attach_album_preview.cpp
+++ b/Telegram/SourceFiles/ui/chat/attach/attach_album_preview.cpp
@@ -7,6 +7,7 @@ https://github.com/telegramdesktop/tdesktop/blob/master/LEGAL
*/
#include "ui/chat/attach/attach_album_preview.h"
+#include "menu/menu_checked_action.h"
#include "ui/chat/attach/attach_album_thumbnail.h"
#include "ui/chat/attach/attach_prepare.h"
#include "ui/effects/spoiler_mess.h"
@@ -643,11 +644,14 @@ void AlbumPreview::showContextMenu(
if (_actionAllowed(index, AttachActionType::ToggleSpoiler)
&& _sendWay.sendImagesAsPhotos()) {
const auto spoilered = thumb->hasSpoiler();
- _menu->addAction(spoilered
- ? tr::lng_context_disable_spoiler(tr::now)
- : tr::lng_context_spoiler_effect(tr::now), [=] {
- thumb->setSpoiler(!spoilered);
- }, spoilered ? &st::menuIconSpoilerOff : &st::menuIconSpoiler);
+ ::Menu::AddCheckedAction(
+ _menu.get(),
+ tr::lng_context_spoiler_effect(tr::now),
+ [=] {
+ thumb->setSpoiler(!spoilered);
+ },
+ &st::menuIconSpoiler,
+ spoilered);
}
if (_actionAllowed(index, AttachActionType::EditCover)) {
_menu->addAction(tr::lng_context_edit_cover(tr::now), [=] {
diff --git a/Telegram/SourceFiles/ui/menu_icons.style b/Telegram/SourceFiles/ui/menu_icons.style
index 55f0366f12..ed468953e7 100644
--- a/Telegram/SourceFiles/ui/menu_icons.style
+++ b/Telegram/SourceFiles/ui/menu_icons.style
@@ -106,9 +106,7 @@ menuIconVideoChat: icon {{ "menu/video_chat", menuIconColor }};
menuIconTranslate: icon {{ "menu/translate", menuIconColor }};
menuIconReportAntiSpam: icon {{ "menu/false_positive", menuIconColor }};
menuIconSpoiler: icon {{ "menu/spoiler_on", menuIconColor }};
-menuIconSpoilerOff: icon {{ "menu/spoiler_off", menuIconColor }};
menuIconQualityHigh: icon {{ "menu/quality_hd", menuIconColor }};
-menuIconQualityStandard: icon {{ "menu/quality_sd", menuIconColor }};
menuIconDisable: icon {{ "menu/disable", menuIconColor }};
menuIconPhotoSet: icon {{ "menu/photo_set", menuIconColor }};
menuIconPhotoSuggest: icon {{ "menu/photo_suggest", menuIconColor }};
diff --git a/Telegram/cmake/td_ui.cmake b/Telegram/cmake/td_ui.cmake
index 9ee7210042..a959ceb849 100644
--- a/Telegram/cmake/td_ui.cmake
+++ b/Telegram/cmake/td_ui.cmake
@@ -218,6 +218,8 @@ PRIVATE
menu/gift_resale_filter.cpp
menu/gift_resale_filter.h
+ menu/menu_checked_action.cpp
+ menu/menu_checked_action.h
menu/menu_check_item.cpp
menu/menu_check_item.h
menu/menu_item_rate_transcribe.cpp