fix(mainwindow): 任务栏网络模块,切换哈维柯语言时从右往左布局出现混乱

Description: 任务栏网络模块,切换哈维柯语言时从右往左布局出现混乱

Log: 任务栏网络模块,切换哈维柯语言时从右往左布局出现混乱
Bug: https://gitee.com/openkylin/kylin-nm/issues/I9IYPM?from=project-issue
This commit is contained in:
Lixit 2024-08-29 17:31:36 +08:00
parent 406516e970
commit ee87601389
1 changed files with 29 additions and 19 deletions

View File

@ -537,31 +537,41 @@ void MainWindow::resetWindowPosition()
#define PANEL_LEFT 2
#define PANEL_RIGHT 3
//#define PANEL_BOTTOM 4
QRect availableGeo = QGuiApplication::screenAt(QCursor::pos())->geometry();
int x, y;
switch(m_panelPosition){
//任务栏位于上方
case PANEL_TOP:
x = availableGeo.x() + availableGeo.width() - this->width() - MARGIN;
y = availableGeo.y() + m_panelSize + MARGIN;
#define MARGIN 8
QDBusInterface iface("org.ukui.panel",
"/panel/position",
"org.ukui.panel",
QDBusConnection::sessionBus());
QDBusReply<QVariantList> 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());
break;
//任务栏位于左边
case PANEL_LEFT:
x = availableGeo.x() + m_panelSize + MARGIN;
y = availableGeo.y() + availableGeo.height() - this->height() - MARGIN;
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());
break;
//任务栏位于右边
case PANEL_RIGHT:
x = availableGeo.x() + availableGeo.width() - m_panelSize - this->width() - MARGIN;
y = availableGeo.y() + availableGeo.height() - this->height() - MARGIN;
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());
break;
//任务栏位于下方
default:
x = availableGeo.x() + availableGeo.width() - this->width() - MARGIN;
y = availableGeo.y() + availableGeo.height() - m_panelSize - this->height() - MARGIN;
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());
break;
}
kdk::WindowManager::setGeometry(this->windowHandle(), QRect(x, y, this->width(), this->height()));
kdk::WindowManager::setGeometry(this->windowHandle(), rect);
qDebug() << " Position of ukui-panel is " << m_panelPosition << "; Position of mainwindow is " << this->geometry() << "." << Q_FUNC_INFO << __LINE__;
}