From 3c67eea72767ad5caacf263751c0cd9f13801854 Mon Sep 17 00:00:00 2001 From: RadRussianRus Date: Fri, 26 Aug 2022 21:49:24 +0300 Subject: [PATCH] [Option][GUI] Always show scheduled --- .../icons/send_control_scheduled_no_dot.png | Bin 0 -> 1694 bytes .../send_control_scheduled_no_dot@2x.png | Bin 0 -> 1826 bytes .../send_control_scheduled_no_dot@3x.png | Bin 0 -> 1976 bytes Telegram/Resources/langs/rewrites/en.json | 1 + Telegram/SourceFiles/facades.cpp | 4 +++ Telegram/SourceFiles/facades.h | 1 + .../SourceFiles/history/history_widget.cpp | 34 +++++++++++------- Telegram/SourceFiles/history/history_widget.h | 1 + .../SourceFiles/kotato/kotato_settings.cpp | 3 ++ .../kotato/kotato_settings_menu.cpp | 15 ++++++++ Telegram/SourceFiles/mainwidget.cpp | 4 +++ Telegram/SourceFiles/mainwidget.h | 1 + Telegram/SourceFiles/ui/chat/chat.style | 5 +++ 13 files changed, 57 insertions(+), 12 deletions(-) create mode 100644 Telegram/Resources/icons/send_control_scheduled_no_dot.png create mode 100644 Telegram/Resources/icons/send_control_scheduled_no_dot@2x.png create mode 100644 Telegram/Resources/icons/send_control_scheduled_no_dot@3x.png 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 0000000000000000000000000000000000000000..ed21b6e955d3adf1b4bbdb90b8e2d293a2ac8fec GIT binary patch literal 1694 zcmbVNPl()99FAgjUFku*NDn1VFT2!CUj9zIcu)}bV)dY)9tu^^qToT=qoDR6)x#>N6yKZ4#9i6e#bGjeNxt`e z-|tU;^UA{fiT%?DrUgOR->BCX+4&$prtW0F7Z;r^cDgsNpH2ngz6bbmhw#RQ2L)l@ zH$iJDTWUTIF%3(|qis?egfT-4!qMY{7~y4-iEYveB3HWc@u!j)c&>EHY=UN7CEcLD zmXMQc^DVr#j2%xpeoQ<%fQ%p{84?F!FG}ISl}5aft@&+55=W41*_A3>P+V#*h*g>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GZ|5SV3ml3N&eJhCZ?sDzIsm zlOwz=N=u-)Yc%M?{{(BQtlO>$amW~-Rv zA5{P|Du;B9)2uiFbBAQi2 zmKH=2(g0)ttwY2^pmB)hxuBuTJtB7-9hHB96F-i^Uj5Mlx z+gK(aD^jlRFXj*?y+!dW>YlCpMd+f=EY96Z`ir@le-94d+WpF^S+TX${WAUdKiyZ8 zqvoKMMRD=%- zf;cthNrLb>Sm=28`Ot42jaSYbPHpE-&YZfKUw=HZ5B)qnpLufO^u+Z`*QC(}>hkHQ z^e6Vr($jqxOD|5CigNc)rJkaW?aQe^1Lee=JxOpS|g zZ3-FP@#gud@#~G_k==(rIkfT77Vv9f+qw(iy?M24ViyMhHfMfoC>lgt}+-r^< S+Y5{a&q^4`v;5Bv>+7FQ4e literal 0 HcmV?d00001 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 0000000000000000000000000000000000000000..d0c17193a72e7c198d3200b988522d5bef3670a3 GIT binary patch literal 1976 zcmbVNeQeZZ9PU^MI0i(RFmRBjOAMmD_S)X<+Hf$un{0_U<~V^FoxIn+y{p`{rR{dN z$(#a8CK(a_kPIdgNcfm$5k+T)I#@&um;eqz1;etT8G#AJ@R6X4Z|`m=(}Be1dVN2h z_xU})kN(!2s#om9icI7-hzY<#Ffy(LolqUUgGM(E&^91FR{!OpaZ%O zMwHTe11_mA4~q3GMP4En%*W>?1Vj*n7Qhp+sA>ucFOlRG(AZw42s{a~R(gqrwn2P( zpaS=42E<(sHz_(f7hc3WoNkum`6qFPc6unH1o5y+Y$$wH<7>9j30 z^AZuu(gli&$K#GT>(Goa<>Yyuq8W-|NQ5BGI@JORQZ);Q8T`-`4Mn#UO~q|S5YlQa zFM*V%T!`rzTGdR42?dNw0G)C=XxpVEP!cmZy~c1_BuyqiTu8GA2x`q!zi64#=ozGgzlXsuG%7jUmF4S|qd3_C^oT!Rn$+*vFCx*x8EK^iTi<^(%bq4x@1-*p5Ptxe;4$_R^;sx6I1kDOGoq`55 zNs;SDLRmUUI|Uab(A)?psu~Gc;6K5VD9D--1ITA32Evfi)i8l)A}RQ^sAeF;NFAG0 z5eNuns%ZgLgk^p&f!uZ|iX^zWB2a`b(nE)2l94%?^vJwOLdc=2q=C%J-0*q7Cf3-= zwa=&OT+&3u@wZixr9C2pj)%~3vdGD?B+q$5q(_oPR)ijpEHT4uiwy<6Y9M+ytF1~x zjBXfWJZ_05Js}85jzeUj5F?U6W&kURZiZz!yP%UbB9tm7%3fXi6YrIl?%mawhT*8$*~3hiMUzaQhAN^q zP#4}#v`)aVtmZQR!eHX3!EJ||-k|eJ8nc#O+dui%v=xPGUi@L*O+dL3^Pl?`BuQCiZ&ExuGqEePgaP z&X_e&d^G!FUG>=;bZ)=LalCKJPGfG{cR4%qCvUj@YFEPr?cA@qJMwdOm7e%)Z`;e; z!{OYL$`4OFw(kD%*3T{e!+F%DPWo~mw>i=rF=w7H>^S(?5q@X?+z%QG7M-mrc~+`= z$2if}`c~V4G3)l_x#|~Byz>ngfK~I)_2(5kyQ`;m+-dt_{pG$@)AwxBo9F0XZSK65 zxN)Fj@P+Y@e7#}Mp@%PD${F~+=gcR&eBkp$PQm`_#JI()YlrGSdb8v9vY}UQ9$Pn1 zJWe?I`o{4`uB@G8?Z}=rkk~S5CW)3(v*hl-hesQG_njX*yRy2sWpM0l@KSHnmy@## zrsrS14sIV`f9lXSS9kB;#*OsS)jbU}gmKAFDTb~618a{LvG4BgXYG};l5&6hQ!Cc| E1 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;