diff --git a/app/dockconfigview.cpp b/app/dockconfigview.cpp index ebed24786..de202637a 100644 --- a/app/dockconfigview.cpp +++ b/app/dockconfigview.cpp @@ -197,6 +197,8 @@ void DockConfigView::showEvent(QShowEvent *ev) m_screenSyncTimer.start(); QTimer::singleShot(400, this, &DockConfigView::syncGeometry); + m_previousMode = m_dockView->visibility()->mode(); + emit showSignal(); } @@ -207,6 +209,17 @@ void DockConfigView::hideEvent(QHideEvent *ev) QQuickWindow::hideEvent(ev); + if (m_dockView->visibility()->mode() != m_previousMode + && ((m_dockView->visibility()->mode() == Dock::AlwaysVisible) + || (m_previousMode == Dock::AlwaysVisible))) { + + auto *dockCorona = qobject_cast(m_dockView->corona()); + + if (dockCorona) { + dockCorona->recreateDock(m_dockView->containment()); + } + } + deleteLater(); } diff --git a/app/dockconfigview.h b/app/dockconfigview.h index 5a966ce4e..acbcb6c1f 100644 --- a/app/dockconfigview.h +++ b/app/dockconfigview.h @@ -22,6 +22,8 @@ #define NOWDOCKCONFIGVIEW_H #include "plasmaquick/configview.h" +#include "../liblattedock/dock.h" + #include #include @@ -76,6 +78,8 @@ private: QTimer m_screenSyncTimer; QList connections; + + Dock::Visibility m_previousMode{Dock::None}; }; } diff --git a/app/dockcorona.cpp b/app/dockcorona.cpp index 2eb2645f8..122c4518b 100644 --- a/app/dockcorona.cpp +++ b/app/dockcorona.cpp @@ -717,7 +717,18 @@ void DockCorona::addDock(Plasma::Containment *containment) qDebug() << "Adding dock for container..."; qDebug() << "onPrimary: " << onPrimary << "screen!!! :" << containment->screen() << " - " << m_screenPool->connector(containment->screen()); - auto dockView = new DockView(this, nextScreen); + + //! it is used to set the correct flag during the creation + //! of the window... This of course is also used during + //! recreations of the window between different visibility modes + auto mode = static_cast(containment->config().readEntry("visibility", static_cast(Dock::DodgeActive))); + bool alwaysVisible{false}; + + if (mode == Latte::Dock::AlwaysVisible) { + alwaysVisible = true; + } + + auto dockView = new DockView(this, nextScreen, alwaysVisible); dockView->init(); dockView->setContainment(containment); @@ -738,6 +749,17 @@ void DockCorona::addDock(Plasma::Containment *containment) emit docksCountChanged(); } +void DockCorona::recreateDock(Plasma::Containment *containment) +{ + auto view = m_dockViews.take(containment); + + if (view) { + view->setVisible(false); + view->deleteLater(); + addDock(view->containment()); + } +} + void DockCorona::destroyedChanged(bool destroyed) { qDebug() << "dock containment destroyed changed!!!!"; diff --git a/app/dockcorona.h b/app/dockcorona.h index d84dd757d..b9499044e 100644 --- a/app/dockcorona.h +++ b/app/dockcorona.h @@ -63,6 +63,7 @@ public: int screenForContainment(const Plasma::Containment *containment) const override; void addDock(Plasma::Containment *containment); + void recreateDock(Plasma::Containment *containment); void aboutApplication(); void closeApplication(); diff --git a/app/dockview.cpp b/app/dockview.cpp index 96a84e852..2e105cb07 100644 --- a/app/dockview.cpp +++ b/app/dockview.cpp @@ -45,7 +45,7 @@ namespace Latte { -DockView::DockView(Plasma::Corona *corona, QScreen *targetScreen) +DockView::DockView(Plasma::Corona *corona, QScreen *targetScreen, bool alwaysVisible) : PlasmaQuick::ContainmentView(corona), m_contextMenu(nullptr) { @@ -54,10 +54,19 @@ DockView::DockView(Plasma::Corona *corona, QScreen *targetScreen) setIcon(QIcon::fromTheme(corona->kPackage().metadata().iconName())); setResizeMode(QuickViewSharedEngine::SizeRootObjectToView); setClearBeforeRendering(true); - setFlags(Qt::FramelessWindowHint - | Qt::WindowStaysOnTopHint - | Qt::NoDropShadowWindowHint - | Qt::WindowDoesNotAcceptFocus); + + if (!alwaysVisible) { + setFlags(Qt::BypassWindowManagerHint + | Qt::FramelessWindowHint + | Qt::WindowStaysOnTopHint + | Qt::NoDropShadowWindowHint + | Qt::WindowDoesNotAcceptFocus); + } else { + setFlags(Qt::FramelessWindowHint + | Qt::WindowStaysOnTopHint + | Qt::NoDropShadowWindowHint + | Qt::WindowDoesNotAcceptFocus); + } if (targetScreen) setScreenToFollow(targetScreen); @@ -136,9 +145,13 @@ void DockView::init() connect(qGuiApp, &QGuiApplication::primaryScreenChanged, this, &DockView::screenChanged); connect(this, &DockView::screenGeometryChanged, this, &DockView::syncGeometry); connect(this, &QQuickWindow::xChanged, this, &DockView::xChanged); + connect(this, &QQuickWindow::xChanged, this, &DockView::updateAbsDockGeometry); connect(this, &QQuickWindow::yChanged, this, &DockView::yChanged); + connect(this, &QQuickWindow::yChanged, this, &DockView::updateAbsDockGeometry); connect(this, &QQuickWindow::widthChanged, this, &DockView::widthChanged); + connect(this, &QQuickWindow::widthChanged, this, &DockView::updateAbsDockGeometry); connect(this, &QQuickWindow::heightChanged, this, &DockView::heightChanged); + connect(this, &QQuickWindow::heightChanged, this, &DockView::updateAbsDockGeometry); connect(corona(), &Plasma::Corona::availableScreenRectChanged, this, [&]() { if (formFactor() == Plasma::Types::Vertical) @@ -481,13 +494,19 @@ void DockView::resizeWindow(QRect availableScreenRect) void DockView::setLocalDockGeometry(const QRect &geometry) { - updateAbsDockGeometry(geometry); + if (m_localGeometry == geometry) { + return; + } + + m_localGeometry = geometry; + + updateAbsDockGeometry(); } -void DockView::updateAbsDockGeometry(const QRect &localDockGeometry) +void DockView::updateAbsDockGeometry() { - QRect absGeometry {x() + localDockGeometry.x(), y() + localDockGeometry.y() - , localDockGeometry.width() - 1, localDockGeometry.height() - 1}; + QRect absGeometry {x() + m_localGeometry.x(), y() + m_localGeometry.y() + , m_localGeometry.width() - 1, m_localGeometry.height() - 1}; if (m_absGeometry == absGeometry) return; diff --git a/app/dockview.h b/app/dockview.h index 8fe7987a6..7f665d8ec 100644 --- a/app/dockview.h +++ b/app/dockview.h @@ -71,7 +71,7 @@ class DockView : public PlasmaQuick::ContainmentView { Q_PROPERTY(QRect screenGeometry READ screenGeometry NOTIFY screenGeometryChanged) public: - DockView(Plasma::Corona *corona, QScreen *targetScreen = nullptr); + DockView(Plasma::Corona *corona, QScreen *targetScreen = nullptr, bool alwaysVisible = false); virtual ~DockView(); void init(); @@ -109,7 +109,6 @@ public: QRect maskArea() const; void setMaskArea(QRect area); - void updateAbsDockGeometry(const QRect &localDockGeometry); QRect absGeometry() const; QRect screenGeometry() const; @@ -139,6 +138,8 @@ public slots: Q_INVOKABLE void closeApplication(); + void updateAbsDockGeometry(); + protected slots: void showConfigurationInterface(Plasma::Applet *applet) override; @@ -203,6 +204,7 @@ private: Dock::Alignment m_alignment{Dock::Center}; + QRect m_localGeometry; QRect m_absGeometry; QRect m_maskArea; QMenu *m_contextMenu; diff --git a/containment/contents/ui/VisibilityManager.qml b/containment/contents/ui/VisibilityManager.qml index 867a7b58d..226705d01 100644 --- a/containment/contents/ui/VisibilityManager.qml +++ b/containment/contents/ui/VisibilityManager.qml @@ -63,8 +63,6 @@ Item{ property int thicknessZoomOriginal: Math.max(statesLineSizeOriginal + ((plasmoid.configuration.iconSize+iconMarginOriginal) * root.zoomFactor) + 2, root.realPanelSize + root.panelShadow) - property rect localGeometry: Qt.rect(-1,-1,0,0) - Binding{ target: dock property:"maxThickness" @@ -309,7 +307,7 @@ Item{ } } - // console.log("update mask area:"+newMaskArea); + //console.log("reached updating geometry ::: "+dock.maskArea); if((normalState && !dock.visibility.isHidden) || root.editMode){ var tempGeometry = Qt.rect(dock.maskArea.x, dock.maskArea.y, dock.maskArea.width, dock.maskArea.height); @@ -338,12 +336,8 @@ Item{ tempGeometry.height = Math.min(tempGeometry.height, dock.height); } - if (localGeometry.x !== tempGeometry.x || localGeometry.y !== tempGeometry.y - || localGeometry.width !== tempGeometry.width || localGeometry.height !== tempGeometry.height) { - localGeometry = tempGeometry; - dock.setLocalDockGeometry(localGeometry); - } - // console.log("update dock geometry:"+newMaskArea); + //console.log("update geometry ::: "+tempGeometry); + dock.setLocalDockGeometry(tempGeometry); } }