tab.hh (1182B)
1 #ifndef __GUCK__BROWSER__STATUSBAR__TAB__GUARD__ 2 #define __GUCK__BROWSER__STATUSBAR__TAB__GUARD__ 3 4 #include "../../defaults.hh" 5 6 #include <QKeyEvent> 7 #include <QUrl> 8 #include <QWebEngineView> 9 #include <QWidget> 10 11 #include <iostream> 12 13 class key_filter_t : public QObject 14 { 15 Q_OBJECT 16 17 protected: 18 bool eventFilter(QObject* obj, QEvent* event) 19 { 20 if (event->type() == QEvent::KeyPress) { 21 QKeyEvent* key = static_cast<QKeyEvent*>(event); 22 23 std::cout << "QWebEngineView " << key->key() << std::endl; 24 25 return QObject::eventFilter(obj, event); 26 } else { 27 return QObject::eventFilter(obj, event); 28 } 29 return false; 30 } 31 }; 32 33 typedef class tab_t : public QWebEngineView 34 { 35 Q_OBJECT 36 37 public: 38 tab_t(QWidget& parent) 39 : QWebEngineView(&parent), 40 m_parent(parent) 41 { 42 installEventFilter(new key_filter_t()); 43 44 QWebEngineView::move(0, TAB_HEIGHT); 45 resize(); 46 } 47 48 virtual ~tab_t() {} 49 50 void resize(); 51 52 void open(const std::string&&); 53 void open(QUrl); 54 55 private: 56 QWidget& m_parent; 57 58 }* tab_ptr_t; 59 60 #endif//__GUCK__BROWSER__STATUSBAR__TAB__GUARD__