From 6f7fccc49fa255e9f58991de3fc60a9c67797b8a Mon Sep 17 00:00:00 2001 From: Lixit Date: Fri, 30 Aug 2024 09:30:45 +0800 Subject: [PATCH] =?UTF-8?q?fix(mainwidget):=20=E4=BB=BB=E5=8A=A1=E6=A0=8F?= =?UTF-8?q?=E7=BD=91=E7=BB=9C=E6=A8=A1=E5=9D=97=EF=BC=8C=E5=88=87=E6=8D=A2?= =?UTF-8?q?=E5=93=88=E7=BB=B4=E6=9F=AF=E8=AF=AD=E8=A8=80=E6=97=B6=E4=BB=8E?= =?UTF-8?q?=E5=8F=B3=E5=BE=80=E5=B7=A6=E5=B8=83=E5=B1=80=E5=87=BA=E7=8E=B0?= =?UTF-8?q?=E6=B7=B7=E4=B9=B1?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Description: 任务栏网络模块,切换哈维柯语言时从右往左布局出现混乱 Log: 任务栏网络模块,切换哈维柯语言时从右往左布局出现混乱 Bug: https://gitee.com/openkylin/kylin-nm/issues/I9IYPM?from=project-issue --- src/frontend/mainwindow.cpp | 76 +++++++++++++++++++++++-------------- 1 file changed, 47 insertions(+), 29 deletions(-) diff --git a/src/frontend/mainwindow.cpp b/src/frontend/mainwindow.cpp index be72f8d2..4139ca56 100644 --- a/src/frontend/mainwindow.cpp +++ b/src/frontend/mainwindow.cpp @@ -536,42 +536,60 @@ void MainWindow::resetWindowPosition() #define PANEL_TOP 1 #define PANEL_LEFT 2 #define PANEL_RIGHT 3 +#define PANEL_Bottom 0 //#define PANEL_BOTTOM 4 -#define MARGIN 8 - QDBusInterface iface("org.ukui.panel", - "/panel/position", - "org.ukui.panel", - QDBusConnection::sessionBus()); - QDBusReply reply=iface.call("GetPrimaryScreenGeometry"); - QVariantList position_list=reply.value(); - /* - * 通过这个dbus接口获取到的6个参数分别为 :可用屏幕大小的x坐标、y坐标、宽度、高度,任务栏位置 - */ - QRect rect; - switch(reply.value().at(4).toInt()){ - case 1: - rect = QRect(position_list.at(0).toInt()+position_list.at(2).toInt()-this->width()-MARGIN, - position_list.at(1).toInt()+MARGIN, - this->width(),this->height()); + QRect availableGeo = QGuiApplication::screenAt(QCursor::pos())->geometry(); + int x, y; + + switch (m_panelPosition) + { + case PANEL_TOP: + { + char *envStr = getenv("LANGUAGE"); + /* 维吾尔语 ug_CN + * 哈萨克语 kk_KZ + * 柯尔克孜语 ky_KG */ + if (strcmp(envStr, "ug_CN") == 0 || strcmp(envStr, "kk_KZ") == 0 || strcmp(envStr, "ky_KG") == 0) { + x = MARGIN; + y = availableGeo.y() + m_panelSize + MARGIN; + } + else { + x = availableGeo.x() + availableGeo.width() - this->width() - MARGIN; + y = availableGeo.y() + m_panelSize + MARGIN; + } + + } break; - case 2: - rect = QRect(position_list.at(0).toInt()+MARGIN, - position_list.at(1).toInt()+reply.value().at(3).toInt()-this->height()-MARGIN, - this->width(),this->height()); + case PANEL_Bottom: + { + char *envStr = getenv("LANGUAGE"); + if (strcmp(envStr, "ug_CN") == 0 || strcmp(envStr, "kk_KZ") == 0 || strcmp(envStr, "ky_KG") == 0) { + x = MARGIN; + y = availableGeo.y() + availableGeo.height() - m_panelSize - this->height() - MARGIN; + } + else { + x = availableGeo.x() + availableGeo.width() - this->width() - MARGIN; + y = availableGeo.y() + availableGeo.height() - m_panelSize - this->height() - MARGIN; + } + + } break; - case 3: - rect = QRect(position_list.at(0).toInt()+position_list.at(2).toInt()-this->width()-MARGIN, - position_list.at(1).toInt()+reply.value().at(3).toInt()-this->height()-MARGIN, - this->width(),this->height()); + case PANEL_LEFT: + { + x = availableGeo.x() + m_panelSize + MARGIN; + y = availableGeo.y() + availableGeo.height() - this->height() - MARGIN; + } break; - default: - rect = QRect(position_list.at(0).toInt()+position_list.at(2).toInt()-this->width()-MARGIN, - position_list.at(1).toInt()+reply.value().at(3).toInt()-this->height()-MARGIN, - this->width(),this->height()); + case PANEL_RIGHT: + { + x = availableGeo.x() + availableGeo.width() - m_panelSize - this->width() - MARGIN; + y = availableGeo.y() + availableGeo.height() - this->height() - MARGIN; + } break; } - kdk::WindowManager::setGeometry(this->windowHandle(), rect); + + kdk::WindowManager::setGeometry(this->windowHandle(), QRect(x, y, this->width(), this->height())); qDebug() << " Position of ukui-panel is " << m_panelPosition << "; Position of mainwindow is " << this->geometry() << "." << Q_FUNC_INFO << __LINE__; }