window.hh (1483B)
1 #ifndef __GUCK__BROWSER__WINDOW__GUARD__ 2 #define __GUCK__BROWSER__WINDOW__GUARD__ 3 4 #include "../common.hh" 5 6 #include "tabbar/tab.hh" 7 #include "statusbar/status.hh" 8 9 #include <QWidget> 10 #include <QKeyEvent> 11 12 #include <vector> 13 #include <iostream> 14 15 16 typedef class window_t : public QWidget 17 { 18 Q_OBJECT 19 20 public: 21 window_t() 22 : m_statusbar(new status_t(*this)) 23 { 24 QWidget::resize(800, 600); 25 QWidget::setWindowTitle(BROWSER_NAME.c_str()); 26 27 m_statusbar->resize(); 28 29 m_tabs.push_back((m_current_tab = new tab_t{*this})); 30 m_tabs.front()->open(DEFAULT_HOMEPAGE.c_str()); 31 32 show(); 33 } 34 35 virtual ~window_t() 36 { 37 for (size_t i = 0; i < m_tabs.size(); ++i) 38 delete m_tabs[i]; 39 } 40 41 protected: 42 void resizeEvent(QResizeEvent*) override; 43 44 void keyPressEvent(QKeyEvent *event) override 45 { 46 std::cout << "press " << event->key() << std::endl; 47 QWidget::keyPressEvent(event); 48 } 49 50 void keyReleaseEvent(QKeyEvent *event) override 51 { 52 std::cout << "release " << event->key() << std::endl; 53 QWidget::keyReleaseEvent(event); 54 } 55 56 private slots: 57 void on_url_send(); 58 void on_toggle_released(); 59 void on_gen_released(); 60 void on_selection_changed(); 61 void on_back(); 62 void on_forward(); 63 64 private: 65 tab_ptr_t m_current_tab; 66 std::vector<tab_ptr_t> m_tabs; 67 status_ptr_t m_statusbar; 68 69 }* window_ptr_t; 70 71 #endif//__GUCK__BROWSER__WINDOW__GUARD__