You cannot select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
126 lines
4.2 KiB
QML
126 lines
4.2 KiB
QML
6 years ago
|
/*
|
||
|
* Copyright 2018 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/>.
|
||
|
*/
|
||
|
|
||
|
import QtQuick 2.7
|
||
|
|
||
6 years ago
|
import "../../../code/AppletIdentifier.js" as AppletIdentifier
|
||
6 years ago
|
|
||
|
Item{
|
||
6 years ago
|
id: mainCommunicator
|
||
6 years ago
|
|
||
|
// -------------------------------------
|
||
|
// BEGIN OF INTERNAL APPLET PROPERTIES
|
||
|
// LATTE<->APPLET COMMUNICATION PROTOCOL
|
||
|
// -------------------------------------
|
||
6 years ago
|
//
|
||
6 years ago
|
// NAME: latteBridge
|
||
|
// USAGE: property QtObject latteBridge: null
|
||
6 years ago
|
// EXPLANATION: The main shared object that Latte is using to communicate with the applet
|
||
6 years ago
|
property bool appletContainsLatteBridge: appletRootItem && appletRootItem.hasOwnProperty("latteBridge") ? true : false
|
||
6 years ago
|
//! END OF INTERNAL APPLET PROPERTIES
|
||
6 years ago
|
// -------------------------------------
|
||
6 years ago
|
|
||
|
//! BEGIN OF PROPERTIES
|
||
|
//this is used for folderView and icon widgets to fake their visual icons
|
||
6 years ago
|
readonly property bool canShowOverlaiedLatteIcon: appletRootItem && appletIconItem
|
||
|
readonly property bool overlayLatteIconIsActive: canShowOverlaiedLatteIcon && bridgeLoader.active && !disableLatteIconOverlay
|
||
6 years ago
|
|
||
6 years ago
|
property Item appletRootItem: appletDiscoveredRootItem ? appletDiscoveredRootItem : appletDefaultRootItem
|
||
|
property Item appletDiscoveredRootItem: null
|
||
|
property Item appletDefaultRootItem: applet && applet.children && applet.children.length>0 ? applet.children[0] : null
|
||
|
|
||
6 years ago
|
property Item appletIconItem; //first applet's IconItem to be used by Latte
|
||
|
property Item appletImageItem; //first applet's ImageItem to be used by Latte
|
||
|
//! END OF PROPERTIES
|
||
|
|
||
6 years ago
|
//! BEGIN OF PUBLIC PROPERTIES SET THROUGH LATTEBRIDGE.ACTIONS
|
||
|
property bool disableLatteSideColoring: false
|
||
|
property bool disableLatteIconOverlay: false
|
||
|
//! END OF PUBLIC PROPERTIES SET THROUGH LATTEBRIDGE.ACTIONS
|
||
|
|
||
6 years ago
|
//! BEGIN OF PROPERTY CHANGES
|
||
|
//! END OF PROPERTY CHANGES
|
||
|
|
||
|
//! BEGIN OF FUNCTIONS
|
||
|
function appletIconItemIsShown() {
|
||
|
return appletIconItem && appletIconItem.visible;
|
||
|
}
|
||
|
|
||
|
function appletImageItemIsShown() {
|
||
|
return appletImageItem && appletImageItem.visible;
|
||
|
}
|
||
|
|
||
|
function reconsiderAppletIconItem() {
|
||
|
AppletIdentifier.reconsiderAppletIconItem();
|
||
|
}
|
||
|
|
||
|
function setAppletIconItemActive(isActive) {
|
||
|
if (appletIconItem) {
|
||
|
appletIconItem.active = isActive;
|
||
|
}
|
||
|
}
|
||
|
//! END OF FUNCTIONS
|
||
|
|
||
|
//! BEGIN OF CONNECTIONS
|
||
|
Connections{
|
||
|
target: container
|
||
|
onAppletChanged: {
|
||
|
if (applet) {
|
||
6 years ago
|
AppletIdentifier.checkAndUpdateAppletRootItem();
|
||
|
AppletIdentifier.reconsiderAppletIconItem();
|
||
6 years ago
|
overlayInitTimer.start();
|
||
|
}
|
||
|
}
|
||
|
|
||
|
}
|
||
|
//! END OF CONNECTIONS
|
||
|
|
||
6 years ago
|
//! BEGIN OF BINDINGS
|
||
|
Binding{
|
||
|
target: appletRootItem
|
||
6 years ago
|
property: "latteBridge"
|
||
|
when: bridgeLoader.active
|
||
|
value: bridgeLoader.item
|
||
6 years ago
|
}
|
||
6 years ago
|
//! END OF BINDINGS
|
||
6 years ago
|
|
||
6 years ago
|
Loader{
|
||
6 years ago
|
id: bridgeLoader
|
||
|
active: appletContainsLatteBridge
|
||
|
sourceComponent: LatteBridge{}
|
||
6 years ago
|
}
|
||
|
|
||
6 years ago
|
//! BEGIN OF TIMERS
|
||
|
//a timer that is used in order to init some Communicator values
|
||
|
Timer {
|
||
|
id: overlayInitTimer
|
||
|
interval: 4000
|
||
|
onTriggered: {
|
||
6 years ago
|
AppletIdentifier.checkAndUpdateAppletRootItem();
|
||
6 years ago
|
AppletIdentifier.reconsiderAppletIconItem();
|
||
|
|
||
|
if (root.debugModeTimers) {
|
||
|
console.log("containment timer: appletItem fakeInitTimer called...");
|
||
|
}
|
||
|
}
|
||
|
}
|
||
|
|
||
|
//! END OF TIMERS
|
||
|
}
|