Commit 449abef5 authored by Marzanna's avatar Marzanna Committed by Linus Jahn

Clean up coding style (#28)

Closes #23.
parent 2144d981
...@@ -16,14 +16,15 @@ Kaidan::Kaidan(NetworkFactories* networkFactories, QObject *parent) : ...@@ -16,14 +16,15 @@ Kaidan::Kaidan(NetworkFactories* networkFactories, QObject *parent) :
Kaidan::~Kaidan() Kaidan::~Kaidan()
{ {
if(connected){ if (connected)
{
client->removePayloadSerializer(&echoPayloadSerializer); client->removePayloadSerializer(&echoPayloadSerializer);
client->removePayloadParserFactory(&echoPayloadParserFactory); client->removePayloadParserFactory(&echoPayloadParserFactory);
softwareVersionResponder->stop(); softwareVersionResponder->stop();
delete tracer; delete tracer;
delete softwareVersionResponder;
delete client;
} }
delete softwareVersionResponder;
delete client;
delete rosterController_; delete rosterController_;
} }
...@@ -50,8 +51,10 @@ void Kaidan::mainConnect(const QString &jid, const QString &pass){ ...@@ -50,8 +51,10 @@ void Kaidan::mainConnect(const QString &jid, const QString &pass){
} }
//we don't want to close client without disconnection //we don't want to close client without disconnection
void Kaidan::mainDisconnect(){ void Kaidan::mainDisconnect()
if(connectionState()){ {
if (connectionState())
{
client->disconnect(); client->disconnect();
} }
} }
...@@ -78,7 +81,8 @@ void Kaidan::handleConnected() ...@@ -78,7 +81,8 @@ void Kaidan::handleConnected()
rosterController_->requestRosterFromClient(client); rosterController_->requestRosterFromClient(client);
} }
void Kaidan::handleDisconnected(){ void Kaidan::handleDisconnected()
{
connected = false; connected = false;
emit connectionStateDisconnected(); emit connectionStateDisconnected();
} }
...@@ -103,6 +107,7 @@ RosterController* Kaidan::getRosterController() ...@@ -103,6 +107,7 @@ RosterController* Kaidan::getRosterController()
return rosterController_; return rosterController_;
} }
bool Kaidan::connectionState() const{ bool Kaidan::connectionState() const
{
return connected; return connected;
} }
...@@ -2,15 +2,15 @@ import QtQuick 2.5 ...@@ -2,15 +2,15 @@ import QtQuick 2.5
import QtQuick.Controls 1.2 import QtQuick.Controls 1.2
import harbour.kaidan 1.0 import harbour.kaidan 1.0
Item{ Item {
Column{ Column {
Row{ Row {
TextField{ TextField {
id: jidField id: jidField
width: 150 width: 150
placeholderText: "JID" placeholderText: "JID"
} }
TextField{ TextField {
id: passField id: passField
width: 150 width: 150
height: 27 height: 27
...@@ -18,27 +18,29 @@ Item{ ...@@ -18,27 +18,29 @@ Item{
echoMode: TextInput.Password echoMode: TextInput.Password
} }
} }
Button{ Button {
id: connectButton id: connectButton
text: "Connect" text: "Connect"
onClicked:{ onClicked: {
connectButton.enabled = false; connectButton.enabled = false;
kaidan.mainConnect(jidField.text, passField.text); kaidan.mainConnect(jidField.text, passField.text);
} }
} }
Label{ Label {
id: statusLabel id: statusLabel
text: "Not connected" text: "Not connected"
} }
} }
Component.onCompleted:{ Component.onCompleted: {
function goToRoster(){ function goToRoster() {
statusLabel.text = "Connected"; statusLabel.text = "Connected";
//we need to disconnect enableConnectButton to prevent calling it on normal disconnection //we need to disconnect enableConnectButton to prevent calling it on normal disconnection
kaidan.connectionStateDisconnected.disconnect(enableConnectButton) kaidan.connectionStateDisconnected.disconnect(enableConnectButton)
mainLoader.source = "RosterPage.qml" mainLoader.source = "RosterPage.qml"
} }
function enableConnectButton(){connectButton.enabled = true} function enableConnectButton() {
connectButton.enabled = true
}
kaidan.connectionStateConnected.connect(goToRoster) kaidan.connectionStateConnected.connect(goToRoster)
kaidan.connectionStateDisconnected.connect(enableConnectButton) kaidan.connectionStateDisconnected.connect(enableConnectButton)
} }
......
import QtQuick 2.1 import QtQuick 2.1
import harbour.kaidan 1.0 import harbour.kaidan 1.0
Flickable{ Flickable {
ListView { ListView {
anchors.fill: parent anchors.fill: parent
model: kaidan.rosterController.rosterList model: kaidan.rosterController.rosterList
......
...@@ -2,12 +2,12 @@ import QtQuick 2.1 ...@@ -2,12 +2,12 @@ import QtQuick 2.1
import QtQuick.Controls 1.4 import QtQuick.Controls 1.4
import harbour.kaidan 1.0 import harbour.kaidan 1.0
ApplicationWindow{ ApplicationWindow {
visible: true visible: true
width: 360 width: 360
height: 720 height: 720
Loader{ Loader {
id: mainLoader id: mainLoader
anchors.fill: parent anchors.fill: parent
source: "LoginPage.qml" source: "LoginPage.qml"
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment