From 014fa1215903802a663a2705ce10ea143811765f Mon Sep 17 00:00:00 2001 From: nowrep Date: Wed, 11 Jul 2012 18:30:00 +0200 Subject: [PATCH] Added GreaseMonkey + PIM plugins --- src/lib/adblock/adblockdialog.cpp | 11 + src/lib/adblock/adblockdialog.h | 3 +- src/lib/adblock/adblocksubscription.cpp | 1 - src/lib/adblock/adblocktreewidget.cpp | 3 - src/lib/adblock/adblocktreewidget.h | 2 +- .../desktopnotificationsfactory.cpp | 2 +- .../AccessKeysNavigation/akn_plugin.cpp | 2 +- src/plugins/GreaseMonkey/GreaseMonkey.pro | 49 +++ src/plugins/GreaseMonkey/data/bootstrap.js | 111 +++++++ .../GreaseMonkey/data/bootstrap.min.js | 1 + src/plugins/GreaseMonkey/data/icon.png | Bin 0 -> 2230 bytes src/plugins/GreaseMonkey/data/script.png | Bin 0 -> 1064 bytes .../GreaseMonkey/gm_addscriptdialog.cpp | 94 ++++++ src/plugins/GreaseMonkey/gm_addscriptdialog.h | 51 +++ .../GreaseMonkey/gm_addscriptdialog.ui | 169 ++++++++++ src/plugins/GreaseMonkey/gm_downloader.cpp | 155 +++++++++ src/plugins/GreaseMonkey/gm_downloader.h | 57 ++++ src/plugins/GreaseMonkey/gm_manager.cpp | 241 ++++++++++++++ src/plugins/GreaseMonkey/gm_manager.h | 75 +++++ src/plugins/GreaseMonkey/gm_notification.cpp | 68 ++++ src/plugins/GreaseMonkey/gm_notification.h | 51 +++ src/plugins/GreaseMonkey/gm_notification.ui | 85 +++++ src/plugins/GreaseMonkey/gm_plugin.cpp | 103 ++++++ src/plugins/GreaseMonkey/gm_plugin.h | 52 +++ src/plugins/GreaseMonkey/gm_script.cpp | 236 +++++++++++++ src/plugins/GreaseMonkey/gm_script.h | 83 +++++ src/plugins/GreaseMonkey/gm_urlmatcher.cpp | 103 ++++++ src/plugins/GreaseMonkey/gm_urlmatcher.h | 44 +++ src/plugins/GreaseMonkey/greasemonkey.qrc | 12 + .../GreaseMonkey/settings/gm_settings.cpp | 154 +++++++++ .../GreaseMonkey/settings/gm_settings.h | 58 ++++ .../GreaseMonkey/settings/gm_settings.ui | 263 +++++++++++++++ .../settings/gm_settingslistdelegate.cpp | 136 ++++++++ .../settings/gm_settingslistdelegate.h | 40 +++ .../settings/gm_settingslistwidget.cpp | 66 ++++ .../settings/gm_settingslistwidget.h | 46 +++ .../settings/gm_settingsscriptinfo.cpp | 41 +++ .../settings/gm_settingsscriptinfo.h | 42 +++ .../settings/gm_settingsscriptinfo.ui | 191 +++++++++++ .../GreaseMonkey/translations/cs_CZ.ts | 177 ++++++++++ .../GreaseMonkey/translations/de_DE.ts | 177 ++++++++++ .../GreaseMonkey/translations/fr_FR.ts | 177 ++++++++++ .../GreaseMonkey/translations/sr_BA.ts | 177 ++++++++++ .../GreaseMonkey/translations/sr_RS.ts | 177 ++++++++++ .../MouseGestures/mousegesturesplugin.cpp | 2 +- src/plugins/PIM/PIM.pro | 33 ++ src/plugins/PIM/PIM_handler.cpp | 221 +++++++++++++ src/plugins/PIM/PIM_handler.h | 87 +++++ src/plugins/PIM/PIM_plugin.cpp | 97 ++++++ src/plugins/PIM/PIM_plugin.h | 54 +++ src/plugins/PIM/PIM_res.qrc | 10 + src/plugins/PIM/PIM_settings.cpp | 79 +++++ src/plugins/PIM/PIM_settings.h | 48 +++ src/plugins/PIM/PIM_settings.ui | 313 ++++++++++++++++++ src/plugins/PIM/data/PIM.png | Bin 0 -> 2239 bytes src/plugins/PIM/test.html | 19 ++ src/plugins/PIM/translations/cs_CZ.ts | 180 ++++++++++ src/plugins/PIM/translations/de_DE.ts | 180 ++++++++++ src/plugins/PIM/translations/fr_FR.ts | 180 ++++++++++ src/plugins/PIM/translations/sr_BA.ts | 180 ++++++++++ src/plugins/PIM/translations/sr_RS.ts | 180 ++++++++++ src/plugins/PIM/translations/zh_TW.ts | 180 ++++++++++ src/plugins/TestPlugin/testplugin.cpp | 2 +- 63 files changed, 5821 insertions(+), 10 deletions(-) create mode 100644 src/plugins/GreaseMonkey/GreaseMonkey.pro create mode 100644 src/plugins/GreaseMonkey/data/bootstrap.js create mode 100644 src/plugins/GreaseMonkey/data/bootstrap.min.js create mode 100644 src/plugins/GreaseMonkey/data/icon.png create mode 100644 src/plugins/GreaseMonkey/data/script.png create mode 100644 src/plugins/GreaseMonkey/gm_addscriptdialog.cpp create mode 100644 src/plugins/GreaseMonkey/gm_addscriptdialog.h create mode 100644 src/plugins/GreaseMonkey/gm_addscriptdialog.ui create mode 100644 src/plugins/GreaseMonkey/gm_downloader.cpp create mode 100644 src/plugins/GreaseMonkey/gm_downloader.h create mode 100644 src/plugins/GreaseMonkey/gm_manager.cpp create mode 100644 src/plugins/GreaseMonkey/gm_manager.h create mode 100644 src/plugins/GreaseMonkey/gm_notification.cpp create mode 100644 src/plugins/GreaseMonkey/gm_notification.h create mode 100644 src/plugins/GreaseMonkey/gm_notification.ui create mode 100644 src/plugins/GreaseMonkey/gm_plugin.cpp create mode 100644 src/plugins/GreaseMonkey/gm_plugin.h create mode 100644 src/plugins/GreaseMonkey/gm_script.cpp create mode 100644 src/plugins/GreaseMonkey/gm_script.h create mode 100644 src/plugins/GreaseMonkey/gm_urlmatcher.cpp create mode 100644 src/plugins/GreaseMonkey/gm_urlmatcher.h create mode 100644 src/plugins/GreaseMonkey/greasemonkey.qrc create mode 100644 src/plugins/GreaseMonkey/settings/gm_settings.cpp create mode 100644 src/plugins/GreaseMonkey/settings/gm_settings.h create mode 100644 src/plugins/GreaseMonkey/settings/gm_settings.ui create mode 100644 src/plugins/GreaseMonkey/settings/gm_settingslistdelegate.cpp create mode 100644 src/plugins/GreaseMonkey/settings/gm_settingslistdelegate.h create mode 100644 src/plugins/GreaseMonkey/settings/gm_settingslistwidget.cpp create mode 100644 src/plugins/GreaseMonkey/settings/gm_settingslistwidget.h create mode 100644 src/plugins/GreaseMonkey/settings/gm_settingsscriptinfo.cpp create mode 100644 src/plugins/GreaseMonkey/settings/gm_settingsscriptinfo.h create mode 100644 src/plugins/GreaseMonkey/settings/gm_settingsscriptinfo.ui create mode 100644 src/plugins/GreaseMonkey/translations/cs_CZ.ts create mode 100644 src/plugins/GreaseMonkey/translations/de_DE.ts create mode 100644 src/plugins/GreaseMonkey/translations/fr_FR.ts create mode 100644 src/plugins/GreaseMonkey/translations/sr_BA.ts create mode 100644 src/plugins/GreaseMonkey/translations/sr_RS.ts create mode 100644 src/plugins/PIM/PIM.pro create mode 100644 src/plugins/PIM/PIM_handler.cpp create mode 100644 src/plugins/PIM/PIM_handler.h create mode 100644 src/plugins/PIM/PIM_plugin.cpp create mode 100644 src/plugins/PIM/PIM_plugin.h create mode 100644 src/plugins/PIM/PIM_res.qrc create mode 100644 src/plugins/PIM/PIM_settings.cpp create mode 100644 src/plugins/PIM/PIM_settings.h create mode 100644 src/plugins/PIM/PIM_settings.ui create mode 100644 src/plugins/PIM/data/PIM.png create mode 100644 src/plugins/PIM/test.html create mode 100644 src/plugins/PIM/translations/cs_CZ.ts create mode 100644 src/plugins/PIM/translations/de_DE.ts create mode 100644 src/plugins/PIM/translations/fr_FR.ts create mode 100644 src/plugins/PIM/translations/sr_BA.ts create mode 100644 src/plugins/PIM/translations/sr_RS.ts create mode 100644 src/plugins/PIM/translations/zh_TW.ts diff --git a/src/lib/adblock/adblockdialog.cpp b/src/lib/adblock/adblockdialog.cpp index 1ddb34b63..cc27ee7bb 100644 --- a/src/lib/adblock/adblockdialog.cpp +++ b/src/lib/adblock/adblockdialog.cpp @@ -23,6 +23,7 @@ #include "mainapplication.h" #include +#include #include #include @@ -152,6 +153,14 @@ void AdBlockDialog::learnAboutRules() mApp->addNewTab(QUrl("http://adblockplus.org/en/filters")); } +void AdBlockDialog::loadSubscriptions() +{ + for (int i = 0; i < tabWidget->count(); ++i) { + AdBlockTreeWidget* treeWidget = qobject_cast(tabWidget->widget(i)); + treeWidget->refresh(); + } +} + void AdBlockDialog::load() { if (m_loaded || !adblockCheckBox->isChecked()) { @@ -164,4 +173,6 @@ void AdBlockDialog::load() } m_loaded = true; + + QTimer::singleShot(50, this, SLOT(loadSubscriptions())); } diff --git a/src/lib/adblock/adblockdialog.h b/src/lib/adblock/adblockdialog.h index 849a37c86..b46bb88b2 100644 --- a/src/lib/adblock/adblockdialog.h +++ b/src/lib/adblock/adblockdialog.h @@ -51,9 +51,10 @@ private slots: void aboutToShowMenu(); void learnAboutRules(); -private: + void loadSubscriptions(); void load(); +private: AdBlockManager* m_manager; AdBlockTreeWidget* m_currentTreeWidget; AdBlockSubscription* m_currentSubscription; diff --git a/src/lib/adblock/adblocksubscription.cpp b/src/lib/adblock/adblocksubscription.cpp index 6e3243ac6..ee2c30523 100644 --- a/src/lib/adblock/adblocksubscription.cpp +++ b/src/lib/adblock/adblocksubscription.cpp @@ -92,7 +92,6 @@ void AdBlockSubscription::loadSubscription(const QStringList &disabledRules) QFile file(m_filePath); if (!file.exists()) { - qWarning() << "AdBlockSubscription::" << __FUNCTION__ << "File does not exists" << m_filePath; QTimer::singleShot(0, this, SLOT(updateSubscription())); return; } diff --git a/src/lib/adblock/adblocktreewidget.cpp b/src/lib/adblock/adblocktreewidget.cpp index 9207a6b75..ca5241491 100644 --- a/src/lib/adblock/adblocktreewidget.cpp +++ b/src/lib/adblock/adblocktreewidget.cpp @@ -19,7 +19,6 @@ #include "adblocksubscription.h" #include -#include #include #include #include @@ -39,8 +38,6 @@ AdBlockTreeWidget::AdBlockTreeWidget(AdBlockSubscription* subscription, QWidget* connect(this, SIGNAL(customContextMenuRequested(QPoint)), this, SLOT(contextMenuRequested(QPoint))); connect(this, SIGNAL(itemChanged(QTreeWidgetItem*, int)), this, SLOT(itemChanged(QTreeWidgetItem*))); connect(m_subscription, SIGNAL(subscriptionUpdated()), this, SLOT(subscriptionUpdated())); - - QTimer::singleShot(100, this, SLOT(refresh())); } AdBlockSubscription* AdBlockTreeWidget::subscription() const diff --git a/src/lib/adblock/adblocktreewidget.h b/src/lib/adblock/adblocktreewidget.h index 372c8a0cf..7ae3363c8 100644 --- a/src/lib/adblock/adblocktreewidget.h +++ b/src/lib/adblock/adblocktreewidget.h @@ -35,6 +35,7 @@ public: AdBlockSubscription* subscription() const; void showRule(const AdBlockRule* rule); + void refresh(); public slots: void addRule(); @@ -45,7 +46,6 @@ private slots: void itemChanged(QTreeWidgetItem* item); void copyFilter(); - void refresh(); void subscriptionUpdated(); private: diff --git a/src/lib/desktopnotifications/desktopnotificationsfactory.cpp b/src/lib/desktopnotifications/desktopnotificationsfactory.cpp index aa8220bc9..58a9b21d8 100644 --- a/src/lib/desktopnotifications/desktopnotificationsfactory.cpp +++ b/src/lib/desktopnotifications/desktopnotificationsfactory.cpp @@ -107,7 +107,7 @@ void DesktopNotificationsFactory::nativeNotificationPreview() #if defined(Q_WS_X11) && !defined(DISABLE_DBUS) QFile tmp(QDir::tempPath() + "/qupzilla_notif.png"); tmp.open(QFile::WriteOnly); - QPixmap(":icons/preferences/stock_dialog-question.png").save(tmp.fileName()); + QPixmap(":icons/preferences/dialog-question.png").save(tmp.fileName()); QDBusInterface dbus("org.freedesktop.Notifications", "/org/freedesktop/Notifications", "org.freedesktop.Notifications", QDBusConnection::sessionBus()); QVariantList args; diff --git a/src/plugins/AccessKeysNavigation/akn_plugin.cpp b/src/plugins/AccessKeysNavigation/akn_plugin.cpp index 9960381c2..757ef51db 100644 --- a/src/plugins/AccessKeysNavigation/akn_plugin.cpp +++ b/src/plugins/AccessKeysNavigation/akn_plugin.cpp @@ -60,7 +60,7 @@ bool AKN_Plugin::testPlugin() { // Let's be sure, require latest version of QupZilla - return (QupZilla::VERSION == "1.2.0"); + return (QupZilla::VERSION == "1.3.0"); } QTranslator* AKN_Plugin::getTranslator(const QString &locale) diff --git a/src/plugins/GreaseMonkey/GreaseMonkey.pro b/src/plugins/GreaseMonkey/GreaseMonkey.pro new file mode 100644 index 000000000..4cb5a887b --- /dev/null +++ b/src/plugins/GreaseMonkey/GreaseMonkey.pro @@ -0,0 +1,49 @@ +TARGET = GreaseMonkey +os2: TARGET = GreaseMo + +SOURCES += gm_plugin.cpp \ + gm_manager.cpp \ + gm_script.cpp \ + gm_urlmatcher.cpp \ + gm_downloader.cpp \ + gm_addscriptdialog.cpp \ + gm_notification.cpp \ + settings/gm_settings.cpp \ + settings/gm_settingslistdelegate.cpp \ + settings/gm_settingsscriptinfo.cpp \ + settings/gm_settingslistwidget.cpp + +HEADERS += gm_plugin.h \ + gm_manager.h \ + gm_script.h \ + gm_urlmatcher.h \ + gm_downloader.h \ + gm_addscriptdialog.h \ + gm_notification.h \ + settings/gm_settings.h \ + settings/gm_settingslistdelegate.h \ + settings/gm_settingsscriptinfo.h \ + settings/gm_settingslistwidget.h + +FORMS += \ + gm_addscriptdialog.ui \ + gm_notification.ui \ + settings/gm_settings.ui \ + settings/gm_settingsscriptinfo.ui + +RESOURCES += greasemonkey.qrc + +TRANSLATIONS = \ + translations/cs_CZ.ts \ + translations/de_DE.ts \ + translations/fr_FR.ts \ + translations/sr_BA.ts \ + translations/sr_RS.ts \ + +srcdir = $$(QUPZILLA_SRCDIR) +equals(srcdir, "") { + include(../../plugins.pri) +} +else { + include($$srcdir/src/plugins.pri) +} diff --git a/src/plugins/GreaseMonkey/data/bootstrap.js b/src/plugins/GreaseMonkey/data/bootstrap.js new file mode 100644 index 000000000..1d6e85d8f --- /dev/null +++ b/src/plugins/GreaseMonkey/data/bootstrap.js @@ -0,0 +1,111 @@ +if(typeof GM_xmlhttpRequest === "undefined") { + GM_xmlhttpRequest = function(/* object */ details) { + details.method = details.method.toUpperCase() || "GET"; + + if(!details.url) { + throw("GM_xmlhttpRequest requires an URL."); + } + + // build XMLHttpRequest object + var oXhr = new XMLHttpRequest; + // run it + if(oXhr) { + if("onreadystatechange" in details) + oXhr.onreadystatechange = function() { details.onreadystatechange(oXhr) }; + if("onload" in details) + oXhr.onload = function() { details.onload(oXhr) }; + if("onerror" in details) + oXhr.onerror = function() { details.onerror(oXhr) }; + + oXhr.open(details.method, details.url, true); + + if("headers" in details) + for(var header in details.headers) + oXhr.setRequestHeader(header, details.headers[header]); + + if("data" in details) + oXhr.send(details.data); + else + oXhr.send(); + } else + throw ("This Browser is not supported, please upgrade.") + } +} + +if(typeof GM_addStyle === "undefined") { + function GM_addStyle(/* String */ styles) { + var head = document.getElementsByTagName("head")[0]; + if (head === undefined) { + document.onreadystatechange = function() { + if (document.readyState == "interactive") { + var oStyle = document.createElement("style"); + oStyle.setAttribute("type", "text\/css"); + oStyle.appendChild(document.createTextNode(styles)); + document.getElementsByTagName("head")[0].appendChild(oStyle); + } + } + } + else { + var oStyle = document.createElement("style"); + oStyle.setAttribute("type", "text\/css"); + oStyle.appendChild(document.createTextNode(styles)); + head.appendChild(oStyle); + } + } +} + +if(typeof GM_log === "undefined") { + function GM_log(log) { + if(console) + console.log(log); + } +} + +if(typeof GM_openInTab === "undefined") { + function GM_openInTab(url) { + window.open(url) + } +} + +// Define unsafe window +var unsafeWindow = window; +window.wrappedJSObject = unsafeWindow; + +// GM_registerMenuCommand not supported +if(typeof GM_registerMenuCommand === "undefined") { + function GM_registerMenuCommand(caption, commandFunc, accessKey) { } +} + +// GM Resource not supported +if(typeof GM_getResourceText === "undefined") { + function GM_getResourceText(resourceName) { + throw ("QupZilla: GM Resource is not supported!"); + } +} + +if(typeof GM_getResourceURL === "undefined") { + function GM_getResourceURL(resourceName) { + throw ("QupZilla: GM Resource is not supported!"); + } +} + +// GM Settings not supported +if(typeof GM_getValue === "undefined") { + function GM_getValue(name, defaultValue) { + return defaultValue; + } +} + +if(typeof GM_setValue === "undefined") { + function GM_setValue(name, value) { } +} + +if(typeof GM_deleteValue === "undefined") { + function GM_deleteValue(name) { } +} + +if(typeof GM_listValues === "undefined") { + function GM_listValues() { + return new Array(""); + } +} diff --git a/src/plugins/GreaseMonkey/data/bootstrap.min.js b/src/plugins/GreaseMonkey/data/bootstrap.min.js new file mode 100644 index 000000000..71bfbbcf0 --- /dev/null +++ b/src/plugins/GreaseMonkey/data/bootstrap.min.js @@ -0,0 +1 @@ +if(typeof GM_xmlhttpRequest==="undefined")GM_xmlhttpRequest=function(details){details.method=details.method.toUpperCase()||"GET";if(!details.url)throw"GM_xmlhttpRequest requires an URL.";var oXhr=new XMLHttpRequest;if(oXhr){if("onreadystatechange"in details)oXhr.onreadystatechange=function(){details.onreadystatechange(oXhr)};if("onload"in details)oXhr.onload=function(){details.onload(oXhr)};if("onerror"in details)oXhr.onerror=function(){details.onerror(oXhr)};oXhr.open(details.method,details.url,true);if("headers"in details)for(var header in details.headers)oXhr.setRequestHeader(header,details.headers[header]);if("data"in details)oXhr.send(details.data);else oXhr.send()}else throw"This Browser is not supported, please upgrade.";};if(typeof GM_addStyle==="undefined"){function GM_addStyle(styles){var head=document.getElementsByTagName("head")[0];if(head===undefined)document.onreadystatechange=function(){if(document.readyState=="interactive"){var oStyle=document.createElement("style");oStyle.setAttribute("type","text/css");oStyle.appendChild(document.createTextNode(styles));document.getElementsByTagName("head")[0].appendChild(oStyle)}};else{var oStyle=document.createElement("style");oStyle.setAttribute("type","text/css");oStyle.appendChild(document.createTextNode(styles));head.appendChild(oStyle)}}}if(typeof GM_log==="undefined"){function GM_log(log){if(console)console.log(log)}}if(typeof GM_openInTab==="undefined"){function GM_openInTab(url){window.open(url)}}var unsafeWindow=window;window.wrappedJSObject=unsafeWindow;if(typeof GM_registerMenuCommand==="undefined"){function GM_registerMenuCommand(caption,commandFunc,accessKey){}}if(typeof GM_getResourceText==="undefined"){function GM_getResourceText(resourceName){throw"QupZilla: GM Resource is not supported!";}}if(typeof GM_getResourceURL==="undefined"){function GM_getResourceURL(resourceName){throw"QupZilla: GM Resource is not supported!";}}if(typeof GM_getValue==="undefined"){function GM_getValue(name,defaultValue){return defaultValue}}if(typeof GM_setValue==="undefined"){function GM_setValue(name,value){}}if(typeof GM_deleteValue==="undefined"){function GM_deleteValue(name){}}if(typeof GM_listValues==="undefined"){function GM_listValues(){return new Array("")}}; diff --git a/src/plugins/GreaseMonkey/data/icon.png b/src/plugins/GreaseMonkey/data/icon.png new file mode 100644 index 0000000000000000000000000000000000000000..ffa8a5ef9ae60615a0b7727bec804c0c46ba7d78 GIT binary patch literal 2230 zcmV;n2ub&eP)g6>$MZx8)IUFaZHjzoW>ALO1puGo2W3C zqEMug7767CG>HBv1rIKRr#7S)8BzA1a zYwvn5=Q7hDXKfte1QpSd=A6--ne)EiJM+!=jo|-K9$ZJ2(sa2#o1GG=2X--dsR!z<21GnR8z!P4lVoKN0x#I;vENZUh@<`Wz32bD(qpt_dnW-4E4!yuHJ~x3!u3(e0*bF2@xv%KK;mM#q7u+(SI!gPaS25u!5;+H)5_iq_ z-_IoQ;5w?}A$ky`07UswbYUP90G8JqOG0%7DlE{D$~iFYfb!XVs?8|o>zpY+yPOqa zlO7>x7Uhwyg1iGqvw`d(6Jj=0+QC}`T0_h8X#+soJYi_xXs=7L~4tBzHCd01hpJn3sD4tJdJWsb_ zaF^C3lxCn<<2!rAMAF}r^&*PO!0Ia=z z6IFFd&>F23TKj0FaEb+bpMHw*kx>e6uq>39NNds$|BICd!1pia+Dp%7``4Q3?rfmB zGQvhf5?<2T$8UJA!J^hS5E3B`q+uYXi7@66 zFfF8MBTb7b*W;mo{FTRF-H9};V4O4&(gY;QbK39}cpCPrP4()Yk;f`zW02j9IcpcXVAx#X!#I|e<)5NN%!to)SE0WFS z7(bE2RrE^NCp|iHf^0U&=jRxDSE*XYMKV& zkc|`)$~*hOz5}ekdp+cVBDg+C(`I^fnumV%P|#l>AWfhiWsg{U z@yPt`058cuz0XUIM<%^zKLyt%??TjqWJ6uxPNM8kLeLngVPtRw@(?$ovu=6kHC>Pc zreXDx*4goMPdPgrVbx`8Nt#8(^fZnaL`MVQtOVidTrm}?ilU|_S$)xR+B!NA<;^6d zffSOC)>eA{z6U4k@xYz8()s0O2q9Q^K|6*I?JdpxaN~{CR#zajLTSa=kx?QQHd_1C z)YtOX%R8wGk@@XA+2Tld=ES23<0G{HN;5! z8Wto!IoF^2>7UVBqm@D{pXzv&WNn;C$iVj z5ng}spWJiheLVN@i>zM1W|k1Z$dO@u1>Q^~of`!`1%`yFi45`T1X?Lp-*6F6-@BFc zRrk}@v4q7-7bAoq8jn%P7G~#u@a6}M4UIB>bR2+|&U3lsj;mPF-c$zH96m5WAz#AR zP%6$tzz<0B?(V%bp52UAK5fez_{NXF$-dqD8G3twV=w=kk$p#I=Oo)20f;S()7a6< zsY|ZR-nsd~gV*q3F^* zgLzUya@$Ipq9$o6Nz^sea{ae&rm7|ZLY9L|*)4?x1Ww7taXpk$2tY~*g)F25t$dX7 zDCYBQ+xi0i?;pU|pftUY?_uo>=1DnW-!PNs)iEq3UDMe-@4l5L7LQTiP>b%fPZErYR6Yqm@Tye2hIichmE`7Z^D@im%HG!}`6)D9x+DtP<_qYMX4C zxnfmS$7wrnDT~i(CQ(yOed8iP2B$0n&eRP21$41eC#rTSh&T>{5A-WAoYHn6Mlb+AP20ls0=e~VK8rUK-Y>Qe*_Am1aOldi^}TPkwOvn=!zD0oy>fO;T{>BLDyZ07*qoM6N<$ Ef?azTC;$Ke literal 0 HcmV?d00001 diff --git a/src/plugins/GreaseMonkey/data/script.png b/src/plugins/GreaseMonkey/data/script.png new file mode 100644 index 0000000000000000000000000000000000000000..9d76ac5475924814b1328017a6967e4684c21058 GIT binary patch literal 1064 zcmeAS@N?(olHy`uVBq!ia0vp^3LwnE0wix1Z>k4UOiAAEE({E-dXT%`P4Eh}EETzcJUV~EYxDc@Aq zs&3omIy+_Z-MKd<)1S@V-Y%P3zIpOH?!yO8fBtX#|M|@4k_&IXtLVP+q4)N$ZvKA~ za*ADy^G;qWdCSpdTDS0{-_zgk{_d^~JZAQCI^Xra1t&LD^8WnzVS!V__L3Ff*k-ZJ zS7ZB>QhR-aMWn)hyV6&>CWdypM&AUlYM-4bTXFsS{CSR_d(3=|_zKvkx$7N_zEfQ_ zt*1lG*M$AY%&)Vro_AxZnE&3gT4(xpL7$K2sb0(X?3~DOZ)#`v@xYcX8Oa3`+>gxg z37)n7{9pY8)`9=NSO{EN(wov{rO3qGeqBqU9MY{v)8c6{tV+xeK7JC9oA8`-g3 zH13Q`z5Y1-=iG+OZ$>ATtt2F7%<#xj;r#wV|NHjM*AFgv!l@?4Ur>3%ZQkue#|}Cf z9n*QY$2^!NA~QHmUH_v|{l?Dj);ANS8;&Nf5Cz8IkKH1(4a=VQH}^L89&uslYMJ{X zu26XT{7Fn=da5yVY_@kYF0oNw(5z9N#<<{DX+g4b{;bxi-MeoFCpj^hUF2W2s$jyZ z^r-9ek`fb>k`j^>8d_TT?ChkOqc47U{>j+T-YuNo|L9pzW1V9Dv`K)Cwe@S6y$j_|Zfpu}>A6vh+ z%6neWP;z3j+QP9uRE#aToxw*ZXNPpr{3$a!_+*))PERe4Ui>s{QFF6n!0m(iZw@Lb zC?qkj<14m);E?dp$jxB?f0vdg{z6Jh*Dk1QYaeDP5>S}1X8MymENYUg_c%E*m#X~| zb1PWD$T&IG>&*ez1re%I9eD>l7#I&MoO*Wm1jY?suhU984;cp>a$j`%$ER!SH~;p~ z2;Tqo$0POT`(CfbneUjNa!Pn&&sh00;;HlVjMv{}-_NcOOi9TQk@9tOTD4i1L6JdP zdb-f#pK9qELP<$MK}JDFMnO&?*IVCwRb|msnx7y(A!Uh1l1LYiE8E@O&t3npZ+~F* zl&gyADlikNmbgZgBp0P7mZa*Y00{;o0|QH4LnB=y;}AnLD?>voLknF4Q!4|5vyw{k zFb%o+DVb@NI5Zd=Kr}o~k~IWskObKfoS#-wo>-L1;Fyx1l&avFo0y&&l$w}QS$Hzl Q2B?U^)78&qol`;+03q?e@&Et; literal 0 HcmV?d00001 diff --git a/src/plugins/GreaseMonkey/gm_addscriptdialog.cpp b/src/plugins/GreaseMonkey/gm_addscriptdialog.cpp new file mode 100644 index 000000000..e8609d9d1 --- /dev/null +++ b/src/plugins/GreaseMonkey/gm_addscriptdialog.cpp @@ -0,0 +1,94 @@ +/* ============================================================ +* GreaseMonkey plugin for QupZilla +* Copyright (C) 2012 David Rosca +* +* This program is free software: you can redistribute it and/or modify +* it under the terms of the GNU General Public License as published by +* the Free Software Foundation, either version 3 of the License, or +* (at your option) any later version. +* +* This program is distributed in the hope that it will be useful, +* but WITHOUT ANY WARRANTY; without even the implied warranty of +* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +* GNU General Public License for more details. +* +* You should have received a copy of the GNU General Public License +* along with this program. If not, see . +* ============================================================ */ +#include "gm_addscriptdialog.h" +#include "ui_gm_addscriptdialog.h" +#include "gm_script.h" +#include "gm_manager.h" +#include "gm_notification.h" + +#include "mainapplication.h" +#include "qupzilla.h" +#include "tabwidget.h" +#include "tabbedwebview.h" +#include "globalfunctions.h" + +#include +#include + +GM_AddScriptDialog::GM_AddScriptDialog(GM_Manager* manager, GM_Script* script, QWidget* parent) + : QDialog(parent) + , ui(new Ui::GM_AddScriptDialog) + , m_manager(manager) + , m_script(script) +{ + ui->setupUi(this); + + QString runsAt; + QString dontRunsAt; + + const QStringList &include = script->include(); + const QStringList &exclude = script->exclude(); + + if (!include.isEmpty()) { + runsAt = tr("

runs at
%1

").arg(include.join("
")); + } + + if (!exclude.isEmpty()) { + dontRunsAt = tr("

does not run at
%1

").arg(exclude.join("
")); + } + + QString scriptInfo = QString("%1 %2
%3 %4 %5").arg(script->name(), script->version(), script->description(), runsAt, dontRunsAt); + ui->textBrowser->setText(scriptInfo); + + connect(ui->showSource, SIGNAL(clicked()), this, SLOT(showSource())); + connect(this, SIGNAL(accepted()), this, SLOT(accepted())); +} + +void GM_AddScriptDialog::showSource() +{ + QupZilla* qz = mApp->getWindow(); + if (!qz) { + return; + } + + const QString &tmpFileName = qz_ensureUniqueFilename(QDir::tempPath() + "/tmp-userscript.js"); + + if (QFile::copy(m_script->fileName(), tmpFileName)) { + int index = qz->tabWidget()->addView(QUrl::fromLocalFile(tmpFileName), Qz::NT_SelectedTabAtTheEnd); + TabbedWebView* view = qz->weView(index); + view->addNotification(new GM_Notification(m_manager, tmpFileName, m_script->fileName())); + } + + reject(); +} + +void GM_AddScriptDialog::accepted() +{ + QString message = tr("Cannot install script"); + + if (m_manager->addScript(m_script)) { + message = tr("'%1' installed successfully").arg(m_script->name()); + } + + m_manager->showNotification(message); +} + +GM_AddScriptDialog::~GM_AddScriptDialog() +{ + delete ui; +} diff --git a/src/plugins/GreaseMonkey/gm_addscriptdialog.h b/src/plugins/GreaseMonkey/gm_addscriptdialog.h new file mode 100644 index 000000000..311b593bc --- /dev/null +++ b/src/plugins/GreaseMonkey/gm_addscriptdialog.h @@ -0,0 +1,51 @@ +/* ============================================================ +* GreaseMonkey plugin for QupZilla +* Copyright (C) 2012 David Rosca +* +* This program is free software: you can redistribute it and/or modify +* it under the terms of the GNU General Public License as published by +* the Free Software Foundation, either version 3 of the License, or +* (at your option) any later version. +* +* This program is distributed in the hope that it will be useful, +* but WITHOUT ANY WARRANTY; without even the implied warranty of +* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +* GNU General Public License for more details. +* +* You should have received a copy of the GNU General Public License +* along with this program. If not, see . +* ============================================================ */ +#ifndef GM_ADDSCRIPTDIALOG_H +#define GM_ADDSCRIPTDIALOG_H + +#include + +namespace Ui +{ +class GM_AddScriptDialog; +} + +class GM_Script; +class GM_Manager; + +class GM_AddScriptDialog : public QDialog +{ + Q_OBJECT + +public: + explicit GM_AddScriptDialog(GM_Manager* manager, GM_Script* script, QWidget* parent); + ~GM_AddScriptDialog(); + +private slots: + void showSource(); + + void accepted(); + +private: + Ui::GM_AddScriptDialog* ui; + + GM_Manager* m_manager; + GM_Script* m_script; +}; + +#endif // GM_ADDSCRIPTDIALOG_H diff --git a/src/plugins/GreaseMonkey/gm_addscriptdialog.ui b/src/plugins/GreaseMonkey/gm_addscriptdialog.ui new file mode 100644 index 000000000..69933c1d1 --- /dev/null +++ b/src/plugins/GreaseMonkey/gm_addscriptdialog.ui @@ -0,0 +1,169 @@ + + + GM_AddScriptDialog + + + + 0 + 0 + 422 + 379 + + + + GreaseMonkey Installation + + + + + + + + Qt::Horizontal + + + + 40 + 20 + + + + + + + + + 0 + 0 + + + + + + + :/gm/data/icon.png + + + + + + + <h3>GreaseMonkey Installation</h3> + + + + + + + Qt::Horizontal + + + + 40 + 20 + + + + + + + + + + You are about to install this userscript into GreaseMonkey: + + + Qt::AlignCenter + + + + + + + + + + <b>You should only install scripts from sources you trust!</b> + + + Qt::AlignCenter + + + + + + + Are you sure you want to install it? + + + Qt::AlignCenter + + + + + + + + + + 0 + 0 + + + + Show source code of script + + + + + + + Qt::Horizontal + + + QDialogButtonBox::No|QDialogButtonBox::Yes + + + + + + + + + + + + + buttonBox + accepted() + GM_AddScriptDialog + accept() + + + 248 + 254 + + + 157 + 274 + + + + + buttonBox + rejected() + GM_AddScriptDialog + reject() + + + 316 + 260 + + + 286 + 274 + + + + + diff --git a/src/plugins/GreaseMonkey/gm_downloader.cpp b/src/plugins/GreaseMonkey/gm_downloader.cpp new file mode 100644 index 000000000..4f62a5ea7 --- /dev/null +++ b/src/plugins/GreaseMonkey/gm_downloader.cpp @@ -0,0 +1,155 @@ +/* ============================================================ +* GreaseMonkey plugin for QupZilla +* Copyright (C) 2012 David Rosca +* +* This program is free software: you can redistribute it and/or modify +* it under the terms of the GNU General Public License as published by +* the Free Software Foundation, either version 3 of the License, or +* (at your option) any later version. +* +* This program is distributed in the hope that it will be useful, +* but WITHOUT ANY WARRANTY; without even the implied warranty of +* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +* GNU General Public License for more details. +* +* You should have received a copy of the GNU General Public License +* along with this program. If not, see . +* ============================================================ */ +#include "gm_downloader.h" +#include "gm_addscriptdialog.h" +#include "gm_manager.h" +#include "gm_script.h" + +#include "webpage.h" +#include "followredirectreply.h" +#include "mainapplication.h" +#include "networkmanager.h" +#include "globalfunctions.h" + +#include +#include +#include +#include + +GM_Downloader::GM_Downloader(const QNetworkRequest &request, GM_Manager* manager) + : QObject() + , m_manager(manager) +{ + m_reply = new FollowRedirectReply(request.url(), mApp->networkManager()); + connect(m_reply, SIGNAL(finished()), this, SLOT(scriptDownloaded())); + + QVariant v = request.attribute((QNetworkRequest::Attribute)(QNetworkRequest::User + 100)); + WebPage* webPage = static_cast(v.value()); + if (WebPage::isPointerSafeToUse(webPage)) { + m_widget = webPage->view(); + } +} + +void GM_Downloader::scriptDownloaded() +{ + if (m_reply != qobject_cast(sender())) { + deleteLater(); + return; + } + + QByteArray response = m_reply->readAll(); + + if (m_reply->error() == QNetworkReply::NoError && response.contains("// ==UserScript==")) { + const QString &filePath = m_manager->scriptsDirectory() + qz_getFileNameFromUrl(m_reply->url()); + m_fileName = qz_ensureUniqueFilename(filePath); + + QFile file(m_fileName); + + if (!file.open(QFile::WriteOnly)) { + qWarning() << "GreaseMonkey: Cannot open file for writing" << m_fileName; + deleteLater(); + return; + } + + file.write(response); + file.close(); + + QSettings settings(m_manager->settinsPath() + "greasemonkey/requires/requires.ini", QSettings::IniFormat); + settings.beginGroup("Files"); + + QRegExp rx("@require(.*)\\n"); + rx.setMinimal(true); + rx.indexIn(response); + + for (int i = 1; i <= rx.captureCount(); ++i) { + const QString &url = rx.cap(i).trimmed(); + if (!url.isEmpty() && !settings.contains(url)) { + m_requireUrls.append(QUrl(url)); + } + } + } + + m_reply->deleteLater(); + m_reply = 0; + + downloadRequires(); +} + +void GM_Downloader::requireDownloaded() +{ + if (m_reply != qobject_cast(sender())) { + deleteLater(); + return; + } + + QByteArray response = m_reply->readAll(); + + if (m_reply->error() == QNetworkReply::NoError && !response.isEmpty()) { + const QString &filePath = m_manager->settinsPath() + "/greasemonkey/requires/require.js"; + const QString &fileName = qz_ensureUniqueFilename(filePath, "%1"); + + QFile file(fileName); + + if (!file.open(QFile::WriteOnly)) { + qWarning() << "GreaseMonkey: Cannot open file for writing" << fileName; + deleteLater(); + return; + } + + file.write(response); + file.close(); + + QSettings settings(m_manager->settinsPath() + "greasemonkey/requires/requires.ini", QSettings::IniFormat); + settings.beginGroup("Files"); + settings.setValue(m_reply->originalUrl().toString(), fileName); + } + + m_reply->deleteLater(); + m_reply = 0; + + downloadRequires(); +} + +void GM_Downloader::downloadRequires() +{ + if (!m_requireUrls.isEmpty()) { + m_reply = new FollowRedirectReply(m_requireUrls.takeFirst(), mApp->networkManager()); + connect(m_reply, SIGNAL(finished()), this, SLOT(requireDownloaded())); + } + else { + bool deleteScript = true; + GM_Script* script = new GM_Script(m_manager, m_fileName); + + if (script->isValid()) { + if (!m_manager->containsScript(script->fullName())) { + GM_AddScriptDialog dialog(m_manager, script, m_widget); + deleteScript = dialog.exec() != QDialog::Accepted; + } + else { + m_manager->showNotification(tr("'%1' is already installed").arg(script->name())); + } + } + + if (deleteScript) { + delete script; + QFile(m_fileName).remove(); + } + + deleteLater(); + } +} diff --git a/src/plugins/GreaseMonkey/gm_downloader.h b/src/plugins/GreaseMonkey/gm_downloader.h new file mode 100644 index 000000000..957acfa42 --- /dev/null +++ b/src/plugins/GreaseMonkey/gm_downloader.h @@ -0,0 +1,57 @@ +/* ============================================================ +* GreaseMonkey plugin for QupZilla +* Copyright (C) 2012 David Rosca +* +* This program is free software: you can redistribute it and/or modify +* it under the terms of the GNU General Public License as published by +* the Free Software Foundation, either version 3 of the License, or +* (at your option) any later version. +* +* This program is distributed in the hope that it will be useful, +* but WITHOUT ANY WARRANTY; without even the implied warranty of +* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +* GNU General Public License for more details. +* +* You should have received a copy of the GNU General Public License +* along with this program. If not, see . +* ============================================================ */ +#ifndef GM_DOWNLOADER_H +#define GM_DOWNLOADER_H + +#include +#include +#include + +class QNetworkRequest; + +class GM_Manager; + +class FollowRedirectReply; + +class GM_Downloader : public QObject +{ + Q_OBJECT +public: + explicit GM_Downloader(const QNetworkRequest &request, GM_Manager* manager); + +signals: + +public slots: + +private slots: + void scriptDownloaded(); + void requireDownloaded(); + +private: + void downloadRequires(); + + GM_Manager* m_manager; + FollowRedirectReply* m_reply; + QWidget* m_widget; + + QString m_fileName; + QList m_requireUrls; + +}; + +#endif // GM_DOWNLOADER_H diff --git a/src/plugins/GreaseMonkey/gm_manager.cpp b/src/plugins/GreaseMonkey/gm_manager.cpp new file mode 100644 index 000000000..0b6ff0f29 --- /dev/null +++ b/src/plugins/GreaseMonkey/gm_manager.cpp @@ -0,0 +1,241 @@ +/* ============================================================ +* GreaseMonkey plugin for QupZilla +* Copyright (C) 2012 David Rosca +* +* This program is free software: you can redistribute it and/or modify +* it under the terms of the GNU General Public License as published by +* the Free Software Foundation, either version 3 of the License, or +* (at your option) any later version. +* +* This program is distributed in the hope that it will be useful, +* but WITHOUT ANY WARRANTY; without even the implied warranty of +* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +* GNU General Public License for more details. +* +* You should have received a copy of the GNU General Public License +* along with this program. If not, see . +* ============================================================ */ +#include "gm_manager.h" +#include "gm_script.h" +#include "gm_downloader.h" +#include "settings/gm_settings.h" + +#include "webpage.h" +#include "globalfunctions.h" +#include "mainapplication.h" +#include "desktopnotificationsfactory.h" + +#include +#include +#include +#include +#include + +GM_Manager::GM_Manager(const QString &sPath, QObject* parent) + : QObject(parent) + , m_settingsPath(sPath) +{ + QTimer::singleShot(0, this, SLOT(load())); +} + +void GM_Manager::showSettings(QWidget* parent) +{ + GM_Settings settings(this, parent); + settings.exec(); +} + +void GM_Manager::downloadScript(const QNetworkRequest &request) +{ + new GM_Downloader(request, this); +} + +QString GM_Manager::settinsPath() const +{ + return m_settingsPath; +} + +QString GM_Manager::scriptsDirectory() const +{ + return m_settingsPath + "/greasemonkey/"; +} + +QString GM_Manager::requireScripts(const QStringList &urlList) const +{ + QDir requiresDir(m_settingsPath + "greasemonkey/requires"); + if (!requiresDir.exists() || urlList.isEmpty()) { + return QString(); + } + + QSettings settings(m_settingsPath + "greasemonkey/requires/requires.ini", QSettings::IniFormat); + settings.beginGroup("Files"); + + QString script; + + foreach(const QString & url, urlList) { + if (settings.contains(url)) { + const QString &fileName = settings.value(url).toString(); + script.append(qz_readAllFileContents(fileName).trimmed() + '\n'); + } + } + + return script; +} + +void GM_Manager::saveSettings() +{ + QSettings settings(m_settingsPath + "extensions.ini", QSettings::IniFormat); + settings.beginGroup("GreaseMonkey"); + settings.setValue("disabledScripts", m_disabledScripts); +} + +QList GM_Manager::allScripts() const +{ + QList list; + list.append(m_startScripts); + list.append(m_endScripts); + + return list; +} + +bool GM_Manager::containsScript(const QString &fullName) const +{ + foreach(GM_Script * script, m_startScripts) { + if (fullName == script->fullName()) { + return true; + } + } + + foreach(GM_Script * script, m_endScripts) { + if (fullName == script->fullName()) { + return true; + } + } + + return false; + +} + +void GM_Manager::enableScript(GM_Script* script) +{ + script->setEnabled(true); + m_disabledScripts.removeOne(script->fullName()); +} + +void GM_Manager::disableScript(GM_Script* script) +{ + script->setEnabled(false); + m_disabledScripts.append(script->fullName()); +} + +bool GM_Manager::addScript(GM_Script* script) +{ + if (!script) { + return false; + } + + if (script->startAt() == GM_Script::DocumentStart) { + m_startScripts.append(script); + } + else { + m_endScripts.append(script); + } + + emit scriptsChanged(); + return true; +} + +bool GM_Manager::removeScript(GM_Script* script) +{ + if (!script) { + return false; + } + + if (script->startAt() == GM_Script::DocumentStart) { + m_startScripts.removeOne(script); + } + else { + m_endScripts.removeOne(script); + } + + m_disabledScripts.removeOne(script->fullName()); + QFile::remove(script->fileName()); + delete script; + + emit scriptsChanged(); + return true; +} + +void GM_Manager::showNotification(const QString &message, const QString &title) +{ + QPixmap icon(":gm/data/icon.png"); + + mApp->desktopNotifications()->showNotification(icon, title.isEmpty() ? tr("GreaseMonkey") : title, message); +} + +void GM_Manager::pageLoadStart() +{ + QWebFrame* frame = qobject_cast(sender()); + if (!frame) { + return; + } + + const QString &urlScheme = frame->url().scheme(); + const QString &urlString = frame->url().toEncoded(); + + if (!canRunOnScheme(urlScheme)) { + return; + } + + foreach(GM_Script * script, m_startScripts) { + if (script->match(urlString)) { + frame->evaluateJavaScript(m_bootstrap + script->script()); + } + } + + foreach(GM_Script * script, m_endScripts) { + if (script->match(urlString)) { + const QString &jscript = QString("window.addEventListener(\"DOMContentLoaded\"," + "function(e) { %1 }, false);").arg(m_bootstrap + script->script()); + frame->evaluateJavaScript(jscript); + } + } +} + +void GM_Manager::load() +{ + QDir gmDir(m_settingsPath + "greasemonkey"); + if (!gmDir.exists()) { + gmDir.mkdir(m_settingsPath + "greasemonkey"); + } + + if (!gmDir.exists("requires")) { + gmDir.mkdir("requires"); + } + + QSettings settings(m_settingsPath + "extensions.ini", QSettings::IniFormat); + settings.beginGroup("GreaseMonkey"); + m_disabledScripts = settings.value("disabledScripts", QStringList()).toStringList(); + + foreach(const QString & fileName, gmDir.entryList(QStringList("*.js"), QDir::Files)) { + const QString &absolutePath = gmDir.absoluteFilePath(fileName); + GM_Script* script = new GM_Script(this, absolutePath); + + if (m_disabledScripts.contains(script->fullName())) { + script->setEnabled(false); + } + + if (script->startAt() == GM_Script::DocumentStart) { + m_startScripts.append(script); + } + else { + m_endScripts.append(script); + } + } + + m_bootstrap = qz_readAllFileContents(":gm/data/bootstrap.min.js"); +} + +bool GM_Manager::canRunOnScheme(const QString &scheme) +{ + return (scheme == "http" || scheme == "https" || scheme == "data" || scheme == "ftp"); +} diff --git a/src/plugins/GreaseMonkey/gm_manager.h b/src/plugins/GreaseMonkey/gm_manager.h new file mode 100644 index 000000000..f389a33d8 --- /dev/null +++ b/src/plugins/GreaseMonkey/gm_manager.h @@ -0,0 +1,75 @@ +/* ============================================================ +* GreaseMonkey plugin for QupZilla +* Copyright (C) 2012 David Rosca +* +* This program is free software: you can redistribute it and/or modify +* it under the terms of the GNU General Public License as published by +* the Free Software Foundation, either version 3 of the License, or +* (at your option) any later version. +* +* This program is distributed in the hope that it will be useful, +* but WITHOUT ANY WARRANTY; without even the implied warranty of +* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +* GNU General Public License for more details. +* +* You should have received a copy of the GNU General Public License +* along with this program. If not, see . +* ============================================================ */ +#ifndef GM_MANAGER_H +#define GM_MANAGER_H + +#include +#include + +class QUrl; +class QNetworkRequest; + +class GM_Script; + +class GM_Manager : public QObject +{ + Q_OBJECT +public: + explicit GM_Manager(const QString &sPath, QObject* parent = 0); + + void showSettings(QWidget* parent); + void downloadScript(const QNetworkRequest &request); + + QString settinsPath() const; + QString scriptsDirectory() const; + QString requireScripts(const QStringList &urlList) const; + + void saveSettings(); + + QList allScripts() const; + bool containsScript(const QString &fullName) const; + + void enableScript(GM_Script* script); + void disableScript(GM_Script* script); + + bool addScript(GM_Script* script); + bool removeScript(GM_Script* script); + + void showNotification(const QString &message, const QString &title = QString()); + + static bool canRunOnScheme(const QString &scheme); + +signals: + void scriptsChanged(); + +public slots: + void pageLoadStart(); + +private slots: + void load(); + +private: + QString m_settingsPath; + QString m_bootstrap; + + QStringList m_disabledScripts; + QList m_endScripts; + QList m_startScripts; +}; + +#endif // GM_MANAGER_H diff --git a/src/plugins/GreaseMonkey/gm_notification.cpp b/src/plugins/GreaseMonkey/gm_notification.cpp new file mode 100644 index 000000000..7efe00fa6 --- /dev/null +++ b/src/plugins/GreaseMonkey/gm_notification.cpp @@ -0,0 +1,68 @@ +/* ============================================================ +* GreaseMonkey plugin for QupZilla +* Copyright (C) 2012 David Rosca +* +* This program is free software: you can redistribute it and/or modify +* it under the terms of the GNU General Public License as published by +* the Free Software Foundation, either version 3 of the License, or +* (at your option) any later version. +* +* This program is distributed in the hope that it will be useful, +* but WITHOUT ANY WARRANTY; without even the implied warranty of +* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +* GNU General Public License for more details. +* +* You should have received a copy of the GNU General Public License +* along with this program. If not, see . +* ============================================================ */ +#include "gm_notification.h" +#include "ui_gm_notification.h" +#include "gm_manager.h" +#include "gm_script.h" + +#include "iconprovider.h" + +#include + +GM_Notification::GM_Notification(GM_Manager* manager, const QString &tmpfileName, const QString &fileName) + : AnimatedWidget(AnimatedWidget::Down, 300, 0) + , ui(new Ui::GM_Notification) + , m_manager(manager) + , m_tmpFileName(tmpfileName) + , m_fileName(fileName) +{ + ui->setupUi(widget()); + + ui->close->setIcon(qIconProvider->standardIcon(QStyle::SP_DialogCloseButton)); + + connect(ui->install, SIGNAL(clicked()), this, SLOT(installScript())); + connect(ui->close, SIGNAL(clicked()), this, SLOT(hide())); + + startAnimation(); +} + +void GM_Notification::installScript() +{ + bool success = false; + + GM_Script* script = 0; + QString message = tr("Cannot install script"); + + if (QFile::copy(m_tmpFileName, m_fileName)) { + script = new GM_Script(m_manager, m_fileName); + success = m_manager->addScript(script); + } + + if (success) { + message = tr("'%1' installed successfully").arg(script->name()); + } + + m_manager->showNotification(message); + + hide(); +} + +GM_Notification::~GM_Notification() +{ + delete ui; +} diff --git a/src/plugins/GreaseMonkey/gm_notification.h b/src/plugins/GreaseMonkey/gm_notification.h new file mode 100644 index 000000000..dfe32d695 --- /dev/null +++ b/src/plugins/GreaseMonkey/gm_notification.h @@ -0,0 +1,51 @@ +/* ============================================================ +* GreaseMonkey plugin for QupZilla +* Copyright (C) 2012 David Rosca +* +* This program is free software: you can redistribute it and/or modify +* it under the terms of the GNU General Public License as published by +* the Free Software Foundation, either version 3 of the License, or +* (at your option) any later version. +* +* This program is distributed in the hope that it will be useful, +* but WITHOUT ANY WARRANTY; without even the implied warranty of +* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +* GNU General Public License for more details. +* +* You should have received a copy of the GNU General Public License +* along with this program. If not, see . +* ============================================================ */ +#ifndef GM_NOTIFICATION_H +#define GM_NOTIFICATION_H + +#include "animatedwidget.h" + +namespace Ui +{ +class GM_Notification; +} + +class GM_Manager; +class GM_Script; + +class GM_Notification : public AnimatedWidget +{ + Q_OBJECT + +public: + explicit GM_Notification(GM_Manager* manager, const QString &tmpfileName, const QString &fileName); + ~GM_Notification(); + +private slots: + void installScript(); + +private: + Ui::GM_Notification* ui; + + GM_Manager* m_manager; + + QString m_tmpFileName; + QString m_fileName; +}; + +#endif // GM_NOTIFICATION_H diff --git a/src/plugins/GreaseMonkey/gm_notification.ui b/src/plugins/GreaseMonkey/gm_notification.ui new file mode 100644 index 000000000..56fdc6960 --- /dev/null +++ b/src/plugins/GreaseMonkey/gm_notification.ui @@ -0,0 +1,85 @@ + + + GM_Notification + + + + 0 + 0 + 820 + 36 + + + + + 0 + + + 0 + + + + + + 24 + 24 + + + + + 24 + 24 + + + + :/gm/data/icon.png + + + true + + + + + + + This script can be installed with the GreaseMonkey plugin. + + + + + + + Qt::Horizontal + + + + 40 + 20 + + + + + + + + Install + + + + + + + + + + true + + + + + + + + + + diff --git a/src/plugins/GreaseMonkey/gm_plugin.cpp b/src/plugins/GreaseMonkey/gm_plugin.cpp new file mode 100644 index 000000000..9dd0daf43 --- /dev/null +++ b/src/plugins/GreaseMonkey/gm_plugin.cpp @@ -0,0 +1,103 @@ +/* ============================================================ +* GreaseMonkey plugin for QupZilla +* Copyright (C) 2012 David Rosca +* +* This program is free software: you can redistribute it and/or modify +* it under the terms of the GNU General Public License as published by +* the Free Software Foundation, either version 3 of the License, or +* (at your option) any later version. +* +* This program is distributed in the hope that it will be useful, +* but WITHOUT ANY WARRANTY; without even the implied warranty of +* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +* GNU General Public License for more details. +* +* You should have received a copy of the GNU General Public License +* along with this program. If not, see . +* ============================================================ */ +#include "gm_plugin.h" +#include "gm_manager.h" +#include "qupzilla.h" +#include "webpage.h" +#include "pluginproxy.h" +#include "mainapplication.h" +#include "emptynetworkreply.h" + +#include +#include + +GM_Plugin::GM_Plugin() + : QObject() + , m_manager(0) +{ +} + +PluginSpec GM_Plugin::pluginSpec() +{ + PluginSpec spec; + spec.name = "GreaseMonkey"; + spec.info = "Userscripts for QupZilla"; + spec.description = "Provides support for userscripts (www.userscripts.org)"; + spec.version = "0.1.1"; + spec.author = "David Rosca "; + spec.icon = QPixmap(":gm/data/icon.png"); + spec.hasSettings = true; + + return spec; +} + +void GM_Plugin::init(const QString &sPath) +{ + m_manager = new GM_Manager(sPath, this); + m_settingsPath = sPath; + + connect(mApp->plugins(), SIGNAL(webPageCreated(WebPage*)), this, SLOT(webPageCreated(WebPage*))); +} + +void GM_Plugin::unload() +{ + m_manager->saveSettings(); + delete m_manager; +} + +bool GM_Plugin::testPlugin() +{ + return (QupZilla::VERSION == "1.3.0"); +} + +QTranslator* GM_Plugin::getTranslator(const QString &locale) +{ + QTranslator* translator = new QTranslator(this); + translator->load(locale, ":/gm/locale/"); + return translator; +} + +void GM_Plugin::showSettings(QWidget* parent) +{ + m_manager->showSettings(parent); +} + +QNetworkReply* GM_Plugin::createRequest(QNetworkAccessManager::Operation op, const QNetworkRequest &request, QIODevice* outgoingData) +{ + Q_UNUSED(outgoingData) + + int type = request.attribute((QNetworkRequest::Attribute)(QNetworkRequest::User + 101), -1).toInt(); + + if (op == QNetworkAccessManager::GetOperation && QWebPage::NavigationType(type) == QWebPage::NavigationTypeLinkClicked) { + const QString &urlString = request.url().toString(QUrl::RemoveFragment | QUrl::RemoveQuery); + + if (urlString.endsWith(".user.js")) { + m_manager->downloadScript(request); + return new EmptyNetworkReply; + } + } + + return 0; +} + +void GM_Plugin::webPageCreated(WebPage* page) +{ + connect(page->mainFrame(), SIGNAL(javaScriptWindowObjectCleared()), m_manager, SLOT(pageLoadStart())); +} + +Q_EXPORT_PLUGIN2(GreaseMonkey, GM_Plugin) diff --git a/src/plugins/GreaseMonkey/gm_plugin.h b/src/plugins/GreaseMonkey/gm_plugin.h new file mode 100644 index 000000000..ce8ddda6d --- /dev/null +++ b/src/plugins/GreaseMonkey/gm_plugin.h @@ -0,0 +1,52 @@ +/* ============================================================ +* GreaseMonkey plugin for QupZilla +* Copyright (C) 2012 David Rosca +* +* This program is free software: you can redistribute it and/or modify +* it under the terms of the GNU General Public License as published by +* the Free Software Foundation, either version 3 of the License, or +* (at your option) any later version. +* +* This program is distributed in the hope that it will be useful, +* but WITHOUT ANY WARRANTY; without even the implied warranty of +* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +* GNU General Public License for more details. +* +* You should have received a copy of the GNU General Public License +* along with this program. If not, see . +* ============================================================ */ +#ifndef GM_PLUGIN_H +#define GM_PLUGIN_H + +#include "plugininterface.h" + +class WebPage; +class GM_Manager; + +class GM_Plugin : public QObject, public PluginInterface +{ + Q_OBJECT + Q_INTERFACES(PluginInterface) + +public: + explicit GM_Plugin(); + PluginSpec pluginSpec(); + + void init(const QString &sPath); + void unload(); + bool testPlugin(); + + QTranslator* getTranslator(const QString &locale); + void showSettings(QWidget* parent = 0); + + QNetworkReply* createRequest(QNetworkAccessManager::Operation op, const QNetworkRequest &request, QIODevice* outgoingData); + +private slots: + void webPageCreated(WebPage* page); + +private: + GM_Manager* m_manager; + QString m_settingsPath; +}; + +#endif // GM_PLUGIN_H diff --git a/src/plugins/GreaseMonkey/gm_script.cpp b/src/plugins/GreaseMonkey/gm_script.cpp new file mode 100644 index 000000000..18507c6f4 --- /dev/null +++ b/src/plugins/GreaseMonkey/gm_script.cpp @@ -0,0 +1,236 @@ +/* ============================================================ +* GreaseMonkey plugin for QupZilla +* Copyright (C) 2012 David Rosca +* +* This program is free software: you can redistribute it and/or modify +* it under the terms of the GNU General Public License as published by +* the Free Software Foundation, either version 3 of the License, or +* (at your option) any later version. +* +* This program is distributed in the hope that it will be useful, +* but WITHOUT ANY WARRANTY; without even the implied warranty of +* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +* GNU General Public License for more details. +* +* You should have received a copy of the GNU General Public License +* along with this program. If not, see . +* ============================================================ */ +#include "gm_script.h" +#include "gm_manager.h" + +#include +#include +#include +#include +#include +#include + +GM_Script::GM_Script(GM_Manager* manager, const QString &filePath) + : m_manager(manager) + , m_namespace("GreaseMonkeyNS") + , m_startAt(DocumentEnd) + , m_fileName(filePath) + , m_enabled(true) + , m_valid(false) +{ + parseScript(filePath); +} + +bool GM_Script::isValid() const +{ + return m_valid; +} + +QString GM_Script::name() const +{ + return m_name; +} + +QString GM_Script::nameSpace() const +{ + return m_namespace; +} + +QString GM_Script::fullName() const +{ + return QString("%1/%2").arg(m_namespace, m_name); +} + +QString GM_Script::description() const +{ + return m_description; +} + +QString GM_Script::version() const +{ + return m_version; +} + +QUrl GM_Script::downloadUrl() const +{ + return m_downloadUrl; +} + +GM_Script::StartAt GM_Script::startAt() const +{ + return m_startAt; +} + +bool GM_Script::isEnabled() const +{ + return m_enabled; +} + +void GM_Script::setEnabled(bool enable) +{ + m_enabled = enable; +} + +QStringList GM_Script::include() const +{ + QStringList list; + + foreach(const GM_UrlMatcher & matcher, m_include) { + list.append(matcher.pattern()); + } + + return list; +} + +QStringList GM_Script::exclude() const +{ + QStringList list; + + foreach(const GM_UrlMatcher & matcher, m_exclude) { + list.append(matcher.pattern()); + } + + return list; +} + +QString GM_Script::script() const +{ + return m_script; +} + +QString GM_Script::fileName() const +{ + return m_fileName; +} + +bool GM_Script::match(const QString &urlString) +{ + if (!m_enabled) { + return false; + } + + foreach(const GM_UrlMatcher & matcher, m_exclude) { + if (matcher.match(urlString)) { + return false; + } + } + + foreach(const GM_UrlMatcher & matcher, m_include) { + if (matcher.match(urlString)) { + return true; + } + } + + return false; +} + +void GM_Script::parseScript(const QString &filePath) +{ + QFile file(filePath); + if (!file.open(QFile::ReadOnly)) { + qWarning() << "GreaseMonkey: Cannot open file for reading" << filePath; + return; + } + + QString fileData = QString::fromUtf8(file.readAll()); + + QRegExp rx("// ==UserScript==(.*)// ==/UserScript=="); + rx.indexIn(fileData); + QString metadataBlock = rx.cap(1).trimmed(); + + if (metadataBlock.isEmpty()) { + qWarning() << "GreaseMonkey: File does not contain metadata block" << filePath; + return; + } + + QStringList requireList; + + const QStringList &lines = metadataBlock.split('\n'); + foreach(QString line, lines) { + if (!line.startsWith("// @")) { + continue; + } + + line = line.mid(3).replace('\t', ' '); + int index = line.indexOf(' '); + + if (index < 0) { + continue; + } + + const QString &key = line.left(index).trimmed(); + const QString &value = line.mid(index + 1).trimmed(); + + // Ignored values: + // @resource + // @unwrap + + if (key.isEmpty() || value.isEmpty()) { + continue; + } + + if (key == "@name") { + m_name = value; + } + else if (key == "@namespace") { + m_namespace = value; + } + else if (key == "@description") { + m_description = value; + } + else if (key == "@version") { + m_version = value; + } + else if (key == "@updateURL") { + m_downloadUrl = QUrl(value); + } + else if (key == "@include" || key == "@match") { + m_include.append(GM_UrlMatcher(value)); + } + else if (key == "@exclude" || key == "@exclude_match") { + m_exclude.append(GM_UrlMatcher(value)); + } + else if (key == "@require") { + requireList.append(value); + } + else if (key == "@run-at") { + if (value == "document-end") { + m_startAt = DocumentEnd; + } + else if (value == "document-start") { + m_startAt = DocumentStart; + } + } + else if (key == "@downloadURL" && m_downloadUrl.isEmpty()) { + m_downloadUrl = QUrl(value); + } + } + + if (m_include.isEmpty()) { + m_include.append(GM_UrlMatcher("*")); + } + + int index = fileData.indexOf("// ==/UserScript==") + 18; + QString script = fileData.mid(index).trimmed(); + + script.prepend(m_manager->requireScripts(requireList)); + script = QString("(function(){%1})();").arg(script); + + m_script = script; + m_valid = !script.isEmpty(); +} diff --git a/src/plugins/GreaseMonkey/gm_script.h b/src/plugins/GreaseMonkey/gm_script.h new file mode 100644 index 000000000..607d086ba --- /dev/null +++ b/src/plugins/GreaseMonkey/gm_script.h @@ -0,0 +1,83 @@ +/* ============================================================ +* GreaseMonkey plugin for QupZilla +* Copyright (C) 2012 David Rosca +* +* This program is free software: you can redistribute it and/or modify +* it under the terms of the GNU General Public License as published by +* the Free Software Foundation, either version 3 of the License, or +* (at your option) any later version. +* +* This program is distributed in the hope that it will be useful, +* but WITHOUT ANY WARRANTY; without even the implied warranty of +* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +* GNU General Public License for more details. +* +* You should have received a copy of the GNU General Public License +* along with this program. If not, see . +* ============================================================ */ +#ifndef GM_SCRIPT_H +#define GM_SCRIPT_H + +#include "gm_urlmatcher.h" + +#include +#include +#include + +class QWebFrame; + +class GM_Manager; +class GM_UrlMatcher; + +class GM_Script +{ +public: + GM_Script(GM_Manager* manager, const QString &filePath); + + enum StartAt { DocumentStart, DocumentEnd }; + + bool isValid() const; + QString name() const; + QString nameSpace() const; + QString fullName() const; + + QString description() const; + QString version() const; + + QUrl downloadUrl() const; + StartAt startAt() const; + + bool isEnabled() const; + void setEnabled(bool enable); + + QStringList include() const; + QStringList exclude() const; + + QString script() const; + QString fileName() const; + + bool match(const QString &urlString); + +private: + void parseScript(const QString &filePath); + + GM_Manager* m_manager; + + QString m_name; + QString m_namespace; + QString m_description; + QString m_version; + + QList m_include; + QList m_exclude; + + QUrl m_downloadUrl; + StartAt m_startAt; + + QString m_script; + QString m_fileName; + bool m_enabled; + bool m_valid; +}; + +#endif // GM_SCRIPT_H diff --git a/src/plugins/GreaseMonkey/gm_urlmatcher.cpp b/src/plugins/GreaseMonkey/gm_urlmatcher.cpp new file mode 100644 index 000000000..c5f24502f --- /dev/null +++ b/src/plugins/GreaseMonkey/gm_urlmatcher.cpp @@ -0,0 +1,103 @@ +/* ============================================================ +* GreaseMonkey plugin for QupZilla +* Copyright (C) 2012 David Rosca +* +* This program is free software: you can redistribute it and/or modify +* it under the terms of the GNU General Public License as published by +* the Free Software Foundation, either version 3 of the License, or +* (at your option) any later version. +* +* This program is distributed in the hope that it will be useful, +* but WITHOUT ANY WARRANTY; without even the implied warranty of +* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +* GNU General Public License for more details. +* +* You should have received a copy of the GNU General Public License +* along with this program. If not, see . +* ============================================================ */ +#include "gm_urlmatcher.h" + +#include +#include + +bool wildcardMatch(const QString &string, const QString &pattern) +{ + int stringSize = string.size(); + int patternSize = pattern.size(); + + bool startsWithWildcard = pattern[0] == '*'; + bool endsWithWildcard = pattern[patternSize - 1] == '*'; + + const QStringList &parts = pattern.split('*'); + int pos = 0; + + if (startsWithWildcard) { + pos = string.indexOf(parts.at(1)); + if (pos == -1) { + return false; + } + } + + foreach(const QString & part, parts) { + pos = string.indexOf(part, pos); + if (pos == -1) { + return false; + } + } + + if (!endsWithWildcard && stringSize - pos != parts.last().size()) { + return false; + } + + return true; +} + +GM_UrlMatcher::GM_UrlMatcher(const QString &pattern) + : m_pattern(pattern) + , m_useRegExp(false) +{ + parsePattern(m_pattern); +} + +QString GM_UrlMatcher::pattern() const +{ + return m_pattern; +} + +bool GM_UrlMatcher::match(const QString &urlString) const +{ + if (m_useRegExp) { + return m_regExp.indexIn(urlString) != -1; + } + else { + return wildcardMatch(urlString, m_matchString); + } +} + +void GM_UrlMatcher::parsePattern(QString pattern) +{ + if (pattern.startsWith('/') && pattern.endsWith('/')) { + pattern = pattern.mid(1); + pattern = pattern.left(pattern.size() - 1); + + m_regExp = QRegExp(pattern, Qt::CaseInsensitive); + m_useRegExp = true; + return; + } + + if (pattern.contains(".tld")) { + + pattern.replace(QRegExp("(\\W)"), "\\\\1") + .replace(QRegExp("\\*+"), "*") + .replace(QRegExp("^\\\\\\|"), "^") + .replace(QRegExp("\\\\\\|$"), "$") + .replace(QRegExp("\\\\\\*"), ".*") + .replace("\\.tld", "\\.[a-z.]{2,6}"); + + m_useRegExp = true; + m_regExp = QRegExp(pattern, Qt::CaseInsensitive); + } + else { + m_matchString = pattern; + } +} diff --git a/src/plugins/GreaseMonkey/gm_urlmatcher.h b/src/plugins/GreaseMonkey/gm_urlmatcher.h new file mode 100644 index 000000000..6d45d422d --- /dev/null +++ b/src/plugins/GreaseMonkey/gm_urlmatcher.h @@ -0,0 +1,44 @@ +/* ============================================================ +* GreaseMonkey plugin for QupZilla +* Copyright (C) 2012 David Rosca +* +* This program is free software: you can redistribute it and/or modify +* it under the terms of the GNU General Public License as published by +* the Free Software Foundation, either version 3 of the License, or +* (at your option) any later version. +* +* This program is distributed in the hope that it will be useful, +* but WITHOUT ANY WARRANTY; without even the implied warranty of +* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +* GNU General Public License for more details. +* +* You should have received a copy of the GNU General Public License +* along with this program. If not, see . +* ============================================================ */ +#ifndef GM_URLMATCHER_H +#define GM_URLMATCHER_H + +#include +#include + +class GM_UrlMatcher +{ +public: + GM_UrlMatcher(const QString &pattern); + + QString pattern() const; + + bool match(const QString &urlString) const; + +private: + void parsePattern(QString pattern); + + QString m_pattern; + + QString m_matchString; + QRegExp m_regExp; + + bool m_useRegExp; +}; + +#endif // GM_URLMATCHER_H diff --git a/src/plugins/GreaseMonkey/greasemonkey.qrc b/src/plugins/GreaseMonkey/greasemonkey.qrc new file mode 100644 index 000000000..a6ad25325 --- /dev/null +++ b/src/plugins/GreaseMonkey/greasemonkey.qrc @@ -0,0 +1,12 @@ + + + data/icon.png + data/bootstrap.min.js + data/script.png + locale/cs_CZ.qm + locale/de_DE.qm + locale/fr_FR.qm + locale/sr_BA.qm + locale/sr_RS.qm + + diff --git a/src/plugins/GreaseMonkey/settings/gm_settings.cpp b/src/plugins/GreaseMonkey/settings/gm_settings.cpp new file mode 100644 index 000000000..8ca0f68b4 --- /dev/null +++ b/src/plugins/GreaseMonkey/settings/gm_settings.cpp @@ -0,0 +1,154 @@ +/* ============================================================ +* GreaseMonkey plugin for QupZilla +* Copyright (C) 2012 David Rosca +* +* This program is free software: you can redistribute it and/or modify +* it under the terms of the GNU General Public License as published by +* the Free Software Foundation, either version 3 of the License, or +* (at your option) any later version. +* +* This program is distributed in the hope that it will be useful, +* but WITHOUT ANY WARRANTY; without even the implied warranty of +* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +* GNU General Public License for more details. +* +* You should have received a copy of the GNU General Public License +* along with this program. If not, see . +* ============================================================ */ +#include "gm_settings.h" +#include "ui_gm_settings.h" +#include "gm_settingsscriptinfo.h" +#include "../gm_manager.h" +#include "../gm_script.h" + +#include "mainapplication.h" + +#include +#include + +GM_Settings::GM_Settings(GM_Manager* manager, QWidget* parent) + : QDialog(parent) + , ui(new Ui::GM_Settings) + , m_manager(manager) +{ + ui->setupUi(this); + + connect(ui->listWidget, SIGNAL(itemDoubleClicked(QListWidgetItem*)), this, SLOT(showItemInfo(QListWidgetItem*))); + connect(ui->listWidget, SIGNAL(removeItemRequested(QListWidgetItem*)), this, SLOT(removeItem(QListWidgetItem*))); + connect(ui->openDirectory, SIGNAL(clicked()), this, SLOT(openScriptsDirectory())); + connect(ui->link, SIGNAL(clicked(QPoint)), this, SLOT(openUserscripts())); + + loadScripts(); +} + +void GM_Settings::openUserscripts() +{ + mApp->addNewTab(QUrl("http://www.userscripts.org")); + close(); +} + +void GM_Settings::showItemInfo(QListWidgetItem* item) +{ + GM_Script* script = getScript(item); + if (!script) { + return; + } + + GM_SettingsScriptInfo info(script, this); + info.exec(); +} + +void GM_Settings::removeItem(QListWidgetItem* item) +{ + GM_Script* script = getScript(item); + if (!script) { + return; + } + + QMessageBox::StandardButton button = QMessageBox::question(this, tr("Remove script"), + tr("Are you sure you want to remove '%1'?").arg(script->name()), + QMessageBox::Yes | QMessageBox::No); + + if (button == QMessageBox::Yes && m_manager->removeScript(script)) { + delete item; + } +} + +void GM_Settings::itemChanged(QListWidgetItem* item) +{ + GM_Script* script = getScript(item); + if (!script) { + return; + } + + if (item->checkState() == Qt::Checked) { + m_manager->enableScript(script); + } + else { + m_manager->disableScript(script); + } +} + +void GM_Settings::openScriptsDirectory() +{ + QDesktopServices::openUrl(QUrl::fromLocalFile(m_manager->scriptsDirectory())); +} + +void GM_Settings::loadScripts() +{ + disconnect(ui->listWidget, SIGNAL(itemChanged(QListWidgetItem*)), this, SLOT(itemChanged(QListWidgetItem*))); + + foreach(GM_Script * script, m_manager->allScripts()) { + QListWidgetItem* item = new QListWidgetItem(ui->listWidget); + QIcon icon = QIcon(":/gm/data/script.png"); + item->setIcon(icon); + + item->setText(script->name()); + item->setData(Qt::UserRole, script->version()); + item->setData(Qt::UserRole + 1, script->description()); + + item->setFlags(item->flags() | Qt::ItemIsUserCheckable); + item->setCheckState(script->isEnabled() ? Qt::Checked : Qt::Unchecked); + item->setData(Qt::UserRole + 10, qVariantFromValue((void*)script)); + + ui->listWidget->addItem(item); + } + + ui->listWidget->sortItems(); + + bool itemMoved; + do { + itemMoved = false; + for (int i = 0; i < ui->listWidget->count(); ++i) { + QListWidgetItem* topItem = ui->listWidget->item(i); + QListWidgetItem* bottomItem = ui->listWidget->item(i + 1); + if (!topItem || !bottomItem) { + continue; + } + + if (topItem->checkState() == Qt::Unchecked && bottomItem->checkState() == Qt::Checked) { + QListWidgetItem* item = ui->listWidget->takeItem(i + 1); + ui->listWidget->insertItem(i, item); + itemMoved = true; + } + } + } + while (itemMoved); + + connect(ui->listWidget, SIGNAL(itemChanged(QListWidgetItem*)), this, SLOT(itemChanged(QListWidgetItem*))); +} + +GM_Script* GM_Settings::getScript(QListWidgetItem* item) +{ + if (!item) { + return 0; + } + + GM_Script* script = static_cast(item->data(Qt::UserRole + 10).value()); + return script; +} + +GM_Settings::~GM_Settings() +{ + delete ui; +} diff --git a/src/plugins/GreaseMonkey/settings/gm_settings.h b/src/plugins/GreaseMonkey/settings/gm_settings.h new file mode 100644 index 000000000..0402638ef --- /dev/null +++ b/src/plugins/GreaseMonkey/settings/gm_settings.h @@ -0,0 +1,58 @@ +/* ============================================================ +* GreaseMonkey plugin for QupZilla +* Copyright (C) 2012 David Rosca +* +* This program is free software: you can redistribute it and/or modify +* it under the terms of the GNU General Public License as published by +* the Free Software Foundation, either version 3 of the License, or +* (at your option) any later version. +* +* This program is distributed in the hope that it will be useful, +* but WITHOUT ANY WARRANTY; without even the implied warranty of +* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +* GNU General Public License for more details. +* +* You should have received a copy of the GNU General Public License +* along with this program. If not, see . +* ============================================================ */ +#ifndef GM_SETTINGS_H +#define GM_SETTINGS_H + +#include + +namespace Ui +{ +class GM_Settings; +} + +class QListWidgetItem; + +class GM_Manager; +class GM_Script; + +class GM_Settings : public QDialog +{ + Q_OBJECT + +public: + explicit GM_Settings(GM_Manager* manager, QWidget* parent = 0); + ~GM_Settings(); + +private slots: + void showItemInfo(QListWidgetItem* item); + void removeItem(QListWidgetItem* item); + + void itemChanged(QListWidgetItem* item); + + void openScriptsDirectory(); + void openUserscripts(); + +private: + void loadScripts(); + inline GM_Script* getScript(QListWidgetItem* item); + + Ui::GM_Settings* ui; + GM_Manager* m_manager; +}; + +#endif // GM_SETTINGS_H diff --git a/src/plugins/GreaseMonkey/settings/gm_settings.ui b/src/plugins/GreaseMonkey/settings/gm_settings.ui new file mode 100644 index 000000000..9d99f1bdf --- /dev/null +++ b/src/plugins/GreaseMonkey/settings/gm_settings.ui @@ -0,0 +1,263 @@ + + + GM_Settings + + + + 0 + 0 + 512 + 416 + + + + GreaseMonkey Scripts + + + + + + + + Qt::Horizontal + + + + 40 + 20 + + + + + + + + + 0 + 0 + + + + + + + :/gm/data/icon.png + + + + + + + <h3>GreaseMonkey Scripts</h3> + + + + + + + Qt::Horizontal + + + + 40 + 20 + + + + + + + + + + Double clicking script will show additional information + + + Qt::AlignCenter + + + + + + + + + Qt::Horizontal + + + QSizePolicy::Fixed + + + + 10 + 20 + + + + + + + + true + + + QAbstractItemView::ScrollPerPixel + + + true + + + true + + + + + + + Qt::Horizontal + + + QSizePolicy::Fixed + + + + 10 + 20 + + + + + + + + + + 2 + + + + + Qt::Horizontal + + + + 40 + 20 + + + + + + + + More scripts can be downloaded from + + + + + + + PointingHandCursor + + + userscripts.org + + + true + + + + + + + Qt::Horizontal + + + + 40 + 20 + + + + + + + + + + + + + 0 + 0 + + + + Open scripts directory + + + + + + + Qt::Horizontal + + + QDialogButtonBox::Ok + + + + + + + + + + ClickableLabel + QLabel +
clickablelabel.h
+
+ + GM_SettingsListWidget + QListWidget +
settings/gm_settingslistwidget.h
+
+
+ + + + + + buttonBox + accepted() + GM_Settings + accept() + + + 248 + 254 + + + 157 + 274 + + + + + buttonBox + rejected() + GM_Settings + reject() + + + 316 + 260 + + + 286 + 274 + + + + +
diff --git a/src/plugins/GreaseMonkey/settings/gm_settingslistdelegate.cpp b/src/plugins/GreaseMonkey/settings/gm_settingslistdelegate.cpp new file mode 100644 index 000000000..7bbce4dea --- /dev/null +++ b/src/plugins/GreaseMonkey/settings/gm_settingslistdelegate.cpp @@ -0,0 +1,136 @@ +/* ============================================================ +* GreaseMonkey plugin for QupZilla +* Copyright (C) 2012 David Rosca +* +* This program is free software: you can redistribute it and/or modify +* it under the terms of the GNU General Public License as published by +* the Free Software Foundation, either version 3 of the License, or +* (at your option) any later version. +* +* This program is distributed in the hope that it will be useful, +* but WITHOUT ANY WARRANTY; without even the implied warranty of +* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +* GNU General Public License for more details. +* +* You should have received a copy of the GNU General Public License +* along with this program. If not, see . +* ============================================================ */ +#include "gm_settingslistdelegate.h" + +#include "iconprovider.h" + +#include +#include +#include + +GM_SettingsListDelegate::GM_SettingsListDelegate(QObject* parent) + : QStyledItemDelegate(parent) + , m_rowHeight(0) + , m_padding(0) +{ + m_removePixmap = qIconProvider->standardIcon(QStyle::SP_DialogCloseButton).pixmap(16); +} + +int GM_SettingsListDelegate::padding() const +{ + return m_padding; +} + +void GM_SettingsListDelegate::paint(QPainter* painter, const QStyleOptionViewItem &option, const QModelIndex &index) const +{ + QStyleOptionViewItemV4 opt = option; + initStyleOption(&opt, index); + + const QWidget* w = opt.widget; + const QStyle* style = w ? w->style() : QApplication::style(); + const int height = opt.rect.height(); + const int center = height / 2 + opt.rect.top(); + + // Prepare title font + QFont titleFont = opt.font; + titleFont.setBold(true); + titleFont.setPointSize(titleFont.pointSize() + 1); + + const QFontMetrics titleMetrics(titleFont); + const QPalette::ColorRole colorRole = opt.state & QStyle::State_Selected ? QPalette::HighlightedText : QPalette::Text; + + int leftPosition = m_padding; + int rightPosition = opt.rect.right() - m_padding - 16; // 16 for remove button + + // Draw background + style->drawPrimitive(QStyle::PE_PanelItemViewItem, &opt, painter, w); + + // Draw checkbox + const int checkboxSize = 18; + const int checkboxYPos = center - (checkboxSize / 2); + QStyleOptionViewItemV4 opt2 = opt; + opt2.checkState == Qt::Checked ? opt2.state |= QStyle::State_On : opt2.state |= QStyle::State_Off; + QRect styleCheckBoxRect = style->subElementRect(QStyle::SE_ViewItemCheckIndicator, &opt2, w); + opt2.rect = QRect(leftPosition, checkboxYPos, styleCheckBoxRect.width(), styleCheckBoxRect.height()); + style->drawPrimitive(QStyle::PE_IndicatorViewItemCheck, &opt2, painter, w); + leftPosition = opt2.rect.right() + m_padding; + + // Draw icon + const int iconSize = 32; + const int iconYPos = center - (iconSize / 2); + QRect iconRect(leftPosition, iconYPos, iconSize, iconSize); + QPixmap pixmap = index.data(Qt::DecorationRole).value().pixmap(iconSize); + painter->drawPixmap(iconRect, pixmap); + leftPosition = iconRect.right() + m_padding; + + // Draw script name + const QString &name = index.data(Qt::DisplayRole).toString(); + const int leftTitleEdge = leftPosition + 2; + const int rightTitleEdge = rightPosition - m_padding; + const int leftPosForVersion = titleMetrics.width(name) + m_padding; + QRect nameRect(leftTitleEdge, opt.rect.top() + m_padding, rightTitleEdge - leftTitleEdge, titleMetrics.height()); + painter->setFont(titleFont); + style->drawItemText(painter, nameRect, Qt::AlignLeft, opt.palette, true, name, colorRole); + + // Draw version + const QString &version = index.data(Qt::UserRole).toString(); + QRect versionRect(nameRect.x() + leftPosForVersion, nameRect.y(), rightTitleEdge - leftPosForVersion, titleMetrics.height()); + QFont versionFont = titleFont; + versionFont.setBold(false); + painter->setFont(versionFont); + style->drawItemText(painter, versionRect, Qt::AlignLeft, opt.palette, true, version, colorRole); + + // Draw description + const int infoYPos = nameRect.bottom() + opt.fontMetrics.leading(); + QRect infoRect(nameRect.x(), infoYPos, nameRect.width(), opt.fontMetrics.height()); + const QString &info = opt.fontMetrics.elidedText(index.data(Qt::UserRole + 1).toString(), Qt::ElideRight, infoRect.width()); + painter->setFont(opt.font); + style->drawItemText(painter, infoRect, Qt::TextSingleLine | Qt::AlignLeft, opt.palette, true, info, colorRole); + + // Draw remove button + const int removeIconSize = 16; + const int removeIconYPos = center - (removeIconSize / 2); + QRect removeIconRect(rightPosition, removeIconYPos, removeIconSize, removeIconSize); + painter->drawPixmap(removeIconRect, m_removePixmap); +} + +QSize GM_SettingsListDelegate::sizeHint(const QStyleOptionViewItem &option, const QModelIndex &index) const +{ + Q_UNUSED(index) + + if (!m_rowHeight) { + QStyleOptionViewItemV4 opt(option); + initStyleOption(&opt, index); + + const QWidget* w = opt.widget; + const QStyle* style = w ? w->style() : QApplication::style(); + const int padding = style->pixelMetric(QStyle::PM_FocusFrameHMargin, 0) + 1; + + QFont titleFont = opt.font; + titleFont.setBold(true); + titleFont.setPointSize(titleFont.pointSize() + 1); + + m_padding = padding > 5 ? padding : 5; + + const QFontMetrics titleMetrics(titleFont); + + m_rowHeight = 2 * m_padding + opt.fontMetrics.leading() + opt.fontMetrics.height() + titleMetrics.height(); + } + + return QSize(200, m_rowHeight); +} diff --git a/src/plugins/GreaseMonkey/settings/gm_settingslistdelegate.h b/src/plugins/GreaseMonkey/settings/gm_settingslistdelegate.h new file mode 100644 index 000000000..53f91be72 --- /dev/null +++ b/src/plugins/GreaseMonkey/settings/gm_settingslistdelegate.h @@ -0,0 +1,40 @@ +/* ============================================================ +* GreaseMonkey plugin for QupZilla +* Copyright (C) 2012 David Rosca +* +* This program is free software: you can redistribute it and/or modify +* it under the terms of the GNU General Public License as published by +* the Free Software Foundation, either version 3 of the License, or +* (at your option) any later version. +* +* This program is distributed in the hope that it will be useful, +* but WITHOUT ANY WARRANTY; without even the implied warranty of +* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +* GNU General Public License for more details. +* +* You should have received a copy of the GNU General Public License +* along with this program. If not, see . +* ============================================================ */ +#ifndef GM_SETTINGSLISTDELEGATE_H +#define GM_SETTINGSLISTDELEGATE_H + +#include + +class GM_SettingsListDelegate : public QStyledItemDelegate +{ +public: + explicit GM_SettingsListDelegate(QObject* parent = 0); + + int padding() const; + + void paint(QPainter* painter, const QStyleOptionViewItem &option, const QModelIndex &index) const; + QSize sizeHint(const QStyleOptionViewItem &option, const QModelIndex &index) const; + +private: + QPixmap m_removePixmap; + + mutable int m_rowHeight; + mutable int m_padding; +}; + +#endif // GM_SETTINGSLISTDELEGATE_H diff --git a/src/plugins/GreaseMonkey/settings/gm_settingslistwidget.cpp b/src/plugins/GreaseMonkey/settings/gm_settingslistwidget.cpp new file mode 100644 index 000000000..69e9fb14b --- /dev/null +++ b/src/plugins/GreaseMonkey/settings/gm_settingslistwidget.cpp @@ -0,0 +1,66 @@ +/* ============================================================ +* GreaseMonkey plugin for QupZilla +* Copyright (C) 2012 David Rosca +* +* This program is free software: you can redistribute it and/or modify +* it under the terms of the GNU General Public License as published by +* the Free Software Foundation, either version 3 of the License, or +* (at your option) any later version. +* +* This program is distributed in the hope that it will be useful, +* but WITHOUT ANY WARRANTY; without even the implied warranty of +* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +* GNU General Public License for more details. +* +* You should have received a copy of the GNU General Public License +* along with this program. If not, see . +* ============================================================ */ +#include "gm_settingslistwidget.h" +#include "gm_settingslistdelegate.h" + +#include +#include + +GM_SettingsListWidget::GM_SettingsListWidget(QWidget* parent) + : QListWidget(parent) + , m_delegate(new GM_SettingsListDelegate(this)) +{ + setItemDelegate(m_delegate); +} + +void GM_SettingsListWidget::mousePressEvent(QMouseEvent* event) +{ + if (containsRemoveIcon(event->pos())) { + emit removeItemRequested(itemAt(event->pos())); + return; + } + + QListWidget::mousePressEvent(event); +} + +void GM_SettingsListWidget::mouseDoubleClickEvent(QMouseEvent* event) +{ + if (containsRemoveIcon(event->pos())) { + emit removeItemRequested(itemAt(event->pos())); + return; + } + + QListWidget::mouseDoubleClickEvent(event); +} + +bool GM_SettingsListWidget::containsRemoveIcon(const QPoint &pos) const +{ + QListWidgetItem* item = itemAt(pos); + if (!item) { + return false; + } + + const QRect &rect = visualItemRect(item); + const int removeIconPosition = rect.right() - m_delegate->padding() - 16; + const int center = rect.height() / 2 + rect.top(); + const int removeIconYPos = center - (16 / 2); + + QRect removeIconRect(removeIconPosition, removeIconYPos, 16, 16); + + return removeIconRect.contains(pos); +} diff --git a/src/plugins/GreaseMonkey/settings/gm_settingslistwidget.h b/src/plugins/GreaseMonkey/settings/gm_settingslistwidget.h new file mode 100644 index 000000000..f70583408 --- /dev/null +++ b/src/plugins/GreaseMonkey/settings/gm_settingslistwidget.h @@ -0,0 +1,46 @@ +/* ============================================================ +* GreaseMonkey plugin for QupZilla +* Copyright (C) 2012 David Rosca +* +* This program is free software: you can redistribute it and/or modify +* it under the terms of the GNU General Public License as published by +* the Free Software Foundation, either version 3 of the License, or +* (at your option) any later version. +* +* This program is distributed in the hope that it will be useful, +* but WITHOUT ANY WARRANTY; without even the implied warranty of +* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +* GNU General Public License for more details. +* +* You should have received a copy of the GNU General Public License +* along with this program. If not, see . +* ============================================================ */ +#ifndef GM_SETTINGSLISTWIDGET_H +#define GM_SETTINGSLISTWIDGET_H + +#include + +class GM_SettingsListDelegate; + +class GM_SettingsListWidget : public QListWidget +{ + Q_OBJECT +public: + explicit GM_SettingsListWidget(QWidget* parent = 0); + +signals: + void removeItemRequested(QListWidgetItem* item); + +public slots: + +private: + bool containsRemoveIcon(const QPoint &pos) const; + + void mousePressEvent(QMouseEvent* event); + void mouseDoubleClickEvent(QMouseEvent* event); + + GM_SettingsListDelegate* m_delegate; + +}; + +#endif // GM_SETTINGSLISTWIDGET_H diff --git a/src/plugins/GreaseMonkey/settings/gm_settingsscriptinfo.cpp b/src/plugins/GreaseMonkey/settings/gm_settingsscriptinfo.cpp new file mode 100644 index 000000000..c5ca9ba1b --- /dev/null +++ b/src/plugins/GreaseMonkey/settings/gm_settingsscriptinfo.cpp @@ -0,0 +1,41 @@ +/* ============================================================ +* GreaseMonkey plugin for QupZilla +* Copyright (C) 2012 David Rosca +* +* This program is free software: you can redistribute it and/or modify +* it under the terms of the GNU General Public License as published by +* the Free Software Foundation, either version 3 of the License, or +* (at your option) any later version. +* +* This program is distributed in the hope that it will be useful, +* but WITHOUT ANY WARRANTY; without even the implied warranty of +* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +* GNU General Public License for more details. +* +* You should have received a copy of the GNU General Public License +* along with this program. If not, see . +* ============================================================ */ +#include "gm_settingsscriptinfo.h" +#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) +{ + ui->setupUi(this); + setWindowTitle(tr("Script Details of %1").arg(script->name())); + + 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("
")); +} + +GM_SettingsScriptInfo::~GM_SettingsScriptInfo() +{ + delete ui; +} diff --git a/src/plugins/GreaseMonkey/settings/gm_settingsscriptinfo.h b/src/plugins/GreaseMonkey/settings/gm_settingsscriptinfo.h new file mode 100644 index 000000000..f08d0a227 --- /dev/null +++ b/src/plugins/GreaseMonkey/settings/gm_settingsscriptinfo.h @@ -0,0 +1,42 @@ +/* ============================================================ +* GreaseMonkey plugin for QupZilla +* Copyright (C) 2012 David Rosca +* +* This program is free software: you can redistribute it and/or modify +* it under the terms of the GNU General Public License as published by +* the Free Software Foundation, either version 3 of the License, or +* (at your option) any later version. +* +* This program is distributed in the hope that it will be useful, +* but WITHOUT ANY WARRANTY; without even the implied warranty of +* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +* GNU General Public License for more details. +* +* You should have received a copy of the GNU General Public License +* along with this program. If not, see . +* ============================================================ */ +#ifndef GM_SETTINGSSCRIPTINFO_H +#define GM_SETTINGSSCRIPTINFO_H + +#include + +namespace Ui +{ +class GM_SettingsScriptInfo; +} + +class GM_Script; + +class GM_SettingsScriptInfo : public QDialog +{ + Q_OBJECT + +public: + explicit GM_SettingsScriptInfo(GM_Script* script, QWidget* parent = 0); + ~GM_SettingsScriptInfo(); + +private: + Ui::GM_SettingsScriptInfo* ui; +}; + +#endif // GM_SETTINGSSCRIPTINFO_H diff --git a/src/plugins/GreaseMonkey/settings/gm_settingsscriptinfo.ui b/src/plugins/GreaseMonkey/settings/gm_settingsscriptinfo.ui new file mode 100644 index 000000000..724ac526c --- /dev/null +++ b/src/plugins/GreaseMonkey/settings/gm_settingsscriptinfo.ui @@ -0,0 +1,191 @@ + + + GM_SettingsScriptInfo + + + + 0 + 0 + 485 + 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: + + + Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter + + + + + + + Does not run at: + + + Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter + + + + + + + + + + Qt::LinksAccessibleByMouse|Qt::TextSelectableByMouse + + + + + + + + + + Qt::LinksAccessibleByMouse|Qt::TextSelectableByMouse + + + + + + + + + + Qt::LinksAccessibleByMouse|Qt::TextSelectableByMouse + + + + + + + + + + Qt::LinksAccessibleByMouse|Qt::TextSelectableByMouse + + + + + + + + + + + + + + + + + + Qt::Horizontal + + + QDialogButtonBox::Close + + + + + + + + SqueezeLabelV2 + QLabel +
squeezelabelv2.h
+
+
+ + + + buttonBox + accepted() + GM_SettingsScriptInfo + accept() + + + 248 + 254 + + + 157 + 274 + + + + + buttonBox + rejected() + GM_SettingsScriptInfo + reject() + + + 316 + 260 + + + 286 + 274 + + + + +
diff --git a/src/plugins/GreaseMonkey/translations/cs_CZ.ts b/src/plugins/GreaseMonkey/translations/cs_CZ.ts new file mode 100644 index 000000000..ec0f56b96 --- /dev/null +++ b/src/plugins/GreaseMonkey/translations/cs_CZ.ts @@ -0,0 +1,177 @@ + + + + + GM_AddScriptDialog + + + GreaseMonkey Installation + Instalace GreaseMonkey + + + + <h3>GreaseMonkey Installation</h3> + <h3>Instalace GreaseMonkey</h3> + + + + You are about to install this userscript into GreaseMonkey: + Chystáte se nainstalovat tento uživatelský skript do GreaseMonkey: + + + + <b>You should only install scripts from sources you trust!</b> + <b>Měli byste instalovat pouze scripty z ověřených zdrojů!<b/> + + + + Are you sure you want to install it? + Opravdu chcete tento skript nainstalovat? + + + + Show source code of script + Zobrazit zdrojový kód skriptu + + + + <p>runs at<br/><i>%1</i></p> + <p>spouští se na<br/><i>%1</i></p> + + + + <p>does not run at<br/><i>%1</i></p> + <p>nespouští se na<br/><i>%1</i></p> + + + + Cannot install script + Nelze nainstalovat skript + + + + '%1' installed successfully + '%1' úspěšně nainstalován + + + + GM_Downloader + + + '%1' is already installed + '%1' již je nainstalován + + + + GM_Manager + + + GreaseMonkey + GreaseMonkey + + + + GM_Notification + + + This script can be installed with the GreaseMonkey plugin. + Tento skript může být nainstalován do GreaseMonkey rozšíření. + + + + Install + Instalovat + + + + Cannot install script + Nelze nainstalovat skript + + + + '%1' installed successfully + '%1' úspěšně nainstalován + + + + GM_Settings + + + GreaseMonkey Scripts + GreaseMonkey Skripty + + + + <h3>GreaseMonkey Scripts</h3> + <h3>GreaseMonkey Skripty</h3> + + + + Double clicking script will show additional information + Dvojtý klik na skript zobrazí podrobnosti + + + + More scripts can be downloaded from + Více skriptů lze stáhnout z + + + + Open scripts directory + Otevřít složku se skripty + + + + Remove script + Odstranit skript + + + + Are you sure you want to remove '%1'? + Opravdu chcete odstranit '%1'? + + + + GM_SettingsScriptInfo + + + Name: + Název: + + + + Version: + Verze: + + + + URL: + URL: + + + + Start at: + Běží na: + + + + Description: + Popis: + + + + Runs at: + Spouští se na: + + + + Does not run at: + Nespouští se na: + + + + Script Details of %1 + Detaily skriptu %1 + + + diff --git a/src/plugins/GreaseMonkey/translations/de_DE.ts b/src/plugins/GreaseMonkey/translations/de_DE.ts new file mode 100644 index 000000000..56f8fa5c2 --- /dev/null +++ b/src/plugins/GreaseMonkey/translations/de_DE.ts @@ -0,0 +1,177 @@ + + + + + GM_AddScriptDialog + + + GreaseMonkey Installation + GreaseMonkey Installation + + + + <h3>GreaseMonkey Installation</h3> + <h3>GreaseMonkey Installation</h3> + + + + You are about to install this userscript into GreaseMonkey: + Sie sind im Begriff, dieses Skript in GreaseMonkey zu installieren: + + + + <b>You should only install scripts from sources you trust!</b> + <b>Installieren Sie nur Skripte aus vertrauenswürdigen Quellen!</b> + + + + Are you sure you want to install it? + Möchten Sie es wirklich installieren? + + + + Show source code of script + Quelltext anzeigen + + + + <p>runs at<br/><i>%1</i></p> + <p>startet bei<br/><i>%1</i></p> + + + + <p>does not run at<br/><i>%1</i></p> + + + + + Cannot install script + Skript kann nicht installiert werden + + + + '%1' installed successfully + '%1' erfolgreich installiert + + + + GM_Downloader + + + '%1' is already installed + + + + + GM_Manager + + + GreaseMonkey + GreaseMonkey + + + + GM_Notification + + + This script can be installed with the GreaseMonkey plugin. + + + + + Install + Installieren + + + + Cannot install script + Skript kann nicht installiert werden + + + + '%1' installed successfully + '%1' erfolgreich installiert + + + + GM_Settings + + + GreaseMonkey Scripts + GreaseMonkey Skripte + + + + <h3>GreaseMonkey Scripts</h3> + <h3>GreaseMonkey Skripte</h3> + + + + Double clicking script will show additional information + Für weitere Informationen bitte doppelklicken + + + + More scripts can be downloaded from + Weitere Skripte herunterladen von + + + + Open scripts directory + + + + + Remove script + Skript entfernen + + + + Are you sure you want to remove '%1'? + Möchten Sie '%1' wirklich entfernen? + + + + GM_SettingsScriptInfo + + + Name: + Name: + + + + Version: + Version: + + + + URL: + URL: + + + + Start at: + Beginnen bei: + + + + Description: + Beschreibung: + + + + Runs at: + + + + + Does not run at: + + + + + Script Details of %1 + Skript Details von %1 + + + diff --git a/src/plugins/GreaseMonkey/translations/fr_FR.ts b/src/plugins/GreaseMonkey/translations/fr_FR.ts new file mode 100644 index 000000000..e5167f01a --- /dev/null +++ b/src/plugins/GreaseMonkey/translations/fr_FR.ts @@ -0,0 +1,177 @@ + + + + + GM_AddScriptDialog + + + GreaseMonkey Installation + Installation de GreaseMonkey + + + + <h3>GreaseMonkey Installation</h3> + <h3>Installation de GreaseMonkey</h3> + + + + You are about to install this userscript into GreaseMonkey: + Vous êtes sur le point d'installer ce script via GreaseMonkey : + + + + <b>You should only install scripts from sources you trust!</b> + <b>N'installez que des script provenant de sources sûres !</b> + + + + Are you sure you want to install it? + Etes vous sûr de vouloir installer ce script ? + + + + Show source code of script + Montrer le code source + + + + <p>runs at<br/><i>%1</i></p> + <p>Lancer<br/><i>%1</i></p> + + + + <p>does not run at<br/><i>%1</i></p> + + + + + Cannot install script + Installation du script impossible + + + + '%1' installed successfully + '%1' Installation réussie + + + + GM_Downloader + + + '%1' is already installed + + + + + GM_Manager + + + GreaseMonkey + GreaseMonkey + + + + GM_Notification + + + This script can be installed with the GreaseMonkey plugin. + + + + + Install + Installer + + + + Cannot install script + Installation du script impossible + + + + '%1' installed successfully + '%1' Installation réussie + + + + GM_Settings + + + GreaseMonkey Scripts + Scripts de GreaseMonkey + + + + <h3>GreaseMonkey Scripts</h3> + <h3>Scripts de GreaseMonkey</h3> + + + + Double clicking script will show additional information + Un double clique sur le script vous montrera des informations supplémentaires + + + + More scripts can be downloaded from + Des scripts complémentaires peuvent être téléchargés ici + + + + Open scripts directory + + + + + Remove script + Supprimer le script + + + + Are you sure you want to remove '%1'? + Etes vous sûr de vouloir supprimer '%1' ? + + + + GM_SettingsScriptInfo + + + Name: + Nom : + + + + Version: + Version : + + + + URL: + URL : + + + + Start at: + Commencer à partir de : + + + + Description: + Description : + + + + Runs at: + + + + + Does not run at: + + + + + Script Details of %1 + Détails du script %1 + + + diff --git a/src/plugins/GreaseMonkey/translations/sr_BA.ts b/src/plugins/GreaseMonkey/translations/sr_BA.ts new file mode 100644 index 000000000..8a7dd3f25 --- /dev/null +++ b/src/plugins/GreaseMonkey/translations/sr_BA.ts @@ -0,0 +1,177 @@ + + + + + GM_AddScriptDialog + + + GreaseMonkey Installation + Инсталација GreaseMonkey скрипте + + + + <h3>GreaseMonkey Installation</h3> + <h3>Инсталација GreaseMonkey скрипте</h3> + + + + You are about to install this userscript into GreaseMonkey: + Инсталираћете ову скрипту у GreaseMonkey: + + + + <b>You should only install scripts from sources you trust!</b> + <b>Инсталирајте само скрипте од извора којима вјерујете!</b> + + + + Are you sure you want to install it? + Желите ли заиста да је инсталирате? + + + + Show source code of script + Прикажи изворни кôд скрипте + + + + <p>runs at<br/><i>%1</i></p> + <p>покреће се на<br/><i>%1</i></p> + + + + <p>does not run at<br/><i>%1</i></p> + <p>не покреће се на<br/><i>%1</i></p> + + + + Cannot install script + Не могу да инсталирам скрипту + + + + '%1' installed successfully + „%1“ је успјешно инсталирана + + + + GM_Downloader + + + '%1' is already installed + + + + + GM_Manager + + + GreaseMonkey + GreaseMonkey + + + + GM_Notification + + + This script can be installed with the GreaseMonkey plugin. + Ова скрипта може бити инсталирана помоћу GreaseMonkey проширења. + + + + Install + Инсталирај + + + + Cannot install script + Не могу да инсталирам скрипту + + + + '%1' installed successfully + „%1“ је успјешно инсталирана + + + + GM_Settings + + + GreaseMonkey Scripts + GreaseMonkey скрипте + + + + <h3>GreaseMonkey Scripts</h3> + <h3>GreaseMonkey скрипте</h3> + + + + Double clicking script will show additional information + Двоклик ће вам приказати додатне податке + + + + More scripts can be downloaded from + Скрипте можете преузети са + + + + Open scripts directory + + + + + Remove script + Уклони скрипту + + + + Are you sure you want to remove '%1'? + Желите ли заиста да уклоните „%1“? + + + + GM_SettingsScriptInfo + + + Name: + Име: + + + + Version: + Издање: + + + + URL: + УРЛ: + + + + Start at: + Покреће се при: + + + + Description: + Опис: + + + + Runs at: + Покреће се на: + + + + Does not run at: + Не покреће се на: + + + + Script Details of %1 + Детаљи скрипте %1 + + + diff --git a/src/plugins/GreaseMonkey/translations/sr_RS.ts b/src/plugins/GreaseMonkey/translations/sr_RS.ts new file mode 100644 index 000000000..e42bfa48b --- /dev/null +++ b/src/plugins/GreaseMonkey/translations/sr_RS.ts @@ -0,0 +1,177 @@ + + + + + GM_AddScriptDialog + + + GreaseMonkey Installation + Инсталација GreaseMonkey скрипте + + + + <h3>GreaseMonkey Installation</h3> + <h3>Инсталација GreaseMonkey скрипте</h3> + + + + You are about to install this userscript into GreaseMonkey: + Инсталираћете ову скрипту у GreaseMonkey: + + + + <b>You should only install scripts from sources you trust!</b> + <b>Инсталирајте само скрипте од извора којима верујете!</b> + + + + Are you sure you want to install it? + Желите ли заиста да је инсталирате? + + + + Show source code of script + Прикажи изворни кôд скрипте + + + + <p>runs at<br/><i>%1</i></p> + <p>покреће се на<br/><i>%1</i></p> + + + + <p>does not run at<br/><i>%1</i></p> + <p>не покреће се на<br/><i>%1</i></p> + + + + Cannot install script + Не могу да инсталирам скрипту + + + + '%1' installed successfully + „%1“ је успешно инсталирана + + + + GM_Downloader + + + '%1' is already installed + + + + + GM_Manager + + + GreaseMonkey + GreaseMonkey + + + + GM_Notification + + + This script can be installed with the GreaseMonkey plugin. + Ова скрипта може бити инсталирана помоћу GreaseMonkey проширења. + + + + Install + Инсталирај + + + + Cannot install script + Не могу да инсталирам скрипту + + + + '%1' installed successfully + „%1“ је успешно инсталирана + + + + GM_Settings + + + GreaseMonkey Scripts + GreaseMonkey скрипте + + + + <h3>GreaseMonkey Scripts</h3> + <h3>GreaseMonkey скрипте</h3> + + + + Double clicking script will show additional information + Двоклик ће вам приказати додатне податке + + + + More scripts can be downloaded from + Скрипте можете преузети са + + + + Open scripts directory + + + + + Remove script + Уклони скрипту + + + + Are you sure you want to remove '%1'? + Желите ли заиста да уклоните „%1“? + + + + GM_SettingsScriptInfo + + + Name: + Име: + + + + Version: + Издање: + + + + URL: + УРЛ: + + + + Start at: + Покреће се при: + + + + Description: + Опис: + + + + Runs at: + Покреће се на: + + + + Does not run at: + Не покреће се на: + + + + Script Details of %1 + Детаљи скрипте %1 + + + diff --git a/src/plugins/MouseGestures/mousegesturesplugin.cpp b/src/plugins/MouseGestures/mousegesturesplugin.cpp index 25e438980..be580cfc0 100644 --- a/src/plugins/MouseGestures/mousegesturesplugin.cpp +++ b/src/plugins/MouseGestures/mousegesturesplugin.cpp @@ -63,7 +63,7 @@ bool MouseGesturesPlugin::testPlugin() { // Let's be sure, require latest version of QupZilla - return (QupZilla::VERSION == "1.2.0"); + return (QupZilla::VERSION == "1.3.0"); } QTranslator* MouseGesturesPlugin::getTranslator(const QString &locale) diff --git a/src/plugins/PIM/PIM.pro b/src/plugins/PIM/PIM.pro new file mode 100644 index 000000000..5acd412d2 --- /dev/null +++ b/src/plugins/PIM/PIM.pro @@ -0,0 +1,33 @@ +TARGET = PIM +os2: TARGET = PIM + +SOURCES = \ + PIM_plugin.cpp \ + PIM_handler.cpp \ + PIM_settings.cpp + +HEADERS = \ + PIM_plugin.h \ + PIM_handler.h \ + PIM_settings.h + +FORMS += \ + PIM_settings.ui + +RESOURCES = PIM_res.qrc + +TRANSLATIONS = \ + translations/cs_CZ.ts \ + translations/de_DE.ts \ + translations/fr_FR.ts \ + translations/sr_BA.ts \ + translations/sr_RS.ts \ + translations/zh_TW.ts \ + +srcdir = $$(QUPZILLA_SRCDIR) +equals(srcdir, "") { + include(../../plugins.pri) +} +else { + include($$srcdir/src/plugins.pri) +} diff --git a/src/plugins/PIM/PIM_handler.cpp b/src/plugins/PIM/PIM_handler.cpp new file mode 100644 index 000000000..e59006911 --- /dev/null +++ b/src/plugins/PIM/PIM_handler.cpp @@ -0,0 +1,221 @@ +/* ============================================================ +* Personal Information Manager plugin for QupZilla +* Copyright (C) 2012 David Rosca +* Copyright (C) 2012 Mladen Pejaković +* +* This program is free software: you can redistribute it and/or modify +* it under the terms of the GNU General Public License as published by +* the Free Software Foundation, either version 3 of the License, or +* (at your option) any later version. +* +* This program is distributed in the hope that it will be useful, +* but WITHOUT ANY WARRANTY; without even the implied warranty of +* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +* GNU General Public License for more details. +* +* You should have received a copy of the GNU General Public License +* along with this program. If not, see . +* ============================================================ */ +#include "PIM_handler.h" +#include "PIM_settings.h" +#include "webview.h" +#include "webpage.h" + +#include +#include +#include +#include +#include +#include + +PIM_Handler::PIM_Handler(const QString &sPath, QObject* parent) + : QObject(parent) + , m_settingsFile(sPath + "extensions.ini") + , m_loaded(false) +{ +} + +void PIM_Handler::loadSettings() +{ + QSettings settings(m_settingsFile, QSettings::IniFormat); + + settings.beginGroup("PIM"); + m_allInfo[PI_LastName] = settings.value("LastName", "").toString(); + m_allInfo[PI_FirstName] = settings.value("FirstName", "").toString(); + m_allInfo[PI_Email] = settings.value("Email", "").toString(); + m_allInfo[PI_Mobile] = settings.value("Mobile", "").toString(); + m_allInfo[PI_Phone] = settings.value("Phone", "").toString(); + m_allInfo[PI_Address] = settings.value("Address", "").toString(); + m_allInfo[PI_City] = settings.value("City", "").toString(); + m_allInfo[PI_Zip] = settings.value("Zip", "").toString(); + m_allInfo[PI_State] = settings.value("State", "").toString(); + m_allInfo[PI_Country] = settings.value("Country", "").toString(); + m_allInfo[PI_HomePage] = settings.value("HomePage", "").toString(); + m_allInfo[PI_Special1] = settings.value("Special1", "").toString(); + m_allInfo[PI_Special2] = settings.value("Special2", "").toString(); + m_allInfo[PI_Special3] = settings.value("Special3", "").toString(); + settings.endGroup(); + + m_translations[PI_LastName] = tr("Last Name"); + m_translations[PI_FirstName] = tr("First Name"); + m_translations[PI_Email] = tr("E-mail"); + m_translations[PI_Mobile] = tr("Mobile"); + m_translations[PI_Phone] = tr("Phone"); + m_translations[PI_Address] = tr("Address"); + m_translations[PI_City] = tr("City"); + m_translations[PI_Zip] = tr("ZIP Code"); + m_translations[PI_State] = tr("State/Region"); + m_translations[PI_Country] = tr("Country"); + m_translations[PI_HomePage] = tr("Home Page"); + m_translations[PI_Special1] = tr("Custom 1"); + m_translations[PI_Special2] = tr("Custom 2"); + m_translations[PI_Special3] = tr("Custom 3"); + + m_infoMatches[PI_LastName] << "lastname" << "surname"; + m_infoMatches[PI_FirstName] << "firstname" << "name"; + m_infoMatches[PI_Email] << "email" << "e-mail" << "mail"; + m_infoMatches[PI_Mobile] << "mobile" << "mobilephone"; + m_infoMatches[PI_Phone] << "phone" << "telephone"; + m_infoMatches[PI_Address] << "address"; + m_infoMatches[PI_City] << "city"; + m_infoMatches[PI_Zip] << "zip"; + m_infoMatches[PI_State] << "state" << "region"; + m_infoMatches[PI_Country] << "country"; + m_infoMatches[PI_HomePage] << "homepage" << "www"; + + m_loaded = true; +} + +void PIM_Handler::showSettings(QWidget* parent) +{ + PIM_Settings* settings = new PIM_Settings(m_settingsFile, parent); + settings->show(); + + connect(settings, SIGNAL(accepted()), this, SLOT(loadSettings())); +} + +void PIM_Handler::populateWebViewMenu(QMenu* menu, WebView* view, const QWebHitTestResult &hitTest) +{ + m_view = view; + m_element = hitTest.element(); + + if (!hitTest.isContentEditable()) { + return; + } + + if (!m_loaded) { + loadSettings(); + } + + QMenu* pimMenu = new QMenu(tr("Insert Personal Information")); + pimMenu->setIcon(QIcon(":/PIM/data/PIM.png")); + + for (int i = 0; i < PI_Max; ++i) { + const QString &info = m_allInfo[PI_Type(i)]; + if (info.isEmpty()) { + continue; + } + + QAction* action = pimMenu->addAction(m_translations[PI_Type(i)], this, SLOT(pimInsert())); + action->setData(info); + } + + pimMenu->addSeparator(); + pimMenu->addAction(tr("Edit"), this, SLOT(showSettings())); + + menu->addMenu(pimMenu); + menu->addSeparator(); +} + +bool PIM_Handler::keyPress(WebView* view, QKeyEvent* event) +{ + if (!view) { + return false; + } + + bool isEnter = event->key() == Qt::Key_Return || event->key() == Qt::Key_Enter; + + if (!isEnter || event->modifiers() != Qt::ControlModifier) { + return false; + } + + const QWebElement &document = view->page()->mainFrame()->documentElement(); + const QWebElementCollection elements = document.findAll("input[type=\"text\"]"); + + foreach(QWebElement element, elements) { + const QString &name = element.attribute("name"); + if (name.isEmpty()) { + continue; + } + + PI_Type match = nameMatch(name); + if (match != PI_Invalid) { + element.evaluateJavaScript(QString("this.value = \"%1\"").arg(m_allInfo[match])); + } + } + + return true; +} + +void PIM_Handler::webPageCreated(WebPage* page) +{ + connect(page, SIGNAL(loadFinished(bool)), this, SLOT(pageLoadFinished())); +} + +void PIM_Handler::pimInsert() +{ + QAction* action = qobject_cast(sender()); + if (m_element.isNull() || !action) { + return; + } + + QString info = action->data().toString(); + info.replace('"', "\\\""); + m_element.evaluateJavaScript(QString("var newVal = this.value.substring(0, this.selectionStart) + \"%1\" + this.value.substring(this.selectionEnd); this.value = newVal;").arg(info)); +} + +void PIM_Handler::pageLoadFinished() +{ + WebPage* page = qobject_cast(sender()); + if (!page) { + return; + } + + if (!m_loaded) { + loadSettings(); + } + + const QWebElement &document = page->mainFrame()->documentElement(); + const QWebElementCollection elements = document.findAll("input[type=\"text\"]"); + + foreach(QWebElement element, elements) { + const QString &name = element.attribute("name"); + if (name.isEmpty()) { + continue; + } + + PI_Type match = nameMatch(name); + if (match != PI_Invalid) { + element.setStyleProperty("-webkit-appearance", "none"); + element.setStyleProperty("-webkit-box-shadow", "inset 0 0 2px 1px #EEE000"); + } + } +} + +PIM_Handler::PI_Type PIM_Handler::nameMatch(const QString &name) +{ + for (int i = 0; i < PI_Max; ++i) { + if (!m_allInfo[PI_Type(i)].isEmpty()) { + foreach(const QString & n, m_infoMatches[PI_Type(i)]) { + if (name == n) { + return PI_Type(i); + } + if (name.contains(n)) { + return PI_Type(i); + } + } + } + } + + return PI_Invalid; +} diff --git a/src/plugins/PIM/PIM_handler.h b/src/plugins/PIM/PIM_handler.h new file mode 100644 index 000000000..a40d0de33 --- /dev/null +++ b/src/plugins/PIM/PIM_handler.h @@ -0,0 +1,87 @@ +/* ============================================================ +* Personal Information Manager plugin for QupZilla +* Copyright (C) 2012 David Rosca +* Copyright (C) 2012 Mladen Pejaković +* +* This program is free software: you can redistribute it and/or modify +* it under the terms of the GNU General Public License as published by +* the Free Software Foundation, either version 3 of the License, or +* (at your option) any later version. +* +* This program is distributed in the hope that it will be useful, +* but WITHOUT ANY WARRANTY; without even the implied warranty of +* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +* GNU General Public License for more details. +* +* You should have received a copy of the GNU General Public License +* along with this program. If not, see . +* ============================================================ */ +#ifndef PIM_HANDLER_H +#define PIM_HANDLER_H + +#include +#include +#include +#include +#include +#include +#include + +class WebView; +class WebPage; + +class PIM_Handler : public QObject +{ + Q_OBJECT +public: + explicit PIM_Handler(const QString &sPath, QObject* parent = 0); + + void populateWebViewMenu(QMenu* menu, WebView* view, const QWebHitTestResult &hitTest); + bool keyPress(WebView* view, QKeyEvent* event); + +signals: + +public slots: + void webPageCreated(WebPage* page); + void showSettings(QWidget* parent = 0); + +private slots: + void loadSettings(); + void pimInsert(); + + void pageLoadFinished(); + +private: + enum PI_Type { + PI_LastName = 0, + PI_FirstName = 1, + PI_Email = 2, + PI_Mobile = 3, + PI_Phone = 4, + PI_Address = 5, + PI_City = 6, + PI_Zip = 7, + PI_State = 8, + PI_Country = 9, + PI_HomePage = 10, + PI_Special1 = 11, + PI_Special2 = 12, + PI_Special3 = 13, + PI_Max = 14, + PI_Invalid = 128 + }; + + PI_Type nameMatch(const QString &name); + + QHash m_allInfo; + QHash m_infoMatches; + QHash m_translations; + + QWeakPointer m_view; + QWebElement m_element; + + QString m_settingsFile; + bool m_loaded; +}; + +#endif // PIM_HANDLER_H diff --git a/src/plugins/PIM/PIM_plugin.cpp b/src/plugins/PIM/PIM_plugin.cpp new file mode 100644 index 000000000..770f33158 --- /dev/null +++ b/src/plugins/PIM/PIM_plugin.cpp @@ -0,0 +1,97 @@ +/* ============================================================ +* Personal Information Manager plugin for QupZilla +* Copyright (C) 2012 David Rosca +* Copyright (C) 2012 Mladen Pejaković +* +* This program is free software: you can redistribute it and/or modify +* it under the terms of the GNU General Public License as published by +* the Free Software Foundation, either version 3 of the License, or +* (at your option) any later version. +* +* This program is distributed in the hope that it will be useful, +* but WITHOUT ANY WARRANTY; without even the implied warranty of +* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +* GNU General Public License for more details. +* +* You should have received a copy of the GNU General Public License +* along with this program. If not, see . +* ============================================================ */ +#include "PIM_plugin.h" +#include "PIM_handler.h" +#include "PIM_settings.h" +#include "mainapplication.h" +#include "pluginproxy.h" +#include "qupzilla.h" +#include "webview.h" + +#include + +PIM_Plugin::PIM_Plugin() + : QObject() + , m_handler(0) +{ +} + +PluginSpec PIM_Plugin::pluginSpec() +{ + PluginSpec spec; + spec.name = "PIM"; + spec.info = "Personal Information Manager"; + spec.description = "Adds ability for Qupzilla to store some personal data"; + spec.version = "0.0.1"; + spec.author = QString::fromUtf8("Mladen Pejaković "); + spec.icon = QPixmap(":/PIM/data/PIM.png"); + spec.hasSettings = true; + + return spec; +} + +void PIM_Plugin::init(const QString &sPath) +{ + m_handler = new PIM_Handler(sPath, this); + + QZ_REGISTER_EVENT_HANDLER(PluginProxy::KeyPressHandler); + + connect(mApp->plugins(), SIGNAL(webPageCreated(WebPage*)), m_handler, SLOT(webPageCreated(WebPage*))); +} + +void PIM_Plugin::unload() +{ + m_handler->deleteLater(); +} + +bool PIM_Plugin::testPlugin() +{ + // Let's be sure, require latest version of QupZilla + + return (QupZilla::VERSION == "1.3.0"); +} + +QTranslator* PIM_Plugin::getTranslator(const QString &locale) +{ + QTranslator* translator = new QTranslator(); + translator->load(locale, ":/PIM/locale/"); + return translator; +} + +void PIM_Plugin::showSettings(QWidget* parent) +{ + m_handler->showSettings(parent); +} + +void PIM_Plugin::populateWebViewMenu(QMenu* menu, WebView* view, const QWebHitTestResult &r) +{ + m_handler->populateWebViewMenu(menu, view, r); +} + +bool PIM_Plugin::keyPress(const Qz::ObjectName &type, QObject* obj, QKeyEvent* event) +{ + if (type == Qz::ON_WebView) { + WebView* view = qobject_cast(obj); + return m_handler->keyPress(view, event); + } + + return false; +} + +Q_EXPORT_PLUGIN2(PIM, PIM_Plugin) diff --git a/src/plugins/PIM/PIM_plugin.h b/src/plugins/PIM/PIM_plugin.h new file mode 100644 index 000000000..dd8704c3a --- /dev/null +++ b/src/plugins/PIM/PIM_plugin.h @@ -0,0 +1,54 @@ +/* ============================================================ +* Personal Information Manager plugin for QupZilla +* Copyright (C) 2012 David Rosca +* Copyright (C) 2012 Mladen Pejaković +* +* This program is free software: you can redistribute it and/or modify +* it under the terms of the GNU General Public License as published by +* the Free Software Foundation, either version 3 of the License, or +* (at your option) any later version. +* +* This program is distributed in the hope that it will be useful, +* but WITHOUT ANY WARRANTY; without even the implied warranty of +* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +* GNU General Public License for more details. +* +* You should have received a copy of the GNU General Public License +* along with this program. If not, see . +* ============================================================ */ +#ifndef PIM_PLUGIN_H +#define PIM_PLUGIN_H + +#include "plugininterface.h" + +class WebPage; +class QupZilla; +class PIM_Handler; + +class PIM_Plugin : public QObject, public PluginInterface +{ + Q_OBJECT + Q_INTERFACES(PluginInterface) + +public: + PIM_Plugin(); + PluginSpec pluginSpec(); + + void init(const QString &sPath); + void unload(); + bool testPlugin(); + + QTranslator* getTranslator(const QString &locale); + void showSettings(QWidget* parent = 0); + + void populateWebViewMenu(QMenu* menu, WebView* view, const QWebHitTestResult &r); + bool keyPress(const Qz::ObjectName &type, QObject* obj, QKeyEvent* event); + +private slots: + void webPageCreated(WebPage* page); + +private: + PIM_Handler* m_handler; +}; + +#endif // PIM_PLUGIN_H diff --git a/src/plugins/PIM/PIM_res.qrc b/src/plugins/PIM/PIM_res.qrc new file mode 100644 index 000000000..40fde6ace --- /dev/null +++ b/src/plugins/PIM/PIM_res.qrc @@ -0,0 +1,10 @@ + + + data/PIM.png + locale/cs_CZ.qm + locale/de_DE.qm + locale/fr_FR.qm + locale/sr_BA.qm + locale/sr_RS.qm + + diff --git a/src/plugins/PIM/PIM_settings.cpp b/src/plugins/PIM/PIM_settings.cpp new file mode 100644 index 000000000..4af7d8cb8 --- /dev/null +++ b/src/plugins/PIM/PIM_settings.cpp @@ -0,0 +1,79 @@ +/* ============================================================ +* Personal Information Manager plugin for QupZilla +* Copyright (C) 2012 David Rosca +* Copyright (C) 2012 Mladen Pejaković +* +* This program is free software: you can redistribute it and/or modify +* it under the terms of the GNU General Public License as published by +* the Free Software Foundation, either version 3 of the License, or +* (at your option) any later version. +* +* This program is distributed in the hope that it will be useful, +* but WITHOUT ANY WARRANTY; without even the implied warranty of +* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +* GNU General Public License for more details. +* +* You should have received a copy of the GNU General Public License +* along with this program. If not, see . +* ============================================================ */ + +#include "PIM_settings.h" +#include "ui_PIM_settings.h" +#include "PIM_handler.h" + +#include + +PIM_Settings::PIM_Settings(const QString &settingsFile, QWidget* parent) + : QDialog(parent) + , ui(new Ui::PIM_Settings) + , m_settingsFile(settingsFile) +{ + setAttribute(Qt::WA_DeleteOnClose); + ui->setupUi(this); + + QSettings settings(m_settingsFile, QSettings::IniFormat); + settings.beginGroup("PIM"); + ui->pim_firstname->setText(settings.value("FirstName", "").toString()); + ui->pim_lastname->setText(settings.value("LastName", "").toString()); + ui->pim_email->setText(settings.value("Email", "").toString()); + ui->pim_phone->setText(settings.value("Phone", "").toString()); + ui->pim_mobile->setText(settings.value("Mobile", "").toString()); + ui->pim_address->setText(settings.value("Address", "").toString()); + ui->pim_city->setText(settings.value("City", "").toString()); + ui->pim_zip->setText(settings.value("Zip", "").toString()); + ui->pim_state->setText(settings.value("State", "").toString()); + ui->pim_country->setText(settings.value("Country", "").toString()); + ui->pim_homepage->setText(settings.value("HomePage", "").toString()); + ui->pim_special1->setText(settings.value("Special1", "").toString()); + ui->pim_special2->setText(settings.value("Special2", "").toString()); + ui->pim_special3->setText(settings.value("Special3", "").toString()); + settings.endGroup(); + + connect(this, SIGNAL(accepted()), this, SLOT(dialogAccepted())); +} + +void PIM_Settings::dialogAccepted() +{ + QSettings settings(m_settingsFile, QSettings::IniFormat); + settings.beginGroup("PIM"); + settings.setValue("FirstName", ui->pim_firstname->text()); + settings.setValue("LastName", ui->pim_lastname->text()); + settings.setValue("Email", ui->pim_email->text()); + settings.setValue("Phone", ui->pim_phone->text()); + settings.setValue("Mobile", ui->pim_mobile->text()); + settings.setValue("Address", ui->pim_address->text()); + settings.setValue("City", ui->pim_city->text()); + settings.setValue("Zip", ui->pim_zip->text()); + settings.setValue("State", ui->pim_state->text()); + settings.setValue("Country", ui->pim_country->text()); + settings.setValue("HomePage", ui->pim_homepage->text()); + settings.setValue("Special1", ui->pim_special1->text()); + settings.setValue("Special2", ui->pim_special2->text()); + settings.setValue("Special3", ui->pim_special3->text()); + settings.endGroup(); +} + +PIM_Settings::~PIM_Settings() +{ + delete ui; +} diff --git a/src/plugins/PIM/PIM_settings.h b/src/plugins/PIM/PIM_settings.h new file mode 100644 index 000000000..0cd145a6b --- /dev/null +++ b/src/plugins/PIM/PIM_settings.h @@ -0,0 +1,48 @@ +/* ============================================================ +* Personal Information Manager plugin for QupZilla +* Copyright (C) 2012 David Rosca +* Copyright (C) 2012 Mladen Pejaković +* +* This program is free software: you can redistribute it and/or modify +* it under the terms of the GNU General Public License as published by +* the Free Software Foundation, either version 3 of the License, or +* (at your option) any later version. +* +* This program is distributed in the hope that it will be useful, +* but WITHOUT ANY WARRANTY; without even the implied warranty of +* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +* GNU General Public License for more details. +* +* You should have received a copy of the GNU General Public License +* along with this program. If not, see . +* ============================================================ */ +#ifndef PIM_SETTINGS_H +#define PIM_SETTINGS_H + +#include + +namespace Ui +{ +class PIM_Settings; +} + +class PIM_Handler; + +class PIM_Settings : public QDialog +{ + Q_OBJECT + +public: + explicit PIM_Settings(const QString &settingsFile, QWidget* parent = 0); + ~PIM_Settings(); + +private slots: + void dialogAccepted(); + +private: + Ui::PIM_Settings* ui; + + QString m_settingsFile; +}; + +#endif // PIM_SETTINGS_H diff --git a/src/plugins/PIM/PIM_settings.ui b/src/plugins/PIM/PIM_settings.ui new file mode 100644 index 000000000..f24abd4db --- /dev/null +++ b/src/plugins/PIM/PIM_settings.ui @@ -0,0 +1,313 @@ + + + PIM_Settings + + + + 0 + 0 + 539 + 346 + + + + PIM Settings + + + + + + + + Qt::Horizontal + + + + 40 + 20 + + + + + + + + :/PIM/data/PIM.png + + + + + + + <h2>Personal Information Manager</h2> + + + + + + + Qt::Horizontal + + + + 40 + 20 + + + + + + + + + + Your personal information that will be used on webpages. + + + Qt::AlignCenter + + + + + + + + + Phone: + + + Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter + + + + + + + + + + Address: + + + Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter + + + + + + + Last Name: + + + Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter + + + + + + + + + + First Name: + + + Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter + + + + + + + + + + + + + Mobile Phone: + + + Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter + + + + + + + City: + + + Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter + + + + + + + + + + E-mail: + + + Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter + + + + + + + + + + + + + ZIP Code: + + + Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter + + + + + + + + + + State/Region: + + + Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter + + + + + + + + + + Country: + + + Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter + + + + + + + + + + Home Page: + + + Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter + + + + + + + + + + Custom 1: + + + Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter + + + + + + + + + + Custom 2: + + + Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter + + + + + + + + + + Custom 3: + + + Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter + + + + + + + + + + + + <b>Note:</b> Press Ctrl+ENTER to autofill form fields for which QupZilla finds personal entries. + + + + + + + Qt::Horizontal + + + QDialogButtonBox::Cancel|QDialogButtonBox::Ok + + + + + + + + + + + buttonBox + accepted() + PIM_Settings + accept() + + + 248 + 254 + + + 157 + 274 + + + + + buttonBox + rejected() + PIM_Settings + reject() + + + 316 + 260 + + + 286 + 274 + + + + + diff --git a/src/plugins/PIM/data/PIM.png b/src/plugins/PIM/data/PIM.png new file mode 100644 index 0000000000000000000000000000000000000000..46a2b279d89ee406403a2289feb03ac2d66f9a5a GIT binary patch literal 2239 zcmV;w2tfCVP)=Bj*|(nE&u9Oc`Oo>zIdjf0vnY!2SqjHzECQb*7v4I5EuHDx z({Vhz<91q(({2*#mTlK;)7&yGt0II_S5&1T%c7xaYC{!jLs3LS%IJ+WPdAPqKW?H2 zd8h>E&Ye@oCwAF8^Fthn=mSz+O>+Nv-}B&lKEj9)+`G?M1QzS~Bk_=P$+g?o#;dQq zbm6^s{_?`VuUQ+9%z&2R2Q*FNVH5%nI42!-H2^M2(1jH5086}b@I-Nd*0iE8(@e|E zn4617hEwv_0Q}~W1X#qURaH$Qjlyu-Il%DAj4;N!SK0R8gh_W5gaJI)#lnpnYiihF z!&zm%r*}XI?MaEEt2LYW)9HUeBQpIN9iuyQ7|myq&7`2|DkO@YM;sCF7N@JiAb{(; z2*WT5Vy#p%v!Xq$_DX<^KN-;G({EhC)btG0%nn#~8)eJF@@7wo+>Q(1Ya=9Q zieO0V8V34O7$3=D-^5VtJR!5ZveK_eA^*k6wQ5fUWFaQw)HhpAjP2S*YZ=jChEf_O z2nl)B#(?5tzLtg)FkHIX!1-$>4Co$$zc1nCpCkk*6CRvqRaZG%?x_vu=HAHa#!xP# z&74aB6X^I6{H|lcLLBKULsk@oof?iBt9WZ!$G>jM(9=2W7*vU*KoIyzMQq#Zpi^@t z#^-w?;CX5>Bg+VUA4Xp`aUKMOh!6s^*>(7?2hTCV!y2qR7jeLfVCdh(Kw5?$0K0b@ zhyws3lu4AJ;c&S}0-?kX(_lfXX(6Q>=y3(=YL;yU>#17Gbs>+BsPaJ6d zBghw@LtErwXd(d^!>+s%mn(T@Wog;bn44C8wKoE?B+Z1B>&i?pp-cGJP(`Yj|UYIvY-C({aQ~1sQ>p8ceE@Uik_uN zSW$%d^9R|aO!G^(cSx#`bQDRpdPngCuzZYy=iIO zbT}9DJ)MSB+i686LjWY9A_bvkA)$O_0fwd~ zC!i{GC~|}mnuL;6i*U-dNtEI#T@wV;Iyt7z%@`2>8@;6~~1V z*>G$Xp0*o0lZXJ4QLL+=3@8*x03gIhsU+pm$#}jr-_tul87P7QTeT*PbRK)NAqrz@ zn(b+f<#p^H(x4lC@YNx3y$^+bdohtRky0hdG6(m4ML$*ptMP4$3V;l8q)s&+aY=^p~)rMW)$VZ*# z?~d=i`}+Ime{4KNKt$|u&N%G0o%C?WZ9>y(7~E-LyudIx3^eKuI*u#&aBdk3AC%B( zyXcO5#J!Ur(7+i>GO$^#tc$>E20@6}ZmaEKWpN4rdGFFQderyYjf=m`JU}2~(NWjy zfO7^;1|&|9?tyVmDRt;xg9tg;J1H<&qZY{T#R#uhG%}UyJUA;e-gCZ-*P}v5P{%3tpGsd>pPP>hZ7vFZH>Icz_f4KSc z#mi@|%d-5uq3cZ7b?BOwWVN(fI&|dO@4O-?@{kOyzw`RrF9Y~3VYE;vOg(XQ=DE-9 zFB};i9iEsNA5Tpeiy#AuGX^9Y1a=>|r){SlhE6?loZtpXzV*VXKcD*5w`Zx$r-|Gc z7~p$8*4Nj}?LkB&0#YU!ut`@J78b4(&H~62b{(8LI6FBxd2I5)mWVT!`8`W09UR_=N>c0MHMhP3wICdj*bJh6~BN6z7 z#MvO#iP0s~AS_>>zy2=a_W;HSoL&l>=~OV?y-+qMv*_3o|qdbwPCsZ=Vh-MMq85s~!#&nYA6W=!c~fUt+^yYHzl zJaug9@YGace_`+Zhx6^V`3sS(=YKtMaP~~GSS*tSrfCK%D=XpR;-Wt{H|IxP#}5g7O&|Y9dLz&~A*qWXM%1I>{{r#K5?DO8{HXu{ N002ovPDHLkV1f*4C*%MC literal 0 HcmV?d00001 diff --git a/src/plugins/PIM/test.html b/src/plugins/PIM/test.html new file mode 100644 index 000000000..b5b208ff9 --- /dev/null +++ b/src/plugins/PIM/test.html @@ -0,0 +1,19 @@ + + Test + + + + +
+
+
+
+
+
+
+
+
+
+
+ + diff --git a/src/plugins/PIM/translations/cs_CZ.ts b/src/plugins/PIM/translations/cs_CZ.ts new file mode 100644 index 000000000..632947c6d --- /dev/null +++ b/src/plugins/PIM/translations/cs_CZ.ts @@ -0,0 +1,180 @@ + + + + + PIM_Handler + + + Last Name + Jméno + + + + First Name + Příjmení + + + + E-mail + E-mail + + + + Mobile + Mobilní telefon + + + + Phone + Telefon + + + + Address + Adresa + + + + City + Město + + + + ZIP Code + PSČ + + + + State/Region + Oblast/Stát + + + + Country + Země + + + + Home Page + Domovská stránka + + + + Custom 1 + Vlastní 1 + + + + Custom 2 + Vlastní 2 + + + + Custom 3 + Vlastní 3 + + + + Insert Personal Information + Vložit osobní údaj + + + + Edit + Upravit + + + + PIM_Settings + + + PIM Settings + PIM Nastavení + + + + <h2>Personal Information Manager</h2> + <h2>Správce osobních údajů</h2> + + + + Your personal information that will be used on webpages. + Vaše osobní údaje které budou použity na stránkách. + + + + Phone: + Telefon: + + + + Address: + Adresa: + + + + Last Name: + Jméno: + + + + First Name: + Příjmení: + + + + Mobile Phone: + Mobilní telefon: + + + + City: + Město: + + + + E-mail: + E-mail: + + + + ZIP Code: + PSČ: + + + + State/Region: + Oblast/Stát: + + + + Country: + Země: + + + + Home Page: + Domovská stránka: + + + + Custom 1: + Vlastní 1: + + + + Custom 2: + Vlastní 2: + + + + Custom 3: + Vlastní 3: + + + + <b>Note:</b> Press Ctrl+ENTER to autofill form fields for which QupZilla finds personal entries. + <b>Poznámka:</b> Ctrl+ENTER slouží k automatickému vyplnění známých polí na stránce. + + + diff --git a/src/plugins/PIM/translations/de_DE.ts b/src/plugins/PIM/translations/de_DE.ts new file mode 100644 index 000000000..9c74543d8 --- /dev/null +++ b/src/plugins/PIM/translations/de_DE.ts @@ -0,0 +1,180 @@ + + + + + PIM_Handler + + + First Name + Vorname + + + + Last Name + Nachname + + + + E-mail + E-Mail + + + + Phone + Telefon + + + + Mobile + Mobiltelefon + + + + Address + Adresse + + + + City + Stadt + + + + ZIP Code + + + + + State/Region + Bundesland/ Region + + + + Country + Land + + + + Home Page + Homepage + + + + Custom 1 + Benutzerdefiniert 3: {1?} + + + + Custom 2 + Benutzerdefiniert 3: {2?} + + + + Custom 3 + Benutzerdefiniert 3: {3?} + + + + Insert Personal Information + + + + + Edit + Bearbeiten + + + + PIM_Settings + + + PIM Settings + PIM Einstellungen + + + + First Name: + Vorname: + + + + Last Name: + Nachname: + + + + Phone: + Telefon: + + + + Mobile Phone: + Mobiltelefon: + + + + Address: + Adresse: + + + + <h2>Personal Information Manager</h2> + + + + + Your personal information that will be used on webpages. + + + + + City: + Stadt: + + + + E-mail: + + + + + ZIP Code: + Postleitzahl: + + + + State/Region: + Bundesland/ Region: + + + + Country: + Land: + + + + Home Page: + Homepage: + + + + Custom 1: + Benutzerdefiniert 1: + + + + Custom 2: + Benutzerdefiniert 2: + + + + Custom 3: + Benutzerdefiniert 3: + + + + <b>Note:</b> Press Ctrl+ENTER to autofill form fields for which QupZilla finds personal entries. + <b>Note:</b> Drücken Sie STRG+ENTER um die Formularfelder automatisch ausfüllen zu lassen. + + + diff --git a/src/plugins/PIM/translations/fr_FR.ts b/src/plugins/PIM/translations/fr_FR.ts new file mode 100644 index 000000000..b1cd5676a --- /dev/null +++ b/src/plugins/PIM/translations/fr_FR.ts @@ -0,0 +1,180 @@ + + + + + PIM_Handler + + + Last Name + Nom + + + + First Name + Prénom + + + + E-mail + E-mail + + + + Mobile + Téléphone mobile + + + + Phone + Téléphone fixe + + + + Address + Adresse + + + + City + Ville + + + + ZIP Code + Code postal + + + + State/Region + Région + + + + Country + Pays + + + + Home Page + Site Web + + + + Custom 1 + Informations complémentaires 1 + + + + Custom 2 + Informations complémentaires 2 + + + + Custom 3 + Informations complémentaires 3 + + + + Insert Personal Information + Insérer vos informations personnelles + + + + Edit + Modifier + + + + PIM_Settings + + + PIM Settings + Paramétres PIM + + + + <h2>Personal Information Manager</h2> + <h2>Gestionnaire d'informations personnelles (PIM)</h2> + + + + Your personal information that will be used on webpages. + Vos informations personnelles pouvant être utilisées dans les pages Web. + + + + Phone: + Téléphone : + + + + Address: + Adresse : + + + + Last Name: + Nom : + + + + First Name: + Prénom : + + + + Mobile Phone: + Téléphone mobile : + + + + City: + Ville : + + + + E-mail: + E-mail : + + + + ZIP Code: + Code postal : + + + + State/Region: + Région : + + + + Country: + Pays : + + + + Home Page: + Site Web : + + + + Custom 1: + Informations complémentaires 1 : + + + + Custom 2: + Informations complémentaires 2 : + + + + Custom 3: + Informations complémentaires 3 : + + + + <b>Note:</b> Press Ctrl+ENTER to autofill form fields for which QupZilla finds personal entries. + <b>Note:</b> Appuyer sur Ctrl+ENTER pour autocompléter les champs dont QupZilla dispose.d'informations. + + + diff --git a/src/plugins/PIM/translations/sr_BA.ts b/src/plugins/PIM/translations/sr_BA.ts new file mode 100644 index 000000000..cb97f933f --- /dev/null +++ b/src/plugins/PIM/translations/sr_BA.ts @@ -0,0 +1,180 @@ + + + + + PIM_Handler + + + First Name + Име + + + + Last Name + Презиме + + + + E-mail + Е-адресу + + + + Phone + Бр. телефона + + + + Mobile + Бр. мобилног + + + + Address + Адресу + + + + City + Град + + + + ZIP Code + Пошт. број + + + + State/Region + Сав. држ./регију + + + + Country + Државу + + + + Home Page + Домаћу страницу + + + + Custom 1 + Посебно 1 + + + + Custom 2 + Посебно 2 + + + + Custom 3 + Посебно 3 + + + + Insert Personal Information + Уметни лични податак + + + + Edit + Уреди + + + + PIM_Settings + + + PIM Settings + ПИМ подешавања + + + + First Name: + Име: + + + + Last Name: + Презиме: + + + + Phone: + Број телефона: + + + + Mobile Phone: + Број мобилног тел: + + + + Address: + Адреса: + + + + <h2>Personal Information Manager</h2> + <h2>Менаџер личних података</h2> + + + + Your personal information that will be used on webpages. + Ваши лични подаци које можете да користите на веб страницама. + + + + City: + Град: + + + + E-mail: + Е-адреса: + + + + ZIP Code: + Поштански број: + + + + State/Region: + Савезна држ./регија: + + + + Country: + Држава: + + + + Home Page: + Домаћа страница: + + + + Custom 1: + Посебно 1: + + + + Custom 2: + Посебно 2: + + + + Custom 3: + Посебно 3: + + + + <b>Note:</b> Press Ctrl+ENTER to autofill form fields for which QupZilla finds personal entries. + <b>Напомена:</b> Притисните Ctrl+ENTER да бисте аутоматски попунили поља за која Капзила пронађе личне податке. + + + diff --git a/src/plugins/PIM/translations/sr_RS.ts b/src/plugins/PIM/translations/sr_RS.ts new file mode 100644 index 000000000..49d1bbdc9 --- /dev/null +++ b/src/plugins/PIM/translations/sr_RS.ts @@ -0,0 +1,180 @@ + + + + + PIM_Handler + + + First Name + Име + + + + Last Name + Презиме + + + + E-mail + Е-адресу + + + + Phone + Бр. телефона + + + + Mobile + Бр. мобилног + + + + Address + Адресу + + + + City + Град + + + + ZIP Code + Пошт. број + + + + State/Region + Сав. држ./регију + + + + Country + Државу + + + + Home Page + Домаћу страницу + + + + Custom 1 + Посебно 1 + + + + Custom 2 + Посебно 2 + + + + Custom 3 + Посебно 3 + + + + Insert Personal Information + Уметни лични податак + + + + Edit + Уреди + + + + PIM_Settings + + + PIM Settings + ПИМ подешавања + + + + First Name: + Име: + + + + Last Name: + Презиме: + + + + Phone: + Број телефона: + + + + Mobile Phone: + Број мобилног тел: + + + + Address: + Адреса: + + + + <h2>Personal Information Manager</h2> + <h2>Менаџер личних података</h2> + + + + Your personal information that will be used on webpages. + Ваши лични подаци које можете да користите на веб страницама. + + + + City: + Град: + + + + E-mail: + Е-адреса: + + + + ZIP Code: + Пошт. број: + + + + State/Region: + Савезна држ./регија: + + + + Country: + Држава: + + + + Home Page: + Домаћа страница: + + + + Custom 1: + Посебно 1: + + + + Custom 2: + Посебно 2: + + + + Custom 3: + Посебно 3: + + + + <b>Note:</b> Press Ctrl+ENTER to autofill form fields for which QupZilla finds personal entries. + <b>Напомена:</b> Притисните Ctrl+ENTER да бисте аутоматски попунили поља за која Капзила пронађе личне податке. + + + diff --git a/src/plugins/PIM/translations/zh_TW.ts b/src/plugins/PIM/translations/zh_TW.ts new file mode 100644 index 000000000..8aacd44d8 --- /dev/null +++ b/src/plugins/PIM/translations/zh_TW.ts @@ -0,0 +1,180 @@ + + + + + PIM_Handler + + + First Name + 名字 + + + + Last Name + 姓氏 + + + + E-mail + 電子郵件 + + + + Phone + 電話 + + + + ZIP Code + + + + + Custom 1 + 自訂 3: {1?} + + + + Custom 2 + 自訂 3: {2?} + + + + Custom 3 + 自訂 3: {3?} + + + + Insert Personal Information + + + + + Mobile + 手機 + + + + Address + 住址 + + + + City + 城市 + + + + State/Region + 州 / 區域 + + + + Country + 國家 + + + + Home Page + 首頁 + + + + Edit + 編輯 + + + + PIM_Settings + + + PIM Settings + PIM 設定 + + + + First Name: + 名字: + + + + Last Name: + 姓氏: + + + + Phone: + 電話: + + + + Mobile Phone: + 手機: + + + + Address: + 住址: + + + + <h2>Personal Information Manager</h2> + + + + + Your personal information that will be used on webpages. + + + + + City: + 城市: + + + + E-mail: + + + + + ZIP Code: + 郵遞區號: + + + + State/Region: + 州 / 區域: + + + + Country: + 國家: + + + + Home Page: + 首頁: + + + + Custom 1: + 自訂 1: + + + + Custom 2: + 自訂 2: + + + + Custom 3: + 自訂 3: + + + + <b>Note:</b> Press Ctrl+ENTER to autofill form fields for which QupZilla finds personal entries. + <b>附註:</b> 按下 Ctrl+Enter,QupZilla會為您從發現的個人條目中自動填入表單欄位。 + + + diff --git a/src/plugins/TestPlugin/testplugin.cpp b/src/plugins/TestPlugin/testplugin.cpp index 26461bb5f..129430d8c 100644 --- a/src/plugins/TestPlugin/testplugin.cpp +++ b/src/plugins/TestPlugin/testplugin.cpp @@ -89,7 +89,7 @@ bool TestPlugin::testPlugin() //There should be some testing if plugin is loaded correctly //If this function returns false, plugin is automatically unloaded - return (QupZilla::VERSION == "1.2.0"); + return (QupZilla::VERSION == "1.3.0"); } QTranslator* TestPlugin::getTranslator(const QString &locale)