c854ff05665783bd230fc84367c636545801adea
[yandex-traffic] / tests / conn / mainwindow.hpp
1 #ifndef __MAINWINDOW_H__
2 #define __MAINWINDOW_H__
3
4 #include <QtGui>
5 #include <connection.hpp>
6
7 class MainWindow : public QPushButton
8 {
9     Q_OBJECT
10 public:
11     MainWindow ()
12         : QPushButton ()
13     {
14         ConnectionChecker *cc = ConnectionChecker::instance ();
15
16         connect (cc, SIGNAL (connected (bool)), SLOT (connected (bool)));
17
18         setText (cc->isConnected () ? "Connected" : "Not connected");
19         connect (this, SIGNAL (clicked ()), SLOT (checkConnection ()));
20     }
21
22 protected slots:
23     void connected (bool active)
24     {
25         if (active)
26             printf ("Device connected\n");
27         else
28             printf ("Device not connected\n");
29         setText (ConnectionChecker::instance ()->isConnected () ? "Connected" : "Not connected");
30     }
31
32     void checkConnection ()
33     {
34         ConnectionChecker::instance ()->requestState ();
35     }
36 };
37
38 #endif // __MAINWINDOW_H__