[TFIVE-232] Increased the timer for long press event as shutdown dialog require longe...
[sdk/emulator/qemu.git] / tizen / src / ui / menu / contextmenu.h
1 /*
2  * Qt UI
3  *
4  * Copyright (C) 2014 Samsung Electronics Co., Ltd. All rights reserved.
5  *
6  * Contact:
7  * SungMin Ha <sungmin82.ha@samsung.com>
8  * GiWoong Kim <giwoong.kim@samsung.com>
9  * SeokYeon Hwang <syeon.hwang@samsung.com>
10  * Sangho Park <sangho.p@samsung.com>
11  *
12  * This program is free software; you can redistribute it and/or
13  * modify it under the terms of the GNU General Public License
14  * as published by the Free Software Foundation; either version 2
15  * of the License, or (at your option) any later version.
16  *
17  * This program is distributed in the hope that it will be useful,
18  * but WITHOUT ANY WARRANTY; without even the implied warranty of
19  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
20  * GNU General Public License for more details.
21  *
22  * You should have received a copy of the GNU General Public License
23  * along with this program; if not, write to the Free Software
24  * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston,
25  * MA 02110-1301, USA.
26  *
27  * Contributors:
28  * - S-Core Co., Ltd
29  *
30  */
31
32 #ifndef CONTEXTMENU_H
33 #define CONTEXTMENU_H
34
35 #include <QtWidgets>
36
37 #include "emulator_common.h"
38 #include "detailedinfodialog.h"
39 #include "aboutdialog.h"
40 #include "screenshotdialog.h"
41 #include "menu/menuitem.h"
42 #include "menu/sdbhelper.h"
43 #include "input/keyboardshortcut.h"
44
45 class MainWindow;
46
47 extern "C" {
48 #include "emul_state.h"
49 }
50
51 #define CLOSE_POWER_KEY_INTERVAL 3000 /* milli-seconds */
52 #define HARDWARE_REBOOT_INTERVAL 1000 /* milli-seconds */
53
54 class ContextMenu : public QMenu
55 {
56     Q_OBJECT
57
58 public:
59     explicit ContextMenu(QWidget *parent = 0);
60     ~ContextMenu();
61
62     QAction *getOnTopAction();
63
64     QSignalMapper *getSwitchMapper();
65     QSignalMapper *getScaleMapper();
66     QSignalMapper *getControllerMapper();
67
68     ScreenShotDialog *screenshotDialog;
69
70 public slots:
71     void slotAmbiguousShortcut();
72
73     void slotDetailedInfo();
74     void slotOnTop(bool on);
75     void slotOnTopShortcut();
76     void slotMove();
77     void slotSwitch(int index);
78     void slotSwitchShortcutPrev();
79     void slotSwitchShortcutNext();
80
81     void slotScale(int scale);
82     void slotScaleShortcutPrev();
83     void slotScaleShortcutNext();
84
85     void slotController(int index);
86     void slotCloseCon();
87     void slotConShortcutPrev();
88     void slotConShortcutNext();
89
90     void slotShell();
91     void slotControlPanel();
92     void slotRequestScreenshot();
93     void slotShowScreenshot(const QPixmap &);
94     void slotHostKeyboard(bool on);
95     void slotAbout();
96
97     void slotSystemReset();
98     void slotDeviceReset();
99
100     void slotForceClose();
101     void slotClose();
102     void slotPwkeyRelease();
103
104     void slotUndefinedMenu();
105
106 protected:
107     void createItems(QMenu *menu, QList<MenuItem *> &list);
108     void createSeparator(QMenu *menu);
109     void createAdvancedItem(QMenu *menu, MenuItem *item);
110
111     void createInfoItem(QMenu *menu, MenuItem *item);
112     void createOnTopItem(QMenu *menu, MenuItem *item);
113     void createMoveItem(QMenu *menu, MenuItem *item);
114     void createSwitchItem(QMenu *menu, MenuItem *item);
115     void createScaleItem(QMenu *menu, MenuItem *item);
116     void createControllerItem(QMenu *menu, MenuItem *item);
117     void createHostKeyboardItem(QMenu *menu, MenuItem *item);
118     void createShellItem(QMenu *menu, MenuItem *item);
119     void createControlPanelItem(QMenu *menu, MenuItem *item);
120     void createScreenShotItem(QMenu *menu, MenuItem *item);
121     void createAboutItem(QMenu *menu, MenuItem *item);
122     void createSystemResetItem(QMenu *menu, MenuItem *item);
123     void createForceCloseItem(QMenu *menu, MenuItem *item);
124     void createCloseItem(QMenu *menu, MenuItem *item);
125     bool eventFilter(QObject *obj, QEvent *event);
126
127 private:
128     void launchControlPanel(QString &, QStringList &);
129     QAction *addGeneralAction(QMenu *menu, const QIcon &icon,
130         const QString &text, QShortcut *shortcut, const char *slot);
131     void attachShortcut(QAction *action, QShortcut *shortcut, const char *slot);
132
133     MainWindow *parent;
134     QString vmName;
135     DetailedInfoDialog *infoDialog;
136     AboutDialog *aboutDialog;
137
138     QMenu *advancedMenu;
139     QMenu *switchMenu;
140     QMenu *scaleMenu;
141     QMenu *controllerMenu;
142
143     QActionGroup *switchGroup;
144     QActionGroup *scaleGroup;
145     QActionGroup *keyboardGroup;
146     QActionGroup *controllerGroup;
147
148     QAction *actionDetailedInfo;
149     QAction *actionOnTop;
150     QAction *actionMove;
151     QAction *actionShell;
152     QAction *actionControlPanel;
153     QAction *actionScreenShot;
154     QAction *actionAbout;
155     QAction *actionSystemReset;
156     QAction *actionForceClose;
157     QAction *actionClose;
158
159     QSignalMapper *switchMapper;
160     QSignalMapper *scaleMapper;
161     QSignalMapper *controllerMapper;
162
163     SdbHelper *sdbHelper;
164     QTimer *longPressTimer;
165     QTimer *rebootTimer;
166 };
167 #endif // CONTEXTMENU_H