2017-06-04 01:58:03 +03:00
/*
2021-05-27 15:01:00 +00:00
SPDX - FileCopyrightText : 2016 Smith AR < audoban @ openmailbox . org >
SPDX - FileCopyrightText : 2016 Michail Vourlakos < mvourlakos @ gmail . com >
SPDX - License - Identifier : GPL - 2.0 - or - later
2017-06-04 01:58:03 +03:00
*/
# ifndef GLOBALSHORTCUTS_H
# define GLOBALSHORTCUTS_H
2020-04-24 14:52:16 +03:00
// local
# include <coretypes.h>
2018-12-02 02:05:52 +02:00
// Qt
2019-12-21 18:53:02 +02:00
# include <QAction>
2019-02-02 17:46:35 +02:00
# include <QPointer>
2018-01-10 22:55:19 +02:00
# include <QTimer>
2017-06-04 11:15:32 +03:00
2019-01-30 20:09:59 +02:00
// KDE
# include <kmodifierkeyinfo.h>
2020-04-22 14:09:42 +03:00
2018-07-23 16:55:51 +03:00
namespace Plasma {
class Containment ;
}
2018-02-03 11:34:13 +02:00
namespace Latte {
2018-12-06 14:35:34 +02:00
class Corona ;
2018-12-06 12:15:58 +02:00
class View ;
2019-02-02 17:46:35 +02:00
namespace ShortcutsPart {
class ModifierTracker ;
2019-02-03 00:10:07 +02:00
class ShortcutsTracker ;
2019-02-02 17:46:35 +02:00
}
2018-02-03 11:34:13 +02:00
}
2017-06-04 01:58:03 +03:00
namespace Latte {
2018-07-03 22:15:45 +03:00
class GlobalShortcuts : public QObject
{
2017-06-04 01:58:03 +03:00
Q_OBJECT
public :
2021-05-13 20:09:05 +03:00
static constexpr const char * SHORTCUTBLOCKHIDINGTYPE = " globalshortcuts::blockHiding() " ;
2017-06-04 01:58:03 +03:00
GlobalShortcuts ( QObject * parent = nullptr ) ;
~ GlobalShortcuts ( ) override ;
void activateLauncherMenu ( ) ;
2019-02-02 18:01:52 +02:00
void updateViewItemBadge ( QString identifier , QString value ) ;
2017-06-04 01:58:03 +03:00
2019-02-03 00:10:07 +02:00
ShortcutsPart : : ShortcutsTracker * shortcutsTracker ( ) const ;
2019-02-01 20:01:00 +02:00
signals :
void modifiersChanged ( ) ;
2017-06-04 10:08:58 +03:00
private slots :
2019-02-02 18:01:52 +02:00
void hideViewsTimerSlot ( ) ;
2017-06-04 10:08:58 +03:00
2017-06-04 01:58:03 +03:00
private :
void init ( ) ;
2019-02-01 20:01:00 +02:00
void initModifiers ( ) ;
2018-02-25 20:00:23 +02:00
void activateEntry ( int index , Qt : : Key modifier ) ;
2019-02-02 18:01:52 +02:00
void showViews ( ) ;
2017-11-19 14:51:15 +02:00
void showSettings ( ) ;
2019-12-21 19:08:33 +02:00
bool activateLatteEntry ( Latte : : View * view , int index , Qt : : Key modifier , bool * delayedExecution ) ;
bool activatePlasmaTaskManager ( const Latte : : View * view , int index , Qt : : Key modifier , bool * delayedExecution ) ;
2020-04-21 01:45:07 +03:00
bool activateEntryForView ( Latte : : View * view , int index , Qt : : Key modifier ) ;
2019-02-02 18:01:52 +02:00
bool viewAtLowerEdgePriority ( Latte : : View * test , Latte : : View * base ) ;
bool viewAtLowerScreenPriority ( Latte : : View * test , Latte : : View * base ) ;
bool viewsToHideAreValid ( ) ;
2018-07-23 16:55:51 +03:00
2020-01-10 17:58:34 +02:00
//! highest priority application launcher view
Latte : : View * highestApplicationLauncherView ( const QList < Latte : : View * > & views ) const ;
2018-12-06 12:15:58 +02:00
QList < Latte : : View * > sortedViewsList ( QHash < const Plasma : : Containment * , Latte : : View * > * views ) ;
2017-06-04 01:58:03 +03:00
2019-02-01 20:13:31 +02:00
private :
bool m_metaShowedViews { false } ;
2019-02-02 18:16:17 +02:00
//! last action that was trigerred from the user
2017-06-04 10:08:58 +03:00
QAction * m_lastInvokedAction ;
2019-02-02 18:16:17 +02:00
//! it is used for code compatibility reasons in order to replicate a single Meta action
2018-05-27 01:32:14 +03:00
QAction * m_singleMetaAction ;
2019-02-02 18:16:17 +02:00
//! delayer for hiding the shown latte views
2019-02-02 18:01:52 +02:00
QTimer m_hideViewsTimer ;
QList < Latte : : View * > m_hideViews ;
2017-06-04 01:58:03 +03:00
2019-02-02 17:46:35 +02:00
QPointer < ShortcutsPart : : ModifierTracker > m_modifierTracker ;
2019-02-03 00:10:07 +02:00
QPointer < ShortcutsPart : : ShortcutsTracker > m_shortcutsTracker ;
2019-02-02 17:46:35 +02:00
QPointer < Latte : : Corona > m_corona ;
2017-06-04 01:58:03 +03:00
} ;
}
# endif // GLOBALSHORTCUTS_H