Commit 7248a71a authored by David Edmundson's avatar David Edmundson

Don't set PanelView visibilty when opening/closing config

Summary:
    Instead of making PanelViewConfig manipulate the visibiltyMode of
    PanelView, make PanelView force the view to be visible whilst the
config
    is open.

    This is cleaner as it doesn't alter the original config, and
resolves a
    bug that opening configure with an autohide panel would shift
contents
    about.

Test Plan:
With panel as autohide opened config
Moused away from panel, panel stayed visible

With panel as autohide, plugged in a USB pen - panel appeared - and
closed when I hid the dialog

Changed mode in panel config, panel didn't immediately change - but did
on close.
Tested with all modes.

Reviewers: #plasma, mart

Reviewed By: mart

Subscribers: mart, plasma-devel

Tags: #plasma
BUG: 372248

Differential Revision: https://phabricator.kde.org/D3408
parent 41b96399
......@@ -49,8 +49,6 @@ PanelConfigView::PanelConfigView(Plasma::Containment *containment, PanelView *pa
{
connect(panelView, &QObject::destroyed, this, &QObject::deleteLater);
m_visibilityMode = panelView->visibilityMode();
setScreen(panelView->screen());
connect(panelView, SIGNAL(screenChanged(QScreen *)), &m_screenSyncTimer, SLOT(start()));
......@@ -83,9 +81,6 @@ PanelConfigView::PanelConfigView(Plasma::Containment *containment, PanelView *pa
PanelConfigView::~PanelConfigView()
{
if (m_panelView) {
m_panelView->setVisibilityMode(m_visibilityMode);
}
}
void PanelConfigView::init()
......@@ -209,16 +204,12 @@ void PanelConfigView::showEvent(QShowEvent *ev)
m_containment->setUserConfiguring(true);
}
if (m_visibilityMode != PanelView::NormalPanel) {
m_panelView->setVisibilityMode(PanelView::WindowsGoBelow);
}
PanelShadows::self()->addWindow(this, m_enabledBorders);
}
void PanelConfigView::hideEvent(QHideEvent *ev)
{
QQuickWindow::hideEvent(ev);
m_panelView->setVisibilityMode(m_visibilityMode);
if (m_containment) {
m_containment->setUserConfiguring(false);
......@@ -280,17 +271,13 @@ bool PanelConfigView::event(QEvent *e)
void PanelConfigView::setVisibilityMode(PanelView::VisibilityMode mode)
{
if (m_visibilityMode == mode) {
return;
}
m_visibilityMode = mode;
m_panelView->setVisibilityMode(mode);
emit visibilityModeChanged();
}
PanelView::VisibilityMode PanelConfigView::visibilityMode() const
{
return m_visibilityMode;
return m_panelView->visibilityMode();
}
Plasma::FrameSvg::EnabledBorders PanelConfigView::enabledBorders() const
......
......@@ -87,7 +87,6 @@ Q_SIGNALS:
private:
Plasma::Containment *m_containment;
QPointer<PanelView> m_panelView;
PanelView::VisibilityMode m_visibilityMode;
Plasma::FrameSvg::EnabledBorders m_enabledBorders = Plasma::FrameSvg::AllBorders;
Plasma::Theme m_theme;
QTimer m_screenSyncTimer;
......
......@@ -320,6 +320,7 @@ void PanelView::setVisibilityMode(PanelView::VisibilityMode mode)
updateStruts();
emit visibilityModeChanged();
restoreAutoHide();
}
......@@ -562,13 +563,23 @@ void PanelView::showConfigurationInterface(Plasma::Applet *applet)
void PanelView::restoreAutoHide()
{
setAutoHideEnabled(edgeActivated()
&& (!containment() ||
(containment()->status() < Plasma::Types::RequiresAttentionStatus
|| containment()->status() == Plasma::Types::HiddenStatus)
)
&& !geometry().contains(QCursor::pos(screenToFollow()))
);
bool autoHide = true;
if (!edgeActivated()) {
autoHide = false;
}
else if (geometry().contains(QCursor::pos(screenToFollow()))) {
autoHide = false;
}
else if (containment() && containment()->isUserConfiguring()) {
autoHide = false;
}
else if (containment() && containment()->status() >= Plasma::Types::NeedsAttentionStatus &&
containment()->status() != Plasma::Types::HiddenStatus) {
autoHide = false;
}
setAutoHideEnabled(autoHide);
}
void PanelView::setAutoHideEnabled(bool enabled)
......@@ -949,11 +960,10 @@ bool PanelView::canSetStrut() const
void PanelView::updateStruts()
{
if (!containment() || !m_screenToFollow) {
if (!containment() || containment()->isUserConfiguring() || !m_screenToFollow) {
return;
}
NETExtendedStrut strut;
if (m_visibilityMode == NormalPanel) {
......@@ -1037,6 +1047,15 @@ void PanelView::themeChanged()
void PanelView::containmentChanged()
{
restore();
connect(containment(), &Plasma::Containment::userConfiguringChanged, this, [this](bool configuring){
if (configuring) {
showTemporarily();
} else {
m_unhideTimer.start();
updateStruts();
}
});
connect(containment(), SIGNAL(statusChanged(Plasma::Types::ItemStatus)), SLOT(statusChanged(Plasma::Types::ItemStatus)));
connect(containment(), &Plasma::Applet::appletDeleted, this, [this] {
//containment()->destroyed() is true only when the user deleted it
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment