Skip to content
This repository has been archived by the owner on Feb 12, 2023. It is now read-only.

Commit

Permalink
fix: remove reconnect button
Browse files Browse the repository at this point in the history
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.
  • Loading branch information
sudden6 authored and anthonybilinski committed Aug 28, 2019
1 parent 9819aef commit 909deb0
Show file tree
Hide file tree
Showing 7 changed files with 18 additions and 87 deletions.
10 changes: 0 additions & 10 deletions src/core/coreav.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -189,16 +189,6 @@ void CoreAV::process()
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.
* @param f the friend to check
Expand Down
1 change: 0 additions & 1 deletion src/core/coreav.h
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,6 @@ class CoreAV : public QObject

~CoreAV();

bool anyActiveCalls() const;
bool isCallStarted(const Friend* f) const;
bool isCallStarted(const Group* f) const;
bool isCallActive(const Friend* f) const;
Expand Down
34 changes: 0 additions & 34 deletions src/persistence/profile.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -786,40 +786,6 @@ const ToxEncrypt* Profile::getPasskey() const
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
* @param newPassword Password for encryption, if empty profile will be decrypted.
Expand Down
1 change: 0 additions & 1 deletion src/persistence/profile.h
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,6 @@ class Profile : public QObject
QString getName() const;

void startCore();
void restartCore();
bool isEncrypted() const;
QString setPassword(const QString& newPassword);
const ToxEncrypt* getPasskey() const;
Expand Down
21 changes: 4 additions & 17 deletions src/widget/form/settings/advancedform.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -27,9 +27,6 @@
#include <QMessageBox>
#include <QProcess>

#include "src/core/core.h"
#include "src/core/coreav.h"
#include "src/nexus.h"
#include "src/model/status.h"
#include "src/persistence/profile.h"
#include "src/persistence/settings.h"
Expand Down Expand Up @@ -73,9 +70,11 @@ AdvancedForm::AdvancedForm()
QString warningBody = tr("Unless you %1 know what you are doing, "
"please do %2 change anything here. Changes "
"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("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;\">"
"<p><b>%1</b></p><p>%2</p></div>")
Expand Down Expand Up @@ -215,18 +214,6 @@ void AdvancedForm::on_proxyType_currentIndexChanged(int index)
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.
*/
Expand Down
1 change: 0 additions & 1 deletion src/widget/form/settings/advancedform.h
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,6 @@ private slots:
void on_proxyAddr_editingFinished();
void on_proxyPort_valueChanged(int port);
void on_proxyType_currentIndexChanged(int index);
void on_reconnectButton_clicked();

private:
void retranslateUi();
Expand Down
37 changes: 14 additions & 23 deletions src/widget/form/settings/advancedsettings.ui
Original file line number Diff line number Diff line change
Expand Up @@ -121,19 +121,19 @@
</property>
</widget>
</item>
<item>
<layout class="QVBoxLayout" name="verticalLayout_6">
<property name="leftMargin">
<number>40</number>
</property>
<item>
<widget class="QCheckBox" name="cbEnableLanDiscovery">
<property name="text">
<string>Enable LAN discovery</string>
</property>
</widget>
</item>
</layout>
<item>
<layout class="QVBoxLayout" name="verticalLayout_6">
<property name="leftMargin">
<number>40</number>
</property>
<item>
<widget class="QCheckBox" name="cbEnableLanDiscovery">
<property name="text">
<string>Enable LAN discovery</string>
</property>
</widget>
</item>
</layout>
</item>
</layout>
</item>
Expand Down Expand Up @@ -201,15 +201,7 @@
</layout>
</item>
<item>
<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>
<layout class="QHBoxLayout" name="horizontalLayout_4"/>
</item>
</layout>
</widget>
Expand Down Expand Up @@ -258,7 +250,6 @@
<tabstop>proxyType</tabstop>
<tabstop>proxyAddr</tabstop>
<tabstop>proxyPort</tabstop>
<tabstop>reconnectButton</tabstop>
<tabstop>resetButton</tabstop>
</tabstops>
<resources/>
Expand Down

0 comments on commit 909deb0

Please sign in to comment.