improve settings window behavior onlostfocus

-- and fix a crash from immutabilityChanged from
settings window
pull/1/head
Michail Vourlakos
parent dce9e76049
commit 6b1ff92463

@ -51,12 +51,12 @@ NowDockConfigView::NowDockConfigView(Plasma::Containment *containment, NowDockVi
syncSlideEffect(); syncSlideEffect();
}); });
//containment->setLocation(Plasma::Types::LeftEdge); connect(containment, &Plasma::Containment::immutabilityChanged, this, &NowDockConfigView::immutabilityChanged);
/*connect(containment, &Plasma::Containment::immutabilityChanged /* connect(containment, &Plasma::Containment::immutabilityChanged
, [&](Plasma::Types::ImmutabilityType type) { , [&](Plasma::Types::ImmutabilityType type) {
if (type != Plasma::Types::Mutable && isVisible()) if (type != Plasma::Types::Mutable && this && isVisible())
hide(); hide();
});*/ });*/
} }
NowDockConfigView::~NowDockConfigView() NowDockConfigView::~NowDockConfigView()
@ -83,7 +83,7 @@ void NowDockConfigView::syncGeometry()
{ {
if (!m_containment || !rootObject()) if (!m_containment || !rootObject())
return; return;
const auto location = m_containment->location(); const auto location = m_containment->location();
const auto sGeometry = screen()->geometry(); const auto sGeometry = screen()->geometry();
@ -93,7 +93,7 @@ void NowDockConfigView::syncGeometry()
setMaximumSize(size); setMaximumSize(size);
setMinimumSize(size); setMinimumSize(size);
resize(size); resize(size);
if (location == Plasma::Types::TopEdge) { if (location == Plasma::Types::TopEdge) {
setPosition(sGeometry.center().x() - size.width() / 2 setPosition(sGeometry.center().x() - size.width() / 2
, m_dockView->currentThickness()); , m_dockView->currentThickness());
@ -109,7 +109,7 @@ void NowDockConfigView::syncGeometry()
setMaximumSize(size); setMaximumSize(size);
setMinimumSize(size); setMinimumSize(size);
resize(size); resize(size);
if (location == Plasma::Types::LeftEdge) { if (location == Plasma::Types::LeftEdge) {
setPosition(m_dockView->currentThickness() setPosition(m_dockView->currentThickness()
, sGeometry.center().y() - size.height() / 2); , sGeometry.center().y() - size.height() / 2);
@ -131,26 +131,26 @@ void NowDockConfigView::syncSlideEffect()
{ {
if (!m_containment) if (!m_containment)
return; return;
KWindowEffects::SlideFromLocation slideLocation{KWindowEffects::NoEdge}; KWindowEffects::SlideFromLocation slideLocation{KWindowEffects::NoEdge};
switch (m_containment->location()) { switch (m_containment->location()) {
case Plasma::Types::TopEdge: case Plasma::Types::TopEdge:
slideLocation = KWindowEffects::TopEdge; slideLocation = KWindowEffects::TopEdge;
break; break;
case Plasma::Types::RightEdge: case Plasma::Types::RightEdge:
slideLocation = KWindowEffects::RightEdge; slideLocation = KWindowEffects::RightEdge;
break; break;
case Plasma::Types::BottomEdge: case Plasma::Types::BottomEdge:
slideLocation = KWindowEffects::BottomEdge; slideLocation = KWindowEffects::BottomEdge;
break; break;
case Plasma::Types::LeftEdge: case Plasma::Types::LeftEdge:
slideLocation = KWindowEffects::LeftEdge; slideLocation = KWindowEffects::LeftEdge;
break; break;
default: default:
qDebug() << staticMetaObject.className() << "wrong location";// << qEnumToStr(m_containment->location()); qDebug() << staticMetaObject.className() << "wrong location";// << qEnumToStr(m_containment->location());
break; break;
@ -172,7 +172,7 @@ void NowDockConfigView::showEvent(QShowEvent *ev)
if (m_containment) if (m_containment)
m_containment->setUserConfiguring(true); m_containment->setUserConfiguring(true);
// m_dockView->visibility()->forceShow(true); // m_dockView->visibility()->forceShow(true);
// m_dockView->visibility()->showImmediately(); // m_dockView->visibility()->showImmediately();
m_screenSyncTimer.start(); m_screenSyncTimer.start();
@ -196,12 +196,22 @@ void NowDockConfigView::hideEvent(QHideEvent *ev)
void NowDockConfigView::focusOutEvent(QFocusEvent *ev) void NowDockConfigView::focusOutEvent(QFocusEvent *ev)
{ {
//FIXME: I can understand why we need to hide on focus out
Q_UNUSED(ev); Q_UNUSED(ev);
const auto *focusWindow = qGuiApp->focusWindow(); const auto *focusWindow = qGuiApp->focusWindow();
if (focusWindow && focusWindow->flags().testFlag(Qt::Popup)) if (focusWindow && focusWindow->flags().testFlag(Qt::Popup))
return; return;
hide();
// hide();
} }
void NowDockConfigView::immutabilityChanged(Plasma::Types::ImmutabilityType type)
{
if (type != Plasma::Types::Mutable && isVisible()) {
hide();
}
}
// kate: indent-mode cstyle; indent-width 4; replace-tabs on; // kate: indent-mode cstyle; indent-width 4; replace-tabs on;

@ -21,6 +21,7 @@
#define NOWDOCKCONFIGVIEW_H #define NOWDOCKCONFIGVIEW_H
#include "plasmaquick/configview.h" #include "plasmaquick/configview.h"
#include <plasma/package.h>
#include <QObject> #include <QObject>
#include <QWindow> #include <QWindow>
@ -30,6 +31,7 @@
namespace Plasma { namespace Plasma {
class Applet; class Applet;
class Containment; class Containment;
class Types;
} }
class NowDockView; class NowDockView;
@ -51,6 +53,9 @@ protected:
void syncGeometry(); void syncGeometry();
void syncSlideEffect(); void syncSlideEffect();
private Q_SLOTS:
void immutabilityChanged(Plasma::Types::ImmutabilityType type);
private: private:
Plasma::Containment *m_containment{nullptr}; Plasma::Containment *m_containment{nullptr};

Loading…
Cancel
Save