mirror of
https://github.com/telegramdesktop/tdesktop
synced 2025-09-01 15:05:56 +00:00
Reuse lib_ui's title control side deduction code
This commit is contained in:
@@ -49,14 +49,6 @@ namespace {
|
|||||||
constexpr auto kPipLoaderPriority = 2;
|
constexpr auto kPipLoaderPriority = 2;
|
||||||
constexpr auto kMsInSecond = 1000;
|
constexpr auto kMsInSecond = 1000;
|
||||||
|
|
||||||
[[nodiscard]] bool IsWindowControlsOnLeft() {
|
|
||||||
using Control = Ui::Platform::TitleControls::Control;
|
|
||||||
const auto controlsLayout = Ui::Platform::TitleControlsLayout();
|
|
||||||
return ranges::contains(controlsLayout.left, Control::Close)
|
|
||||||
|| (controlsLayout.left.size() > controlsLayout.right.size()
|
|
||||||
&& !ranges::contains(controlsLayout.right, Control::Close));
|
|
||||||
}
|
|
||||||
|
|
||||||
[[nodiscard]] QRect ScreenFromPosition(QPoint point) {
|
[[nodiscard]] QRect ScreenFromPosition(QPoint point) {
|
||||||
const auto screen = QGuiApplication::screenAt(point);
|
const auto screen = QGuiApplication::screenAt(point);
|
||||||
const auto use = screen ? screen : QGuiApplication::primaryScreen();
|
const auto use = screen ? screen : QGuiApplication::primaryScreen();
|
||||||
@@ -1266,7 +1258,7 @@ void Pip::setupButtons() {
|
|||||||
rect.y(),
|
rect.y(),
|
||||||
volumeToggleWidth,
|
volumeToggleWidth,
|
||||||
volumeToggleHeight);
|
volumeToggleHeight);
|
||||||
if (!IsWindowControlsOnLeft()) {
|
if (!Ui::Platform::TitleControlsOnLeft()) {
|
||||||
_close.area.moveLeft(rect.x()
|
_close.area.moveLeft(rect.x()
|
||||||
+ rect.width()
|
+ rect.width()
|
||||||
- (_close.area.x() - rect.x())
|
- (_close.area.x() - rect.x())
|
||||||
|
@@ -9,7 +9,6 @@ https://github.com/telegramdesktop/tdesktop/blob/master/LEGAL
|
|||||||
|
|
||||||
#include "ui/effects/animations.h"
|
#include "ui/effects/animations.h"
|
||||||
#include "ui/platform/ui_platform_window_title.h"
|
#include "ui/platform/ui_platform_window_title.h"
|
||||||
#include "ui/platform/ui_platform_utility.h"
|
|
||||||
#include "ui/widgets/rp_window.h"
|
#include "ui/widgets/rp_window.h"
|
||||||
#include "ui/abstract_button.h"
|
#include "ui/abstract_button.h"
|
||||||
#include "styles/style_media_view.h"
|
#include "styles/style_media_view.h"
|
||||||
@@ -228,16 +227,7 @@ rpl::producer<bool> DefaultOverlayWidgetHelper::controlsSideRightValue() {
|
|||||||
|
|
||||||
return TitleControlsLayoutValue(
|
return TitleControlsLayoutValue(
|
||||||
) | rpl::map([=](const TitleControls::Layout &layout) {
|
) | rpl::map([=](const TitleControls::Layout &layout) {
|
||||||
// See TitleControls::updateControlsPosition.
|
return !TitleControlsOnLeft(layout);
|
||||||
if (ranges::contains(layout.left, TitleControl::Close)) {
|
|
||||||
return false;
|
|
||||||
} else if (ranges::contains(layout.right, TitleControl::Close)) {
|
|
||||||
return true;
|
|
||||||
} else if (layout.left.size() > layout.right.size()) {
|
|
||||||
return false;
|
|
||||||
} else {
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
}) | rpl::distinct_until_changed();
|
}) | rpl::distinct_until_changed();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Reference in New Issue
Block a user