forked from linuxdeepin/dde-launcher
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathmainframe.h
187 lines (161 loc) · 5.56 KB
/
mainframe.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
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
#ifndef MAINFRAME_H
#define MAINFRAME_H
#include "gradientlabel.h"
#include "searchwidget.h"
#include "navigationwidget.h"
#include "categorytitlewidget.h"
#include "delegate/appitemdelegate.h"
#include "global_util/util.h"
#include "global_util/calculate_util.h"
#include "global_util/constants.h"
#include "model/appsmanager.h"
#include "model/appslistmodel.h"
#include "view/applistview.h"
#include "worker/menuworker.h"
#include "dbusinterface/dbusdisplay.h"
#include "widgets/applistarea.h"
#include "boxframe/boxframe.h"
#include <QFrame>
#include <QScrollArea>
#include <QPropertyAnimation>
#include <QSettings>
#include <QTimer>
#include <QGSettings>
#include <dboxwidget.h>
DWIDGET_USE_NAMESPACE
class BackgroundManager;
class DBusLauncherService;
class MainFrame : public BoxFrame
{
Q_OBJECT
Q_PROPERTY(int dockPosition READ dockPosition DESIGNABLE true)
public:
enum DisplayMode {
AllApps,
GroupByCategory,
Search,
};
public:
explicit MainFrame(QWidget *parent = 0);
void exit();
void uninstallApp(const QString &appKey);
void showByMode(const qlonglong mode);
int dockPosition();
signals:
void categoryAppNumsChanged(const AppsListModel::AppCategory category, const int appNums);
void displayModeChanged(const DisplayMode mode);
void currentVisibleCategoryChanged(const AppsListModel::AppCategory currentVisibleCategory) const;
public slots:
void scrollToCategory(const AppsListModel::AppCategory &category);
void showTips(const QString &tips);
void hideTips();
protected:
void resizeEvent(QResizeEvent *e);
void keyPressEvent(QKeyEvent *e);
void showEvent(QShowEvent *e);
void mouseReleaseEvent(QMouseEvent *e);
void wheelEvent(QWheelEvent *e);
void paintEvent(QPaintEvent *e);
bool event(QEvent *e);
bool eventFilter(QObject *o, QEvent *e);
private:
void initUI();
void initConnection();
void initTimer();
void updateGeometry();
void moveCurrentSelectApp(const int key);
void launchCurrentApp();
void checkCategoryVisible();
void showPopupMenu(const QPoint &pos, const QModelIndex &context);
void showPopupUninstallDialog(const QModelIndex &context);
void updateDisplayMode(const DisplayMode mode);
void updateCurrentVisibleCategory();
void updatePlaceholderSize();
void updateDockPosition();
DisplayMode getDisplayMode();
AppsListModel *nextCategoryModel(const AppsListModel *currentModel);
AppsListModel *prevCategoryModel(const AppsListModel *currentModel);
private slots:
void layoutChanged();
void searchTextChanged(const QString &keywords);
void ensureScrollToDest(const QVariant &value);
void ensureItemVisible(const QModelIndex &index);
void refershCategoryVisible(const AppsListModel::AppCategory category, const int appNums);
void showGradient();
void refreshTitleVisible();
void refershCategoryTextVisible();
void refershCurrentFloatTitle();
private:
CategoryTitleWidget *categoryTitle(const AppsListModel::AppCategory category) const;
AppListView *categoryView(const AppsListModel::AppCategory category) const;
AppListView *lastVisibleView() const;
private:
bool m_isConfirmDialogShown = false;
bool m_refershCategoryTextVisible = false;
int m_autoScrollStep = DLauncher::APPS_AREA_AUTO_SCROLL_STEP;
double rightMarginRation = 1;
DisplayMode m_displayMode = Search;
AppsListModel::AppCategory m_currentCategory = AppsListModel::All;
QGSettings *m_launcherGsettings;
BackgroundManager *m_backgroundManager;
DBusDisplay *m_displayInter;
CalculateUtil *m_calcUtil;
AppsManager *m_appsManager;
QPropertyAnimation *m_scrollAnimation;
QWidget *m_scrollDest;
QTimer *m_delayHideTimer;
QTimer *m_autoScrollTimer;
NavigationWidget *m_navigationWidget;
QWidget *m_rightSpacing;
SearchWidget *m_searchWidget;
AppListArea *m_appsArea;
DVBoxWidget *m_appsVbox;
MenuWorker* m_menuWorker;
QWidget *m_viewListPlaceholder;
QLabel *m_tipsLabel;
AppItemDelegate *m_appItemDelegate;
GradientLabel* m_topGradient;
GradientLabel* m_bottomGradient;
AppListView *m_allAppsView;
AppListView *m_internetView;
AppListView * m_chatView;
AppListView *m_musicView;
AppListView *m_videoView;
AppListView *m_graphicsView;
AppListView *m_gameView;
AppListView *m_officeView;
AppListView *m_readingView;
AppListView *m_developmentView;
AppListView *m_systemView;
AppListView *m_othersView;
AppsListModel *m_allAppsModel;
AppsListModel *m_searchResultModel;
AppsListModel *m_internetModel;
AppsListModel *m_chatModel;
AppsListModel *m_musicModel;
AppsListModel *m_videoModel;
AppsListModel *m_graphicsModel;
AppsListModel *m_gameModel;
AppsListModel *m_officeModel;
AppsListModel *m_readingModel;
AppsListModel *m_developmentModel;
AppsListModel *m_systemModel;
AppsListModel *m_othersModel;
CategoryTitleWidget* m_floatTitle;
CategoryTitleWidget *m_internetTitle;
CategoryTitleWidget *m_chatTitle;
CategoryTitleWidget *m_musicTitle;
CategoryTitleWidget *m_videoTitle;
CategoryTitleWidget *m_graphicsTitle;
CategoryTitleWidget *m_gameTitle;
CategoryTitleWidget *m_officeTitle;
CategoryTitleWidget *m_readingTitle;
CategoryTitleWidget *m_developmentTitle;
CategoryTitleWidget *m_systemTitle;
CategoryTitleWidget *m_othersTitle;
QVBoxLayout *m_scrollAreaLayout;
QHBoxLayout *m_mainLayout;
QVBoxLayout *m_contentLayout;
};
Q_DECLARE_METATYPE(MainFrame::DisplayMode)
#endif // MAINFRAME_H