File indexing completed on 2025-01-05 04:35:04
0001 /* ============================================================ 0002 * GreaseMonkey plugin for Falkon 0003 * Copyright (C) 2012-2013 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 "gm_settingsscriptinfo.h" 0019 #include "ui_gm_settingsscriptinfo.h" 0020 #include "../gm_script.h" 0021 0022 #include <QDesktopServices> 0023 0024 GM_SettingsScriptInfo::GM_SettingsScriptInfo(GM_Script* script, QWidget* parent) 0025 : QDialog(parent) 0026 , ui(new Ui::GM_SettingsScriptInfo) 0027 , m_script(script) 0028 { 0029 setAttribute(Qt::WA_DeleteOnClose); 0030 0031 ui->setupUi(this); 0032 loadScript(); 0033 0034 connect(m_script, &GM_Script::scriptChanged, this, &GM_SettingsScriptInfo::loadScript); 0035 connect(ui->editInEditor, &QAbstractButton::clicked, this, &GM_SettingsScriptInfo::editInTextEditor); 0036 } 0037 0038 void GM_SettingsScriptInfo::editInTextEditor() 0039 { 0040 QDesktopServices::openUrl(QUrl::fromLocalFile(m_script->fileName())); 0041 } 0042 0043 void GM_SettingsScriptInfo::loadScript() 0044 { 0045 setWindowTitle(tr("Script Details of %1").arg(m_script->name())); 0046 0047 ui->name->setText(m_script->name()); 0048 ui->nspace->setText(m_script->nameSpace()); 0049 ui->version->setText(m_script->version()); 0050 ui->url->setText(m_script->downloadUrl().toString()); 0051 ui->startAt->setText(m_script->startAt() == GM_Script::DocumentStart ? QSL("document-start") : QSL("document-end")); 0052 ui->description->setText(m_script->description()); 0053 ui->include->setText(m_script->include().join(QSL("<br/>"))); 0054 ui->exclude->setText(m_script->exclude().join(QSL("<br/>"))); 0055 0056 ui->version->setVisible(!m_script->version().isEmpty()); 0057 ui->labelVersion->setVisible(!m_script->version().isEmpty()); 0058 0059 ui->url->setVisible(!m_script->downloadUrl().isEmpty()); 0060 ui->labelUrl->setVisible(!m_script->downloadUrl().isEmpty()); 0061 } 0062 0063 GM_SettingsScriptInfo::~GM_SettingsScriptInfo() 0064 { 0065 delete ui; 0066 } 0067