fix(window): 使用任务栏尺寸计算可用区域

This commit is contained in:
hewenfei 2024-04-29 11:03:38 +08:00
parent 7ed8489e53
commit 91ae206d37
2 changed files with 19 additions and 1 deletions

View File

@ -277,10 +277,17 @@ void MenuWindow::initPanelSetting()
m_panelPos = m_setting->get(UKUI_PANEL_POSITION_KEY).toInt(); m_panelPos = m_setting->get(UKUI_PANEL_POSITION_KEY).toInt();
} }
if (keys.contains(UKUI_PANEL_SIZE_KEY)) {
m_panelSize = m_setting->get(UKUI_PANEL_SIZE_KEY).toInt();
}
connect(m_setting, &QGSettings::changed, this, [this] (const QString& key) { connect(m_setting, &QGSettings::changed, this, [this] (const QString& key) {
if (key == UKUI_PANEL_POSITION_KEY) { if (key == UKUI_PANEL_POSITION_KEY) {
m_panelPos = m_setting->get(UKUI_PANEL_POSITION_KEY).toInt(); m_panelPos = m_setting->get(UKUI_PANEL_POSITION_KEY).toInt();
updateGeometry(); updateGeometry();
} else if (key == UKUI_PANEL_SIZE_KEY) {
m_panelSize = m_setting->get(key).toInt();
updateGeometry();
} }
}); });
} }
@ -410,7 +417,9 @@ void MenuWindow::updateCurrentScreenGeometry()
setScreen(QGuiApplication::primaryScreen()); setScreen(QGuiApplication::primaryScreen());
} }
QRect normalMaskRect, fullRect = screen()->availableGeometry(); // qt的可用区域有问题暂时使用任务栏尺寸计算
//QRect normalMaskRect, fullRect = screen()->availableGeometry();
QRect normalMaskRect, fullRect = screen()->geometry();
int width = MenuSetting::instance()->get(MENU_WIDTH).toInt(); int width = MenuSetting::instance()->get(MENU_WIDTH).toInt();
int height = MenuSetting::instance()->get(MENU_HEIGHT).toInt(); int height = MenuSetting::instance()->get(MENU_HEIGHT).toInt();
int margin = MenuSetting::instance()->get(MENU_MARGIN).toInt(); int margin = MenuSetting::instance()->get(MENU_MARGIN).toInt();
@ -419,22 +428,30 @@ void MenuWindow::updateCurrentScreenGeometry()
switch (m_panelPos) { switch (m_panelPos) {
default: default:
case 0: { case 0: {
fullRect.adjust(0, 0, 0, -m_panelSize);
QSize normalSize(qMin<int>(fullRect.width() - margin*2, width), qMin<int>(fullRect.height() - margin*2, height)); QSize normalSize(qMin<int>(fullRect.width() - margin*2, width), qMin<int>(fullRect.height() - margin*2, height));
normalMaskRect.setTopLeft({margin, fullRect.height() - normalSize.height() - margin}); normalMaskRect.setTopLeft({margin, fullRect.height() - normalSize.height() - margin});
normalMaskRect.setSize(normalSize); normalMaskRect.setSize(normalSize);
break; break;
} }
case 1: { case 1: {
fullRect.adjust(0, m_panelSize, 0, 0);
normalMaskRect.setTopLeft({margin, margin}); normalMaskRect.setTopLeft({margin, margin});
normalMaskRect.setSize({qMin<int>(fullRect.width() - margin*2, width), qMin<int>(fullRect.height() - margin*2, height)}); normalMaskRect.setSize({qMin<int>(fullRect.width() - margin*2, width), qMin<int>(fullRect.height() - margin*2, height)});
break; break;
} }
case 2: { case 2: {
fullRect.adjust(m_panelSize, 0, 0, 0);
normalMaskRect.setTopLeft({margin, margin}); normalMaskRect.setTopLeft({margin, margin});
normalMaskRect.setSize({qMin<int>(fullRect.width() - margin*2, width), qMin<int>(fullRect.height() - margin*2, height)}); normalMaskRect.setSize({qMin<int>(fullRect.width() - margin*2, width), qMin<int>(fullRect.height() - margin*2, height)});
break; break;
} }
case 3: { case 3: {
fullRect.adjust(0, 0, -m_panelSize, 0);
QSize normalSize(qMin<int>(fullRect.width() - margin*2, width), qMin<int>(fullRect.height() - margin*2, height)); QSize normalSize(qMin<int>(fullRect.width() - margin*2, width), qMin<int>(fullRect.height() - margin*2, height));
normalMaskRect.setTopLeft({fullRect.width() - normalSize.width() - margin, margin}); normalMaskRect.setTopLeft({fullRect.width() - normalSize.width() - margin, margin});
normalMaskRect.setSize(normalSize); normalMaskRect.setSize(normalSize);

View File

@ -128,6 +128,7 @@ private:
private: private:
// 任务栏位置与屏幕:上: 1, 下: 0, 左: 2, 右: 3, 如果为其他值,则说明任务栏不存在 // 任务栏位置与屏幕:上: 1, 下: 0, 左: 2, 右: 3, 如果为其他值,则说明任务栏不存在
int m_panelPos{4}; int m_panelPos{4};
int m_panelSize{48};
bool m_editMode {false}; bool m_editMode {false};
bool m_isFullScreen{false}; bool m_isFullScreen{false};
QRect m_maskGeometry = QRect(0,0,0,0); QRect m_maskGeometry = QRect(0,0,0,0);