1
0
mirror of https://github.com/qTox/qTox.git synced 2024-03-22 14:00:36 +08:00

Load user status from data file

This commit is contained in:
Impyy 2015-09-25 20:56:11 +02:00
parent 3ceb289020
commit c49ce6208e
5 changed files with 12 additions and 6 deletions

View File

@ -838,6 +838,11 @@ QString Core::getStatusMessage() const
return sname; return sname;
} }
Status Core::getStatus() const
{
return (Status)tox_self_get_status(tox);
}
void Core::setStatusMessage(const QString& message) void Core::setStatusMessage(const QString& message)
{ {
CString cMessage(message); CString cMessage(message);

View File

@ -77,6 +77,7 @@ public:
QString getIDString() const; ///< Get the 12 first characters of our Tox ID QString getIDString() const; ///< Get the 12 first characters of our Tox ID
QString getUsername() const; ///< Returns our username, or an empty string on failure 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 QString getStatusMessage() const; ///< Returns our status message, or an empty string on failure
ToxId getSelfId() const; ///< Returns our Tox ID ToxId getSelfId() const; ///< Returns our Tox ID
QPair<QByteArray, QByteArray> getKeypair() const; ///< Returns our public and private keys QPair<QByteArray, QByteArray> getKeypair() const; ///< Returns our public and private keys

View File

@ -360,11 +360,16 @@ void GeneralForm::onUseProxyUpdated()
void GeneralForm::onReconnectClicked() void GeneralForm::onReconnectClicked()
{ {
if (Core::getInstance()->anyActiveCalls()) if (Core::getInstance()->anyActiveCalls())
{
QMessageBox::warning(this, tr("Call active", "popup title"), QMessageBox::warning(this, tr("Call active", "popup title"),
tr("You can't disconnect while a call is active!", "popup text")); tr("You can't disconnect while a call is active!", "popup text"));
}
else else
{
emit Core::getInstance()->statusSet(Status::Offline);
Nexus::getProfile()->restartCore(); Nexus::getProfile()->restartCore();
} }
}
void GeneralForm::reloadSmiles() void GeneralForm::reloadSmiles()
{ {

View File

@ -499,15 +499,11 @@ void Widget::onSelfAvatarLoaded(const QPixmap& pic)
void Widget::onConnected() void Widget::onConnected()
{ {
ui->statusButton->setEnabled(true); ui->statusButton->setEnabled(true);
if (beforeDisconnect == Status::Offline) emit statusSet(Nexus::getCore()->getStatus());
emit statusSet(Status::Online);
else
emit statusSet(beforeDisconnect);
} }
void Widget::onDisconnected() void Widget::onDisconnected()
{ {
beforeDisconnect = getStatusFromString(ui->statusButton->property("status").toString());
ui->statusButton->setEnabled(false); ui->statusButton->setEnabled(false);
emit statusSet(Status::Offline); emit statusSet(Status::Offline);
} }

View File

@ -253,7 +253,6 @@ private:
MaskablePixmapWidget *profilePicture; MaskablePixmapWidget *profilePicture;
bool notify(QObject *receiver, QEvent *event); bool notify(QObject *receiver, QEvent *event);
bool autoAwayActive = false; bool autoAwayActive = false;
Status beforeDisconnect = Status::Offline;
QTimer *timer, *offlineMsgTimer; QTimer *timer, *offlineMsgTimer;
QRegExp nameMention, sanitizedNameMention; QRegExp nameMention, sanitizedNameMention;
bool eventFlag; bool eventFlag;