Refactor code. Add tabs for enabling using two remote controls at once.
[qzeecontrol] / btconnector.cpp
index 57fafb6..aeca38a 100644 (file)
@@ -56,6 +56,23 @@ void BtConnector::connect(QString address, int port){
     QObject::connect(socket, SIGNAL(readyRead()), this, SLOT(readData()));
 }
 
+void BtConnector::disconnect(){
+    if(!socket)
+        return;
+
+    if(socket->isOpen())
+        socket->close();
+
+    delete socket;
+    socket = 0;
+
+    /*
+     * Explicitly set D to false in case the remote was shut off
+     * using the power key, which equals the 'D' key.
+     */
+    setD(false);
+}
+
 void BtConnector::readData(){
 //        qDebug("readData...");
     QByteArray data = socket->readAll();