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

fix: remove reconnect button

The button didn't work that well and caused all kinds of issues inside
the code, so I replaced it by a notice that changes to the Advanced
settings only apply after a restart of qTox.

In the process I also removed all code that was exclusively used for
that feature.

We may add it back later when qTox's internal architecture makes it less
cumbersome.
This commit is contained in:
sudden6 2019-08-10 19:43:11 +02:00 committed by Anthony Bilinski
parent 9819aefc44
commit 909deb0feb
No known key found for this signature in database
GPG Key ID: 2AA8E0DA1B31FB3C
7 changed files with 18 additions and 87 deletions

View File

@ -189,16 +189,6 @@ void CoreAV::process()
iterateTimer->start(toxav_iteration_interval(toxav.get())); iterateTimer->start(toxav_iteration_interval(toxav.get()));
} }
/**
* @brief Check, if any calls are currently active.
* @return true if any calls are currently active, false otherwise
* @note A call about to start is not yet active.
*/
bool CoreAV::anyActiveCalls() const
{
return !calls.empty();
}
/** /**
* @brief Checks the call status for a Tox friend. * @brief Checks the call status for a Tox friend.
* @param f the friend to check * @param f the friend to check

View File

@ -52,7 +52,6 @@ public:
~CoreAV(); ~CoreAV();
bool anyActiveCalls() const;
bool isCallStarted(const Friend* f) const; bool isCallStarted(const Friend* f) const;
bool isCallStarted(const Group* f) const; bool isCallStarted(const Group* f) const;
bool isCallActive(const Friend* f) const; bool isCallActive(const Friend* f) const;

View File

@ -786,40 +786,6 @@ const ToxEncrypt* Profile::getPasskey() const
return passkey.get(); return passkey.get();
} }
/**
* @brief Delete core and restart a new one
*/
void Profile::restartCore()
{
GUI::setEnabled(false); // Core::reset re-enables it
if (core && !isRemoved) {
// TODO(sudden6): there's a potential race condition between unlocking the core loop
// and killing the core
const QByteArray& savedata = core->getToxSaveData();
// save to disk just in case
if (saveToxSave(savedata)) {
qDebug() << "Restarting Core";
const bool isNewProfile{false};
IAudioControl* audioBak = core->getAv()->getAudio();
assert(audioBak != nullptr);
initCore(savedata, Settings::getInstance(), isNewProfile);
core->getAv()->setAudio(*audioBak);
// kriby: code duplication belongs in initCore, but cannot yet due to Core/Profile coupling
connect(core.get(), &Core::requestSent, this, &Profile::onRequestSent);
emit coreChanged(*core);
core->start();
} else {
qCritical() << "Failed to save, not restarting core";
}
}
GUI::setEnabled(true);
}
/** /**
* @brief Changes the encryption password and re-saves everything with it * @brief Changes the encryption password and re-saves everything with it
* @param newPassword Password for encryption, if empty profile will be decrypted. * @param newPassword Password for encryption, if empty profile will be decrypted.

View File

@ -47,7 +47,6 @@ public:
QString getName() const; QString getName() const;
void startCore(); void startCore();
void restartCore();
bool isEncrypted() const; bool isEncrypted() const;
QString setPassword(const QString& newPassword); QString setPassword(const QString& newPassword);
const ToxEncrypt* getPasskey() const; const ToxEncrypt* getPasskey() const;

View File

@ -27,9 +27,6 @@
#include <QMessageBox> #include <QMessageBox>
#include <QProcess> #include <QProcess>
#include "src/core/core.h"
#include "src/core/coreav.h"
#include "src/nexus.h"
#include "src/model/status.h" #include "src/model/status.h"
#include "src/persistence/profile.h" #include "src/persistence/profile.h"
#include "src/persistence/settings.h" #include "src/persistence/settings.h"
@ -73,9 +70,11 @@ AdvancedForm::AdvancedForm()
QString warningBody = tr("Unless you %1 know what you are doing, " QString warningBody = tr("Unless you %1 know what you are doing, "
"please do %2 change anything here. Changes " "please do %2 change anything here. Changes "
"made here may lead to problems with qTox, and even " "made here may lead to problems with qTox, and even "
"to loss of your data, e.g. history.") "to loss of your data, e.g. history."
"%3")
.arg(QString("<b>%1</b>").arg(tr("really"))) .arg(QString("<b>%1</b>").arg(tr("really")))
.arg(QString("<b>%1</b>").arg(tr("not"))); .arg(QString("<b>%1</b>").arg(tr("not")))
.arg(QString("<p>%1</p>").arg(tr("Changes here are applied only after restarting qTox.")));
QString warning = QString("<div style=\"color:#ff0000;\">" QString warning = QString("<div style=\"color:#ff0000;\">"
"<p><b>%1</b></p><p>%2</p></div>") "<p><b>%1</b></p><p>%2</p></div>")
@ -215,18 +214,6 @@ void AdvancedForm::on_proxyType_currentIndexChanged(int index)
Settings::getInstance().setProxyType(proxytype); Settings::getInstance().setProxyType(proxytype);
} }
void AdvancedForm::on_reconnectButton_clicked()
{
if (Core::getInstance()->getAv()->anyActiveCalls()) {
QMessageBox::warning(this, tr("Call active", "popup title"),
tr("You can't disconnect while a call is active!", "popup text"));
return;
}
emit Core::getInstance()->statusSet(Status::Status::Offline);
Nexus::getProfile()->restartCore();
}
/** /**
* @brief Retranslate all elements in the form. * @brief Retranslate all elements in the form.
*/ */

View File

@ -53,7 +53,6 @@ private slots:
void on_proxyAddr_editingFinished(); void on_proxyAddr_editingFinished();
void on_proxyPort_valueChanged(int port); void on_proxyPort_valueChanged(int port);
void on_proxyType_currentIndexChanged(int index); void on_proxyType_currentIndexChanged(int index);
void on_reconnectButton_clicked();
private: private:
void retranslateUi(); void retranslateUi();

View File

@ -122,18 +122,18 @@
</widget> </widget>
</item> </item>
<item> <item>
<layout class="QVBoxLayout" name="verticalLayout_6"> <layout class="QVBoxLayout" name="verticalLayout_6">
<property name="leftMargin"> <property name="leftMargin">
<number>40</number> <number>40</number>
</property> </property>
<item> <item>
<widget class="QCheckBox" name="cbEnableLanDiscovery"> <widget class="QCheckBox" name="cbEnableLanDiscovery">
<property name="text"> <property name="text">
<string>Enable LAN discovery</string> <string>Enable LAN discovery</string>
</property> </property>
</widget> </widget>
</item> </item>
</layout> </layout>
</item> </item>
</layout> </layout>
</item> </item>
@ -201,15 +201,7 @@
</layout> </layout>
</item> </item>
<item> <item>
<layout class="QHBoxLayout" name="horizontalLayout_4"> <layout class="QHBoxLayout" name="horizontalLayout_4"/>
<item>
<widget class="QPushButton" name="reconnectButton">
<property name="text">
<string comment="reconnect button">Reconnect</string>
</property>
</widget>
</item>
</layout>
</item> </item>
</layout> </layout>
</widget> </widget>
@ -258,7 +250,6 @@
<tabstop>proxyType</tabstop> <tabstop>proxyType</tabstop>
<tabstop>proxyAddr</tabstop> <tabstop>proxyAddr</tabstop>
<tabstop>proxyPort</tabstop> <tabstop>proxyPort</tabstop>
<tabstop>reconnectButton</tabstop>
<tabstop>resetButton</tabstop> <tabstop>resetButton</tabstop>
</tabstops> </tabstops>
<resources/> <resources/>