From 4b0552e3efafa1eadcd2968be0a51e0124ffca32 Mon Sep 17 00:00:00 2001 From: nowrep Date: Sun, 2 Jun 2013 18:25:25 +0200 Subject: [PATCH] [GreaseMonkey] Added "Edit in text editor" button to script info. --- src/plugins/GreaseMonkey/gm_script.cpp | 2 + src/plugins/GreaseMonkey/gm_script.h | 3 + .../settings/gm_settingsscriptinfo.cpp | 46 +++- .../settings/gm_settingsscriptinfo.h | 6 + .../settings/gm_settingsscriptinfo.ui | 202 ++++++++++-------- .../StatusBarIcons/statusbariconsplugin.cpp | 2 +- 6 files changed, 160 insertions(+), 101 deletions(-) diff --git a/src/plugins/GreaseMonkey/gm_script.cpp b/src/plugins/GreaseMonkey/gm_script.cpp index 0e4d9fc85..3558bc8db 100644 --- a/src/plugins/GreaseMonkey/gm_script.cpp +++ b/src/plugins/GreaseMonkey/gm_script.cpp @@ -152,6 +152,8 @@ void GM_Script::watchedFileChanged(const QString &file) m_manager->removeScript(this, false); m_manager->addScript(this); + + emit scriptChanged(); } } diff --git a/src/plugins/GreaseMonkey/gm_script.h b/src/plugins/GreaseMonkey/gm_script.h index d50bb3278..86d396c7c 100644 --- a/src/plugins/GreaseMonkey/gm_script.h +++ b/src/plugins/GreaseMonkey/gm_script.h @@ -61,6 +61,9 @@ public: bool match(const QString &urlString); +signals: + void scriptChanged(); + private slots: void watchedFileChanged(const QString &file); diff --git a/src/plugins/GreaseMonkey/settings/gm_settingsscriptinfo.cpp b/src/plugins/GreaseMonkey/settings/gm_settingsscriptinfo.cpp index c5ca9ba1b..ff9684ba6 100644 --- a/src/plugins/GreaseMonkey/settings/gm_settingsscriptinfo.cpp +++ b/src/plugins/GreaseMonkey/settings/gm_settingsscriptinfo.cpp @@ -19,23 +19,47 @@ #include "ui_gm_settingsscriptinfo.h" #include "../gm_script.h" -GM_SettingsScriptInfo::GM_SettingsScriptInfo(GM_Script* script, QWidget* parent) : - QDialog(parent), - ui(new Ui::GM_SettingsScriptInfo) +#include + +GM_SettingsScriptInfo::GM_SettingsScriptInfo(GM_Script* script, QWidget* parent) + : QDialog(parent) + , ui(new Ui::GM_SettingsScriptInfo) + , m_script(script) { ui->setupUi(this); - setWindowTitle(tr("Script Details of %1").arg(script->name())); + loadScript(); - ui->name->setText(script->fullName()); - ui->version->setText(script->version()); - ui->url->setText(script->downloadUrl().toString()); - ui->startAt->setText(script->startAt() == GM_Script::DocumentStart ? "document-start" : "document-end"); - ui->description->setText(script->description()); - ui->include->setText(script->include().join("
")); - ui->exclude->setText(script->exclude().join("
")); + connect(m_script, SIGNAL(scriptChanged()), this, SLOT(loadScript())); + connect(ui->editInEditor, SIGNAL(clicked()), this, SLOT(editInTextEditor())); +} + +void GM_SettingsScriptInfo::editInTextEditor() +{ + QDesktopServices::openUrl(QUrl::fromLocalFile(m_script->fileName())); +} + +void GM_SettingsScriptInfo::loadScript() +{ + setWindowTitle(tr("Script Details of %1").arg(m_script->name())); + + ui->name->setText(m_script->name()); + ui->nspace->setText(m_script->nameSpace()); + ui->version->setText(m_script->version()); + ui->url->setText(m_script->downloadUrl().toString()); + ui->startAt->setText(m_script->startAt() == GM_Script::DocumentStart ? "document-start" : "document-end"); + ui->description->setText(m_script->description()); + ui->include->setText(m_script->include().join("
")); + ui->exclude->setText(m_script->exclude().join("
")); + + ui->version->setVisible(!m_script->version().isEmpty()); + ui->labelVersion->setVisible(!m_script->version().isEmpty()); + + ui->url->setVisible(!m_script->downloadUrl().isEmpty()); + ui->labelUrl->setVisible(!m_script->downloadUrl().isEmpty()); } GM_SettingsScriptInfo::~GM_SettingsScriptInfo() { delete ui; } + diff --git a/src/plugins/GreaseMonkey/settings/gm_settingsscriptinfo.h b/src/plugins/GreaseMonkey/settings/gm_settingsscriptinfo.h index f08d0a227..187eb2284 100644 --- a/src/plugins/GreaseMonkey/settings/gm_settingsscriptinfo.h +++ b/src/plugins/GreaseMonkey/settings/gm_settingsscriptinfo.h @@ -35,8 +35,14 @@ public: explicit GM_SettingsScriptInfo(GM_Script* script, QWidget* parent = 0); ~GM_SettingsScriptInfo(); +private slots: + void editInTextEditor(); + void loadScript(); + private: Ui::GM_SettingsScriptInfo* ui; + + GM_Script* m_script; }; #endif // GM_SETTINGSSCRIPTINFO_H diff --git a/src/plugins/GreaseMonkey/settings/gm_settingsscriptinfo.ui b/src/plugins/GreaseMonkey/settings/gm_settingsscriptinfo.ui index 724ac526c..7c39198fe 100644 --- a/src/plugins/GreaseMonkey/settings/gm_settingsscriptinfo.ui +++ b/src/plugins/GreaseMonkey/settings/gm_settingsscriptinfo.ui @@ -10,60 +10,10 @@ 408 - + - - - - Name: - - - Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter - - - - - - - Version: - - - Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter - - - - - - - URL: - - - Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter - - - - - - - Start at: - - - Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter - - - - - - - Description: - - - Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter - - - - + Runs at: @@ -73,15 +23,11 @@ - - - - Does not run at: - - - Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter - - + + + + + @@ -93,27 +39,37 @@ - - + + - + Description: - - Qt::LinksAccessibleByMouse|Qt::TextSelectableByMouse + + Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter + + + + + + + Version: + + + Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter + + + + + + + Start at: + + + Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter - - - - - - Qt::LinksAccessibleByMouse|Qt::TextSelectableByMouse - - - - @@ -123,26 +79,94 @@ - - + + + + Name: + + + Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter + + - - + + + + + + + Qt::LinksAccessibleByMouse|Qt::TextSelectableByMouse + + + + + + + + + + Qt::LinksAccessibleByMouse|Qt::TextSelectableByMouse + + + + + + + URL: + + + Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter + + - + + + + + + Does not run at: + + + Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter + + + + + + + Namespace: + + + Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter + + + + + - - - Qt::Horizontal - - - QDialogButtonBox::Close - - + + + + + Edit in text editor + + + + + + + Qt::Horizontal + + + QDialogButtonBox::Close + + + + diff --git a/src/plugins/StatusBarIcons/statusbariconsplugin.cpp b/src/plugins/StatusBarIcons/statusbariconsplugin.cpp index 0285332c4..d671ec9ce 100644 --- a/src/plugins/StatusBarIcons/statusbariconsplugin.cpp +++ b/src/plugins/StatusBarIcons/statusbariconsplugin.cpp @@ -75,7 +75,7 @@ bool StatusBarIconsPlugin::testPlugin() return (QupZilla::VERSION == QLatin1String("1.5.0")); } -QTranslator *StatusBarIconsPlugin::getTranslator(const QString &locale) +QTranslator* StatusBarIconsPlugin::getTranslator(const QString &locale) { QTranslator* translator = new QTranslator(this); translator->load(locale, ":/sbi/locale/");