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/>.
*/
# ifndef VIEWCONTAINMENTINTERFACE_H
# define VIEWCONTAINMENTINTERFACE_H
2020-04-16 19:37:40 +03:00
// local
# include "tasksmodel.h"
2019-12-21 19:53:02 +03:00
// Qt
# include <QMetaMethod>
# include <QObject>
# include <QPointer>
# include <QQuickItem>
2020-04-08 15:22:38 +03:00
# include <QTimer>
2019-12-21 19:53:02 +03:00
2020-05-18 19:04:02 +03:00
namespace Plasma {
class Applet ;
}
2020-04-08 14:39:12 +03:00
namespace PlasmaQuick {
class AppletQuickItem ;
}
2019-12-21 19:53:02 +03:00
namespace Latte {
class Corona ;
class View ;
}
namespace Latte {
namespace ViewPart {
class ContainmentInterface : public QObject
{
Q_OBJECT
2020-04-08 15:22:38 +03:00
Q_PROPERTY ( bool hasExpandedApplet READ hasExpandedApplet NOTIFY hasExpandedAppletChanged )
2019-12-21 19:53:02 +03:00
2020-05-18 18:45:12 +03:00
Q_PROPERTY ( QAbstractListModel * latteTasksModel READ latteTasksModel ( ) NOTIFY latteTasksModelChanged )
2020-05-18 19:04:02 +03:00
Q_PROPERTY ( QAbstractListModel * plasmaTasksModel READ plasmaTasksModel ( ) NOTIFY plasmaTasksModelChanged )
2020-04-16 19:37:40 +03:00
2019-12-21 19:53:02 +03:00
public :
ContainmentInterface ( Latte : : View * parent ) ;
virtual ~ ContainmentInterface ( ) ;
2020-04-08 15:22:38 +03:00
bool hasExpandedApplet ( ) const ;
2019-12-21 20:08:33 +03:00
bool applicationLauncherInPopup ( ) const ;
2020-01-10 18:58:34 +03:00
bool applicationLauncherHasGlobalShortcut ( ) const ;
2019-12-21 19:53:02 +03:00
bool containsApplicationLauncher ( ) const ;
2020-01-10 18:58:34 +03:00
bool isCapableToShowShortcutBadges ( ) ;
2019-12-21 19:53:02 +03:00
bool activateEntry ( const int index ) ;
bool newInstanceForEntry ( const int index ) ;
bool activatePlasmaTask ( const int index ) ;
bool newInstanceForPlasmaTask ( const int index ) ;
bool hideShortcutBadges ( ) ;
bool showOnlyMeta ( ) ;
bool showShortcutBadges ( const bool showLatteShortcuts , const bool showMeta ) ;
//! this is updated from external apps e.g. a thunderbird plugin
bool updateBadgeForLatteTask ( const QString identifier , const QString value ) ;
int applicationLauncherId ( ) const ;
2019-12-21 20:08:33 +03:00
int appletIdForIndex ( const int index ) ;
2019-12-21 19:53:02 +03:00
2020-05-18 18:45:12 +03:00
QAbstractListModel * latteTasksModel ( ) const ;
2020-05-18 19:04:02 +03:00
QAbstractListModel * plasmaTasksModel ( ) const ;
2020-04-16 19:37:40 +03:00
2020-04-08 14:39:12 +03:00
public slots :
Q_INVOKABLE void deactivateApplets ( ) ;
2020-04-08 15:22:38 +03:00
Q_INVOKABLE void toggleAppletExpanded ( const int id ) ;
Q_INVOKABLE bool appletIsExpandable ( const int id ) ;
Q_INVOKABLE bool appletIsExpanded ( const int id ) ;
signals :
void hasExpandedAppletChanged ( ) ;
void expandedAppletStateChanged ( ) ;
2020-05-18 18:45:12 +03:00
void latteTasksModelChanged ( ) ;
2020-05-18 19:04:02 +03:00
void plasmaTasksModelChanged ( ) ;
2020-04-08 14:39:12 +03:00
2019-12-21 19:53:02 +03:00
private slots :
void identifyMainItem ( ) ;
void identifyMethods ( ) ;
2020-04-16 19:37:40 +03:00
void updateAppletsTracking ( ) ;
2020-05-18 19:04:02 +03:00
void on_appletAdded ( Plasma : : Applet * applet ) ;
2020-04-08 15:22:38 +03:00
void on_appletExpandedChanged ( ) ;
private :
void addExpandedApplet ( const int & id ) ;
void removeExpandedApplet ( const int & id ) ;
2020-04-19 02:24:56 +03:00
bool appletIsExpandable ( PlasmaQuick : : AppletQuickItem * appletQuickItem ) ;
2019-12-21 19:53:02 +03:00
private :
QMetaMethod m_activateEntryMethod ;
2019-12-21 20:08:33 +03:00
QMetaMethod m_appletIdForIndexMethod ;
2019-12-21 19:53:02 +03:00
QMetaMethod m_newInstanceMethod ;
QMetaMethod m_showShortcutsMethod ;
QPointer < Latte : : Corona > m_corona ;
QPointer < Latte : : View > m_view ;
QPointer < QQuickItem > m_mainItem ;
2020-04-08 15:22:38 +03:00
//! startup timer to initialize
2020-04-16 19:37:40 +03:00
//! applets tracking
2020-04-08 15:22:38 +03:00
QTimer m_appletsExpandedConnectionsTimer ;
2020-05-18 18:45:12 +03:00
TasksModel * m_latteTasksModel ;
2020-05-18 19:04:02 +03:00
TasksModel * m_plasmaTasksModel ;
2020-04-16 19:37:40 +03:00
2020-04-08 15:22:38 +03:00
QHash < PlasmaQuick : : AppletQuickItem * , QMetaObject : : Connection > m_appletsExpandedConnections ;
QList < int > m_expandedAppletIds ;
2019-12-21 19:53:02 +03:00
} ;
}
}
# endif