mirror of
https://github.com/kotatogram/kotatogram-desktop
synced 2025-08-30 14:17:45 +00:00
Options to remember forward mode and set default
This commit is contained in:
parent
8b7fa27a7a
commit
2daaf3f402
@ -243,5 +243,15 @@
|
||||
"other": "days"
|
||||
},
|
||||
"ktg_forward_sender_names_and_captions_removed": "Sender names and captions removed",
|
||||
"ktg_forward_remember_mode": "Remember forward mode",
|
||||
"ktg_forward_mode": "Forward mode",
|
||||
"ktg_forward_mode_quoted": "Quoted",
|
||||
"ktg_forward_mode_unquoted": "Unquoted",
|
||||
"ktg_forward_mode_uncaptioned": "Uncaptioned",
|
||||
"ktg_forward_grouping_mode": "Grouping mode",
|
||||
"ktg_forward_grouping_mode_preserve_albums": "Same as original",
|
||||
"ktg_forward_grouping_mode_regroup": "Regroup media",
|
||||
"ktg_forward_grouping_mode_regroup_desc": "Unquoted and uncaptioned only",
|
||||
"ktg_forward_grouping_mode_separate": "Separate",
|
||||
"dummy_last_string": ""
|
||||
}
|
||||
|
@ -261,5 +261,15 @@
|
||||
"other": "дня"
|
||||
},
|
||||
"ktg_forward_sender_names_and_captions_removed": "Имена отправителей и подписи скрыты",
|
||||
"ktg_forward_remember_mode": "Запоминать режим пересылки",
|
||||
"ktg_forward_mode": "Режим пересылки",
|
||||
"ktg_forward_mode_quoted": "С автором",
|
||||
"ktg_forward_mode_unquoted": "Без автора",
|
||||
"ktg_forward_mode_uncaptioned": "Без подписей",
|
||||
"ktg_forward_grouping_mode": "Режим группировки",
|
||||
"ktg_forward_grouping_mode_preserve_albums": "Как в оригинале",
|
||||
"ktg_forward_grouping_mode_regroup": "Объединить медиа",
|
||||
"ktg_forward_grouping_mode_regroup_desc": "Только без автора и без подписей",
|
||||
"ktg_forward_grouping_mode_separate": "По отдельности",
|
||||
"dummy_last_string": ""
|
||||
}
|
||||
|
@ -9,6 +9,7 @@ https://github.com/telegramdesktop/tdesktop/blob/master/LEGAL
|
||||
|
||||
#include "dialogs/dialogs_indexed_list.h"
|
||||
#include "kotato/kotato_lang.h"
|
||||
#include "kotato/json_settings.h"
|
||||
#include "lang/lang_keys.h"
|
||||
#include "mainwindow.h"
|
||||
#include "mainwidget.h"
|
||||
@ -527,34 +528,42 @@ bool ShareBox::showMenu(not_null<Ui::IconButton*> button) {
|
||||
});
|
||||
button->installEventFilter(_menu);
|
||||
|
||||
const auto addForwardOption = [this] (Data::ForwardOptions option, const QString &langKey) {
|
||||
const auto addForwardOption = [this] (Data::ForwardOptions option, const QString &langKey, int settingsKey) {
|
||||
if (_descriptor.draft->options != option) {
|
||||
_menu->addAction(ktr(langKey), [this, option] {
|
||||
_menu->addAction(ktr(langKey), [this, option, settingsKey] {
|
||||
_descriptor.draft->options = option;
|
||||
updateAdditionalTitle();
|
||||
if (cForwardRememberMode()) {
|
||||
SetForwardMode(settingsKey);
|
||||
Kotato::JsonSettings::Write();
|
||||
}
|
||||
});
|
||||
}
|
||||
};
|
||||
|
||||
addForwardOption(Data::ForwardOptions::PreserveInfo, "ktg_forward_menu_quoted");
|
||||
addForwardOption(Data::ForwardOptions::NoSenderNames, "ktg_forward_menu_unquoted");
|
||||
addForwardOption(Data::ForwardOptions::NoNamesAndCaptions, "ktg_forward_menu_uncaptioned");
|
||||
addForwardOption(Data::ForwardOptions::PreserveInfo, "ktg_forward_menu_quoted", 0);
|
||||
addForwardOption(Data::ForwardOptions::NoSenderNames, "ktg_forward_menu_unquoted", 1);
|
||||
addForwardOption(Data::ForwardOptions::NoNamesAndCaptions, "ktg_forward_menu_uncaptioned", 2);
|
||||
|
||||
if (_descriptor.hasMedia) {
|
||||
_menu->addSeparator();
|
||||
|
||||
const auto addGroupingOption = [this] (Data::GroupingOptions option, const QString &langKey) {
|
||||
const auto addGroupingOption = [this] (Data::GroupingOptions option, const QString &langKey, int settingsKey) {
|
||||
if (_descriptor.draft->groupOptions != option) {
|
||||
_menu->addAction(ktr(langKey), [this, option] {
|
||||
_menu->addAction(ktr(langKey), [this, option, settingsKey] {
|
||||
_descriptor.draft->groupOptions = option;
|
||||
updateAdditionalTitle();
|
||||
if (cForwardRememberMode()) {
|
||||
SetForwardGroupingMode(settingsKey);
|
||||
Kotato::JsonSettings::Write();
|
||||
}
|
||||
});
|
||||
}
|
||||
};
|
||||
|
||||
addGroupingOption(Data::GroupingOptions::GroupAsIs, "ktg_forward_menu_default_albums");
|
||||
addGroupingOption(Data::GroupingOptions::RegroupAll, "ktg_forward_menu_group_all_media");
|
||||
addGroupingOption(Data::GroupingOptions::Separate, "ktg_forward_menu_separate_messages");
|
||||
addGroupingOption(Data::GroupingOptions::GroupAsIs, "ktg_forward_menu_default_albums", 0);
|
||||
addGroupingOption(Data::GroupingOptions::RegroupAll, "ktg_forward_menu_group_all_media", 1);
|
||||
addGroupingOption(Data::GroupingOptions::Separate, "ktg_forward_menu_separate_messages", 2);
|
||||
}
|
||||
|
||||
const auto parentTopLeft = window()->mapToGlobal({ 0, 0 });
|
||||
|
@ -8,6 +8,7 @@ https://github.com/telegramdesktop/tdesktop/blob/master/LEGAL
|
||||
#include "history/history_widget.h"
|
||||
|
||||
#include "kotato/kotato_lang.h"
|
||||
#include "kotato/json_settings.h"
|
||||
#include "api/api_editing.h"
|
||||
#include "api/api_bot.h"
|
||||
#include "api/api_sending.h"
|
||||
@ -5718,7 +5719,8 @@ void HistoryWidget::contextMenuEvent(QContextMenuEvent *e) {
|
||||
}();
|
||||
const auto addForwardOption = [=](
|
||||
Options newOptions,
|
||||
const QString &langKey) {
|
||||
const QString &langKey,
|
||||
int settingsKey) {
|
||||
if (_history && _toForward.options != newOptions) {
|
||||
_menu->addAction(ktr(langKey), [=] {
|
||||
_toForward.options = newOptions;
|
||||
@ -5728,22 +5730,27 @@ void HistoryWidget::contextMenuEvent(QContextMenuEvent *e) {
|
||||
.groupOptions = _toForward.groupOptions,
|
||||
});
|
||||
updateField();
|
||||
if (cForwardRememberMode()) {
|
||||
SetForwardMode(settingsKey);
|
||||
Kotato::JsonSettings::Write();
|
||||
}
|
||||
});
|
||||
}
|
||||
};
|
||||
|
||||
_menu = base::make_unique_q<Ui::PopupMenu>(this);
|
||||
|
||||
addForwardOption(Options::PreserveInfo, "ktg_forward_menu_quoted");
|
||||
addForwardOption(Options::NoSenderNames, "ktg_forward_menu_unquoted");
|
||||
addForwardOption(Options::PreserveInfo, "ktg_forward_menu_quoted", 0);
|
||||
addForwardOption(Options::NoSenderNames, "ktg_forward_menu_unquoted", 1);
|
||||
if (hasCaptions) {
|
||||
addForwardOption(Options::NoNamesAndCaptions, "ktg_forward_menu_uncaptioned");
|
||||
addForwardOption(Options::NoNamesAndCaptions, "ktg_forward_menu_uncaptioned", 2);
|
||||
}
|
||||
|
||||
if (hasMediaToGroup && count > 1) {
|
||||
const auto addGroupingOption = [=](
|
||||
GroupingOptions newOptions,
|
||||
const QString &langKey) {
|
||||
const QString &langKey,
|
||||
int settingsKey) {
|
||||
if (_history && _toForward.groupOptions != newOptions) {
|
||||
_menu->addAction(ktr(langKey), [=] {
|
||||
_toForward.groupOptions = newOptions;
|
||||
@ -5754,14 +5761,18 @@ void HistoryWidget::contextMenuEvent(QContextMenuEvent *e) {
|
||||
});
|
||||
updateForwardingTexts();
|
||||
updateField();
|
||||
if (cForwardRememberMode()) {
|
||||
SetForwardGroupingMode(settingsKey);
|
||||
Kotato::JsonSettings::Write();
|
||||
}
|
||||
});
|
||||
}
|
||||
};
|
||||
|
||||
_menu->addSeparator();
|
||||
addGroupingOption(GroupingOptions::GroupAsIs, "ktg_forward_menu_default_albums");
|
||||
addGroupingOption(GroupingOptions::RegroupAll, "ktg_forward_menu_group_all_media");
|
||||
addGroupingOption(GroupingOptions::Separate, "ktg_forward_menu_separate_messages");
|
||||
addGroupingOption(GroupingOptions::GroupAsIs, "ktg_forward_menu_default_albums", 0);
|
||||
addGroupingOption(GroupingOptions::RegroupAll, "ktg_forward_menu_group_all_media", 1);
|
||||
addGroupingOption(GroupingOptions::Separate, "ktg_forward_menu_separate_messages", 2);
|
||||
}
|
||||
|
||||
_menu->popup(QCursor::pos());
|
||||
|
@ -391,6 +391,9 @@ QByteArray GenerateSettingsJson(bool areDefault = false) {
|
||||
settings.insert(qsl("forward_retain_selection"), cForwardRetainSelection());
|
||||
settings.insert(qsl("forward_on_click"), cForwardChatOnClick());
|
||||
settings.insert(qsl("telegram_sites_autologin"), cTelegramSitesAutologin());
|
||||
settings.insert(qsl("forward_remember_mode"), cForwardRememberMode());
|
||||
settings.insert(qsl("forward_mode"), ForwardMode());
|
||||
settings.insert(qsl("forward_grouping_mode"), ForwardGroupingMode());
|
||||
|
||||
settingsFonts.insert(qsl("size"), cFontSize());
|
||||
settingsFonts.insert(qsl("use_system_font"), cUseSystemFont());
|
||||
@ -972,6 +975,19 @@ bool Manager::readCustomFile() {
|
||||
ReadBoolOption(settings, "telegram_sites_autologin", [&](auto v) {
|
||||
cSetTelegramSitesAutologin(v);
|
||||
});
|
||||
ReadBoolOption(settings, "forward_remember_mode", [&](auto v) {
|
||||
cSetForwardRememberMode(v);
|
||||
});
|
||||
ReadIntOption(settings, "forward_mode", [&](auto v) {
|
||||
if (v >= 0 && v <= 2) {
|
||||
SetForwardMode(v);
|
||||
}
|
||||
});
|
||||
ReadIntOption(settings, "forward_grouping_mode", [&](auto v) {
|
||||
if (v >= 0 && v <= 2) {
|
||||
SetForwardGroupingMode(v);
|
||||
}
|
||||
});
|
||||
return true;
|
||||
}
|
||||
|
||||
|
@ -262,3 +262,33 @@ bool gAutoScrollUnfocused = false;
|
||||
LocalFolderVector gLocalFolders;
|
||||
|
||||
bool gTelegramSitesAutologin = true;
|
||||
|
||||
bool gForwardRememberMode = true;
|
||||
|
||||
// 0 - quoted
|
||||
// 1 - unquoted
|
||||
// 2 - uncaptioned
|
||||
rpl::variable<int> gForwardMode = 0;
|
||||
void SetForwardMode(int mode) {
|
||||
gForwardMode = mode;
|
||||
}
|
||||
int ForwardMode() {
|
||||
return gForwardMode.current();
|
||||
}
|
||||
rpl::producer<int> ForwardModeChanges() {
|
||||
return gForwardMode.changes();
|
||||
}
|
||||
|
||||
// 0 - preserve albums
|
||||
// 1 - group all media
|
||||
// 2 - separate messages
|
||||
rpl::variable<int> gForwardGroupingMode = 0;
|
||||
void SetForwardGroupingMode(int mode) {
|
||||
gForwardGroupingMode = mode;
|
||||
}
|
||||
int ForwardGroupingMode() {
|
||||
return gForwardGroupingMode.current();
|
||||
}
|
||||
rpl::producer<int> ForwardGroupingModeChanges() {
|
||||
return gForwardGroupingMode.changes();
|
||||
}
|
||||
|
@ -174,3 +174,13 @@ using LocalFolderVector = std::vector<LocalFolder>;
|
||||
DeclareRefSetting(LocalFolderVector, LocalFolders);
|
||||
|
||||
DeclareSetting(bool, TelegramSitesAutologin);
|
||||
|
||||
DeclareSetting(bool, ForwardRememberMode);
|
||||
|
||||
void SetForwardMode(int mode);
|
||||
[[nodiscard]] int ForwardMode();
|
||||
[[nodiscard]] rpl::producer<int> ForwardModeChanges();
|
||||
|
||||
void SetForwardGroupingMode(int mode);
|
||||
[[nodiscard]] int ForwardGroupingMode();
|
||||
[[nodiscard]] rpl::producer<int> ForwardGroupingModeChanges();
|
||||
|
@ -56,6 +56,55 @@ QString FileDialogTypeDescription(int value) {
|
||||
return Platform::FileDialog::ImplementationTypeDescription(typedValue);
|
||||
}
|
||||
|
||||
QString ForwardModeLabel(int mode) {
|
||||
switch (mode) {
|
||||
case 0:
|
||||
return ktr("ktg_forward_mode_quoted");
|
||||
|
||||
case 1:
|
||||
return ktr("ktg_forward_mode_unquoted");
|
||||
|
||||
case 2:
|
||||
return ktr("ktg_forward_mode_uncaptioned");
|
||||
|
||||
default:
|
||||
Unexpected("Boost in Settings::ForwardModeLabel.");
|
||||
}
|
||||
return QString();
|
||||
}
|
||||
|
||||
QString GroupingModeLabel(int mode) {
|
||||
switch (mode) {
|
||||
case 0:
|
||||
return ktr("ktg_forward_grouping_mode_preserve_albums");
|
||||
|
||||
case 1:
|
||||
return ktr("ktg_forward_grouping_mode_regroup");
|
||||
|
||||
case 2:
|
||||
return ktr("ktg_forward_grouping_mode_separate");
|
||||
|
||||
default:
|
||||
Unexpected("Boost in Settings::GroupingModeLabel.");
|
||||
}
|
||||
return QString();
|
||||
}
|
||||
|
||||
QString GroupingModeDescription(int mode) {
|
||||
switch (mode) {
|
||||
case 0:
|
||||
case 2:
|
||||
return QString();
|
||||
|
||||
case 1:
|
||||
return ktr("ktg_forward_grouping_mode_regroup_desc");
|
||||
|
||||
default:
|
||||
Unexpected("Boost in Settings::GroupingModeLabel.");
|
||||
}
|
||||
return QString();
|
||||
}
|
||||
|
||||
QString NetBoostLabel(int boost) {
|
||||
switch (boost) {
|
||||
case 0:
|
||||
@ -388,6 +437,59 @@ void SetupKotatoForward(not_null<Ui::VerticalLayout*> container) {
|
||||
AddSkip(container);
|
||||
AddSubsectionTitle(container, rktr("ktg_settings_forward"));
|
||||
|
||||
SettingsMenuCSwitch(ktg_forward_remember_mode, ForwardRememberMode);
|
||||
|
||||
auto forwardModeText = rpl::single(
|
||||
ForwardMode()
|
||||
) | rpl::then(
|
||||
ForwardModeChanges()
|
||||
) | rpl::map([] {
|
||||
return ForwardModeLabel(ForwardMode());
|
||||
});
|
||||
|
||||
AddButtonWithLabel(
|
||||
container,
|
||||
rktr("ktg_forward_mode"),
|
||||
forwardModeText,
|
||||
st::settingsButton
|
||||
)->addClickHandler([=] {
|
||||
Ui::show(Box<::Kotato::RadioBox>(
|
||||
ktr("ktg_forward_mode"),
|
||||
ForwardMode(),
|
||||
3,
|
||||
ForwardModeLabel,
|
||||
[=] (int value) {
|
||||
SetForwardMode(value);
|
||||
::Kotato::JsonSettings::Write();
|
||||
}, false));
|
||||
});
|
||||
|
||||
auto forwardGroupingModeText = rpl::single(
|
||||
ForwardGroupingMode()
|
||||
) | rpl::then(
|
||||
ForwardGroupingModeChanges()
|
||||
) | rpl::map([] {
|
||||
return GroupingModeLabel(ForwardGroupingMode());
|
||||
});
|
||||
|
||||
AddButtonWithLabel(
|
||||
container,
|
||||
rktr("ktg_forward_grouping_mode"),
|
||||
forwardGroupingModeText,
|
||||
st::settingsButton
|
||||
)->addClickHandler([=] {
|
||||
Ui::show(Box<::Kotato::RadioBox>(
|
||||
ktr("ktg_forward_grouping_mode"),
|
||||
ForwardGroupingMode(),
|
||||
3,
|
||||
GroupingModeLabel,
|
||||
GroupingModeDescription,
|
||||
[=] (int value) {
|
||||
SetForwardGroupingMode(value);
|
||||
::Kotato::JsonSettings::Write();
|
||||
}, false));
|
||||
});
|
||||
|
||||
SettingsMenuCSwitch(ktg_settings_forward_retain_selection, ForwardRetainSelection);
|
||||
SettingsMenuCSwitch(ktg_settings_forward_chat_on_click, ForwardChatOnClick);
|
||||
|
||||
|
@ -1272,10 +1272,29 @@ QPointer<Ui::RpWidget> ShowForwardMessagesBox(
|
||||
not_null<Window::SessionNavigation*> navigation,
|
||||
MessageIdsList &&items,
|
||||
FnMut<void()> &&successCallback) {
|
||||
const auto options = [] {
|
||||
switch (ForwardMode()) {
|
||||
case 1: return Data::ForwardOptions::NoSenderNames;
|
||||
case 2: return Data::ForwardOptions::NoNamesAndCaptions;
|
||||
default: return Data::ForwardOptions::PreserveInfo;
|
||||
}
|
||||
}();
|
||||
|
||||
const auto groupOptions = [] {
|
||||
switch (ForwardGroupingMode()) {
|
||||
case 1: return Data::GroupingOptions::RegroupAll;
|
||||
case 2: return Data::GroupingOptions::Separate;
|
||||
default: return Data::GroupingOptions::GroupAsIs;
|
||||
}
|
||||
}();
|
||||
|
||||
return ShowForwardMessagesBox(
|
||||
navigation,
|
||||
Data::ForwardDraft{ .ids = std::move(items) },
|
||||
std::move(successCallback));
|
||||
Data::ForwardDraft{
|
||||
.ids = std::move(items),
|
||||
.options = options,
|
||||
.groupOptions = groupOptions,
|
||||
}, std::move(successCallback));
|
||||
}
|
||||
|
||||
QPointer<Ui::RpWidget> ShowSendNowMessagesBox(
|
||||
|
Loading…
x
Reference in New Issue
Block a user