diff --git a/src/core/core.cpp b/src/core/core.cpp index 2b9bb425b..cf713f33f 100644 --- a/src/core/core.cpp +++ b/src/core/core.cpp @@ -838,6 +838,11 @@ QString Core::getStatusMessage() const return sname; } +Status Core::getStatus() const +{ + return (Status)tox_self_get_status(tox); +} + void Core::setStatusMessage(const QString& message) { CString cMessage(message); diff --git a/src/core/core.h b/src/core/core.h index c0e325057..13fdbbe47 100644 --- a/src/core/core.h +++ b/src/core/core.h @@ -77,6 +77,7 @@ public: QString getIDString() const; ///< Get the 12 first characters of our Tox ID QString getUsername() const; ///< Returns our username, or an empty string on failure + Status getStatus() const; ///< Returns our user status QString getStatusMessage() const; ///< Returns our status message, or an empty string on failure ToxId getSelfId() const; ///< Returns our Tox ID QPair getKeypair() const; ///< Returns our public and private keys diff --git a/src/widget/form/settings/generalform.cpp b/src/widget/form/settings/generalform.cpp index 7e552fd85..8049449d0 100644 --- a/src/widget/form/settings/generalform.cpp +++ b/src/widget/form/settings/generalform.cpp @@ -360,10 +360,15 @@ void GeneralForm::onUseProxyUpdated() void GeneralForm::onReconnectClicked() { if (Core::getInstance()->anyActiveCalls()) + { QMessageBox::warning(this, tr("Call active", "popup title"), tr("You can't disconnect while a call is active!", "popup text")); + } else + { + emit Core::getInstance()->statusSet(Status::Offline); Nexus::getProfile()->restartCore(); + } } void GeneralForm::reloadSmiles() diff --git a/src/widget/widget.cpp b/src/widget/widget.cpp index a6a618bb4..1a13d7039 100644 --- a/src/widget/widget.cpp +++ b/src/widget/widget.cpp @@ -499,15 +499,11 @@ void Widget::onSelfAvatarLoaded(const QPixmap& pic) void Widget::onConnected() { ui->statusButton->setEnabled(true); - if (beforeDisconnect == Status::Offline) - emit statusSet(Status::Online); - else - emit statusSet(beforeDisconnect); + emit statusSet(Nexus::getCore()->getStatus()); } void Widget::onDisconnected() { - beforeDisconnect = getStatusFromString(ui->statusButton->property("status").toString()); ui->statusButton->setEnabled(false); emit statusSet(Status::Offline); } diff --git a/src/widget/widget.h b/src/widget/widget.h index 5ee59bfa5..aca1462cd 100644 --- a/src/widget/widget.h +++ b/src/widget/widget.h @@ -253,7 +253,6 @@ private: MaskablePixmapWidget *profilePicture; bool notify(QObject *receiver, QEvent *event); bool autoAwayActive = false; - Status beforeDisconnect = Status::Offline; QTimer *timer, *offlineMsgTimer; QRegExp nameMention, sanitizedNameMention; bool eventFlag;