diff options
Diffstat (limited to 'src/ui/settings/SettingsDialog.cpp')
-rw-r--r-- | src/ui/settings/SettingsDialog.cpp | 115 |
1 files changed, 54 insertions, 61 deletions
diff --git a/src/ui/settings/SettingsDialog.cpp b/src/ui/settings/SettingsDialog.cpp index dc84e8ac..2c23858f 100644 --- a/src/ui/settings/SettingsDialog.cpp +++ b/src/ui/settings/SettingsDialog.cpp @@ -1,4 +1,6 @@ /** + * Copyright (C) 2021 Saturneric + * * This file is part of GpgFrontend. * * GpgFrontend is free software: you can redistribute it and/or modify @@ -6,118 +8,109 @@ * the Free Software Foundation, either version 3 of the License, or * (at your option) any later version. * - * Foobar is distributed in the hope that it will be useful, + * GpgFrontend is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * * You should have received a copy of the GNU General Public License - * along with Foobar. If not, see <https://www.gnu.org/licenses/>. + * along with GpgFrontend. If not, see <https://www.gnu.org/licenses/>. + * + * The initial version of the source code is inherited from + * the gpg4usb project, which is under GPL-3.0-or-later. * - * The initial version of the source code is inherited from gpg4usb-team. - * Their source code version also complies with GNU General Public License. + * All the source code of GpgFrontend was modified and released by + * Saturneric<[email protected]> starting on May 12, 2021. * - * The source code version of this software was modified and released - * by Saturneric<[email protected]> starting on May 12, 2021. + * SPDX-License-Identifier: GPL-3.0-or-later * */ #include "SettingsDialog.h" -#include "GlobalSettingStation.h" -#include "SettingsAdvanced.h" -#include "SettingsAppearance.h" -#include "SettingsGeneral.h" -#include "SettingsKeyServer.h" -#include "SettingsNetwork.h" +#include "core/function/GlobalSettingStation.h" +#include "ui/settings/SettingsAdvanced.h" +#include "ui/settings/SettingsAppearance.h" +#include "ui/settings/SettingsGeneral.h" +#include "ui/settings/SettingsKeyServer.h" +#include "ui/settings/SettingsNetwork.h" +#include "ui/main_window/MainWindow.h" #ifdef SMTP_SUPPORT -#include "SettingsSendMail.h" +#include "ui/settings/SettingsSendMail.h" #endif namespace GpgFrontend::UI { SettingsDialog::SettingsDialog(QWidget* parent) : QDialog(parent) { - tabWidget = new QTabWidget(); - generalTab = new GeneralTab(); - appearanceTab = new AppearanceTab(); + tab_widget_ = new QTabWidget(); + general_tab_ = new GeneralTab(); + appearance_tab_ = new AppearanceTab(); #ifdef SMTP_SUPPORT - sendMailTab = new SendMailTab(); + send_mail_tab_ = new SendMailTab(); #endif - keyserverTab = new KeyserverTab(); - networkTab = new NetworkTab(); + key_server_tab_ = new KeyserverTab(); + network_tab_ = new NetworkTab(); #ifdef ADVANCED_SUPPORT advancedTab = new AdvancedTab; #endif - tabWidget->addTab(generalTab, _("General")); - tabWidget->addTab(appearanceTab, _("Appearance")); + tab_widget_->addTab(general_tab_, _("General")); + tab_widget_->addTab(appearance_tab_, _("Appearance")); #ifdef SMTP_SUPPORT - tabWidget->addTab(sendMailTab, _("Send Mail")); + tab_widget_->addTab(send_mail_tab_, _("Send Mail")); #endif - tabWidget->addTab(keyserverTab, _("Key Server")); + tab_widget_->addTab(key_server_tab_, _("Key Server")); // tabWidget->addTab(gpgPathsTab, _("Gpg paths")); - tabWidget->addTab(networkTab, _("Network")); + tab_widget_->addTab(network_tab_, _("Network")); #ifdef ADVANCED_SUPPORT tabWidget->addTab(advancedTab, _("Advanced")); #endif - buttonBox = + button_box_ = new QDialogButtonBox(QDialogButtonBox::Ok | QDialogButtonBox::Cancel); - connect(buttonBox, SIGNAL(accepted()), this, SLOT(slotAccept())); - connect(buttonBox, SIGNAL(rejected()), this, SLOT(reject())); + connect(button_box_, &QDialogButtonBox::accepted, this, &SettingsDialog::SlotAccept); + connect(button_box_, &QDialogButtonBox::rejected, this, &SettingsDialog::reject); auto* mainLayout = new QVBoxLayout; - mainLayout->addWidget(tabWidget); + mainLayout->addWidget(tab_widget_); mainLayout->stretch(0); - mainLayout->addWidget(buttonBox); + mainLayout->addWidget(button_box_); mainLayout->stretch(0); setLayout(mainLayout); setWindowTitle(_("Settings")); - // slots for handling the restartneeded member - this->slotSetRestartNeeded(false); - connect(generalTab, SIGNAL(signalRestartNeeded(bool)), this, - SLOT(slotSetRestartNeeded(bool))); - connect(appearanceTab, SIGNAL(signalRestartNeeded(bool)), this, - SLOT(slotSetRestartNeeded(bool))); -#ifdef SMTP_SUPPORT - connect(sendMailTab, SIGNAL(signalRestartNeeded(bool)), this, - SLOT(slotSetRestartNeeded(bool))); -#endif - connect(keyserverTab, SIGNAL(signalRestartNeeded(bool)), this, - SLOT(slotSetRestartNeeded(bool))); -#ifdef ADVANCED_SUPPORT - connect(advancedTab, SIGNAL(signalRestartNeeded(bool)), this, - SLOT(slotSetRestartNeeded(bool))); -#endif - - connect(this, SIGNAL(signalRestartNeeded(bool)), parent, - SLOT(slotSetRestartNeeded(bool))); + // slots for handling the restart needed member + this->slot_set_restart_needed(false); + connect(general_tab_, &GeneralTab::SignalRestartNeeded, this, + &SettingsDialog::slot_set_restart_needed); + connect(this, &SettingsDialog::SignalRestartNeeded, qobject_cast<MainWindow *>(parent), &MainWindow::SlotSetRestartNeeded); this->setMinimumSize(480, 680); this->adjustSize(); this->show(); } -bool SettingsDialog::getRestartNeeded() const { return this->restartNeeded; } +bool SettingsDialog::get_restart_needed() const { + return this->restart_needed_; +} -void SettingsDialog::slotSetRestartNeeded(bool needed) { - this->restartNeeded = needed; +void SettingsDialog::slot_set_restart_needed(bool needed) { + this->restart_needed_ = needed; } -void SettingsDialog::slotAccept() { +void SettingsDialog::SlotAccept() { LOG(INFO) << "Called"; - generalTab->applySettings(); + general_tab_->ApplySettings(); #ifdef SMTP_SUPPORT - sendMailTab->applySettings(); + send_mail_tab_->ApplySettings(); #endif - appearanceTab->applySettings(); - keyserverTab->applySettings(); - networkTab->applySettings(); + appearance_tab_->ApplySettings(); + key_server_tab_->ApplySettings(); + network_tab_->ApplySettings(); #ifdef ADVANCED_SUPPORT advancedTab->applySettings(); #endif @@ -127,14 +120,14 @@ void SettingsDialog::slotAccept() { // write settings to filesystem GlobalSettingStation::GetInstance().SyncSettings(); - LOG(INFO) << "restart needed" << getRestartNeeded(); - if (getRestartNeeded()) { - emit signalRestartNeeded(true); + LOG(INFO) << "restart needed" << get_restart_needed(); + if (get_restart_needed()) { + emit SignalRestartNeeded(true); } close(); } -QHash<QString, QString> SettingsDialog::listLanguages() { +QHash<QString, QString> SettingsDialog::ListLanguages() { QHash<QString, QString> languages; languages.insert(QString(), _("System Default")); |