mirror of
https://github.com/AyuGram/AyuGramDesktop.git
synced 2025-06-05 22:54:01 +02:00
Add "Include muted chats in folder counters".
This commit is contained in:
parent
3658b32db5
commit
3218c30983
6 changed files with 62 additions and 11 deletions
|
@ -508,6 +508,7 @@ https://github.com/telegramdesktop/tdesktop/blob/master/LEGAL
|
||||||
"lng_settings_alert_linux" = "Draw attention to the window";
|
"lng_settings_alert_linux" = "Draw attention to the window";
|
||||||
"lng_settings_badge_title" = "Badge counter";
|
"lng_settings_badge_title" = "Badge counter";
|
||||||
"lng_settings_include_muted" = "Include muted chats in unread count";
|
"lng_settings_include_muted" = "Include muted chats in unread count";
|
||||||
|
"lng_settings_include_muted_folders" = "Include muted chats in folder counters";
|
||||||
"lng_settings_count_unread" = "Count unread messages";
|
"lng_settings_count_unread" = "Count unread messages";
|
||||||
"lng_settings_events_title" = "Events";
|
"lng_settings_events_title" = "Events";
|
||||||
"lng_settings_events_joined" = "Contact joined Telegram";
|
"lng_settings_events_joined" = "Contact joined Telegram";
|
||||||
|
|
|
@ -221,7 +221,8 @@ QByteArray Settings::serialize() const {
|
||||||
+ Serialize::stringSize(noWarningExtensions)
|
+ Serialize::stringSize(noWarningExtensions)
|
||||||
+ Serialize::stringSize(_customFontFamily)
|
+ Serialize::stringSize(_customFontFamily)
|
||||||
+ sizeof(qint32) * 3
|
+ sizeof(qint32) * 3
|
||||||
+ Serialize::bytearraySize(_tonsiteStorageToken);
|
+ Serialize::bytearraySize(_tonsiteStorageToken)
|
||||||
|
+ sizeof(qint32);
|
||||||
|
|
||||||
auto result = QByteArray();
|
auto result = QByteArray();
|
||||||
result.reserve(size);
|
result.reserve(size);
|
||||||
|
@ -375,7 +376,8 @@ QByteArray Settings::serialize() const {
|
||||||
1000000))
|
1000000))
|
||||||
<< qint32(_systemUnlockEnabled ? 1 : 0)
|
<< qint32(_systemUnlockEnabled ? 1 : 0)
|
||||||
<< qint32(!_weatherInCelsius ? 0 : *_weatherInCelsius ? 1 : 2)
|
<< qint32(!_weatherInCelsius ? 0 : *_weatherInCelsius ? 1 : 2)
|
||||||
<< _tonsiteStorageToken;
|
<< _tonsiteStorageToken
|
||||||
|
<< qint32(_includeMutedCounterFolders ? 1 : 0);
|
||||||
}
|
}
|
||||||
|
|
||||||
Ensures(result.size() == size);
|
Ensures(result.size() == size);
|
||||||
|
@ -423,6 +425,7 @@ void Settings::addFromSerialized(const QByteArray &serialized) {
|
||||||
qint32 sendFilesWay = _sendFilesWay.serialize();
|
qint32 sendFilesWay = _sendFilesWay.serialize();
|
||||||
qint32 sendSubmitWay = static_cast<qint32>(_sendSubmitWay.current());
|
qint32 sendSubmitWay = static_cast<qint32>(_sendSubmitWay.current());
|
||||||
qint32 includeMutedCounter = _includeMutedCounter ? 1 : 0;
|
qint32 includeMutedCounter = _includeMutedCounter ? 1 : 0;
|
||||||
|
qint32 includeMutedCounterFolders = _includeMutedCounterFolders ? 1 : 0;
|
||||||
qint32 countUnreadMessages = _countUnreadMessages ? 1 : 0;
|
qint32 countUnreadMessages = _countUnreadMessages ? 1 : 0;
|
||||||
std::optional<QString> noWarningExtensions;
|
std::optional<QString> noWarningExtensions;
|
||||||
qint32 legacyExeLaunchWarning = 1;
|
qint32 legacyExeLaunchWarning = 1;
|
||||||
|
@ -804,6 +807,9 @@ void Settings::addFromSerialized(const QByteArray &serialized) {
|
||||||
if (!stream.atEnd()) {
|
if (!stream.atEnd()) {
|
||||||
stream >> tonsiteStorageToken;
|
stream >> tonsiteStorageToken;
|
||||||
}
|
}
|
||||||
|
if (!stream.atEnd()) {
|
||||||
|
stream >> includeMutedCounterFolders;
|
||||||
|
}
|
||||||
if (stream.status() != QDataStream::Ok) {
|
if (stream.status() != QDataStream::Ok) {
|
||||||
LOG(("App Error: "
|
LOG(("App Error: "
|
||||||
"Bad data for Core::Settings::constructFromSerialized()"));
|
"Bad data for Core::Settings::constructFromSerialized()"));
|
||||||
|
@ -844,6 +850,7 @@ void Settings::addFromSerialized(const QByteArray &serialized) {
|
||||||
case ScreenCorner::BottomLeft: _notificationsCorner = uncheckedNotificationsCorner; break;
|
case ScreenCorner::BottomLeft: _notificationsCorner = uncheckedNotificationsCorner; break;
|
||||||
}
|
}
|
||||||
_includeMutedCounter = (includeMutedCounter == 1);
|
_includeMutedCounter = (includeMutedCounter == 1);
|
||||||
|
_includeMutedCounterFolders = (includeMutedCounterFolders == 1);
|
||||||
_countUnreadMessages = (countUnreadMessages == 1);
|
_countUnreadMessages = (countUnreadMessages == 1);
|
||||||
_notifyAboutPinned = (notifyAboutPinned == 1);
|
_notifyAboutPinned = (notifyAboutPinned == 1);
|
||||||
_autoLock = autoLock;
|
_autoLock = autoLock;
|
||||||
|
@ -864,8 +871,6 @@ void Settings::addFromSerialized(const QByteArray &serialized) {
|
||||||
case Ui::InputSubmitSettings::Enter:
|
case Ui::InputSubmitSettings::Enter:
|
||||||
case Ui::InputSubmitSettings::CtrlEnter: _sendSubmitWay = uncheckedSendSubmitWay; break;
|
case Ui::InputSubmitSettings::CtrlEnter: _sendSubmitWay = uncheckedSendSubmitWay; break;
|
||||||
}
|
}
|
||||||
_includeMutedCounter = (includeMutedCounter == 1);
|
|
||||||
_countUnreadMessages = (countUnreadMessages == 1);
|
|
||||||
if (noWarningExtensions) {
|
if (noWarningExtensions) {
|
||||||
const auto list = noWarningExtensions->mid(0, 10240)
|
const auto list = noWarningExtensions->mid(0, 10240)
|
||||||
.split(' ', Qt::SkipEmptyParts)
|
.split(' ', Qt::SkipEmptyParts)
|
||||||
|
@ -1345,6 +1350,7 @@ void Settings::resetOnLastLogout() {
|
||||||
//_notificationsCount = 3;
|
//_notificationsCount = 3;
|
||||||
//_notificationsCorner = ScreenCorner::BottomRight;
|
//_notificationsCorner = ScreenCorner::BottomRight;
|
||||||
_includeMutedCounter = true;
|
_includeMutedCounter = true;
|
||||||
|
_includeMutedCounterFolders = true;
|
||||||
_countUnreadMessages = true;
|
_countUnreadMessages = true;
|
||||||
_notifyAboutPinned = true;
|
_notifyAboutPinned = true;
|
||||||
//_autoLock = 3600;
|
//_autoLock = 3600;
|
||||||
|
|
|
@ -238,6 +238,12 @@ public:
|
||||||
void setIncludeMutedCounter(bool value) {
|
void setIncludeMutedCounter(bool value) {
|
||||||
_includeMutedCounter = value;
|
_includeMutedCounter = value;
|
||||||
}
|
}
|
||||||
|
[[nodiscard]] bool includeMutedCounterFolders() const {
|
||||||
|
return _includeMutedCounterFolders;
|
||||||
|
}
|
||||||
|
void setIncludeMutedCounterFolders(bool value) {
|
||||||
|
_includeMutedCounterFolders = value;
|
||||||
|
}
|
||||||
[[nodiscard]] bool countUnreadMessages() const {
|
[[nodiscard]] bool countUnreadMessages() const {
|
||||||
return _countUnreadMessages;
|
return _countUnreadMessages;
|
||||||
}
|
}
|
||||||
|
@ -951,6 +957,7 @@ private:
|
||||||
int _notificationsCount = 3;
|
int _notificationsCount = 3;
|
||||||
ScreenCorner _notificationsCorner = ScreenCorner::BottomRight;
|
ScreenCorner _notificationsCorner = ScreenCorner::BottomRight;
|
||||||
bool _includeMutedCounter = true;
|
bool _includeMutedCounter = true;
|
||||||
|
bool _includeMutedCounterFolders = true;
|
||||||
bool _countUnreadMessages = true;
|
bool _countUnreadMessages = true;
|
||||||
rpl::variable<bool> _notifyAboutPinned = true;
|
rpl::variable<bool> _notifyAboutPinned = true;
|
||||||
int _autoLock = 3600;
|
int _autoLock = 3600;
|
||||||
|
|
|
@ -35,6 +35,7 @@ https://github.com/telegramdesktop/tdesktop/blob/master/LEGAL
|
||||||
#include "main/main_domain.h"
|
#include "main/main_domain.h"
|
||||||
#include "api/api_authorizations.h"
|
#include "api/api_authorizations.h"
|
||||||
#include "api/api_ringtones.h"
|
#include "api/api_ringtones.h"
|
||||||
|
#include "data/data_chat_filters.h"
|
||||||
#include "data/data_session.h"
|
#include "data/data_session.h"
|
||||||
#include "data/data_document.h"
|
#include "data/data_document.h"
|
||||||
#include "data/notify/data_notify_settings.h"
|
#include "data/notify/data_notify_settings.h"
|
||||||
|
@ -1085,6 +1086,16 @@ void SetupNotificationsContent(
|
||||||
tr::lng_settings_include_muted(),
|
tr::lng_settings_include_muted(),
|
||||||
st::settingsButtonNoIcon));
|
st::settingsButtonNoIcon));
|
||||||
muted->toggleOn(rpl::single(settings.includeMutedCounter()));
|
muted->toggleOn(rpl::single(settings.includeMutedCounter()));
|
||||||
|
const auto mutedFolders = session->data().chatsFilters().has()
|
||||||
|
? container->add(object_ptr<Button>(
|
||||||
|
container,
|
||||||
|
tr::lng_settings_include_muted_folders(),
|
||||||
|
st::settingsButtonNoIcon))
|
||||||
|
: nullptr;
|
||||||
|
if (mutedFolders) {
|
||||||
|
mutedFolders->toggleOn(
|
||||||
|
rpl::single(settings.includeMutedCounterFolders()));
|
||||||
|
}
|
||||||
const auto count = container->add(object_ptr<Button>(
|
const auto count = container->add(object_ptr<Button>(
|
||||||
container,
|
container,
|
||||||
tr::lng_settings_count_unread(),
|
tr::lng_settings_count_unread(),
|
||||||
|
@ -1202,6 +1213,17 @@ void SetupNotificationsContent(
|
||||||
changed(Change::IncludeMuted);
|
changed(Change::IncludeMuted);
|
||||||
}, muted->lifetime());
|
}, muted->lifetime());
|
||||||
|
|
||||||
|
if (mutedFolders) {
|
||||||
|
mutedFolders->toggledChanges(
|
||||||
|
) | rpl::filter([=](bool checked) {
|
||||||
|
return (checked
|
||||||
|
!= Core::App().settings().includeMutedCounterFolders());
|
||||||
|
}) | rpl::start_with_next([=](bool checked) {
|
||||||
|
Core::App().settings().setIncludeMutedCounterFolders(checked);
|
||||||
|
changed(Change::IncludeMuted);
|
||||||
|
}, mutedFolders->lifetime());
|
||||||
|
}
|
||||||
|
|
||||||
count->toggledChanges(
|
count->toggledChanges(
|
||||||
) | rpl::filter([=](bool checked) {
|
) | rpl::filter([=](bool checked) {
|
||||||
return (checked != Core::App().settings().countUnreadMessages());
|
return (checked != Core::App().settings().countUnreadMessages());
|
||||||
|
|
|
@ -13,6 +13,9 @@ https://github.com/telegramdesktop/tdesktop/blob/master/LEGAL
|
||||||
#include "window/window_main_menu.h"
|
#include "window/window_main_menu.h"
|
||||||
#include "window/window_peer_menu.h"
|
#include "window/window_peer_menu.h"
|
||||||
#include "main/main_session.h"
|
#include "main/main_session.h"
|
||||||
|
#include "core/application.h"
|
||||||
|
#include "core/core_settings.h"
|
||||||
|
#include "window/notifications_manager.h"
|
||||||
#include "data/data_session.h"
|
#include "data/data_session.h"
|
||||||
#include "data/data_chat_filters.h"
|
#include "data/data_chat_filters.h"
|
||||||
#include "data/data_folder.h"
|
#include "data/data_folder.h"
|
||||||
|
@ -85,7 +88,15 @@ FiltersMenu::FiltersMenu(
|
||||||
, _scroll(&_outer)
|
, _scroll(&_outer)
|
||||||
, _container(
|
, _container(
|
||||||
_scroll.setOwnedWidget(
|
_scroll.setOwnedWidget(
|
||||||
object_ptr<Ui::VerticalLayout>(&_scroll))) {
|
object_ptr<Ui::VerticalLayout>(&_scroll)))
|
||||||
|
, _includeMuted(Core::App().settings().includeMutedCounterFolders()) {
|
||||||
|
Core::App().notifications().settingsChanged(
|
||||||
|
) | rpl::filter(
|
||||||
|
rpl::mappers::_1 == Window::Notifications::ChangeType::IncludeMuted
|
||||||
|
) | rpl::start_with_next([=] {
|
||||||
|
_includeMuted = Core::App().settings().includeMutedCounterFolders();
|
||||||
|
}, _outer.lifetime());
|
||||||
|
|
||||||
_drag.timer.setCallback([=] {
|
_drag.timer.setCallback([=] {
|
||||||
if (_drag.filterId >= 0) {
|
if (_drag.filterId >= 0) {
|
||||||
_session->setActiveChatsFilter(_drag.filterId);
|
_session->setActiveChatsFilter(_drag.filterId);
|
||||||
|
@ -298,18 +309,21 @@ base::unique_qptr<Ui::SideBarButton> FiltersMenu::prepareButton(
|
||||||
: Ui::FilterIcon::All);
|
: Ui::FilterIcon::All);
|
||||||
raw->setIconOverride(icons.normal, icons.active);
|
raw->setIconOverride(icons.normal, icons.active);
|
||||||
if (id >= 0) {
|
if (id >= 0) {
|
||||||
UnreadStateValue(
|
rpl::combine(
|
||||||
&_session->session(),
|
UnreadStateValue(&_session->session(), id),
|
||||||
id
|
_includeMuted.value()
|
||||||
) | rpl::start_with_next([=](const Dialogs::UnreadState &state) {
|
) | rpl::start_with_next([=](
|
||||||
const auto count = (state.chats + state.marks);
|
const Dialogs::UnreadState &state,
|
||||||
|
bool includeMuted) {
|
||||||
const auto muted = (state.chatsMuted + state.marksMuted);
|
const auto muted = (state.chatsMuted + state.marksMuted);
|
||||||
|
const auto count = (state.chats + state.marks)
|
||||||
|
- (includeMuted ? 0 : muted);
|
||||||
const auto string = !count
|
const auto string = !count
|
||||||
? QString()
|
? QString()
|
||||||
: (count > 99)
|
: (count > 99)
|
||||||
? "99+"
|
? "99+"
|
||||||
: QString::number(count);
|
: QString::number(count);
|
||||||
raw->setBadge(string, count == muted);
|
raw->setBadge(string, includeMuted && (count == muted));
|
||||||
}, raw->lifetime());
|
}, raw->lifetime());
|
||||||
}
|
}
|
||||||
raw->setActive(_session->activeChatsFilterCurrent() == id);
|
raw->setActive(_session->activeChatsFilterCurrent() == id);
|
||||||
|
|
|
@ -64,6 +64,7 @@ private:
|
||||||
std::unique_ptr<Ui::VerticalLayoutReorder> _reorder;
|
std::unique_ptr<Ui::VerticalLayoutReorder> _reorder;
|
||||||
base::unique_qptr<Ui::SideBarButton> _setup;
|
base::unique_qptr<Ui::SideBarButton> _setup;
|
||||||
base::flat_map<FilterId, base::unique_qptr<Ui::SideBarButton>> _filters;
|
base::flat_map<FilterId, base::unique_qptr<Ui::SideBarButton>> _filters;
|
||||||
|
rpl::variable<bool> _includeMuted;
|
||||||
FilterId _activeFilterId = 0;
|
FilterId _activeFilterId = 0;
|
||||||
int _reordering = 0;
|
int _reordering = 0;
|
||||||
bool _ignoreRefresh = false;
|
bool _ignoreRefresh = false;
|
||||||
|
|
Loading…
Add table
Reference in a new issue