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

0001 /* ============================================================
0002 * Falkon - Qt web browser
0003 * Copyright (C) 2013-2014  David Rosca <nowrep@gmail.com>
0004                 2013-2014  Mladen Pejaković <pejakm@autistici.org>
0005 *
0006 * This program is free software: you can redistribute it and/or modify
0007 * it under the terms of the GNU General Public License as published by
0008 * the Free Software Foundation, either version 3 of the License, or
0009 * (at your option) any later version.
0010 *
0011 * This program is distributed in the hope that it will be useful,
0012 * but WITHOUT ANY WARRANTY; without even the implied warranty of
0013 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
0014 * GNU General Public License for more details.
0015 *
0016 * You should have received a copy of the GNU General Public License
0017 * along with this program.  If not, see <http://www.gnu.org/licenses/>.
0018 * ============================================================ */
0019 #include "jsoptions.h"
0020 #include "ui_jsoptions.h"
0021 #include "mainapplication.h"
0022 #include "settings.h"
0023 #include <QtWebEngineWidgetsVersion>
0024 
0025 JsOptions::JsOptions(QWidget* parent)
0026     : QDialog(parent)
0027     , ui(new Ui::JsOptions)
0028 {
0029     setAttribute(Qt::WA_DeleteOnClose);
0030 
0031     ui->setupUi(this);
0032 
0033     Settings settings;
0034     settings.beginGroup(QSL("Web-Browser-Settings"));
0035     ui->jscanOpenWindow->setChecked(settings.value(QSL("allowJavaScriptOpenWindow"), false).toBool());
0036     ui->jscanActivateWindow->setChecked(settings.value(QSL("allowJavaScriptActivateWindow"), false).toBool());
0037     ui->jscanAccessClipboard->setChecked(settings.value(QSL("allowJavaScriptAccessClipboard"), true).toBool());
0038     ui->jscanPaste->setChecked(settings.value(QSL("allowJavaScriptPaste"), true).toBool());
0039     settings.endGroup();
0040 }
0041 
0042 void JsOptions::accept()
0043 {
0044     Settings settings;
0045     settings.beginGroup(QSL("Web-Browser-Settings"));
0046     settings.setValue(QSL("allowJavaScriptOpenWindow"), ui->jscanOpenWindow->isChecked());
0047     settings.setValue(QSL("allowJavaScriptActivateWindow"), ui->jscanActivateWindow->isChecked());
0048     settings.setValue(QSL("allowJavaScriptAccessClipboard"), ui->jscanAccessClipboard->isChecked());
0049     settings.setValue(QSL("allowJavaScriptPaste"), ui->jscanPaste->isChecked());
0050     settings.endGroup();
0051 
0052     QDialog::close();
0053 }
0054 
0055 JsOptions::~JsOptions()
0056 {
0057     delete ui;
0058 }