Remove base::Observable / base::Variable.
This commit is contained in:
parent
73e2cc96d1
commit
644ec1f599
22 changed files with 112 additions and 108 deletions
|
@ -829,10 +829,6 @@ rpl::producer<bool> Application::appDeactivatedValue() const {
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
void Application::call_handleObservables() {
|
|
||||||
base::HandleObservables();
|
|
||||||
}
|
|
||||||
|
|
||||||
void Application::switchDebugMode() {
|
void Application::switchDebugMode() {
|
||||||
if (Logs::DebugEnabled()) {
|
if (Logs::DebugEnabled()) {
|
||||||
Logs::SetDebugEnabled(false);
|
Logs::SetDebugEnabled(false);
|
||||||
|
|
|
@ -297,8 +297,6 @@ public:
|
||||||
|
|
||||||
void preventOrInvoke(Fn<void()> &&callback);
|
void preventOrInvoke(Fn<void()> &&callback);
|
||||||
|
|
||||||
void call_handleObservables();
|
|
||||||
|
|
||||||
// Global runtime variables.
|
// Global runtime variables.
|
||||||
void setScreenIsLocked(bool locked);
|
void setScreenIsLocked(bool locked);
|
||||||
bool screenIsLocked() const;
|
bool screenIsLocked() const;
|
||||||
|
|
|
@ -85,11 +85,6 @@ Sandbox::Sandbox(
|
||||||
char **argv)
|
char **argv)
|
||||||
: QApplication(argc, argv)
|
: QApplication(argc, argv)
|
||||||
, _mainThreadId(QThread::currentThreadId())
|
, _mainThreadId(QThread::currentThreadId())
|
||||||
, _handleObservables([=] {
|
|
||||||
if (_application) {
|
|
||||||
_application->call_handleObservables();
|
|
||||||
}
|
|
||||||
})
|
|
||||||
, _launcher(launcher) {
|
, _launcher(launcher) {
|
||||||
setQuitOnLastWindowClosed(false);
|
setQuitOnLastWindowClosed(false);
|
||||||
}
|
}
|
||||||
|
@ -201,10 +196,6 @@ void Sandbox::launchApplication() {
|
||||||
}
|
}
|
||||||
setupScreenScale();
|
setupScreenScale();
|
||||||
|
|
||||||
base::InitObservables([] {
|
|
||||||
Instance()._handleObservables.call();
|
|
||||||
});
|
|
||||||
|
|
||||||
_application = std::make_unique<Application>(_launcher);
|
_application = std::make_unique<Application>(_launcher);
|
||||||
|
|
||||||
// Ideally this should go to constructor.
|
// Ideally this should go to constructor.
|
||||||
|
|
|
@ -112,7 +112,6 @@ private:
|
||||||
int _loopNestingLevel = 0;
|
int _loopNestingLevel = 0;
|
||||||
std::vector<int> _previousLoopNestingLevels;
|
std::vector<int> _previousLoopNestingLevels;
|
||||||
std::vector<PostponedCall> _postponedCalls;
|
std::vector<PostponedCall> _postponedCalls;
|
||||||
SingleQueuedInvokation _handleObservables;
|
|
||||||
|
|
||||||
not_null<Launcher*> _launcher;
|
not_null<Launcher*> _launcher;
|
||||||
std::unique_ptr<Application> _application;
|
std::unique_ptr<Application> _application;
|
||||||
|
|
|
@ -2508,9 +2508,8 @@ void InnerWidget::refresh(bool toTop) {
|
||||||
_mustScrollTo.fire({ 0, 0 });
|
_mustScrollTo.fire({ 0, 0 });
|
||||||
loadPeerPhotos();
|
loadPeerPhotos();
|
||||||
}
|
}
|
||||||
_controller->dialogsListDisplayForced().set(
|
_controller->setDialogsListDisplayForced(
|
||||||
_searchInChat || !_filter.isEmpty(),
|
_searchInChat || !_filter.isEmpty());
|
||||||
true);
|
|
||||||
update();
|
update();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -2648,9 +2647,8 @@ void InnerWidget::searchInChat(Key key, PeerData *from) {
|
||||||
}
|
}
|
||||||
moveCancelSearchButtons();
|
moveCancelSearchButtons();
|
||||||
|
|
||||||
_controller->dialogsListDisplayForced().set(
|
_controller->setDialogsListDisplayForced(
|
||||||
_searchInChat || !_filter.isEmpty(),
|
_searchInChat || !_filter.isEmpty());
|
||||||
true);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void InnerWidget::refreshSearchInChatLabel() {
|
void InnerWidget::refreshSearchInChatLabel() {
|
||||||
|
|
|
@ -294,12 +294,13 @@ MainWidget::MainWidget(
|
||||||
_player->finishAnimating();
|
_player->finishAnimating();
|
||||||
}
|
}
|
||||||
|
|
||||||
subscribe(_controller->dialogsListFocused(), [this](bool) {
|
rpl::merge(
|
||||||
|
_controller->dialogsListFocusedChanges(),
|
||||||
|
_controller->dialogsListDisplayForcedChanges()
|
||||||
|
) | rpl::start_with_next([=] {
|
||||||
updateDialogsWidthAnimated();
|
updateDialogsWidthAnimated();
|
||||||
});
|
}, lifetime());
|
||||||
subscribe(_controller->dialogsListDisplayForced(), [this](bool) {
|
|
||||||
updateDialogsWidthAnimated();
|
|
||||||
});
|
|
||||||
rpl::merge(
|
rpl::merge(
|
||||||
Core::App().settings().dialogsWidthRatioChanges() | rpl::to_empty,
|
Core::App().settings().dialogsWidthRatioChanges() | rpl::to_empty,
|
||||||
Core::App().settings().thirdColumnWidthChanges() | rpl::to_empty
|
Core::App().settings().thirdColumnWidthChanges() | rpl::to_empty
|
||||||
|
@ -1396,7 +1397,7 @@ void MainWidget::ui_showPeerHistory(
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
_controller->dialogsListFocused().set(false, true);
|
_controller->setDialogsListFocused(false);
|
||||||
_a_dialogsWidth.stop();
|
_a_dialogsWidth.stop();
|
||||||
|
|
||||||
using Way = SectionShow::Way;
|
using Way = SectionShow::Way;
|
||||||
|
@ -1751,7 +1752,7 @@ void MainWidget::showNewSection(
|
||||||
controller()->window().hideSettingsAndLayer();
|
controller()->window().hideSettingsAndLayer();
|
||||||
}
|
}
|
||||||
|
|
||||||
_controller->dialogsListFocused().set(false, true);
|
_controller->setDialogsListFocused(false);
|
||||||
_a_dialogsWidth.stop();
|
_a_dialogsWidth.stop();
|
||||||
|
|
||||||
auto mainSectionTop = getMainSectionTop();
|
auto mainSectionTop = getMainSectionTop();
|
||||||
|
@ -2619,10 +2620,10 @@ bool MainWidget::eventFilter(QObject *o, QEvent *e) {
|
||||||
if (_history == widget || _history->isAncestorOf(widget)
|
if (_history == widget || _history->isAncestorOf(widget)
|
||||||
|| (_mainSection && (_mainSection == widget || _mainSection->isAncestorOf(widget)))
|
|| (_mainSection && (_mainSection == widget || _mainSection->isAncestorOf(widget)))
|
||||||
|| (_thirdSection && (_thirdSection == widget || _thirdSection->isAncestorOf(widget)))) {
|
|| (_thirdSection && (_thirdSection == widget || _thirdSection->isAncestorOf(widget)))) {
|
||||||
_controller->dialogsListFocused().set(false);
|
_controller->setDialogsListFocused(false);
|
||||||
} else if (_dialogs
|
} else if (_dialogs
|
||||||
&& (_dialogs == widget || _dialogs->isAncestorOf(widget))) {
|
&& (_dialogs == widget || _dialogs->isAncestorOf(widget))) {
|
||||||
_controller->dialogsListFocused().set(true);
|
_controller->setDialogsListFocused(true);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
} else if (e->type() == QEvent::MouseButtonPress) {
|
} else if (e->type() == QEvent::MouseButtonPress) {
|
||||||
|
|
|
@ -113,8 +113,7 @@ class ItemBase;
|
||||||
|
|
||||||
class MainWidget
|
class MainWidget
|
||||||
: public Ui::RpWidget
|
: public Ui::RpWidget
|
||||||
, private Media::Player::FloatDelegate
|
, private Media::Player::FloatDelegate {
|
||||||
, private base::Subscriber {
|
|
||||||
public:
|
public:
|
||||||
using SectionShow = Window::SectionShow;
|
using SectionShow = Window::SectionShow;
|
||||||
|
|
||||||
|
|
|
@ -305,12 +305,12 @@ constexpr auto kCheckPlaybackPositionTimeout = crl::time(100); // 100ms per chec
|
||||||
constexpr auto kCheckPlaybackPositionDelta = 2400LL; // update position called each 2400 samples
|
constexpr auto kCheckPlaybackPositionDelta = 2400LL; // update position called each 2400 samples
|
||||||
constexpr auto kCheckFadingTimeout = crl::time(7); // 7ms
|
constexpr auto kCheckFadingTimeout = crl::time(7); // 7ms
|
||||||
|
|
||||||
base::Observable<AudioMsgId> UpdatedObservable;
|
rpl::event_stream<AudioMsgId> UpdatedStream;
|
||||||
|
|
||||||
} // namespace
|
} // namespace
|
||||||
|
|
||||||
base::Observable<AudioMsgId> &Updated() {
|
rpl::producer<AudioMsgId> Updated() {
|
||||||
return UpdatedObservable;
|
return UpdatedStream.events();
|
||||||
}
|
}
|
||||||
|
|
||||||
// Thread: Any. Must be locked: AudioMutex.
|
// Thread: Any. Must be locked: AudioMutex.
|
||||||
|
@ -648,7 +648,11 @@ void Mixer::onUpdated(const AudioMsgId &audio) {
|
||||||
if (audio.externalPlayId()) {
|
if (audio.externalPlayId()) {
|
||||||
externalSoundProgress(audio);
|
externalSoundProgress(audio);
|
||||||
}
|
}
|
||||||
Media::Player::Updated().notify(audio);
|
crl::on_main([=] {
|
||||||
|
// We've replaced base::Observable with on_main, because
|
||||||
|
// base::Observable::notify is not syncronous by default.
|
||||||
|
UpdatedStream.fire_copy(audio);
|
||||||
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
// Thread: Any. Must be locked: AudioMutex.
|
// Thread: Any. Must be locked: AudioMutex.
|
||||||
|
|
|
@ -12,7 +12,6 @@ https://github.com/telegramdesktop/tdesktop/blob/master/LEGAL
|
||||||
#include "core/file_location.h"
|
#include "core/file_location.h"
|
||||||
#include "data/data_audio_msg_id.h"
|
#include "data/data_audio_msg_id.h"
|
||||||
#include "base/bytes.h"
|
#include "base/bytes.h"
|
||||||
#include "base/observer.h"
|
|
||||||
#include "base/timer.h"
|
#include "base/timer.h"
|
||||||
|
|
||||||
#include <QtCore/QTimer>
|
#include <QtCore/QTimer>
|
||||||
|
@ -60,7 +59,7 @@ constexpr auto kWaveformSamplesCount = 100;
|
||||||
class Fader;
|
class Fader;
|
||||||
class Loaders;
|
class Loaders;
|
||||||
|
|
||||||
base::Observable<AudioMsgId> &Updated();
|
[[nodiscard]] rpl::producer<AudioMsgId> Updated();
|
||||||
|
|
||||||
float64 ComputeVolume(AudioMsgId::Type type);
|
float64 ComputeVolume(AudioMsgId::Type type);
|
||||||
|
|
||||||
|
|
|
@ -11,7 +11,6 @@ https://github.com/telegramdesktop/tdesktop/blob/master/LEGAL
|
||||||
#include "ui/rect_part.h"
|
#include "ui/rect_part.h"
|
||||||
#include "ui/effects/animations.h"
|
#include "ui/effects/animations.h"
|
||||||
#include "base/object_ptr.h"
|
#include "base/object_ptr.h"
|
||||||
#include "base/observer.h"
|
|
||||||
|
|
||||||
namespace Window {
|
namespace Window {
|
||||||
class SessionController;
|
class SessionController;
|
||||||
|
@ -48,7 +47,7 @@ private:
|
||||||
|
|
||||||
};
|
};
|
||||||
|
|
||||||
class Float : public Ui::RpWidget, private base::Subscriber {
|
class Float final : public Ui::RpWidget {
|
||||||
public:
|
public:
|
||||||
Float(
|
Float(
|
||||||
QWidget *parent,
|
QWidget *parent,
|
||||||
|
@ -210,12 +209,13 @@ private:
|
||||||
|
|
||||||
};
|
};
|
||||||
|
|
||||||
class FloatController : private base::Subscriber {
|
class FloatController final {
|
||||||
public:
|
public:
|
||||||
explicit FloatController(not_null<FloatDelegate*> delegate);
|
explicit FloatController(not_null<FloatDelegate*> delegate);
|
||||||
|
|
||||||
void replaceDelegate(not_null<FloatDelegate*> delegate);
|
void replaceDelegate(not_null<FloatDelegate*> delegate);
|
||||||
rpl::producer<FullMsgId> closeEvents() const {
|
|
||||||
|
[[nodiscard]] rpl::producer<FullMsgId> closeEvents() const {
|
||||||
return _closeEvents.events();
|
return _closeEvents.events();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -146,9 +146,10 @@ Instance::Data::~Data() = default;
|
||||||
Instance::Instance()
|
Instance::Instance()
|
||||||
: _songData(AudioMsgId::Type::Song, SharedMediaType::MusicFile)
|
: _songData(AudioMsgId::Type::Song, SharedMediaType::MusicFile)
|
||||||
, _voiceData(AudioMsgId::Type::Voice, SharedMediaType::RoundVoiceFile) {
|
, _voiceData(AudioMsgId::Type::Voice, SharedMediaType::RoundVoiceFile) {
|
||||||
subscribe(Media::Player::Updated(), [this](const AudioMsgId &audioId) {
|
Media::Player::Updated(
|
||||||
|
) | rpl::start_with_next([=](const AudioMsgId &audioId) {
|
||||||
handleSongUpdate(audioId);
|
handleSongUpdate(audioId);
|
||||||
});
|
}, _lifetime);
|
||||||
|
|
||||||
repeatChanges(
|
repeatChanges(
|
||||||
&_songData
|
&_songData
|
||||||
|
@ -157,6 +158,7 @@ Instance::Instance()
|
||||||
refreshPlaylist(&_songData);
|
refreshPlaylist(&_songData);
|
||||||
}
|
}
|
||||||
}, _lifetime);
|
}, _lifetime);
|
||||||
|
|
||||||
orderChanges(
|
orderChanges(
|
||||||
&_songData
|
&_songData
|
||||||
) | rpl::start_with_next([=](OrderMode mode) {
|
) | rpl::start_with_next([=](OrderMode mode) {
|
||||||
|
|
|
@ -7,7 +7,6 @@ https://github.com/telegramdesktop/tdesktop/blob/master/LEGAL
|
||||||
*/
|
*/
|
||||||
#pragma once
|
#pragma once
|
||||||
|
|
||||||
#include "base/observer.h"
|
|
||||||
#include "data/data_audio_msg_id.h"
|
#include "data/data_audio_msg_id.h"
|
||||||
#include "data/data_shared_media.h"
|
#include "data/data_shared_media.h"
|
||||||
|
|
||||||
|
@ -70,7 +69,7 @@ void SaveLastPlaybackPosition(
|
||||||
|
|
||||||
not_null<Instance*> instance();
|
not_null<Instance*> instance();
|
||||||
|
|
||||||
class Instance : private base::Subscriber {
|
class Instance final {
|
||||||
public:
|
public:
|
||||||
enum class Seeking {
|
enum class Seeking {
|
||||||
Start,
|
Start,
|
||||||
|
|
|
@ -198,7 +198,7 @@ rpl::producer<crl::time> AudioTrack::playPosition() {
|
||||||
|
|
||||||
if (!_subscription) {
|
if (!_subscription) {
|
||||||
_subscription = Media::Player::Updated(
|
_subscription = Media::Player::Updated(
|
||||||
).add_subscription([=](const AudioMsgId &id) {
|
) | rpl::start_with_next([=](const AudioMsgId &id) {
|
||||||
using State = Media::Player::State;
|
using State = Media::Player::State;
|
||||||
if (id != _audioId) {
|
if (id != _audioId) {
|
||||||
return;
|
return;
|
||||||
|
|
|
@ -7,7 +7,6 @@ https://github.com/telegramdesktop/tdesktop/blob/master/LEGAL
|
||||||
*/
|
*/
|
||||||
#pragma once
|
#pragma once
|
||||||
|
|
||||||
#include "base/observer.h"
|
|
||||||
#include "media/streaming/media_streaming_utility.h"
|
#include "media/streaming/media_streaming_utility.h"
|
||||||
|
|
||||||
namespace Media {
|
namespace Media {
|
||||||
|
@ -80,7 +79,7 @@ private:
|
||||||
crl::time _startedPosition = kTimeUnknown;
|
crl::time _startedPosition = kTimeUnknown;
|
||||||
|
|
||||||
// Accessed from the main thread.
|
// Accessed from the main thread.
|
||||||
base::Subscription _subscription;
|
rpl::lifetime _subscription;
|
||||||
rpl::event_stream<> _waitingForData;
|
rpl::event_stream<> _waitingForData;
|
||||||
// First set from the same unspecified thread before _ready is called.
|
// First set from the same unspecified thread before _ready is called.
|
||||||
// After that accessed from the main thread.
|
// After that accessed from the main thread.
|
||||||
|
|
|
@ -8,7 +8,6 @@ https://github.com/telegramdesktop/tdesktop/blob/master/LEGAL
|
||||||
#include "media/system_media_controls_manager.h"
|
#include "media/system_media_controls_manager.h"
|
||||||
|
|
||||||
#include "media/audio/media_audio.h"
|
#include "media/audio/media_audio.h"
|
||||||
#include "base/observer.h"
|
|
||||||
#include "base/platform/base_platform_system_media_controls.h"
|
#include "base/platform/base_platform_system_media_controls.h"
|
||||||
#include "core/application.h"
|
#include "core/application.h"
|
||||||
#include "core/core_settings.h"
|
#include "core/core_settings.h"
|
||||||
|
|
|
@ -201,7 +201,7 @@ QString bytesToUtf8(QLatin1String bytes) {
|
||||||
|
|
||||||
} // namespace
|
} // namespace
|
||||||
|
|
||||||
class Editor::Inner : public Ui::RpWidget, private base::Subscriber {
|
class Editor::Inner final : public Ui::RpWidget {
|
||||||
public:
|
public:
|
||||||
Inner(QWidget *parent, const QString &path);
|
Inner(QWidget *parent, const QString &path);
|
||||||
|
|
||||||
|
@ -397,24 +397,36 @@ Editor::Inner::Inner(QWidget *parent, const QString &path)
|
||||||
, _existingRows(this, EditorBlock::Type::Existing, &_context)
|
, _existingRows(this, EditorBlock::Type::Existing, &_context)
|
||||||
, _newRows(this, EditorBlock::Type::New, &_context) {
|
, _newRows(this, EditorBlock::Type::New, &_context) {
|
||||||
resize(st::windowMinWidth, st::windowMinHeight);
|
resize(st::windowMinWidth, st::windowMinHeight);
|
||||||
subscribe(_context.resized, [this] {
|
|
||||||
|
_context.resized.events(
|
||||||
|
) | rpl::start_with_next([=] {
|
||||||
resizeToWidth(width());
|
resizeToWidth(width());
|
||||||
});
|
}, lifetime());
|
||||||
subscribe(_context.pending, [this](const EditorBlock::Context::EditionData &data) {
|
|
||||||
|
using Context = EditorBlock::Context;
|
||||||
|
_context.pending.events(
|
||||||
|
) | rpl::start_with_next([=](const Context::EditionData &data) {
|
||||||
applyEditing(data.name, data.copyOf, data.value);
|
applyEditing(data.name, data.copyOf, data.value);
|
||||||
});
|
}, lifetime());
|
||||||
subscribe(_context.updated, [this] {
|
|
||||||
|
_context.updated.events(
|
||||||
|
) | rpl::start_with_next([=] {
|
||||||
if (_context.name.isEmpty() && _focusCallback) {
|
if (_context.name.isEmpty() && _focusCallback) {
|
||||||
_focusCallback();
|
_focusCallback();
|
||||||
}
|
}
|
||||||
});
|
}, lifetime());
|
||||||
subscribe(_context.scroll, [this](const EditorBlock::Context::ScrollData &data) {
|
|
||||||
|
_context.scroll.events(
|
||||||
|
) | rpl::start_with_next([=](const Context::ScrollData &data) {
|
||||||
if (_scrollCallback) {
|
if (_scrollCallback) {
|
||||||
auto top = (data.type == EditorBlock::Type::Existing ? _existingRows : _newRows)->y();
|
auto top = (data.type == EditorBlock::Type::Existing
|
||||||
|
? _existingRows
|
||||||
|
: _newRows)->y();
|
||||||
top += data.position;
|
top += data.position;
|
||||||
_scrollCallback(top, top + data.height);
|
_scrollCallback(top, top + data.height);
|
||||||
}
|
}
|
||||||
});
|
}, lifetime());
|
||||||
|
|
||||||
Background()->updates(
|
Background()->updates(
|
||||||
) | rpl::start_with_next([=](const BackgroundUpdate &update) {
|
) | rpl::start_with_next([=](const BackgroundUpdate &update) {
|
||||||
if (_applyingUpdate || !Background()->editingTheme()) {
|
if (_applyingUpdate || !Background()->editingTheme()) {
|
||||||
|
|
|
@ -167,20 +167,25 @@ void EditorBlock::Row::fillSearchIndex() {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
EditorBlock::EditorBlock(QWidget *parent, Type type, Context *context) : TWidget(parent)
|
EditorBlock::EditorBlock(QWidget *parent, Type type, Context *context)
|
||||||
|
: RpWidget(parent)
|
||||||
, _type(type)
|
, _type(type)
|
||||||
, _context(context)
|
, _context(context)
|
||||||
, _transparent(style::TransparentPlaceholder()) {
|
, _transparent(style::TransparentPlaceholder()) {
|
||||||
setMouseTracking(true);
|
setMouseTracking(true);
|
||||||
subscribe(_context->updated, [this] {
|
|
||||||
|
_context->updated.events(
|
||||||
|
) | rpl::start_with_next([=] {
|
||||||
if (_mouseSelection) {
|
if (_mouseSelection) {
|
||||||
_lastGlobalPos = QCursor::pos();
|
_lastGlobalPos = QCursor::pos();
|
||||||
updateSelected(mapFromGlobal(_lastGlobalPos));
|
updateSelected(mapFromGlobal(_lastGlobalPos));
|
||||||
}
|
}
|
||||||
update();
|
update();
|
||||||
});
|
}, lifetime());
|
||||||
|
|
||||||
if (_type == Type::Existing) {
|
if (_type == Type::Existing) {
|
||||||
subscribe(_context->appended, [this](const Context::AppendData &added) {
|
_context->appended.events(
|
||||||
|
) | rpl::start_with_next([=](const Context::AppendData &added) {
|
||||||
auto name = added.name;
|
auto name = added.name;
|
||||||
auto value = added.value;
|
auto value = added.value;
|
||||||
feed(name, value);
|
feed(name, value);
|
||||||
|
@ -194,14 +199,15 @@ EditorBlock::EditorBlock(QWidget *parent, Type type, Context *context) : TWidget
|
||||||
row->setCopyOf(copyOf);
|
row->setCopyOf(copyOf);
|
||||||
addToSearch(*row);
|
addToSearch(*row);
|
||||||
|
|
||||||
_context->changed.notify({ QStringList(name), value }, true);
|
_context->changed.fire({ QStringList(name), value });
|
||||||
_context->resized.notify();
|
_context->resized.fire({});
|
||||||
_context->pending.notify({ name, copyOf, value }, true);
|
_context->pending.fire({ name, copyOf, value });
|
||||||
});
|
}, lifetime());
|
||||||
} else {
|
} else {
|
||||||
subscribe(_context->changed, [this](const Context::ChangeData &data) {
|
_context->changed.events(
|
||||||
|
) | rpl::start_with_next([=](const Context::ChangeData &data) {
|
||||||
checkCopiesChanged(0, data.names, data.value);
|
checkCopiesChanged(0, data.names, data.value);
|
||||||
});
|
}, lifetime());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -310,7 +316,7 @@ void EditorBlock::activateRow(const Row &row) {
|
||||||
}));
|
}));
|
||||||
_context->box = box;
|
_context->box = box;
|
||||||
_context->name = row.name();
|
_context->name = row.name();
|
||||||
_context->updated.notify();
|
_context->updated.fire({});
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -335,11 +341,8 @@ bool EditorBlock::selectSkip(int direction) {
|
||||||
|
|
||||||
void EditorBlock::scrollToSelected() {
|
void EditorBlock::scrollToSelected() {
|
||||||
if (_selected >= 0) {
|
if (_selected >= 0) {
|
||||||
Context::ScrollData update;
|
const auto &row = rowAtIndex(_selected);
|
||||||
update.type = _type;
|
_context->scroll.fire({ _type, row.top(), row.height() });
|
||||||
update.position = rowAtIndex(_selected).top();
|
|
||||||
update.height = rowAtIndex(_selected).height();
|
|
||||||
_context->scroll.notify(update, true);
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -383,7 +386,7 @@ void EditorBlock::searchByQuery(QString query) {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
_context->resized.notify(true);
|
_context->resized.fire({});
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -556,7 +559,7 @@ void EditorBlock::saveEditing(QColor value) {
|
||||||
|
|
||||||
removeRow(name, false);
|
removeRow(name, false);
|
||||||
|
|
||||||
_context->appended.notify({ name, possibleCopyOf, color, description }, true);
|
_context->appended.fire({ name, possibleCopyOf, color, description });
|
||||||
} else if (_type == Type::Existing) {
|
} else if (_type == Type::Existing) {
|
||||||
removeFromSearch(row);
|
removeFromSearch(row);
|
||||||
|
|
||||||
|
@ -576,7 +579,7 @@ void EditorBlock::saveEditing(QColor value) {
|
||||||
|
|
||||||
if (valueChanged || copyOfChanged) {
|
if (valueChanged || copyOfChanged) {
|
||||||
checkCopiesChanged(_editing + 1, QStringList(name), value);
|
checkCopiesChanged(_editing + 1, QStringList(name), value);
|
||||||
_context->pending.notify({ name, copyOf, value }, true);
|
_context->pending.fire({ name, copyOf, value });
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
cancelEditing();
|
cancelEditing();
|
||||||
|
@ -593,7 +596,7 @@ void EditorBlock::checkCopiesChanged(int startIndex, QStringList names, QColor v
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if (_type == Type::Existing) {
|
if (_type == Type::Existing) {
|
||||||
_context->changed.notify({ names, value }, true);
|
_context->changed.fire({ names, value });
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -608,7 +611,7 @@ void EditorBlock::cancelEditing() {
|
||||||
_context->possibleCopyOf = QString();
|
_context->possibleCopyOf = QString();
|
||||||
if (!_context->name.isEmpty()) {
|
if (!_context->name.isEmpty()) {
|
||||||
_context->name = QString();
|
_context->name = QString();
|
||||||
_context->updated.notify();
|
_context->updated.fire({});
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -7,7 +7,6 @@ https://github.com/telegramdesktop/tdesktop/blob/master/LEGAL
|
||||||
*/
|
*/
|
||||||
#pragma once
|
#pragma once
|
||||||
|
|
||||||
#include "base/observer.h"
|
|
||||||
#include "ui/rp_widget.h"
|
#include "ui/rp_widget.h"
|
||||||
|
|
||||||
class EditColorBox;
|
class EditColorBox;
|
||||||
|
@ -15,7 +14,7 @@ class EditColorBox;
|
||||||
namespace Window {
|
namespace Window {
|
||||||
namespace Theme {
|
namespace Theme {
|
||||||
|
|
||||||
class EditorBlock : public TWidget, private base::Subscriber {
|
class EditorBlock final : public Ui::RpWidget {
|
||||||
public:
|
public:
|
||||||
enum class Type {
|
enum class Type {
|
||||||
Existing,
|
Existing,
|
||||||
|
@ -26,8 +25,8 @@ public:
|
||||||
QString name;
|
QString name;
|
||||||
QString possibleCopyOf;
|
QString possibleCopyOf;
|
||||||
|
|
||||||
base::Observable<void> updated;
|
rpl::event_stream<> updated;
|
||||||
base::Observable<void> resized;
|
rpl::event_stream<> resized;
|
||||||
|
|
||||||
struct AppendData {
|
struct AppendData {
|
||||||
QString name;
|
QString name;
|
||||||
|
@ -35,27 +34,27 @@ public:
|
||||||
QColor value;
|
QColor value;
|
||||||
QString description;
|
QString description;
|
||||||
};
|
};
|
||||||
base::Observable<AppendData> appended;
|
rpl::event_stream<AppendData> appended;
|
||||||
|
|
||||||
struct ChangeData {
|
struct ChangeData {
|
||||||
QStringList names;
|
QStringList names;
|
||||||
QColor value;
|
QColor value;
|
||||||
};
|
};
|
||||||
base::Observable<ChangeData> changed;
|
rpl::event_stream<ChangeData> changed;
|
||||||
|
|
||||||
struct EditionData {
|
struct EditionData {
|
||||||
QString name;
|
QString name;
|
||||||
QString copyOf;
|
QString copyOf;
|
||||||
QColor value;
|
QColor value;
|
||||||
};
|
};
|
||||||
base::Observable<EditionData> pending;
|
rpl::event_stream<EditionData> pending;
|
||||||
|
|
||||||
struct ScrollData {
|
struct ScrollData {
|
||||||
Type type;
|
Type type = {};
|
||||||
int position;
|
int position = 0;
|
||||||
int height;
|
int height = 0;
|
||||||
};
|
};
|
||||||
base::Observable<ScrollData> scroll;
|
rpl::event_stream<ScrollData> scroll;
|
||||||
};
|
};
|
||||||
EditorBlock(QWidget *parent, Type type, Context *context);
|
EditorBlock(QWidget *parent, Type type, Context *context);
|
||||||
|
|
||||||
|
|
|
@ -41,7 +41,7 @@ not_null<Controller*> LockWidget::window() const {
|
||||||
|
|
||||||
void LockWidget::setInnerFocus() {
|
void LockWidget::setInnerFocus() {
|
||||||
if (const auto controller = _window->sessionController()) {
|
if (const auto controller = _window->sessionController()) {
|
||||||
controller->dialogsListFocused().set(false, true);
|
controller->setDialogsListFocused(false);
|
||||||
}
|
}
|
||||||
setFocus();
|
setFocus();
|
||||||
}
|
}
|
||||||
|
|
|
@ -1234,9 +1234,9 @@ int SessionController::minimalThreeColumnWidth() const {
|
||||||
}
|
}
|
||||||
|
|
||||||
bool SessionController::forceWideDialogs() const {
|
bool SessionController::forceWideDialogs() const {
|
||||||
if (dialogsListDisplayForced().value()) {
|
if (_dialogsListDisplayForced.current()) {
|
||||||
return true;
|
return true;
|
||||||
} else if (dialogsListFocused().value()) {
|
} else if (_dialogsListFocused.current()) {
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
return !content()->isMainSectionShown();
|
return !content()->isMainSectionShown();
|
||||||
|
|
|
@ -9,7 +9,6 @@ https://github.com/telegramdesktop/tdesktop/blob/master/LEGAL
|
||||||
|
|
||||||
#include "base/flags.h"
|
#include "base/flags.h"
|
||||||
#include "base/object_ptr.h"
|
#include "base/object_ptr.h"
|
||||||
#include "base/observer.h"
|
|
||||||
#include "base/weak_ptr.h"
|
#include "base/weak_ptr.h"
|
||||||
#include "base/timer.h"
|
#include "base/timer.h"
|
||||||
#include "boxes/gift_premium_box.h" // GiftPremiumValidator.
|
#include "boxes/gift_premium_box.h" // GiftPremiumValidator.
|
||||||
|
@ -480,17 +479,24 @@ public:
|
||||||
|
|
||||||
void toggleChooseChatTheme(not_null<PeerData*> peer);
|
void toggleChooseChatTheme(not_null<PeerData*> peer);
|
||||||
|
|
||||||
base::Variable<bool> &dialogsListFocused() {
|
[[nodiscard]] bool dialogsListFocused() const {
|
||||||
return _dialogsListFocused;
|
return _dialogsListFocused.current();
|
||||||
}
|
}
|
||||||
const base::Variable<bool> &dialogsListFocused() const {
|
[[nodiscard]] rpl::producer<bool> dialogsListFocusedChanges() const {
|
||||||
return _dialogsListFocused;
|
return _dialogsListFocused.changes();
|
||||||
}
|
}
|
||||||
base::Variable<bool> &dialogsListDisplayForced() {
|
void setDialogsListFocused(bool value) {
|
||||||
return _dialogsListDisplayForced;
|
_dialogsListFocused = value;
|
||||||
}
|
}
|
||||||
const base::Variable<bool> &dialogsListDisplayForced() const {
|
[[nodiscard]] bool dialogsListDisplayForced() const {
|
||||||
return _dialogsListDisplayForced;
|
return _dialogsListDisplayForced.current();
|
||||||
|
}
|
||||||
|
[[nodiscard]] auto dialogsListDisplayForcedChanges() const
|
||||||
|
-> rpl::producer<bool> {
|
||||||
|
return _dialogsListDisplayForced.changes();
|
||||||
|
}
|
||||||
|
void setDialogsListDisplayForced(bool value) {
|
||||||
|
_dialogsListDisplayForced = value;
|
||||||
}
|
}
|
||||||
|
|
||||||
not_null<SessionController*> parentController() override {
|
not_null<SessionController*> parentController() override {
|
||||||
|
@ -611,8 +617,8 @@ private:
|
||||||
|
|
||||||
rpl::variable<Dialogs::RowDescriptor> _activeChatEntry;
|
rpl::variable<Dialogs::RowDescriptor> _activeChatEntry;
|
||||||
rpl::lifetime _activeHistoryLifetime;
|
rpl::lifetime _activeHistoryLifetime;
|
||||||
base::Variable<bool> _dialogsListFocused = { false };
|
rpl::variable<bool> _dialogsListFocused = false;
|
||||||
base::Variable<bool> _dialogsListDisplayForced = { false };
|
rpl::variable<bool> _dialogsListDisplayForced = false;
|
||||||
std::deque<Dialogs::RowDescriptor> _chatEntryHistory;
|
std::deque<Dialogs::RowDescriptor> _chatEntryHistory;
|
||||||
int _chatEntryHistoryPosition = -1;
|
int _chatEntryHistoryPosition = -1;
|
||||||
bool _filtersActivated = false;
|
bool _filtersActivated = false;
|
||||||
|
|
|
@ -1 +1 @@
|
||||||
Subproject commit ff0d99dea36c80650acc2cd9c0dd3b24db6b8c1d
|
Subproject commit 4560884973dd855d9d06f0a9c09f5156e5a06dde
|
Loading…
Reference in a new issue