mirror of
https://github.com/AyuGram/AyuGramDesktop.git
synced 2025-06-05 06:33:57 +02:00
Update exposed state for connecting widgets without QWindow events
This commit is contained in:
parent
b58ece3a38
commit
d2d5226dc7
3 changed files with 23 additions and 25 deletions
|
@ -55,7 +55,6 @@ https://github.com/telegramdesktop/tdesktop/blob/master/LEGAL
|
||||||
#include "data/data_send_action.h"
|
#include "data/data_send_action.h"
|
||||||
#include "chat_helpers/emoji_interactions.h"
|
#include "chat_helpers/emoji_interactions.h"
|
||||||
#include "base/unixtime.h"
|
#include "base/unixtime.h"
|
||||||
#include "base/event_filter.h"
|
|
||||||
#include "support/support_helper.h"
|
#include "support/support_helper.h"
|
||||||
#include "apiwrap.h"
|
#include "apiwrap.h"
|
||||||
#include "api/api_chat_participants.h"
|
#include "api/api_chat_participants.h"
|
||||||
|
@ -233,16 +232,6 @@ TopBarWidget::TopBarWidget(
|
||||||
updateConnectingState();
|
updateConnectingState();
|
||||||
}, lifetime());
|
}, lifetime());
|
||||||
|
|
||||||
base::install_event_filter(
|
|
||||||
this,
|
|
||||||
window()->windowHandle(),
|
|
||||||
[=](not_null<QEvent*> e) {
|
|
||||||
if (e->type() == QEvent::Expose) {
|
|
||||||
updateConnectingState();
|
|
||||||
}
|
|
||||||
return base::EventFilterResult::Continue;
|
|
||||||
});
|
|
||||||
|
|
||||||
setCursor(style::cur_pointer);
|
setCursor(style::cur_pointer);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -254,7 +243,8 @@ Main::Session &TopBarWidget::session() const {
|
||||||
|
|
||||||
void TopBarWidget::updateConnectingState() {
|
void TopBarWidget::updateConnectingState() {
|
||||||
const auto state = _controller->session().mtp().dcstate();
|
const auto state = _controller->session().mtp().dcstate();
|
||||||
const auto exposed = window()->windowHandle()->isExposed();
|
const auto exposed = window()->windowHandle()
|
||||||
|
&& window()->windowHandle()->isExposed();
|
||||||
if (state == MTP::ConnectedState || !exposed) {
|
if (state == MTP::ConnectedState || !exposed) {
|
||||||
if (_connecting) {
|
if (_connecting) {
|
||||||
_connecting = nullptr;
|
_connecting = nullptr;
|
||||||
|
@ -271,6 +261,7 @@ void TopBarWidget::updateConnectingState() {
|
||||||
|
|
||||||
void TopBarWidget::connectingAnimationCallback() {
|
void TopBarWidget::connectingAnimationCallback() {
|
||||||
if (!anim::Disabled()) {
|
if (!anim::Disabled()) {
|
||||||
|
updateConnectingState();
|
||||||
update();
|
update();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -436,6 +427,7 @@ void TopBarWidget::paintEvent(QPaintEvent *e) {
|
||||||
if (_animatingMode) {
|
if (_animatingMode) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
updateConnectingState();
|
||||||
Painter p(this);
|
Painter p(this);
|
||||||
|
|
||||||
const auto selectedButtonsTop = countSelectedButtonsTop(
|
const auto selectedButtonsTop = countSelectedButtonsTop(
|
||||||
|
|
|
@ -7,7 +7,6 @@ https://github.com/telegramdesktop/tdesktop/blob/master/LEGAL
|
||||||
*/
|
*/
|
||||||
#include "window/window_connecting_widget.h"
|
#include "window/window_connecting_widget.h"
|
||||||
|
|
||||||
#include "base/event_filter.h"
|
|
||||||
#include "ui/widgets/buttons.h"
|
#include "ui/widgets/buttons.h"
|
||||||
#include "ui/effects/radial_animation.h"
|
#include "ui/effects/radial_animation.h"
|
||||||
#include "ui/painter.h"
|
#include "ui/painter.h"
|
||||||
|
@ -37,6 +36,8 @@ class Progress : public Ui::RpWidget {
|
||||||
public:
|
public:
|
||||||
Progress(QWidget *parent);
|
Progress(QWidget *parent);
|
||||||
|
|
||||||
|
rpl::producer<> animationStepRequests() const;
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
void paintEvent(QPaintEvent *e) override;
|
void paintEvent(QPaintEvent *e) override;
|
||||||
|
|
||||||
|
@ -44,6 +45,7 @@ private:
|
||||||
void animationStep();
|
void animationStep();
|
||||||
|
|
||||||
Ui::InfiniteRadialAnimation _animation;
|
Ui::InfiniteRadialAnimation _animation;
|
||||||
|
rpl::event_stream<> _animationStepRequests;
|
||||||
|
|
||||||
};
|
};
|
||||||
|
|
||||||
|
@ -71,10 +73,15 @@ void Progress::paintEvent(QPaintEvent *e) {
|
||||||
|
|
||||||
void Progress::animationStep() {
|
void Progress::animationStep() {
|
||||||
if (!anim::Disabled()) {
|
if (!anim::Disabled()) {
|
||||||
|
_animationStepRequests.fire({});
|
||||||
update();
|
update();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
rpl::producer<> Progress::animationStepRequests() const {
|
||||||
|
return _animationStepRequests.events();
|
||||||
|
}
|
||||||
|
|
||||||
} // namespace
|
} // namespace
|
||||||
|
|
||||||
class ConnectionState::Widget : public Ui::AbstractButton {
|
class ConnectionState::Widget : public Ui::AbstractButton {
|
||||||
|
@ -109,7 +116,7 @@ private:
|
||||||
const not_null<Main::Account*> _account;
|
const not_null<Main::Account*> _account;
|
||||||
Layout _currentLayout;
|
Layout _currentLayout;
|
||||||
base::unique_qptr<Ui::LinkButton> _retry;
|
base::unique_qptr<Ui::LinkButton> _retry;
|
||||||
QPointer<Ui::RpWidget> _progress;
|
QPointer<Progress> _progress;
|
||||||
QPointer<ProxyIcon> _proxyIcon;
|
QPointer<ProxyIcon> _proxyIcon;
|
||||||
rpl::event_stream<> _refreshStateRequests;
|
rpl::event_stream<> _refreshStateRequests;
|
||||||
|
|
||||||
|
@ -210,14 +217,6 @@ ConnectionState::ConnectionState(
|
||||||
rpl::producer<bool> shown)
|
rpl::producer<bool> shown)
|
||||||
: _account(account)
|
: _account(account)
|
||||||
, _parent(parent)
|
, _parent(parent)
|
||||||
, _exposeFilter(base::install_event_filter(
|
|
||||||
parent->window()->windowHandle(),
|
|
||||||
[=](not_null<QEvent*> e) {
|
|
||||||
if (e->type() == QEvent::Expose) {
|
|
||||||
refreshState();
|
|
||||||
}
|
|
||||||
return base::EventFilterResult::Continue;
|
|
||||||
}))
|
|
||||||
, _refreshTimer([=] { refreshState(); })
|
, _refreshTimer([=] { refreshState(); })
|
||||||
, _currentLayout(computeLayout(_state)) {
|
, _currentLayout(computeLayout(_state)) {
|
||||||
rpl::combine(
|
rpl::combine(
|
||||||
|
@ -241,7 +240,9 @@ ConnectionState::ConnectionState(
|
||||||
}, _lifetime);
|
}, _lifetime);
|
||||||
}
|
}
|
||||||
|
|
||||||
Core::App().settings().proxy().connectionTypeValue(
|
rpl::combine(
|
||||||
|
Core::App().settings().proxy().connectionTypeValue(),
|
||||||
|
rpl::single(QRect()) | rpl::then(_parent->paintRequest())
|
||||||
) | rpl::start_with_next([=] {
|
) | rpl::start_with_next([=] {
|
||||||
refreshState();
|
refreshState();
|
||||||
}, _lifetime);
|
}, _lifetime);
|
||||||
|
@ -301,7 +302,8 @@ void ConnectionState::setBottomSkip(int skip) {
|
||||||
void ConnectionState::refreshState() {
|
void ConnectionState::refreshState() {
|
||||||
using Checker = Core::UpdateChecker;
|
using Checker = Core::UpdateChecker;
|
||||||
const auto state = [&]() -> State {
|
const auto state = [&]() -> State {
|
||||||
const auto exposed = _parent->window()->windowHandle()->isExposed();
|
const auto exposed = _parent->window()->windowHandle()
|
||||||
|
&& _parent->window()->windowHandle()->isExposed();
|
||||||
const auto under = _widget && _widget->isOver();
|
const auto under = _widget && _widget->isOver();
|
||||||
const auto ready = (Checker().state() == Checker::State::Ready);
|
const auto ready = (Checker().state() == Checker::State::Ready);
|
||||||
const auto state = _account->mtp().dcstate();
|
const auto state = _account->mtp().dcstate();
|
||||||
|
@ -501,6 +503,11 @@ ConnectionState::Widget::Widget(
|
||||||
addClickHandler([=] {
|
addClickHandler([=] {
|
||||||
Ui::show(ProxiesBoxController::CreateOwningBox(account));
|
Ui::show(ProxiesBoxController::CreateOwningBox(account));
|
||||||
});
|
});
|
||||||
|
|
||||||
|
_progress->animationStepRequests(
|
||||||
|
) | rpl::start_with_next([=] {
|
||||||
|
_refreshStateRequests.fire({});
|
||||||
|
}, _progress->lifetime());
|
||||||
}
|
}
|
||||||
|
|
||||||
void ConnectionState::Widget::onStateChanged(
|
void ConnectionState::Widget::onStateChanged(
|
||||||
|
|
|
@ -80,7 +80,6 @@ private:
|
||||||
|
|
||||||
const not_null<Main::Account*> _account;
|
const not_null<Main::Account*> _account;
|
||||||
not_null<Ui::RpWidget*> _parent;
|
not_null<Ui::RpWidget*> _parent;
|
||||||
base::unique_qptr<QObject> _exposeFilter;
|
|
||||||
rpl::variable<int> _bottomSkip;
|
rpl::variable<int> _bottomSkip;
|
||||||
base::unique_qptr<Widget> _widget;
|
base::unique_qptr<Widget> _widget;
|
||||||
bool _forceHidden = false;
|
bool _forceHidden = false;
|
||||||
|
|
Loading…
Add table
Reference in a new issue