2017-06-04 01:58:03 +03:00
/*
* Copyright 2016 Smith AR < audoban @ openmailbox . org >
* 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 GLOBALSHORTCUTS_H
# define GLOBALSHORTCUTS_H
2018-12-02 02:05:52 +02:00
// local
2018-12-07 18:55:35 +02:00
# include "../liblatte2/types.h"
2017-06-04 01:58:03 +03:00
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>
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 :
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 18:53:02 +02:00
bool activateLatteEntry ( const Latte : : View * view , int index , Qt : : Key modifier ) ;
bool activatePlasmaTaskManager ( const 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
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