mirror of
https://github.com/AyuGram/AyuGramDesktop.git
synced 2025-04-14 13:17:08 +02:00
Use RpWidget::screenValue
This commit is contained in:
parent
5180e0ec57
commit
006d6fe2c0
5 changed files with 18 additions and 26 deletions
|
@ -633,10 +633,10 @@ OverlayWidget::OverlayWidget()
|
|||
_widget->setMouseTracking(true);
|
||||
_window->createWinId();
|
||||
|
||||
QObject::connect(
|
||||
window(),
|
||||
&QWindow::screenChanged,
|
||||
[=](QScreen *screen) { handleScreenChanged(screen); });
|
||||
_window->screenValue(
|
||||
) | rpl::skip(1) | rpl::start_with_next([=](not_null<QScreen*> screen) {
|
||||
handleScreenChanged(screen);
|
||||
}, lifetime());
|
||||
subscribeToScreenGeometry();
|
||||
updateGeometry();
|
||||
updateControlsGeometry();
|
||||
|
@ -2315,7 +2315,7 @@ void OverlayWidget::dropdownHidden() {
|
|||
}
|
||||
}
|
||||
|
||||
void OverlayWidget::handleScreenChanged(QScreen *screen) {
|
||||
void OverlayWidget::handleScreenChanged(not_null<QScreen*> screen) {
|
||||
subscribeToScreenGeometry();
|
||||
if (isHidden()) {
|
||||
return;
|
||||
|
|
|
@ -303,7 +303,7 @@ private:
|
|||
bool moveToNext(int delta);
|
||||
void preloadData(int delta);
|
||||
|
||||
void handleScreenChanged(QScreen *screen);
|
||||
void handleScreenChanged(not_null<QScreen*> screen);
|
||||
|
||||
[[nodiscard]] bool computeSaveButtonVisible() const;
|
||||
void checkForSaveLoaded();
|
||||
|
|
|
@ -361,12 +361,10 @@ void PipPanel::init() {
|
|||
Ui::Platform::ClearTransientParent(widget());
|
||||
}, rp()->lifetime());
|
||||
|
||||
QObject::connect(
|
||||
widget()->windowHandle(),
|
||||
&QWindow::screenChanged,
|
||||
[=](QScreen *screen) {
|
||||
handleScreenChanged(screen);
|
||||
});
|
||||
rp()->screenValue(
|
||||
) | rpl::skip(1) | rpl::start_with_next([=](not_null<QScreen*> screen) {
|
||||
handleScreenChanged(screen);
|
||||
}, rp()->lifetime());
|
||||
|
||||
if (Platform::IsWayland()) {
|
||||
rp()->sizeValue(
|
||||
|
@ -637,7 +635,7 @@ void PipPanel::handleWaylandResize(QSize size) {
|
|||
_inHandleWaylandResize = false;
|
||||
}
|
||||
|
||||
void PipPanel::handleScreenChanged(QScreen *screen) {
|
||||
void PipPanel::handleScreenChanged(not_null<QScreen*> screen) {
|
||||
const auto screenGeometry = screen->availableGeometry();
|
||||
const auto minimalSize = _ratio.scaled(
|
||||
st::pipMinimalSize,
|
||||
|
|
|
@ -77,7 +77,7 @@ public:
|
|||
[[nodiscard]] bool dragging() const;
|
||||
|
||||
void handleWaylandResize(QSize size);
|
||||
void handleScreenChanged(QScreen *screen);
|
||||
void handleScreenChanged(not_null<QScreen*> screen);
|
||||
void handleMousePress(QPoint position, Qt::MouseButton button);
|
||||
void handleMouseRelease(QPoint position, Qt::MouseButton button);
|
||||
void handleMouseMove(QPoint position);
|
||||
|
|
|
@ -957,21 +957,15 @@ void MainMenu::drawName(Painter &p) {
|
|||
}
|
||||
|
||||
void MainMenu::initResetScaleButton() {
|
||||
if (!window() || !window()->windowHandle()) {
|
||||
return;
|
||||
}
|
||||
const auto handle = window()->windowHandle();
|
||||
rpl::single(
|
||||
handle->screen()
|
||||
) | rpl::then(
|
||||
base::qt_signal_producer(handle, &QWindow::screenChanged)
|
||||
) | rpl::filter([](QScreen *screen) {
|
||||
return screen != nullptr;
|
||||
}) | rpl::map([](QScreen * screen) {
|
||||
_controller->widget()->screenValue(
|
||||
) | rpl::map([](not_null<QScreen*> screen) {
|
||||
return rpl::single(
|
||||
screen->availableGeometry()
|
||||
) | rpl::then(
|
||||
base::qt_signal_producer(screen, &QScreen::availableGeometryChanged)
|
||||
base::qt_signal_producer(
|
||||
screen.get(),
|
||||
&QScreen::availableGeometryChanged
|
||||
)
|
||||
);
|
||||
}) | rpl::flatten_latest(
|
||||
) | rpl::map([](QRect available) {
|
||||
|
|
Loading…
Add table
Reference in a new issue