Very minor UI tweak
[vlc-remote] / accountdialog.cpp
index c87215a..ecdb02f 100644 (file)
@@ -1,3 +1,20 @@
+/*   VLC-REMOTE for MAEMO 5
+*   Copyright (C) 2010 Schutz Sacha <istdasklar@gmail.com>, Dru Moore <usr@dru-id.co.uk>, Yann Nave <yannux@onbebop.net>
+*   This program is free software; you can redistribute it and/or modify
+*   it under the terms of the GNU General Public License version 2,
+*   or (at your option) any later version, as published by the Free
+*   Software Foundation
+*
+*   This program is distributed in the hope that it will be useful,
+*   but WITHOUT ANY WARRANTY; without even the implied warranty of
+*   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+*   GNU General Public License for more details
+*
+*   You should have received a copy of the GNU General Public
+*   License along with this program; if not, write to the
+*   Free Software Foundation, Inc.,
+*   51 Franklin Street, Fifth Floor, Boston, MA  02110-1301, USA.
+*/
 #include "accountdialog.h"
 #include "ui_accountdialog.h"
 #include "newaccountdialog.h"
@@ -109,22 +126,28 @@ void AccountDialog::load()
 
 QListWidgetItem AccountDialog::asyncTestItem(const QListWidgetItem& item)
 {
+    //==========> NEED TO USE POINTER TO AVOID setAsyncItem! But I don't know how;..
     QListWidgetItem newItem = item;
 
     QTcpSocket * socket = new QTcpSocket;
     QSettings settings;
     QString host = settings.value("account/"+item.text()).toString();
-    QStringList hostSplit = host.split(":");
-    QString ip   = hostSplit.at(0);
-    QString port = hostSplit.at(1);
 
+    if(host.contains(":"))
+    {
+        QStringList hostSplit = host.split(":");
+        QString ip   = hostSplit.at(0);
+        QString port = hostSplit.at(1);
+        socket->connectToHost(ip,port.toInt());
+    }
 
-    socket->connectToHost(ip,port.toInt());
+    else
+        socket->connectToHost(host,8080);
 
     if (socket->waitForConnected(1000))
-        newItem.setBackgroundColor(Qt::green);
+        newItem.setIcon(QIcon::fromTheme("widgets_tickmark_list"));
     else
-        newItem.setBackgroundColor(Qt::red);
+        newItem.setIcon(QIcon::fromTheme("statusarea_presence_busy_error"));
 
     return newItem;
 
@@ -138,7 +161,7 @@ void AccountDialog::setAsyncItem(int row)  // EDIT THE ROW AFTER ASYNC FUNCTION
     QListWidgetItem newItem = mFuturWatcher->resultAt(row);
     QListWidgetItem * item = ui->listWidget->item(row);
 
-    item->setBackgroundColor(newItem.backgroundColor());
+    item->setIcon(newItem.icon());
 
 
 
@@ -176,6 +199,7 @@ void AccountDialog::use()
     QSettings settings;
     settings.setValue("config/currentKey", currentKey);
     load();
+    emit accept();
 }
 
 void AccountDialog::enableUi()