@@ -164,6 +164,28 @@ void MainWindow::connectRemote() {
164
164
return ;
165
165
}
166
166
}
167
+
168
+ if (usingDefaultSession && defaultSession.loginType == LOGIN_TYPE_PASSWORD) {
169
+ if (!mqtt->setPassword (defaultSession.username , defaultSession.password )) {
170
+ cerr << " Setting username/password failed.\n " ;
171
+ QMessageBox::critical (this , tr (" Setting username/password failed" ),
172
+ tr (" Setting the username and/or password failed.\n\n \
173
+ Please check the provided info and try again." ));
174
+
175
+ return ;
176
+ }
177
+
178
+ }
179
+ else if (loadedSession.loginType == LOGIN_TYPE_PASSWORD) {
180
+ if (!mqtt->setPassword (loadedSession.username , loadedSession.password )) {
181
+ cerr << " Setting username/password failed.\n " ;
182
+ QMessageBox::critical (this , tr (" Setting username/password failed" ),
183
+ tr (" Setting the username and/or password failed.\n\n \
184
+ Please check the provided info and try again." ));
185
+
186
+ return ;
187
+ }
188
+ }
167
189
168
190
// Try to connect. If successful, update local copy and stored remote server address.
169
191
// The MQTT client class has to run on its own thread since it uses its own event loop.
@@ -216,6 +238,11 @@ void MainWindow::remoteConnected() {
216
238
void MainWindow::errorHandler (QString err) {
217
239
QMessageBox::warning (this , tr (" Error" ), err);
218
240
connected = false ;
241
+
242
+ // Reset UI elements.
243
+ ui->actionConnect ->setEnabled (true );
244
+ ui->actionDisconnect ->setEnabled (false );
245
+ ui->mainToolBar ->setDisabled (true );
219
246
}
220
247
221
248
0 commit comments