2019-12-21 19:53:02 +03:00
/*
* Copyright 2019 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 "containmentinterface.h"
// local
# include "view.h"
# include "../lattecorona.h"
2020-04-08 15:22:38 +03:00
# include "../layout/genericlayout.h"
2019-12-21 19:53:02 +03:00
# include "../settings/universalsettings.h"
// Qt
# include <QDebug>
// Plasma
# include <Plasma/Applet>
# include <Plasma/Containment>
2020-04-08 14:39:12 +03:00
# include <PlasmaQuick/AppletQuickItem>
2019-12-21 19:53:02 +03:00
// KDE
# include <KLocalizedString>
# include <KPluginMetaData>
namespace Latte {
namespace ViewPart {
ContainmentInterface : : ContainmentInterface ( Latte : : View * parent )
: QObject ( parent ) ,
m_view ( parent )
{
m_corona = qobject_cast < Latte : : Corona * > ( m_view - > corona ( ) ) ;
2020-04-08 15:22:38 +03:00
2020-05-18 18:45:12 +03:00
m_latteTasksModel = new TasksModel ( this ) ;
2020-05-18 19:04:02 +03:00
m_plasmaTasksModel = new TasksModel ( this ) ;
2020-04-16 19:37:40 +03:00
2020-04-08 15:22:38 +03:00
m_appletsExpandedConnectionsTimer . setInterval ( 2000 ) ;
m_appletsExpandedConnectionsTimer . setSingleShot ( true ) ;
2020-04-16 19:37:40 +03:00
connect ( & m_appletsExpandedConnectionsTimer , & QTimer : : timeout , this , & ContainmentInterface : : updateAppletsTracking ) ;
2020-04-08 15:22:38 +03:00
connect ( m_view , & View : : containmentChanged
, this , [ & ] ( ) {
if ( m_view - > containment ( ) ) {
2020-05-18 19:04:02 +03:00
connect ( m_view - > containment ( ) , & Plasma : : Containment : : appletAdded , this , & ContainmentInterface : : on_appletAdded ) ;
2020-04-08 15:22:38 +03:00
m_appletsExpandedConnectionsTimer . start ( ) ;
}
} ) ;
2020-05-18 19:14:35 +03:00
connect ( m_latteTasksModel , & TasksModel : : countChanged , this , & ContainmentInterface : : onLatteTasksCountChanged ) ;
connect ( m_plasmaTasksModel , & TasksModel : : countChanged , this , & ContainmentInterface : : onPlasmaTasksCountChanged ) ;
2019-12-21 19:53:02 +03:00
}
ContainmentInterface : : ~ ContainmentInterface ( )
{
}
void ContainmentInterface : : identifyMainItem ( )
{
if ( m_mainItem ) {
return ;
}
if ( QQuickItem * graphicItem = m_view - > containment ( ) - > property ( " _plasma_graphicObject " ) . value < QQuickItem * > ( ) ) {
const auto & childItems = graphicItem - > childItems ( ) ;
for ( QQuickItem * item : childItems ) {
if ( item - > objectName ( ) = = " containmentViewLayout " ) {
m_mainItem = item ;
identifyMethods ( ) ;
return ;
}
}
}
}
void ContainmentInterface : : identifyMethods ( )
{
int aeIndex = m_mainItem - > metaObject ( ) - > indexOfMethod ( " activateEntryAtIndex(QVariant) " ) ;
int niIndex = m_mainItem - > metaObject ( ) - > indexOfMethod ( " newInstanceForEntryAtIndex(QVariant) " ) ;
int sbIndex = m_mainItem - > metaObject ( ) - > indexOfMethod ( " setShowAppletShortcutBadges(QVariant,QVariant,QVariant,QVariant) " ) ;
2019-12-21 20:08:33 +03:00
int afiIndex = m_mainItem - > metaObject ( ) - > indexOfMethod ( " appletIdForIndex(QVariant) " ) ;
2019-12-21 19:53:02 +03:00
m_activateEntryMethod = m_mainItem - > metaObject ( ) - > method ( aeIndex ) ;
2019-12-21 20:08:33 +03:00
m_appletIdForIndexMethod = m_mainItem - > metaObject ( ) - > method ( afiIndex ) ;
2019-12-21 19:53:02 +03:00
m_newInstanceMethod = m_mainItem - > metaObject ( ) - > method ( niIndex ) ;
m_showShortcutsMethod = m_mainItem - > metaObject ( ) - > method ( sbIndex ) ;
}
2020-01-10 18:58:34 +03:00
bool ContainmentInterface : : applicationLauncherHasGlobalShortcut ( ) const
{
if ( ! containsApplicationLauncher ( ) ) {
return false ;
}
2020-03-14 15:41:07 +03:00
uint launcherAppletId = applicationLauncherId ( ) ;
2020-01-10 18:58:34 +03:00
const auto applets = m_view - > containment ( ) - > applets ( ) ;
for ( auto applet : applets ) {
if ( applet - > id ( ) = = launcherAppletId ) {
return ! applet - > globalShortcut ( ) . isEmpty ( ) ;
}
}
return false ;
}
2019-12-21 20:08:33 +03:00
bool ContainmentInterface : : applicationLauncherInPopup ( ) const
{
if ( ! containsApplicationLauncher ( ) ) {
return false ;
}
2020-03-14 15:41:07 +03:00
uint launcherAppletId = applicationLauncherId ( ) ;
2019-12-21 20:08:33 +03:00
QString launcherPluginId ;
const auto applets = m_view - > containment ( ) - > applets ( ) ;
for ( auto applet : applets ) {
if ( applet - > id ( ) = = launcherAppletId ) {
launcherPluginId = applet - > kPackage ( ) . metadata ( ) . pluginId ( ) ;
}
}
return launcherPluginId ! = " org.kde.plasma.kickerdash " ;
}
2019-12-21 19:53:02 +03:00
bool ContainmentInterface : : containsApplicationLauncher ( ) const
{
2020-01-10 18:58:34 +03:00
return ( applicationLauncherId ( ) > = 0 ) ;
2019-12-21 19:53:02 +03:00
}
2020-01-10 18:58:34 +03:00
bool ContainmentInterface : : isCapableToShowShortcutBadges ( )
2019-12-21 19:53:02 +03:00
{
2020-01-10 18:58:34 +03:00
identifyMainItem ( ) ;
2020-05-18 19:17:11 +03:00
if ( ! hasLatteTasks ( ) & & hasPlasmaTasks ( ) ) {
2019-12-21 19:53:02 +03:00
return false ;
}
return m_showShortcutsMethod . isValid ( ) ;
}
int ContainmentInterface : : applicationLauncherId ( ) const
{
const auto applets = m_view - > containment ( ) - > applets ( ) ;
2020-01-10 18:58:34 +03:00
auto launcherId { - 1 } ;
2019-12-21 19:53:02 +03:00
for ( auto applet : applets ) {
const auto provides = applet - > kPackage ( ) . metadata ( ) . value ( QStringLiteral ( " X-Plasma-Provides " ) ) ;
if ( provides . contains ( QLatin1String ( " org.kde.plasma.launchermenu " ) ) ) {
2020-01-10 18:58:34 +03:00
if ( ! applet - > globalShortcut ( ) . isEmpty ( ) ) {
return applet - > id ( ) ;
} else if ( launcherId = = - 1 ) {
launcherId = applet - > id ( ) ;
}
2019-12-21 19:53:02 +03:00
}
}
2020-01-10 18:58:34 +03:00
return launcherId ;
2019-12-21 19:53:02 +03:00
}
bool ContainmentInterface : : updateBadgeForLatteTask ( const QString identifier , const QString value )
{
2020-05-18 19:17:11 +03:00
if ( ! hasLatteTasks ( ) ) {
2019-12-21 19:53:02 +03:00
return false ;
}
const auto & applets = m_view - > containment ( ) - > applets ( ) ;
for ( auto * applet : applets ) {
KPluginMetaData meta = applet - > kPackage ( ) . metadata ( ) ;
if ( meta . pluginId ( ) = = " org.kde.latte.plasmoid " ) {
if ( QQuickItem * appletInterface = applet - > property ( " _plasma_graphicObject " ) . value < QQuickItem * > ( ) ) {
const auto & childItems = appletInterface - > childItems ( ) ;
if ( childItems . isEmpty ( ) ) {
continue ;
}
for ( QQuickItem * item : childItems ) {
if ( auto * metaObject = item - > metaObject ( ) ) {
// not using QMetaObject::invokeMethod to avoid warnings when calling
// this on applets that don't have it or other child items since this
// is pretty much trial and error.
// Also, "var" arguments are treated as QVariant in QMetaObject
int methodIndex = metaObject - > indexOfMethod ( " updateBadge(QVariant,QVariant) " ) ;
if ( methodIndex = = - 1 ) {
continue ;
}
QMetaMethod method = metaObject - > method ( methodIndex ) ;
if ( method . invoke ( item , Q_ARG ( QVariant , identifier ) , Q_ARG ( QVariant , value ) ) ) {
return true ;
}
}
}
}
}
}
return false ;
}
bool ContainmentInterface : : activatePlasmaTask ( const int index )
{
2020-05-18 19:17:11 +03:00
bool containsPlasmaTaskManager { hasPlasmaTasks ( ) & & ! hasLatteTasks ( ) } ;
2019-12-21 19:53:02 +03:00
if ( ! containsPlasmaTaskManager ) {
return false ;
}
const auto & applets = m_view - > containment ( ) - > applets ( ) ;
for ( auto * applet : applets ) {
const auto & provides = KPluginMetaData : : readStringList ( applet - > pluginMetaData ( ) . rawData ( ) , QStringLiteral ( " X-Plasma-Provides " ) ) ;
if ( provides . contains ( QLatin1String ( " org.kde.plasma.multitasking " ) ) ) {
if ( QQuickItem * appletInterface = applet - > property ( " _plasma_graphicObject " ) . value < QQuickItem * > ( ) ) {
const auto & childItems = appletInterface - > childItems ( ) ;
if ( childItems . isEmpty ( ) ) {
continue ;
}
KPluginMetaData meta = applet - > kPackage ( ) . metadata ( ) ;
for ( QQuickItem * item : childItems ) {
if ( auto * metaObject = item - > metaObject ( ) ) {
int methodIndex { metaObject - > indexOfMethod ( " activateTaskAtIndex(QVariant) " ) } ;
if ( methodIndex = = - 1 ) {
continue ;
}
QMetaMethod method = metaObject - > method ( methodIndex ) ;
if ( method . invoke ( item , Q_ARG ( QVariant , index - 1 ) ) ) {
showShortcutBadges ( false , true ) ;
return true ;
}
}
}
}
}
}
return false ;
}
bool ContainmentInterface : : newInstanceForPlasmaTask ( const int index )
{
2020-05-18 19:17:11 +03:00
bool containsPlasmaTaskManager { hasPlasmaTasks ( ) & & ! hasLatteTasks ( ) } ;
2019-12-21 19:53:02 +03:00
if ( ! containsPlasmaTaskManager ) {
return false ;
}
const auto & applets = m_view - > containment ( ) - > applets ( ) ;
for ( auto * applet : applets ) {
const auto & provides = KPluginMetaData : : readStringList ( applet - > pluginMetaData ( ) . rawData ( ) , QStringLiteral ( " X-Plasma-Provides " ) ) ;
if ( provides . contains ( QLatin1String ( " org.kde.plasma.multitasking " ) ) ) {
if ( QQuickItem * appletInterface = applet - > property ( " _plasma_graphicObject " ) . value < QQuickItem * > ( ) ) {
const auto & childItems = appletInterface - > childItems ( ) ;
if ( childItems . isEmpty ( ) ) {
continue ;
}
KPluginMetaData meta = applet - > kPackage ( ) . metadata ( ) ;
for ( QQuickItem * item : childItems ) {
if ( auto * metaObject = item - > metaObject ( ) ) {
int methodIndex { metaObject - > indexOfMethod ( " ewInstanceForTaskAtIndex(QVariant) " ) } ;
if ( methodIndex = = - 1 ) {
continue ;
}
QMetaMethod method = metaObject - > method ( methodIndex ) ;
if ( method . invoke ( item , Q_ARG ( QVariant , index - 1 ) ) ) {
showShortcutBadges ( false , true ) ;
return true ;
}
}
}
}
}
}
return false ;
}
bool ContainmentInterface : : activateEntry ( const int index )
{
identifyMainItem ( ) ;
if ( ! m_activateEntryMethod . isValid ( ) ) {
return false ;
}
return m_activateEntryMethod . invoke ( m_mainItem , Q_ARG ( QVariant , index ) ) ;
}
bool ContainmentInterface : : newInstanceForEntry ( const int index )
{
identifyMainItem ( ) ;
if ( ! m_newInstanceMethod . isValid ( ) ) {
return false ;
}
return m_newInstanceMethod . invoke ( m_mainItem , Q_ARG ( QVariant , index ) ) ;
}
bool ContainmentInterface : : hideShortcutBadges ( )
{
identifyMainItem ( ) ;
if ( ! m_showShortcutsMethod . isValid ( ) ) {
return false ;
}
return m_showShortcutsMethod . invoke ( m_mainItem , Q_ARG ( QVariant , false ) , Q_ARG ( QVariant , false ) , Q_ARG ( QVariant , false ) , Q_ARG ( QVariant , - 1 ) ) ;
}
bool ContainmentInterface : : showOnlyMeta ( )
{
if ( ! m_corona - > universalSettings ( ) - > kwin_metaForwardedToLatte ( ) ) {
return false ;
}
return showShortcutBadges ( false , true ) ;
}
bool ContainmentInterface : : showShortcutBadges ( const bool showLatteShortcuts , const bool showMeta )
{
identifyMainItem ( ) ;
2020-04-21 01:45:07 +03:00
if ( ! m_showShortcutsMethod . isValid ( ) | | ! isCapableToShowShortcutBadges ( ) ) {
2019-12-21 19:53:02 +03:00
return false ;
}
int appLauncherId = m_corona - > universalSettings ( ) - > kwin_metaForwardedToLatte ( ) & & showMeta ? applicationLauncherId ( ) : - 1 ;
return m_showShortcutsMethod . invoke ( m_mainItem , Q_ARG ( QVariant , showLatteShortcuts ) , Q_ARG ( QVariant , true ) , Q_ARG ( QVariant , showMeta ) , Q_ARG ( QVariant , appLauncherId ) ) ;
}
2020-05-19 18:41:49 +03:00
int ContainmentInterface : : appletIdForVisualIndex ( const int index )
2019-12-21 20:08:33 +03:00
{
identifyMainItem ( ) ;
if ( ! m_appletIdForIndexMethod . isValid ( ) ) {
return false ;
}
QVariant appletId { - 1 } ;
m_appletIdForIndexMethod . invoke ( m_mainItem , Q_RETURN_ARG ( QVariant , appletId ) , Q_ARG ( QVariant , index ) ) ;
return appletId . toInt ( ) ;
}
2020-04-08 14:39:12 +03:00
void ContainmentInterface : : deactivateApplets ( )
{
2020-05-08 10:16:26 +03:00
if ( ! m_view - > containment ( ) | | ! m_view - > inReadyState ( ) ) {
2020-04-08 14:39:12 +03:00
return ;
}
for ( const auto applet : m_view - > containment ( ) - > applets ( ) ) {
PlasmaQuick : : AppletQuickItem * ai = applet - > property ( " _plasma_graphicObject " ) . value < PlasmaQuick : : AppletQuickItem * > ( ) ;
if ( ai ) {
ai - > setExpanded ( false ) ;
}
}
}
2020-04-08 15:22:38 +03:00
bool ContainmentInterface : : appletIsExpandable ( const int id )
{
2020-05-08 10:16:26 +03:00
if ( ! m_view - > containment ( ) | | ! m_view - > inReadyState ( ) ) {
2020-04-08 15:22:38 +03:00
return false ;
}
for ( const auto applet : m_view - > containment ( ) - > applets ( ) ) {
2020-05-08 10:16:26 +03:00
if ( applet & & applet - > id ( ) = = ( uint ) id ) {
2020-04-08 15:22:38 +03:00
if ( m_view - > layout ( ) & & m_view - > layout ( ) - > isInternalContainment ( applet ) ) {
return true ;
}
PlasmaQuick : : AppletQuickItem * ai = applet - > property ( " _plasma_graphicObject " ) . value < PlasmaQuick : : AppletQuickItem * > ( ) ;
if ( ai ) {
2020-04-19 02:24:56 +03:00
return appletIsExpandable ( ai ) ;
2020-04-08 15:22:38 +03:00
}
}
}
return false ;
}
2020-04-19 02:24:56 +03:00
bool ContainmentInterface : : appletIsExpandable ( PlasmaQuick : : AppletQuickItem * appletQuickItem )
{
2020-05-08 10:16:26 +03:00
if ( ! appletQuickItem | | ! m_view - > inReadyState ( ) ) {
2020-04-19 02:24:56 +03:00
return false ;
}
return ( appletQuickItem - > fullRepresentation ( ) ! = nullptr
& & appletQuickItem - > preferredRepresentation ( ) ! = appletQuickItem - > fullRepresentation ( ) ) ;
}
2020-04-08 15:22:38 +03:00
bool ContainmentInterface : : hasExpandedApplet ( ) const
{
return m_expandedAppletIds . count ( ) > 0 ;
}
2020-05-18 19:14:35 +03:00
bool ContainmentInterface : : hasLatteTasks ( ) const
{
return ( m_latteTasksModel - > count ( ) > 0 ) ;
}
bool ContainmentInterface : : hasPlasmaTasks ( ) const
{
return ( m_plasmaTasksModel - > count ( ) > 0 ) ;
}
2020-04-08 15:22:38 +03:00
void ContainmentInterface : : addExpandedApplet ( const int & id )
{
if ( m_expandedAppletIds . contains ( id ) & & appletIsExpandable ( id ) ) {
return ;
}
bool isExpanded = hasExpandedApplet ( ) ;
m_expandedAppletIds < < id ;
if ( isExpanded ! = hasExpandedApplet ( ) ) {
emit hasExpandedAppletChanged ( ) ;
}
emit expandedAppletStateChanged ( ) ;
}
void ContainmentInterface : : removeExpandedApplet ( const int & id )
{
if ( ! m_expandedAppletIds . contains ( id ) ) {
return ;
}
bool isExpanded = hasExpandedApplet ( ) ;
m_expandedAppletIds . removeAll ( id ) ;
if ( isExpanded ! = hasExpandedApplet ( ) ) {
emit hasExpandedAppletChanged ( ) ;
}
emit expandedAppletStateChanged ( ) ;
}
2020-05-18 18:45:12 +03:00
QAbstractListModel * ContainmentInterface : : latteTasksModel ( ) const
2020-04-16 19:37:40 +03:00
{
2020-05-18 18:45:12 +03:00
return m_latteTasksModel ;
2020-04-16 19:37:40 +03:00
}
2020-05-18 19:04:02 +03:00
QAbstractListModel * ContainmentInterface : : plasmaTasksModel ( ) const
{
return m_plasmaTasksModel ;
}
2020-04-08 15:22:38 +03:00
void ContainmentInterface : : on_appletExpandedChanged ( )
{
PlasmaQuick : : AppletQuickItem * appletItem = static_cast < PlasmaQuick : : AppletQuickItem * > ( QObject : : sender ( ) ) ;
if ( appletItem ) {
if ( appletItem - > isExpanded ( ) ) {
addExpandedApplet ( appletItem - > applet ( ) - > id ( ) ) ;
} else {
removeExpandedApplet ( appletItem - > applet ( ) - > id ( ) ) ;
}
}
}
2020-05-18 19:14:35 +03:00
void ContainmentInterface : : onLatteTasksCountChanged ( )
{
if ( ( m_hasLatteTasks & & m_latteTasksModel - > count ( ) > 0 )
| | ( ! m_hasLatteTasks & & m_latteTasksModel - > count ( ) = = 0 ) ) {
return ;
}
m_hasLatteTasks = ( m_latteTasksModel - > count ( ) > 0 ) ;
emit hasLatteTasksChanged ( ) ;
}
void ContainmentInterface : : onPlasmaTasksCountChanged ( )
{
if ( ( m_hasPlasmaTasks & & m_plasmaTasksModel - > count ( ) > 0 )
| | ( ! m_hasPlasmaTasks & & m_plasmaTasksModel - > count ( ) = = 0 ) ) {
return ;
}
m_hasPlasmaTasks = ( m_plasmaTasksModel - > count ( ) > 0 ) ;
emit hasPlasmaTasksChanged ( ) ;
}
2020-04-08 15:22:38 +03:00
bool ContainmentInterface : : appletIsExpanded ( const int id )
{
return m_expandedAppletIds . contains ( id ) ;
}
void ContainmentInterface : : toggleAppletExpanded ( const int id )
{
2020-05-08 10:16:26 +03:00
if ( ! m_view - > containment ( ) | | ! m_view - > inReadyState ( ) ) {
2020-04-08 15:22:38 +03:00
return ;
}
for ( const auto applet : m_view - > containment ( ) - > applets ( ) ) {
2020-04-10 12:31:31 +03:00
if ( applet - > id ( ) = = ( uint ) id & & ! m_view - > layout ( ) - > isInternalContainment ( applet ) /*block for internal containments*/ ) {
2020-04-08 15:22:38 +03:00
PlasmaQuick : : AppletQuickItem * ai = applet - > property ( " _plasma_graphicObject " ) . value < PlasmaQuick : : AppletQuickItem * > ( ) ;
if ( ai ) {
2020-04-19 02:24:56 +03:00
if ( appletIsExpandable ( ai ) ) {
ai - > setExpanded ( ! ai - > isExpanded ( ) ) ;
} else {
emit applet - > activated ( ) ;
}
2020-04-08 15:22:38 +03:00
}
}
}
}
2020-04-16 19:37:40 +03:00
void ContainmentInterface : : updateAppletsTracking ( )
2020-04-08 15:22:38 +03:00
{
if ( ! m_view - > containment ( ) ) {
return ;
}
for ( const auto applet : m_view - > containment ( ) - > applets ( ) ) {
2020-05-18 19:04:02 +03:00
on_appletAdded ( applet ) ;
}
}
2020-04-08 15:22:38 +03:00
2020-05-18 19:04:02 +03:00
void ContainmentInterface : : on_appletAdded ( Plasma : : Applet * applet )
{
if ( ! m_view - > containment ( ) | | ! applet ) {
return ;
}
2020-04-08 15:22:38 +03:00
2020-05-18 19:04:02 +03:00
if ( m_view - > layout ( ) & & m_view - > layout ( ) - > isInternalContainment ( applet ) ) {
//! internal containment case
Plasma : : Containment * internalC = m_view - > layout ( ) - > internalContainmentOf ( applet ) ;
PlasmaQuick : : AppletQuickItem * contAi = applet - > property ( " _plasma_graphicObject " ) . value < PlasmaQuick : : AppletQuickItem * > ( ) ;
2020-04-08 15:22:38 +03:00
2020-05-18 19:04:02 +03:00
if ( contAi & & ! m_appletsExpandedConnections . contains ( contAi ) ) {
m_appletsExpandedConnections [ contAi ] = connect ( contAi , & PlasmaQuick : : AppletQuickItem : : expandedChanged , this , & ContainmentInterface : : on_appletExpandedChanged ) ;
2020-04-08 15:22:38 +03:00
2020-05-18 19:04:02 +03:00
connect ( contAi , & QObject : : destroyed , this , [ & , contAi ] ( ) {
m_appletsExpandedConnections . remove ( contAi ) ;
removeExpandedApplet ( contAi - > applet ( ) - > id ( ) ) ;
} ) ;
}
2020-04-17 17:05:35 +03:00
2020-05-18 19:04:02 +03:00
for ( const auto internalApplet : internalC - > applets ( ) ) {
PlasmaQuick : : AppletQuickItem * ai = internalApplet - > property ( " _plasma_graphicObject " ) . value < PlasmaQuick : : AppletQuickItem * > ( ) ;
2020-04-08 15:22:38 +03:00
2020-05-18 19:04:02 +03:00
if ( ai & & ! m_appletsExpandedConnections . contains ( ai ) ) {
2020-04-08 15:22:38 +03:00
m_appletsExpandedConnections [ ai ] = connect ( ai , & PlasmaQuick : : AppletQuickItem : : expandedChanged , this , & ContainmentInterface : : on_appletExpandedChanged ) ;
connect ( ai , & QObject : : destroyed , this , [ & , ai ] ( ) {
m_appletsExpandedConnections . remove ( ai ) ;
removeExpandedApplet ( ai - > applet ( ) - > id ( ) ) ;
} ) ;
}
}
2020-05-18 19:04:02 +03:00
} else {
PlasmaQuick : : AppletQuickItem * ai = applet - > property ( " _plasma_graphicObject " ) . value < PlasmaQuick : : AppletQuickItem * > ( ) ;
if ( ! ai ) {
return ;
}
KPluginMetaData meta = applet - > kPackage ( ) . metadata ( ) ;
const auto & provides = KPluginMetaData : : readStringList ( meta . rawData ( ) , QStringLiteral ( " X-Plasma-Provides " ) ) ;
if ( meta . pluginId ( ) = = " org.kde.latte.plasmoid " ) {
//! populate latte tasks applet
m_latteTasksModel - > addTask ( ai ) ;
} else if ( provides . contains ( QLatin1String ( " org.kde.plasma.multitasking " ) ) ) {
//! populate plasma tasks applet
m_plasmaTasksModel - > addTask ( ai ) ;
} else if ( ! m_appletsExpandedConnections . contains ( ai ) ) {
m_appletsExpandedConnections [ ai ] = connect ( ai , & PlasmaQuick : : AppletQuickItem : : expandedChanged , this , & ContainmentInterface : : on_appletExpandedChanged ) ;
connect ( ai , & QObject : : destroyed , this , [ & , ai ] ( ) {
m_appletsExpandedConnections . remove ( ai ) ;
removeExpandedApplet ( ai - > applet ( ) - > id ( ) ) ;
} ) ;
}
2020-04-08 15:22:38 +03:00
}
2020-05-18 19:04:02 +03:00
2020-04-08 15:22:38 +03:00
}
2019-12-21 19:53:02 +03:00
}
}