mirror of
https://github.com/AyuGram/AyuGramDesktop.git
synced 2025-04-19 15:47:11 +02:00
Use rpl for Window::Theme::Background updates.
This commit is contained in:
parent
7e83088a84
commit
4276b6cce0
66 changed files with 203 additions and 262 deletions
|
@ -37,6 +37,7 @@ https://github.com/telegramdesktop/tdesktop/blob/master/LEGAL
|
|||
#include "data/data_cloud_themes.h"
|
||||
#include "data/data_chat_filters.h"
|
||||
#include "data/data_histories.h"
|
||||
#include "data/data_wall_paper.h"
|
||||
#include "data/stickers/data_stickers.h"
|
||||
#include "dialogs/dialogs_key.h"
|
||||
#include "core/core_cloud_password.h"
|
||||
|
@ -62,7 +63,6 @@ https://github.com/telegramdesktop/tdesktop/blob/master/LEGAL
|
|||
#include "window/notifications_manager.h"
|
||||
#include "window/window_lock_widgets.h"
|
||||
#include "window/window_session_controller.h"
|
||||
#include "window/themes/window_theme.h"
|
||||
#include "inline_bots/inline_bot_result.h"
|
||||
#include "chat_helpers/message_field.h"
|
||||
#include "ui/item_text_options.h"
|
||||
|
|
|
@ -108,7 +108,7 @@ QString RequestKey(Types &&...values) {
|
|||
|
||||
} // namespace Api
|
||||
|
||||
class ApiWrap : public MTP::Sender, private base::Subscriber {
|
||||
class ApiWrap final : public MTP::Sender {
|
||||
public:
|
||||
using SendAction = Api::SendAction;
|
||||
using MessageToSend = Api::MessageToSend;
|
||||
|
|
|
@ -19,7 +19,7 @@ https://github.com/telegramdesktop/tdesktop/blob/master/LEGAL
|
|||
#include "history/history.h"
|
||||
#include "history/history_location_manager.h"
|
||||
#include "history/history_item_components.h"
|
||||
#include "history/view/history_view_service_message.h"
|
||||
#include "history/view/history_view_element.h"
|
||||
#include "media/audio/media_audio.h"
|
||||
#include "ui/image/image.h"
|
||||
#include "ui/cached_round_corners.h"
|
||||
|
@ -28,7 +28,6 @@ https://github.com/telegramdesktop/tdesktop/blob/master/LEGAL
|
|||
#include "core/update_checker.h"
|
||||
#include "core/sandbox.h"
|
||||
#include "core/application.h"
|
||||
#include "window/themes/window_theme.h"
|
||||
#include "window/notifications_manager.h"
|
||||
#include "window/window_controller.h"
|
||||
#include "platform/platform_notifications_manager.h"
|
||||
|
@ -99,16 +98,6 @@ namespace App {
|
|||
|
||||
void initMedia() {
|
||||
Ui::StartCachedCorners();
|
||||
|
||||
using Update = Window::Theme::BackgroundUpdate;
|
||||
static auto subscription = Window::Theme::Background()->add_subscription([](const Update &update) {
|
||||
if (update.paletteChanged()) {
|
||||
if (const auto m = App::main()) { // multi good
|
||||
m->updateScrollColors();
|
||||
}
|
||||
HistoryView::serviceColorsUpdated();
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
void deinitMedia() {
|
||||
|
|
|
@ -145,9 +145,7 @@ private:
|
|||
|
||||
};
|
||||
|
||||
class SetupChannelBox final
|
||||
: public Ui::BoxContent
|
||||
, private base::Subscriber {
|
||||
class SetupChannelBox final : public Ui::BoxContent {
|
||||
public:
|
||||
SetupChannelBox(
|
||||
QWidget*,
|
||||
|
@ -244,9 +242,7 @@ private:
|
|||
|
||||
};
|
||||
|
||||
class RevokePublicLinkBox final
|
||||
: public Ui::BoxContent
|
||||
, private base::Subscriber {
|
||||
class RevokePublicLinkBox final : public Ui::BoxContent {
|
||||
public:
|
||||
RevokePublicLinkBox(
|
||||
QWidget*,
|
||||
|
|
|
@ -21,6 +21,7 @@ https://github.com/telegramdesktop/tdesktop/blob/master/LEGAL
|
|||
#include "boxes/background_preview_box.h"
|
||||
#include "boxes/confirm_box.h"
|
||||
#include "window/window_session_controller.h"
|
||||
#include "window/themes/window_theme.h"
|
||||
#include "styles/style_overview.h"
|
||||
#include "styles/style_layers.h"
|
||||
#include "styles/style_boxes.h"
|
||||
|
@ -55,9 +56,7 @@ QImage TakeMiddleSample(QImage original, QSize size) {
|
|||
|
||||
} // namespace
|
||||
|
||||
class BackgroundBox::Inner final
|
||||
: public Ui::RpWidget
|
||||
, private base::Subscriber {
|
||||
class BackgroundBox::Inner final : public Ui::RpWidget {
|
||||
public:
|
||||
Inner(
|
||||
QWidget *parent,
|
||||
|
@ -203,16 +202,22 @@ BackgroundBox::Inner::Inner(
|
|||
) | rpl::start_with_next([=] {
|
||||
update();
|
||||
}, lifetime());
|
||||
|
||||
style::PaletteChanged(
|
||||
) | rpl::start_with_next([=] {
|
||||
_check->invalidateCache();
|
||||
}, lifetime());
|
||||
|
||||
using Update = Window::Theme::BackgroundUpdate;
|
||||
subscribe(Window::Theme::Background(), [=](const Update &update) {
|
||||
if (update.paletteChanged()) {
|
||||
_check->invalidateCache();
|
||||
} else if (update.type == Update::Type::New) {
|
||||
Window::Theme::Background()->updates(
|
||||
) | rpl::start_with_next([=](const Update &update) {
|
||||
if (update.type == Update::Type::New) {
|
||||
sortPapers();
|
||||
requestPapers();
|
||||
this->update();
|
||||
}
|
||||
});
|
||||
}, lifetime());
|
||||
|
||||
setMouseTracking(true);
|
||||
}
|
||||
|
||||
|
|
|
@ -99,12 +99,10 @@ private:
|
|||
};
|
||||
|
||||
ServiceCheck::Generator::Generator() {
|
||||
*_lifetime.make_state<base::Subscription>() = Window::Theme::Background(
|
||||
)->add_subscription([=](const Window::Theme::BackgroundUpdate &update) {
|
||||
if (update.paletteChanged()) {
|
||||
invalidate();
|
||||
}
|
||||
});
|
||||
style::PaletteChanged(
|
||||
) | rpl::start_with_next([=] {
|
||||
invalidate();
|
||||
}, _lifetime);
|
||||
}
|
||||
|
||||
auto ServiceCheck::Generator::framesForStyle(
|
||||
|
|
|
@ -9,11 +9,11 @@ https://github.com/telegramdesktop/tdesktop/blob/master/LEGAL
|
|||
|
||||
#include "boxes/abstract_box.h"
|
||||
#include "base/binary_guard.h"
|
||||
#include "window/themes/window_theme.h"
|
||||
#include "history/admin_log/history_admin_log_item.h"
|
||||
#include "history/view/history_view_element.h"
|
||||
#include "ui/effects/animations.h"
|
||||
#include "ui/effects/radial_animation.h"
|
||||
#include "data/data_wall_paper.h"
|
||||
|
||||
namespace Data {
|
||||
class DocumentMedia;
|
||||
|
@ -29,8 +29,7 @@ class Checkbox;
|
|||
|
||||
class BackgroundPreviewBox
|
||||
: public Ui::BoxContent
|
||||
, private HistoryView::SimpleElementDelegate
|
||||
, private base::Subscriber {
|
||||
, private HistoryView::SimpleElementDelegate {
|
||||
public:
|
||||
BackgroundPreviewBox(
|
||||
QWidget*,
|
||||
|
|
|
@ -141,7 +141,7 @@ public:
|
|||
|
||||
};
|
||||
|
||||
class MaxInviteBox : public Ui::BoxContent, private base::Subscriber {
|
||||
class MaxInviteBox final : public Ui::BoxContent {
|
||||
public:
|
||||
MaxInviteBox(QWidget*, not_null<ChannelData*> channel);
|
||||
|
||||
|
|
|
@ -25,7 +25,6 @@ https://github.com/telegramdesktop/tdesktop/blob/master/LEGAL
|
|||
#include "data/data_session.h"
|
||||
#include "data/data_changes.h"
|
||||
#include "base/unixtime.h"
|
||||
#include "window/themes/window_theme.h"
|
||||
#include "styles/style_layers.h"
|
||||
#include "styles/style_boxes.h"
|
||||
#include "styles/style_dialogs.h"
|
||||
|
@ -738,11 +737,11 @@ PeerListContent::PeerListContent(
|
|||
}
|
||||
}, lifetime());
|
||||
|
||||
subscribe(Window::Theme::Background(), [this](const Window::Theme::BackgroundUpdate &update) {
|
||||
if (update.paletteChanged()) {
|
||||
invalidatePixmapsCache();
|
||||
}
|
||||
});
|
||||
style::PaletteChanged(
|
||||
) | rpl::start_with_next([=] {
|
||||
invalidatePixmapsCache();
|
||||
}, lifetime());
|
||||
|
||||
_repaintByStatus.setCallback([this] { update(); });
|
||||
}
|
||||
|
||||
|
|
|
@ -527,9 +527,7 @@ struct PeerListState {
|
|||
QString searchQuery;
|
||||
};
|
||||
|
||||
class PeerListContent
|
||||
: public Ui::RpWidget
|
||||
, private base::Subscriber {
|
||||
class PeerListContent : public Ui::RpWidget {
|
||||
public:
|
||||
PeerListContent(
|
||||
QWidget *parent,
|
||||
|
|
|
@ -73,7 +73,6 @@ private:
|
|||
// with search + contacts search + global search.
|
||||
class AddSpecialBoxController
|
||||
: public PeerListController
|
||||
, private base::Subscriber
|
||||
, public base::has_weak_ptr {
|
||||
public:
|
||||
using Role = ParticipantsBoxController::Role;
|
||||
|
@ -146,9 +145,7 @@ protected:
|
|||
};
|
||||
|
||||
// Finds chat/channel members, then contacts, then global search results.
|
||||
class AddSpecialBoxSearchController
|
||||
: public PeerListSearchController
|
||||
, private base::Subscriber {
|
||||
class AddSpecialBoxSearchController : public PeerListSearchController {
|
||||
public:
|
||||
using Role = ParticipantsBoxController::Role;
|
||||
|
||||
|
|
|
@ -27,7 +27,6 @@ https://github.com/telegramdesktop/tdesktop/blob/master/LEGAL
|
|||
#include "history/history.h"
|
||||
#include "history/history_message.h"
|
||||
#include "history/view/history_view_schedule_box.h"
|
||||
#include "window/themes/window_theme.h"
|
||||
#include "window/window_session_controller.h"
|
||||
#include "boxes/peer_list_box.h"
|
||||
#include "chat_helpers/emoji_suggestions_widget.h"
|
||||
|
@ -42,7 +41,7 @@ https://github.com/telegramdesktop/tdesktop/blob/master/LEGAL
|
|||
#include "styles/style_boxes.h"
|
||||
#include "styles/style_chat.h"
|
||||
|
||||
class ShareBox::Inner final : public Ui::RpWidget, private base::Subscriber {
|
||||
class ShareBox::Inner final : public Ui::RpWidget {
|
||||
public:
|
||||
Inner(QWidget *parent, const Descriptor &descriptor);
|
||||
|
||||
|
@ -598,11 +597,10 @@ ShareBox::Inner::Inner(QWidget *parent, const Descriptor &descriptor)
|
|||
update();
|
||||
}, lifetime());
|
||||
|
||||
subscribe(Window::Theme::Background(), [this](const Window::Theme::BackgroundUpdate &update) {
|
||||
if (update.paletteChanged()) {
|
||||
invalidateCache();
|
||||
}
|
||||
});
|
||||
style::PaletteChanged(
|
||||
) | rpl::start_with_next([=] {
|
||||
invalidateCache();
|
||||
}, lifetime());
|
||||
}
|
||||
|
||||
void ShareBox::Inner::invalidateCache() {
|
||||
|
|
|
@ -55,7 +55,7 @@ using SetFlag = Data::StickersSetFlag;
|
|||
|
||||
} // namespace
|
||||
|
||||
class StickerSetBox::Inner : public Ui::RpWidget, private base::Subscriber {
|
||||
class StickerSetBox::Inner final : public Ui::RpWidget {
|
||||
public:
|
||||
Inner(
|
||||
QWidget *parent,
|
||||
|
|
|
@ -49,7 +49,7 @@ namespace Stickers {
|
|||
class Set;
|
||||
} // namespace Stickers
|
||||
|
||||
class StickersBox final : public Ui::BoxContent, private base::Subscriber {
|
||||
class StickersBox final : public Ui::BoxContent {
|
||||
public:
|
||||
enum class Section {
|
||||
Installed,
|
||||
|
|
|
@ -16,7 +16,7 @@ class SessionController;
|
|||
|
||||
namespace Calls {
|
||||
|
||||
class BoxController : public PeerListController, private base::Subscriber {
|
||||
class BoxController : public PeerListController {
|
||||
public:
|
||||
explicit BoxController(not_null<Window::SessionController*> window);
|
||||
|
||||
|
|
|
@ -43,7 +43,7 @@ class GroupCall;
|
|||
class Panel;
|
||||
struct DhConfig;
|
||||
|
||||
class Instance : private base::Subscriber, public base::has_weak_ptr {
|
||||
class Instance final : public base::has_weak_ptr {
|
||||
public:
|
||||
Instance();
|
||||
~Instance();
|
||||
|
|
|
@ -44,10 +44,7 @@ https://github.com/telegramdesktop/tdesktop/blob/master/LEGAL
|
|||
|
||||
#include <QtWidgets/QApplication>
|
||||
|
||||
class FieldAutocomplete::Inner final
|
||||
: public Ui::RpWidget
|
||||
, private base::Subscriber {
|
||||
|
||||
class FieldAutocomplete::Inner final : public Ui::RpWidget {
|
||||
public:
|
||||
struct ScrollTo {
|
||||
int top;
|
||||
|
|
|
@ -43,9 +43,7 @@ namespace ChatHelpers {
|
|||
|
||||
struct StickerIcon;
|
||||
|
||||
class StickersListWidget
|
||||
: public TabbedSelector::Inner
|
||||
, private base::Subscriber {
|
||||
class StickersListWidget final : public TabbedSelector::Inner {
|
||||
public:
|
||||
StickersListWidget(
|
||||
QWidget *parent,
|
||||
|
|
|
@ -51,7 +51,7 @@ class EmojiListWidget;
|
|||
class StickersListWidget;
|
||||
class GifsListWidget;
|
||||
|
||||
class TabbedSelector : public Ui::RpWidget, private base::Subscriber {
|
||||
class TabbedSelector : public Ui::RpWidget {
|
||||
public:
|
||||
struct FileChosen {
|
||||
not_null<DocumentData*> document;
|
||||
|
|
|
@ -143,7 +143,7 @@ std::map<int, const char*> BetaLogs() {
|
|||
"- Use Direct3D 9 backend in ANGLE by default (Windows).\n"
|
||||
|
||||
"- Fix \"Show in Finder\" not focusing the Finder window (macOS).\n"
|
||||
|
||||
|
||||
"- Use GTK from a child process (Linux).\n"
|
||||
},
|
||||
};
|
||||
|
|
|
@ -18,7 +18,7 @@ namespace Core {
|
|||
[[nodiscard]] QString FormatVersionDisplay(int version);
|
||||
[[nodiscard]] QString FormatVersionPrecise(int version);
|
||||
|
||||
class Changelogs : public base::has_weak_ptr, private base::Subscriber {
|
||||
class Changelogs final : public base::has_weak_ptr {
|
||||
public:
|
||||
Changelogs(not_null<Main::Session*> session, int oldVersion);
|
||||
|
||||
|
|
|
@ -10,7 +10,6 @@ https://github.com/telegramdesktop/tdesktop/blob/master/LEGAL
|
|||
#include "boxes/send_files_box.h"
|
||||
#include "ui/widgets/input_fields.h"
|
||||
#include "storage/serialize_common.h"
|
||||
#include "window/themes/window_theme.h"
|
||||
#include "window/section_widget.h"
|
||||
#include "base/platform/base_platform_info.h"
|
||||
#include "webrtc/webrtc_create_adm.h"
|
||||
|
|
|
@ -63,8 +63,7 @@ void CloudThemes::setupReload() {
|
|||
if (needReload()) {
|
||||
_reloadCurrentTimer.callOnce(kFirstReloadTimeout);
|
||||
}
|
||||
base::ObservableViewer(
|
||||
*Background()
|
||||
Background()->updates(
|
||||
) | rpl::filter([](const BackgroundUpdate &update) {
|
||||
return (update.type == BackgroundUpdate::Type::ApplyingTheme);
|
||||
}) | rpl::map([=] {
|
||||
|
|
|
@ -34,7 +34,6 @@ https://github.com/telegramdesktop/tdesktop/blob/master/LEGAL
|
|||
#include "media/audio/media_audio.h"
|
||||
#include "boxes/abstract_box.h"
|
||||
#include "passport/passport_form_controller.h"
|
||||
#include "window/themes/window_theme.h"
|
||||
#include "lang/lang_keys.h" // tr::lng_deleted(tr::now) in user name
|
||||
#include "data/stickers/data_stickers.h"
|
||||
#include "data/data_changes.h"
|
||||
|
@ -48,6 +47,7 @@ https://github.com/telegramdesktop/tdesktop/blob/master/LEGAL
|
|||
#include "data/data_photo.h"
|
||||
#include "data/data_document.h"
|
||||
#include "data/data_web_page.h"
|
||||
#include "data/data_wall_paper.h"
|
||||
#include "data/data_game.h"
|
||||
#include "data/data_poll.h"
|
||||
#include "data/data_chat_filters.h"
|
||||
|
|
|
@ -38,7 +38,6 @@ https://github.com/telegramdesktop/tdesktop/blob/master/LEGAL
|
|||
#include "mainwidget.h"
|
||||
#include "storage/storage_account.h"
|
||||
#include "apiwrap.h"
|
||||
#include "window/themes/window_theme.h"
|
||||
#include "main/main_session.h"
|
||||
#include "main/main_session_settings.h"
|
||||
#include "window/notifications_manager.h"
|
||||
|
|
|
@ -62,7 +62,7 @@ enum class WidgetState {
|
|||
Filtered,
|
||||
};
|
||||
|
||||
class InnerWidget final : public Ui::RpWidget, private base::Subscriber {
|
||||
class InnerWidget final : public Ui::RpWidget {
|
||||
Q_OBJECT
|
||||
|
||||
public:
|
||||
|
|
|
@ -45,7 +45,10 @@ inline bool operator!=(const FilterValue &a, const FilterValue &b) {
|
|||
|
||||
class Widget final : public Window::SectionWidget {
|
||||
public:
|
||||
Widget(QWidget *parent, not_null<Window::SessionController*> controller, not_null<ChannelData*> channel);
|
||||
Widget(
|
||||
QWidget *parent,
|
||||
not_null<Window::SessionController*> controller,
|
||||
not_null<ChannelData*> channel);
|
||||
|
||||
not_null<ChannelData*> channel() const;
|
||||
Dialogs::RowDescriptor activeChat() const override;
|
||||
|
|
|
@ -111,7 +111,6 @@ https://github.com/telegramdesktop/tdesktop/blob/master/LEGAL
|
|||
#include "ui/unread_badge.h"
|
||||
#include "main/main_session.h"
|
||||
#include "main/main_session_settings.h"
|
||||
#include "window/themes/window_theme.h"
|
||||
#include "window/notifications_manager.h"
|
||||
#include "window/window_adaptive.h"
|
||||
#include "window/window_controller.h"
|
||||
|
@ -304,7 +303,10 @@ HistoryWidget::HistoryWidget(
|
|||
_scroll->hide();
|
||||
_kbScroll->hide();
|
||||
|
||||
updateScrollColors();
|
||||
style::PaletteChanged(
|
||||
) | rpl::start_with_next([=] {
|
||||
_scroll->updateBars();
|
||||
}, lifetime());
|
||||
|
||||
_historyDown->installEventFilter(this);
|
||||
_unreadMentions->installEventFilter(this);
|
||||
|
@ -4698,10 +4700,6 @@ void HistoryWidget::itemEdited(not_null<HistoryItem*> item) {
|
|||
}
|
||||
}
|
||||
|
||||
void HistoryWidget::updateScrollColors() {
|
||||
_scroll->updateBars();
|
||||
}
|
||||
|
||||
MsgId HistoryWidget::replyToId() const {
|
||||
return _replyToId ? _replyToId : (_kbReplyTo ? _kbReplyTo->id : 0);
|
||||
}
|
||||
|
|
|
@ -188,8 +188,6 @@ public:
|
|||
MessageIdsList getSelectedItems() const;
|
||||
void itemEdited(not_null<HistoryItem*> item);
|
||||
|
||||
void updateScrollColors();
|
||||
|
||||
void replyToMessage(FullMsgId itemId);
|
||||
void replyToMessage(not_null<HistoryItem*> item);
|
||||
void editMessage(FullMsgId itemId);
|
||||
|
|
|
@ -43,6 +43,15 @@ enum CornerHorizontalSide {
|
|||
|
||||
class ServiceMessageStyleData : public Data::AbstractStructure {
|
||||
public:
|
||||
ServiceMessageStyleData() {
|
||||
style::PaletteChanged(
|
||||
) | rpl::start_with_next([=] {
|
||||
for (auto &corner : corners) {
|
||||
corner = QPixmap();
|
||||
}
|
||||
}, _lifetime);
|
||||
}
|
||||
|
||||
// circle[CircleMask value]
|
||||
QImage circle[2];
|
||||
|
||||
|
@ -50,6 +59,10 @@ public:
|
|||
QPixmap corners[8];
|
||||
|
||||
base::flat_map<std::pair<int, uint32>, QPixmap> overridenCorners;
|
||||
|
||||
private:
|
||||
rpl::lifetime _lifetime;
|
||||
|
||||
};
|
||||
Data::GlobalStructurePointer<ServiceMessageStyleData> serviceMessageStyle;
|
||||
|
||||
|
@ -420,14 +433,6 @@ QVector<int> ServiceMessagePainter::countLineWidths(const Ui::Text::String &text
|
|||
return lineWidths;
|
||||
}
|
||||
|
||||
void serviceColorsUpdated() {
|
||||
if (serviceMessageStyle) {
|
||||
for (auto &corner : serviceMessageStyle->corners) {
|
||||
corner = QPixmap();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Service::Service(
|
||||
not_null<ElementDelegate*> delegate,
|
||||
not_null<HistoryService*> data,
|
||||
|
|
|
@ -126,6 +126,4 @@ private:
|
|||
|
||||
};
|
||||
|
||||
void serviceColorsUpdated();
|
||||
|
||||
} // namespace HistoryView
|
||||
|
|
|
@ -35,7 +35,7 @@ namespace HistoryView {
|
|||
|
||||
class SendActionPainter;
|
||||
|
||||
class TopBarWidget : public Ui::RpWidget, private base::Subscriber {
|
||||
class TopBarWidget final : public Ui::RpWidget {
|
||||
public:
|
||||
struct SelectedState {
|
||||
bool textSelected = false;
|
||||
|
|
|
@ -16,11 +16,11 @@ https://github.com/telegramdesktop/tdesktop/blob/master/LEGAL
|
|||
#include "data/data_document_media.h"
|
||||
#include "data/data_file_click_handler.h"
|
||||
#include "data/data_file_origin.h"
|
||||
#include "data/data_wall_paper.h"
|
||||
#include "base/qthelp_url.h"
|
||||
#include "ui/text/format_values.h"
|
||||
#include "ui/cached_round_corners.h"
|
||||
#include "ui/ui_utility.h"
|
||||
#include "window/themes/window_theme.h"
|
||||
#include "layout.h" // FullSelection
|
||||
#include "styles/style_chat.h"
|
||||
|
||||
|
|
|
@ -27,7 +27,7 @@ namespace {
|
|||
constexpr auto kCommonGroupsPerPage = 40;
|
||||
constexpr auto kCommonGroupsSearchAfter = 20;
|
||||
|
||||
class ListController : public PeerListController , private base::Subscriber {
|
||||
class ListController final : public PeerListController {
|
||||
public:
|
||||
ListController(
|
||||
not_null<Controller*> controller,
|
||||
|
|
|
@ -19,7 +19,6 @@ https://github.com/telegramdesktop/tdesktop/blob/master/LEGAL
|
|||
#include "history/history.h"
|
||||
#include "history/view/history_view_cursor_state.h"
|
||||
#include "history/view/history_view_service_message.h"
|
||||
#include "window/themes/window_theme.h"
|
||||
#include "window/window_session_controller.h"
|
||||
#include "window/window_peer_menu.h"
|
||||
#include "ui/widgets/popup_menu.h"
|
||||
|
@ -626,12 +625,9 @@ Main::Session &ListWidget::session() const {
|
|||
|
||||
void ListWidget::start() {
|
||||
_controller->setSearchEnabledByContent(false);
|
||||
ObservableViewer(
|
||||
*Window::Theme::Background()
|
||||
) | rpl::start_with_next([this](const auto &update) {
|
||||
if (update.paletteChanged()) {
|
||||
invalidatePaletteCache();
|
||||
}
|
||||
style::PaletteChanged(
|
||||
) | rpl::start_with_next([=] {
|
||||
invalidatePaletteCache();
|
||||
}, lifetime());
|
||||
|
||||
session().downloaderTaskFinished(
|
||||
|
|
|
@ -32,7 +32,6 @@ https://github.com/telegramdesktop/tdesktop/blob/master/LEGAL
|
|||
#include "data/data_session.h"
|
||||
#include "data/data_chat_filters.h"
|
||||
#include "window/window_controller.h"
|
||||
#include "window/themes/window_theme.h"
|
||||
#include "styles/style_intro.h"
|
||||
#include "styles/style_window.h"
|
||||
|
||||
|
@ -75,11 +74,8 @@ Step::Step(
|
|||
? st::introCoverDescription
|
||||
: st::introDescription)) {
|
||||
hide();
|
||||
base::ObservableViewer(
|
||||
*Window::Theme::Background()
|
||||
) | rpl::filter([](const Window::Theme::BackgroundUpdate &update) {
|
||||
return update.paletteChanged();
|
||||
}) | rpl::start_with_next([=] {
|
||||
style::PaletteChanged(
|
||||
) | rpl::start_with_next([=] {
|
||||
if (!_coverMask.isNull()) {
|
||||
_coverMask = QPixmap();
|
||||
prepareCoverMask();
|
||||
|
|
|
@ -28,8 +28,6 @@ https://github.com/telegramdesktop/tdesktop/blob/master/LEGAL
|
|||
#include "data/stickers/data_stickers.h"
|
||||
#include "window/window_session_controller.h"
|
||||
#include "window/window_lock_widgets.h"
|
||||
#include "window/themes/window_theme.h"
|
||||
//#include "platform/platform_specific.h"
|
||||
#include "base/unixtime.h"
|
||||
#include "calls/calls_instance.h"
|
||||
#include "support/support_helper.h"
|
||||
|
|
|
@ -59,9 +59,7 @@ class Account;
|
|||
class Domain;
|
||||
class SessionSettings;
|
||||
|
||||
class Session final
|
||||
: public base::has_weak_ptr
|
||||
, private base::Subscriber {
|
||||
class Session final : public base::has_weak_ptr {
|
||||
public:
|
||||
Session(
|
||||
not_null<Account*> account,
|
||||
|
|
|
@ -242,7 +242,6 @@ MainWidget::MainWidget(
|
|||
, _cacheBackgroundTimer([=] { cacheBackground(); })
|
||||
, _viewsIncrementTimer([=] { viewsIncrement(); })
|
||||
, _changelogs(Core::Changelogs::Create(&controller->session())) {
|
||||
updateScrollColors();
|
||||
setupConnectingWidget();
|
||||
|
||||
connect(_dialogs, SIGNAL(cancelled()), this, SLOT(dialogsCancelled()));
|
||||
|
@ -347,11 +346,13 @@ MainWidget::MainWidget(
|
|||
QCoreApplication::instance()->installEventFilter(this);
|
||||
|
||||
using Update = Window::Theme::BackgroundUpdate;
|
||||
subscribe(Window::Theme::Background(), [this](const Update &update) {
|
||||
if (update.type == Update::Type::New || update.type == Update::Type::Changed) {
|
||||
Window::Theme::Background()->updates(
|
||||
) | rpl::start_with_next([=](const Update &update) {
|
||||
if (update.type == Update::Type::New
|
||||
|| update.type == Update::Type::Changed) {
|
||||
clearCachedBackground();
|
||||
}
|
||||
});
|
||||
}, lifetime());
|
||||
|
||||
subscribe(Media::Player::instance()->playerWidgetOver(), [this](bool over) {
|
||||
if (over) {
|
||||
|
@ -1173,10 +1174,6 @@ QPixmap MainWidget::cachedBackground(const QRect &forRect, int &x, int &y) {
|
|||
return QPixmap();
|
||||
}
|
||||
|
||||
void MainWidget::updateScrollColors() {
|
||||
_history->updateScrollColors();
|
||||
}
|
||||
|
||||
void MainWidget::setChatBackground(
|
||||
const Data::WallPaper &background,
|
||||
QImage &&image) {
|
||||
|
@ -1197,8 +1194,7 @@ void MainWidget::setChatBackground(
|
|||
checkChatBackground();
|
||||
|
||||
const auto tile = Data::IsLegacy1DefaultWallPaper(background);
|
||||
using Update = Window::Theme::BackgroundUpdate;
|
||||
Window::Theme::Background()->notify(Update(Update::Type::Start, tile));
|
||||
Window::Theme::Background()->downloadingStarted(tile);
|
||||
}
|
||||
|
||||
bool MainWidget::isReadyChatBackground(
|
||||
|
|
|
@ -190,7 +190,6 @@ public:
|
|||
void searchMessages(const QString &query, Dialogs::Key inChat);
|
||||
|
||||
QPixmap cachedBackground(const QRect &forRect, int &x, int &y);
|
||||
void updateScrollColors();
|
||||
|
||||
void setChatBackground(
|
||||
const Data::WallPaper &background,
|
||||
|
|
|
@ -98,9 +98,12 @@ MainWindow::MainWindow(not_null<Window::Controller*> controller)
|
|||
|
||||
setLocale(QLocale(QLocale::English, QLocale::UnitedStates));
|
||||
|
||||
subscribe(Window::Theme::Background(), [this](const Window::Theme::BackgroundUpdate &data) {
|
||||
using Window::Theme::BackgroundUpdate;
|
||||
Window::Theme::Background()->updates(
|
||||
) | rpl::start_with_next([=](const BackgroundUpdate &data) {
|
||||
themeUpdated(data);
|
||||
});
|
||||
}, lifetime());
|
||||
|
||||
Core::App().passcodeLockChanges(
|
||||
) | rpl::start_with_next([=] {
|
||||
updateGlobalMenu();
|
||||
|
@ -571,7 +574,7 @@ void MainWindow::themeUpdated(const Window::Theme::BackgroundUpdate &data) {
|
|||
using Type = Window::Theme::BackgroundUpdate::Type;
|
||||
|
||||
// We delay animating theme warning because we want all other
|
||||
// subscribers to receive paltte changed notification before any
|
||||
// subscribers to receive palette changed notification before any
|
||||
// animations (that include pixmap caches with old palette values).
|
||||
if (data.type == Type::TestingTheme) {
|
||||
if (!_testingThemeWarning) {
|
||||
|
|
|
@ -25,7 +25,7 @@ class SessionController;
|
|||
namespace Media {
|
||||
namespace Player {
|
||||
|
||||
class VolumeController : public Ui::RpWidget, private base::Subscriber {
|
||||
class VolumeController final : public Ui::RpWidget {
|
||||
public:
|
||||
VolumeController(
|
||||
QWidget *parent,
|
||||
|
|
|
@ -15,7 +15,7 @@ class Session;
|
|||
|
||||
namespace MTP {
|
||||
|
||||
class WeakInstance : private QObject, private base::Subscriber {
|
||||
class WeakInstance final : private QObject {
|
||||
public:
|
||||
explicit WeakInstance(base::weak_ptr<Main::Session> session);
|
||||
|
||||
|
|
|
@ -25,7 +25,6 @@ https://github.com/telegramdesktop/tdesktop/blob/master/LEGAL
|
|||
#include "window/notifications_manager_default.h"
|
||||
#include "window/window_session_controller.h"
|
||||
#include "window/window_controller.h"
|
||||
#include "window/themes/window_theme.h"
|
||||
#include "platform/mac/touchbar/mac_touchbar_manager.h"
|
||||
#include "platform/platform_specific.h"
|
||||
#include "platform/platform_notifications_manager.h"
|
||||
|
@ -451,11 +450,10 @@ MainWindow::MainWindow(not_null<Window::Controller*> controller)
|
|||
|
||||
_hideAfterFullScreenTimer.setCallback([this] { hideAndDeactivate(); });
|
||||
|
||||
subscribe(Window::Theme::Background(), [this](const Window::Theme::BackgroundUpdate &data) {
|
||||
if (data.paletteChanged()) {
|
||||
_private->updateNativeTitle();
|
||||
}
|
||||
});
|
||||
style::PaletteChanged(
|
||||
) | rpl::start_with_next([=] {
|
||||
_private->updateNativeTitle();
|
||||
}, lifetime());
|
||||
}
|
||||
|
||||
void MainWindow::closeWithoutDestroy() {
|
||||
|
|
|
@ -30,7 +30,6 @@ https://github.com/telegramdesktop/tdesktop/blob/master/LEGAL
|
|||
#include "styles/style_dialogs.h"
|
||||
#include "ui/effects/animations.h"
|
||||
#include "ui/empty_userpic.h"
|
||||
#include "window/themes/window_theme.h"
|
||||
#include "window/window_controller.h"
|
||||
#include "window/window_session_controller.h"
|
||||
|
||||
|
@ -718,11 +717,8 @@ TimeId CalculateOnlineTill(not_null<PeerData*> peer) {
|
|||
|
||||
const auto localGuard = _lifetime.make_state<base::has_weak_ptr>();
|
||||
|
||||
base::ObservableViewer(
|
||||
*Window::Theme::Background()
|
||||
) | rpl::filter([](const Window::Theme::BackgroundUpdate &update) {
|
||||
return update.paletteChanged();
|
||||
}) | rpl::start_with_next([=] {
|
||||
style::PaletteChanged(
|
||||
) | rpl::start_with_next([=] {
|
||||
crl::on_main(&(*localGuard), [=] {
|
||||
updateOnlineColor();
|
||||
if (const auto f = _session->data().folderLoaded(ArchiveId)) {
|
||||
|
|
|
@ -122,11 +122,12 @@ MainWindow::MainWindow(not_null<Window::Controller*> controller)
|
|||
if (!kTaskbarCreatedMsgId) {
|
||||
kTaskbarCreatedMsgId = RegisterWindowMessage(L"TaskbarButtonCreated");
|
||||
}
|
||||
subscribe(Window::Theme::Background(), [this](const Window::Theme::BackgroundUpdate &update) {
|
||||
if (_shadow && update.paletteChanged()) {
|
||||
style::PaletteChanged(
|
||||
) | rpl::start_with_next([=] {
|
||||
if (_shadow) {
|
||||
_shadow->setColor(st::windowShadowFg->c);
|
||||
}
|
||||
});
|
||||
}, lifetime());
|
||||
setupNativeWindowFrame();
|
||||
|
||||
using namespace rpl::mappers;
|
||||
|
@ -145,8 +146,7 @@ void MainWindow::setupNativeWindowFrame() {
|
|||
);
|
||||
|
||||
using BackgroundUpdate = Window::Theme::BackgroundUpdate;
|
||||
auto paletteChanges = base::ObservableViewer(
|
||||
*Window::Theme::Background()
|
||||
auto themeChanges = Window::Theme::Background()->updates(
|
||||
) | rpl::filter([=](const BackgroundUpdate &update) {
|
||||
return update.type == BackgroundUpdate::Type::ApplyingTheme;
|
||||
}) | rpl::to_empty;
|
||||
|
@ -154,7 +154,7 @@ void MainWindow::setupNativeWindowFrame() {
|
|||
auto nightMode = rpl::single(
|
||||
rpl::empty_value()
|
||||
) | rpl::then(
|
||||
std::move(paletteChanges)
|
||||
std::move(themeChanges)
|
||||
) | rpl::map([=] {
|
||||
return Window::Theme::IsNightMode();
|
||||
}) | rpl::distinct_until_changed();
|
||||
|
|
|
@ -15,7 +15,7 @@ class Session;
|
|||
|
||||
namespace Profile {
|
||||
|
||||
class BackButton final : public Ui::AbstractButton, private base::Subscriber {
|
||||
class BackButton final : public Ui::AbstractButton {
|
||||
public:
|
||||
BackButton(
|
||||
QWidget *parent,
|
||||
|
|
|
@ -14,7 +14,7 @@ namespace Profile {
|
|||
|
||||
class SectionMemento;
|
||||
|
||||
class BlockWidget : public Ui::RpWidget, protected base::Subscriber {
|
||||
class BlockWidget : public Ui::RpWidget {
|
||||
public:
|
||||
BlockWidget(QWidget *parent, PeerData *peer, const QString &title);
|
||||
|
||||
|
|
|
@ -424,8 +424,7 @@ BackgroundRow::BackgroundRow(
|
|||
});
|
||||
|
||||
using Update = const Window::Theme::BackgroundUpdate;
|
||||
base::ObservableViewer(
|
||||
*Window::Theme::Background()
|
||||
Window::Theme::Background()->updates(
|
||||
) | rpl::filter([](const Update &update) {
|
||||
return (update.type == Update::Type::New
|
||||
|| update.type == Update::Type::Start
|
||||
|
@ -958,8 +957,7 @@ void SetupChatBackground(
|
|||
}, tile->lifetime());
|
||||
|
||||
using Update = const Window::Theme::BackgroundUpdate;
|
||||
base::ObservableViewer(
|
||||
*Window::Theme::Background()
|
||||
Window::Theme::Background()->updates(
|
||||
) | rpl::filter([](const Update &update) {
|
||||
return (update.type == Update::Type::Changed);
|
||||
}) | rpl::map([] {
|
||||
|
@ -1089,8 +1087,7 @@ void SetupDefaultThemes(
|
|||
refreshColorizer(scheme.type);
|
||||
}
|
||||
|
||||
base::ObservableViewer(
|
||||
*Background()
|
||||
Background()->updates(
|
||||
) | rpl::filter([](const BackgroundUpdate &update) {
|
||||
return (update.type == BackgroundUpdate::Type::ApplyingTheme);
|
||||
}) | rpl::map([=] {
|
||||
|
@ -1254,9 +1251,9 @@ void SetupCloudThemes(
|
|||
editWrap->toggleOn(rpl::single(BackgroundUpdate(
|
||||
BackgroundUpdate::Type::ApplyingTheme,
|
||||
Background()->tile()
|
||||
)) | rpl::then(base::ObservableViewer(
|
||||
*Background()
|
||||
)) | rpl::filter([](const BackgroundUpdate &update) {
|
||||
)) | rpl::then(
|
||||
Background()->updates()
|
||||
) | rpl::filter([](const BackgroundUpdate &update) {
|
||||
return (update.type == BackgroundUpdate::Type::ApplyingTheme);
|
||||
}) | rpl::map([=] {
|
||||
const auto userId = controller->session().userId();
|
||||
|
|
|
@ -47,9 +47,7 @@ namespace {
|
|||
|
||||
constexpr auto kBlockedPerPage = 40;
|
||||
|
||||
class BlockPeerBoxController
|
||||
: public ChatsListBoxController
|
||||
, private base::Subscriber {
|
||||
class BlockPeerBoxController final : public ChatsListBoxController {
|
||||
public:
|
||||
explicit BlockPeerBoxController(not_null<Main::Session*> session);
|
||||
|
||||
|
|
|
@ -18,9 +18,7 @@ class SessionController;
|
|||
|
||||
namespace Settings {
|
||||
|
||||
class BlockedBoxController
|
||||
: public PeerListController
|
||||
, private base::Subscriber {
|
||||
class BlockedBoxController : public PeerListController {
|
||||
public:
|
||||
explicit BlockedBoxController(
|
||||
not_null<Window::SessionController*> window);
|
||||
|
|
|
@ -7,7 +7,6 @@ https://github.com/telegramdesktop/tdesktop/blob/master/LEGAL
|
|||
*/
|
||||
#include "ui/effects/round_checkbox.h"
|
||||
|
||||
#include "window/themes/window_theme.h"
|
||||
#include "ui/rp_widget.h"
|
||||
#include "ui/ui_utility.h"
|
||||
|
||||
|
@ -22,9 +21,12 @@ class CheckCaches : public QObject {
|
|||
public:
|
||||
CheckCaches(QObject *parent) : QObject(parent) {
|
||||
Expects(parent != nullptr);
|
||||
}
|
||||
|
||||
void clear();
|
||||
style::PaletteChanged(
|
||||
) | rpl::start_with_next([=] {
|
||||
_data.clear();
|
||||
}, _lifetime);
|
||||
}
|
||||
|
||||
QPixmap frame(
|
||||
const style::RoundCheckbox *st,
|
||||
|
@ -54,6 +56,7 @@ private:
|
|||
float64 progress);
|
||||
|
||||
std::map<const style::RoundCheckbox *, Frames> _data;
|
||||
rpl::lifetime _lifetime;
|
||||
|
||||
};
|
||||
|
||||
|
@ -134,10 +137,6 @@ QRect WideDestRect(
|
|||
return QRect(iconLeft, iconTop, iconSize, iconSize);
|
||||
}
|
||||
|
||||
void CheckCaches::clear() {
|
||||
_data.clear();
|
||||
}
|
||||
|
||||
int CheckCaches::countFramesCount(const style::RoundCheckbox *st) {
|
||||
return (st->duration / AnimationTimerDelta) + 1;
|
||||
}
|
||||
|
@ -248,13 +247,6 @@ CheckCaches *FrameCaches() {
|
|||
}
|
||||
const auto result = new CheckCaches(QCoreApplication::instance());
|
||||
Instance = result;
|
||||
const auto subscription = Ui::CreateChild<base::Subscription>(result);
|
||||
*subscription = Window::Theme::Background()->add_subscription([=](
|
||||
const Window::Theme::BackgroundUpdate &update) {
|
||||
if (update.paletteChanged()) {
|
||||
FrameCaches()->clear();
|
||||
}
|
||||
});
|
||||
return result;
|
||||
}
|
||||
|
||||
|
|
|
@ -13,7 +13,6 @@ https://github.com/telegramdesktop/tdesktop/blob/master/LEGAL
|
|||
#include "base/platform/base_platform_info.h"
|
||||
#include "ui/platform/ui_platform_utility.h"
|
||||
#include "history/history.h"
|
||||
#include "window/themes/window_theme.h"
|
||||
#include "window/window_session_controller.h"
|
||||
#include "window/window_lock_widgets.h"
|
||||
#include "window/window_outdated_bar.h"
|
||||
|
@ -165,12 +164,10 @@ MainWindow::MainWindow(not_null<Controller*> controller)
|
|||
, _outdated(CreateOutdatedBar(this))
|
||||
, _body(this)
|
||||
, _titleText(qsl("Telegram")) {
|
||||
subscribe(Theme::Background(), [=](
|
||||
const Theme::BackgroundUpdate &data) {
|
||||
if (data.paletteChanged()) {
|
||||
updatePalette();
|
||||
}
|
||||
});
|
||||
style::PaletteChanged(
|
||||
) | rpl::start_with_next([=] {
|
||||
updatePalette();
|
||||
}, lifetime());
|
||||
|
||||
Core::App().unreadBadgeChanges(
|
||||
) | rpl::start_with_next([=] {
|
||||
|
|
|
@ -37,7 +37,7 @@ QImage LoadLogoNoMargin();
|
|||
QIcon CreateIcon(Main::Session *session = nullptr);
|
||||
void ConvertIconToBlack(QImage &image);
|
||||
|
||||
class MainWindow : public Ui::RpWidget, protected base::Subscriber {
|
||||
class MainWindow : public Ui::RpWidget {
|
||||
public:
|
||||
explicit MainWindow(not_null<Controller*> controller);
|
||||
virtual ~MainWindow();
|
||||
|
|
|
@ -19,7 +19,6 @@ https://github.com/telegramdesktop/tdesktop/blob/master/LEGAL
|
|||
#include "ui/empty_userpic.h"
|
||||
#include "ui/ui_utility.h"
|
||||
#include "dialogs/dialogs_layout.h"
|
||||
#include "window/themes/window_theme.h"
|
||||
#include "window/window_controller.h"
|
||||
#include "storage/file_download.h"
|
||||
#include "main/main_session.h"
|
||||
|
@ -641,18 +640,17 @@ Notification::Notification(
|
|||
|
||||
prepareActionsCache();
|
||||
|
||||
subscribe(Window::Theme::Background(), [this](const Window::Theme::BackgroundUpdate &data) {
|
||||
if (data.paletteChanged()) {
|
||||
updateNotifyDisplay();
|
||||
if (!_buttonsCache.isNull()) {
|
||||
prepareActionsCache();
|
||||
}
|
||||
update();
|
||||
if (_background) {
|
||||
_background->update();
|
||||
}
|
||||
style::PaletteChanged(
|
||||
) | rpl::start_with_next([=] {
|
||||
updateNotifyDisplay();
|
||||
if (!_buttonsCache.isNull()) {
|
||||
prepareActionsCache();
|
||||
}
|
||||
});
|
||||
update();
|
||||
if (_background) {
|
||||
_background->update();
|
||||
}
|
||||
}, lifetime());
|
||||
|
||||
show();
|
||||
}
|
||||
|
@ -1077,11 +1075,10 @@ HideAllButton::HideAllButton(
|
|||
hide();
|
||||
createWinId();
|
||||
|
||||
subscribe(Window::Theme::Background(), [this](const Window::Theme::BackgroundUpdate &data) {
|
||||
if (data.paletteChanged()) {
|
||||
update();
|
||||
}
|
||||
});
|
||||
style::PaletteChanged(
|
||||
) | rpl::start_with_next([=] {
|
||||
update();
|
||||
}, lifetime());
|
||||
|
||||
show();
|
||||
}
|
||||
|
|
|
@ -132,7 +132,7 @@ private:
|
|||
|
||||
namespace internal {
|
||||
|
||||
class Widget : public Ui::RpWidget, protected base::Subscriber {
|
||||
class Widget : public Ui::RpWidget {
|
||||
public:
|
||||
enum class Direction {
|
||||
Up,
|
||||
|
|
|
@ -551,11 +551,12 @@ void ChatBackground::initialRead() {
|
|||
void ChatBackground::start() {
|
||||
saveAdjustableColors();
|
||||
|
||||
subscribe(this, [=](const BackgroundUpdate &update) {
|
||||
_updates.events(
|
||||
) | rpl::start_with_next([=](const BackgroundUpdate &update) {
|
||||
if (update.paletteChanged()) {
|
||||
style::NotifyPaletteChanged();
|
||||
}
|
||||
});
|
||||
}, _lifetime);
|
||||
|
||||
initialRead();
|
||||
|
||||
|
@ -620,7 +621,7 @@ void ChatBackground::checkUploadWallPaper() {
|
|||
if (const auto paper = Data::WallPaper::Create(_session, result)) {
|
||||
setPaper(*paper);
|
||||
writeNewBackgroundSettings();
|
||||
notify(BackgroundUpdate(BackgroundUpdate::Type::New, tile()));
|
||||
_updates.fire({ BackgroundUpdate::Type::New, tile() });
|
||||
}
|
||||
}).send();
|
||||
});
|
||||
|
@ -705,10 +706,10 @@ void ChatBackground::set(const Data::WallPaper &paper, QImage image) {
|
|||
&& !_pixmap.isNull()
|
||||
&& !_pixmapForTiled.isNull()));
|
||||
|
||||
notify(BackgroundUpdate(BackgroundUpdate::Type::New, tile()));
|
||||
_updates.fire({ BackgroundUpdate::Type::New, tile() }); // delayed?
|
||||
if (needResetAdjustable) {
|
||||
notify(BackgroundUpdate(BackgroundUpdate::Type::TestingTheme, tile()), true);
|
||||
notify(BackgroundUpdate(BackgroundUpdate::Type::ApplyingTheme, tile()), true);
|
||||
_updates.fire({ BackgroundUpdate::Type::TestingTheme, tile() });
|
||||
_updates.fire({ BackgroundUpdate::Type::ApplyingTheme, tile() });
|
||||
}
|
||||
checkUploadWallPaper();
|
||||
}
|
||||
|
@ -883,7 +884,7 @@ void ChatBackground::setTile(bool tile) {
|
|||
&& !Data::details::IsTestingDefaultWallPaper(_paper)) {
|
||||
Local::writeSettings();
|
||||
}
|
||||
notify(BackgroundUpdate(BackgroundUpdate::Type::Changed, tile));
|
||||
_updates.fire({ BackgroundUpdate::Type::Changed, tile }); // delayed?
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -927,8 +928,8 @@ void ChatBackground::reset() {
|
|||
} else {
|
||||
set(Data::ThemeWallPaper());
|
||||
restoreAdjustableColors();
|
||||
notify(BackgroundUpdate(BackgroundUpdate::Type::TestingTheme, tile()), true);
|
||||
notify(BackgroundUpdate(BackgroundUpdate::Type::ApplyingTheme, tile()), true);
|
||||
_updates.fire({ BackgroundUpdate::Type::TestingTheme, tile() });
|
||||
_updates.fire({ BackgroundUpdate::Type::ApplyingTheme, tile() });
|
||||
}
|
||||
writeNewBackgroundSettings();
|
||||
}
|
||||
|
@ -990,7 +991,7 @@ void ChatBackground::setTestingTheme(Instance &&theme) {
|
|||
// Apply current background image so that service bg colors are recounted.
|
||||
set(_paper, std::move(_original));
|
||||
}
|
||||
notify(BackgroundUpdate(BackgroundUpdate::Type::TestingTheme, tile()), true);
|
||||
_updates.fire({ BackgroundUpdate::Type::TestingTheme, tile() });
|
||||
}
|
||||
|
||||
void ChatBackground::setTestingDefaultTheme() {
|
||||
|
@ -1000,7 +1001,7 @@ void ChatBackground::setTestingDefaultTheme() {
|
|||
saveForRevert();
|
||||
set(Data::details::TestingDefaultWallPaper());
|
||||
setTile(false);
|
||||
notify(BackgroundUpdate(BackgroundUpdate::Type::TestingTheme, tile()), true);
|
||||
_updates.fire({ BackgroundUpdate::Type::TestingTheme, tile() });
|
||||
}
|
||||
|
||||
void ChatBackground::keepApplied(const Object &object, bool write) {
|
||||
|
@ -1027,7 +1028,7 @@ void ChatBackground::keepApplied(const Object &object, bool write) {
|
|||
writeNewBackgroundSettings();
|
||||
}
|
||||
}
|
||||
notify(BackgroundUpdate(BackgroundUpdate::Type::ApplyingTheme, tile()), true);
|
||||
_updates.fire({ BackgroundUpdate::Type::ApplyingTheme, tile() });
|
||||
}
|
||||
|
||||
bool ChatBackground::isNonDefaultThemeOrBackground() {
|
||||
|
@ -1068,7 +1069,15 @@ void ChatBackground::revert() {
|
|||
// Apply current background image so that service bg colors are recounted.
|
||||
set(_paper, std::move(_original));
|
||||
}
|
||||
notify(BackgroundUpdate(BackgroundUpdate::Type::RevertingTheme, tile()), true);
|
||||
_updates.fire({ BackgroundUpdate::Type::RevertingTheme, tile() });
|
||||
}
|
||||
|
||||
void ChatBackground::appliedEditedPalette() {
|
||||
_updates.fire({ BackgroundUpdate::Type::ApplyingEdit, tile() });
|
||||
}
|
||||
|
||||
void ChatBackground::downloadingStarted(bool tile) {
|
||||
_updates.fire({ BackgroundUpdate::Type::Start, tile });
|
||||
}
|
||||
|
||||
void ChatBackground::setNightModeValue(bool nightMode) {
|
||||
|
@ -1225,7 +1234,7 @@ bool ApplyEditedPalette(const QByteArray &content) {
|
|||
return false;
|
||||
}
|
||||
style::main_palette::apply(out.palette);
|
||||
Background()->notify(BackgroundUpdate(BackgroundUpdate::Type::ApplyingEdit, Background()->tile()), true);
|
||||
Background()->appliedEditedPalette();
|
||||
return true;
|
||||
}
|
||||
|
||||
|
|
|
@ -131,12 +131,14 @@ enum class ClearEditing {
|
|||
KeepChanges,
|
||||
};
|
||||
|
||||
class ChatBackground
|
||||
: public base::Observable<BackgroundUpdate>
|
||||
, private base::Subscriber {
|
||||
class ChatBackground final {
|
||||
public:
|
||||
ChatBackground();
|
||||
|
||||
[[nodiscard]] rpl::producer<BackgroundUpdate> updates() const {
|
||||
return _updates.events();
|
||||
}
|
||||
|
||||
void start();
|
||||
|
||||
// This method is allowed to (and should) be called before start().
|
||||
|
@ -159,6 +161,9 @@ public:
|
|||
void setTestingDefaultTheme();
|
||||
void revert();
|
||||
|
||||
void appliedEditedPalette();
|
||||
void downloadingStarted(bool tile);
|
||||
|
||||
[[nodiscard]] Data::WallPaper paper() const {
|
||||
return _paper;
|
||||
}
|
||||
|
@ -227,6 +232,7 @@ private:
|
|||
friend bool IsNonDefaultBackground();
|
||||
|
||||
Main::Session *_session = nullptr;
|
||||
rpl::event_stream<BackgroundUpdate> _updates;
|
||||
Data::WallPaper _paper = Data::details::UninitializedWallPaper();
|
||||
std::optional<QColor> _paperColor;
|
||||
QImage _original;
|
||||
|
@ -259,7 +265,7 @@ private:
|
|||
|
||||
};
|
||||
|
||||
ChatBackground *Background();
|
||||
[[nodiscard]] ChatBackground *Background();
|
||||
|
||||
void ComputeBackgroundRects(QRect wholeFill, QSize imageSize, QRect &to, QRect &from);
|
||||
|
||||
|
|
|
@ -197,7 +197,7 @@ QString bytesToUtf8(QLatin1String bytes) {
|
|||
|
||||
} // namespace
|
||||
|
||||
class Editor::Inner : public TWidget, private base::Subscriber {
|
||||
class Editor::Inner : public Ui::RpWidget, private base::Subscriber {
|
||||
public:
|
||||
Inner(QWidget *parent, const QString &path);
|
||||
|
||||
|
@ -387,7 +387,8 @@ QByteArray StripCloudTextFields(const QByteArray &text) {
|
|||
return (start > 0) ? text.mid(start) : text;
|
||||
}
|
||||
|
||||
Editor::Inner::Inner(QWidget *parent, const QString &path) : TWidget(parent)
|
||||
Editor::Inner::Inner(QWidget *parent, const QString &path)
|
||||
: RpWidget(parent)
|
||||
, _path(path)
|
||||
, _existingRows(this, EditorBlock::Type::Existing, &_context)
|
||||
, _newRows(this, EditorBlock::Type::New, &_context) {
|
||||
|
@ -410,7 +411,8 @@ Editor::Inner::Inner(QWidget *parent, const QString &path) : TWidget(parent)
|
|||
_scrollCallback(top, top + data.height);
|
||||
}
|
||||
});
|
||||
subscribe(Background(), [this](const BackgroundUpdate &update) {
|
||||
Background()->updates(
|
||||
) | rpl::start_with_next([=](const BackgroundUpdate &update) {
|
||||
if (_applyingUpdate || !Background()->editingTheme()) {
|
||||
return;
|
||||
}
|
||||
|
@ -422,7 +424,7 @@ Editor::Inner::Inner(QWidget *parent, const QString &path) : TWidget(parent)
|
|||
tr::lng_theme_editor_cant_change_theme(tr::now)));
|
||||
});
|
||||
}
|
||||
});
|
||||
}, lifetime());
|
||||
}
|
||||
|
||||
void Editor::Inner::recreateRows() {
|
||||
|
|
|
@ -7,7 +7,6 @@ https://github.com/telegramdesktop/tdesktop/blob/master/LEGAL
|
|||
*/
|
||||
#include "window/themes/window_theme_preview.h"
|
||||
|
||||
#include "window/themes/window_theme.h"
|
||||
#include "lang/lang_keys.h"
|
||||
#include "platform/platform_window_title.h"
|
||||
#include "ui/text/text_options.h"
|
||||
|
|
|
@ -30,8 +30,8 @@ WarningWidget::WarningWidget(QWidget *parent)
|
|||
, _secondsLeft(kWaitBeforeRevertMs / 1000)
|
||||
, _keepChanges(this, tr::lng_theme_keep_changes(), st::defaultBoxButton)
|
||||
, _revert(this, tr::lng_theme_revert(), st::defaultBoxButton) {
|
||||
_keepChanges->setClickedCallback([] { Window::Theme::KeepApplied(); });
|
||||
_revert->setClickedCallback([] { Window::Theme::Revert(); });
|
||||
_keepChanges->setClickedCallback([] { KeepApplied(); });
|
||||
_revert->setClickedCallback([] { Revert(); });
|
||||
updateText();
|
||||
}
|
||||
|
||||
|
|
|
@ -340,9 +340,9 @@ void CloudList::setup() {
|
|||
auto themeChanges = rpl::single(BackgroundUpdate(
|
||||
BackgroundUpdate::Type::ApplyingTheme,
|
||||
Background()->tile()
|
||||
)) | rpl::then(base::ObservableViewer(
|
||||
*Background()
|
||||
)) | rpl::filter([](const BackgroundUpdate &update) {
|
||||
)) | rpl::then(
|
||||
Background()->updates()
|
||||
) | rpl::filter([](const BackgroundUpdate &update) {
|
||||
return (update.type == BackgroundUpdate::Type::ApplyingTheme);
|
||||
});
|
||||
|
||||
|
|
|
@ -16,7 +16,6 @@ https://github.com/telegramdesktop/tdesktop/blob/master/LEGAL
|
|||
#include "core/application.h"
|
||||
#include "core/core_settings.h"
|
||||
#include "core/update_checker.h"
|
||||
#include "window/themes/window_theme.h"
|
||||
#include "boxes/connection_box.h"
|
||||
#include "boxes/abstract_box.h"
|
||||
#include "lang/lang_keys.h"
|
||||
|
@ -112,9 +111,7 @@ private:
|
|||
|
||||
};
|
||||
|
||||
class ConnectionState::Widget::ProxyIcon
|
||||
: public Ui::RpWidget
|
||||
, private base::Subscriber {
|
||||
class ConnectionState::Widget::ProxyIcon final : public Ui::RpWidget {
|
||||
public:
|
||||
ProxyIcon(QWidget *parent);
|
||||
|
||||
|
@ -143,12 +140,10 @@ ConnectionState::Widget::ProxyIcon::ProxyIcon(QWidget *parent) : RpWidget(parent
|
|||
st::connectingRadial.size.height(),
|
||||
st::connectingProxyOn.height()));
|
||||
|
||||
using namespace Window::Theme;
|
||||
subscribe(Background(), [=](const BackgroundUpdate &update) {
|
||||
if (update.paletteChanged()) {
|
||||
refreshCacheImages();
|
||||
}
|
||||
});
|
||||
style::PaletteChanged(
|
||||
) | rpl::start_with_next([=] {
|
||||
refreshCacheImages();
|
||||
}, lifetime());
|
||||
|
||||
refreshCacheImages();
|
||||
}
|
||||
|
|
|
@ -138,9 +138,7 @@ void ShowCallsBox(not_null<Window::SessionController*> window) {
|
|||
|
||||
namespace Window {
|
||||
|
||||
class MainMenu::AccountButton final
|
||||
: public Ui::RippleButton
|
||||
, public base::Subscriber {
|
||||
class MainMenu::AccountButton final : public Ui::RippleButton {
|
||||
public:
|
||||
AccountButton(QWidget *parent, not_null<Main::Account*> account);
|
||||
|
||||
|
@ -209,12 +207,10 @@ MainMenu::AccountButton::AccountButton(
|
|||
+ _st.itemPadding.bottom();
|
||||
resize(width(), height);
|
||||
|
||||
subscribe(Window::Theme::Background(), [=](
|
||||
const Window::Theme::BackgroundUpdate &update) {
|
||||
if (update.paletteChanged()) {
|
||||
_userpicKey = {};
|
||||
}
|
||||
});
|
||||
style::PaletteChanged(
|
||||
) | rpl::start_with_next([=] {
|
||||
_userpicKey = {};
|
||||
}, lifetime());
|
||||
|
||||
rpl::single(
|
||||
rpl::empty_value()
|
||||
|
@ -639,8 +635,10 @@ MainMenu::MainMenu(
|
|||
refreshMenu();
|
||||
}, lifetime());
|
||||
|
||||
subscribe(Window::Theme::Background(), [this](const Window::Theme::BackgroundUpdate &update) {
|
||||
if (update.type == Window::Theme::BackgroundUpdate::Type::ApplyingTheme) {
|
||||
using Window::Theme::BackgroundUpdate;
|
||||
Window::Theme::Background()->updates(
|
||||
) | rpl::start_with_next([=](const BackgroundUpdate &update) {
|
||||
if (update.type == BackgroundUpdate::Type::ApplyingTheme) {
|
||||
if (const auto action = *_nightThemeAction) {
|
||||
const auto nightMode = Window::Theme::IsNightMode();
|
||||
if (action->isChecked() != nightMode) {
|
||||
|
@ -649,10 +647,10 @@ MainMenu::MainMenu(
|
|||
}
|
||||
}
|
||||
}
|
||||
if (update.type == Window::Theme::BackgroundUpdate::Type::New) {
|
||||
if (update.type == BackgroundUpdate::Type::New) {
|
||||
refreshBackground();
|
||||
}
|
||||
});
|
||||
}, lifetime());
|
||||
updatePhone();
|
||||
initResetScaleButton();
|
||||
}
|
||||
|
|
|
@ -37,7 +37,7 @@ namespace Window {
|
|||
|
||||
class SessionController;
|
||||
|
||||
class MainMenu : public Ui::LayerWidget, private base::Subscriber {
|
||||
class MainMenu final : public Ui::LayerWidget {
|
||||
public:
|
||||
MainMenu(QWidget *parent, not_null<SessionController*> controller);
|
||||
|
||||
|
|
|
@ -25,7 +25,7 @@ namespace Window {
|
|||
|
||||
class SessionController;
|
||||
|
||||
class MediaPreviewWidget : public Ui::RpWidget, private base::Subscriber {
|
||||
class MediaPreviewWidget final : public Ui::RpWidget {
|
||||
public:
|
||||
MediaPreviewWidget(
|
||||
QWidget *parent,
|
||||
|
|
Loading…
Add table
Reference in a new issue