summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorQt Forward Merge Bot <qt_forward_merge_bot@qt-project.org>2018-12-15 03:00:12 +0100
committerQt Forward Merge Bot <qt_forward_merge_bot@qt-project.org>2018-12-15 03:00:12 +0100
commit306058b96ab8219a5176118e7cbe25d12b2e6aa6 (patch)
tree88209a0dca25ccf1dc80b179634a66170fe97449
parentb86ccb50ee7aa43463d3117dc9cd1c57ee185a60 (diff)
parentbf30507ef17445b464abe230f4bf349d732fbfd1 (diff)
Merge remote-tracking branch 'origin/5.12' into dev
-rw-r--r--examples/mqtt/quickpublication/main.qml25
-rw-r--r--examples/mqtt/quicksubscription/main.qml17
-rw-r--r--src/mqtt/qmqttconnection.cpp5
3 files changed, 33 insertions, 14 deletions
diff --git a/examples/mqtt/quickpublication/main.qml b/examples/mqtt/quickpublication/main.qml
index b018e68..dea9613 100644
--- a/examples/mqtt/quickpublication/main.qml
+++ b/examples/mqtt/quickpublication/main.qml
@@ -81,6 +81,7 @@ Window {
GridLayout {
anchors.fill: parent
+ anchors.margins: 10
columns: 2
Label {
@@ -113,19 +114,22 @@ Window {
Button {
id: connectButton
Layout.columnSpan: 2
+ Layout.fillWidth: true
text: client.state === MqttClient.Connected ? "Disconnect" : "Connect"
onClicked: {
- if (client.state === MqttClient.Connected)
+ if (client.state === MqttClient.Connected) {
client.disconnectFromHost()
- else
+ messageModel.clear()
+ } else
client.connectToHost()
}
}
- RowLayout {
+ GridLayout {
enabled: client.state === MqttClient.Connected
Layout.columnSpan: 2
Layout.fillWidth: true
+ columns: 4
Label {
text: "Topic:"
@@ -133,6 +137,7 @@ Window {
TextField {
id: pubField
+ Layout.fillWidth: true
placeholderText: "<Publication topic>"
}
@@ -142,14 +147,9 @@ Window {
TextField {
id: msgField
+ Layout.fillWidth: true
placeholderText: "<Publication message>"
}
- }
-
- RowLayout {
- enabled: client.state === MqttClient.Connected
- Layout.columnSpan: 2
- Layout.fillWidth: true
Label {
text: "QoS:"
@@ -157,6 +157,7 @@ Window {
ComboBox {
id: qosItems
+ Layout.fillWidth: true
editable: false
model: [0, 1, 2]
}
@@ -169,6 +170,7 @@ Window {
Button {
id: pubButton
+ Layout.fillWidth: true
text: "Publish"
onClicked: {
if (pubField.text.length === 0) {
@@ -187,8 +189,11 @@ Window {
height: 300
width: 200
Layout.fillHeight: true
+ Layout.fillWidth: true
+ Layout.columnSpan: 2
+ clip: true
delegate: Rectangle {
- width: 150
+ width: messageView.width
height: 30
color: index % 2 ? "#DDDDDD" : "#888888"
radius: 5
diff --git a/examples/mqtt/quicksubscription/main.qml b/examples/mqtt/quicksubscription/main.qml
index 7b930e2..4558c7e 100644
--- a/examples/mqtt/quicksubscription/main.qml
+++ b/examples/mqtt/quicksubscription/main.qml
@@ -83,6 +83,7 @@ Window {
GridLayout {
anchors.fill: parent
+ anchors.margins: 10
columns: 2
Label {
@@ -115,11 +116,15 @@ Window {
Button {
id: connectButton
Layout.columnSpan: 2
+ Layout.fillWidth: true
text: client.state === MqttClient.Connected ? "Disconnect" : "Connect"
onClicked: {
- if (client.state === MqttClient.Connected)
+ if (client.state === MqttClient.Connected) {
client.disconnectFromHost()
- else
+ messageModel.clear()
+ tempSubscription.destroy()
+ tempSubscription = 0
+ } else
client.connectToHost()
}
}
@@ -136,11 +141,14 @@ Window {
TextField {
id: subField
placeholderText: "<Subscription topic>"
+ Layout.fillWidth: true
+ enabled: tempSubscription === 0
}
Button {
id: subButton
text: "Subscribe"
+ visible: tempSubscription === 0
onClicked: {
if (subField.text.length === 0) {
console.log("No topic specified to subscribe to.")
@@ -157,9 +165,12 @@ Window {
model: messageModel
height: 300
width: 200
+ Layout.columnSpan: 2
Layout.fillHeight: true
+ Layout.fillWidth: true
+ clip: true
delegate: Rectangle {
- width: 150
+ width: messageView.width
height: 30
color: index % 2 ? "#DDDDDD" : "#888888"
radius: 5
diff --git a/src/mqtt/qmqttconnection.cpp b/src/mqtt/qmqttconnection.cpp
index f1ad7ec..150bbf4 100644
--- a/src/mqtt/qmqttconnection.cpp
+++ b/src/mqtt/qmqttconnection.cpp
@@ -674,7 +674,10 @@ void QMqttConnection::transportConnectionClosed()
m_readBuffer.clear();
m_readPosition = 0;
m_pingTimer.stop();
- m_clientPrivate->setStateAndError(QMqttClient::Disconnected, QMqttClient::TransportInvalid);
+ if (m_internalState == BrokerDisconnected) // We manually disconnected
+ m_clientPrivate->setStateAndError(QMqttClient::Disconnected, QMqttClient::NoError);
+ else
+ m_clientPrivate->setStateAndError(QMqttClient::Disconnected, QMqttClient::TransportInvalid);
}
void QMqttConnection::transportReadReady()