diff --git a/src/windows/menu-main-window.cpp b/src/windows/menu-main-window.cpp index 872e369..53837ce 100644 --- a/src/windows/menu-main-window.cpp +++ b/src/windows/menu-main-window.cpp @@ -277,10 +277,17 @@ void MenuWindow::initPanelSetting() 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) { if (key == UKUI_PANEL_POSITION_KEY) { m_panelPos = m_setting->get(UKUI_PANEL_POSITION_KEY).toInt(); 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()); } - 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 height = MenuSetting::instance()->get(MENU_HEIGHT).toInt(); int margin = MenuSetting::instance()->get(MENU_MARGIN).toInt(); @@ -419,22 +428,30 @@ void MenuWindow::updateCurrentScreenGeometry() switch (m_panelPos) { default: case 0: { + 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}); normalMaskRect.setSize(normalSize); break; } 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)}); break; } case 2: { + fullRect.adjust(m_panelSize, 0, 0, 0); + normalMaskRect.setTopLeft({margin, margin}); normalMaskRect.setSize({qMin(fullRect.width() - margin*2, width), qMin(fullRect.height() - margin*2, height)}); break; } case 3: { + fullRect.adjust(0, 0, -m_panelSize, 0); + QSize normalSize(qMin(fullRect.width() - margin*2, width), qMin(fullRect.height() - margin*2, height)); normalMaskRect.setTopLeft({fullRect.width() - normalSize.width() - margin, margin}); normalMaskRect.setSize(normalSize); diff --git a/src/windows/menu-main-window.h b/src/windows/menu-main-window.h index 8844d5e..38fe984 100644 --- a/src/windows/menu-main-window.h +++ b/src/windows/menu-main-window.h @@ -128,6 +128,7 @@ private: private: // 任务栏位置与屏幕:上: 1, 下: 0, 左: 2, 右: 3, 如果为其他值,则说明任务栏不存在 int m_panelPos{4}; + int m_panelSize{48}; bool m_editMode {false}; bool m_isFullScreen{false}; QRect m_maskGeometry = QRect(0,0,0,0);