From a5727019845157500acd48dc264dfa82022cbd15 Mon Sep 17 00:00:00 2001 From: youdiansaodongxi Date: Wed, 21 Aug 2024 15:35:17 +0800 Subject: [PATCH] =?UTF-8?q?fix(src/windows):=20=E4=BF=AE=E6=94=B9=E7=BB=B4?= =?UTF-8?q?=E5=93=88=E6=9F=AF=E8=AF=AD=E8=A8=80=E4=B8=8B=E5=BC=80=E5=A7=8B?= =?UTF-8?q?=E8=8F=9C=E5=8D=95=E7=9A=84=E7=AA=97=E5=8F=A3=E4=BD=8D=E7=BD=AE?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- qml/AppUI/AppListHeader.qml | 1 + src/windows/menu-main-window.cpp | 18 +++++++++++++++--- 2 files changed, 16 insertions(+), 3 deletions(-) diff --git a/qml/AppUI/AppListHeader.qml b/qml/AppUI/AppListHeader.qml index 54bacac..c80e004 100644 --- a/qml/AppUI/AppListHeader.qml +++ b/qml/AppUI/AppListHeader.qml @@ -41,6 +41,7 @@ Item { Layout.fillWidth: true Layout.fillHeight: true verticalAlignment: Text.AlignVCenter + horizontalAlignment: Text.AlignLeft elide: Text.ElideRight text: root.title === "" ? header.title : root.title } diff --git a/src/windows/menu-main-window.cpp b/src/windows/menu-main-window.cpp index c616703..0c6eb36 100644 --- a/src/windows/menu-main-window.cpp +++ b/src/windows/menu-main-window.cpp @@ -233,6 +233,7 @@ void MenuWindow::init() }); setScreen(QGuiApplication::primaryScreen()); connect(screen(), &QScreen::geometryChanged, this, &MenuWindow::updateGeometry); + connect(qGuiApp, &QGuiApplication::layoutDirectionChanged, this, &MenuWindow::updateGeometry); setTitle(QCoreApplication::applicationName()); setResizeMode(SizeRootObjectToView); @@ -423,6 +424,7 @@ void MenuWindow::updateCurrentScreenGeometry() int height = MenuSetting::instance()->get(MENU_HEIGHT).toInt(); int margin = MenuSetting::instance()->get(MENU_MARGIN).toInt(); UkuiQuick::WindowProxy::SlideFromEdge slideFromEdge; + bool isMirrored = qGuiApp->layoutDirection() == Qt::LayoutDirection::RightToLeft; //上: 1, 下: 0, 左: 2, 右: 3 switch (m_panelPos) { @@ -431,7 +433,11 @@ void MenuWindow::updateCurrentScreenGeometry() fullRect.adjust(0, 0, 0, -m_panelSize); QSize normalSize(qMin(fullRect.width() - margin*2, width), qMin(fullRect.height() - margin*2, height)); - normalMaskRect.setTopLeft({margin, fullRect.height() - normalSize.height() - margin}); + if (isMirrored) { + normalMaskRect.setTopLeft({fullRect.width() - margin - width, fullRect.height() - normalSize.height() - margin}); + } else { + normalMaskRect.setTopLeft({margin, fullRect.height() - normalSize.height() - margin}); + } normalMaskRect.setSize(normalSize); slideFromEdge = UkuiQuick::WindowProxy::BottomEdge; break; @@ -439,8 +445,13 @@ void MenuWindow::updateCurrentScreenGeometry() case 1: { fullRect.adjust(0, m_panelSize, 0, 0); - normalMaskRect.setTopLeft({margin, margin}); - normalMaskRect.setSize({qMin(fullRect.width() - margin*2, width), qMin(fullRect.height() - margin*2, height)}); + QSize normalSize(qMin(fullRect.width() - margin*2, width), qMin(fullRect.height() - margin*2, height)); + if (isMirrored) { + normalMaskRect.setTopLeft({fullRect.width() - margin - width, margin}); + } else { + normalMaskRect.setTopLeft({margin, margin}); + } + normalMaskRect.setSize(normalSize); slideFromEdge = UkuiQuick::WindowProxy::TopEdge; break; } @@ -490,6 +501,7 @@ void MenuWindow::activeMenuWindow(bool active) } this->setScreen(UkuiQuick::WindowProxy::currentScreen()); connect(screen(), &QScreen::geometryChanged, this, &MenuWindow::updateGeometry); + connect(qGuiApp, &QGuiApplication::layoutDirectionChanged, this, &MenuWindow::updateGeometry); updateGeometry(); } }