upgrade to LatteApp.Interfaces containment access

pull/15/head
Michail Vourlakos 5 years ago
parent 6259c395de
commit 9be7822b98

@ -8,6 +8,7 @@ set(lattedock-app_SRCS
coretypes.h coretypes.h
) )
add_subdirectory(declarativeimports)
add_subdirectory(indicator) add_subdirectory(indicator)
add_subdirectory(layout) add_subdirectory(layout)
add_subdirectory(layouts) add_subdirectory(layouts)

@ -0,0 +1,5 @@
set(lattedock-app_SRCS
${lattedock-app_SRCS}
${CMAKE_CURRENT_SOURCE_DIR}/interfaces.cpp
PARENT_SCOPE
)

@ -0,0 +1,79 @@
/*
* Copyright 2020 Michail Vourlakos <mvourlakos@gmail.com>
*
* This file is part of Latte-Dock
*
* Latte-Dock is free software; you can redistribute it and/or
* modify it under the terms of the GNU General Public License as
* published by the Free Software Foundation; either version 2 of
* the License, or (at your option) any later version.
*
* Latte-Dock is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*
*/
#include "interfaces.h"
#include <PlasmaQuick/AppletQuickItem>
namespace Latte{
Interfaces::Interfaces(QObject *parent)
: QObject(parent)
{
}
QObject *Interfaces::globalShortcuts() const
{
return m_globalShortcuts;
}
QObject *Interfaces::layoutsManager() const
{
return m_layoutsManager;
}
QObject *Interfaces::themeExtended() const
{
return m_themeExtended;
}
QObject *Interfaces::universalSettings() const
{
return m_universalSettings;
}
QObject *Interfaces::view() const
{
return m_view;
}
QObject *Interfaces::plasmoidInterface() const
{
return m_plasmoid;
}
void Interfaces::setPlasmoidInterface(QObject *interface)
{
PlasmaQuick::AppletQuickItem *plasmoid = qobject_cast<PlasmaQuick::AppletQuickItem *>(interface);
if (plasmoid && m_plasmoid != plasmoid) {
m_plasmoid = plasmoid;
m_globalShortcuts = plasmoid->property("_latte_globalShortcuts_object").value<QObject *>();
m_layoutsManager = plasmoid->property("_latte_layoutsManager_object").value<QObject *>();
m_themeExtended = plasmoid->property("_latte_themeExtended_object").value<QObject *>();
m_universalSettings = plasmoid->property("_latte_universalSettings_object").value<QObject *>();
m_view = plasmoid->property("_latte_view_object").value<QObject *>();
emit interfacesChanged();
}
}
}

@ -0,0 +1,75 @@
/*
* Copyright 2020 Michail Vourlakos <mvourlakos@gmail.com>
*
* This file is part of Latte-Dock
*
* Latte-Dock is free software; you can redistribute it and/or
* modify it under the terms of the GNU General Public License as
* published by the Free Software Foundation; either version 2 of
* the License, or (at your option) any later version.
*
* Latte-Dock is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*
*/
#ifndef APPINTERFACES_H
#define APPINTERFACES_H
// Qt
#include <QObject>
// Plasma
#include <PlasmaQuick/AppletQuickItem>
namespace Latte{
class Interfaces: public QObject
{
Q_OBJECT
Q_PROPERTY(QObject *plasmoidInterface READ plasmoidInterface WRITE setPlasmoidInterface NOTIFY interfacesChanged)
Q_PROPERTY(QObject *globalShortcuts READ globalShortcuts NOTIFY interfacesChanged)
Q_PROPERTY(QObject *layoutsManager READ layoutsManager NOTIFY interfacesChanged)
Q_PROPERTY(QObject *themeExtended READ themeExtended NOTIFY interfacesChanged)
Q_PROPERTY(QObject *universalSettings READ universalSettings NOTIFY interfacesChanged)
Q_PROPERTY(QObject *view READ view NOTIFY interfacesChanged)
public:
explicit Interfaces(QObject *parent = nullptr);
QObject *globalShortcuts() const;
QObject *layoutsManager() const;
QObject *themeExtended() const;
QObject *universalSettings() const;
QObject *view() const;
QObject *plasmoidInterface() const;
void setPlasmoidInterface(QObject *interface);
signals:
void interfacesChanged();
private:
QObject *m_globalShortcuts{nullptr};
QObject *m_layoutsManager{nullptr};
QObject *m_themeExtended{nullptr};
QObject *m_universalSettings{nullptr};
QObject *m_view{nullptr};
PlasmaQuick::AppletQuickItem *m_plasmoid{nullptr};
};
}
#endif

@ -26,6 +26,7 @@
#include "apptypes.h" #include "apptypes.h"
#include "lattedockadaptor.h" #include "lattedockadaptor.h"
#include "screenpool.h" #include "screenpool.h"
#include "declarativeimports/interfaces.h"
#include "indicator/factory.h" #include "indicator/factory.h"
#include "layout/centrallayout.h" #include "layout/centrallayout.h"
#include "layout/genericlayout.h" #include "layout/genericlayout.h"
@ -1272,6 +1273,7 @@ inline void Corona::qmlRegisterTypes() const
"Error: only enums of latte app settings"); "Error: only enums of latte app settings");
qmlRegisterType<Latte::BackgroundTracker>("org.kde.latte.private.app", 0, 1, "BackgroundTracker"); qmlRegisterType<Latte::BackgroundTracker>("org.kde.latte.private.app", 0, 1, "BackgroundTracker");
qmlRegisterType<Latte::Interfaces>("org.kde.latte.private.app", 0, 1, "Interfaces");
#if QT_VERSION < QT_VERSION_CHECK(5, 14, 0) #if QT_VERSION < QT_VERSION_CHECK(5, 14, 0)

@ -895,7 +895,7 @@ void GenericLayout::addView(Plasma::Containment *containment, bool forceOnPrimar
auto latteView = new Latte::View(m_corona, nextScreen, byPassWM); auto latteView = new Latte::View(m_corona, nextScreen, byPassWM);
latteView->init(); latteView->init(containment);
latteView->setContainment(containment); latteView->setContainment(containment);
//! force this special dock case to become primary //! force this special dock case to become primary

@ -76,6 +76,8 @@ Indicator::Indicator(Latte::View *parent)
Indicator::~Indicator() Indicator::~Indicator()
{ {
unloadIndicators();
if (m_component) { if (m_component) {
m_component->deleteLater(); m_component->deleteLater();
} }

@ -182,11 +182,6 @@ View::~View()
disconnect(containment(), SIGNAL(statusChanged(Plasma::Types::ItemStatus)), this, SLOT(statusChanged(Plasma::Types::ItemStatus))); disconnect(containment(), SIGNAL(statusChanged(Plasma::Types::ItemStatus)), this, SLOT(statusChanged(Plasma::Types::ItemStatus)));
qDebug() << "dock view deleting..."; qDebug() << "dock view deleting...";
rootContext()->setContextProperty(QStringLiteral("dock"), nullptr);
rootContext()->setContextProperty(QStringLiteral("layoutsManager"), nullptr);
rootContext()->setContextProperty(QStringLiteral("shortcutsEngine"), nullptr);
rootContext()->setContextProperty(QStringLiteral("themeExtended"), nullptr);
rootContext()->setContextProperty(QStringLiteral("universalSettings"), nullptr);
//! this disconnect does not free up connections correctly when //! this disconnect does not free up connections correctly when
//! latteView is deleted. A crash for this example is the following: //! latteView is deleted. A crash for this example is the following:
@ -229,7 +224,7 @@ View::~View()
} }
} }
void View::init() void View::init(Plasma::Containment *plasma_containment)
{ {
connect(this, &QQuickWindow::xChanged, this, &View::xChanged); connect(this, &QQuickWindow::xChanged, this, &View::xChanged);
connect(this, &QQuickWindow::xChanged, this, &View::updateAbsoluteGeometry); connect(this, &QQuickWindow::xChanged, this, &View::updateAbsoluteGeometry);
@ -287,17 +282,19 @@ void View::init()
connect(m_corona->indicatorFactory(), &Latte::Indicator::Factory::indicatorRemoved, this, &View::indicatorPluginRemoved); connect(m_corona->indicatorFactory(), &Latte::Indicator::Factory::indicatorRemoved, this, &View::indicatorPluginRemoved);
///!!!!! //! Assign app interfaces in be accessible through containment graphic item
rootContext()->setContextProperty(QStringLiteral("latteView"), this); QQuickItem *containmentGraphicItem = qobject_cast<QQuickItem *>(plasma_containment->property("_plasma_graphicObject").value<QObject *>());
if (m_corona) { if (containmentGraphicItem) {
rootContext()->setContextProperty(QStringLiteral("layoutsManager"), m_corona->layoutsManager()); containmentGraphicItem->setProperty("_latte_globalShortcuts_object", QVariant::fromValue(m_corona->globalShortcuts()->shortcutsTracker()));
rootContext()->setContextProperty(QStringLiteral("shortcutsEngine"), m_corona->globalShortcuts()->shortcutsTracker()); containmentGraphicItem->setProperty("_latte_layoutsManager_object", QVariant::fromValue(m_corona->layoutsManager()));
rootContext()->setContextProperty(QStringLiteral("themeExtended"), m_corona->themeExtended()); containmentGraphicItem->setProperty("_latte_themeExtended_object", QVariant::fromValue(m_corona->themeExtended()));
rootContext()->setContextProperty(QStringLiteral("universalSettings"), m_corona->universalSettings()); containmentGraphicItem->setProperty("_latte_universalSettings_object", QVariant::fromValue(m_corona->universalSettings()));
containmentGraphicItem->setProperty("_latte_view_object", QVariant::fromValue(this));
} }
setSource(corona()->kPackage().filePath("lattedockui")); setSource(corona()->kPackage().filePath("lattedockui"));
m_positioner->syncGeometry(); m_positioner->syncGeometry();
qDebug() << "SOURCE:" << source(); qDebug() << "SOURCE:" << source();

@ -131,7 +131,7 @@ public:
View(Plasma::Corona *corona, QScreen *targetScreen = nullptr, bool byPassWM = false); View(Plasma::Corona *corona, QScreen *targetScreen = nullptr, bool byPassWM = false);
virtual ~View(); virtual ~View();
void init(); void init(Plasma::Containment *plasma_containment = nullptr);
Types::ViewType type() const; Types::ViewType type() const;
void setType(Types::ViewType type); void setType(Types::ViewType type);

@ -56,8 +56,6 @@ Item{
property rect efGeometry property rect efGeometry
property string layoutColor: latteView && latteView.layout ? latteView.layout.color : "blue"
readonly property real appliedOpacity: imageTiler.opacity readonly property real appliedOpacity: imageTiler.opacity
readonly property real maxOpacity: root.inConfigureAppletsMode || !LatteCore.WindowSystem.compositingActive ? readonly property real maxOpacity: root.inConfigureAppletsMode || !LatteCore.WindowSystem.compositingActive ?
1 : plasmoid.configuration.editBackgroundOpacity 1 : plasmoid.configuration.editBackgroundOpacity
@ -128,10 +126,15 @@ Item{
opacity: 0 opacity: 0
fillMode: Image.Tile fillMode: Image.Tile
source: hasBackground ? latteView.layout.background : "../../icons/"+latteView.layout.background+"print.jpg" source: {
if (hasBackground) {
return viewLayout.background;
}
return viewLayout ? "../../icons/"+viewLayout.background+"print.jpg" : "../../icons/blueprint.jpg"
}
readonly property bool hasBackground: (latteView && latteView.layout && latteView.layout.background.startsWith("/")) ? readonly property bool hasBackground: (viewLayout && viewLayout.background.startsWith("/")) ? true : false
true : false
Connections { Connections {
target: editVisual target: editVisual

@ -443,13 +443,14 @@ Item {
readonly property alias maskManager: visibilityManager readonly property alias maskManager: visibilityManager
readonly property alias layoutsContainerItem: layoutsContainer readonly property alias layoutsContainerItem: layoutsContainer
property QtObject latteView: null readonly property alias latteView: _interfaces.view
property QtObject shortcutsEngine: null readonly property alias layoutsManager: _interfaces.layoutsManager
property QtObject themeExtended: null readonly property alias shortcutsEngine: _interfaces.globalShortcuts
property QtObject universalSettings: null readonly property alias themeExtended: _interfaces.themeExtended
property QtObject layoutsManager: null readonly property alias universalSettings: _interfaces.universalSettings
property QtObject viewLayout: latteView && latteView.layout ? latteView.layout : null
property QtObject selectedWindowsTracker: { readonly property QtObject viewLayout: latteView && latteView.layout ? latteView.layout : null
readonly property QtObject selectedWindowsTracker: {
if (latteView && latteView.windowsTracker) { if (latteView && latteView.windowsTracker) {
switch(plasmoid.configuration.activeWindowFilter) { switch(plasmoid.configuration.activeWindowFilter) {
case LatteContainment.Types.ActiveInCurrentScreen: case LatteContainment.Types.ActiveInCurrentScreen:
@ -1709,6 +1710,11 @@ Item {
indicators: indicatorsManager indicators: indicatorsManager
} }
LatteApp.Interfaces {
id: _interfaces
plasmoidInterface: plasmoid
}
///////////////END ABILITIES ///////////////END ABILITIES
///////////////BEGIN TIMER elements ///////////////BEGIN TIMER elements

@ -96,11 +96,6 @@ PlasmaCore.FrameSvgItem {
for(var i=0; i<containment.children.length; ++i){ for(var i=0; i<containment.children.length; ++i){
if (containment.children[i].objectName === "containmentViewLayout") { if (containment.children[i].objectName === "containmentViewLayout") {
viewLayout = containment.children[i]; viewLayout = containment.children[i];
viewLayout.latteView = latteView;
viewLayout.shortcutsEngine = shortcutsEngine;
viewLayout.themeExtended = themeExtended;
viewLayout.universalSettings = universalSettings;
viewLayout.layoutsManager = layoutsManager;
} }
} }
} }

Loading…
Cancel
Save