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

refactor: remove Core::getInstance from PrivacyForm

This commit is contained in:
sudden6 2020-05-01 15:02:55 +02:00
parent 2809cd91f5
commit ef18afcbf1
No known key found for this signature in database
GPG Key ID: 279509B499E032B9
3 changed files with 13 additions and 8 deletions

View File

@ -39,9 +39,10 @@
#include "src/widget/translator.h" #include "src/widget/translator.h"
#include "src/widget/widget.h" #include "src/widget/widget.h"
PrivacyForm::PrivacyForm() PrivacyForm::PrivacyForm(Core* _core)
: GenericForm(QPixmap(":/img/settings/privacy.png")) : GenericForm(QPixmap(":/img/settings/privacy.png"))
, bodyUI(new Ui::PrivacySettings) , bodyUI(new Ui::PrivacySettings)
, core{_core}
{ {
bodyUI->setupUi(this); bodyUI->setupUi(this);
@ -85,14 +86,15 @@ void PrivacyForm::on_nospamLineEdit_editingFinished()
bool ok; bool ok;
uint32_t nospam = newNospam.toLongLong(&ok, 16); uint32_t nospam = newNospam.toLongLong(&ok, 16);
if (ok) if (ok) {
Core::getInstance()->setNospam(nospam); core->setNospam(nospam);
}
} }
void PrivacyForm::showEvent(QShowEvent*) void PrivacyForm::showEvent(QShowEvent*)
{ {
const Settings& s = Settings::getInstance(); const Settings& s = Settings::getInstance();
bodyUI->nospamLineEdit->setText(Core::getInstance()->getSelfId().getNoSpamString()); bodyUI->nospamLineEdit->setText(core->getSelfId().getNoSpamString());
bodyUI->cbTypingNotification->setChecked(s.getTypingNotification()); bodyUI->cbTypingNotification->setChecked(s.getTypingNotification());
bodyUI->cbKeepHistory->setChecked(Settings::getInstance().getEnableLogging()); bodyUI->cbKeepHistory->setChecked(Settings::getInstance().getEnableLogging());
bodyUI->blackListTextEdit->setText(s.getBlackList().join('\n')); bodyUI->blackListTextEdit->setText(s.getBlackList().join('\n'));
@ -115,8 +117,8 @@ void PrivacyForm::on_randomNosapamButton_clicked()
newNospam = (newNospam << 8) + (qrand() % 256); // Generate byte by byte. For some reason. newNospam = (newNospam << 8) + (qrand() % 256); // Generate byte by byte. For some reason.
#endif #endif
Core::getInstance()->setNospam(newNospam); core->setNospam(newNospam);
bodyUI->nospamLineEdit->setText(Core::getInstance()->getSelfId().getNoSpamString()); bodyUI->nospamLineEdit->setText(core->getSelfId().getNoSpamString());
} }
void PrivacyForm::on_nospamLineEdit_textChanged() void PrivacyForm::on_nospamLineEdit_textChanged()

View File

@ -22,6 +22,8 @@
#include "genericsettings.h" #include "genericsettings.h"
class Core;
namespace Ui { namespace Ui {
class PrivacySettings; class PrivacySettings;
} }
@ -30,7 +32,7 @@ class PrivacyForm : public GenericForm
{ {
Q_OBJECT Q_OBJECT
public: public:
PrivacyForm(); PrivacyForm(Core* _core);
~PrivacyForm(); ~PrivacyForm();
QString getFormName() final QString getFormName() final
{ {
@ -54,6 +56,7 @@ private:
private: private:
Ui::PrivacySettings* bodyUI; Ui::PrivacySettings* bodyUI;
Core* core;
}; };
#endif #endif

View File

@ -61,7 +61,7 @@ SettingsWidget::SettingsWidget(UpdateCheck* updateCheck, IAudioControl& audio, C
connect(gfrm.get(), &GeneralForm::updateIcons, parent, &Widget::updateIcons); connect(gfrm.get(), &GeneralForm::updateIcons, parent, &Widget::updateIcons);
std::unique_ptr<UserInterfaceForm> uifrm(new UserInterfaceForm(this)); std::unique_ptr<UserInterfaceForm> uifrm(new UserInterfaceForm(this));
std::unique_ptr<PrivacyForm> pfrm(new PrivacyForm()); std::unique_ptr<PrivacyForm> pfrm(new PrivacyForm(core));
connect(pfrm.get(), &PrivacyForm::clearAllReceipts, parent, &Widget::clearAllReceipts); connect(pfrm.get(), &PrivacyForm::clearAllReceipts, parent, &Widget::clearAllReceipts);
AVForm* rawAvfrm = new AVForm(audio, coreAV, camera, audioSettings, videoSettings); AVForm* rawAvfrm = new AVForm(audio, coreAV, camera, audioSettings, videoSettings);