Internal rework of settings

This commit is contained in:
Eric Kotato 2022-01-10 03:16:41 +03:00
parent f0676bbe46
commit 845957f33a
101 changed files with 2191 additions and 2395 deletions

View file

@ -792,14 +792,12 @@ PRIVATE
kotato/boxes/kotato_radio_box.h
kotato/boxes/kotato_unpin_box.cpp
kotato/boxes/kotato_unpin_box.h
kotato/json_settings.cpp
kotato/json_settings.h
kotato/settings_menu.cpp
kotato/settings_menu.h
kotato/settings.cpp
kotato/settings.h
kotato/kotato_lang.cpp
kotato/kotato_lang.h
kotato/kotato_settings.cpp
kotato/kotato_settings.h
kotato/kotato_settings_menu.cpp
kotato/kotato_settings_menu.h
kotato/kotato_version.h
lang/lang_cloud_manager.cpp
lang/lang_cloud_manager.h

View file

@ -7,10 +7,10 @@ https://github.com/telegramdesktop/tdesktop/blob/master/LEGAL
*/
#include "api/api_chat_filters.h"
#include "kotato/kotato_settings.h"
#include "data/data_session.h"
#include "data/data_chat_filters.h"
#include "main/main_session.h"
#include "kotato/json_settings.h"
#include "apiwrap.h"
namespace Api {
@ -26,7 +26,7 @@ void SaveNewFilterPinned(
filterId,
order);
if (filter.isLocal()) {
filters.saveLocal(filterId);
filters.saveLocal();
Kotato::JsonSettings::Write();
} else {
session->api().request(MTPmessages_UpdateDialogFilter(

View file

@ -254,12 +254,7 @@ void ConfirmInviteBox::paintEvent(QPaintEvent *e) {
if (const auto image = _photo->image(Data::PhotoSize::Small)) {
auto source = [=] {
const auto size = st::confirmInvitePhotoSize;
switch (cUserpicCornersType()) {
case 0: return image->pixRounded(size, size, ImageRoundRadius::None);
case 1: return image->pixRounded(size, size, ImageRoundRadius::Small);
case 2: return image->pixRounded(size, size, ImageRoundRadius::Large);
default: return image->pixCircled(size, size);
}
return image->pixRounded(size, size, KotatoImageRoundRadius());
}();
p.drawPixmap(
(width() - st::confirmInvitePhotoSize) / 2,

View file

@ -7,6 +7,7 @@ https://github.com/telegramdesktop/tdesktop/blob/master/LEGAL
*/
#include "apiwrap.h"
#include "kotato/kotato_settings.h"
#include "api/api_authorizations.h"
#include "api/api_attached_stickers.h"
#include "api/api_blocked_peers.h"
@ -3116,7 +3117,7 @@ void ApiWrap::forwardMessages(
FnMut<void()> &&successCallback) {
if (draft.options != Data::ForwardOptions::PreserveInfo
&& (draft.groupOptions == Data::GroupingOptions::RegroupAll
|| cForwardForceOld())) {
|| ::Kotato::JsonSettings::GetBool("forward_force_old_unquoted"))) {
forwardMessagesUnquoted(std::move(draft), action, std::move(successCallback));
return;
}

View file

@ -8,6 +8,7 @@ https://github.com/telegramdesktop/tdesktop/blob/master/LEGAL
#include "boxes/filters/edit_filter_box.h"
#include "kotato/kotato_lang.h"
#include "kotato/kotato_settings.h"
#include "boxes/filters/edit_filter_chats_list.h"
#include "chat_helpers/emoji_suggestions_widget.h"
#include "ui/layers/generic_box.h"
@ -27,7 +28,6 @@ https://github.com/telegramdesktop/tdesktop/blob/master/LEGAL
#include "data/data_session.h"
#include "core/application.h"
#include "core/core_settings.h"
#include "kotato/json_settings.h"
#include "settings/settings_common.h"
#include "base/event_filter.h"
#include "lang/lang_keys.h"
@ -825,7 +825,7 @@ void EditExistingFilter(
if (result.isLocal()) {
filters->set(result);
filters->saveLocal(id);
filters->saveLocal();
needSave = true;
} else {
const auto tl = result.tl();

View file

@ -312,22 +312,18 @@ void PaintFilterChatsTypeIcon(
auto hq = PainterHighQualityEnabler(p);
p.setBrush(color->b);
p.setPen(Qt::NoPen);
switch (cUserpicCornersType()) {
case 0:
p.drawRoundedRect(
rect,
0, 0);
switch (KotatoImageRoundRadius()) {
case ImageRoundRadius::None:
p.drawRoundedRect(rect, 0, 0);
break;
case 1:
p.drawRoundedRect(
rect,
case ImageRoundRadius::Small:
p.drawRoundedRect(rect,
st::buttonRadius, st::buttonRadius);
break;
case 2:
p.drawRoundedRect(
rect,
case ImageRoundRadius::Large:
p.drawRoundedRect(rect,
st::dateRadius, st::dateRadius);
break;

View file

@ -821,22 +821,18 @@ void PeerListRow::paintDisabledCheckUserpic(
p.setPen(userpicBorderPen);
p.setBrush(Qt::NoBrush);
switch (cUserpicCornersType()) {
case 0:
p.drawRoundedRect(
userpicEllipse,
0, 0);
switch (KotatoImageRoundRadius()) {
case ImageRoundRadius::None:
p.drawRoundedRect(userpicEllipse, 0, 0);
break;
case 1:
p.drawRoundedRect(
userpicEllipse,
case ImageRoundRadius::Small:
p.drawRoundedRect(userpicEllipse,
st::buttonRadius, st::buttonRadius);
break;
case 2:
p.drawRoundedRect(
userpicEllipse,
case ImageRoundRadius::Large:
p.drawRoundedRect(userpicEllipse,
st::dateRadius, st::dateRadius);
break;

View file

@ -7,6 +7,7 @@ https://github.com/telegramdesktop/tdesktop/blob/master/LEGAL
*/
#include "boxes/send_files_box.h"
#include "kotato/kotato_settings.h"
#include "lang/lang_keys.h"
#include "storage/localstorage.h"
#include "storage/storage_media_prepare.h"
@ -977,7 +978,7 @@ void SendFilesBox::saveSendWaySettings() {
}
if (_list.overrideSendImagesAsPhotos == way.sendImagesAsPhotos()
|| _sendImagesAsPhotos->isHidden()
|| !cRememberCompressImages()) {
|| !::Kotato::JsonSettings::GetBool("remember_compress_images")) {
way.setSendImagesAsPhotos(oldWay.sendImagesAsPhotos());
}
if (way != oldWay) {

View file

@ -7,9 +7,9 @@ https://github.com/telegramdesktop/tdesktop/blob/master/LEGAL
*/
#include "boxes/share_box.h"
#include "dialogs/dialogs_indexed_list.h"
#include "kotato/kotato_lang.h"
#include "kotato/json_settings.h"
#include "kotato/kotato_settings.h"
#include "dialogs/dialogs_indexed_list.h"
#include "lang/lang_keys.h"
#include "mainwindow.h"
#include "mainwidget.h"
@ -275,7 +275,8 @@ void ShareBox::prepare() {
});
_select->setResizedCallback([=] { updateScrollSkips(); });
_select->setSubmittedCallback([=](Qt::KeyboardModifiers modifiers) {
if ((modifiers.testFlag(Qt::ControlModifier) && !cForwardChatOnClick())
if ((modifiers.testFlag(Qt::ControlModifier)
&& !::Kotato::JsonSettings::GetBool("forward_on_click"))
|| modifiers.testFlag(Qt::MetaModifier)) {
submit({});
} else if (modifiers.testFlag(Qt::ShiftModifier)) {
@ -284,7 +285,8 @@ void ShareBox::prepare() {
}
} else {
_inner->selectActive();
if (!modifiers.testFlag(Qt::ControlModifier) || cForwardChatOnClick()) {
if (!modifiers.testFlag(Qt::ControlModifier)
|| ::Kotato::JsonSettings::GetBool("forward_on_click")) {
_inner->tryGoToChat();
} else {
_inner->selectionMade();
@ -536,9 +538,9 @@ bool ShareBox::showMenu(not_null<Ui::IconButton*> button) {
_menu->addAction(ktr(langKey), [this, option, settingsKey] {
_descriptor.draft->options = option;
updateAdditionalTitle();
if (cForwardRememberMode()) {
SetForwardMode(settingsKey);
Kotato::JsonSettings::Write();
if (::Kotato::JsonSettings::GetBool("forward_remember_mode")) {
::Kotato::JsonSettings::Set("forward_mode", settingsKey);
::Kotato::JsonSettings::Write();
}
});
}
@ -556,9 +558,9 @@ bool ShareBox::showMenu(not_null<Ui::IconButton*> button) {
_menu->addAction(ktr(langKey), [this, option, settingsKey] {
_descriptor.draft->groupOptions = option;
updateAdditionalTitle();
if (cForwardRememberMode()) {
SetForwardGroupingMode(settingsKey);
Kotato::JsonSettings::Write();
if (::Kotato::JsonSettings::GetBool("forward_remember_mode")) {
::Kotato::JsonSettings::Set("forward_grouping_mode", settingsKey);
::Kotato::JsonSettings::Write();
}
});
}
@ -1121,7 +1123,8 @@ void ShareBox::Inner::tryGoToChat() {
&& _selected.size() == 1) {
if (_submitRequest && _selected.front()->isSelf()) {
_submitRequest();
} else if (_goToChatRequest && cForwardChatOnClick()) {
} else if (_goToChatRequest
&& ::Kotato::JsonSettings::GetBool("forward_on_click")) {
_goToChatRequest();
}
_hadSelection = true;

View file

@ -8,6 +8,7 @@ https://github.com/telegramdesktop/tdesktop/blob/master/LEGAL
#include "calls/calls_box_controller.h"
#include "kotato/kotato_lang.h"
#include "kotato/kotato_settings.h"
#include "lang/lang_keys.h"
#include "ui/boxes/confirm_box.h"
#include "ui/effects/ripple_animation.h"
@ -390,7 +391,7 @@ void BoxController::rowRightActionClicked(not_null<PeerListRow*> row) {
auto user = row->peer()->asUser();
Assert(user != nullptr);
if (cConfirmBeforeCall()) {
if (::Kotato::JsonSettings::GetBool("confirm_before_calls")) {
Ui::show(Box<Ui::ConfirmBox>(ktr("ktg_call_sure"), ktr("ktg_call_button"), [=] {
Ui::hideLayer();
Core::App().calls().startOutgoingCall(user, false);

View file

@ -7,6 +7,7 @@ https://github.com/telegramdesktop/tdesktop/blob/master/LEGAL
*/
#include "calls/calls_top_bar.h"
#include "kotato/kotato_settings.h"
#include "ui/effects/cross_line.h"
#include "ui/paint/blobs_linear.h"
#include "ui/widgets/buttons.h"
@ -250,7 +251,7 @@ TopBar::TopBar(
st::groupCallTopBarUserpics,
rpl::single(true),
[=] { updateUserpics(); },
cUserpicCornersType()))
::Kotato::JsonSettings::GetInt("userpic_corner_type")))
, _durationLabel(_call
? object_ptr<Ui::LabelSimple>(this, st::callBarLabel)
: object_ptr<Ui::LabelSimple>(nullptr))

View file

@ -106,22 +106,25 @@ void Userpic::paint() {
_mutePosition.y() - _muteSize / 2,
_muteSize,
_muteSize);
switch (cUserpicCornersType()) {
case 0:
switch (KotatoImageRoundRadius()) {
case ImageRoundRadius::None:
p.drawRoundedRect(rect, 0, 0);
break;
case 1:
p.drawRoundedRect(rect, st::buttonRadius, st::buttonRadius);
case ImageRoundRadius::Small:
p.drawRoundedRect(rect,
st::buttonRadius, st::buttonRadius);
break;
case 2:
p.drawRoundedRect(rect, st::dateRadius, st::dateRadius);
case ImageRoundRadius::Large:
p.drawRoundedRect(rect,
st::dateRadius, st::dateRadius);
break;
default:
p.drawEllipse(rect);
}
st::callMutedPeerIcon.paintInCenter(p, rect);
}
}
@ -182,7 +185,7 @@ void Userpic::refreshPhoto() {
void Userpic::createCache(Image *image) {
const auto size = this->size();
const auto real = size * cIntRetinaFactor();
auto options = Images::Option::Smooth | Images::Option::Circled;
// auto options = Images::Option::Smooth | Images::Option::Circled;
// _useTransparency ? (Images::Option::RoundedLarge | Images::Option::RoundedTopLeft | Images::Option::RoundedTopRight | Images::Option::Smooth) : Images::Option::None;
if (image) {
auto width = image->width();
@ -197,25 +200,7 @@ void Userpic::createCache(Image *image) {
const auto callRounded = [=](const ImageRoundRadius radius) {
return image->pixRounded(width, height, radius, RectPart::AllCorners, size, size);
};
switch (cUserpicCornersType()) {
case 0:
_userPhoto = callRounded(ImageRoundRadius::None);
break;
case 1:
_userPhoto = callRounded(ImageRoundRadius::Small);
break;
case 2:
_userPhoto = callRounded(ImageRoundRadius::Large);
break;
default:
_userPhoto = image->pixNoCache(
width,
height,
options,
size,
size);
_userPhoto.setDevicePixelRatio(cRetinaFactor());
}
_userPhoto = callRounded(KotatoImageRoundRadius());
} else {
auto filled = QImage(QSize(real, real), QImage::Format_ARGB32_Premultiplied);
filled.setDevicePixelRatio(cRetinaFactor());

View file

@ -7,6 +7,7 @@ https://github.com/telegramdesktop/tdesktop/blob/master/LEGAL
*/
#include "chat_helpers/stickers_emoji_image_loader.h"
#include "kotato/kotato_settings.h"
#include "styles/style_chat.h"
namespace Stickers {
@ -33,7 +34,9 @@ QImage EmojiImageLoader::prepare(EmojiPtr emoji) const {
auto tinted = QImage(
QSize(st::largeEmojiSize, st::largeEmojiSize) * factor,
QImage::Format_ARGB32_Premultiplied);
tinted.fill(BigEmojiOutline() ? Qt::white : QColor(0, 0, 0, 0));
tinted.fill(::Kotato::JsonSettings::GetBool("big_emoji_outline")
? Qt::white
: QColor(0, 0, 0, 0));
if (loaded) {
QPainter p(&tinted);
p.setCompositionMode(QPainter::CompositionMode_DestinationIn);

View file

@ -7,6 +7,7 @@ https://github.com/telegramdesktop/tdesktop/blob/master/LEGAL
*/
#include "chat_helpers/stickers_emoji_pack.h"
#include "kotato/kotato_settings.h"
#include "chat_helpers/stickers_emoji_image_loader.h"
#include "history/history_item.h"
#include "lottie/lottie_common.h"
@ -106,7 +107,8 @@ EmojiPack::EmojiPack(not_null<Main::Session*> session)
refreshAll();
}, _lifetime);
BigEmojiOutlineChanges(
::Kotato::JsonSettings::Events(
"big_emoji_outline"
) | rpl::start_with_next([=] {
_images.clear();
refreshAll();

View file

@ -7,6 +7,7 @@ https://github.com/telegramdesktop/tdesktop/blob/master/LEGAL
*/
#include "chat_helpers/stickers_list_widget.h"
#include "kotato/kotato_settings.h"
#include "data/data_document.h"
#include "data/data_document_media.h"
#include "data/data_session.h"
@ -976,7 +977,8 @@ StickersListWidget::StickersListWidget(
TabbedSelector::Action::Update
) | rpl::start_to_stream(_choosingUpdated, lifetime());
RecentStickersLimitChanges(
::Kotato::JsonSettings::Events(
"recent_stickers_limit"
) | rpl::start_with_next([=] {
refreshStickers();
}, lifetime());
@ -2616,7 +2618,7 @@ auto StickersListWidget::collectRecentStickers() -> std::vector<Sticker> {
_custom.reserve(cloudCount + recent.size() + customCount);
auto add = [&](not_null<DocumentData*> document, bool custom) {
if (result.size() >= RecentStickersLimit()) {
if (result.size() >= ::Kotato::JsonSettings::GetInt("recent_stickers_limit")) {
return;
}
const auto i = ranges::find(result, document, &Sticker::document);

View file

@ -9,7 +9,6 @@ https://github.com/telegramdesktop/tdesktop/blob/master/LEGAL
#include "core/version.h"
#include "settings.h"
#include "kotato/settings.h"
enum {
MaxSelectedItems = 100,

View file

@ -8,6 +8,7 @@ https://github.com/telegramdesktop/tdesktop/blob/master/LEGAL
#include "core/application.h"
#include "kotato/kotato_lang.h"
#include "kotato/kotato_settings.h"
#include "data/data_abstract_structure.h"
#include "data/data_photo.h"
#include "data/data_document.h"
@ -218,9 +219,13 @@ void Application::run() {
startLocalStorage();
Kotato::Lang::Load(Lang::GetInstance().baseId(), Lang::GetInstance().id());
if (!cQtScale()) {
#if QT_VERSION < QT_VERSION_CHECK(6, 0, 0)
if (!::Kotato::JsonSettings::GetBool("qt_scale")) {
#endif
ValidateScale();
#if QT_VERSION < QT_VERSION_CHECK(6, 0, 0)
}
#endif
refreshGlobalProxy(); // Depends on app settings being read.

View file

@ -97,8 +97,7 @@ std::unique_ptr<Changelogs> Changelogs::Create(
const auto oldVersion = local.oldVersion();
const auto oldKotatoVersion = Local::oldKotatoVersion();
local.clearOldVersion();
return (!cKotatoFirstRun()
&& oldVersion != 0
return (oldVersion != 0
&& oldKotatoVersion < AppKotatoVersion)
? std::make_unique<Changelogs>(session, oldVersion, oldKotatoVersion)
: nullptr;

View file

@ -7,6 +7,7 @@ https://github.com/telegramdesktop/tdesktop/blob/master/LEGAL
*/
#include "core/crash_reports.h"
#include "kotato/kotato_settings.h"
#include "kotato/kotato_version.h"
#include "platform/platform_specific.h"
#include "base/platform/base_platform_info.h"
@ -309,7 +310,7 @@ QString PlatformString() {
void StartCatching(not_null<Core::Launcher*> launcher) {
#ifndef DESKTOP_APP_DISABLE_CRASH_REPORTS
ProcessAnnotations["Binary"] = cExeName().toUtf8().constData();
ProcessAnnotations["ApiId"] = QString::number(cApiId()).toUtf8().constData();
ProcessAnnotations["ApiId"] = QString::number(::Kotato::JsonSettings::GetInt("api_id")).toUtf8().constData();
ProcessAnnotations["Version"] = (cAlphaVersion() ? qsl("%1 %2").arg(cAlphaVersion()).arg(AppKotatoTestBranch) : (AppBetaVersion ? qsl("%1 beta") : qsl("%1")).arg(AppKotatoVersion)).toUtf8().constData();
ProcessAnnotations["Launched"] = QDateTime::currentDateTime().toString("dd.MM.yyyy hh:mm:ss").toUtf8().constData();
ProcessAnnotations["Platform"] = PlatformString().toUtf8().constData();

View file

@ -7,6 +7,7 @@ https://github.com/telegramdesktop/tdesktop/blob/master/LEGAL
*/
#include "core/launcher.h"
#include "kotato/kotato_settings.h"
#include "kotato/kotato_version.h"
#include "platform/platform_launcher.h"
#include "platform/platform_specific.h"
@ -18,7 +19,6 @@ https://github.com/telegramdesktop/tdesktop/blob/master/LEGAL
#include "core/update_checker.h"
#include "core/sandbox.h"
#include "base/concurrent_timer.h"
#include "kotato/json_settings.h"
#include <QtCore/QLoggingCategory>
@ -319,6 +319,9 @@ void Launcher::init() {
}
int Launcher::exec() {
// This should be called before init to load default
// values and set some options that are not stored in JSON.
Kotato::JsonSettings::Start();
init();
if (cLaunchMode() == LaunchModeFixPrevious) {
@ -329,12 +332,14 @@ int Launcher::exec() {
// Must be started before Platform is started.
Logs::start(this);
Kotato::JsonSettings::Start();
Kotato::JsonSettings::Load();
if (cQtScale()) {
#if QT_VERSION < QT_VERSION_CHECK(6, 0, 0)
if (::Kotato::JsonSettings::GetBool("qt_scale")) {
QApplication::setAttribute(Qt::AA_DisableHighDpiScaling, false);
QApplication::setAttribute(Qt::AA_EnableHighDpiScaling, true);
}
#endif
if (Logs::DebugEnabled()) {
const auto openalLogPath = QDir::toNativeSeparators(
@ -356,12 +361,12 @@ int Launcher::exec() {
// Must be started before Sandbox is created.
Platform::start();
if (cUseEnvApi()
if (::Kotato::JsonSettings::GetBool("api_use_env")
&& qEnvironmentVariableIsSet(kApiIdVarName.utf8().constData())
&& qEnvironmentVariableIsSet(kApiHashVarName.utf8().constData())) {
cSetApiId(qgetenv(kApiIdVarName.utf8().constData()).toInt());
cSetApiHash(QString::fromLatin1(qgetenv(kApiHashVarName.utf8().constData())));
cSetApiFromStartParams(false);
::Kotato::JsonSettings::Set("api_id", qgetenv(kApiIdVarName.utf8().constData()).toInt());
::Kotato::JsonSettings::Set("api_hash", QString::fromLatin1(qgetenv(kApiHashVarName.utf8().constData())));
::Kotato::JsonSettings::Set("api_start_params", false);
}
auto result = executeApplication();
@ -561,13 +566,13 @@ void Launcher::processArguments() {
: value;
}
gUseEnvApi = !parseResult.contains("-no-env-api");
::Kotato::JsonSettings::Set("api_use_env", !parseResult.contains("-no-env-api"));
auto customApiId = parseResult.value("-api-id", {}).join(QString()).toInt();
auto customApiHash = parseResult.value("-api-hash", {}).join(QString());
if (customApiId > 0 && !customApiHash.isEmpty()) {
gApiId = customApiId;
gApiHash = customApiHash;
gApiFromStartParams = true;
::Kotato::JsonSettings::Set("api_id", customApiId);
::Kotato::JsonSettings::Set("api_hash", customApiHash);
::Kotato::JsonSettings::Set("api_start_params", true);
}
}

View file

@ -7,6 +7,7 @@ https://github.com/telegramdesktop/tdesktop/blob/master/LEGAL
*/
#include "core/sandbox.h"
#include "kotato/kotato_settings.h"
#include "base/platform/base_platform_info.h"
#include "platform/platform_specific.h"
#include "mainwidget.h"
@ -241,7 +242,11 @@ void Sandbox::setupScreenScale() {
}
const auto ratio = devicePixelRatio();
if (ratio > 1. || cQtScale()) {
if (ratio > 1.
#if QT_VERSION < QT_VERSION_CHECK(6, 0, 0)
|| ::Kotato::JsonSettings::GetBool("qt_scale")
#endif
) {
if (!Platform::IsMac() || (ratio != 2.)) {
LOG(("Found non-trivial Device Pixel Ratio: %1").arg(ratio));
LOG(("Environmental variables: QT_DEVICE_PIXEL_RATIO='%1'").arg(qEnvironmentVariable("QT_DEVICE_PIXEL_RATIO")));
@ -250,7 +255,11 @@ void Sandbox::setupScreenScale() {
LOG(("Environmental variables: QT_SCREEN_SCALE_FACTORS='%1'").arg(qEnvironmentVariable("QT_SCREEN_SCALE_FACTORS")));
}
style::SetDevicePixelRatio(int(ratio));
if (Platform::IsMac() && ratio == 2. && !cQtScale()) {
if (Platform::IsMac() && ratio == 2.
#if QT_VERSION < QT_VERSION_CHECK(6, 0, 0)
&& !::Kotato::JsonSettings::GetBool("qt_scale")
#endif
) {
cSetScreenScale(110); // 110% for Retina screens by default.
} else {
cSetScreenScale(style::kScaleDefault);
@ -363,9 +372,11 @@ void Sandbox::singleInstanceChecked() {
LOG(("App Info: Detected another instance"));
}
if (!cQtScale()) {
#if QT_VERSION < QT_VERSION_CHECK(6, 0, 0)
if (!::Kotato::JsonSettings::GetBool("qt_scale")) {
Ui::DisableCustomScaling();
}
#endif
refreshGlobalProxy();
if (!Logs::started() || !Logs::instanceChecked()) {

View file

@ -7,6 +7,7 @@ https://github.com/telegramdesktop/tdesktop/blob/master/LEGAL
*/
#include "core/ui_integration.h"
#include "kotato/kotato_settings.h"
#include "core/local_url_handlers.h"
#include "core/file_utilities.h"
#include "core/application.h"
@ -49,7 +50,7 @@ const auto kBadPrefix = u"http://"_q;
const auto domains = config.get<std::vector<QString>>(
"autologin_domains",
{});
if (!cTelegramSitesAutologin()
if (!::Kotato::JsonSettings::GetBool("telegram_sites_autologin")
|| token.isEmpty()
|| domain.isEmpty()
|| !ranges::contains(domains, domain)) {
@ -132,13 +133,13 @@ void UiIntegration::activationFromTopPanel() {
style::CustomFontSettings UiIntegration::fontSettings() {
return {
cMainFont(),
cSemiboldFont(),
cMonospaceFont(),
cFontSize(),
cSemiboldFontIsBold(),
cUseSystemFont(),
cUseOriginalMetrics(),
::Kotato::JsonSettings::GetString("fonts/main"),
::Kotato::JsonSettings::GetString("fonts/semibold"),
::Kotato::JsonSettings::GetString("fonts/monospaced"),
::Kotato::JsonSettings::GetInt("fonts/size"),
::Kotato::JsonSettings::GetBool("fonts/semibold_is_bold"),
::Kotato::JsonSettings::GetBool("fonts/use_system_font"),
::Kotato::JsonSettings::GetBool("fonts/use_original_metrics"),
};
}

View file

@ -7,6 +7,7 @@ https://github.com/telegramdesktop/tdesktop/blob/master/LEGAL
*/
#include "data/data_chat_filters.h"
#include "kotato/kotato_settings.h"
#include "history/history.h"
#include "data/data_peer.h"
#include "data/data_user.h"
@ -30,8 +31,204 @@ constexpr auto kLoadExceptionsAfter = 100;
constexpr auto kLoadExceptionsPerRequest = 100;
constexpr auto kFiltersLimit = 10;
const std::map<ChatFilter::Flag, QString> LocalFolderSettingsFlags {
{ ChatFilter::Flag::Contacts, qsl("include_contacts") },
{ ChatFilter::Flag::NonContacts, qsl("include_non_contacts") },
{ ChatFilter::Flag::Groups, qsl("include_groups") },
{ ChatFilter::Flag::Channels, qsl("include_channels") },
{ ChatFilter::Flag::Bots, qsl("include_bots") },
{ ChatFilter::Flag::NoMuted, qsl("exclude_muted") },
{ ChatFilter::Flag::NoRead, qsl("exclude_read") },
{ ChatFilter::Flag::NoArchived, qsl("exclude_archived") },
{ ChatFilter::Flag::Owned, qsl("exclude_not_owned") },
{ ChatFilter::Flag::Admin, qsl("exclude_not_admin") },
{ ChatFilter::Flag::NotOwned, qsl("exclude_owned") },
{ ChatFilter::Flag::NotAdmin, qsl("exclude_admin") },
{ ChatFilter::Flag::Recent, qsl("exclude_non_recent") },
{ ChatFilter::Flag::NoFilter, qsl("exclude_filtered") },
};
bool ReadOption(QJsonObject obj, QString key, std::function<void(QJsonValue)> callback) {
const auto it = obj.constFind(key);
if (it == obj.constEnd()) {
return false;
}
callback(*it);
return true;
}
bool ReadStringOption(QJsonObject obj, QString key, std::function<void(QString)> callback) {
auto readResult = false;
auto readValueResult = ReadOption(obj, key, [&](QJsonValue v) {
if (v.isString()) {
callback(v.toString());
readResult = true;
}
});
return (readValueResult && readResult);
}
bool ReadIntOption(QJsonObject obj, QString key, std::function<void(int)> callback) {
auto readResult = false;
auto readValueResult = ReadOption(obj, key, [&](QJsonValue v) {
if (v.isDouble()) {
callback(v.toInt());
readResult = true;
}
});
return (readValueResult && readResult);
}
bool ReadBoolOption(QJsonObject obj, QString key, std::function<void(bool)> callback) {
auto readResult = false;
auto readValueResult = ReadOption(obj, key, [&](QJsonValue v) {
if (v.isBool()) {
callback(v.toBool());
readResult = true;
}
});
return (readValueResult && readResult);
}
bool ReadArrayOption(QJsonObject obj, QString key, std::function<void(QJsonArray)> callback) {
auto readResult = false;
auto readValueResult = ReadOption(obj, key, [&](QJsonValue v) {
if (v.isArray()) {
callback(v.toArray());
readResult = true;
}
});
return (readValueResult && readResult);
}
} // namespace
QJsonObject LocalFolder::toJson() {
auto folderObject = QJsonObject();
folderObject.insert(qsl("id"), id);
folderObject.insert(qsl("order"), cloudOrder);
folderObject.insert(qsl("name"), name);
folderObject.insert(qsl("emoticon"), emoticon);
for (const auto &[flag, option] : LocalFolderSettingsFlags) {
if (flags & flag) {
folderObject.insert(option, true);
}
}
const auto peerToStr = [](uint64 peer) {
auto peerId = PeerId(peer);
return (peerIsChannel(peerId))
? qsl("channel")
: (peerIsChat(peerId))
? qsl("chat")
: qsl("user");
};
const auto peerToLocalBare = [](uint64 peer) {
auto peerId = PeerId(peer);
return QString::number((peerIsChannel(peerId))
? peerToChannel(peerId).bare
: (peerIsChat(peerId))
? peerToChat(peerId).bare
: peerToUser(peerId).bare);
};
const auto fillChatsArray = [peerToStr, peerToLocalBare] (const std::vector<uint64> &chats) -> QJsonArray {
auto result = QJsonArray();
for (auto peer : chats) {
auto peerObj = QJsonObject();
peerObj.insert(qsl("type"), peerToStr(peer));
peerObj.insert(qsl("id"), peerToLocalBare(peer));
result << peerObj;
}
return result;
};
folderObject.insert(qsl("never"), fillChatsArray(never));
folderObject.insert(qsl("pinned"), fillChatsArray(pinned));
folderObject.insert(qsl("always"), fillChatsArray(always));
return folderObject;
}
LocalFolder MakeLocalFolder(const QJsonObject &obj) {
auto result = LocalFolder();
ReadIntOption(obj, "id", [&](auto v) {
result.id = v;
});
ReadIntOption(obj, "order", [&](auto v) {
result.cloudOrder = v;
});
ReadStringOption(obj, "name", [&](auto v) {
result.name = v;
});
ReadStringOption(obj, "emoticon", [&](auto v) {
result.emoticon = v;
});
for (const auto &[flag, option] : LocalFolderSettingsFlags) {
ReadBoolOption(obj, option, [&](auto v) {
if (v) {
result.flags |= flag;
}
});
}
const auto readChatsArray = [obj] (const QString &key, std::vector<uint64> &chats) {
ReadArrayOption(obj, key, [&](auto a) {
for (auto i = a.constBegin(), e = a.constEnd(); i != e; ++i) {
if (!(*i).isObject()) {
continue;
}
auto peer = (*i).toObject();
BareId peerId = 0;
auto isPeerIdRead = ReadIntOption(peer, "id", [&](auto v) {
peerId = v;
});
if (!isPeerIdRead) {
isPeerIdRead = ReadStringOption(peer, "id", [&](auto v) {
peerId = static_cast<BareId>(v.toLongLong());
});
}
if (peerId == 0 || !isPeerIdRead) {
continue;
}
auto isPeerTypeRead = ReadStringOption(peer, "type", [&](auto v) {
peerId = (QString::compare(v.toLower(), "channel") == 0)
? peerFromChannel(ChannelId(peerId)).value
: (QString::compare(v.toLower(), "chat") == 0)
? peerFromChat(ChatId(peerId)).value
: peerFromUser(UserId(peerId)).value;
});
if (!isPeerTypeRead) {
peerId = peerFromUser(UserId(peerId)).value;
}
chats.push_back(peerId);
}
});
};
readChatsArray(qsl("never"), result.never);
readChatsArray(qsl("pinned"), result.pinned);
readChatsArray(qsl("always"), result.always);
return result;
}
ChatFilter::ChatFilter(FilterId id, bool isLocal)
: _id(id)
, _isLocal(isLocal) {
@ -46,7 +243,8 @@ ChatFilter::ChatFilter(
std::vector<not_null<History*>> pinned,
base::flat_set<not_null<History*>> never,
bool isDefault,
bool isLocal)
bool isLocal,
int cloudLocalOrder)
: _id(id)
, _title(title)
, _iconEmoji(iconEmoji)
@ -55,13 +253,13 @@ ChatFilter::ChatFilter(
, _never(std::move(never))
, _flags(flags)
, _isDefault(isDefault)
, _isLocal(isLocal) {
, _isLocal(isLocal)
, _cloudLocalOrder(cloudLocalOrder) {
}
ChatFilter ChatFilter::local(
const LocalFolder &data,
not_null<Session*> owner) {
const auto flags = Flag(data.flags);
auto &&to_histories = ranges::view::transform([&](
const uint64 &filterPeer) {
PeerData *peer = nullptr;
@ -102,12 +300,13 @@ ChatFilter ChatFilter::local(
data.id,
data.name,
data.emoticon,
flags,
data.flags,
std::move(list),
std::move(pinned),
{ never.begin(), never.end() },
(data.id == defaultFilterId),
true);
true,
data.cloudOrder);
}
ChatFilter ChatFilter::FromTL(
@ -214,7 +413,7 @@ MTPDialogFilter ChatFilter::tl(FilterId replaceId) const {
MTP_vector<MTPInputPeer>(never));
}
LocalFolder ChatFilter::toLocal(int cloudOrder, FilterId replaceId) const {
LocalFolder ChatFilter::toLocal(FilterId replaceId) const {
auto always = _always;
auto pinned = std::vector<uint64>();
pinned.reserve(_pinned.size());
@ -235,18 +434,15 @@ LocalFolder ChatFilter::toLocal(int cloudOrder, FilterId replaceId) const {
const auto &peer = history->peer;
never.push_back(peer->id.value);
}
const auto &session = App::main()->session();
return {
.id = replaceId ? replaceId : _id,
.ownerId = session.userId().bare,
.isTest = session.mtp().isTestMode(),
.cloudOrder = cloudOrder,
.cloudOrder = _cloudLocalOrder,
.name = _title,
.emoticon = _iconEmoji,
.always = include,
.never = never,
.pinned = pinned,
.flags = _flags.value()
.flags = _flags
};
}
@ -442,7 +638,9 @@ void ChatFilters::load(bool force) {
void ChatFilters::received(const QVector<MTPDialogFilter> &list) {
const auto account = &_owner->session().account();
const auto localFilters = cRefLocalFolders();
const auto accountId = account->session().userId().bare;
const auto isTestAccount = account->mtp().isTestMode();
const auto localFilters = ::Kotato::JsonSettings::GetJsonArray("folders/local", accountId, isTestAccount);
auto position = 0;
auto originalPosition = 0;
auto changed = false;
@ -467,36 +665,36 @@ void ChatFilters::received(const QVector<MTPDialogFilter> &list) {
// First we're adding cloud filters and corresponding local filters.
for (const auto &filter : list) {
addToList(ChatFilter::FromTL(filter, _owner));
for (const auto &localFilter : localFilters) {
if (!account->isCurrent(localFilter.ownerId, localFilter.isTest)
|| localFilter.cloudOrder != originalPosition) {
auto local = MakeLocalFolder(localFilter.toObject());
if (local.cloudOrder != originalPosition) {
continue;
}
addToList(ChatFilter::local(localFilter, _owner));
addToList(ChatFilter::local(local, _owner));
}
addToList(ChatFilter::FromTL(filter, _owner));
++originalPosition;
}
// Then we adding local filters, retaining cloud order
while (originalPosition < kFiltersLimit) {
for (const auto &localFilter : localFilters) {
if (!account->isCurrent(localFilter.ownerId, localFilter.isTest)
|| localFilter.cloudOrder != originalPosition) {
auto local = MakeLocalFolder(localFilter.toObject());
if (local.cloudOrder != originalPosition) {
continue;
}
addToList(ChatFilter::local(localFilter, _owner));
addToList(ChatFilter::local(local, _owner));
}
++originalPosition;
}
// And finally we adding other filters
for (const auto &localFilter : localFilters) {
if (!account->isCurrent(localFilter.ownerId, localFilter.isTest)
|| localFilter.cloudOrder < kFiltersLimit) {
auto local = MakeLocalFolder(localFilter.toObject());
if (local.cloudOrder < kFiltersLimit) {
continue;
}
addToList(ChatFilter::local(localFilter, _owner));
addToList(ChatFilter::local(local, _owner));
}
while (position < _list.size()) {
@ -706,22 +904,15 @@ void ChatFilters::saveOrder(
ids.reserve(order.size());
auto cloudIds = QVector<MTPint>();
cloudIds.reserve(kFiltersLimit);
auto &localFolders = cRefLocalFolders();
const auto account = &_owner->session().account();
for (const auto id : order) {
ids.push_back(MTP_int(id));
const auto i = ranges::find(_list, id, &ChatFilter::id);
auto i = ranges::find(_list, id, &ChatFilter::id);
Assert(i != end(_list));
if ((*i).isLocal()) {
auto j = ranges::find_if(localFolders, [id, account](LocalFolder localFolder) {
return (id == localFolder.id
&& account->isCurrent(localFolder.ownerId, localFolder.isTest));
});
(*j).cloudOrder = cloudIds.size();
std::rotate(j, j+1, localFolders.end());
i->setLocalCloudOrder(cloudIds.size());
} else {
cloudIds.push_back(MTP_int(id));
}
@ -856,20 +1047,19 @@ rpl::producer<> ChatFilters::suggestedUpdated() const {
return _suggestedUpdated.events();
}
void ChatFilters::saveLocal(FilterId filterId) {
const auto i = ranges::find(_list, filterId, &ChatFilter::id);
auto &localFolders = cRefLocalFolders();
void ChatFilters::saveLocal() {
auto localFolders = QJsonArray();
const auto account = &_owner->session().account();
const auto j = ranges::find_if(localFolders, [filterId, account](LocalFolder localFolder) {
return (filterId == localFolder.id
&& account->isCurrent(localFolder.ownerId, localFolder.isTest));
});
Assert(i != end(_list));
Assert(j != end(localFolders));
const auto accountId = account->session().userId().bare;
const auto isTestAccount = account->mtp().isTestMode();
const auto cloudOrder = (*j).cloudOrder;
for (const auto &folder : _list) {
if (folder.isLocal()) {
localFolders << folder.toLocal().toJson();
}
}
*j = (*i).toLocal(cloudOrder);
::Kotato::JsonSettings::Set("folders/local", localFolders, accountId, isTestAccount);
}
} // namespace Data

View file

@ -19,6 +19,7 @@ class Key;
namespace Data {
class Session;
class LocalFolder;
class ChatFilter final {
public:
@ -56,7 +57,8 @@ public:
std::vector<not_null<History*>> pinned,
base::flat_set<not_null<History*>> never,
bool isDefault = false,
bool isLocal = false);
bool isLocal = false,
int localCloudOrder = 0);
[[nodiscard]] static ChatFilter local(
const LocalFolder &data,
@ -67,7 +69,7 @@ public:
not_null<Session*> owner,
bool isLocal = false);
[[nodiscard]] MTPDialogFilter tl(FilterId replaceId = 0) const;
[[nodiscard]] LocalFolder toLocal(int cloudOrder, FilterId replaceId = 0) const;
[[nodiscard]] LocalFolder toLocal(FilterId replaceId = 0) const;
[[nodiscard]] FilterId id() const;
[[nodiscard]] QString title() const;
@ -82,6 +84,10 @@ public:
[[nodiscard]] bool isLocal() const;
void setLocalCloudOrder(int order) {
_cloudLocalOrder = order;
}
private:
FilterId _id = 0;
QString _title;
@ -92,6 +98,7 @@ private:
Flags _flags;
bool _isDefault = false;
bool _isLocal = false;
int _cloudLocalOrder = 0;
};
@ -147,7 +154,7 @@ public:
-> const std::vector<SuggestedFilter> &;
[[nodiscard]] rpl::producer<> suggestedUpdated() const;
void saveLocal(FilterId filterId);
void saveLocal();
private:
void load(bool force);
@ -177,4 +184,19 @@ private:
};
struct LocalFolder {
QJsonObject toJson();
int id = 0;
int cloudOrder = 0;
QString name;
QString emoticon;
std::vector<uint64> always;
std::vector<uint64> never;
std::vector<uint64> pinned;
ChatFilter::Flags flags = Data::ChatFilter::Flags(0);
};
LocalFolder MakeLocalFolder(const QJsonObject &obj);
} // namespace Data

View file

@ -8,6 +8,7 @@ https://github.com/telegramdesktop/tdesktop/blob/master/LEGAL
#include "data/data_cloud_themes.h"
#include "kotato/kotato_lang.h"
#include "kotato/kotato_settings.h"
#include "window/themes/window_theme.h"
#include "window/themes/window_theme_preview.h"
#include "window/themes/window_theme_editor_box.h"
@ -390,7 +391,7 @@ rpl::producer<> CloudThemes::chatThemesUpdated() const {
std::optional<CloudTheme> CloudThemes::themeForEmoji(
const QString &emoticon) const {
const auto emoji = Ui::Emoji::Find(emoticon);
if (!emoji || cDisableChatThemes()) {
if (!emoji || ::Kotato::JsonSettings::GetBool("disable_chat_themes")) {
return {};
}
const auto i = ranges::find(_chatThemes, emoji, [](const CloudTheme &v) {

View file

@ -248,29 +248,24 @@ void Folder::paintUserpic(
p.setBrush(overrideBg ? *overrideBg : st::historyPeerArchiveUserpicBg);
{
PainterHighQualityEnabler hq(p);
switch (cUserpicCornersType()) {
case 0:
p.drawRoundedRect(
QRect{ x, y, size, size },
0, 0);
switch (KotatoImageRoundRadius()) {
case ImageRoundRadius::None:
p.drawRoundedRect(QRect{ x, y, size, size }, 0, 0);
break;
case 1:
p.drawRoundedRect(
QRect{ x, y, size, size },
case ImageRoundRadius::Small:
p.drawRoundedRect(QRect{ x, y, size, size },
st::buttonRadius, st::buttonRadius);
break;
case 2:
p.drawRoundedRect(
QRect{ x, y, size, size },
case ImageRoundRadius::Large:
p.drawRoundedRect(QRect{ x, y, size, size },
st::dateRadius, st::dateRadius);
break;
default:
p.drawEllipse(x, y, size, size);
}
}
if (size == st::dialogsPhotoSize) {
const auto rect = QRect{ x, y, size, size };

View file

@ -319,16 +319,16 @@ void PeerData::paintUserpic(
int x,
int y,
int size) const {
switch (cUserpicCornersType()) {
case 0:
switch (KotatoImageRoundRadius()) {
case ImageRoundRadius::None:
paintUserpicSquare(p, view, x, y, size);
break;
case 1:
case ImageRoundRadius::Small:
paintUserpicRounded(p, view, x, y, size);
break;
case 2:
case ImageRoundRadius::Large:
paintUserpicRoundedLarge(p, view, x, y, size);
break;
@ -443,12 +443,7 @@ QPixmap PeerData::genUserpic(
std::shared_ptr<Data::CloudImageView> &view,
int size) const {
if (const auto userpic = currentUserpic(view)) {
switch (cUserpicCornersType()) {
case 0: return userpic->pixRounded(size, size, ImageRoundRadius::None);
case 1: return userpic->pixRounded(size, size, ImageRoundRadius::Small);
case 2: return userpic->pixRounded(size, size, ImageRoundRadius::Large);
default: return userpic->pixCircled(size, size);
}
return userpic->pixRounded(size, size, KotatoImageRoundRadius());
}
auto result = QImage(QSize(size, size) * cIntRetinaFactor(), QImage::Format_ARGB32_Premultiplied);
result.setDevicePixelRatio(cRetinaFactor());
@ -463,16 +458,7 @@ QPixmap PeerData::genUserpic(
QImage PeerData::generateUserpicImage(
std::shared_ptr<Data::CloudImageView> &view,
int size) const {
const auto rounding = [] {
switch (cUserpicCornersType()) {
case 0: return ImageRoundRadius::None;
case 1: return ImageRoundRadius::Small;
case 2: return ImageRoundRadius::Large;
default: return ImageRoundRadius::Ellipse;
}
}();
return generateUserpicImage(view, size, rounding);
return generateUserpicImage(view, size, KotatoImageRoundRadius());
}
QImage PeerData::generateUserpicImage(

View file

@ -456,14 +456,7 @@ bool ChannelHasActiveCall(not_null<ChannelData*> channel) {
rpl::producer<QImage> PeerUserpicImageValue(
not_null<PeerData*> peer,
int size) {
return PeerUserpicImageValue(peer, size,
cUserpicCornersType() == 0
? ImageRoundRadius::None
: cUserpicCornersType() == 1
? ImageRoundRadius::Small
: cUserpicCornersType() == 2
? ImageRoundRadius::Large
: ImageRoundRadius::Ellipse);
return PeerUserpicImageValue(peer, size, KotatoImageRoundRadius());
}
rpl::producer<QImage> PeerUserpicImageValue(

View file

@ -7,6 +7,7 @@ https://github.com/telegramdesktop/tdesktop/blob/master/LEGAL
*/
#include "dialogs/dialogs_inner_widget.h"
#include "kotato/kotato_settings.h"
#include "dialogs/dialogs_indexed_list.h"
#include "dialogs/ui/dialogs_layout.h"
#include "dialogs/dialogs_widget.h"
@ -65,11 +66,15 @@ constexpr auto kHashtagResultsLimit = 5;
constexpr auto kStartReorderThreshold = 30;
inline int DialogsRowHeight() {
return (DialogListLines() == 1 ? st::dialogsImportantBarHeight : st::dialogsRowHeight);
return (::Kotato::JsonSettings::GetInt("chat_list_lines") == 1
? st::dialogsImportantBarHeight
: st::dialogsRowHeight);
}
inline int DialogsPhotoSize() {
return (DialogListLines() == 1 ? st::dialogsUnreadHeight : st::dialogsPhotoSize);
return (::Kotato::JsonSettings::GetInt("chat_list_lines") == 1
? st::dialogsUnreadHeight
: st::dialogsPhotoSize);
}
int FixedOnTopDialogsCount(not_null<Dialogs::IndexedList*> list) {
@ -210,7 +215,8 @@ InnerWidget::InnerWidget(
refresh();
}, lifetime());
DialogListLinesChanges(
::Kotato::JsonSettings::Events(
"chat_list_lines"
) | rpl::start_with_next([=] {
refresh();
}, lifetime());
@ -304,7 +310,10 @@ void InnerWidget::refreshWithCollapsedRows(bool toTop) {
? (*list->begin())->folder()
: nullptr;
const auto inMainMenu = session().settings().archiveInMainMenu();
if (archive && (session().settings().archiveCollapsed() || inMainMenu || DialogListLines() == 1)) {
if (archive &&
(session().settings().archiveCollapsed()
|| inMainMenu
|| ::Kotato::JsonSettings::GetInt("chat_list_lines") == 1)) {
if (_selected && _selected->folder() == archive) {
_selected = nullptr;
}
@ -736,7 +745,9 @@ void InnerWidget::paintPeerSearchResult(
auto namewidth = fullWidth - nameleft - st::dialogsPadding.x();
QRect rectForName(
nameleft,
(DialogListLines() == 1) ? st::dialogsPadding.y() : st::dialogsPadding.y() + st::dialogsNameTop,
(::Kotato::JsonSettings::GetInt("chat_list_lines") == 1)
? st::dialogsPadding.y()
: st::dialogsPadding.y() + st::dialogsNameTop,
namewidth,
st::msgNameFont->height);
@ -765,7 +776,7 @@ void InnerWidget::paintPeerSearchResult(
badgeStyle);
rectForName.setWidth(rectForName.width() - badgeWidth);
if (DialogListLines() == 1) {
if (::Kotato::JsonSettings::GetInt("chat_list_lines") == 1) {
QString text = peer->nameText().toString();
p.setPen(active
? st::dialogsNameFgActive
@ -2183,7 +2194,8 @@ bool InnerWidget::needCollapsedRowsRefresh() const {
const auto collapsedHasArchive = !_collapsedRows.empty()
&& (_collapsedRows.back()->folder != nullptr);
const auto archiveIsCollapsed = (archive != nullptr)
&& (session().settings().archiveCollapsed() || DialogListLines() == 1);
&& (session().settings().archiveCollapsed()
|| ::Kotato::JsonSettings::GetInt("chat_list_lines") == 1);
const auto archiveIsInMainMenu = (archive != nullptr)
&& session().settings().archiveInMainMenu();
return archiveIsInMainMenu

View file

@ -7,6 +7,7 @@ https://github.com/telegramdesktop/tdesktop/blob/master/LEGAL
*/
#include "dialogs/dialogs_row.h"
#include "kotato/kotato_settings.h"
#include "ui/effects/ripple_animation.h"
#include "ui/text/text_options.h"
#include "dialogs/dialogs_entry.h"
@ -135,7 +136,7 @@ void BasicRow::updateCornerBadgeShown(
not_null<PeerData*> peer,
Fn<void()> updateCallback) const {
const auto shown = [&] {
if (DialogListLines() == 1) {
if (::Kotato::JsonSettings::GetInt("chat_list_lines") == 1) {
return false;
}
if (const auto user = peer->asUser()) {
@ -167,7 +168,9 @@ void BasicRow::PaintCornerBadgeFrame(
view,
0,
0,
(DialogListLines() == 1 ? st::dialogsUnreadHeight : st::dialogsPhotoSize));
(::Kotato::JsonSettings::GetInt("chat_list_lines") == 1
? st::dialogsUnreadHeight
: st::dialogsPhotoSize));
PainterHighQualityEnabler hq(q);
q.setCompositionMode(QPainter::CompositionMode_Source);
@ -188,8 +191,12 @@ void BasicRow::PaintCornerBadgeFrame(
? st::dialogsOnlineBadgeFgActive
: st::dialogsOnlineBadgeFg);
q.drawEllipse(QRectF(
st::dialogsPhotoSize - size - (cUserpicCornersType() == 3 ? skip.x() : -(stroke / 2)),
st::dialogsPhotoSize - size - (cUserpicCornersType() == 3 ? skip.y() : -(stroke / 2)),
st::dialogsPhotoSize - size -
(KotatoImageRoundRadius() == ImageRoundRadius::Ellipse
? skip.x() : -(stroke / 2)),
st::dialogsPhotoSize - size -
(KotatoImageRoundRadius() == ImageRoundRadius::Ellipse
? skip.y() : -(stroke / 2)),
size,
size
).marginsRemoved({ shrink, shrink, shrink, shrink }));
@ -214,7 +221,9 @@ void BasicRow::paintUserpic(
st::dialogsPadding.x(),
st::dialogsPadding.y(),
fullWidth,
(DialogListLines() == 1 ? st::dialogsUnreadHeight : st::dialogsPhotoSize));
(::Kotato::JsonSettings::GetInt("chat_list_lines") == 1
? st::dialogsUnreadHeight
: st::dialogsPhotoSize));
if (!historyForCornerBadge || !_cornerBadgeShown) {
_cornerBadgeUserpic = nullptr;
}
@ -222,9 +231,10 @@ void BasicRow::paintUserpic(
}
ensureCornerBadgeUserpic();
if (_cornerBadgeUserpic->frame.isNull()) {
_cornerBadgeUserpic->frame = QImage(
(DialogListLines() == 1 ? st::dialogsUnreadHeight : st::dialogsPhotoSize) * cRetinaFactor(),
(DialogListLines() == 1 ? st::dialogsUnreadHeight : st::dialogsPhotoSize) * cRetinaFactor(),
const auto frameSize = (::Kotato::JsonSettings::GetInt("chat_list_lines") == 1
? st::dialogsUnreadHeight
: st::dialogsPhotoSize) * cRetinaFactor();
_cornerBadgeUserpic->frame = QImage(frameSize, frameSize,
QImage::Format_ARGB32_Premultiplied);
_cornerBadgeUserpic->frame.setDevicePixelRatio(cRetinaFactor());
}
@ -252,8 +262,12 @@ void BasicRow::paintUserpic(
p.translate(st::dialogsPadding);
actionPainter->paintSpeaking(
p,
st::dialogsPhotoSize - size - (cUserpicCornersType() == 3 ? skip.x() : -(stroke / 2)),
st::dialogsPhotoSize - size - (cUserpicCornersType() == 3 ? skip.y() : -(stroke / 2)),
st::dialogsPhotoSize - size -
(KotatoImageRoundRadius() == ImageRoundRadius::Ellipse
? skip.x() : -(stroke / 2)),
st::dialogsPhotoSize - size -
(KotatoImageRoundRadius() == ImageRoundRadius::Ellipse
? skip.y() : -(stroke / 2)),
fullWidth,
bg,
now);

View file

@ -7,6 +7,7 @@ https://github.com/telegramdesktop/tdesktop/blob/master/LEGAL
*/
#include "dialogs/dialogs_widget.h"
#include "kotato/kotato_settings.h"
#include "kotato/kotato_lang.h"
#include "dialogs/dialogs_inner_widget.h"
#include "dialogs/dialogs_search_from_controllers.h"
@ -1592,7 +1593,7 @@ void Widget::updateControlsGeometry() {
_forwardCancel->moveToLeft(0, filterAreaTop);
filterAreaTop += st::dialogsForwardHeight;
}
auto smallLayoutWidth = (st::dialogsPadding.x() + (DialogListLines() == 1 ? st::dialogsUnreadHeight : st::dialogsPhotoSize) + st::dialogsPadding.x());
auto smallLayoutWidth = (st::dialogsPadding.x() + (::Kotato::JsonSettings::GetInt("chat_list_lines") == 1 ? st::dialogsUnreadHeight : st::dialogsPhotoSize) + st::dialogsPadding.x());
auto smallLayoutRatio = (width() < st::columnMinimalWidthLeft) ? (st::columnMinimalWidthLeft - width()) / float64(st::columnMinimalWidthLeft - smallLayoutWidth) : 0.;
auto filterLeft = (controller()->filtersWidth() ? st::dialogsFilterSkip : st::dialogsFilterPadding.x() + _mainMenuToggle->width()) + st::dialogsFilterPadding.x();
auto filterRight = (session().domain().local().hasLocalPasscode() ? (st::dialogsFilterPadding.x() + _lockUnlock->width()) : st::dialogsFilterSkip) + st::dialogsFilterPadding.x();
@ -1820,7 +1821,7 @@ void Widget::onCancelSearchInChat() {
void Widget::onDialogMoved(int movedFrom, int movedTo) {
int32 st = _scroll->scrollTop();
if (st > movedTo && st < movedFrom) {
_scroll->scrollToY(st + (DialogListLines() == 1 ? st::dialogsImportantBarHeight : st::dialogsRowHeight));
_scroll->scrollToY(st + (::Kotato::JsonSettings::GetInt("chat_list_lines") == 1 ? st::dialogsImportantBarHeight : st::dialogsRowHeight));
}
}

View file

@ -7,6 +7,7 @@ https://github.com/telegramdesktop/tdesktop/blob/master/LEGAL
*/
#include "dialogs/ui/dialogs_layout.h"
#include "kotato/kotato_settings.h"
#include "data/data_abstract_structure.h"
#include "data/data_drafts.h"
#include "data/data_session.h"
@ -94,7 +95,7 @@ void PaintNarrowCounter(
? QString::number(unreadCount)
: QString();
const auto allowDigits = displayMentionBadge ? 1 : 3;
auto unreadRight = st::dialogsPadding.x() + (DialogListLines() == 1 ? st::dialogsUnreadHeight : st::dialogsPhotoSize);
auto unreadRight = st::dialogsPadding.x() + (::Kotato::JsonSettings::GetInt("chat_list_lines") == 1 ? st::dialogsUnreadHeight : st::dialogsPhotoSize);
auto unreadTop = (lines == 1
? st::dialogsPadding.y()
: st::dialogsPadding.y() + st::dialogsPhotoSize - st::dialogsUnreadHeight);
@ -108,7 +109,7 @@ void PaintNarrowCounter(
}
if (displayMentionBadge) {
auto counter = qsl("@");
auto unreadRight = st::dialogsPadding.x() + (DialogListLines() == 1 ? st::dialogsUnreadHeight : st::dialogsPhotoSize) - skipBeforeMention;
auto unreadRight = st::dialogsPadding.x() + (::Kotato::JsonSettings::GetInt("chat_list_lines") == 1 ? st::dialogsUnreadHeight : st::dialogsPhotoSize) - skipBeforeMention;
auto unreadTop = (lines == 1
? st::dialogsPadding.y()
: st::dialogsPadding.y() + st::dialogsPhotoSize - st::dialogsUnreadHeight);
@ -896,7 +897,8 @@ void RowPainter::paint(
? history->hasUnreadMentions()
: false;
const auto displayUnreadCounter = [&] {
if (fullWidth < st::columnMinimalWidthLeft && DialogListLines() == 1) {
if (fullWidth < st::columnMinimalWidthLeft
&& ::Kotato::JsonSettings::GetInt("chat_list_lines") == 1) {
return false;
}
@ -931,7 +933,7 @@ void RowPainter::paint(
| (peer && peer->isSelf() ? Flag::SavedMessages : Flag(0))
| (peer && peer->isRepliesChat() ? Flag::RepliesMessages : Flag(0));
const auto paintItemCallback = [&](int nameleft, int namewidth) {
const auto texttop = (DialogListLines() == 1
const auto texttop = (::Kotato::JsonSettings::GetInt("chat_list_lines") == 1
? st::dialogsPadding.y()
: st::dialogsPadding.y()
+ st::msgNameFont->height
@ -951,7 +953,8 @@ void RowPainter::paint(
selected,
unreadMuted,
mentionMuted);
if (DialogListLines() > 1 || flags & Flag::SearchResult) {
if (flags & Flag::SearchResult
|| ::Kotato::JsonSettings::GetInt("chat_list_lines") > 1) {
const auto &color = active
? st::dialogsTextFgServiceActive
: (selected
@ -997,9 +1000,9 @@ void RowPainter::paint(
active,
unreadMuted,
mentionMuted,
DialogListLines());
::Kotato::JsonSettings::GetInt("chat_list_lines"));
};
if (DialogListLines() == 1) {
if (::Kotato::JsonSettings::GetInt("chat_list_lines") == 1) {
paintOneLineRow(
p,
row,
@ -1102,7 +1105,7 @@ void RowPainter::paint(
| (showSavedMessages ? Flag::SavedMessages : Flag(0))
| (showRepliesMessages ? Flag::RepliesMessages : Flag(0));
const auto paintItemCallback = [&](int nameleft, int namewidth) {
const auto texttop = (DialogListLines() == 1
const auto texttop = (::Kotato::JsonSettings::GetInt("chat_list_lines") == 1
? st::dialogsPadding.y()
: st::dialogsPadding.y()
+ st::msgNameFont->height
@ -1122,7 +1125,8 @@ void RowPainter::paint(
unreadMuted,
mentionMuted);
if (DialogListLines() > 1 || flags & Flag::SearchResult) {
if (flags & Flag::SearchResult
|| ::Kotato::JsonSettings::GetInt("chat_list_lines") > 1) {
const auto itemRect = QRect(
nameleft,
texttop,
@ -1149,9 +1153,9 @@ void RowPainter::paint(
active,
unreadMuted,
mentionMuted,
DialogListLines());
::Kotato::JsonSettings::GetInt("chat_list_lines"));
};
if (DialogListLines() == 1) {
if (::Kotato::JsonSettings::GetInt("chat_list_lines") == 1) {
paintOneLineRow(
p,
row,
@ -1195,7 +1199,9 @@ QRect RowPainter::sendActionAnimationRect(
int fullWidth,
bool textUpdated) {
const auto nameleft = st::dialogsPadding.x()
+ (DialogListLines() == 1 ? st::dialogsUnreadHeight : st::dialogsPhotoSize)
+ (::Kotato::JsonSettings::GetInt("chat_list_lines") == 1
? st::dialogsUnreadHeight
: st::dialogsPhotoSize)
+ st::dialogsPhotoPadding;
const auto namewidth = fullWidth - nameleft - st::dialogsPadding.x();
const auto texttop = st::dialogsPadding.y()

View file

@ -7,8 +7,8 @@ https://github.com/telegramdesktop/tdesktop/blob/master/LEGAL
*/
#include "ffmpeg/ffmpeg_utility.h"
#include "kotato/kotato_settings.h"
#include "base/algorithm.h"
#include "kotato/settings.h"
#include "logs.h"
#include <QImage>
@ -170,9 +170,9 @@ CodecPointer MakeCodecPointer(not_null<AVStream*> stream) {
return {};
}
context->pkt_timebase = stream->time_base;
if(cFFmpegMultithread()) {
if (cFFmpegThreadCount() > 0) {
av_opt_set(context, "threads", std::to_string(cFFmpegThreadCount()).c_str(), 0);
if(::Kotato::JsonSettings::GetBool("ffmpeg_multithread")) {
if (::Kotato::JsonSettings::GetInt("ffmpeg_thread_count") > 0) {
av_opt_set(context, "threads", std::to_string(::Kotato::JsonSettings::GetInt("ffmpeg_thread_count")).c_str(), 0);
} else {
av_opt_set(context, "threads", "auto", 0);
}

View file

@ -7,6 +7,7 @@ https://github.com/telegramdesktop/tdesktop/blob/master/LEGAL
*/
#include "history/history_inner_widget.h"
#include "kotato/kotato_settings.h"
#include "kotato/kotato_lang.h"
#include "core/file_utilities.h"
#include "core/crash_reports.h"
@ -2422,7 +2423,7 @@ void HistoryInner::recountHistoryGeometry() {
updateBotInfo(false);
if (_botAbout && !_botAbout->info->text.isEmpty()) {
int32 tw = _scroll->width() - st::msgMargin.left() - st::msgMargin.right();
if (!AdaptiveBubbles() && tw > st::msgMaxWidth) tw = st::msgMaxWidth;
if (!::Kotato::JsonSettings::GetBool("adaptive_bubbles") && tw > st::msgMaxWidth) tw = st::msgMaxWidth;
tw -= st::msgPadding.left() + st::msgPadding.right();
const auto descriptionWidth = _history->peer->isRepliesChat()
? 0
@ -2438,7 +2439,7 @@ void HistoryInner::recountHistoryGeometry() {
: (st::msgNameFont->height + st::botDescSkip);
int32 descH = st::msgMargin.top() + st::msgPadding.top() + descriptionHeight + _botAbout->height + st::msgPadding.bottom() + st::msgMargin.bottom();
int32 descMaxWidth = _scroll->width();
if (_isChatWide && !AdaptiveBubbles()) {
if (_isChatWide && !::Kotato::JsonSettings::GetBool("adaptive_bubbles")) {
descMaxWidth = qMin(descMaxWidth, int32(st::msgMaxWidth + 2 * st::msgPhotoSkip + 2 * st::msgMargin.left()));
}
int32 descAtX = (descMaxWidth - _botAbout->width) / 2 - st::msgPadding.left();
@ -2475,7 +2476,7 @@ void HistoryInner::updateBotInfo(bool recount) {
Ui::ItemTextBotNoMonoOptions());
if (recount) {
int32 tw = _scroll->width() - st::msgMargin.left() - st::msgMargin.right();
if (!AdaptiveBubbles() && tw > st::msgMaxWidth) tw = st::msgMaxWidth;
if (!::Kotato::JsonSettings::GetBool("adaptive_bubbles") && tw > st::msgMaxWidth) tw = st::msgMaxWidth;
tw -= st::msgPadding.left() + st::msgPadding.right();
const auto descriptionWidth = _history->peer->isRepliesChat()
? 0
@ -2657,7 +2658,7 @@ void HistoryInner::updateSize() {
: (st::msgNameFont->height + st::botDescSkip);
int32 descH = st::msgMargin.top() + st::msgPadding.top() + descriptionHeight + _botAbout->height + st::msgPadding.bottom() + st::msgMargin.bottom();
int32 descMaxWidth = _scroll->width();
if (_isChatWide && !AdaptiveBubbles()) {
if (_isChatWide && !::Kotato::JsonSettings::GetBool("adaptive_bubbles")) {
descMaxWidth = qMin(descMaxWidth, int32(st::msgMaxWidth + 2 * st::msgPhotoSkip + 2 * st::msgMargin.left()));
}
int32 descAtX = (descMaxWidth - _botAbout->width) / 2 - st::msgPadding.left();
@ -3111,7 +3112,7 @@ void HistoryInner::mouseActionUpdate() {
dateWidth += st::msgServicePadding.left() + st::msgServicePadding.right();
auto dateLeft = st::msgServiceMargin.left();
auto maxwidth = _contentWidth;
if (_isChatWide && !AdaptiveBubbles()) {
if (_isChatWide && !::Kotato::JsonSettings::GetBool("adaptive_bubbles")) {
maxwidth = qMin(maxwidth, int32(st::msgMaxWidth + 2 * st::msgPhotoSkip + 2 * st::msgMargin.left()));
}
auto widthForDate = maxwidth - st::msgServiceMargin.left() - st::msgServiceMargin.left();

View file

@ -7,8 +7,8 @@ https://github.com/telegramdesktop/tdesktop/blob/master/LEGAL
*/
#include "history/history_widget.h"
#include "kotato/kotato_settings.h"
#include "kotato/kotato_lang.h"
#include "kotato/json_settings.h"
#include "api/api_editing.h"
#include "api/api_bot.h"
#include "api/api_chat_participants.h"
@ -609,28 +609,32 @@ HistoryWidget::HistoryWidget(
});
}, lifetime());
BigEmojiOutlineChanges(
::Kotato::JsonSettings::Events(
"big_emoji_outline"
) | rpl::start_with_next([=] {
crl::on_main(this, [=] {
updateHistoryGeometry();
});
}, lifetime());
StickerHeightChanges(
::Kotato::JsonSettings::Events(
"sticker_height"
) | rpl::start_with_next([=] {
crl::on_main(this, [=] {
updateHistoryGeometry();
});
}, lifetime());
StickerScaleBothChanges(
::Kotato::JsonSettings::Events(
"sticker_scale_both"
) | rpl::start_with_next([=] {
crl::on_main(this, [=] {
updateHistoryGeometry();
});
}, lifetime());
AdaptiveBubblesChanges(
::Kotato::JsonSettings::Events(
"adaptive_bubbles"
) | rpl::start_with_next([=] {
crl::on_main(this, [=] {
if (_history) {
@ -644,7 +648,8 @@ HistoryWidget::HistoryWidget(
});
}, lifetime());
MonospaceLargeBubblesChanges(
::Kotato::JsonSettings::Events(
"monospace_large_bubbles"
) | rpl::start_with_next([=] {
crl::on_main(this, [=] {
if (_history) {
@ -658,7 +663,8 @@ HistoryWidget::HistoryWidget(
});
}, lifetime());
HoverEmojiPanelChanges(
::Kotato::JsonSettings::Events(
"hover_emoji_panel"
) | rpl::start_with_next([=] {
crl::on_main(this, [=] {
refreshTabbedPanel();
@ -1091,7 +1097,9 @@ void HistoryWidget::initTabbedSelector() {
});
base::install_event_filter(_tabbedSelectorToggle, [=](not_null<QEvent*> e) {
if (e->type() == QEvent::ContextMenu && !HoverEmojiPanel() && _tabbedPanel) {
if (e->type() == QEvent::ContextMenu
&& !::Kotato::JsonSettings::GetBool("hover_emoji_panel")
&& _tabbedPanel) {
_tabbedPanel->toggleAnimated();
return base::EventFilterResult::Cancel;
}
@ -2594,7 +2602,7 @@ void HistoryWidget::refreshScheduledToggle() {
if (_scheduled) {
_scheduled.destroy();
}
if (cAlwaysShowScheduled() || has){
if (::Kotato::JsonSettings::GetBool("always_show_scheduled") || has){
_scheduled.create(this, (has ? st::historyScheduledToggle : st::historyScheduledToggleEmpty));
_scheduled->show();
_scheduled->addClickHandler([=] {
@ -2626,7 +2634,7 @@ void HistoryWidget::refreshSendAsToggle() {
} else if (_sendAs) {
return;
}
_sendAs.create(this, st::sendAsButton, cUserpicCornersType());
_sendAs.create(this, st::sendAsButton, ::Kotato::JsonSettings::GetInt("userpic_corner_type"));
Ui::SetupSendAsButton(_sendAs.data(), controller());
}
@ -4607,7 +4615,7 @@ void HistoryWidget::createTabbedPanel() {
void HistoryWidget::setTabbedPanel(std::unique_ptr<TabbedPanel> panel) {
_tabbedPanel = std::move(panel);
if (const auto raw = _tabbedPanel.get()) {
_tabbedPanel->setPreventHover(!HoverEmojiPanel());
_tabbedPanel->setPreventHover(!::Kotato::JsonSettings::GetBool("hover_emoji_panel"));
_tabbedSelectorToggle->installEventFilter(raw);
_tabbedSelectorToggle->setColorOverrides(nullptr, nullptr, nullptr);
} else {
@ -5933,9 +5941,9 @@ void HistoryWidget::contextMenuEvent(QContextMenuEvent *e) {
.groupOptions = _toForward.groupOptions,
});
updateField();
if (cForwardRememberMode()) {
SetForwardMode(settingsKey);
Kotato::JsonSettings::Write();
if (::Kotato::JsonSettings::GetBool("forward_remember_mode")) {
::Kotato::JsonSettings::Set("forward_mode", settingsKey);
::Kotato::JsonSettings::Write();
}
});
}
@ -5964,9 +5972,9 @@ void HistoryWidget::contextMenuEvent(QContextMenuEvent *e) {
});
updateForwardingTexts();
updateField();
if (cForwardRememberMode()) {
SetForwardGroupingMode(settingsKey);
Kotato::JsonSettings::Write();
if (::Kotato::JsonSettings::GetBool("forward_remember_mode")) {
::Kotato::JsonSettings::Set("forward_grouping_mode", settingsKey);
::Kotato::JsonSettings::Write();
}
});
}
@ -5999,7 +6007,7 @@ void HistoryWidget::keyPressEvent(QKeyEvent *e) {
} else if (e->key() == Qt::Key_Down && !commonModifiers) {
_scroll->keyPressEvent(e);
} else if (e->key() == Qt::Key_Up && !commonModifiers) {
if (!cDisableUpEdit()) {
if (!::Kotato::JsonSettings::GetBool("disable_up_edit")) {
const auto item = _history
? _history->lastEditableMessage()
: nullptr;
@ -6420,7 +6428,7 @@ void HistoryWidget::setupGroupCallBar() {
peer,
st::historyGroupCallUserpics.size),
Core::App().appDeactivatedValue(),
cUserpicCornersType());
::Kotato::JsonSettings::GetInt("userpic_corner_type"));
controller()->adaptive().oneColumnValue(
) | rpl::start_with_next([=](bool one) {
@ -6472,7 +6480,7 @@ void HistoryWidget::setupRequestsBar() {
HistoryView::RequestsBarContentByPeer(
peer,
st::historyRequestsUserpics.size),
cUserpicCornersType());
::Kotato::JsonSettings::GetInt("userpic_corner_type"));
controller()->adaptive().oneColumnValue(
) | rpl::start_with_next([=](bool one) {

View file

@ -7,6 +7,7 @@ https://github.com/telegramdesktop/tdesktop/blob/master/LEGAL
*/
#include "history/view/controls/history_view_compose_controls.h"
#include "kotato/kotato_settings.h"
#include "base/event_filter.h"
#include "base/platform/base_platform_info.h"
#include "base/qt_signal_producer.h"
@ -1074,7 +1075,8 @@ void ComposeControls::init() {
}, _wrap->lifetime());
}
HoverEmojiPanelChanges(
::Kotato::JsonSettings::Events(
"hover_emoji_panel"
) | rpl::start_with_next([=] {
if (_window->hasTabbedSelectorOwnership()) {
createTabbedPanel();
@ -1130,7 +1132,9 @@ void ComposeControls::initKeyHandler() {
_attachRequests.fire({});
return;
}
if (key == Qt::Key_Up && !hasModifiers && !cDisableUpEdit()) {
if (key == Qt::Key_Up
&& !hasModifiers
&& !::Kotato::JsonSettings::GetBool("disable_up_edit")) {
if (!isEditingMessage() && _field->empty()) {
_editLastMessageRequests.fire(std::move(keyEvent));
return;
@ -1573,7 +1577,9 @@ void ComposeControls::initTabbedSelector() {
}
base::install_event_filter(_tabbedSelectorToggle, [=](not_null<QEvent*> e) {
if (e->type() == QEvent::ContextMenu && !HoverEmojiPanel() && _tabbedPanel) {
if (e->type() == QEvent::ContextMenu
&& !::Kotato::JsonSettings::GetBool("hover_emoji_panel")
&& _tabbedPanel) {
_tabbedPanel->toggleAnimated();
return base::EventFilterResult::Cancel;
}
@ -1988,7 +1994,7 @@ bool ComposeControls::updateSendAsButton() {
_sendAs = std::make_unique<Ui::SendAsButton>(
_wrap.get(),
st::sendAsButton,
cUserpicCornersType());
::Kotato::JsonSettings::GetInt("userpic_corner_type"));
Ui::SetupSendAsButton(
_sendAs.get(),
rpl::single(peer.get()),
@ -2049,7 +2055,7 @@ void ComposeControls::setTabbedPanel(
std::unique_ptr<ChatHelpers::TabbedPanel> panel) {
_tabbedPanel = std::move(panel);
if (const auto raw = _tabbedPanel.get()) {
_tabbedPanel->setPreventHover(!HoverEmojiPanel());
_tabbedPanel->setPreventHover(!::Kotato::JsonSettings::GetBool("hover_emoji_panel"));
_tabbedSelectorToggle->installEventFilter(raw);
_tabbedSelectorToggle->setColorOverrides(nullptr, nullptr, nullptr);
} else {

View file

@ -7,6 +7,7 @@ https://github.com/telegramdesktop/tdesktop/blob/master/LEGAL
*/
#include "history/view/history_view_context_menu.h"
#include "kotato/kotato_settings.h"
#include "api/api_attached_stickers.h"
#include "api/api_editing.h"
#include "api/api_polls.h"
@ -1099,7 +1100,7 @@ void AddWhoReactedAction(
Api::WhoReacted(item, context, st::defaultWhoRead),
participantChosen,
showAllChosen,
cUserpicCornersType()));
::Kotato::JsonSettings::GetInt("userpic_corner_type")));
}
void ShowReportItemsBox(not_null<PeerData*> peer, MessageIdsList ids) {

View file

@ -8,6 +8,7 @@ https://github.com/telegramdesktop/tdesktop/blob/master/LEGAL
#include "history/view/history_view_element.h"
#include "kotato/kotato_lang.h"
#include "kotato/kotato_settings.h"
#include "api/api_chat_invite.h"
#include "history/view/history_view_service_message.h"
#include "history/view/history_view_message.h"
@ -304,7 +305,7 @@ void UnreadBar::paint(
p.setPen(st->historyUnreadBarFg());
int maxwidth = w;
if (chatWide && !AdaptiveBubbles()) {
if (chatWide && !::Kotato::JsonSettings::GetBool("adaptive_bubbles")) {
maxwidth = qMin(
maxwidth,
st::msgMaxWidth

View file

@ -58,22 +58,18 @@ void GenerateUserpicsInRow(
q.setCompositionMode(QPainter::CompositionMode_Source);
q.setBrush(Qt::NoBrush);
q.setPen(pen);
switch (cUserpicCornersType()) {
case 0:
q.drawRoundedRect(
QRect{ x, 0, single, single },
0, 0);
switch (KotatoImageRoundRadius()) {
case ImageRoundRadius::None:
q.drawRoundedRect(QRect{ x, 0, single, single }, 0, 0);
break;
case 1:
q.drawRoundedRect(
QRect{ x, 0, single, single },
case ImageRoundRadius::Small:
q.drawRoundedRect(QRect{ x, 0, single, single },
st::buttonRadius, st::buttonRadius);
break;
case 2:
q.drawRoundedRect(
QRect{ x, 0, single, single },
case ImageRoundRadius::Large:
q.drawRoundedRect(QRect{ x, 0, single, single },
st::dateRadius, st::dateRadius);
break;

View file

@ -7,6 +7,7 @@ https://github.com/telegramdesktop/tdesktop/blob/master/LEGAL
*/
#include "history/view/history_view_list_widget.h"
#include "kotato/kotato_settings.h"
#include "base/unixtime.h"
#include "history/history_message.h"
#include "history/history_item_components.h"
@ -2638,7 +2639,7 @@ void ListWidget::mouseActionUpdate() {
dateWidth += st::msgServicePadding.left() + st::msgServicePadding.right();
auto dateLeft = st::msgServiceMargin.left();
auto maxwidth = view->width();
if (_isChatWide && !AdaptiveBubbles()) {
if (_isChatWide && !::Kotato::JsonSettings::GetBool("adaptive_bubbles")) {
maxwidth = qMin(maxwidth, int32(st::msgMaxWidth + 2 * st::msgPhotoSkip + 2 * st::msgMargin.left()));
}
auto widthForDate = maxwidth - st::msgServiceMargin.left() - st::msgServiceMargin.left();

View file

@ -7,6 +7,7 @@ https://github.com/telegramdesktop/tdesktop/blob/master/LEGAL
*/
#include "history/view/history_view_message.h"
#include "kotato/kotato_settings.h"
#include "core/click_handler_types.h" // ClickHandlerContext
#include "history/view/history_view_cursor_state.h"
#include "history/history_item_components.h"
@ -2693,7 +2694,7 @@ QRect Message::countGeometry() const {
// contentLeft += st::msgPhotoSkip - (hmaxwidth - hwidth);
}
accumulate_min(contentWidth, maxWidth());
if (!AdaptiveBubbles()) {
if (!::Kotato::JsonSettings::GetBool("adaptive_bubbles")) {
accumulate_min(contentWidth, _bubbleWidthLimit);
}
if (mediaWidth < contentWidth) {
@ -2707,7 +2708,7 @@ QRect Message::countGeometry() const {
}
if (contentWidth < availableWidth
&& (!delegate()->elementIsChatWide()
|| (commentsRoot && AdaptiveBubbles()))) {
|| (commentsRoot && ::Kotato::JsonSettings::GetBool("adaptive_bubbles")))) {
if (outbg) {
contentLeft += availableWidth - contentWidth;
} else if (commentsRoot) {
@ -2751,10 +2752,10 @@ int Message::resizeContentGetHeight(int newWidth) {
}
}
accumulate_min(contentWidth, maxWidth());
_bubbleWidthLimit = (MonospaceLargeBubbles()
_bubbleWidthLimit = (::Kotato::JsonSettings::GetBool("monospace_large_bubbles")
? std::max(st::msgMaxWidth, monospaceMaxWidth())
: st::msgMaxWidth);
if (!AdaptiveBubbles()) {
if (!::Kotato::JsonSettings::GetBool("adaptive_bubbles")) {
accumulate_min(contentWidth, _bubbleWidthLimit);
}
if (mediaDisplayed) {
@ -2789,7 +2790,7 @@ int Message::resizeContentGetHeight(int newWidth) {
_reactions->resizeGetHeight(textWidth);
}
if (!AdaptiveBubbles() && contentWidth == maxWidth()) {
if (!::Kotato::JsonSettings::GetBool("adaptive_bubbles") && contentWidth == maxWidth()) {
if (mediaDisplayed) {
if (entry) {
newHeight += entry->resizeGetHeight(contentWidth);

View file

@ -7,6 +7,7 @@ https://github.com/telegramdesktop/tdesktop/blob/master/LEGAL
*/
#include "history/view/history_view_service_message.h"
#include "kotato/kotato_settings.h"
#include "history/history.h"
#include "history/history_service.h"
#include "history/view/media/history_view_media.h"
@ -140,7 +141,7 @@ void PaintPreparedDate(
int w,
bool chatWide) {
int left = st::msgServiceMargin.left();
const auto maxwidth = (chatWide && !AdaptiveBubbles())
const auto maxwidth = (chatWide && !::Kotato::JsonSettings::GetBool("adaptive_bubbles"))
? std::min(w, WideChatWidth())
: w;
w = maxwidth - st::msgServiceMargin.left() - st::msgServiceMargin.left();
@ -395,7 +396,7 @@ not_null<HistoryService*> Service::message() const {
QRect Service::countGeometry() const {
auto result = QRect(0, 0, width(), height());
if (delegate()->elementIsChatWide() && !AdaptiveBubbles()) {
if (delegate()->elementIsChatWide() && !::Kotato::JsonSettings::GetBool("adaptive_bubbles")) {
result.setWidth(qMin(result.width(), st::msgMaxWidth + 2 * st::msgPhotoSkip + 2 * st::msgMargin.left()));
}
return result.marginsRemoved(st::msgServiceMargin);
@ -418,7 +419,7 @@ QSize Service::performCountCurrentSize(int newWidth) {
item->_textHeight = 0;
} else {
auto contentWidth = newWidth;
if (delegate()->elementIsChatWide() && !AdaptiveBubbles()) {
if (delegate()->elementIsChatWide() && !::Kotato::JsonSettings::GetBool("adaptive_bubbles")) {
accumulate_min(contentWidth, st::msgMaxWidth + 2 * st::msgPhotoSkip + 2 * st::msgMargin.left());
}
contentWidth -= st::msgServiceMargin.left() + st::msgServiceMargin.left(); // two small margins

View file

@ -10,6 +10,7 @@ https://github.com/telegramdesktop/tdesktop/blob/master/LEGAL
#include <rpl/combine.h>
#include <rpl/combine_previous.h>
#include "kotato/kotato_lang.h"
#include "kotato/kotato_settings.h"
#include "history/history.h"
#include "history/view/history_view_send_action.h"
#include "boxes/add_contact_box.h"
@ -240,7 +241,7 @@ void TopBarWidget::search() {
void TopBarWidget::call() {
if (const auto peer = _activeChat.key.peer()) {
if (const auto user = peer->asUser()) {
if (cConfirmBeforeCall()) {
if (::Kotato::JsonSettings::GetBool("confirm_before_calls")) {
Ui::show(Box<Ui::ConfirmBox>(ktr("ktg_call_sure"), ktr("ktg_call_button"), [=] {
Ui::hideLayer();
Core::App().calls().startOutgoingCall(user, false);
@ -813,7 +814,7 @@ void TopBarWidget::updateControlsGeometry() {
_cancelChoose->moveToLeft(_leftTaken, otherButtonsTop);
_leftTaken += _cancelChoose->width();
} else if (_back->isHidden()) {
if (cShowTopBarUserpic()) {
if (::Kotato::JsonSettings::GetBool("always_show_top_userpic")) {
_leftTaken = st::topBarActionSkip;
} else {
_leftTaken = st::topBarArrowPadding.right();
@ -826,7 +827,7 @@ void TopBarWidget::updateControlsGeometry() {
_leftTaken += _back->width();
}
if (!_back->isHidden() || cShowTopBarUserpic()) {
if (!_back->isHidden() || ::Kotato::JsonSettings::GetBool("always_show_top_userpic")) {
if (_info && !_info->isHidden()) {
_info->moveToLeft(_leftTaken, otherButtonsTop);
_leftTaken += _info->width();
@ -889,7 +890,8 @@ void TopBarWidget::updateControlsVisibility() {
_back->setVisible(backVisible && !_chooseForReportReason);
_cancelChoose->setVisible(_chooseForReportReason.has_value());
if (_info) {
_info->setVisible(cShowTopBarUserpic() || (isOneColumn && !_chooseForReportReason));
_info->setVisible(::Kotato::JsonSettings::GetBool("always_show_top_userpic")
|| (isOneColumn && !_chooseForReportReason));
}
if (_unreadBadge) {
_unreadBadge->setVisible(!_chooseForReportReason);

View file

@ -7,6 +7,7 @@ https://github.com/telegramdesktop/tdesktop/blob/master/LEGAL
*/
#include "history/view/media/history_view_call.h"
#include "kotato/kotato_settings.h"
#include "kotato/kotato_lang.h"
#include "ui/boxes/confirm_box.h"
#include "lang/lang_keys.h"
@ -63,7 +64,7 @@ QSize Call::countOptimalSize() {
const auto video = _video;
_link = std::make_shared<LambdaClickHandler>([=] {
if (user) {
if (cConfirmBeforeCall()) {
if (::Kotato::JsonSettings::GetBool("confirm_before_calls")) {
Ui::show(Box<Ui::ConfirmBox>(ktr("ktg_call_sure"), ktr("ktg_call_button"), [=] {
Ui::hideLayer();
Core::App().calls().startOutgoingCall(user, video);

View file

@ -188,28 +188,25 @@ void Contact::draw(Painter &p, const PaintContext &context) const {
PainterHighQualityEnabler hq(p);
p.setBrush(p.textPalette().selectOverlay);
p.setPen(Qt::NoPen);
switch (cUserpicCornersType()) {
case 0:
p.drawRoundedRect(
rthumb,
0, 0);
switch (KotatoImageRoundRadius()) {
case ImageRoundRadius::None:
p.drawRoundedRect(rthumb, 0, 0);
break;
case 1:
p.drawRoundedRect(
rthumb,
case ImageRoundRadius::Small:
p.drawRoundedRect(rthumb,
st::buttonRadius, st::buttonRadius);
break;
case 2:
p.drawRoundedRect(
rthumb,
case ImageRoundRadius::Large:
p.drawRoundedRect(rthumb,
st::dateRadius, st::dateRadius);
break;
default:
p.drawEllipse(rthumb);
}
}
bool over = ClickHandler::showAsActive(_linkl);

View file

@ -7,6 +7,7 @@ https://github.com/telegramdesktop/tdesktop/blob/master/LEGAL
*/
#include "history/view/media/history_view_document.h"
#include "kotato/kotato_settings.h"
#include "lang/lang_keys.h"
#include "storage/localstorage.h"
#include "media/audio/media_audio.h"
@ -262,7 +263,7 @@ QSize Document::countOptimalSize() {
if (auto named = Get<HistoryDocumentNamed>()) {
accumulate_max(maxWidth, tleft + named->_namew + tright);
if (AdaptiveBubbles() && captioned) {
if (::Kotato::JsonSettings::GetBool("adaptive_bubbles") && captioned) {
accumulate_max(maxWidth, captioned->_caption.maxWidth() + st::msgPadding.left() + st::msgPadding.right());
} else {
accumulate_min(maxWidth, st::msgMaxWidth);

View file

@ -7,6 +7,7 @@ https://github.com/telegramdesktop/tdesktop/blob/master/LEGAL
*/
#include "history/view/media/history_view_gif.h"
#include "kotato/kotato_settings.h"
#include "lang/lang_keys.h"
#include "mainwindow.h"
#include "main/main_session.h"
@ -144,10 +145,10 @@ QSize Gif::countOptimalSize() {
const auto size = style::ConvertScale(videoSize());
auto tw = size.width();
auto th = size.height();
if ((!AdaptiveBubbles() || captionWithPaddings <= maxSize) && tw > maxSize) {
if ((!::Kotato::JsonSettings::GetBool("adaptive_bubbles") || captionWithPaddings <= maxSize) && tw > maxSize) {
th = (maxSize * th) / tw;
tw = maxSize;
} else if (AdaptiveBubbles() && captionWithPaddings > maxSize && tw > captionWithPaddings) {
} else if (::Kotato::JsonSettings::GetBool("adaptive_bubbles") && captionWithPaddings > maxSize && tw > captionWithPaddings) {
th = (captionWithPaddings * th) / tw;
tw = captionWithPaddings;
}
@ -171,7 +172,7 @@ QSize Gif::countOptimalSize() {
if (_parent->hasBubble()) {
accumulate_max(maxWidth, _parent->minWidthForMedia());
if (!_caption.isEmpty()) {
if (AdaptiveBubbles()) {
if (::Kotato::JsonSettings::GetBool("adaptive_bubbles")) {
accumulate_max(maxWidth, captionWithPaddings);
}
auto captionw = maxWidth - st::msgPadding.left() - st::msgPadding.right();
@ -207,10 +208,10 @@ QSize Gif::countCurrentSize(int newWidth) {
const auto size = style::ConvertScale(videoSize());
auto tw = size.width();
auto th = size.height();
if ((!AdaptiveBubbles() || captionWithPaddings <= maxSize) && tw > maxSize) {
if ((!::Kotato::JsonSettings::GetBool("adaptive_bubbles") || captionWithPaddings <= maxSize) && tw > maxSize) {
th = (maxSize * th) / tw;
tw = maxSize;
} else if (AdaptiveBubbles() && captionWithPaddings > maxSize && tw > captionWithPaddings) {
} else if (::Kotato::JsonSettings::GetBool("adaptive_bubbles") && captionWithPaddings > maxSize && tw > captionWithPaddings) {
th = (captionWithPaddings * th) / tw;
tw = captionWithPaddings;
}
@ -240,7 +241,7 @@ QSize Gif::countCurrentSize(int newWidth) {
if (_parent->hasBubble()) {
accumulate_max(newWidth, _parent->minWidthForMedia());
if (!_caption.isEmpty()) {
if (AdaptiveBubbles()) {
if (::Kotato::JsonSettings::GetBool("adaptive_bubbles")) {
accumulate_max(newWidth, captionWithPaddings);
accumulate_min(newWidth, availableWidth);
}

View file

@ -7,6 +7,7 @@ https://github.com/telegramdesktop/tdesktop/blob/master/LEGAL
*/
#include "history/view/media/history_view_location.h"
#include "kotato/kotato_settings.h"
#include "history/history.h"
#include "history/history_item_components.h"
#include "history/history_item.h"
@ -91,13 +92,13 @@ QSize Location::countOptimalSize() {
if (_parent->hasBubble()) {
if (!_title.isEmpty()) {
if (AdaptiveBubbles()) {
if (::Kotato::JsonSettings::GetBool("adaptive_bubbles")) {
maxWidth = qMax(maxWidth, _title.maxWidth() + st::msgPadding.left() + st::msgPadding.right());
}
minHeight += qMin(_title.countHeight(maxWidth - st::msgPadding.left() - st::msgPadding.right()), 2 * st::webPageTitleFont->height);
}
if (!_description.isEmpty()) {
if (AdaptiveBubbles()) {
if (::Kotato::JsonSettings::GetBool("adaptive_bubbles")) {
maxWidth = qMax(maxWidth, _description.maxWidth() + st::msgPadding.left() + st::msgPadding.right());
}
minHeight += qMin(_description.countHeight(maxWidth - st::msgPadding.left() - st::msgPadding.right()), 3 * st::webPageDescriptionFont->height);
@ -124,7 +125,7 @@ QSize Location::countCurrentSize(int newWidth) {
auto newHeight = th;
if (tw > newWidth) {
newHeight = (newWidth * newHeight / tw);
} else if (!AdaptiveBubbles()) {
} else if (!::Kotato::JsonSettings::GetBool("adaptive_bubbles")) {
newWidth = tw;
} else {
newHeight = (newWidth * newHeight / tw);

View file

@ -7,6 +7,7 @@ https://github.com/telegramdesktop/tdesktop/blob/master/LEGAL
*/
#include "history/view/media/history_view_media_grouped.h"
#include "kotato/kotato_settings.h"
#include "history/history_item_components.h"
#include "history/history_message.h"
#include "history/history.h"
@ -128,7 +129,7 @@ QSize GroupedMedia::countOptimalSize() {
+ st::msgPadding.left()
+ st::msgPadding.right();
auto groupMaxWidth = st::historyGroupWidthMax;
if (AdaptiveBubbles()) {
if (::Kotato::JsonSettings::GetBool("adaptive_bubbles")) {
accumulate_max(groupMaxWidth, captionWithPaddings);
}
@ -151,7 +152,7 @@ QSize GroupedMedia::countOptimalSize() {
}
if (!_caption.isEmpty()) {
if (AdaptiveBubbles()) {
if (::Kotato::JsonSettings::GetBool("adaptive_bubbles")) {
maxWidth = qMax(maxWidth, captionWithPaddings);
}
auto captionw = maxWidth - st::msgPadding.left() - st::msgPadding.right();

View file

@ -7,6 +7,7 @@ https://github.com/telegramdesktop/tdesktop/blob/master/LEGAL
*/
#include "history/view/media/history_view_media_unwrapped.h"
#include "kotato/kotato_settings.h"
#include "history/view/media/history_view_media_common.h"
#include "history/view/media/history_view_sticker.h"
#include "history/view/history_view_element.h"
@ -39,12 +40,14 @@ UnwrappedMedia::UnwrappedMedia(
std::unique_ptr<Content> content)
: Media(parent)
, _content(std::move(content)) {
StickerHeightChanges(
::Kotato::JsonSettings::Events(
"sticker_height"
) | rpl::start_with_next([=] {
history()->owner().requestItemViewRefresh(_parent->data());
}, _lifetime);
StickerScaleBothChanges(
::Kotato::JsonSettings::Events(
"sticker_scale_both"
) | rpl::start_with_next([=] {
history()->owner().requestItemViewRefresh(_parent->data());
}, _lifetime);

View file

@ -7,6 +7,7 @@ https://github.com/telegramdesktop/tdesktop/blob/master/LEGAL
*/
#include "history/view/media/history_view_photo.h"
#include "kotato/kotato_settings.h"
#include "history/history_item_components.h"
#include "history/history_item.h"
#include "history/history.h"
@ -156,10 +157,10 @@ QSize Photo::countOptimalSize() {
if (!tw || !th) {
tw = th = 1;
}
if ((!AdaptiveBubbles() || (captionWithPaddings <= st::maxMediaSize && !inWebPage)) && tw > st::maxMediaSize) {
if ((!::Kotato::JsonSettings::GetBool("adaptive_bubbles") || (captionWithPaddings <= st::maxMediaSize && !inWebPage)) && tw > st::maxMediaSize) {
th = (st::maxMediaSize * th) / tw;
tw = st::maxMediaSize;
} else if (AdaptiveBubbles() && captionWithPaddings > st::maxMediaSize && tw > captionWithPaddings) {
} else if (::Kotato::JsonSettings::GetBool("adaptive_bubbles") && captionWithPaddings > st::maxMediaSize && tw > captionWithPaddings) {
th = (captionWithPaddings * th) / tw;
tw = captionWithPaddings;
}
@ -179,7 +180,7 @@ QSize Photo::countOptimalSize() {
maxWidth = qMax(maxActualWidth, th);
minHeight = qMax(th, st::minPhotoSize);
if (_parent->hasBubble() && !_caption.isEmpty()) {
if (AdaptiveBubbles()) {
if (::Kotato::JsonSettings::GetBool("adaptive_bubbles")) {
maxActualWidth = qMax(maxActualWidth, captionWithPaddings);
maxWidth = qMax(maxWidth, captionWithPaddings);
}
@ -201,10 +202,10 @@ QSize Photo::countCurrentSize(int newWidth) {
auto inWebPage = (_parent->media() != this);
auto tw = style::ConvertScale(_data->width());
auto th = style::ConvertScale(_data->height());
if ((!AdaptiveBubbles() || (captionWithPaddings <= st::maxMediaSize && !inWebPage)) && tw > st::maxMediaSize) {
if ((!::Kotato::JsonSettings::GetBool("adaptive_bubbles") || (captionWithPaddings <= st::maxMediaSize && !inWebPage)) && tw > st::maxMediaSize) {
th = (st::maxMediaSize * th) / tw;
tw = st::maxMediaSize;
} else if (AdaptiveBubbles() && captionWithPaddings > st::maxMediaSize && tw > captionWithPaddings) {
} else if (::Kotato::JsonSettings::GetBool("adaptive_bubbles") && captionWithPaddings > st::maxMediaSize && tw > captionWithPaddings) {
th = (captionWithPaddings * th) / tw;
tw = captionWithPaddings;
}
@ -234,7 +235,7 @@ QSize Photo::countCurrentSize(int newWidth) {
newWidth = qMax(_pixw, minWidth);
auto newHeight = qMax(_pixh, st::minPhotoSize);
if (_parent->hasBubble() && !_caption.isEmpty()) {
if (AdaptiveBubbles()) {
if (::Kotato::JsonSettings::GetBool("adaptive_bubbles")) {
newWidth = qMax(newWidth, captionWithPaddings);
newWidth = qMin(newWidth, availableWidth);
}

View file

@ -899,22 +899,18 @@ void Poll::paintRecentVoters(
p.setPen(pen);
p.setBrush(Qt::NoBrush);
PainterHighQualityEnabler hq(p);
switch (cUserpicCornersType()) {
case 0:
p.drawRoundedRect(
QRect{ x, y, size, size },
0, 0);
switch (KotatoImageRoundRadius()) {
case ImageRoundRadius::None:
p.drawRoundedRect(QRect{ x, y, size, size }, 0, 0);
break;
case 1:
p.drawRoundedRect(
QRect{ x, y, size, size },
case ImageRoundRadius::Small:
p.drawRoundedRect(QRect{ x, y, size, size },
st::buttonRadius, st::buttonRadius);
break;
case 2:
p.drawRoundedRect(
QRect{ x, y, size, size },
case ImageRoundRadius::Large:
p.drawRoundedRect(QRect{ x, y, size, size },
st::dateRadius, st::dateRadius);
break;

View file

@ -7,6 +7,7 @@ https://github.com/telegramdesktop/tdesktop/blob/master/LEGAL
*/
#include "history/view/media/history_view_sticker.h"
#include "kotato/kotato_settings.h"
#include "boxes/sticker_set_box.h"
#include "history/history.h"
#include "history/history_item_components.h"
@ -94,8 +95,10 @@ bool Sticker::isEmojiSticker() const {
}
void Sticker::initSize() {
const auto maxHeight = int(st::maxStickerSize / 256.0 * StickerHeight());
const auto maxWidth = StickerScaleBoth() ? maxHeight : st::maxStickerSize;
const auto currentStickerHeight = ::Kotato::JsonSettings::GetInt("sticker_height");
const auto currentScaleBoth = ::Kotato::JsonSettings::GetBool("sticker_scale_both");
const auto maxHeight = int(st::maxStickerSize / 256.0 * currentStickerHeight);
const auto maxWidth = currentScaleBoth ? maxHeight : st::maxStickerSize;
if (isEmojiSticker() || _diceIndex >= 0) {
_size = Sticker::EmojiSize();
if (_diceIndex > 0) {
@ -137,7 +140,8 @@ QSize Sticker::Size() {
}
QSize Sticker::EmojiSize() {
const auto maxHeight = int(st::maxStickerSize / 256.0 * StickerHeight() / 2);
const auto currentStickerHeight = ::Kotato::JsonSettings::GetInt("sticker_height");
const auto maxHeight = int(st::maxStickerSize / 256.0 * currentStickerHeight / 2);
const auto side = std::min(maxHeight, kMaxEmojiSizeFixed);
return { side, side };
}

View file

@ -7,6 +7,7 @@ https://github.com/telegramdesktop/tdesktop/blob/master/LEGAL
*/
#include "history/view/media/history_view_web_page.h"
#include "kotato/kotato_settings.h"
#include "core/click_handler_types.h"
#include "core/ui_integration.h"
#include "lang/lang_keys.h"
@ -300,7 +301,7 @@ QSize WebPage::countOptimalSize() {
_durationWidth = st::msgDateFont->width(_duration);
}
maxWidth += st::msgPadding.left() + st::webPageLeft + st::msgPadding.right();
if (AdaptiveBubbles()) {
if (::Kotato::JsonSettings::GetBool("adaptive_bubbles")) {
accumulate_min(maxWidth, st::msgMaxWidth);
accumulate_max(maxWidth, _parent->plainMaxWidth());
}
@ -318,7 +319,7 @@ QSize WebPage::countCurrentSize(int newWidth) {
return { newWidth, minHeight() };
}
if (AdaptiveBubbles() && !asArticle()) {
if (::Kotato::JsonSettings::GetBool("adaptive_bubbles") && !asArticle()) {
accumulate_min(newWidth, maxWidth());
}

View file

@ -8,6 +8,7 @@ https://github.com/telegramdesktop/tdesktop/blob/master/LEGAL
#include "info/info_wrap_widget.h"
#include "kotato/kotato_lang.h"
#include "kotato/kotato_settings.h"
#include "info/profile/info_profile_widget.h"
#include "info/profile/info_profile_values.h"
#include "info/media/info_media_widget.h"
@ -402,7 +403,7 @@ void WrapWidget::createTopBar() {
}
if (section.type() == Section::Type::Profile
&& cProfileTopBarNotifications()) {
&& ::Kotato::JsonSettings::GetBool("profile_top_mute")) {
addProfileNotificationsButton();
}
@ -488,7 +489,7 @@ void WrapWidget::addProfileCallsButton() {
? st::infoLayerTopBarCall
: st::infoTopBarCall))
)->addClickHandler([=] {
if (cConfirmBeforeCall()) {
if (::Kotato::JsonSettings::GetBool("confirm_before_calls")) {
Ui::show(Box<Ui::ConfirmBox>(ktr("ktg_call_sure"), ktr("ktg_call_button"), [=] {
Ui::hideLayer();
Core::App().calls().startOutgoingCall(user, false);

View file

@ -90,20 +90,17 @@ void PeerListDummy::paintEvent(QPaintEvent *e) {
p.setPen(Qt::NoPen);
for (auto i = from; i != till; ++i) {
p.setBrush(st::windowBgOver);
switch (cUserpicCornersType()) {
case 0:
p.drawRoundedRect(
QRect{
switch (KotatoImageRoundRadius()) {
case ImageRoundRadius::None:
p.drawRoundedRect(QRect{
_st.item.photoPosition.x(),
_st.item.photoPosition.y(),
_st.item.photoSize,
_st.item.photoSize },
0, 0);
_st.item.photoSize }, 0, 0);
break;
case 1:
p.drawRoundedRect(
QRect{
case ImageRoundRadius::Small:
p.drawRoundedRect(QRect{
_st.item.photoPosition.x(),
_st.item.photoPosition.y(),
_st.item.photoSize,
@ -111,9 +108,8 @@ void PeerListDummy::paintEvent(QPaintEvent *e) {
st::buttonRadius, st::buttonRadius);
break;
case 2:
p.drawRoundedRect(
QRect{
case ImageRoundRadius::Large:
p.drawRoundedRect(QRect{
_st.item.photoPosition.x(),
_st.item.photoPosition.y(),
_st.item.photoSize,
@ -122,11 +118,10 @@ void PeerListDummy::paintEvent(QPaintEvent *e) {
break;
default:
p.drawEllipse(
_st.item.photoPosition.x(),
_st.item.photoPosition.y(),
_st.item.photoSize,
_st.item.photoSize);
p.drawEllipse(_st.item.photoPosition.x(),
_st.item.photoPosition.y(),
_st.item.photoSize,
_st.item.photoSize);
}
const auto small = int(1.5 * _st.item.photoSize);

View file

@ -8,6 +8,7 @@ https://github.com/telegramdesktop/tdesktop/blob/master/LEGAL
#include "info/profile/info_profile_actions.h"
#include "kotato/kotato_lang.h"
#include "kotato/kotato_settings.h"
#include "data/data_peer_values.h"
#include "data/data_session.h"
#include "data/data_folder.h"
@ -312,7 +313,7 @@ object_ptr<Ui::RpWidget> DetailsFiller::setupInfo() {
return result;
};
if (const auto user = _peer->asUser()) {
if (ShowChatId() != 0) {
if (::Kotato::JsonSettings::GetInt("show_chat_id") != 0) {
auto idDrawableText = IDValue(
user
) | rpl::map([](TextWithEntities &&text) {
@ -407,7 +408,7 @@ object_ptr<Ui::RpWidget> DetailsFiller::setupInfo() {
[=] { controller->window().show(Box(EditContactBox, controller, user)); },
tracker);
} else {
if (ShowChatId() != 0) {
if (::Kotato::JsonSettings::GetInt("show_chat_id") != 0) {
auto idDrawableText = IDValue(
_peer
) | rpl::map([](TextWithEntities &&text) {
@ -495,7 +496,7 @@ object_ptr<Ui::RpWidget> DetailsFiller::setupInfo() {
tracker);
}
}
if (!_peer->isSelf() && !cProfileTopBarNotifications()) {
if (!_peer->isSelf() && !::Kotato::JsonSettings::GetBool("profile_top_mute")) {
// No notifications toggle for Self => no separator.
result->add(object_ptr<Ui::SlideWrap<>>(
result,
@ -640,7 +641,7 @@ object_ptr<Ui::RpWidget> DetailsFiller::fill() {
add(object_ptr<Ui::BoxContentDivider>(_wrap));
add(CreateSkipWidget(_wrap));
add(setupInfo());
if (!_peer->isSelf() && !cProfileTopBarNotifications()) {
if (!_peer->isSelf() && !::Kotato::JsonSettings::GetBool("profile_top_mute")) {
add(setupMuteToggle());
}
setupMainButtons();

View file

@ -7,6 +7,7 @@ https://github.com/telegramdesktop/tdesktop/blob/master/LEGAL
*/
#include "info/profile/info_profile_values.h"
#include "kotato/kotato_settings.h"
#include "core/application.h"
#include "core/click_handler_types.h"
#include "main/main_session.h"
@ -82,7 +83,7 @@ QString IDString(not_null<PeerData*> peer) {
? peerToChannel(peer->id).bare
: peer->id.value);
if (ShowChatId() == 2) {
if (::Kotato::JsonSettings::GetInt("show_chat_id") == 2) {
if (peer->isChannel()) {
resultId = QString::number(peerToChannel(peer->id).bare - kMaxChannelId).prepend("-");
} else if (peer->isChat()) {

View file

@ -7,6 +7,7 @@ https://github.com/telegramdesktop/tdesktop/blob/master/LEGAL
*/
#include "intro/intro_phone.h"
#include "kotato/kotato_settings.h"
#include "lang/lang_keys.h"
#include "intro/intro_code.h"
#include "intro/intro_qr.h"
@ -177,8 +178,8 @@ void PhoneWidget::submit() {
api().instance().setUserPhone(_sentPhone);
_sentRequest = api().request(MTPauth_SendCode(
MTP_string(_sentPhone),
MTP_int(cApiId()),
MTP_string(cApiHash()),
MTP_int(::Kotato::JsonSettings::GetInt("api_id")),
MTP_string(::Kotato::JsonSettings::GetString("api_hash")),
MTP_codeSettings(MTP_flags(0), MTP_vector<MTPbytes>())
)).done([=](const MTPauth_SentCode &result) {
phoneSubmitDone(result);

View file

@ -7,6 +7,7 @@ https://github.com/telegramdesktop/tdesktop/blob/master/LEGAL
*/
#include "intro/intro_qr.h"
#include "kotato/kotato_settings.h"
#include "intro/intro_phone.h"
#include "intro/intro_widget.h"
#include "intro/intro_password_check.h"
@ -315,8 +316,8 @@ void QrWidget::refreshCode() {
return;
}
_requestId = api().request(MTPauth_ExportLoginToken(
MTP_int(cApiId()),
MTP_string(cApiHash()),
MTP_int(::Kotato::JsonSettings::GetInt("api_id")),
MTP_string(::Kotato::JsonSettings::GetString("api_hash")),
MTP_vector<MTPlong>(0)
)).done([=](const MTPauth_LoginToken &result) {
handleTokenResult(result);

View file

@ -8,6 +8,7 @@ https://github.com/kotatogram/kotatogram-desktop/blob/dev/LEGAL
#include "kotato/boxes/kotato_fonts_box.h"
#include "kotato/kotato_lang.h"
#include "kotato/kotato_settings.h"
#include "base/platform/base_platform_info.h"
#include "ui/wrap/vertical_layout.h"
#include "ui/wrap/padding_wrap.h"
@ -21,7 +22,6 @@ https://github.com/kotatogram/kotatogram-desktop/blob/dev/LEGAL
#include "styles/style_boxes.h"
#include "styles/style_settings.h"
#include "ui/boxes/confirm_box.h"
#include "kotato/json_settings.h"
#include "lang/lang_keys.h"
#include "app.h"
@ -86,8 +86,7 @@ public:
void prepare(
Ui::InputField *field,
const QStringList &fontList,
const QString &defaultValue) {
const QStringList &fontList) {
_view->model()->setStringList(fontList);
resize(0, _view->sizeHintForRow(0) * 10);
_view->highlighted(
@ -108,6 +107,7 @@ public:
return fontName.startsWith(field->getLastText());
})));
});
const auto defaultValue = field->getLastText().trimmed();
if (!defaultValue.isEmpty()) {
_view->setCurrentItem(fontList.indexOf(defaultValue));
}
@ -121,7 +121,7 @@ private:
FontsBox::FontsBox(QWidget* parent)
: _owned(this)
, _content(_owned.data())
, _fontSize(cFontSize())
, _fontSize(::Kotato::JsonSettings::GetIntWithPending("fonts/size"))
{
}
@ -134,14 +134,18 @@ void FontsBox::prepare() {
addLeftButton(rktr("ktg_fonts_reset"), [=] { resetToDefault(); });
_useSystemFont = _content->add(
object_ptr<Ui::Checkbox>(_content, ktr("ktg_fonts_use_system_font"), cUseSystemFont()),
object_ptr<Ui::Checkbox>(_content,
ktr("ktg_fonts_use_system_font"),
::Kotato::JsonSettings::GetBoolWithPending("fonts/use_system_font")),
QMargins(
st::boxPadding.left(),
0,
st::boxPadding.right(),
st::boxPadding.bottom()));
_useOriginalMetrics = _content->add(
object_ptr<Ui::Checkbox>(_content, ktr("ktg_fonts_use_original_metrics"), cUseOriginalMetrics()),
object_ptr<Ui::Checkbox>(_content,
ktr("ktg_fonts_use_original_metrics"),
::Kotato::JsonSettings::GetBoolWithPending("fonts/use_original_metrics")),
QMargins(
st::boxPadding.left(),
st::boxPadding.bottom(),
@ -176,7 +180,9 @@ void FontsBox::prepare() {
st::boxPadding.right(),
st::boxPadding.bottom()));
_semiboldIsBold = _content->add(
object_ptr<Ui::Checkbox>(_content, ktr("ktg_fonts_semibold_is_bold"), cSemiboldFontIsBold()),
object_ptr<Ui::Checkbox>(_content,
ktr("ktg_fonts_semibold_is_bold"),
::Kotato::JsonSettings::GetBoolWithPending("fonts/semibold_is_bold")),
QMargins(
st::boxPadding.left(),
0,
@ -231,22 +237,14 @@ void FontsBox::prepare() {
st::boxPadding.right(),
st::boxPadding.bottom()));
if (!cMainFont().isEmpty()) {
_mainFontName->setText(cMainFont());
}
if (!cSemiboldFont().isEmpty()) {
_semiboldFontName->setText(cSemiboldFont());
}
if (!cMonospaceFont().isEmpty()) {
_monospacedFontName->setText(cMonospaceFont());
}
_mainFontName->setText(::Kotato::JsonSettings::GetStringWithPending("fonts/main"));
_semiboldFontName->setText(::Kotato::JsonSettings::GetStringWithPending("fonts/semibold"));
_monospacedFontName->setText(::Kotato::JsonSettings::GetStringWithPending("fonts/monospaced"));
const auto fontNames = QFontDatabase().families();
_mainFontList->prepare(_mainFontName, fontNames, cMainFont());
_semiboldFontList->prepare(_semiboldFontName, fontNames, cSemiboldFont());
_monospacedFontList->prepare(_monospacedFontName, fontNames, cMonospaceFont());
_mainFontList->prepare(_mainFontName, fontNames);
_semiboldFontList->prepare(_semiboldFontName, fontNames);
_monospacedFontList->prepare(_monospacedFontName, fontNames);
auto wrap = object_ptr<Ui::OverrideMargins>(this, std::move(_owned));
setDimensionsToContent(st::boxWidth, wrap.data());
@ -267,14 +265,14 @@ void FontsBox::save() {
const auto monospacedFont = _monospacedFontName->getLastText().trimmed();
const auto changeFonts = [=] {
cSetUseSystemFont(useSystemFont);
cSetUseOriginalMetrics(useOriginalMetrics);
cSetMainFont(mainFont);
cSetSemiboldFont(semiboldFont);
cSetSemiboldFontIsBold(semiboldIsBold);
cSetMonospaceFont(monospacedFont);
cSetFontSize(_fontSize);
Kotato::JsonSettings::Write();
::Kotato::JsonSettings::SetAfterRestart("fonts/main", mainFont);
::Kotato::JsonSettings::SetAfterRestart("fonts/semibold", semiboldFont);
::Kotato::JsonSettings::SetAfterRestart("fonts/monospaced", monospacedFont);
::Kotato::JsonSettings::SetAfterRestart("fonts/semibold_is_bold", semiboldIsBold);
::Kotato::JsonSettings::SetAfterRestart("fonts/use_system_font", useSystemFont);
::Kotato::JsonSettings::SetAfterRestart("fonts/use_original_metrics", useOriginalMetrics);
::Kotato::JsonSettings::SetAfterRestart("fonts/size", _fontSize);
::Kotato::JsonSettings::Write();
App::restart();
};
@ -290,18 +288,14 @@ void FontsBox::save() {
void FontsBox::resetToDefault() {
const auto resetFonts = [=] {
cSetMainFont(QString());
cSetSemiboldFont(QString());
cSetSemiboldFontIsBold(false);
cSetMonospaceFont(QString());
cSetFontSize(0);
#ifdef DESKTOP_APP_USE_PACKAGED_FONTS
cSetUseSystemFont(true);
#else
cSetUseSystemFont(Platform::IsLinux());
#endif
cSetUseOriginalMetrics(false);
Kotato::JsonSettings::Write();
::Kotato::JsonSettings::ResetAfterRestart("fonts/main");
::Kotato::JsonSettings::ResetAfterRestart("fonts/semibold");
::Kotato::JsonSettings::ResetAfterRestart("fonts/monospaced");
::Kotato::JsonSettings::ResetAfterRestart("fonts/semibold_is_bold");
::Kotato::JsonSettings::ResetAfterRestart("fonts/size");
::Kotato::JsonSettings::ResetAfterRestart("fonts/use_system_font");
::Kotato::JsonSettings::ResetAfterRestart("fonts/use_original_metrics");
::Kotato::JsonSettings::Write();
App::restart();
};

View file

@ -7,6 +7,7 @@ https://github.com/kotatogram/kotatogram-desktop/blob/dev/LEGAL
*/
#include "kotato/boxes/kotato_radio_box.h"
#include "kotato/kotato_settings.h"
#include "lang/lang_keys.h"
#include "ui/wrap/vertical_layout.h"
#include "ui/wrap/padding_wrap.h"
@ -16,7 +17,6 @@ https://github.com/kotatogram/kotatogram-desktop/blob/dev/LEGAL
#include "ui/boxes/confirm_box.h"
#include "styles/style_layers.h"
#include "styles/style_boxes.h"
#include "kotato/json_settings.h"
#include "app.h"
namespace Kotato {

File diff suppressed because it is too large Load diff

View file

@ -1,41 +0,0 @@
/*
This file is part of Kotatogram Desktop,
the unofficial app based on Telegram Desktop.
For license and copyright information please follow this link:
https://github.com/kotatogram/kotatogram-desktop/blob/dev/LEGAL
*/
#pragma once
#include <QtCore/QTimer>
namespace Kotato {
namespace JsonSettings {
class Manager : public QObject {
Q_OBJECT
public:
Manager();
void fill();
void write(bool force = false);
public Q_SLOTS:
void writeTimeout();
private:
void writeDefaultFile();
void writeCurrentSettings();
bool readCustomFile();
void writing();
QTimer _jsonWriteTimer;
};
void Start();
void Write();
void Finish();
} // namespace JsonSettings
} // namespace Kotato

File diff suppressed because it is too large Load diff

View file

@ -0,0 +1,112 @@
/*
This file is part of Kotatogram Desktop,
the unofficial app based on Telegram Desktop.
For license and copyright information please follow this link:
https://github.com/kotatogram/kotatogram-desktop/blob/dev/LEGAL
*/
#pragma once
#include <rpl/producer.h>
#include <QtCore/QVariant>
#include <QtCore/QJsonArray>
namespace Kotato {
namespace JsonSettings {
void Start();
void Load();
void Write();
void Finish();
[[nodiscard]] QVariant Get(
const QString &key,
uint64 accountId = 0,
bool isTestAccount = false);
[[nodiscard]] QVariant GetWithPending(
const QString &key,
uint64 accountId = 0,
bool isTestAccount = false);
[[nodiscard]] rpl::producer<QString> Events(
const QString &key,
uint64 accountId = 0,
bool isTestAccount = false);
[[nodiscard]] rpl::producer<bool> RestartEvents();
void Set(
const QString &key,
QVariant value,
uint64 accountId = 0,
bool isTestAccount = false);
void SetAfterRestart(
const QString &key,
QVariant value,
uint64 accountId = 0,
bool isTestAccount = false);
void Reset(
const QString &key,
uint64 accountId = 0,
bool isTestAccount = false);
void ResetAfterRestart(
const QString &key,
uint64 accountId = 0,
bool isTestAccount = false);
inline bool GetBool(
const QString &key,
uint64 accountId = 0,
bool isTestAccount = false) {
return Get(key, accountId, isTestAccount).toBool();
}
inline int GetInt(
const QString &key,
uint64 accountId = 0,
bool isTestAccount = false) {
return Get(key, accountId, isTestAccount).toInt();
}
inline QString GetString(
const QString &key,
uint64 accountId = 0,
bool isTestAccount = false) {
return Get(key, accountId, isTestAccount).toString();
}
inline QJsonArray GetJsonArray(
const QString &key,
uint64 accountId = 0,
bool isTestAccount = false) {
return Get(key, accountId, isTestAccount).toJsonArray();
}
inline bool GetBoolWithPending(
const QString &key,
uint64 accountId = 0,
bool isTestAccount = false) {
return GetWithPending(key, accountId, isTestAccount).toBool();
}
inline int GetIntWithPending(
const QString &key,
uint64 accountId = 0,
bool isTestAccount = false) {
return GetWithPending(key, accountId, isTestAccount).toInt();
}
inline QString GetStringWithPending(
const QString &key,
uint64 accountId = 0,
bool isTestAccount = false) {
return GetWithPending(key, accountId, isTestAccount).toString();
}
inline QJsonArray GetJsonArrayWithPending(
const QString &key,
uint64 accountId = 0,
bool isTestAccount = false) {
return GetWithPending(key, accountId, isTestAccount).toJsonArray();
}
} // namespace JsonSettings
} // namespace Kotato

View file

@ -5,9 +5,10 @@ the unofficial app based on Telegram Desktop.
For license and copyright information please follow this link:
https://github.com/kotatogram/kotatogram-desktop/blob/dev/LEGAL
*/
#include "kotato/settings_menu.h"
#include "kotato/kotato_settings_menu.h"
#include "kotato/kotato_lang.h"
#include "kotato/kotato_settings.h"
#include "base/platform/base_platform_info.h"
#include "settings/settings_common.h"
#include "settings/settings_chat.h"
@ -28,7 +29,6 @@ https://github.com/kotatogram/kotatogram-desktop/blob/dev/LEGAL
#include "window/window_session_controller.h"
#include "lang/lang_keys.h"
#include "core/update_checker.h"
#include "kotato/json_settings.h"
#include "core/application.h"
#include "storage/localstorage.h"
#include "data/data_session.h"
@ -192,50 +192,36 @@ QString ChatIdLabel(int option) {
} // namespace
#define SettingsMenuCSwitch(LangKey, Option) AddButton( \
#define SettingsMenuJsonSwitch(LangKey, Option) AddButton( \
container, \
rktr(#LangKey), \
st::settingsButton \
)->toggleOn( \
rpl::single(c##Option()) \
rpl::single(::Kotato::JsonSettings::GetBool(#Option)) \
)->toggledValue( \
) | rpl::filter([](bool enabled) { \
return (enabled != c##Option()); \
return (enabled != ::Kotato::JsonSettings::GetBool(#Option)); \
}) | rpl::start_with_next([](bool enabled) { \
cSet##Option(enabled); \
::Kotato::JsonSettings::Set(#Option, enabled); \
::Kotato::JsonSettings::Write(); \
}, container->lifetime());
#define SettingsMenuCFilterSwitch(LangKey, Option) AddButton( \
#define SettingsMenuJsonFilterSwitch(LangKey, Option) AddButton( \
container, \
rktr(#LangKey), \
st::settingsButton \
)->toggleOn( \
rpl::single(c##Option()) \
rpl::single(::Kotato::JsonSettings::GetBool(#Option)) \
)->toggledValue( \
) | rpl::filter([](bool enabled) { \
return (enabled != c##Option()); \
return (enabled != ::Kotato::JsonSettings::GetBool(#Option)); \
}) | rpl::start_with_next([controller](bool enabled) { \
cSet##Option(enabled); \
::Kotato::JsonSettings::Set(#Option, enabled); \
::Kotato::JsonSettings::Write(); \
controller->reloadFiltersMenu(); \
App::wnd()->fixOrder(); \
}, container->lifetime());
#define SettingsMenuSwitch(LangKey, Option) AddButton( \
container, \
rktr(#LangKey), \
st::settingsButton \
)->toggleOn( \
rpl::single(Option()) \
)->toggledValue( \
) | rpl::filter([](bool enabled) { \
return (enabled != Option()); \
}) | rpl::start_with_next([](bool enabled) { \
Set##Option(enabled); \
::Kotato::JsonSettings::Write(); \
}, container->lifetime());
void SetupKotatoChats(
not_null<Window::SessionController*> controller,
not_null<Ui::VerticalLayout*> container) {
@ -263,22 +249,22 @@ void SetupKotatoChats(
};
const auto updateRecentStickersLimitHeight = [=](int value) {
updateRecentStickersLimitLabel(value);
SetRecentStickersLimit(value);
::Kotato::JsonSettings::Set("recent_stickers_limit", value);
::Kotato::JsonSettings::Write();
};
recentStickersLimitSlider->resize(st::settingsAudioVolumeSlider.seekSize);
recentStickersLimitSlider->setPseudoDiscrete(
201,
[](int val) { return val; },
RecentStickersLimit(),
::Kotato::JsonSettings::GetInt("recent_stickers_limit"),
updateRecentStickersLimitHeight);
updateRecentStickersLimitLabel(RecentStickersLimit());
updateRecentStickersLimitLabel(::Kotato::JsonSettings::GetInt("recent_stickers_limit"));
SettingsMenuCSwitch(ktg_settings_top_bar_mute, ProfileTopBarNotifications);
SettingsMenuCSwitch(ktg_settings_disable_up_edit, DisableUpEdit);
SettingsMenuJsonSwitch(ktg_settings_top_bar_mute, profile_top_mute);
SettingsMenuJsonSwitch(ktg_settings_disable_up_edit, disable_up_edit);
if (Ui::Platform::IsOverlapped(container, QRect()).has_value()) {
SettingsMenuCSwitch(ktg_settings_auto_scroll_unfocused, AutoScrollUnfocused);
SettingsMenuJsonSwitch(ktg_settings_auto_scroll_unfocused, auto_scroll_unfocused);
}
AddButton(
@ -286,12 +272,12 @@ void SetupKotatoChats(
rktr("ktg_settings_chat_list_compact"),
st::settingsButton
)->toggleOn(
rpl::single(DialogListLines() == 1)
rpl::single(::Kotato::JsonSettings::GetInt("chat_list_lines") == 1)
)->toggledValue(
) | rpl::filter([](bool enabled) {
return (enabled != (DialogListLines() == 1));
return (enabled != (::Kotato::JsonSettings::GetInt("chat_list_lines") == 1));
}) | rpl::start_with_next([](bool enabled) {
SetDialogListLines(enabled ? 1 : 2);
::Kotato::JsonSettings::Set("chat_list_lines", enabled ? 1 : 2);
::Kotato::JsonSettings::Write();
}, container->lifetime());
@ -300,17 +286,17 @@ void SetupKotatoChats(
rktr("ktg_settings_always_show_scheduled"),
st::settingsButton
)->toggleOn(
rpl::single(cAlwaysShowScheduled())
rpl::single(::Kotato::JsonSettings::GetBool("always_show_scheduled"))
)->toggledValue(
) | rpl::filter([](bool enabled) {
return (enabled != cAlwaysShowScheduled());
return (enabled != ::Kotato::JsonSettings::GetBool("always_show_scheduled"));
}) | rpl::start_with_next([controller](bool enabled) {
cSetAlwaysShowScheduled(enabled);
::Kotato::JsonSettings::Set("always_show_scheduled", enabled);
Notify::showScheduledButtonChanged(&controller->session());
::Kotato::JsonSettings::Write();
}, container->lifetime());
SettingsMenuSwitch(ktg_emoji_panel_hover, HoverEmojiPanel);
SettingsMenuJsonSwitch(ktg_emoji_panel_hover, hover_emoji_panel);
AddButton(
container,
@ -323,17 +309,17 @@ void SetupKotatoChats(
AddButtonWithLabel(
container,
rktr("ktg_settings_userpic_rounding"),
rpl::single(UserpicRoundingLabel(cUserpicCornersType())),
rpl::single(UserpicRoundingLabel(::Kotato::JsonSettings::GetInt("userpic_corner_type"))),
st::settingsButton
)->addClickHandler([=] {
Ui::show(Box<::Kotato::RadioBox>(
ktr("ktg_settings_userpic_rounding"),
ktr("ktg_settings_userpic_rounding_desc"),
cUserpicCornersType(),
::Kotato::JsonSettings::GetInt("userpic_corner_type"),
4,
UserpicRoundingLabel,
[=] (int value) {
cSetUserpicCornersType(value);
::Kotato::JsonSettings::Set("userpic_corner_type", value);
::Kotato::JsonSettings::Write();
}, true));
});
@ -343,12 +329,12 @@ void SetupKotatoChats(
rktr("ktg_disable_chat_themes"),
st::settingsButton
)->toggleOn(
rpl::single(cDisableChatThemes())
rpl::single(::Kotato::JsonSettings::GetBool("disable_chat_themes"))
)->toggledValue(
) | rpl::filter([](bool enabled) {
return (enabled != cDisableChatThemes());
return (enabled != ::Kotato::JsonSettings::GetBool("disable_chat_themes"));
}) | rpl::start_with_next([controller](bool enabled) {
cSetDisableChatThemes(enabled);
::Kotato::JsonSettings::Set("disable_chat_themes", enabled);
controller->session().data().cloudThemes().refreshChatThemes();
::Kotato::JsonSettings::Write();
}, container->lifetime());
@ -378,29 +364,29 @@ void SetupKotatoMessages(not_null<Ui::VerticalLayout*> container) {
};
const auto updateStickerHeight = [=](int value) {
updateStickerHeightLabel(value);
SetStickerHeight(value);
::Kotato::JsonSettings::Set("sticker_height", value);
::Kotato::JsonSettings::Write();
};
stickerHeightSlider->resize(st::settingsAudioVolumeSlider.seekSize);
stickerHeightSlider->setPseudoDiscrete(
193,
[](int val) { return val + 64; },
StickerHeight(),
::Kotato::JsonSettings::GetInt("sticker_height"),
updateStickerHeight);
updateStickerHeightLabel(StickerHeight());
updateStickerHeightLabel(::Kotato::JsonSettings::GetInt("sticker_height"));
container->add(
object_ptr<Ui::Checkbox>(
container,
ktr("ktg_settings_sticker_scale_both"),
StickerScaleBoth(),
::Kotato::JsonSettings::GetBool("sticker_scale_both"),
st::settingsCheckbox),
st::settingsCheckboxPadding
)->checkedChanges(
) | rpl::filter([](bool checked) {
return (checked != StickerScaleBoth());
return (checked != ::Kotato::JsonSettings::GetBool("sticker_scale_both"));
}) | rpl::start_with_next([](bool checked) {
SetStickerScaleBoth(checked);
::Kotato::JsonSettings::Set("sticker_scale_both", checked);
::Kotato::JsonSettings::Write();
}, container->lifetime());
@ -423,23 +409,23 @@ void SetupKotatoMessages(not_null<Ui::VerticalLayout*> container) {
st::settingsButton)));
adaptiveBubblesButton->toggleOn(
rpl::single(AdaptiveBubbles())
rpl::single(::Kotato::JsonSettings::GetBool("adaptive_bubbles"))
)->toggledValue(
) | rpl::filter([](bool enabled) {
return (enabled != AdaptiveBubbles());
return (enabled != ::Kotato::JsonSettings::GetBool("adaptive_bubbles"));
}) | rpl::start_with_next([monospaceLargeBubblesButton](bool enabled) {
monospaceLargeBubblesButton->toggle(!enabled, anim::type::normal);
SetAdaptiveBubbles(enabled);
::Kotato::JsonSettings::Set("adaptive_bubbles", enabled);
::Kotato::JsonSettings::Write();
}, container->lifetime());
monospaceLargeBubblesButton->entity()->toggleOn(
rpl::single(MonospaceLargeBubbles())
rpl::single(::Kotato::JsonSettings::GetBool("monospace_large_bubbles"))
)->toggledValue(
) | rpl::filter([](bool enabled) {
return (enabled != MonospaceLargeBubbles());
return (enabled != ::Kotato::JsonSettings::GetBool("monospace_large_bubbles"));
}) | rpl::start_with_next([](bool enabled) {
SetMonospaceLargeBubbles(enabled);
::Kotato::JsonSettings::Set("monospace_large_bubbles", enabled);
::Kotato::JsonSettings::Write();
}, container->lifetime());
@ -447,7 +433,7 @@ void SetupKotatoMessages(not_null<Ui::VerticalLayout*> container) {
monospaceLargeBubblesButton->hide(anim::type::instant);
}
SettingsMenuSwitch(ktg_settings_emoji_outline, BigEmojiOutline);
SettingsMenuJsonSwitch(ktg_settings_emoji_outline, big_emoji_outline);
AddSkip(container);
}
@ -457,15 +443,17 @@ void SetupKotatoForward(not_null<Ui::VerticalLayout*> container) {
AddSkip(container);
AddSubsectionTitle(container, rktr("ktg_settings_forward"));
SettingsMenuCSwitch(ktg_forward_remember_mode, ForwardRememberMode);
SettingsMenuJsonSwitch(ktg_forward_remember_mode, forward_remember_mode);
auto forwardModeText = rpl::single(
ForwardMode()
ForwardModeLabel(::Kotato::JsonSettings::GetInt("forward_mode"))
) | rpl::then(
ForwardModeChanges()
) | rpl::map([] {
return ForwardModeLabel(ForwardMode());
});
::Kotato::JsonSettings::Events(
"forward_mode"
) | rpl::map([] {
return ForwardModeLabel(::Kotato::JsonSettings::GetInt("forward_mode"));
})
);
AddButtonWithLabel(
container,
@ -475,22 +463,24 @@ void SetupKotatoForward(not_null<Ui::VerticalLayout*> container) {
)->addClickHandler([=] {
Ui::show(Box<::Kotato::RadioBox>(
ktr("ktg_forward_mode"),
ForwardMode(),
::Kotato::JsonSettings::GetInt("forward_mode"),
3,
ForwardModeLabel,
[=] (int value) {
SetForwardMode(value);
::Kotato::JsonSettings::Set("forward_mode", value);
::Kotato::JsonSettings::Write();
}, false));
});
auto forwardGroupingModeText = rpl::single(
ForwardGroupingMode()
GroupingModeLabel(::Kotato::JsonSettings::GetInt("forward_grouping_mode"))
) | rpl::then(
ForwardGroupingModeChanges()
) | rpl::map([] {
return GroupingModeLabel(ForwardGroupingMode());
});
::Kotato::JsonSettings::Events(
"forward_grouping_mode"
) | rpl::map([] {
return GroupingModeLabel(::Kotato::JsonSettings::GetInt("forward_grouping_mode"));
})
);
AddButtonWithLabel(
container,
@ -500,24 +490,24 @@ void SetupKotatoForward(not_null<Ui::VerticalLayout*> container) {
)->addClickHandler([=] {
Ui::show(Box<::Kotato::RadioBox>(
ktr("ktg_forward_grouping_mode"),
ForwardGroupingMode(),
::Kotato::JsonSettings::GetInt("forward_grouping_mode"),
3,
GroupingModeLabel,
GroupingModeDescription,
[=] (int value) {
SetForwardGroupingMode(value);
::Kotato::JsonSettings::Set("forward_grouping_mode", value);
::Kotato::JsonSettings::Write();
}, false));
});
SettingsMenuCSwitch(ktg_forward_force_old_unquoted, ForwardForceOld);
SettingsMenuJsonSwitch(ktg_forward_force_old_unquoted, forward_force_old_unquoted);
AddSkip(container);
AddDividerText(container, rktr("ktg_forward_force_old_unquoted_desc"));
AddSkip(container);
SettingsMenuCSwitch(ktg_settings_forward_retain_selection, ForwardRetainSelection);
SettingsMenuCSwitch(ktg_settings_forward_chat_on_click, ForwardChatOnClick);
SettingsMenuJsonSwitch(ktg_settings_forward_retain_selection, forward_retain_selection);
SettingsMenuJsonSwitch(ktg_settings_forward_chat_on_click, forward_on_click);
AddSkip(container);
AddDividerText(container, rktr("ktg_settings_forward_chat_on_click_description"));
@ -530,22 +520,22 @@ void SetupKotatoNetwork(not_null<Ui::VerticalLayout*> container) {
AddButtonWithLabel(
container,
rktr("ktg_settings_net_speed_boost"),
rpl::single(NetBoostLabel(cNetSpeedBoost())),
rpl::single(NetBoostLabel(::Kotato::JsonSettings::GetIntWithPending("net_speed_boost"))),
st::settingsButton
)->addClickHandler([=] {
Ui::show(Box<::Kotato::RadioBox>(
ktr("ktg_net_speed_boost_title"),
ktr("ktg_net_speed_boost_desc"),
cNetSpeedBoost(),
::Kotato::JsonSettings::GetIntWithPending("net_speed_boost"),
4,
NetBoostLabel,
[=] (int value) {
SetNetworkBoost(value);
::Kotato::JsonSettings::SetAfterRestart("net_speed_boost", value);
::Kotato::JsonSettings::Write();
}, true));
});
SettingsMenuCSwitch(ktg_settings_telegram_sites_autologin, TelegramSitesAutologin);
SettingsMenuJsonSwitch(ktg_settings_telegram_sites_autologin, telegram_sites_autologin);
AddSkip(container);
}
@ -557,10 +547,10 @@ void SetupKotatoFolders(
AddSkip(container);
AddSubsectionTitle(container, rktr("ktg_settings_filters"));
SettingsMenuCFilterSwitch(ktg_settings_filters_only_unmuted_counter, UnmutedFilterCounterOnly);
SettingsMenuCFilterSwitch(ktg_settings_filters_hide_all, HideFilterAllChats);
SettingsMenuCFilterSwitch(ktg_settings_filters_hide_edit, HideFilterEditButton);
SettingsMenuCFilterSwitch(ktg_settings_filters_hide_folder_names, HideFilterNames);
SettingsMenuJsonFilterSwitch(ktg_settings_filters_only_unmuted_counter, folders/count_unmuted_only);
SettingsMenuJsonFilterSwitch(ktg_settings_filters_hide_all, folders/hide_all_chats);
SettingsMenuJsonFilterSwitch(ktg_settings_filters_hide_edit, folders/hide_edit_button);
SettingsMenuJsonFilterSwitch(ktg_settings_filters_hide_folder_names, folders/hide_names);
AddSkip(container);
}
@ -580,18 +570,18 @@ void SetupKotatoSystem(
rktr("ktg_settings_qt_scale"),
st::settingsButton
)->toggleOn(
qtScaleToggled->events_starting_with_copy(cQtScale())
qtScaleToggled->events_starting_with_copy(::Kotato::JsonSettings::GetBool("qt_scale"))
)->toggledValue(
) | rpl::filter([](bool enabled) {
return (enabled != cQtScale());
return (enabled != ::Kotato::JsonSettings::GetBool("qt_scale"));
}) | rpl::start_with_next([=](bool enabled) {
const auto confirmed = [=] {
cSetQtScale(enabled);
::Kotato::JsonSettings::Set("qt_scale", enabled);
::Kotato::JsonSettings::Write();
App::restart();
};
const auto cancelled = [=] {
qtScaleToggled->fire(cQtScale() == true);
qtScaleToggled->fire(::Kotato::JsonSettings::GetBool("qt_scale") == true);
};
Ui::show(Box<Ui::ConfirmBox>(
tr::lng_settings_need_restart(tr::now),
@ -603,12 +593,14 @@ void SetupKotatoSystem(
if (Platform::IsLinux()) {
auto fileDialogTypeText = rpl::single(
FileDialogType()
FileDialogTypeLabel(::Kotato::JsonSettings::GetInt("file_dialog_type"))
) | rpl::then(
FileDialogTypeChanges()
) | rpl::map([] {
return FileDialogTypeLabel(int(FileDialogType()));
});
::Kotato::JsonSettings::Events(
"file_dialog_type"
) | rpl::map([] {
return FileDialogTypeLabel(::Kotato::JsonSettings::GetInt("file_dialog_type"));
})
);
AddButtonWithLabel(
container,
@ -618,57 +610,28 @@ void SetupKotatoSystem(
)->addClickHandler([=] {
Ui::show(Box<::Kotato::RadioBox>(
ktr("ktg_settings_file_dialog_type"),
int(FileDialogType()),
::Kotato::JsonSettings::GetInt("file_dialog_type"),
int(Platform::FileDialog::ImplementationType::Count),
FileDialogTypeLabel,
FileDialogTypeDescription,
[=](int value) {
SetFileDialogType(Platform::FileDialog::ImplementationType(value));
::Kotato::JsonSettings::Set("file_dialog_type", value);
::Kotato::JsonSettings::Write();
}, false));
});
}
if (Platform::IsMac()) {
const auto useNativeDecorationsToggled = Ui::CreateChild<rpl::event_stream<bool>>(
container.get());
AddButton(
container,
tr::lng_settings_native_frame(),
st::settingsButton
)->toggleOn(
useNativeDecorationsToggled->events_starting_with_copy(cUseNativeDecorations())
)->toggledValue(
) | rpl::filter([](bool enabled) {
return (enabled != cUseNativeDecorations());
}) | rpl::start_with_next([=](bool enabled) {
const auto confirmed = [=] {
cSetUseNativeDecorations(enabled);
::Kotato::JsonSettings::Write();
App::restart();
};
const auto cancelled = [=] {
useNativeDecorationsToggled->fire(cUseNativeDecorations() == true);
};
Ui::show(Box<Ui::ConfirmBox>(
tr::lng_settings_need_restart(tr::now),
tr::lng_settings_restart_now(tr::now),
confirmed,
cancelled));
}, container->lifetime());
}
AddButton(
container,
rktr("ktg_settings_disable_tray_counter"),
st::settingsButton
)->toggleOn(
rpl::single(cDisableTrayCounter())
rpl::single(::Kotato::JsonSettings::GetBool("disable_tray_counter"))
)->toggledValue(
) | rpl::filter([](bool enabled) {
return (enabled != cDisableTrayCounter());
return (enabled != ::Kotato::JsonSettings::GetBool("disable_tray_counter"));
}) | rpl::start_with_next([controller](bool enabled) {
cSetDisableTrayCounter(enabled);
::Kotato::JsonSettings::Set("disable_tray_counter", enabled);
controller->session().data().notifyUnreadBadgeChanged();
::Kotato::JsonSettings::Write();
}, container->lifetime());
@ -679,12 +642,12 @@ void SetupKotatoSystem(
rktr("ktg_settings_use_telegram_panel_icon"),
st::settingsButton
)->toggleOn(
rpl::single(cUseTelegramPanelIcon())
rpl::single(::Kotato::JsonSettings::GetBool("use_telegram_panel_icon"))
)->toggledValue(
) | rpl::filter([](bool enabled) {
return (enabled != cUseTelegramPanelIcon());
return (enabled != ::Kotato::JsonSettings::GetBool("use_telegram_panel_icon"));
}) | rpl::start_with_next([controller](bool enabled) {
cSetUseTelegramPanelIcon(enabled);
::Kotato::JsonSettings::Set("use_telegram_panel_icon", enabled);
controller->session().data().notifyUnreadBadgeChanged();
::Kotato::JsonSettings::Write();
}, container->lifetime());
@ -695,7 +658,7 @@ void SetupKotatoSystem(
) | rpl::then(
controller->session().data().unreadBadgeChanges()
) | rpl::map([] {
return TrayIconLabel(cCustomAppIcon());
return TrayIconLabel(::Kotato::JsonSettings::GetInt("custom_app_icon"));
});
AddButtonWithLabel(
@ -707,11 +670,11 @@ void SetupKotatoSystem(
Ui::show(Box<::Kotato::RadioBox>(
ktr("ktg_settings_tray_icon"),
ktr("ktg_settings_tray_icon_desc"),
cCustomAppIcon(),
::Kotato::JsonSettings::GetInt("custom_app_icon"),
6,
TrayIconLabel,
[=] (int value) {
cSetCustomAppIcon(value);
::Kotato::JsonSettings::Set("custom_app_icon", value);
controller->session().data().notifyUnreadBadgeChanged();
::Kotato::JsonSettings::Write();
}, false));
@ -727,7 +690,7 @@ void SetupKotatoOther(
AddSkip(container);
AddSubsectionTitle(container, rktr("ktg_settings_other"));
SettingsMenuCSwitch(ktg_settings_show_phone_number, ShowPhoneInDrawer);
SettingsMenuJsonSwitch(ktg_settings_show_phone_number, show_phone_in_drawer);
const auto chatIdButton = container->add(
object_ptr<Button>(
@ -735,11 +698,12 @@ void SetupKotatoOther(
rktr("ktg_settings_chat_id"),
st::settingsButton));
auto chatIdText = rpl::single(
ChatIdLabel(ShowChatId())
ChatIdLabel(::Kotato::JsonSettings::GetInt("show_chat_id"))
) | rpl::then(
ShowChatIdChanges(
) | rpl::map([] (int chatIdType) {
return ChatIdLabel(chatIdType);
::Kotato::JsonSettings::Events(
"show_chat_id"
) | rpl::map([] {
return ChatIdLabel(::Kotato::JsonSettings::GetInt("show_chat_id"));
})
);
CreateRightLabel(
@ -751,17 +715,17 @@ void SetupKotatoOther(
Ui::show(Box<::Kotato::RadioBox>(
ktr("ktg_settings_chat_id"),
ktr("ktg_settings_chat_id_desc"),
ShowChatId(),
::Kotato::JsonSettings::GetInt("show_chat_id"),
3,
ChatIdLabel,
[=] (int value) {
SetShowChatId(value);
::Kotato::JsonSettings::Set("show_chat_id", value);
::Kotato::JsonSettings::Write();
}));
});
SettingsMenuCSwitch(ktg_settings_call_confirm, ConfirmBeforeCall);
SettingsMenuCSwitch(ktg_settings_remember_compress_images, RememberCompressImages);
SettingsMenuJsonSwitch(ktg_settings_call_confirm, confirm_before_calls);
SettingsMenuJsonSwitch(ktg_settings_remember_compress_images, remember_compress_images);
AddButton(
container,
rktr("ktg_settings_compress_images_default"),
@ -777,7 +741,7 @@ void SetupKotatoOther(
Core::App().settings().setSendFilesWay(way);
Core::App().saveSettingsDelayed();
}, container->lifetime());
SettingsMenuCSwitch(ktg_settings_ffmpeg_multithread, FFmpegMultithread);
SettingsMenuJsonSwitch(ktg_settings_ffmpeg_multithread, ffmpeg_multithread);
AddSkip(container);
AddDividerText(container, rktr("ktg_settings_ffmpeg_multithread_about"));

View file

@ -1,298 +0,0 @@
/*
This file is part of Kotatogram Desktop,
the unofficial app based on Telegram Desktop.
For license and copyright information please follow this link:
https://github.com/kotatogram/kotatogram-desktop/blob/dev/LEGAL
*/
#include "kotato/settings.h"
#include "base/platform/base_platform_info.h"
#include "platform/platform_file_utilities.h"
bool gKotatoFirstRun = true;
QString gMainFont, gSemiboldFont, gMonospaceFont;
int gFontSize = 0;
bool gSemiboldFontIsBold = false;
#ifdef DESKTOP_APP_USE_PACKAGED_FONTS
bool gUseSystemFont = true;
#else
bool gUseSystemFont = Platform::IsLinux();
#endif
bool gUseOriginalMetrics = false;
rpl::variable<int> gStickerHeight = 170;
void SetStickerHeight(int height) {
gStickerHeight = height;
}
int StickerHeight() {
return gStickerHeight.current();
}
rpl::producer<int> StickerHeightChanges() {
return gStickerHeight.changes();
}
rpl::variable<bool> gStickerScaleBoth = true;
void SetStickerScaleBoth(bool scale) {
gStickerScaleBoth = scale;
}
bool StickerScaleBoth() {
return gStickerScaleBoth.current();
}
rpl::producer<bool> StickerScaleBothChanges() {
return gStickerScaleBoth.changes();
}
rpl::variable<bool> gBigEmojiOutline = true;
void SetBigEmojiOutline(bool enabled) {
gBigEmojiOutline = enabled;
}
bool BigEmojiOutline() {
return gBigEmojiOutline.current();
}
rpl::producer<bool> BigEmojiOutlineChanges() {
return gBigEmojiOutline.changes();
}
rpl::variable<bool> gAdaptiveBubbles = false;
void SetAdaptiveBubbles(bool enabled) {
gAdaptiveBubbles = enabled;
}
bool AdaptiveBubbles() {
return gAdaptiveBubbles.current();
}
rpl::producer<bool> AdaptiveBubblesChanges() {
return gAdaptiveBubbles.changes();
}
rpl::variable<bool> gMonospaceLargeBubbles = false;
void SetMonospaceLargeBubbles(bool enabled) {
gMonospaceLargeBubbles = enabled;
}
bool MonospaceLargeBubbles() {
return gMonospaceLargeBubbles.current();
}
rpl::producer<bool> MonospaceLargeBubblesChanges() {
return gMonospaceLargeBubbles.changes();
}
bool gAlwaysShowScheduled = false;
rpl::variable<int> gShowChatId = 2;
void SetShowChatId(int chatIdType) {
if (chatIdType >= 0 && chatIdType <= 2) {
gShowChatId = chatIdType;
}
}
int ShowChatId() {
return gShowChatId.current();
}
rpl::producer<int> ShowChatIdChanges() {
return gShowChatId.changes();
}
int gNetSpeedBoost = 0;
int gNetRequestsCount = 2;
int gNetUploadSessionsCount = 2;
int gNetUploadRequestInterval = 500;
bool gShowPhoneInDrawer = true;
ScaleVector gInterfaceScales;
bool HasCustomScales() {
return (!gInterfaceScales.empty());
}
bool AddCustomScale(int scale) {
if (gInterfaceScales.size() >= 6) {
return false;
}
gInterfaceScales.push_back(style::CheckScale(scale));
return true;
}
void ClearCustomScales() {
gInterfaceScales.clear();
}
rpl::variable<int> gDialogListLines = 2;
void SetDialogListLines(int lines) {
gDialogListLines = lines;
}
int DialogListLines() {
return gDialogListLines.current();
}
rpl::producer<int> DialogListLinesChanges() {
return gDialogListLines.changes();
}
bool gDisableUpEdit = false;
CustomReplacementsMap gCustomReplaces;
bool AddCustomReplace(QString from, QString to) {
gCustomReplaces.insert(from, to);
return true;
}
bool gConfirmBeforeCall = true;
bool gFFmpegMultithread = true;
uint gFFmpegThreadCount = 0;
bool gUseNativeDecorations = false;
bool UseNativeDecorations() {
static const auto NativeDecorations = cUseNativeDecorations();
return NativeDecorations;
}
rpl::variable<int> gRecentStickersLimit = 20;
void SetRecentStickersLimit(int limit) {
if (limit >= 0 && limit <= 200) {
gRecentStickersLimit = limit;
}
}
int RecentStickersLimit() {
return gRecentStickersLimit.current();
}
rpl::producer<int> RecentStickersLimitChanges() {
return gRecentStickersLimit.changes();
}
int gUserpicCornersType = 3;
bool gShowTopBarUserpic = false;
bool gQtScale = false;
rpl::variable<Platform::FileDialog::ImplementationType> gFileDialogType = Platform::FileDialog::ImplementationType::Default;
void SetFileDialogType(Platform::FileDialog::ImplementationType t) {
if (t == Platform::FileDialog::ImplementationType::Count) {
t = Platform::FileDialog::ImplementationType::Default;
}
gFileDialogType = t;
}
Platform::FileDialog::ImplementationType FileDialogType() {
return gFileDialogType.current();
}
rpl::producer<Platform::FileDialog::ImplementationType> FileDialogTypeChanges() {
return gFileDialogType.changes();
}
bool gDisableTrayCounter = Platform::IsLinux();
bool gUseTelegramPanelIcon = false;
int gCustomAppIcon = 0;
DefaultFilterMap gDefaultFilterId;
void SetDefaultFilterId(QString account, int filter) {
if (gDefaultFilterId.contains(account)) {
gDefaultFilterId[account] = filter;
} else {
gDefaultFilterId.insert(account, filter);
}
}
int DefaultFilterId(QString account) {
if (gDefaultFilterId.contains(account)) {
return gDefaultFilterId[account];
}
return 0;
}
bool HasDefaultFilterId(QString account) {
return gDefaultFilterId.contains(account);
}
bool ClearDefaultFilterId(QString account) {
return gDefaultFilterId.remove(account);
}
bool gUnmutedFilterCounterOnly = false;
bool gHideFilterEditButton = false;
bool gHideFilterNames = false;
bool gHideFilterAllChats = false;
bool gProfileTopBarNotifications = false;
rpl::variable<bool> gHoverEmojiPanel = true;
void SetHoverEmojiPanel(bool enabled) {
gHoverEmojiPanel = enabled;
}
bool HoverEmojiPanel() {
return gHoverEmojiPanel.current();
}
rpl::producer<bool> HoverEmojiPanelChanges() {
return gHoverEmojiPanel.changes();
}
bool gForwardRetainSelection = false;
bool gForwardChatOnClick = false;
#if defined TDESKTOP_API_ID && defined TDESKTOP_API_HASH
int gApiId = TDESKTOP_API_ID;
QString gApiHash = QT_STRINGIFY(TDESKTOP_API_HASH);
#else // TDESKTOP_API_ID && TDESKTOP_API_HASH
// To build your version of Telegram Desktop you're required to provide
// your own 'api_id' and 'api_hash' for the Telegram API access.
//
// How to obtain your 'api_id' and 'api_hash' is described here:
// https://core.telegram.org/api/obtaining_api_id
//
// If you're building the application not for deployment,
// but only for test purposes you can comment out the error below.
//
// This will allow you to use TEST ONLY 'api_id' and 'api_hash' which are
// very limited by the Telegram API server.
//
// Your users will start getting internal server errors on login
// if you deploy an app using those 'api_id' and 'api_hash'.
int gApiId = 0;
QString gApiHash;
#endif // TDESKTOP_API_ID && TDESKTOP_API_HASH
bool gUseEnvApi = true;
bool gApiFromStartParams = false;
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();
}
bool gForwardForceOld = false;
bool gDisableChatThemes = false;
bool gRememberCompressImages = true;

View file

@ -1,190 +0,0 @@
/*
This file is part of Kotatogram Desktop,
the unofficial app based on Telegram Desktop.
For license and copyright information please follow this link:
https://github.com/kotatogram/kotatogram-desktop/blob/dev/LEGAL
*/
#pragma once
#include <rpl/producer.h>
namespace Platform {
namespace FileDialog {
enum class ImplementationType;
} // namespace FileDialog
} // namespace Platform
#define DeclareReadSetting(Type, Name) extern Type g##Name; \
inline const Type &c##Name() { \
return g##Name; \
}
#define DeclareSetting(Type, Name) DeclareReadSetting(Type, Name) \
inline void cSet##Name(const Type &Name) { \
g##Name = Name; \
}
#define DeclareRefSetting(Type, Name) DeclareSetting(Type, Name) \
inline Type &cRef##Name() { \
return g##Name; \
}
DeclareSetting(bool, KotatoFirstRun);
DeclareSetting(QString, MainFont);
DeclareSetting(QString, SemiboldFont);
DeclareSetting(bool, SemiboldFontIsBold);
DeclareSetting(QString, MonospaceFont);
DeclareSetting(int, FontSize);
DeclareSetting(bool, UseSystemFont);
DeclareSetting(bool, UseOriginalMetrics);
void SetBigEmojiOutline(bool enabled);
[[nodiscard]] bool BigEmojiOutline();
[[nodiscard]] rpl::producer<bool> BigEmojiOutlineChanges();
void SetStickerHeight(int height);
[[nodiscard]] int StickerHeight();
[[nodiscard]] rpl::producer<int> StickerHeightChanges();
void SetStickerScaleBoth(bool scale);
[[nodiscard]] bool StickerScaleBoth();
[[nodiscard]] rpl::producer<bool> StickerScaleBothChanges();
void SetAdaptiveBubbles(bool enabled);
[[nodiscard]] bool AdaptiveBubbles();
[[nodiscard]] rpl::producer<bool> AdaptiveBubblesChanges();
void SetMonospaceLargeBubbles(bool enabled);
[[nodiscard]] bool MonospaceLargeBubbles();
[[nodiscard]] rpl::producer<bool> MonospaceLargeBubblesChanges();
DeclareSetting(bool, AlwaysShowScheduled);
void SetShowChatId(int chatIdType);
[[nodiscard]] int ShowChatId();
[[nodiscard]] rpl::producer<int> ShowChatIdChanges();
DeclareSetting(int, NetSpeedBoost);
DeclareSetting(int, NetRequestsCount);
DeclareSetting(int, NetUploadSessionsCount);
DeclareSetting(int, NetUploadRequestInterval);
inline void SetNetworkBoost(int boost) {
if (boost < 0) {
cSetNetSpeedBoost(0);
} else if (boost > 3) {
cSetNetSpeedBoost(3);
} else {
cSetNetSpeedBoost(boost);
}
cSetNetRequestsCount(2 + (2 * cNetSpeedBoost()));
cSetNetUploadSessionsCount(2 + (2 * cNetSpeedBoost()));
cSetNetUploadRequestInterval(500 - (100 * cNetSpeedBoost()));
}
DeclareSetting(bool, ShowPhoneInDrawer);
using ScaleVector = std::vector<int>;
DeclareRefSetting(ScaleVector, InterfaceScales);
bool HasCustomScales();
bool AddCustomScale(int scale);
void ClearCustomScales();
void SetDialogListLines(int lines);
[[nodiscard]] int DialogListLines();
[[nodiscard]] rpl::producer<int> DialogListLinesChanges();
DeclareSetting(bool, DisableUpEdit);
using CustomReplacementsMap = QMap<QString, QString>;
DeclareRefSetting(CustomReplacementsMap, CustomReplaces);
bool AddCustomReplace(QString from, QString to);
DeclareSetting(bool, ConfirmBeforeCall);
DeclareSetting(bool, FFmpegMultithread);
DeclareSetting(uint, FFmpegThreadCount);
DeclareSetting(bool, UseNativeDecorations);
[[nodiscard]] bool UseNativeDecorations();
void SetRecentStickersLimit(int limit);
[[nodiscard]] int RecentStickersLimit();
[[nodiscard]] rpl::producer<int> RecentStickersLimitChanges();
DeclareSetting(int, UserpicCornersType);
DeclareSetting(bool, ShowTopBarUserpic);
DeclareSetting(bool, QtScale);
void SetFileDialogType(Platform::FileDialog::ImplementationType t);
[[nodiscard]] Platform::FileDialog::ImplementationType FileDialogType();
[[nodiscard]] rpl::producer<Platform::FileDialog::ImplementationType> FileDialogTypeChanges();
DeclareSetting(bool, DisableTrayCounter);
DeclareSetting(bool, UseTelegramPanelIcon);
DeclareSetting(int, CustomAppIcon);
using DefaultFilterMap = QMap<QString, int>;
DeclareRefSetting(DefaultFilterMap, DefaultFilterId);
void SetDefaultFilterId(QString account, int filter);
int DefaultFilterId(QString account);
bool HasDefaultFilterId(QString account);
bool ClearDefaultFilterId(QString account);
DeclareSetting(bool, UnmutedFilterCounterOnly);
DeclareSetting(bool, HideFilterEditButton);
DeclareSetting(bool, HideFilterNames);
DeclareSetting(bool, HideFilterAllChats);
DeclareSetting(bool, ProfileTopBarNotifications);
void SetHoverEmojiPanel(bool enabled);
[[nodiscard]] bool HoverEmojiPanel();
[[nodiscard]] rpl::producer<bool> HoverEmojiPanelChanges();
DeclareSetting(bool, ForwardRetainSelection);
DeclareSetting(bool, ForwardChatOnClick);
DeclareSetting(int, ApiId);
DeclareSetting(QString, ApiHash);
DeclareSetting(bool, UseEnvApi);
DeclareSetting(bool, ApiFromStartParams);
DeclareSetting(bool, AutoScrollUnfocused);
struct LocalFolder {
int id = 0;
uint64 ownerId = 0;
bool isTest = false;
int cloudOrder = 0;
QString name;
QString emoticon;
std::vector<uint64> always;
std::vector<uint64> never;
std::vector<uint64> pinned;
ushort flags = 0;
};
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();
DeclareSetting(bool, ForwardForceOld);
DeclareSetting(bool, DisableChatThemes);
DeclareSetting(bool, RememberCompressImages);

View file

@ -7,6 +7,7 @@ https://github.com/telegramdesktop/tdesktop/blob/master/LEGAL
*/
#include "main/main_account.h"
#include "kotato/kotato_settings.h"
#include "base/platform/base_platform_info.h"
#include "core/application.h"
#include "core/shortcuts.h"
@ -30,7 +31,6 @@ https://github.com/telegramdesktop/tdesktop/blob/master/LEGAL
#include "main/main_session.h"
#include "main/main_domain.h"
#include "main/main_session_settings.h"
#include "kotato/json_settings.h"
namespace Main {
namespace {
@ -192,20 +192,10 @@ void Account::createSession(
Ensures(_session != nullptr);
auto defaultFilterUserId = QString::number(session().userId().bare);
if (_mtp->isTestMode()) {
defaultFilterUserId.prepend("test_");
}
if (HasDefaultFilterId("0")) {
const auto newDefaultFilterId = DefaultFilterId("0");
ClearDefaultFilterId("0");
setDefaultFilterId(newDefaultFilterId);
Kotato::JsonSettings::Write();
} else {
_defaultFilterId = DefaultFilterId(defaultFilterUserId);
}
_defaultFilterId = ::Kotato::JsonSettings::GetInt(
"folders/default",
session().userId().bare,
_mtp->isTestMode());
}
void Account::destroySession(DestroyReason reason) {
@ -620,17 +610,12 @@ void Account::setDefaultFilterId(uint64 id) {
Expects(_session != nullptr);
_defaultFilterId = id;
auto defaultFilterUserId = QString::number(session().userId().bare);
if (_mtp->isTestMode()) {
defaultFilterUserId.prepend("test_");
}
if (id == 0) {
ClearDefaultFilterId(defaultFilterUserId);
} else {
SetDefaultFilterId(defaultFilterUserId, id);
}
::Kotato::JsonSettings::Set(
"folders/default",
_defaultFilterId,
session().userId().bare,
_mtp->isTestMode());
}
bool Account::isCurrent(uint64 id, bool testMode) {

View file

@ -8,6 +8,7 @@ https://github.com/telegramdesktop/tdesktop/blob/master/LEGAL
#include "mainwindow.h"
#include "kotato/kotato_lang.h"
#include "kotato/kotato_settings.h"
#include "data/data_document.h"
#include "data/data_session.h"
#include "data/data_document_media.h"
@ -599,7 +600,7 @@ bool MainWindow::doWeMarkAsRead() {
if (!_main || Ui::isLayerShown()) {
return false;
}
if (cAutoScrollUnfocused()) {
if (::Kotato::JsonSettings::GetBool("auto_scroll_unfocused")) {
// for tile grid in case other windows have shadows
// i've seen some windows with >70px shadow margins
const auto margin = style::ConvertScale(100);

View file

@ -7,6 +7,7 @@ https://github.com/telegramdesktop/tdesktop/blob/master/LEGAL
*/
#include "mtproto/dedicated_file_loader.h"
#include "kotato/kotato_settings.h"
#include "mtproto/facade.h"
#include "main/main_account.h" // Account::sessionChanges.
#include "main/main_session.h" // Session::account.
@ -80,6 +81,11 @@ std::optional<DedicatedLoader::File> ParseFile(
return DedicatedLoader::File{ name, size, fields.vdc_id().v, location };
}
int RequestCount() {
static const auto count = 2 + (2 * ::Kotato::JsonSettings::GetInt("net_speed_boost"));
return count;
}
} // namespace
WeakInstance::WeakInstance(base::weak_ptr<Main::Session> session)
@ -310,7 +316,7 @@ void DedicatedLoader::startLoading() {
}
void DedicatedLoader::sendRequest() {
if (_requests.size() >= cNetRequestsCount() || _offset >= _size) {
if (_requests.size() >= RequestCount() || _offset >= _size) {
return;
}
const auto offset = _offset;
@ -326,7 +332,7 @@ void DedicatedLoader::sendRequest() {
MTP::updaterDcId(_dcId));
_offset += kChunkSize;
if (_requests.size() < cNetRequestsCount()) {
if (_requests.size() < RequestCount()) {
base::call_delayed(kNextRequestDelay, this, [=] { sendRequest(); });
}
}

View file

@ -7,6 +7,7 @@ https://github.com/telegramdesktop/tdesktop/blob/master/LEGAL
*/
#include "mtproto/session_private.h"
#include "kotato/kotato_settings.h"
#include "kotato/kotato_version.h"
#include "mtproto/details/mtproto_bound_key_creator.h"
#include "mtproto/details/mtproto_dcenter.h"
@ -687,7 +688,7 @@ void SessionPrivate::tryToSend() {
initWrapper = MTPInitConnection<SerializedRequest>(
MTP_flags(Flag::f_params
| (mtprotoProxy ? Flag::f_proxy : Flag(0))),
MTP_int(cApiId()),
MTP_int(::Kotato::JsonSettings::GetInt("api_id")),
MTP_string(deviceModel),
MTP_string(systemVersion),
MTP_string(appVersion),

View file

@ -7,6 +7,7 @@ https://github.com/telegramdesktop/tdesktop/blob/master/LEGAL
*/
#include "platform/linux/launcher_linux.h"
#include "kotato/kotato_settings.h"
#include "core/crash_reports.h"
#include "core/update_checker.h"
#include "webview/platform/linux/webview_linux_webkit2gtk.h"
@ -137,15 +138,15 @@ bool Launcher::launchUpdater(UpdaterLaunch action) {
}
}
if (!cUseEnvApi()) {
if (!::Kotato::JsonSettings::GetBool("api_use_env")) {
argumentsList.push("-no-env-api");
}
if (cApiFromStartParams()) {
if (::Kotato::JsonSettings::GetBool("api_start_params")) {
argumentsList.push("-api-id");
argumentsList.push(QFile::encodeName(QString::number(cApiId())));
argumentsList.push(QFile::encodeName(QString::number(::Kotato::JsonSettings::GetInt("api_id"))));
argumentsList.push("-api-hash");
argumentsList.push(QFile::encodeName(cApiHash()));
argumentsList.push(QFile::encodeName(::Kotato::JsonSettings::GetString("api_hash")));
}
Logs::closeMain();

View file

@ -7,6 +7,7 @@ https://github.com/telegramdesktop/tdesktop/blob/master/LEGAL
*/
#include "platform/linux/linux_xdp_file_dialog.h"
#include "kotato/kotato_settings.h"
#include "platform/platform_file_utilities.h"
#include "base/platform/base_platform_info.h"
#include "base/platform/linux/base_linux_glibmm_helper.h"
@ -684,7 +685,8 @@ std::optional<bool> Get(
const QString &filter,
Type type,
QString startFile) {
if (FileDialogType() > ImplementationType::XDP
const auto fileDialogType = ImplementationType(::Kotato::JsonSettings::GetInt("file_dialog_type"));
if (fileDialogType > ImplementationType::XDP
|| !FileChooserPortalVersion.has_value()
|| (type == Type::ReadFolder && *FileChooserPortalVersion < 3)) {
return std::nullopt;

View file

@ -7,6 +7,7 @@ https://github.com/telegramdesktop/tdesktop/blob/master/LEGAL
*/
#include "platform/linux/main_window_linux.h"
#include "kotato/kotato_settings.h"
#include "styles/style_window.h"
#include "platform/linux/specific_linux.h"
#include "platform/linux/linux_wayland_integration.h"
@ -190,15 +191,16 @@ void SkipTaskbar(QWindow *window, bool skip) {
}
QString GetPanelIconName(int counter, bool muted) {
const auto iconName = cUseTelegramPanelIcon()
const auto useTelegramPanelIcon = ::Kotato::JsonSettings::GetBool("use_telegram_panel_icon");
const auto iconName = useTelegramPanelIcon
? kTelegramPanelTrayIconName.utf16()
: kPanelTrayIconName.utf16();
const auto muteIconName = cUseTelegramPanelIcon()
const auto muteIconName = useTelegramPanelIcon
? kTelegramMutePanelTrayIconName.utf16()
: kMutePanelTrayIconName.utf16();
const auto attentionIconName = cUseTelegramPanelIcon()
const auto attentionIconName = useTelegramPanelIcon
? kTelegramAttentionPanelTrayIconName.utf16()
: kAttentionPanelTrayIconName.utf16();
@ -229,9 +231,9 @@ int GetCounterSlice(int counter) {
}
bool UseIconFromTheme(const QString &iconName) {
return cDisableTrayCounter()
return ::Kotato::JsonSettings::GetBool("disable_tray_counter")
&& !QFileInfo::exists(cWorkingDir() + "tdata/icon.png")
&& cCustomAppIcon() == 0
&& ::Kotato::JsonSettings::GetInt("custom_app_icon") == 0
&& !iconName.isEmpty();
}
@ -247,8 +249,8 @@ bool IsIconRegenerationNeeded(
|| iconName != TrayIconName
|| muted != TrayIconMuted
|| counterSlice != TrayIconCount
|| cCustomAppIcon() != TrayIconCustomId
|| cDisableTrayCounter() != TrayIconCounterDisabled;
|| ::Kotato::JsonSettings::GetInt("custom_app_icon") != TrayIconCustomId
|| ::Kotato::JsonSettings::GetBool("disable_tray_counter") != TrayIconCounterDisabled;
}
void UpdateIconRegenerationNeeded(
@ -264,8 +266,8 @@ void UpdateIconRegenerationNeeded(
TrayIconCount = counterSlice;
TrayIconThemeName = iconThemeName;
TrayIconName = iconName;
TrayIconCustomId = cCustomAppIcon();
TrayIconCounterDisabled = cDisableTrayCounter();
TrayIconCustomId = ::Kotato::JsonSettings::GetInt("custom_app_icon");
TrayIconCounterDisabled = ::Kotato::JsonSettings::GetBool("disable_tray_counter");
}
QIcon TrayIconGen(int counter, bool muted) {
@ -298,6 +300,9 @@ QIcon TrayIconGen(int counter, bool muted) {
return image.size() / image.devicePixelRatio();
};
const auto customAppIcon = ::Kotato::JsonSettings::GetInt("custom_app_icon");
const auto disableTrayCounter = ::Kotato::JsonSettings::GetInt("disable_tray_counter");
for (const auto iconSize : iconSizes) {
auto &currentImageBack = TrayIconImageBack[iconSize];
const auto desiredSize = QSize(iconSize, iconSize);
@ -305,12 +310,12 @@ QIcon TrayIconGen(int counter, bool muted) {
if (currentImageBack.isNull()
|| iconThemeName != TrayIconThemeName
|| iconName != TrayIconName
|| cCustomAppIcon() != TrayIconCustomId
|| cDisableTrayCounter() != TrayIconCounterDisabled) {
|| customAppIcon != TrayIconCustomId
|| disableTrayCounter != TrayIconCounterDisabled) {
if (QFileInfo::exists(cWorkingDir() + "tdata/icon.png")) {
currentImageBack = QImage(cWorkingDir() + "tdata/icon.png");
} else if (cCustomAppIcon() != 0) {
currentImageBack = Window::Logo(cCustomAppIcon());
} else if (customAppIcon != 0) {
currentImageBack = Window::Logo(customAppIcon);
} else if (!iconName.isEmpty()) {
if (systemIcon.isNull()) {
systemIcon = QIcon::fromTheme(iconName);
@ -354,7 +359,7 @@ QIcon TrayIconGen(int counter, bool muted) {
auto iconImage = currentImageBack;
if (!cDisableTrayCounter()
if (!disableTrayCounter
&& counter > 0) {
const auto &bg = muted
? st::trayCounterBgMute

View file

@ -7,6 +7,7 @@ https://github.com/telegramdesktop/tdesktop/blob/master/LEGAL
*/
#include "platform/mac/launcher_mac.h"
#include "kotato/kotato_settings.h"
#include "core/crash_reports.h"
#include "core/update_checker.h"
#include "base/base_file_utilities.h"
@ -71,12 +72,12 @@ bool Launcher::launchUpdater(UpdaterLaunch action) {
if (customWorkingDir()) {
[args addObject:@"-workdir_custom"];
}
if (!cUseEnvApi()) [args addObject:@"-no-env-api"];
if (cApiFromStartParams()) {
if (!::Kotato::JsonSettings::GetBool("api_use_env")) [args addObject:@"-no-env-api"];
if (::Kotato::JsonSettings::GetBool("api_start_params")) {
[args addObject:@"-api-id"];
[args addObject:Q2NSString(QString::number(cApiId()))];
[args addObject:Q2NSString(QString::number(::Kotato::JsonSettings::GetInt("api_id")))];
[args addObject:@"-api-hash"];
[args addObject:Q2NSString(cApiHash())];
[args addObject:Q2NSString(::Kotato::JsonSettings::GetString("api_hash"))];
}
DEBUG_LOG(("Application Info: executing %1 %2").arg(NS2QString(path)).arg(NS2QString([args componentsJoinedByString:@" "])));

View file

@ -8,6 +8,7 @@ https://github.com/telegramdesktop/tdesktop/blob/master/LEGAL
#include "platform/mac/main_window_mac.h"
#include "kotato/kotato_lang.h"
#include "kotato/kotato_settings.h"
#include "data/data_session.h"
#include "styles/style_window.h"
#include "mainwindow.h"
@ -411,7 +412,7 @@ QIcon MainWindow::generateIconForTray(int counter, bool muted) const {
imgsel.detach();
const auto size = 22 * cIntRetinaFactor();
const auto &bg = (muted ? st::trayCounterBgMute : st::trayCounterBg);
if (!cDisableTrayCounter()) {
if (!::Kotato::JsonSettings::GetBool("disable_tray_counter")) {
_placeCounter(img, size, counter, bg, (dm && muted) ? st::trayCounterFgMacInvert : st::trayCounterFg);
_placeCounter(imgsel, size, counter, st::trayCounterBgMacInvert, st::trayCounterFgMacInvert);
}

View file

@ -7,6 +7,7 @@ https://github.com/telegramdesktop/tdesktop/blob/master/LEGAL
*/
#include "platform/win/launcher_win.h"
#include "kotato/kotato_settings.h"
#include "core/crash_reports.h"
#include "core/update_checker.h"
#include "base/platform/win/base_windows_h.h"
@ -94,14 +95,14 @@ bool Launcher::launchUpdater(UpdaterLaunch action) {
}
}
if (!cUseEnvApi()) {
if (!::Kotato::JsonSettings::GetBool("api_use_env")) {
pushArgument(qsl("-no-env-api"));
}
if (cApiFromStartParams()) {
if (::Kotato::JsonSettings::GetBool("api_start_params")) {
pushArgument(qsl("-api-id"));
pushArgument('"' + QString::number(cApiId()) + '"');
pushArgument('"' + QString::number(::Kotato::JsonSettings::GetInt("api_id")) + '"');
pushArgument(qsl("-api-hash"));
pushArgument('"' + cApiHash() + '"');
pushArgument('"' + ::Kotato::JsonSettings::GetString("api_hash") + '"');
}
return launch(operation, binaryPath, argumentsList);
}

View file

@ -8,6 +8,7 @@ https://github.com/telegramdesktop/tdesktop/blob/master/LEGAL
#include "platform/win/main_window_win.h"
#include "kotato/kotato_lang.h"
#include "kotato/kotato_settings.h"
#include "styles/style_window.h"
#include "platform/platform_specific.h"
#include "platform/platform_notifications_manager.h"
@ -109,15 +110,17 @@ using namespace Microsoft::WRL;
auto &scaled = smallIcon ? ScaledLogoNoMargin : ScaledLogo;
auto result = [&] {
const auto idx = CustomIcon.isNull() ? cCustomAppIcon() : kLogoCount - 1;
const auto idx = CustomIcon.isNull()
? ::Kotato::JsonSettings::GetInt("custom_app_icon")
: kLogoCount - 1;
auto &image = scaled[idx * kCount + d.index];
if (image.isNull()) {
image = !CustomIcon.isNull()
? CustomIcon.scaledToWidth(d.size, Qt::SmoothTransformation)
: (smallIcon
? Window::LogoNoMargin(cCustomAppIcon())
: Window::Logo(cCustomAppIcon())).scaledToWidth(
? Window::LogoNoMargin(::Kotato::JsonSettings::GetInt("custom_app_icon"))
: Window::Logo(::Kotato::JsonSettings::GetInt("custom_app_icon"))).scaledToWidth(
d.size,
Qt::SmoothTransformation);
}
@ -243,7 +246,7 @@ void MainWindow::psSetupTrayIcon() {
auto icon = QIcon(cWorkingDir() + "tdata/icon.png");
if (icon.isNull()) {
icon = QIcon(Ui::PixmapFromImage(
QImage(Window::LogoNoMargin(cCustomAppIcon()))));
QImage(Window::LogoNoMargin(::Kotato::JsonSettings::GetInt("custom_app_icon")))));
}
trayIcon->setIcon(icon);
@ -407,10 +410,11 @@ void MainWindow::updateIconCounters() {
if (trayIcon) {
// Force Qt to use right icon size, not the larger one.
QIcon forTrayIcon;
auto forTrayIcon16 = cDisableTrayCounter()
const auto disableTrayCounter = ::Kotato::JsonSettings::GetBool("disable_tray_counter");
auto forTrayIcon16 = disableTrayCounter
? iconWithCounter(16, 0, true)
: iconSmallPixmap16;
auto forTrayIcon32 = cDisableTrayCounter()
auto forTrayIcon32 = disableTrayCounter
? iconWithCounter(32, 0, true)
: iconSmallPixmap32;
forTrayIcon.addPixmap(iconSizeSmall.width() >= 20

View file

@ -56,7 +56,7 @@ namespace {
[[nodiscard]] std::wstring NotificationTemplate(
QString id,
Window::Notifications::Manager::DisplayOptions options) {
const auto crop = (cUserpicCornersType() == 3) ? L"circle" : L"none";
const auto crop = (KotatoImageRoundRadius() == ImageRoundRadius::Ellipse) ? L"circle" : L"none";
const auto wid = id.replace('&', "&amp;").toStdWString();
const auto fastReply = LR"(
<input id="fastReply" type="text" placeHolderContent=""/>

View file

@ -16,7 +16,7 @@ https://github.com/telegramdesktop/tdesktop/blob/master/LEGAL
#include "settings/settings_privacy_security.h"
#include "settings/settings_folders.h"
#include "settings/settings_calls.h"
#include "kotato/settings_menu.h"
#include "kotato/kotato_settings_menu.h"
#include "core/application.h"
#include "ui/wrap/padding_wrap.h"
#include "ui/wrap/vertical_layout.h"

View file

@ -8,6 +8,7 @@ https://github.com/telegramdesktop/tdesktop/blob/master/LEGAL
#include "settings/settings_folders.h"
#include "kotato/kotato_lang.h"
#include "kotato/kotato_settings.h"
#include "boxes/filters/edit_filter_box.h"
#include "data/data_session.h"
#include "data/data_folder.h"
@ -27,7 +28,6 @@ https://github.com/telegramdesktop/tdesktop/blob/master/LEGAL
#include "ui/wrap/slide_wrap.h"
#include "ui/painter.h"
#include "ui/filter_icons.h"
#include "kotato/json_settings.h"
#include "settings/settings_common.h"
#include "lang/lang_keys.h"
#include "apiwrap.h"
@ -609,10 +609,9 @@ void FilterRowButton::paintEvent(QPaintEvent *e) {
auto addRequests = Requests(), removeRequests = Requests();
auto &realFilters = session->data().chatsFilters();
const auto &list = realFilters.list();
auto &localFolders = cRefLocalFolders();
auto order = std::vector<FilterId>();
order.reserve(rows->size());
auto localFoldersAdded = false;
auto localFoldersChanged = false;
for (const auto &row : *rows) {
const auto id = row.filter.id();
const auto removed = row.removed;
@ -624,35 +623,14 @@ void FilterRowButton::paintEvent(QPaintEvent *e) {
continue;
}
if (row.filter.isLocal()) {
const auto j = ranges::find_if(localFolders, [id, account](LocalFolder localFolder) {
return (id == localFolder.id
&& account->isCurrent(localFolder.ownerId, localFolder.isTest));
});
if (j == end(localFolders)) {
if (removed) {
continue;
} else {
localFolders.push_back(row.filter.toLocal(kFiltersLimit));
realFilters.set(row.filter);
order.push_back(id);
needSave = true;
localFoldersAdded = true;
}
if (removed) {
realFilters.remove(id);
} else {
if (removed) {
localFolders.erase(j);
realFilters.remove(id);
needSave = true;
} else {
const auto cloudOrder = (*j).cloudOrder;
*j = row.filter.toLocal(cloudOrder);
realFilters.set(row.filter);
order.push_back(id);
needSave = true;
localFoldersAdded = true;
}
realFilters.set(row.filter);
order.push_back(id);
}
localFoldersChanged = true;
needSave = true;
} else {
const auto newId = ids.take(row.button).value_or(id);
const auto tl = removed
@ -685,13 +663,16 @@ void FilterRowButton::paintEvent(QPaintEvent *e) {
std::move(request)
).afterRequest(previousId).send();
}
if (!order.empty() && (!addRequests.empty() || localFoldersAdded)) {
if (!order.empty() && (!addRequests.empty() || localFoldersChanged)) {
realFilters.saveOrder(order, previousId);
}
if (currentDefaultRemoved) {
account->setDefaultFilterId(0);
controller->setActiveChatsFilter(0);
}
if (localFoldersChanged) {
realFilters.saveLocal();
}
if (currentDefaultId != account->defaultFilterId()) {
needSave = true;
}

View file

@ -8,6 +8,7 @@ https://github.com/telegramdesktop/tdesktop/blob/master/LEGAL
#include "settings/settings_main.h"
#include "kotato/kotato_lang.h"
#include "kotato/kotato_settings.h"
#include "settings/settings_common.h"
#include "settings/settings_codes.h"
#include "settings/settings_chat.h"
@ -44,6 +45,8 @@ https://github.com/telegramdesktop/tdesktop/blob/master/LEGAL
#include "styles/style_settings.h"
#include "base/platform/base_platform_info.h"
#include <QtCore/QJsonArray>
namespace Settings {
void SetupLanguageButton(
@ -167,7 +170,7 @@ void SetupSections(
addSection(
rktr("ktg_settings_kotato"),
Type::Kotato,
(cCustomAppIcon() == 5
(::Kotato::JsonSettings::GetInt("custom_app_icon") == 5
? &st::settingsIconKotatoOld
: &st::settingsIconKotato));
@ -177,7 +180,11 @@ void SetupSections(
}
bool HasInterfaceScale() {
return !cQtScale();
#if QT_VERSION < QT_VERSION_CHECK(6, 0, 0)
return !::Kotato::JsonSettings::GetBool("qt_scale");
#else
return true;
#endif
}
void SetupInterfaceScale(
@ -203,9 +210,21 @@ void SetupInterfaceScale(
object_ptr<Ui::SettingsSlider>(container, st::settingsSlider),
icon ? st::settingsScalePadding : st::settingsBigScalePadding);
static const auto customScales = [&] {
const auto scalesJson = ::Kotato::JsonSettings::Get("scales").toJsonArray();
auto result = std::vector<int>();
result.reserve(scalesJson.size());
for (auto i = scalesJson.begin(); i != scalesJson.end(); ++i) {
if ((*i).type() != QJsonValue::Undefined) {
result.push_back(int((*i).toDouble()));
}
}
return result;
}();
static const auto ScaleValues = [&] {
auto values = HasCustomScales()
? cInterfaceScales()
auto values = (customScales.size() > 1)
? customScales
: (cIntRetinaFactor() > 1)
? std::vector<int>{ 100, 110, 120, 130, 140, 150 }
: std::vector<int>{ 100, 125, 150, 200, 250, 300 };

View file

@ -7,6 +7,7 @@ https://github.com/telegramdesktop/tdesktop/blob/master/LEGAL
*/
#include "settings/settings_notifications.h"
#include "kotato/kotato_settings.h"
#include "settings/settings_common.h"
#include "ui/effects/animations.h"
#include "ui/wrap/vertical_layout.h"
@ -259,7 +260,7 @@ void NotificationsCount::prepareNotificationSampleSmall() {
void NotificationsCount::prepareNotificationSampleUserpic() {
if (_notificationSampleUserpic.isNull()) {
_notificationSampleUserpic = Ui::PixmapFromImage(
Window::LogoNoMargin(cCustomAppIcon()).scaled(
Window::LogoNoMargin(::Kotato::JsonSettings::GetInt("custom_app_icon")).scaled(
st::notifyPhotoSize * cIntRetinaFactor(),
st::notifyPhotoSize * cIntRetinaFactor(),
Qt::IgnoreAspectRatio,

View file

@ -7,6 +7,7 @@ https://github.com/telegramdesktop/tdesktop/blob/master/LEGAL
*/
#include "storage/file_upload.h"
#include "kotato/kotato_settings.h"
#include "api/api_editing.h"
#include "api/api_send_progress.h"
#include "storage/localimageloader.h"
@ -56,6 +57,16 @@ constexpr auto kKillSessionTimeout = 15 * crl::time(000);
return Core::IsMimeSticker(mime) ? "WEBP" : "JPG";
}
int UploadSessionsCount() {
static const auto count = 2 + (2 * ::Kotato::JsonSettings::GetInt("net_speed_boost"));
return count;
}
int UploadSessionsInterval() {
static const auto interval = 500 - (100 * ::Kotato::JsonSettings::GetInt("net_speed_boost"));
return interval;
}
} // namespace
struct Uploader::File {
@ -381,7 +392,7 @@ void Uploader::currentFailed() {
dcMap.clear();
uploadingId = FullMsgId();
sentSize = 0;
for (int i = 0; i < cNetUploadSessionsCount(); ++i) {
for (int i = 0; i < UploadSessionsCount(); ++i) {
sentSizes[i] = 0;
}
@ -389,13 +400,13 @@ void Uploader::currentFailed() {
}
void Uploader::stopSessions() {
for (int i = 0; i < cNetUploadSessionsCount(); ++i) {
for (int i = 0; i < UploadSessionsCount(); ++i) {
_api->instance().stopSession(MTP::uploadDcId(i));
}
}
void Uploader::sendNext() {
if (sentSize >= (cNetUploadSessionsCount() * 512 * 1024) || _pausedId.msg) {
if (sentSize >= (UploadSessionsCount() * 512 * 1024) || _pausedId.msg) {
return;
}
@ -420,7 +431,7 @@ void Uploader::sendNext() {
auto &uploadingData = i->second;
auto todc = 0;
for (auto dc = 1; dc != cNetUploadSessionsCount(); ++dc) {
for (auto dc = 1; dc != UploadSessionsCount(); ++dc) {
if (sentSizes[dc] < sentSizes[todc]) {
todc = dc;
}
@ -613,7 +624,7 @@ void Uploader::sendNext() {
parts.erase(part);
}
_nextTimer.callOnce(crl::time(cNetUploadRequestInterval()));
_nextTimer.callOnce(crl::time(UploadSessionsInterval()));
}
void Uploader::cancel(const FullMsgId &msgId) {
@ -650,7 +661,7 @@ void Uploader::clear() {
docRequestsSent.clear();
dcMap.clear();
sentSize = 0;
for (int i = 0; i < cNetUploadSessionsCount(); ++i) {
for (int i = 0; i < UploadSessionsCount(); ++i) {
_api->instance().stopSession(MTP::uploadDcId(i));
sentSizes[i] = 0;
}

View file

@ -7,6 +7,7 @@ https://github.com/telegramdesktop/tdesktop/blob/master/LEGAL
*/
#include "ui/effects/round_checkbox.h"
#include "ui/image/image.h"
#include "ui/rp_widget.h"
#include "ui/ui_utility.h"
@ -390,22 +391,19 @@ void RoundImageCheckbox::paint(Painter &p, int x, int y, int outerWidth) {
auto pen = _st.selectFg->p;
pen.setWidth(_st.selectWidth);
p.setPen(pen);
switch (cUserpicCornersType()) {
case 0:
p.drawRoundedRect(
style::rtlrect(x, y, _st.imageRadius * 2, _st.imageRadius * 2, outerWidth),
switch (KotatoImageRoundRadius()) {
case ImageRoundRadius::None:
p.drawRoundedRect(style::rtlrect(x, y, _st.imageRadius * 2, _st.imageRadius * 2, outerWidth),
0, 0);
break;
case 1:
p.drawRoundedRect(
style::rtlrect(x, y, _st.imageRadius * 2, _st.imageRadius * 2, outerWidth),
case ImageRoundRadius::Small:
p.drawRoundedRect(style::rtlrect(x, y, _st.imageRadius * 2, _st.imageRadius * 2, outerWidth),
st::buttonRadius, st::buttonRadius);
break;
case 2:
p.drawRoundedRect(
style::rtlrect(x, y, _st.imageRadius * 2, _st.imageRadius * 2, outerWidth),
case ImageRoundRadius::Large:
p.drawRoundedRect(style::rtlrect(x, y, _st.imageRadius * 2, _st.imageRadius * 2, outerWidth),
st::dateRadius, st::dateRadius);
break;

View file

@ -222,16 +222,16 @@ void EmptyUserpic::paint(
int y,
int outerWidth,
int size) const {
switch (cUserpicCornersType()) {
case 0:
switch (KotatoImageRoundRadius()) {
case ImageRoundRadius::None:
paintSquare(p, x, y, outerWidth, size);
break;
case 1:
case ImageRoundRadius::Small:
paintRounded(p, x, y, outerWidth, size);
break;
case 2:
case ImageRoundRadius::Large:
paintRoundedLarge(p, x, y, outerWidth, size);
break;
@ -266,16 +266,16 @@ void EmptyUserpic::PaintSavedMessages(
int y,
int outerWidth,
int size) {
switch (cUserpicCornersType()) {
case 0:
switch (KotatoImageRoundRadius()) {
case ImageRoundRadius::None:
PaintSavedMessagesSquared(p, x, y, outerWidth, size);
break;
case 1:
case ImageRoundRadius::Small:
PaintSavedMessagesRounded(p, x, y, outerWidth, size);
break;
case 2:
case ImageRoundRadius::Large:
PaintSavedMessagesRoundedLarge(p, x, y, outerWidth, size);
break;
@ -327,16 +327,16 @@ void EmptyUserpic::PaintSavedMessages(
int size,
const style::color &bg,
const style::color &fg) {
switch (cUserpicCornersType()) {
case 0:
switch (KotatoImageRoundRadius()) {
case ImageRoundRadius::None:
PaintSavedMessagesSquared(p, x, y, outerWidth, size, bg, fg);
break;
case 1:
case ImageRoundRadius::Small:
PaintSavedMessagesRounded(p, x, y, outerWidth, size, bg, fg);
break;
case 2:
case ImageRoundRadius::Large:
PaintSavedMessagesRoundedLarge(p, x, y, outerWidth, size, bg, fg);
break;
@ -424,16 +424,16 @@ void EmptyUserpic::PaintRepliesMessages(
int y,
int outerWidth,
int size) {
switch (cUserpicCornersType()) {
case 0:
switch (KotatoImageRoundRadius()) {
case ImageRoundRadius::None:
PaintRepliesMessagesSquared(p, x, y, outerWidth, size);
break;
case 1:
case ImageRoundRadius::Small:
PaintRepliesMessagesRounded(p, x, y, outerWidth, size);
break;
case 2:
case ImageRoundRadius::Large:
PaintRepliesMessagesRoundedLarge(p, x, y, outerWidth, size);
break;

View file

@ -7,11 +7,21 @@ https://github.com/telegramdesktop/tdesktop/blob/master/LEGAL
*/
#include "ui/image/image.h"
#include "kotato/kotato_settings.h"
#include "storage/cache/storage_cache_database.h"
#include "data/data_session.h"
#include "main/main_session.h"
#include "ui/ui_utility.h"
ImageRoundRadius KotatoImageRoundRadius() {
switch (::Kotato::JsonSettings::GetInt("userpic_corner_type")) {
case 0: return ImageRoundRadius::None;
case 1: return ImageRoundRadius::Small;
case 2: return ImageRoundRadius::Large;
default: return ImageRoundRadius::Ellipse;
}
}
using namespace Images;
namespace Images {

View file

@ -9,6 +9,8 @@ https://github.com/telegramdesktop/tdesktop/blob/master/LEGAL
#include "ui/image/image_prepare.h"
ImageRoundRadius KotatoImageRoundRadius();
class QPainterPath;
namespace Images {

View file

@ -317,31 +317,23 @@ void UserpicButton::paintEvent(QPaintEvent *e) {
p.setBrush(_userpicHasImage
? st::msgDateImgBg
: _st.changeButton.textBgOver);
switch (cUserpicCornersType()) {
case 0:
p.drawRoundedRect(
QRect{ photoLeft, photoTop, _st.photoSize, _st.photoSize },
0, 0);
switch (KotatoImageRoundRadius()) {
case ImageRoundRadius::None:
p.drawRoundedRect(QRect{ photoLeft, photoTop, _st.photoSize, _st.photoSize }, 0, 0);
break;
case 1:
p.drawRoundedRect(
QRect{ photoLeft, photoTop, _st.photoSize, _st.photoSize },
case ImageRoundRadius::Small:
p.drawRoundedRect(QRect{ photoLeft, photoTop, _st.photoSize, _st.photoSize },
st::buttonRadius, st::buttonRadius);
break;
case 2:
p.drawRoundedRect(
QRect{ photoLeft, photoTop, _st.photoSize, _st.photoSize },
case ImageRoundRadius::Large:
p.drawRoundedRect(QRect{ photoLeft, photoTop, _st.photoSize, _st.photoSize },
st::dateRadius, st::dateRadius);
break;
default:
p.drawEllipse(
photoLeft,
photoTop,
_st.photoSize,
_st.photoSize);
p.drawEllipse(photoLeft, photoTop, _st.photoSize, _st.photoSize);
}
}
paintRipple(
@ -384,31 +376,23 @@ void UserpicButton::paintEvent(QPaintEvent *e) {
PainterHighQualityEnabler hq(p);
p.setPen(Qt::NoPen);
p.setBrush(_st.uploadBg);
switch (cUserpicCornersType()) {
case 0:
p.drawRoundedRect(
QRect{ photoLeft, photoTop, _st.photoSize, _st.photoSize },
0, 0);
switch (KotatoImageRoundRadius()) {
case ImageRoundRadius::None:
p.drawRoundedRect(QRect{ photoLeft, photoTop, _st.photoSize, _st.photoSize }, 0, 0);
break;
case 1:
p.drawRoundedRect(
QRect{ photoLeft, photoTop, _st.photoSize, _st.photoSize },
case ImageRoundRadius::Small:
p.drawRoundedRect(QRect{ photoLeft, photoTop, _st.photoSize, _st.photoSize },
st::buttonRadius, st::buttonRadius);
break;
case 2:
p.drawRoundedRect(
QRect{ photoLeft, photoTop, _st.photoSize, _st.photoSize },
case ImageRoundRadius::Large:
p.drawRoundedRect(QRect{ photoLeft, photoTop, _st.photoSize, _st.photoSize },
st::dateRadius, st::dateRadius);
break;
default:
p.drawEllipse(
photoLeft,
photoTop,
_st.photoSize,
_st.photoSize);
p.drawEllipse(photoLeft, photoTop, _st.photoSize, _st.photoSize);
}
}
auto iconLeft = (_st.uploadIconPosition.x() < 0)
@ -441,13 +425,7 @@ void UserpicButton::paintUserpicFrame(Painter &p, QPoint photoPosition) {
auto size = QSize{ _st.photoSize, _st.photoSize };
request.outer = size * cIntRetinaFactor();
request.resize = size * cIntRetinaFactor();
request.radius = (cUserpicCornersType() == 3)
? ImageRoundRadius::Ellipse
: (cUserpicCornersType() == 2)
? ImageRoundRadius::Large
: (cUserpicCornersType() == 1)
? ImageRoundRadius::Small
: ImageRoundRadius::None;
request.radius = KotatoImageRoundRadius();
p.drawImage(QRect(photoPosition, size), _streamed->frame(request));
if (!paused) {
_streamed->markFrameShown();
@ -470,14 +448,14 @@ QPoint UserpicButton::countPhotoPosition() const {
QImage UserpicButton::prepareRippleMask() const {
const auto size = QSize(_st.photoSize, _st.photoSize);
switch (cUserpicCornersType()) {
case 0:
switch (KotatoImageRoundRadius()) {
case ImageRoundRadius::None:
return Ui::RippleAnimation::rectMask(size);
case 1:
case ImageRoundRadius::Small:
return Ui::RippleAnimation::roundRectMask(size, st::buttonRadius);
case 2:
case ImageRoundRadius::Large:
return Ui::RippleAnimation::roundRectMask(size, st::dateRadius);
default:
@ -756,22 +734,7 @@ void UserpicButton::setImage(QImage &&image) {
size * cIntRetinaFactor(),
Qt::IgnoreAspectRatio,
Qt::SmoothTransformation);
switch (cUserpicCornersType()) {
case 0:
Images::prepareRound(small, ImageRoundRadius::None);
break;
case 1:
Images::prepareRound(small, ImageRoundRadius::Small);
break;
case 2:
Images::prepareRound(small, ImageRoundRadius::Large);
break;
default:
Images::prepareCircle(small);
}
Images::prepareRound(small, KotatoImageRoundRadius());
_userpic = Ui::PixmapFromImage(std::move(small));
_userpic.setDevicePixelRatio(cRetinaFactor());
@ -790,22 +753,18 @@ void UserpicButton::prepareUserpicPixmap() {
PainterHighQualityEnabler hq(p);
p.setBrush(color);
p.setPen(Qt::NoPen);
switch (cUserpicCornersType()) {
case 0:
p.drawRoundedRect(
QRect{ 0, 0, size, size },
0, 0);
switch (KotatoImageRoundRadius()) {
case ImageRoundRadius::None:
p.drawRoundedRect(QRect{ 0, 0, size, size }, 0, 0);
break;
case 1:
p.drawRoundedRect(
QRect{ 0, 0, size, size },
case ImageRoundRadius::Small:
p.drawRoundedRect(QRect{ 0, 0, size, size },
st::buttonRadius, st::buttonRadius);
break;
case 2:
p.drawRoundedRect(
QRect{ 0, 0, size, size },
case ImageRoundRadius::Large:
p.drawRoundedRect(QRect{ 0, 0, size, size },
st::dateRadius, st::dateRadius);
break;

View file

@ -8,6 +8,7 @@ https://github.com/telegramdesktop/tdesktop/blob/master/LEGAL
#include "ui/widgets/multi_select.h"
#include "styles/style_widgets.h"
#include "ui/image/image.h"
#include "ui/widgets/buttons.h"
#include "ui/widgets/input_fields.h"
#include "ui/widgets/scroll_area.h"
@ -72,16 +73,16 @@ void MultiSelect::Item::paintOnce(Painter &p, int x, int y, int outerWidth) {
}
auto radius = _st.height / 2;
switch (cUserpicCornersType()) {
case 0:
switch (KotatoImageRoundRadius()) {
case ImageRoundRadius::None:
radius = 0;
break;
case 1:
case ImageRoundRadius::Small:
radius = st::buttonRadius;
break;
case 2:
case ImageRoundRadius::Large:
radius = st::dateRadius;
break;
}
@ -126,22 +127,18 @@ void MultiSelect::Item::paintDeleteButton(Painter &p, int x, int y, int outerWid
p.setBrush(_color);
{
PainterHighQualityEnabler hq(p);
switch (cUserpicCornersType()) {
case 0:
p.drawRoundedRect(
style::rtlrect(x, y, _st.height, _st.height, outerWidth),
0, 0);
switch (KotatoImageRoundRadius()) {
case ImageRoundRadius::None:
p.drawRoundedRect(style::rtlrect(x, y, _st.height, _st.height, outerWidth), 0, 0);
break;
case 1:
p.drawRoundedRect(
style::rtlrect(x, y, _st.height, _st.height, outerWidth),
case ImageRoundRadius::Small:
p.drawRoundedRect(style::rtlrect(x, y, _st.height, _st.height, outerWidth),
st::buttonRadius, st::buttonRadius);
break;
case 2:
p.drawRoundedRect(
style::rtlrect(x, y, _st.height, _st.height, outerWidth),
case ImageRoundRadius::Large:
p.drawRoundedRect(style::rtlrect(x, y, _st.height, _st.height, outerWidth),
st::dateRadius, st::dateRadius);
break;

View file

@ -7,6 +7,7 @@ https://github.com/telegramdesktop/tdesktop/blob/master/LEGAL
*/
#include "window/main_window.h"
#include "kotato/kotato_settings.h"
#include "storage/localstorage.h"
#include "platform/platform_specific.h"
#include "ui/platform/ui_platform_window.h"
@ -139,7 +140,7 @@ QIcon CreateOfficialIcon(Main::Session *session) {
const auto customIcon = QImage(cWorkingDir() + "tdata/icon.png");
auto image = customIcon.isNull()
? Logo(cCustomAppIcon())
? Logo(::Kotato::JsonSettings::GetInt("custom_app_icon"))
: customIcon;
if (session && session->supportMode()) {
@ -151,7 +152,7 @@ QIcon CreateOfficialIcon(Main::Session *session) {
QIcon CreateIcon(Main::Session *session) {
if constexpr (Platform::IsMac()) {
if ((!session || !session->supportMode())
&& (cCustomAppIcon() == 0)
&& (::Kotato::JsonSettings::GetInt("custom_app_icon") == 0)
&& !QFileInfo::exists(cWorkingDir() + "tdata/icon.png")) {
return QIcon();
}
@ -161,7 +162,7 @@ QIcon CreateIcon(Main::Session *session) {
#if defined Q_OS_UNIX && !defined Q_OS_MAC
if ((session && session->supportMode())
|| (cCustomAppIcon() != 0)
|| (::Kotato::JsonSettings::GetInt("custom_app_icon") != 0)
|| QFileInfo::exists(cWorkingDir() + "tdata/icon.png")) {
return result;
}
@ -446,10 +447,11 @@ void MainWindow::updateWindowIcon() {
? &sessionController()->session()
: nullptr;
const auto supportIcon = session && session->supportMode();
if (supportIcon != _usingSupportIcon || _icon.isNull() || _customIconId != cCustomAppIcon()) {
const auto customAppIcon = ::Kotato::JsonSettings::GetInt("custom_app_icon");
if (supportIcon != _usingSupportIcon || _icon.isNull() || _customIconId != customAppIcon) {
_icon = CreateIcon(session);
_usingSupportIcon = supportIcon;
_customIconId = cCustomAppIcon();
_customIconId = customAppIcon;
}
setWindowIcon(_icon);
}

View file

@ -7,6 +7,7 @@ https://github.com/telegramdesktop/tdesktop/blob/master/LEGAL
*/
#include "window/notifications_manager_default.h"
#include "kotato/kotato_settings.h"
#include "platform/platform_notifications_manager.h"
#include "platform/platform_specific.h"
#include "core/application.h"
@ -88,7 +89,7 @@ Manager::QueuedNotification::QueuedNotification(
QPixmap Manager::hiddenUserpicPlaceholder() const {
if (_hiddenUserpicPlaceholder.isNull()) {
_hiddenUserpicPlaceholder = Ui::PixmapFromImage(
LogoNoMargin(cCustomAppIcon()).scaled(
LogoNoMargin(::Kotato::JsonSettings::GetInt("custom_app_icon")).scaled(
st::notifyPhotoSize,
st::notifyPhotoSize,
Qt::IgnoreAspectRatio,

View file

@ -7,6 +7,7 @@ https://github.com/telegramdesktop/tdesktop/blob/master/LEGAL
*/
#include "window/notifications_utilities.h"
#include "kotato/kotato_settings.h"
#include "window/main_window.h"
#include "base/platform/base_platform_file_utilities.h"
#include "base/random.h"
@ -80,7 +81,7 @@ QString CachedUserpics::get(
peer->saveUserpic(view, v.path, st::notifyMacPhotoSize);
}
} else {
LogoNoMargin(cCustomAppIcon()).save(v.path, "PNG");
LogoNoMargin(::Kotato::JsonSettings::GetInt("custom_app_icon")).save(v.path, "PNG");
}
i = _images.insert(key, v);
_someSavedFlag = true;

View file

@ -7,6 +7,7 @@ https://github.com/telegramdesktop/tdesktop/blob/master/LEGAL
*/
#include "window/themes/window_theme_preview.h"
#include "kotato/kotato_settings.h"
#include "lang/lang_keys.h"
#include "platform/platform_window_title.h"
#include "ui/text/text_options.h"
@ -251,7 +252,7 @@ void Generator::addAudioBubble(QVector<int> waveform, int waveactive, QString wa
const auto &st = st::msgFileLayout;
auto tleft = st.padding.left() + st.thumbSize + st.padding.right();
accumulate_max(width, tleft + st::normalFont->width(wavestatus) + skipBlock.width() + st::msgPadding.right());
if (!AdaptiveBubbles()) {
if (!::Kotato::JsonSettings::GetBool("adaptive_bubbles")) {
accumulate_min(width, st::msgMaxWidth);
}
@ -281,7 +282,7 @@ void Generator::addTextBubble(QString text, QString date, Status status) {
auto width = _history.width() - st::msgMargin.left() - st::msgMargin.right();
accumulate_min(width, st::msgPadding.left() + bubble.text.maxWidth() + st::msgPadding.right());
if (!AdaptiveBubbles()) {
if (!::Kotato::JsonSettings::GetBool("adaptive_bubbles")) {
accumulate_min(width, st::msgMaxWidth);
}
@ -307,7 +308,7 @@ void Generator::addPhotoBubble(QString image, QString caption, QString date, Sta
auto width = _history.width() - st::msgMargin.left() - st::msgMargin.right();
accumulate_min(width, bubble.photoWidth);
if (!AdaptiveBubbles()) {
if (!::Kotato::JsonSettings::GetBool("adaptive_bubbles")) {
accumulate_min(width, st::msgMaxWidth);
}

View file

@ -7,6 +7,7 @@ https://github.com/telegramdesktop/tdesktop/blob/master/LEGAL
*/
#include "window/window_filters_menu.h"
#include "kotato/kotato_settings.h"
#include "kotato/kotato_lang.h"
#include "mainwindow.h"
#include "window/window_session_controller.h"
@ -25,7 +26,6 @@ https://github.com/telegramdesktop/tdesktop/blob/master/LEGAL
#include "ui/toast/toast.h"
#include "ui/boxes/confirm_box.h"
#include "boxes/filters/edit_filter_box.h"
#include "kotato/json_settings.h"
#include "settings/settings_common.h"
#include "api/api_chat_filters.h"
#include "apiwrap.h"
@ -102,7 +102,9 @@ void FiltersMenu::setup() {
_parent->heightValue(
) | rpl::start_with_next([=](int height) {
const auto width = (cHideFilterNames() ? st::windowFiltersWidthNoText : st::windowFiltersWidth);
const auto width = (::Kotato::JsonSettings::GetBool("folders/hide_names")
? st::windowFiltersWidthNoText
: st::windowFiltersWidth);
_outer.setGeometry({ 0, 0, width, height });
_menu.resizeToWidth(width);
_menu.move(0, 0);
@ -219,7 +221,7 @@ void FiltersMenu::refresh() {
const auto i = _filters.find(_activeFilterId);
if (i != end(_filters)) {
scrollToButton(i->second);
} else if (!cHideFilterAllChats()) {
} else if (!::Kotato::JsonSettings::GetBool("folders/hide_all_chats")) {
scrollToButton(_all);
}
@ -230,7 +232,7 @@ void FiltersMenu::refresh() {
}
void FiltersMenu::setupList() {
if (!cHideFilterAllChats()) {
if (!::Kotato::JsonSettings::GetBool("folders/hide_all_chats")) {
_all = prepareButton(
_container,
0,
@ -238,7 +240,7 @@ void FiltersMenu::setupList() {
Ui::FilterIcon::All);
}
_list = _container->add(object_ptr<Ui::VerticalLayout>(_container));
if (!cHideFilterEditButton()) {
if (!::Kotato::JsonSettings::GetBool("folders/hide_edit_button")) {
_setup = prepareButton(
_container,
-1,
@ -271,7 +273,7 @@ base::unique_qptr<Ui::SideBarButton> FiltersMenu::prepareButton(
auto button = base::unique_qptr<Ui::SideBarButton>(container->add(
object_ptr<Ui::SideBarButton>(
container,
(cHideFilterNames() ? QString() : title),
(::Kotato::JsonSettings::GetBool("folders/hide_names") ? QString() : title),
st::windowFiltersButton)));
const auto raw = button.get();
const auto &icons = Ui::LookupFilterIcon(icon);
@ -283,7 +285,7 @@ base::unique_qptr<Ui::SideBarButton> FiltersMenu::prepareButton(
) | rpl::start_with_next([=](const Dialogs::UnreadState &state) {
const auto count = (state.chats + state.marks);
const auto muted = (state.chatsMuted + state.marksMuted);
if (cUnmutedFilterCounterOnly()) {
if (::Kotato::JsonSettings::GetBool("folders/count_unmuted_only")) {
const auto unmuted = count - muted;
const auto string = !unmuted
? QString()
@ -419,8 +421,8 @@ void FiltersMenu::showAllMenu(QPoint position) {
_popupMenu->addAction(
ktr("ktg_filters_hide_folder"),
crl::guard(&_outer, [=] {
cSetHideFilterAllChats(true);
Kotato::JsonSettings::Write();
::Kotato::JsonSettings::Set("folders/hide_all_chats", true);
::Kotato::JsonSettings::Write();
_all = nullptr;
Ui::Toast::Show(Ui::Toast::Config{
.text = { ktr("ktg_filters_hide_all_chats_toast") },
@ -443,8 +445,8 @@ void FiltersMenu::showEditMenu(QPoint position) {
_popupMenu->addAction(
ktr("ktg_filters_hide_button"),
crl::guard(&_outer, [=] {
cSetHideFilterEditButton(true);
Kotato::JsonSettings::Write();
::Kotato::JsonSettings::Set("folders/hide_edit_button", true);
::Kotato::JsonSettings::Write();
_setup = nullptr;
Ui::Toast::Show(Ui::Toast::Config{
.text = { ktr("ktg_filters_hide_edit_toast") },
@ -483,14 +485,8 @@ void FiltersMenu::remove(FilterId id) {
Assert(i != end(list));
bool needSave = false;
if (i->isLocal()) {
const auto account = &_session->session().account();
auto &localFolders = cRefLocalFolders();
const auto j = ranges::find_if(localFolders, [id, account](LocalFolder localFolder) {
return (id == localFolder.id
&& account->isCurrent(localFolder.ownerId, localFolder.isTest));
});
filters->remove(id);
localFolders.erase(j);
filters->saveLocal();
needSave = true;
} else {
_session->session().data().chatsFilters().apply(MTP_updateDialogFilter(
@ -542,6 +538,7 @@ void FiltersMenu::applyReorder(
_ignoreRefresh = true;
filters->saveOrder(order);
_ignoreRefresh = false;
filters->saveLocal();
Kotato::JsonSettings::Write();
}

View file

@ -7,6 +7,7 @@ https://github.com/telegramdesktop/tdesktop/blob/master/LEGAL
*/
#include "window/window_main_menu.h"
#include "kotato/kotato_settings.h"
#include "kotato/kotato_lang.h"
#include "window/themes/window_theme.h"
#include "window/window_peer_menu.h"
@ -1157,7 +1158,7 @@ void MainMenu::paintEvent(QPaintEvent *e) {
p.fillRect(cover, st::mainMenuCoverBg);
}
p.setPen(st::mainMenuCoverFg);
if (cShowPhoneInDrawer()) {
if (::Kotato::JsonSettings::GetBool("show_phone_in_drawer")) {
p.setFont(st::semiboldFont);
_controller->session().user()->nameText().drawLeftElided(
p,

View file

@ -7,6 +7,7 @@ https://github.com/telegramdesktop/tdesktop/blob/master/LEGAL
*/
#include "window/window_peer_menu.h"
#include "kotato/kotato_settings.h"
#include "kotato/kotato_lang.h"
#include "api/api_chat_participants.h"
#include "lang/lang_keys.h"
@ -825,7 +826,7 @@ void Filler::fillArchiveActions() {
return;
}
const auto controller = _controller;
if (DialogListLines() != 1) {
if (::Kotato::JsonSettings::GetInt("chat_list_lines") != 1) {
const auto hidden = controller->session().settings().archiveCollapsed();
const auto text = hidden
? tr::lng_context_archive_expand(tr::now)
@ -1303,7 +1304,8 @@ QPointer<Ui::RpWidget> ShowForwardMessagesBox(
checkAndClose();
});
}
if (data->submitCallback && !cForwardRetainSelection()) {
if (data->submitCallback
&& !::Kotato::JsonSettings::GetBool("forward_retain_selection")) {
data->submitCallback();
}
};
@ -1314,7 +1316,8 @@ QPointer<Ui::RpWidget> ShowForwardMessagesBox(
? Fn<void()>(std::move(copyCallback))
: Fn<void()>();
auto goToChatCallback = [navigation, data](PeerData *peer, Data::ForwardDraft &&newDraft) {
if (data->submitCallback && !cForwardRetainSelection()) {
if (data->submitCallback
&& !::Kotato::JsonSettings::GetBool("forward_retain_selection")) {
data->submitCallback();
}
data->draft.options = newDraft.options;
@ -1345,7 +1348,7 @@ QPointer<Ui::RpWidget> ShowForwardMessagesBox(
MessageIdsList &&items,
FnMut<void()> &&successCallback) {
const auto options = [] {
switch (ForwardMode()) {
switch (::Kotato::JsonSettings::GetInt("forward_mode")) {
case 1: return Data::ForwardOptions::NoSenderNames;
case 2: return Data::ForwardOptions::NoNamesAndCaptions;
default: return Data::ForwardOptions::PreserveInfo;
@ -1353,7 +1356,7 @@ QPointer<Ui::RpWidget> ShowForwardMessagesBox(
}();
const auto groupOptions = [] {
switch (ForwardGroupingMode()) {
switch (::Kotato::JsonSettings::GetInt("forward_grouping_mode")) {
case 1: return Data::GroupingOptions::RegroupAll;
case 2: return Data::GroupingOptions::Separate;
default: return Data::GroupingOptions::GroupAsIs;

Some files were not shown because too many files have changed in this diff Show more