File indexing completed on 2024-05-19 04:59:19

0001 /* ============================================================
0002 * StatusBarIcons - Extra icons in statusbar for Falkon
0003 * Copyright (C) 2013-2014  David Rosca <nowrep@gmail.com>
0004 *
0005 * This program is free software: you can redistribute it and/or modify
0006 * it under the terms of the GNU General Public License as published by
0007 * the Free Software Foundation, either version 3 of the License, or
0008 * (at your option) any later version.
0009 *
0010 * This program is distributed in the hope that it will be useful,
0011 * but WITHOUT ANY WARRANTY; without even the implied warranty of
0012 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
0013 * GNU General Public License for more details.
0014 *
0015 * You should have received a copy of the GNU General Public License
0016 * along with this program.  If not, see <http://www.gnu.org/licenses/>.
0017 * ============================================================ */
0018 #include "sbi_settingsdialog.h"
0019 #include "ui_sbi_settingsdialog.h"
0020 #include "sbi_iconsmanager.h"
0021 
0022 SBI_SettingsDialog::SBI_SettingsDialog(SBI_IconsManager* manager, QWidget* parent)
0023     : QDialog(parent)
0024     , ui(new Ui::SBI_SettingsDialog)
0025     , m_manager(manager)
0026 {
0027     setAttribute(Qt::WA_DeleteOnClose);
0028 
0029     ui->setupUi(this);
0030 
0031     ui->showImagesIcon->setChecked(m_manager->showImagesIcon());
0032     ui->showJavaScriptIcon->setChecked(m_manager->showJavaScriptIcon());
0033     ui->showNetworkIcon->setChecked(m_manager->showNetworkIcon());
0034     ui->showZoomWidget->setChecked(m_manager->showZoomWidget());
0035 
0036     connect(ui->buttonBox, &QDialogButtonBox::accepted, this, &SBI_SettingsDialog::saveSettings);
0037     connect(ui->buttonBox, &QDialogButtonBox::rejected, this, &QWidget::close);
0038 }
0039 
0040 void SBI_SettingsDialog::saveSettings()
0041 {
0042     m_manager->setShowImagesIcon(ui->showImagesIcon->isChecked());
0043     m_manager->setShowJavaScriptIcon(ui->showJavaScriptIcon->isChecked());
0044     m_manager->setShowNetworkIcon(ui->showNetworkIcon->isChecked());
0045     m_manager->setShowZoomWidget(ui->showZoomWidget->isChecked());
0046 
0047     m_manager->reloadIcons();
0048     close();
0049 }
0050 
0051 SBI_SettingsDialog::~SBI_SettingsDialog()
0052 {
0053     delete ui;
0054 }