diff --git a/Telegram/Resources/icons/send_control_scheduled_no_dot.png b/Telegram/Resources/icons/send_control_scheduled_no_dot.png new file mode 100644 index 000000000..ed21b6e95 Binary files /dev/null and b/Telegram/Resources/icons/send_control_scheduled_no_dot.png differ diff --git a/Telegram/Resources/icons/send_control_scheduled_no_dot@2x.png b/Telegram/Resources/icons/send_control_scheduled_no_dot@2x.png new file mode 100644 index 000000000..bc1ecbbf8 Binary files /dev/null and b/Telegram/Resources/icons/send_control_scheduled_no_dot@2x.png differ diff --git a/Telegram/Resources/icons/send_control_scheduled_no_dot@3x.png b/Telegram/Resources/icons/send_control_scheduled_no_dot@3x.png new file mode 100644 index 000000000..d0c17193a Binary files /dev/null and b/Telegram/Resources/icons/send_control_scheduled_no_dot@3x.png differ diff --git a/Telegram/Resources/langs/rewrites/en.json b/Telegram/Resources/langs/rewrites/en.json index eadf8ae16..fd0113552 100644 --- a/Telegram/Resources/langs/rewrites/en.json +++ b/Telegram/Resources/langs/rewrites/en.json @@ -32,6 +32,7 @@ "ktg_settings_sticker_scale_both": "Apply to sticker width", "ktg_settings_sticker_scale_both_about": "When enabled, sticker maximum width will be changed along with sticker height.", "ktg_settings_emoji_outline": "Big emoji outline", + "ktg_settings_always_show_scheduled": "Always show scheduled", "ktg_fonts_title": "Fonts", "ktg_settings_fonts": "Change application fonts", "ktg_fonts_reset": "Reset", diff --git a/Telegram/SourceFiles/facades.cpp b/Telegram/SourceFiles/facades.cpp index 05a512079..6cd9e0bb1 100644 --- a/Telegram/SourceFiles/facades.cpp +++ b/Telegram/SourceFiles/facades.cpp @@ -287,6 +287,10 @@ bool skipPaintEvent(QWidget *widget, QPaintEvent *event) { namespace Notify { +void showScheduledButtonChanged(not_null session) { + if (const auto m = CheckMainWidget(session)) m->notify_showScheduledButtonChanged(); +} + bool switchInlineBotButtonReceived( not_null session, const QString &query, diff --git a/Telegram/SourceFiles/facades.h b/Telegram/SourceFiles/facades.h index 5c9fdcbff..780f33f96 100644 --- a/Telegram/SourceFiles/facades.h +++ b/Telegram/SourceFiles/facades.h @@ -67,6 +67,7 @@ enum ClipStopperType { namespace Notify { +void showScheduledButtonChanged(not_null session); bool switchInlineBotButtonReceived( not_null session, const QString &query, diff --git a/Telegram/SourceFiles/history/history_widget.cpp b/Telegram/SourceFiles/history/history_widget.cpp index e367a1aa2..f6ba3c85c 100644 --- a/Telegram/SourceFiles/history/history_widget.cpp +++ b/Telegram/SourceFiles/history/history_widget.cpp @@ -1828,6 +1828,12 @@ bool HistoryWidget::notify_switchInlineBotButtonReceived(const QString &query, U return false; } +void HistoryWidget::notify_showScheduledButtonChanged() { + refreshScheduledToggle(); + updateControlsVisibility(); + updateControlsGeometry(); +} + void HistoryWidget::setupShortcuts() { Shortcuts::Requests( ) | rpl::filter([=] { @@ -2517,19 +2523,23 @@ void HistoryWidget::setupScheduledToggle() { } void HistoryWidget::refreshScheduledToggle() { - const auto has = _history - && _peer->canWrite() - && (session().data().scheduledMessages().count(_history) > 0); - if (!_scheduled && has) { - _scheduled.create(this, st::historyScheduledToggle); - _scheduled->show(); - _scheduled->addClickHandler([=] { - controller()->showSection( - std::make_shared(_history)); - }); - orderWidgets(); // Raise drag areas to the top. - } else if (_scheduled && !has) { + const auto canWrite = _history && _peer->canWrite(); + const auto has = canWrite && (session().data().scheduledMessages().count(_history) > 0); + if (_scheduled && !canWrite) { _scheduled.destroy(); + } else if (canWrite) { + if (_scheduled) { + _scheduled.destroy(); + } + if (::Kotato::JsonSettings::GetBool("always_show_scheduled") || has){ + _scheduled.create(this, (has ? st::historyScheduledToggle : st::historyScheduledToggleEmpty)); + _scheduled->show(); + _scheduled->addClickHandler([=] { + controller()->showSection( + std::make_shared(_history)); + }); + orderWidgets(); // Raise drag areas to the top. + } } } diff --git a/Telegram/SourceFiles/history/history_widget.h b/Telegram/SourceFiles/history/history_widget.h index e8cd71b5c..d244a62cc 100644 --- a/Telegram/SourceFiles/history/history_widget.h +++ b/Telegram/SourceFiles/history/history_widget.h @@ -285,6 +285,7 @@ public: QRect floatPlayerAvailableRect() override; bool notify_switchInlineBotButtonReceived(const QString &query, UserData *samePeerBot, MsgId samePeerReplyTo); + void notify_showScheduledButtonChanged(); ~HistoryWidget(); diff --git a/Telegram/SourceFiles/kotato/kotato_settings.cpp b/Telegram/SourceFiles/kotato/kotato_settings.cpp index 04c92bdea..04fdc3feb 100644 --- a/Telegram/SourceFiles/kotato/kotato_settings.cpp +++ b/Telegram/SourceFiles/kotato/kotato_settings.cpp @@ -260,6 +260,9 @@ const std::map> DefinitionMap { { "monospace_large_bubbles", { .type = SettingType::BoolSetting, .defaultValue = false, }}, + { "always_show_scheduled", { + .type = SettingType::BoolSetting, + .defaultValue = false, }}, }; using OldOptionKey = QString; diff --git a/Telegram/SourceFiles/kotato/kotato_settings_menu.cpp b/Telegram/SourceFiles/kotato/kotato_settings_menu.cpp index ba52c84b4..9872ab3f9 100644 --- a/Telegram/SourceFiles/kotato/kotato_settings_menu.cpp +++ b/Telegram/SourceFiles/kotato/kotato_settings_menu.cpp @@ -68,6 +68,21 @@ void SetupKotatoChats( AddSkip(container); AddSubsectionTitle(container, rktr("ktg_settings_chats")); + AddButton( + container, + rktr("ktg_settings_always_show_scheduled"), + st::settingsButton + )->toggleOn( + rpl::single(::Kotato::JsonSettings::GetBool("always_show_scheduled")) + )->toggledValue( + ) | rpl::filter([](bool enabled) { + return (enabled != ::Kotato::JsonSettings::GetBool("always_show_scheduled")); + }) | rpl::start_with_next([controller](bool enabled) { + ::Kotato::JsonSettings::Set("always_show_scheduled", enabled); + Notify::showScheduledButtonChanged(&controller->session()); + ::Kotato::JsonSettings::Write(); + }, container->lifetime()); + AddButton( container, rktr("ktg_settings_fonts"), diff --git a/Telegram/SourceFiles/mainwidget.cpp b/Telegram/SourceFiles/mainwidget.cpp index a18022cce..da617eab8 100644 --- a/Telegram/SourceFiles/mainwidget.cpp +++ b/Telegram/SourceFiles/mainwidget.cpp @@ -621,6 +621,10 @@ bool MainWidget::notify_switchInlineBotButtonReceived(const QString &query, User return _history->notify_switchInlineBotButtonReceived(query, samePeerBot, samePeerReplyTo); } +void MainWidget::notify_showScheduledButtonChanged() { + _history->notify_showScheduledButtonChanged(); +} + void MainWidget::clearHider(not_null instance) { if (_hider != instance) { return; diff --git a/Telegram/SourceFiles/mainwidget.h b/Telegram/SourceFiles/mainwidget.h index 9c2e82bb7..9d7f21a79 100644 --- a/Telegram/SourceFiles/mainwidget.h +++ b/Telegram/SourceFiles/mainwidget.h @@ -223,6 +223,7 @@ public: MsgId msgId); bool notify_switchInlineBotButtonReceived(const QString &query, UserData *samePeerBot, MsgId samePeerReplyTo); + void notify_showScheduledButtonChanged(); using FloatDelegate::floatPlayerAreaUpdated; diff --git a/Telegram/SourceFiles/ui/chat/chat.style b/Telegram/SourceFiles/ui/chat/chat.style index 082fbe66b..64f62dfcf 100644 --- a/Telegram/SourceFiles/ui/chat/chat.style +++ b/Telegram/SourceFiles/ui/chat/chat.style @@ -353,6 +353,11 @@ historyScheduledToggle: IconButton(historyAttach) { }; } +historyScheduledToggleEmpty: IconButton(historyAttach) { + icon: icon {{ "send_control_scheduled_no_dot", historyComposeIconFg }}; + iconOver: icon {{ "send_control_scheduled_no_dot", historyComposeIconFgOver }}; + iconPosition: point(-1px, -1px); +} historyRecordVoiceFg: historyComposeIconFg; historyRecordVoiceFgOver: historyComposeIconFgOver; historyRecordVoiceFgInactive: attentionButtonFg;