[Option][GUI] Always show scheduled

This commit is contained in:
Eric Kotato 2022-08-26 21:49:24 +03:00
parent 09c94b2a56
commit 3c67eea727
13 changed files with 57 additions and 12 deletions

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.7 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.8 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.9 KiB

View file

@ -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",

View file

@ -287,6 +287,10 @@ bool skipPaintEvent(QWidget *widget, QPaintEvent *event) {
namespace Notify {
void showScheduledButtonChanged(not_null<Main::Session*> session) {
if (const auto m = CheckMainWidget(session)) m->notify_showScheduledButtonChanged();
}
bool switchInlineBotButtonReceived(
not_null<Main::Session*> session,
const QString &query,

View file

@ -67,6 +67,7 @@ enum ClipStopperType {
namespace Notify {
void showScheduledButtonChanged(not_null<Main::Session*> session);
bool switchInlineBotButtonReceived(
not_null<Main::Session*> session,
const QString &query,

View file

@ -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<HistoryView::ScheduledMemento>(_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<HistoryView::ScheduledMemento>(_history));
});
orderWidgets(); // Raise drag areas to the top.
}
}
}

View file

@ -285,6 +285,7 @@ public:
QRect floatPlayerAvailableRect() override;
bool notify_switchInlineBotButtonReceived(const QString &query, UserData *samePeerBot, MsgId samePeerReplyTo);
void notify_showScheduledButtonChanged();
~HistoryWidget();

View file

@ -260,6 +260,9 @@ const std::map<QString, Definition, std::greater<QString>> DefinitionMap {
{ "monospace_large_bubbles", {
.type = SettingType::BoolSetting,
.defaultValue = false, }},
{ "always_show_scheduled", {
.type = SettingType::BoolSetting,
.defaultValue = false, }},
};
using OldOptionKey = QString;

View file

@ -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"),

View file

@ -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<Window::HistoryHider*> instance) {
if (_hider != instance) {
return;

View file

@ -223,6 +223,7 @@ public:
MsgId msgId);
bool notify_switchInlineBotButtonReceived(const QString &query, UserData *samePeerBot, MsgId samePeerReplyTo);
void notify_showScheduledButtonChanged();
using FloatDelegate::floatPlayerAreaUpdated;

View file

@ -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;