1
mirror of https://invent.kde.org/network/falkon.git synced 2024-12-20 10:46:35 +01:00

[GreaseMonkey] Added "Edit in text editor" button to script info.

This commit is contained in:
nowrep 2013-06-02 18:25:25 +02:00
parent 4d33b04310
commit 4b0552e3ef
6 changed files with 160 additions and 101 deletions

View File

@ -152,6 +152,8 @@ void GM_Script::watchedFileChanged(const QString &file)
m_manager->removeScript(this, false); m_manager->removeScript(this, false);
m_manager->addScript(this); m_manager->addScript(this);
emit scriptChanged();
} }
} }

View File

@ -61,6 +61,9 @@ public:
bool match(const QString &urlString); bool match(const QString &urlString);
signals:
void scriptChanged();
private slots: private slots:
void watchedFileChanged(const QString &file); void watchedFileChanged(const QString &file);

View File

@ -19,23 +19,47 @@
#include "ui_gm_settingsscriptinfo.h" #include "ui_gm_settingsscriptinfo.h"
#include "../gm_script.h" #include "../gm_script.h"
GM_SettingsScriptInfo::GM_SettingsScriptInfo(GM_Script* script, QWidget* parent) : #include <QDesktopServices>
QDialog(parent),
ui(new Ui::GM_SettingsScriptInfo) GM_SettingsScriptInfo::GM_SettingsScriptInfo(GM_Script* script, QWidget* parent)
: QDialog(parent)
, ui(new Ui::GM_SettingsScriptInfo)
, m_script(script)
{ {
ui->setupUi(this); ui->setupUi(this);
setWindowTitle(tr("Script Details of %1").arg(script->name())); loadScript();
ui->name->setText(script->fullName()); connect(m_script, SIGNAL(scriptChanged()), this, SLOT(loadScript()));
ui->version->setText(script->version()); connect(ui->editInEditor, SIGNAL(clicked()), this, SLOT(editInTextEditor()));
ui->url->setText(script->downloadUrl().toString()); }
ui->startAt->setText(script->startAt() == GM_Script::DocumentStart ? "document-start" : "document-end");
ui->description->setText(script->description()); void GM_SettingsScriptInfo::editInTextEditor()
ui->include->setText(script->include().join("<br/>")); {
ui->exclude->setText(script->exclude().join("<br/>")); 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("<br/>"));
ui->exclude->setText(m_script->exclude().join("<br/>"));
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() GM_SettingsScriptInfo::~GM_SettingsScriptInfo()
{ {
delete ui; delete ui;
} }

View File

@ -35,8 +35,14 @@ public:
explicit GM_SettingsScriptInfo(GM_Script* script, QWidget* parent = 0); explicit GM_SettingsScriptInfo(GM_Script* script, QWidget* parent = 0);
~GM_SettingsScriptInfo(); ~GM_SettingsScriptInfo();
private slots:
void editInTextEditor();
void loadScript();
private: private:
Ui::GM_SettingsScriptInfo* ui; Ui::GM_SettingsScriptInfo* ui;
GM_Script* m_script;
}; };
#endif // GM_SETTINGSSCRIPTINFO_H #endif // GM_SETTINGSSCRIPTINFO_H

View File

@ -10,60 +10,10 @@
<height>408</height> <height>408</height>
</rect> </rect>
</property> </property>
<layout class="QVBoxLayout" name="verticalLayout_2"> <layout class="QVBoxLayout" name="verticalLayout">
<item> <item>
<layout class="QGridLayout" name="gridLayout"> <layout class="QGridLayout" name="gridLayout">
<item row="0" column="0"> <item row="6" column="0">
<widget class="QLabel" name="label_3">
<property name="text">
<string>Name:</string>
</property>
<property name="alignment">
<set>Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter</set>
</property>
</widget>
</item>
<item row="1" column="0">
<widget class="QLabel" name="label_6">
<property name="text">
<string>Version:</string>
</property>
<property name="alignment">
<set>Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter</set>
</property>
</widget>
</item>
<item row="2" column="0">
<widget class="QLabel" name="label_5">
<property name="text">
<string>URL:</string>
</property>
<property name="alignment">
<set>Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter</set>
</property>
</widget>
</item>
<item row="3" column="0">
<widget class="QLabel" name="label_7">
<property name="text">
<string>Start at:</string>
</property>
<property name="alignment">
<set>Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter</set>
</property>
</widget>
</item>
<item row="4" column="0">
<widget class="QLabel" name="label_4">
<property name="text">
<string>Description:</string>
</property>
<property name="alignment">
<set>Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter</set>
</property>
</widget>
</item>
<item row="5" column="0">
<widget class="QLabel" name="label_8"> <widget class="QLabel" name="label_8">
<property name="text"> <property name="text">
<string>Runs at:</string> <string>Runs at:</string>
@ -73,15 +23,11 @@
</property> </property>
</widget> </widget>
</item> </item>
<item row="6" column="0"> <item row="5" column="1">
<widget class="QLabel" name="label_9"> <widget class="QTextBrowser" name="description"/>
<property name="text"> </item>
<string>Does not run at:</string> <item row="7" column="1">
</property> <widget class="QTextBrowser" name="exclude"/>
<property name="alignment">
<set>Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter</set>
</property>
</widget>
</item> </item>
<item row="0" column="1"> <item row="0" column="1">
<widget class="SqueezeLabelV2" name="name"> <widget class="SqueezeLabelV2" name="name">
@ -93,27 +39,37 @@
</property> </property>
</widget> </widget>
</item> </item>
<item row="3" column="1"> <item row="5" column="0">
<widget class="QLabel" name="startAt"> <widget class="QLabel" name="label_4">
<property name="text"> <property name="text">
<string/> <string>Description:</string>
</property> </property>
<property name="textInteractionFlags"> <property name="alignment">
<set>Qt::LinksAccessibleByMouse|Qt::TextSelectableByMouse</set> <set>Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter</set>
</property>
</widget>
</item>
<item row="2" column="0">
<widget class="QLabel" name="labelVersion">
<property name="text">
<string>Version:</string>
</property>
<property name="alignment">
<set>Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter</set>
</property>
</widget>
</item>
<item row="4" column="0">
<widget class="QLabel" name="label_7">
<property name="text">
<string>Start at:</string>
</property>
<property name="alignment">
<set>Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter</set>
</property> </property>
</widget> </widget>
</item> </item>
<item row="2" column="1"> <item row="2" column="1">
<widget class="SqueezeLabelV2" name="url">
<property name="text">
<string/>
</property>
<property name="textInteractionFlags">
<set>Qt::LinksAccessibleByMouse|Qt::TextSelectableByMouse</set>
</property>
</widget>
</item>
<item row="1" column="1">
<widget class="QLabel" name="version"> <widget class="QLabel" name="version">
<property name="text"> <property name="text">
<string/> <string/>
@ -123,26 +79,94 @@
</property> </property>
</widget> </widget>
</item> </item>
<item row="4" column="1"> <item row="0" column="0">
<widget class="QTextBrowser" name="description"/> <widget class="QLabel" name="label_3">
<property name="text">
<string>Name:</string>
</property>
<property name="alignment">
<set>Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter</set>
</property>
</widget>
</item> </item>
<item row="5" column="1"> <item row="4" column="1">
<widget class="QTextBrowser" name="include"/> <widget class="QLabel" name="startAt">
<property name="text">
<string/>
</property>
<property name="textInteractionFlags">
<set>Qt::LinksAccessibleByMouse|Qt::TextSelectableByMouse</set>
</property>
</widget>
</item>
<item row="3" column="1">
<widget class="SqueezeLabelV2" name="url">
<property name="text">
<string/>
</property>
<property name="textInteractionFlags">
<set>Qt::LinksAccessibleByMouse|Qt::TextSelectableByMouse</set>
</property>
</widget>
</item>
<item row="3" column="0">
<widget class="QLabel" name="labelUrl">
<property name="text">
<string>URL:</string>
</property>
<property name="alignment">
<set>Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter</set>
</property>
</widget>
</item> </item>
<item row="6" column="1"> <item row="6" column="1">
<widget class="QTextBrowser" name="exclude"/> <widget class="QTextBrowser" name="include"/>
</item>
<item row="7" column="0">
<widget class="QLabel" name="label_9">
<property name="text">
<string>Does not run at:</string>
</property>
<property name="alignment">
<set>Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter</set>
</property>
</widget>
</item>
<item row="1" column="0">
<widget class="QLabel" name="label">
<property name="text">
<string>Namespace:</string>
</property>
<property name="alignment">
<set>Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter</set>
</property>
</widget>
</item>
<item row="1" column="1">
<widget class="QLabel" name="nspace"/>
</item> </item>
</layout> </layout>
</item> </item>
<item> <item>
<widget class="QDialogButtonBox" name="buttonBox"> <layout class="QHBoxLayout" name="horizontalLayout">
<property name="orientation"> <item>
<enum>Qt::Horizontal</enum> <widget class="QPushButton" name="editInEditor">
</property> <property name="text">
<property name="standardButtons"> <string>Edit in text editor</string>
<set>QDialogButtonBox::Close</set> </property>
</property> </widget>
</widget> </item>
<item>
<widget class="QDialogButtonBox" name="buttonBox">
<property name="orientation">
<enum>Qt::Horizontal</enum>
</property>
<property name="standardButtons">
<set>QDialogButtonBox::Close</set>
</property>
</widget>
</item>
</layout>
</item> </item>
</layout> </layout>
</widget> </widget>

View File

@ -75,7 +75,7 @@ bool StatusBarIconsPlugin::testPlugin()
return (QupZilla::VERSION == QLatin1String("1.5.0")); return (QupZilla::VERSION == QLatin1String("1.5.0"));
} }
QTranslator *StatusBarIconsPlugin::getTranslator(const QString &locale) QTranslator* StatusBarIconsPlugin::getTranslator(const QString &locale)
{ {
QTranslator* translator = new QTranslator(this); QTranslator* translator = new QTranslator(this);
translator->load(locale, ":/sbi/locale/"); translator->load(locale, ":/sbi/locale/");