-
Notifications
You must be signed in to change notification settings - Fork 8
/
wingmenuwidget.h
139 lines (123 loc) · 3.8 KB
/
wingmenuwidget.h
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
#pragma once
#include <QAction>
#include <QActionGroup>
#include <QDomElement>
#include <QHBoxLayout>
#include <QLabel>
#include <QLineEdit>
#include <QListView>
#include <QMainWindow>
#include <QSortFilterProxyModel>
#include <QStackedWidget>
#include <QStandardItemModel>
#include <QStringList>
#include <QTimer>
#include <QToolButton>
#include <QVBoxLayout>
#include <QWidget>
#include <XdgAction>
#include <XdgDesktopFile>
#include <XdgIcon>
#include <XdgMenu>
#include "common.h"
class WingMenuPlugin;
class ApplicationsView;
class ItemDescriptionDelegate;
class MyModel;
class WingMenuWidget : public QWidget
{
Q_OBJECT
public:
enum DataType {
Comment = Qt::UserRole + 1,
Category = Qt::UserRole + 2,
DesktopFile = Qt::UserRole + 3,
SearchString = Qt::UserRole + 4,
Exec = Qt::UserRole + 5
};
Q_ENUM(DataType);
WingMenuWidget(WingMenuPlugin* plugin, XdgMenu* xdgMenu, QWidget* parent = nullptr);
~WingMenuWidget() = default;
void onShow();
void onHide();
void focusLineEdit();
void settingsChanged();
private:
WingMenuPlugin* mPlugin;
int mIconSize;
QHBoxLayout* mRootBox;
QVBoxLayout* mMainBox;
QHBoxLayout* mMenuBox;
QLineEdit* mSearchEdit;
QWidget* mSideWidget;
QVBoxLayout* mSideBox;
QSpacerItem* mSideSpacer;
QWidget* mCategoryWidget;
QVBoxLayout* mCategoryBox;
QStackedWidget* mApplicationsStack;
ApplicationsView* mApplicationsView;
QStandardItemModel* mApplicationsModel;
QSortFilterProxyModel* mProxyModel;
ApplicationsView* mFavoritesView;
QStandardItemModel* mFavoritesModel;
QActionGroup* mSideGroup;
QActionGroup* mCategoryGroup;
QTimer* mHoverTimer;
QAction* mHoveredAction;
QLabel* mFavoritesInfo;
QStringList mLeaveActions;
QStringList mOtherActions;
QString mLastCategory;
bool mCategoryLeft;
bool mSearchBottom;
bool mSidebarLeft;
bool mReverseSidebar;
AppLayout::Layout mAppLayout;
QStringList mFavoritesList;
bool mAskFavoriteRemove;
bool mSwitchOnHover;
int mHoverDelay;
bool mCustomizeLeave;
QStringList mCustomActions;
XdgMenu* mXdgMenu;
QDomElement mXml;
QString mLogDir;
QString mMenuFile;
QString mCurrentWidget;
void focusCategoryWidget();
void sendKeyToApplicationsList(Qt::Key key);
bool eventFilter(QObject* watched, QEvent* event) override;
void indexActivated(const QModelIndex& index);
void showCustomMenu(const QPoint& pos);
void buildMenu();
void connectSignals();
QToolButton* createSideButton(const XdgDesktopFile& df);
void buildSideButtons();
void parseSideActions(const QDomElement& xml);
QString escape(QString string);
void addMenu(const QDomElement& xml);
void addCategoryButton(const QIcon& icon, const QString& title, const QString& name);
void addItem(const QDomElement& xml, const QString& category);
void addItem(const XdgDesktopFile& df, const QString& category);
void setItemToolTip(QStandardItem* item);
void removeSpaces(QLayout* layout);
void removeSpaces(QWidget* widget);
void filterApplications(DataType type, const QString& filterString);
void sideActionTriggered(QAction* action);
void sideActionHovered(QAction* action);
void uncheckSideActions();
void categoryActionTriggered(QAction* action);
void categoryActionHovered(QAction* action);
void hoverTimeout();
void addItemToFavorites(const XdgDesktopFile& df);
void saveFavoritesList();
void removeFromFavorites(const QModelIndex& index);
void favoritesRowRemoved();
void moveFavoriteUp(int index);
void moveFavoriteDown(int index);
protected:
void mouseReleaseEvent(QMouseEvent* event) override;
void keyPressEvent(QKeyEvent* keyEvent) override;
signals:
void hideMenu();
};