mirror of
https://github.com/AyuGram/AyuGramDesktop.git
synced 2025-04-14 13:17:08 +02:00
Use RpWidget::windowActiveValue
This commit is contained in:
parent
8a5797e1bd
commit
a22cf8e303
8 changed files with 25 additions and 40 deletions
|
@ -897,7 +897,7 @@ void Widget::setupStories() {
|
|||
Core::App().saveSettingsDelayed();
|
||||
};
|
||||
_stories->setShowTooltip(
|
||||
parentWidget(),
|
||||
controller()->content(),
|
||||
rpl::combine(
|
||||
Core::App().settings().storiesClickTooltipHiddenValue(),
|
||||
shownValue(),
|
||||
|
|
|
@ -903,7 +903,7 @@ TextWithEntities List::computeTooltipText() const {
|
|||
}
|
||||
|
||||
void List::setShowTooltip(
|
||||
not_null<QWidget*> tooltipParent,
|
||||
not_null<Ui::RpWidget*> tooltipParent,
|
||||
rpl::producer<bool> shown,
|
||||
Fn<void()> hide) {
|
||||
_tooltip = nullptr;
|
||||
|
@ -925,16 +925,6 @@ void List::setShowTooltip(
|
|||
tooltip->toggleFast(false);
|
||||
updateTooltipGeometry();
|
||||
|
||||
const auto handle = tooltipParent->window()->windowHandle();
|
||||
auto windowActive = rpl::single(
|
||||
handle->isActive()
|
||||
) | rpl::then(base::qt_signal_producer(
|
||||
handle,
|
||||
&QWindow::activeChanged
|
||||
) | rpl::map([=] {
|
||||
return handle->isActive();
|
||||
})) | rpl::distinct_until_changed();
|
||||
|
||||
{
|
||||
const auto recompute = [=] {
|
||||
updateTooltipGeometry();
|
||||
|
@ -955,7 +945,7 @@ void List::setShowTooltip(
|
|||
_tooltipText.value() | rpl::map(
|
||||
notEmpty
|
||||
) | rpl::distinct_until_changed(),
|
||||
std::move(windowActive)
|
||||
tooltipParent->windowActiveValue()
|
||||
) | rpl::start_with_next([=](bool, bool, bool active) {
|
||||
_tooltipWindowActive = active;
|
||||
if (!isHidden()) {
|
||||
|
@ -981,7 +971,7 @@ void List::toggleTooltip(bool fast) {
|
|||
&& !isHidden()
|
||||
&& _tooltipNotHidden.current()
|
||||
&& !_tooltipText.current().empty()
|
||||
&& window()->windowHandle()->isActive();
|
||||
&& isActiveWindow();
|
||||
if (_tooltip) {
|
||||
if (fast) {
|
||||
_tooltip->toggleFast(shown);
|
||||
|
|
|
@ -72,7 +72,7 @@ public:
|
|||
style::align alignSmall,
|
||||
QRect geometryFull = QRect());
|
||||
void setShowTooltip(
|
||||
not_null<QWidget*> tooltipParent,
|
||||
not_null<Ui::RpWidget*> tooltipParent,
|
||||
rpl::producer<bool> shown,
|
||||
Fn<void()> hide);
|
||||
void raiseTooltip();
|
||||
|
|
|
@ -342,11 +342,9 @@ void Controller::createWindow() {
|
|||
_window = std::make_unique<Ui::RpWindow>();
|
||||
const auto window = _window.get();
|
||||
|
||||
base::qt_signal_producer(
|
||||
window->window()->windowHandle(),
|
||||
&QWindow::activeChanged
|
||||
) | rpl::filter([=] {
|
||||
return _webview && window->window()->windowHandle()->isActive();
|
||||
window->windowActiveValue(
|
||||
) | rpl::filter([=](bool active) {
|
||||
return _webview && active;
|
||||
}) | rpl::start_with_next([=] {
|
||||
setInnerFocus();
|
||||
}, window->lifetime());
|
||||
|
|
|
@ -139,7 +139,9 @@ void MainWindow::finishFirstShow() {
|
|||
applyInitialWorkMode();
|
||||
createGlobalMenu();
|
||||
|
||||
windowDeactivateEvents(
|
||||
windowActiveValue(
|
||||
) | rpl::skip(1) | rpl::filter(
|
||||
!rpl::mappers::_1
|
||||
) | rpl::start_with_next([=] {
|
||||
Ui::Tooltip::Hide();
|
||||
}, lifetime());
|
||||
|
@ -594,7 +596,7 @@ bool MainWindow::eventFilter(QObject *object, QEvent *e) {
|
|||
case QEvent::ApplicationActivate: {
|
||||
if (object == QCoreApplication::instance()) {
|
||||
InvokeQueued(this, [=] {
|
||||
handleActiveChanged();
|
||||
handleActiveChanged(isActiveWindow());
|
||||
});
|
||||
}
|
||||
} break;
|
||||
|
|
|
@ -328,16 +328,11 @@ Controller::Controller(not_null<Delegate*> delegate)
|
|||
}
|
||||
}, _lifetime);
|
||||
|
||||
const auto window = _wrap->window()->windowHandle();
|
||||
Assert(window != nullptr);
|
||||
base::qt_signal_producer(
|
||||
window,
|
||||
&QWindow::activeChanged
|
||||
) | rpl::start_with_next([=] {
|
||||
_windowActive = window->isActive();
|
||||
_wrap->windowActiveValue(
|
||||
) | rpl::start_with_next([=](bool active) {
|
||||
_windowActive = active;
|
||||
updatePlayingAllowed();
|
||||
}, _lifetime);
|
||||
_windowActive = window->isActive();
|
||||
|
||||
_contentFadeAnimation.stop();
|
||||
}
|
||||
|
|
|
@ -351,6 +351,13 @@ MainWindow::MainWindow(not_null<Controller*> controller)
|
|||
Ui::Toast::SetDefaultParent(_body.data());
|
||||
}
|
||||
|
||||
windowActiveValue(
|
||||
) | rpl::skip(1) | rpl::start_with_next([=](bool active) {
|
||||
InvokeQueued(this, [=] {
|
||||
handleActiveChanged(active);
|
||||
});
|
||||
}, lifetime());
|
||||
|
||||
body()->sizeValue(
|
||||
) | rpl::start_with_next([=](QSize size) {
|
||||
updateControlsGeometry();
|
||||
|
@ -445,13 +452,6 @@ void MainWindow::init() {
|
|||
|
||||
initHook();
|
||||
|
||||
// Non-queued activeChanged handlers must use QtSignalProducer.
|
||||
connect(
|
||||
windowHandle(),
|
||||
&QWindow::activeChanged,
|
||||
this,
|
||||
[=] { handleActiveChanged(); },
|
||||
Qt::QueuedConnection);
|
||||
connect(
|
||||
windowHandle(),
|
||||
&QWindow::windowStateChanged,
|
||||
|
@ -495,9 +495,9 @@ void MainWindow::handleStateChanged(Qt::WindowState state) {
|
|||
savePosition(state);
|
||||
}
|
||||
|
||||
void MainWindow::handleActiveChanged() {
|
||||
void MainWindow::handleActiveChanged(bool active) {
|
||||
checkActivation();
|
||||
if (isActiveWindow()) {
|
||||
if (active) {
|
||||
Core::App().windowActivated(&controller());
|
||||
}
|
||||
if (const auto controller = sessionController()) {
|
||||
|
|
|
@ -151,7 +151,7 @@ protected:
|
|||
|
||||
void savePosition(Qt::WindowState state = Qt::WindowActive);
|
||||
void handleStateChanged(Qt::WindowState state);
|
||||
void handleActiveChanged();
|
||||
void handleActiveChanged(bool active);
|
||||
void handleVisibleChanged(bool visible);
|
||||
|
||||
virtual void checkActivation() {
|
||||
|
|
Loading…
Add table
Reference in a new issue