equal
deleted
inserted
replaced
|
1 #ifndef CONTENTVIEWCONTEXTMENU_H |
|
2 #define CONTENTVIEWCONTEXTMENU_H |
|
3 |
|
4 #include <QMenu> |
|
5 #include <QTimer> |
|
6 |
|
7 #include "ContextMenu.h" |
|
8 |
|
9 namespace GVA { |
|
10 |
|
11 /*! |
|
12 * Context menu implementation for web content views. |
|
13 */ |
|
14 class ContentViewContextMenu : public ContextMenu { |
|
15 Q_OBJECT |
|
16 public: |
|
17 ContentViewContextMenu(QWebHitTestResult *hitTest, QWidget *parent = 0); |
|
18 |
|
19 virtual void addAction(QAction *action) { |
|
20 m_menu.addAction(action); |
|
21 } |
|
22 |
|
23 virtual void addAction(const QString text, const QObject * receiver, const char * member, const QKeySequence & shortcut = 0) { |
|
24 m_menu.addAction(text, receiver, member, shortcut); |
|
25 } |
|
26 |
|
27 virtual void exec(const QPoint & p) { |
|
28 if(!m_menu.isEmpty()){ |
|
29 QPoint newp(p); |
|
30 |
|
31 if(p.x() < 570) // left part of the screen; depends on screen size. should be replaced by something more reliable |
|
32 newp.rx()+=20; // start menu 20 px right of point p |
|
33 else // right part of the screen |
|
34 newp.rx()-=(20 + m_menu.sizeHint().width()); //start menu left of point p |
|
35 m_menu.exec(newp); |
|
36 } |
|
37 } |
|
38 |
|
39 private slots: |
|
40 void onOpenLink(); |
|
41 void onShareLink(); |
|
42 void onShareImage(); |
|
43 void onSaveImage(); |
|
44 void onViewImage(); |
|
45 |
|
46 protected: |
|
47 QMenu m_menu; |
|
48 QWebHitTestResult *m_hitTest; |
|
49 }; |
|
50 |
|
51 } // GVA namespace |
|
52 |
|
53 #endif // CONTENTVIEWCONTEXTMENU_H |