File indexing completed on 2024-09-08 13:20:22
0001 /* 0002 * Copyright 2016 Smith AR <audoban@openmailbox.org> 0003 * Michail Vourlakos <mvourlakos@gmail.com> 0004 * 0005 * This file is part of Latte-Dock 0006 * 0007 * Latte-Dock is free software; you can redistribute it and/or 0008 * modify it under the terms of the GNU General Public License as 0009 * published by the Free Software Foundation; either version 2 of 0010 * the License, or (at your option) any later version. 0011 * 0012 * Latte-Dock is distributed in the hope that it will be useful, 0013 * but WITHOUT ANY WARRANTY; without even the implied warranty of 0014 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 0015 * GNU General Public License for more details. 0016 * 0017 * You should have received a copy of the GNU General Public License 0018 * along with this program. If not, see <http://www.gnu.org/licenses/>. 0019 */ 0020 0021 #ifndef GLOBALSHORTCUTS_H 0022 #define GLOBALSHORTCUTS_H 0023 0024 // local 0025 #include "../liblatte2/types.h" 0026 0027 // Qt 0028 #include <QAction> 0029 #include <QPointer> 0030 #include <QTimer> 0031 0032 // KDE 0033 #include <kmodifierkeyinfo.h> 0034 0035 namespace Plasma { 0036 class Containment; 0037 } 0038 0039 namespace Latte { 0040 class Corona; 0041 class View; 0042 namespace ShortcutsPart{ 0043 class ModifierTracker; 0044 class ShortcutsTracker; 0045 } 0046 } 0047 0048 namespace Latte { 0049 0050 class GlobalShortcuts : public QObject 0051 { 0052 Q_OBJECT 0053 0054 public: 0055 GlobalShortcuts(QObject *parent = nullptr); 0056 ~GlobalShortcuts() override; 0057 0058 void activateLauncherMenu(); 0059 void updateViewItemBadge(QString identifier, QString value); 0060 0061 ShortcutsPart::ShortcutsTracker *shortcutsTracker() const; 0062 0063 signals: 0064 void modifiersChanged(); 0065 0066 private slots: 0067 void hideViewsTimerSlot(); 0068 0069 private: 0070 void init(); 0071 void initModifiers(); 0072 void activateEntry(int index, Qt::Key modifier); 0073 void showViews(); 0074 void showSettings(); 0075 0076 bool activateLatteEntry(Latte::View *view, int index, Qt::Key modifier, bool *delayedExecution); 0077 bool activatePlasmaTaskManager(const Latte::View *view, int index, Qt::Key modifier, bool *delayedExecution); 0078 bool viewAtLowerEdgePriority(Latte::View *test, Latte::View *base); 0079 bool viewAtLowerScreenPriority(Latte::View *test, Latte::View *base); 0080 bool viewsToHideAreValid(); 0081 0082 //! highest priority application launcher view 0083 Latte::View *highestApplicationLauncherView(const QList<Latte::View *> &views) const; 0084 0085 QList<Latte::View *> sortedViewsList(QHash<const Plasma::Containment *, Latte::View *> *views); 0086 0087 private: 0088 bool m_metaShowedViews{false}; 0089 0090 //! last action that was trigerred from the user 0091 QAction *m_lastInvokedAction; 0092 //! it is used for code compatibility reasons in order to replicate a single Meta action 0093 QAction *m_singleMetaAction; 0094 0095 //! delayer for hiding the shown latte views 0096 QTimer m_hideViewsTimer; 0097 QList<Latte::View *> m_hideViews; 0098 0099 QPointer<ShortcutsPart::ModifierTracker> m_modifierTracker; 0100 QPointer<ShortcutsPart::ShortcutsTracker> m_shortcutsTracker; 0101 QPointer<Latte::Corona> m_corona; 0102 }; 0103 0104 } 0105 0106 #endif // GLOBALSHORTCUTS_H