feat(panel):自动隐藏时,触发显示的区域为屏幕边缘4个像素宽度

This commit is contained in:
iaom 2024-04-12 14:45:59 +08:00
parent 00e4d8fb40
commit 5229953e7f
2 changed files with 33 additions and 1 deletions

View File

@ -30,6 +30,7 @@ static const QStringList DEFAULT_LOADING_WIDGETS = {QStringLiteral("org.ukui.men
QStringLiteral("org.ukui.panel.calendar"),
QStringLiteral("org.ukui.panel.showDesktop")
};
static const int MASK_SIZE = 4;
namespace UkuiPanel {
@ -356,6 +357,7 @@ void Panel::updateGeometry()
refreshRect();
setGeometry(m_container->geometry());
kdk::WindowManager::setGeometry(this, m_container->geometry());
updateMask();
}
void Panel::refreshRect()
@ -685,8 +687,9 @@ bool Panel::performHide()
this->rootItem()->setVisible(false);
kdk::WindowManager::setSkipSwitcher(this, true);
kdk::WindowManager::setSkipTaskBar(this, true);
show();
m_isHidden = true;
updateMask();
show();
return true;
}
return false;
@ -698,11 +701,13 @@ void Panel::performShow()
hide();
KWindowEffects::enableBlurBehind(this);
this->rootItem()->setVisible(true);
setMask(QRegion(0, 0, geometry().width(), geometry().height()));
}
kdk::WindowManager::setSkipSwitcher(this, true);
kdk::WindowManager::setSkipTaskBar(this, true);
show();
m_isHidden = false;
updateMask();
}
void Panel::customPanelSize(bool isAdd)
@ -786,4 +791,30 @@ void Panel::onContainerActiveChanged()
}
}
void Panel::updateMask()
{
QRegion mask;
if(m_isHidden) {
switch (m_container->position()) {
case UkuiQuick::Types::Left:
mask = QRegion(0, 0, MASK_SIZE, geometry().height());
break;
case UkuiQuick::Types::Top:
mask = QRegion(0, 0, geometry().width(), MASK_SIZE);
break;
case UkuiQuick::Types::Right:
mask = QRegion(geometry().width() - MASK_SIZE, 0, MASK_SIZE, geometry().height());
break;
case UkuiQuick::Types::Bottom:
mask = QRegion(0, geometry().height() - MASK_SIZE, geometry().width(), MASK_SIZE);
break;
default:
break;
}
} else {
mask = QRegion(0, 0, geometry().width(), geometry().y());
}
setMask(mask);
}
} // UkuiPanel

View File

@ -67,6 +67,7 @@ private:
void updateSizeAction();
void initPositionAction();
void updatePositionAction();
void updateMask();
private:
int m_panelSize {48};