1
0
mirror of https://github.com/KDE/latte-dock.git synced 2025-01-12 01:17:55 +03:00

support new visibilitymanager in ui

-- small fixes in visibilitymanager and removed
some whitespaces also
This commit is contained in:
Michail Vourlakos 2016-12-30 13:46:56 +02:00
parent 4c10939484
commit df08a92d0e
7 changed files with 100 additions and 101 deletions

View File

@ -475,19 +475,7 @@ VisibilityManager *NowDockView::visibility()
bool NowDockView::event(QEvent *e)
{
/* if (ev->type() == QEvent::Enter) {
m_visibility->show();
emit entered();
} else if (ev->type() == QEvent::Leave) {
m_visibility->restore();
emit exited();
} */
//return QQuickWindow::event(e);
if (m_visibility) {
m_visibility->event(e);
}
emit eventTriggered(e);
return ContainmentView::event(e);
}

View File

@ -124,6 +124,7 @@ protected:
signals:
// void visibilityChanged();
void addInternalViewSplitter();
void eventTriggered(QEvent *ev);
void alignmentChanged();
void compositingChanged();
void heightChanged();

View File

@ -4,12 +4,20 @@
#include "../liblattedock/extras.h"
#include "nowdockview.h"
namespace Latte {
//! BEGIN: VisiblityManagerPrivate implementation
VisibilityManagerPrivate::VisibilityManagerPrivate(PlasmaQuick::ContainmentView *view, VisibilityManager *q)
: QObject(view), q(q), view(view), wm(AbstractWindowInterface::getInstance(view, nullptr))
{
NowDockView *dockView = dynamic_cast<NowDockView *>(view);
if (dockView) {
connect(dockView, &NowDockView::eventTriggered, q, &VisibilityManager::eventReceived);
}
timerCheckWindows.setInterval(350);
timerCheckWindows.setSingleShot(true);
@ -34,11 +42,11 @@ inline void VisibilityManagerPrivate::setMode(Dock::Visibility mode)
{
if (this->mode == mode)
return;
// clear mode
if (this->mode == Dock::AlwaysVisible)
wm->removeDockStruts();
for (auto &c : connections) {
disconnect(c);
}
@ -60,31 +68,31 @@ inline void VisibilityManagerPrivate::setMode(Dock::Visibility mode)
raiseDock(true);
}
break;
case Dock::DodgeActive: {
connections[0] = connect(wm.get(), &AbstractWindowInterface::activeWindowChanged
, this, &VisibilityManagerPrivate::dodgeActive);
connections[1] = connect(wm.get(), &AbstractWindowInterface::windowChanged
, this, &VisibilityManagerPrivate::dodgeActive);
dodgeActive(wm->activeWindow());
}
break;
case Dock::DodgeMaximized: {
connections[0] = connect(wm.get(), &AbstractWindowInterface::windowChanged
, this, &VisibilityManagerPrivate::dodgeMaximized);
}
break;
case Dock::DodgeAllWindows: {
for (const auto &wid : wm->windows()) {
windows.insert({wid, wm->requestInfo(wid)});
}
connections[0] = connect(wm.get(), &AbstractWindowInterface::windowChanged
, this, &VisibilityManagerPrivate::dodgeWindows);
connections[1] = connect(wm.get(), &AbstractWindowInterface::windowRemoved
, this, [&](WId wid) {
windows.erase(wid);
@ -99,13 +107,15 @@ inline void VisibilityManagerPrivate::setMode(Dock::Visibility mode)
}
saveConfig();
emit q->modeChanged();
}
inline void VisibilityManagerPrivate::setIsHidden(bool isHidden)
{
if (this->isHidden == isHidden)
return;
this->isHidden = isHidden;
emit q->isHiddenChanged();
}
@ -130,15 +140,18 @@ inline void VisibilityManagerPrivate::raiseDock(bool raise)
/* if (!isHidden == raise) {
return;
} */
if (raise) {
timerHide.stop();
if (!timerShow.isActive())
if (!timerShow.isActive() && mode != Dock::AutoHide) {
timerShow.start();
} else {
emit q->mustBeShown();
}
} else {
timerShow.stop();
if (!timerHide.isActive())
timerHide.start();
}
@ -148,7 +161,7 @@ inline void VisibilityManagerPrivate::setDockRect(const QRect &dockRect)
{
if (!view->containment() || this->dockRect == dockRect)
return;
this->dockRect = dockRect;
if (mode == Dock::AlwaysVisible) {
@ -160,12 +173,12 @@ void VisibilityManagerPrivate::dodgeActive(WId wid)
{
if (wid != wm->activeWindow())
return;
auto winfo = wm->requestInfo(wid);
if (!winfo.isValid() || !winfo.isOnCurrentDesktop() || winfo.isMinimized())
return;
raiseDock(intersects(winfo));
}
@ -173,12 +186,12 @@ void VisibilityManagerPrivate::dodgeMaximized(WId wid)
{
if (wid != wm->activeWindow())
return;
auto winfo = wm->requestInfo(wid);
if (!winfo.isValid() || !winfo.isOnCurrentDesktop() || winfo.isMinimized())
return;
raiseDock(winfo.isMaximized());
}
@ -188,7 +201,7 @@ void VisibilityManagerPrivate::dodgeWindows(WId wid)
if (!winfo.isValid() || !winfo.isOnCurrentDesktop() || winfo.isMinimized())
return;
if (intersects(winfo))
raiseDock(false);
else
@ -203,7 +216,7 @@ void VisibilityManagerPrivate::checkAllWindows()
//! std::pair<WId, WindowInfoWrap>
if (!std::get<1>(winfo).isValid() || !std::get<1>(winfo).isOnCurrentDesktop())
continue;
if (std::get<1>(winfo).isFullscreen()) {
raise = false;
break;
@ -229,7 +242,7 @@ inline void VisibilityManagerPrivate::saveConfig()
{
if (!view->containment())
return;
auto config = view->containment()->config();
config.writeEntry("visibility", static_cast<int>(mode));
@ -243,7 +256,7 @@ inline void VisibilityManagerPrivate::restoreConfig()
{
if (!view->containment())
return;
auto config = view->containment()->config();
mode = static_cast<Dock::Visibility>(config.readEntry("visibility", static_cast<int>(Dock::DodgeActive)));
@ -259,14 +272,14 @@ bool VisibilityManagerPrivate::event(QEvent *ev)
if (mode == Dock::AutoHide)
raiseDock(true);
} else if (ev->type() == QEvent::Leave && containsMouse) {
containsMouse = false;
emit q->containsMouseChanged();
if (mode == Dock::AutoHide)
raiseDock(false);
} else if (ev->type() == QEvent::Show) {
wm->setDockDefaultFlags();
}
@ -338,13 +351,13 @@ void VisibilityManager::updateDockGeometry(const QRect &geometry)
d->setDockRect(geometry);
}
void VisibilityManager::eventReceived(QEvent *ev)
{
d->event(ev);
}
//! END: VisibilityManager implementation
}
#include "abstractwindowinterface.h"
#include "xwindowinterface.h"
#include "plasmaquick/containmentview.h"

View File

@ -44,7 +44,10 @@ public:
* @brief updateDockGeometry, the window geometry in absolute coordinates.
*/
void updateDockGeometry(const QRect &geometry);
public Q_SLOTS:
void eventReceived(QEvent *);
signals:
void mustBeShown();
void mustBeHide();

View File

@ -36,15 +36,6 @@ Item{
property int thicknessNormalOriginalValue: statesLineSizeOriginal + plasmoid.configuration.iconSize + iconMarginOriginal + 1
property int thicknessZoomOriginal: statesLineSizeOriginal + ((plasmoid.configuration.iconSize+iconMarginOriginal) * root.zoomFactor) + 2
Binding{
//this is way to avoid warnings for null during initialization phase
target: dock ? dock.visibility : manager
property:"panelVisibility"
when: dock && dock.visibility
value: plasmoid.configuration.panelVisibility
}
Binding{
target: dock ? dock : manager
property:"maxThickness"
@ -71,22 +62,22 @@ Item{
onThicknessZoomOriginalChanged: updateMaskArea();
function slotDisableHidingChanged() {
if (!dock.visibility.disableHiding) {
/*if (!dock.visibility.disableHiding) {
checkListHovered.restart();
}
}*/
}
function slotIsHoveredChanged() {
if(dock.visibility.isHovered) {
function slotContainsMouseChanged() {
if(dock.visibility.containsMouse) {
//stop parent window timer for auto hiding
if ((dock.visibility.panelVisibility === Latte.Dock.AutoHide)|| dock.visibility.isDockWindowType) {
/* if (dock.visibility.mode === Latte.Dock.AutoHide) {
if(hideMagicWindowInAutoHide.forcedDisableHiding) {
hideMagicWindowInAutoHide.forcedDisableHiding = false;
dock.visibility.disableHiding = false;
}
hideMagicWindowInAutoHide.stop();
}
}*/
if (delayerTimer.running) {
delayerTimer.stop();
@ -99,29 +90,23 @@ Item{
}
}
function slotMustBeRaised() {
if ((dock.visibility.panelVisibility === Latte.Dock.AutoHide) || dock.visibility.isDockWindowType) {
slidingAnimationAutoHiddenIn.init();
} else {
slidingAnimation.init(true,false);
}
function slotMustBeShown() {
console.log("show...");
slidingAnimationAutoHiddenIn.init();
}
function slotMustBeRaisedImmediately() {
slidingAnimation.init(true,true);
}
function slotMustBeLowered() {
if ((dock.visibility.panelVisibility === Latte.Dock.AutoHide) || dock.visibility.isDockWindowType ) {
slidingAnimationAutoHiddenOut.init();
} else {
slidingAnimation.init(false,false);
}
function slotMustBeHide() {
console.log("hide....");
slidingAnimationAutoHiddenOut.init();
}
function slotPanelVisibilityChanged() {
if (dock.visibility.panelVisibility !== Latte.Dock.AutoHide) {
dock.visibility.isAutoHidden = false;
function slotModeChanged() {
if (dock.visibility.mode !== Latte.Dock.AutoHide) {
dock.visibility.isHidden = false;
}
}
@ -164,7 +149,7 @@ Item{
tempThickness = thicknessMidOriginal;
}
if (dock.visibility.isAutoHidden && ((dock.visibility.panelVisibility === Latte.Dock.AutoHide) || dock.visibility.isDockWindowType)) {
if (dock.visibility.isHidden && (dock.visibility.mode === Latte.Dock.AutoHide)) {
tempThickness = thicknessAutoHidden;
}
@ -358,7 +343,7 @@ Item{
}
onStopped: {
dock.visibility.isAutoHidden = true;
dock.visibility.isHidden = true;
updateMaskArea();
}
@ -385,7 +370,7 @@ Item{
}
function init() {
dock.visibility.isAutoHidden = false;
dock.visibility.isHidden = false;
updateMaskArea();
start();
}
@ -396,12 +381,12 @@ Item{
onCurrentActivityChanged: {
dock.visibility.disableHiding = true;
if (dock.visibility.isAutoHidden) {
dock.visibility.mustBeRaised();
if (dock.visibility.isHidden) {
dock.visibility.mustBeShown();
}
hideMagicWindowInAutoHide.forcedDisableHiding = true;
hideMagicWindowInAutoHide.start();
// hideMagicWindowInAutoHide.forcedDisableHiding = true;
// hideMagicWindowInAutoHide.start();
}
}
@ -424,9 +409,9 @@ Item{
interval: manager.inStartup ? 1000 : 500
onTriggered: {
layoutsContainer.opacity = 1;
if ((dock.visibility.panelVisibility !== Latte.Dock.AutoHide) && !dock.visibility.isDockWindowType) {
slidingAnimation.init(true,false);
} else {
if (dock.visibility.mode !== Latte.Dock.AutoHide) {
/*slidingAnimation.init(true,false);
} else {*/
slidingAnimationAutoHiddenIn.init();
}
}

View File

@ -398,12 +398,15 @@ DragDrop.DropArea {
dock.onWidthChanged.connect(visibilityManager.updateMaskArea);
dock.onHeightChanged.connect(visibilityManager.updateMaskArea);
dock.visibility.onDisableHidingChanged.connect(visibilityManager.slotDisableHidingChanged);
dock.visibility.onIsHoveredChanged.connect(visibilityManager.slotIsHoveredChanged);
dock.visibility.onMustBeLowered.connect(visibilityManager.slotMustBeLowered);
dock.visibility.onMustBeRaised.connect(visibilityManager.slotMustBeRaised);
dock.visibility.onMustBeRaisedImmediately.connect(visibilityManager.slotMustBeRaisedImmediately);
dock.visibility.onPanelVisibilityChanged.connect(visibilityManager.slotPanelVisibilityChanged);
dock.visibility.timerShow = 1000;
dock.visibility.timerHide = 1000;
//dock.visibility.onDisableHidingChanged.connect(visibilityManager.slotDisableHidingChanged);
dock.visibility.onContainsMouseChanged.connect(visibilityManager.slotContainsMouseChanged);
dock.visibility.onMustBeHide.connect(visibilityManager.slotMustBeHide);
dock.visibility.onMustBeShown.connect(visibilityManager.slotMustBeShown);
//dock.visibility.onMustBeRaisedImmediately.connect(visibilityManager.slotMustBeRaisedImmediately);
dock.visibility.onModeChanged.connect(visibilityManager.slotModeChanged);
}
}
@ -439,9 +442,9 @@ DragDrop.DropArea {
}
onIsHoveredChanged: {
if (isHovered){
/*if (isHovered){
dock.visibility.showOnTopCheck();
}
}*/
}
onHeightChanged: {
@ -584,16 +587,16 @@ DragDrop.DropArea {
}
}
if (plasmoid.immutable) {
/* if (plasmoid.immutable) {
if (windowSystem.compositingActive) {
// magicWin.initialize();
magicWin.initialize();
}
dock.visibility.disableHiding = false;
} else {
dock.visibility.disableHiding = true;
dock.visibility.mustBeRaised();
}
}*/
visibilityManager.updateMaskArea();
@ -749,7 +752,7 @@ DragDrop.DropArea {
animatedLengthTimer.start();
}
if (!dock.visibility.isHovered && (root.animationsNeedBothAxis === 0)
if (!dock.visibility.containsMouse && (root.animationsNeedBothAxis === 0)
&& (root.animationsNeedLength===0) && (root.appletsAnimations === 0)) {
mainLayout.animatedLength = true;
} else {
@ -761,9 +764,9 @@ DragDrop.DropArea {
function clearZoom(){
//console.log("Panel clear....");
if (dock.visibility.disableHiding) {
/* if (dock.visibility.disableHiding) {
return;
}
} */
layoutsContainer.currentSpot = -1000;
layoutsContainer.hoveredIndex = -1;
@ -871,7 +874,7 @@ DragDrop.DropArea {
}
function slotDisableHiding(value) {
dock.visibility.disableHiding = value;
// dock.visibility.disableHiding = value;
}
function updateAutomaticIconSize() {
@ -1251,17 +1254,17 @@ DragDrop.DropArea {
property bool forcedDisableHiding: false
onTriggered: {
if (forcedDisableHiding) {
/* if (forcedDisableHiding) {
forcedDisableHiding = false;
dock.visibility.disableHiding = false;
}
var visibility = dock.visibility;
if (plasmoid.immutable && !visibility.isHovered //&& !wholeArea.containsMouse
&& ((visibility.panelVisibility === Latte.Dock.AutoHide) || visibility.isDockWindowType) ) {
visibility.mustBeLowered();
}
if (plasmoid.immutable && !visibility.containsMouse //&& !wholeArea.containsMouse
&& (visibility.movde === Latte.Dock.AutoHide) ) {
visibility.mustBeHide();
}*/
}
}

View File

@ -375,6 +375,7 @@ PlasmaCore.FrameSvgItem {
onCheckedChanged: {
if(checked && !parent.inStartup){
dock.visibility.mode = Latte.Dock.AlwaysVisible
plasmoid.configuration.panelVisibility = 0
}
}
@ -388,6 +389,7 @@ PlasmaCore.FrameSvgItem {
onCheckedChanged: {
if(checked && !parent.inStartup){
dock.visibility.mode = Latte.Dock.AutoHide
plasmoid.configuration.panelVisibility = 1
}
}
@ -401,6 +403,7 @@ PlasmaCore.FrameSvgItem {
onCheckedChanged: {
if(checked && !parent.inStartup){
dock.visibility.mode = Latte.Dock.DodgeActive
plasmoid.configuration.panelVisibility = 2
}
}
@ -415,6 +418,7 @@ PlasmaCore.FrameSvgItem {
onCheckedChanged: {
if(checked && !parent.inStartup){
dock.visibility.mode = Latte.Dock.DodgeMaximized
plasmoid.configuration.panelVisibility = 3
}
}
@ -429,6 +433,7 @@ PlasmaCore.FrameSvgItem {
onCheckedChanged: {
if(checked && !parent.inStartup){
dock.visibility.mode = Latte.Dock.DodgeWindows
plasmoid.configuration.panelVisibility = 4
}
}
@ -442,6 +447,7 @@ PlasmaCore.FrameSvgItem {
onCheckedChanged: {
if(checked && !parent.inStartup){
dock.visibility.mode = Latte.Dock.AlwaysVisible
plasmoid.configuration.panelVisibility = 5
}
}