Fix bug mainwindow show abnormal position in HuaweiPC

This commit is contained in:
chenlelin 2021-03-06 11:43:37 +08:00
parent 43c8beb804
commit 8da923e7aa
1 changed files with 14 additions and 62 deletions

View File

@ -704,68 +704,20 @@ void MainWindow::handleIconClicked()
int d = 4; //窗口边沿到任务栏距离
if (isHuaWeiPC) {
if (screenGeometry.width() == availableGeometry.width() && screenGeometry.height() == availableGeometry.height()) {
if (n == 0) {
//任务栏在下侧
this->move(m_priX + availableGeometry.width() - this->width() - d, screenMainRect.y() + availableGeometry.height() - this->height() - m - d);
} else if(n == 1) {
//任务栏在上侧
this->move(m_priX + availableGeometry.width() - this->width() - d, screenMainRect.y() + screenGeometry.height() - availableGeometry.height() + m + d);
} else if (n == 2) {
//任务栏在左侧
if (screenGeometry.x() == 0) {//主屏在左侧
this->move(m_priX + m + d, screenMainRect.y() + screenMainRect.height() - this->height() - d);
} else {//主屏在右侧
this->move(m_priX + m + d, screenMainRect.y() + screenMainRect.height() - this->height() - d);
}
} else if (n == 3) {
//任务栏在右侧
if (screenGeometry.x() == 0) {//主屏在左侧
this->move(m_priX + screenMainRect.width() - this->width() - m - d, screenMainRect.y() + screenMainRect.height() - this->height() - d);
} else {//主屏在右侧
this->move(m_priX + screenMainRect.width() - this->width() - m - d, screenMainRect.y() + screenMainRect.height() - this->height() - d);
}
}
} else if(screenGeometry.width() == availableGeometry.width() ) {
if (trayIcon->geometry().y() > availableGeometry.height()/2) {
//任务栏在下侧
if (screenGeometry.height() - 20 < availableGeometry.height()) {
//任务栏隐藏
this->move(m_priX + availableGeometry.width() - this->width() - d, screenMainRect.y() + availableGeometry.height() - this->height() - m );
} else {
//任务栏不隐藏
this->move(m_priX + availableGeometry.width() - this->width() - d, screenMainRect.y() + availableGeometry.height() - this->height() - d);
}
} else {
//任务栏在上侧
if (screenGeometry.height() - 20 < availableGeometry.height()) {
//任务栏隐藏
this->move(m_priX + availableGeometry.width() - this->width() - d, screenMainRect.y() + screenGeometry.height() - availableGeometry.height() + m );
} else {
//任务栏不隐藏
this->move(m_priX + availableGeometry.width() - this->width() - d, screenMainRect.y() + screenGeometry.height() - availableGeometry.height() + d);
}
}
} else if (screenGeometry.height() == availableGeometry.height()) {
if (trayIcon->geometry().x() > availableGeometry.width()/2) {
//任务栏在右侧
if (screenGeometry.width() - 20 < availableGeometry.width()) {
//任务栏隐藏
this->move(m_priX + availableGeometry.width() - this->width() - m, screenMainRect.y() + screenGeometry.height() - this->height() - d - 3);
} else {
//任务栏不隐藏
this->move(m_priX + availableGeometry.width() - this->width() - d, screenMainRect.y() + screenGeometry.height() - this->height() - d - 3);
}
} else {
//任务栏在左侧
if (screenGeometry.width() - 20 < availableGeometry.width()) {
//任务栏隐藏
this->move(m_priX + screenGeometry.width() - availableGeometry.width() + m, screenMainRect.y() + screenGeometry.height() - this->height() - d - 3);
} else {
//任务栏不隐藏
this->move(m_priX + screenGeometry.width() - availableGeometry.width() + d, screenMainRect.y() + screenGeometry.height() - this->height() - d - 3);
}
}
//qDebug() << "-------------------------------------> HUAWEI PC";
//qDebug("primary screen changed, geometry is x=%d, y=%d, windth=%d, height=%d", m_priX, m_priY, m_priWid, m_priHei);
if (n == 0) {
//任务栏在下侧
this->move(m_priX + m_priWid - this->width() - d, m_priY + m_priHei - this->height() - m - d);
} else if(n == 1) {
//任务栏在上侧
this->move(m_priX + m_priWid - this->width() - d, m_priY + m + d);
} else if (n == 2) {
//任务栏在左侧
this->move(m_priX + m + d, m_priY + m_priHei - this->height() - d);
} else if (n == 3) {
//任务栏在右侧
this->move(m_priX + m_priWid - this->width() - m - d, m_priY + m_priHei - this->height() - d);
}
} else {
if (screenGeometry.width() == availableGeometry.width() && screenGeometry.height() == availableGeometry.height()) {