mirror of
https://github.com/AyuGram/AyuGramDesktop.git
synced 2025-04-16 06:07:06 +02:00
Reuse lib_ui's title control side deduction code
This commit is contained in:
parent
f817df9d7f
commit
d60d80ba63
2 changed files with 2 additions and 20 deletions
|
@ -49,14 +49,6 @@ namespace {
|
|||
constexpr auto kPipLoaderPriority = 2;
|
||||
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) {
|
||||
const auto screen = QGuiApplication::screenAt(point);
|
||||
const auto use = screen ? screen : QGuiApplication::primaryScreen();
|
||||
|
@ -1266,7 +1258,7 @@ void Pip::setupButtons() {
|
|||
rect.y(),
|
||||
volumeToggleWidth,
|
||||
volumeToggleHeight);
|
||||
if (!IsWindowControlsOnLeft()) {
|
||||
if (!Ui::Platform::TitleControlsOnLeft()) {
|
||||
_close.area.moveLeft(rect.x()
|
||||
+ rect.width()
|
||||
- (_close.area.x() - rect.x())
|
||||
|
|
|
@ -9,7 +9,6 @@ https://github.com/telegramdesktop/tdesktop/blob/master/LEGAL
|
|||
|
||||
#include "ui/effects/animations.h"
|
||||
#include "ui/platform/ui_platform_window_title.h"
|
||||
#include "ui/platform/ui_platform_utility.h"
|
||||
#include "ui/widgets/rp_window.h"
|
||||
#include "ui/abstract_button.h"
|
||||
#include "styles/style_media_view.h"
|
||||
|
@ -228,16 +227,7 @@ rpl::producer<bool> DefaultOverlayWidgetHelper::controlsSideRightValue() {
|
|||
|
||||
return TitleControlsLayoutValue(
|
||||
) | rpl::map([=](const TitleControls::Layout &layout) {
|
||||
// See TitleControls::updateControlsPosition.
|
||||
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;
|
||||
}
|
||||
return !TitleControlsOnLeft(layout);
|
||||
}) | rpl::distinct_until_changed();
|
||||
}
|
||||
|
||||
|
|
Loading…
Add table
Reference in a new issue