added blockHiding property on visibilitymanager

v0.6
audoban 8 years ago
parent 3b7ab77ecb
commit 53cb0f2522

@ -32,7 +32,7 @@ VisibilityManagerPrivate::VisibilityManagerPrivate(PlasmaQuick::ContainmentView
} }
}); });
connect(&timerHide, &QTimer::timeout, this, [this]() { connect(&timerHide, &QTimer::timeout, this, [this]() {
if (!isHidden) { if (!blockHiding && !isHidden) {
qDebug() << "must be hide"; qDebug() << "must be hide";
emit this->q->mustBeHide(); emit this->q->mustBeHide();
} }
@ -146,10 +146,34 @@ inline void VisibilityManagerPrivate::setIsHidden(bool isHidden)
if (this->isHidden == isHidden) if (this->isHidden == isHidden)
return; return;
if (blockHiding) {
qWarning() << "isHidden property is blocked, ignoring update";
return;
}
this->isHidden = isHidden; this->isHidden = isHidden;
emit q->isHiddenChanged(); emit q->isHiddenChanged();
} }
void VisibilityManagerPrivate::setBlockHiding(bool blockHiding)
{
if (this->blockHiding == blockHiding)
return;
this->blockHiding = blockHiding;
if (this->blockHiding) {
timerHide.stop();
if (isHidden)
isHidden = false;
} else {
updateHiddenState();
}
emit q->blockHidingChanged();
}
inline void VisibilityManagerPrivate::setTimerShow(int msec) inline void VisibilityManagerPrivate::setTimerShow(int msec)
{ {
timerShow.setInterval(msec); timerShow.setInterval(msec);
@ -172,7 +196,7 @@ inline void VisibilityManagerPrivate::raiseDock(bool raise)
if (!timerShow.isActive()) { if (!timerShow.isActive()) {
timerShow.start(); timerShow.start();
} }
} else { } else if (!blockHiding) {
timerShow.stop(); timerShow.stop();
if (!timerHide.isActive()) if (!timerHide.isActive())
@ -180,6 +204,27 @@ inline void VisibilityManagerPrivate::raiseDock(bool raise)
} }
} }
void VisibilityManagerPrivate::updateHiddenState()
{
switch (mode) {
case Dock::AutoHide:
raiseDock(false);
break;
case Dock::DodgeActive:
dodgeActive(wm->activeWindow());
break;
case Dock::DodgeMaximized:
dodgeMaximized(wm->activeWindow());
break;
case Dock::DodgeAllWindows:
dodgeWindows(wm->activeWindow());
break;
}
}
inline void VisibilityManagerPrivate::setDockRect(const QRect &dockRect) inline void VisibilityManagerPrivate::setDockRect(const QRect &dockRect)
{ {
if (!view->containment() || this->dockRect == dockRect) if (!view->containment() || this->dockRect == dockRect)
@ -314,24 +359,7 @@ bool VisibilityManagerPrivate::event(QEvent *ev)
containsMouse = false; containsMouse = false;
emit q->containsMouseChanged(); emit q->containsMouseChanged();
switch (mode) { updateHiddenState();
case Dock::AutoHide:
raiseDock(false);
break;
case Dock::DodgeActive:
dodgeActive(wm->activeWindow());
break;
case Dock::DodgeMaximized:
dodgeMaximized(wm->activeWindow());
break;
case Dock::DodgeAllWindows:
dodgeWindows(wm->activeWindow());
break;
}
} else if (ev->type() == QEvent::Show) { } else if (ev->type() == QEvent::Show) {
wm->setDockDefaultFlags(); wm->setDockDefaultFlags();
} }
@ -372,6 +400,16 @@ void VisibilityManager::setIsHidden(bool isHidden)
d->setIsHidden(isHidden); d->setIsHidden(isHidden);
} }
bool VisibilityManager::blockHiding() const
{
return d->blockHiding;
}
void VisibilityManager::setBlockHiding(bool blockHiding)
{
d->setBlockHiding(blockHiding);
}
bool VisibilityManager::containsMouse() const bool VisibilityManager::containsMouse() const
{ {
return d->containsMouse; return d->containsMouse;

@ -18,6 +18,7 @@ class VisibilityManager : public QObject {
Q_PROPERTY(Latte::Dock::Visibility mode READ mode WRITE setMode NOTIFY modeChanged) Q_PROPERTY(Latte::Dock::Visibility mode READ mode WRITE setMode NOTIFY modeChanged)
Q_PROPERTY(bool isHidden READ isHidden WRITE setIsHidden NOTIFY isHiddenChanged) Q_PROPERTY(bool isHidden READ isHidden WRITE setIsHidden NOTIFY isHiddenChanged)
Q_PROPERTY(bool blockHiding READ blockHiding WRITE setBlockHiding NOTIFY blockHidingChanged)
Q_PROPERTY(bool containsMouse READ containsMouse NOTIFY containsMouseChanged) Q_PROPERTY(bool containsMouse READ containsMouse NOTIFY containsMouseChanged)
Q_PROPERTY(int timerShow READ timerShow WRITE setTimerShow NOTIFY timerShowChanged) Q_PROPERTY(int timerShow READ timerShow WRITE setTimerShow NOTIFY timerShowChanged)
Q_PROPERTY(int timerHide READ timerHide WRITE setTimerHide NOTIFY timerHideChanged) Q_PROPERTY(int timerHide READ timerHide WRITE setTimerHide NOTIFY timerHideChanged)
@ -32,6 +33,9 @@ public:
bool isHidden() const; bool isHidden() const;
void setIsHidden(bool isHidden); void setIsHidden(bool isHidden);
bool blockHiding() const;
void setBlockHiding(bool blockHiding);
bool containsMouse() const; bool containsMouse() const;
int timerShow() const; int timerShow() const;
@ -51,6 +55,7 @@ signals:
void modeChanged(); void modeChanged();
void isHiddenChanged(); void isHiddenChanged();
void blockHidingChanged();
void containsMouseChanged(); void containsMouseChanged();
void timerShowChanged(); void timerShowChanged();
void timerHideChanged(); void timerHideChanged();

@ -30,10 +30,12 @@ public:
void setMode(Dock::Visibility mode); void setMode(Dock::Visibility mode);
void setIsHidden(bool isHidden); void setIsHidden(bool isHidden);
void setBlockHiding(bool blockHiding);
void setTimerShow(int msec); void setTimerShow(int msec);
void setTimerHide(int msec); void setTimerHide(int msec);
void raiseDock(bool raise); void raiseDock(bool raise);
void updateHiddenState();
void setDockRect(const QRect &rect); void setDockRect(const QRect &rect);
@ -61,6 +63,7 @@ public:
QTimer timerCheckWindows; QTimer timerCheckWindows;
QRect dockRect; QRect dockRect;
bool isHidden{false}; bool isHidden{false};
bool blockHiding{false};
bool containsMouse{false}; bool containsMouse{false};
}; };

Loading…
Cancel
Save