Connection tracker class finished.
[yandex-traffic] / tests / conn / mainwindow.hpp
index 0892bef..c854ff0 100644 (file)
@@ -4,16 +4,19 @@
 #include <QtGui>
 #include <connection.hpp>
 
-class MainWindow : public QWidget
+class MainWindow : public QPushButton
 {
     Q_OBJECT
 public:
     MainWindow ()
-        : QWidget ()
+        : QPushButton ()
     {
         ConnectionChecker *cc = ConnectionChecker::instance ();
 
         connect (cc, SIGNAL (connected (bool)), SLOT (connected (bool)));
+
+        setText (cc->isConnected () ? "Connected" : "Not connected");
+        connect (this, SIGNAL (clicked ()), SLOT (checkConnection ()));
     }
 
 protected slots:
@@ -23,6 +26,12 @@ protected slots:
             printf ("Device connected\n");
         else
             printf ("Device not connected\n");
+        setText (ConnectionChecker::instance ()->isConnected () ? "Connected" : "Not connected");
+    }
+
+    void checkConnection ()
+    {
+        ConnectionChecker::instance ()->requestState ();
     }
 };