diff options
Diffstat (limited to 'konq-plugins/tdehtmlsettingsplugin')
6 files changed, 565 insertions, 0 deletions
diff --git a/konq-plugins/tdehtmlsettingsplugin/Makefile.am b/konq-plugins/tdehtmlsettingsplugin/Makefile.am new file mode 100644 index 0000000..6647c14 --- /dev/null +++ b/konq-plugins/tdehtmlsettingsplugin/Makefile.am @@ -0,0 +1,18 @@ +INCLUDES = $(all_includes) + +kde_module_LTLIBRARIES = libtdehtmlsettingsplugin.la + +libtdehtmlsettingsplugin_la_SOURCES = settingsplugin.cpp +libtdehtmlsettingsplugin_la_LIBADD = $(LIB_KHTML) +libtdehtmlsettingsplugin_la_LDFLAGS = $(all_libraries) -module $(KDE_PLUGIN) + +pluginsdir = $(kde_datadir)/tdehtml/kpartplugins +plugins_DATA = tdehtmlsettingsplugin.rc tdehtmlsettingsplugin.desktop + +appsdir = $(kde_appsdir)/.hidden +apps_DATA = tdehtmlsettingsplugin.desktop + +METASOURCES = AUTO + +messages: rc.cpp + $(XGETTEXT) *.cpp *.h -o $(podir)/tdehtmlsettingsplugin.pot diff --git a/konq-plugins/tdehtmlsettingsplugin/settingsplugin.cpp b/konq-plugins/tdehtmlsettingsplugin/settingsplugin.cpp new file mode 100644 index 0000000..05619ed --- /dev/null +++ b/konq-plugins/tdehtmlsettingsplugin/settingsplugin.cpp @@ -0,0 +1,328 @@ +/* This file is part of the KDE project + Copyright (C) 2001 Carsten Pfeiffer <pfeiffer@kde.org> + + 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 2 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; see the file COPYING. If not, write to + the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, + Boston, MA 02110-1301, USA. +*/ + +#include <dcopclient.h> + +#include <kapplication.h> +#include <kaction.h> +#include <kconfig.h> +#include <kglobal.h> +#include <tdehtml_part.h> +#include <kinstance.h> +#include <klocale.h> +#include <kmessagebox.h> +#include <kpopupmenu.h> +#include <kprotocolmanager.h> +#include <kgenericfactory.h> +#include <kaboutdata.h> + +#include "settingsplugin.h" + +typedef KGenericFactory<SettingsPlugin> SettingsPluginFactory; +static const TDEAboutData aboutdata("tdehtmlsettingsplugin", I18N_NOOP("HTML Settings") , "1.0" ); +K_EXPORT_COMPONENT_FACTORY( libtdehtmlsettingsplugin, + SettingsPluginFactory( &aboutdata ) ) + +SettingsPlugin::SettingsPlugin( TQObject* parent, const char* name, + const TQStringList & ) + : KParts::Plugin( parent, name ), mConfig(0) +{ + + setInstance(SettingsPluginFactory::instance()); + + if ( !kapp->dcopClient()->isAttached() ) + kapp->dcopClient()->attach(); + + KActionMenu *menu = new KActionMenu( i18n("HTML Settings"), "configure", + actionCollection(), "action menu" ); + menu->setDelayed( false ); + + KToggleAction *action; + + + action = new KToggleAction( i18n("Java&Script"), 0, + this, TQT_SLOT(toggleJavascript()), + actionCollection(), "javascript" ); + menu->insert( action ); + + action = new KToggleAction( i18n("&Java"), 0, + this, TQT_SLOT(toggleJava()), + actionCollection(), "java" ); + menu->insert( action ); + + action = new KToggleAction( i18n("&Cookies"), 0, + this, TQT_SLOT(toggleCookies()), + actionCollection(), "cookies" ); + menu->insert( action ); + + action = new KToggleAction( i18n("&Plugins"), 0, + this, TQT_SLOT(togglePlugins()), + actionCollection(), "plugins" ); + menu->insert( action ); + + action = new KToggleAction( i18n("Autoload &Images"), 0, + this, TQT_SLOT(toggleImageLoading()), + actionCollection(), "imageloading" ); + menu->insert( action ); + + menu->insert( new KActionSeparator(actionCollection()) ); + + action = new KToggleAction( i18n("Enable Pro&xy"), 0, + this, TQT_SLOT(toggleProxy()), + actionCollection(), "useproxy" ); + action->setCheckedState(i18n("Disable Pro&xy")); + menu->insert( action ); + + action = new KToggleAction( i18n("Enable Cac&he"), 0, + this, TQT_SLOT(toggleCache()), + actionCollection(), "usecache" ); + action->setCheckedState(i18n("Disable Cac&he")); + menu->insert( action ); + + + KSelectAction *sAction = new KSelectAction( i18n("Cache Po&licy"), 0, + 0, 0, actionCollection(), + "cachepolicy" ); + TQStringList policies; + policies += i18n( "&Keep Cache in Sync" ); + policies += i18n( "&Use Cache if Possible" ); + policies += i18n( "&Offline Browsing Mode" ); + sAction->setItems( policies ); + connect( sAction, TQT_SIGNAL( activated( int ) ), TQT_SLOT( cachePolicyChanged(int) ) ); + + menu->insert( sAction ); + + connect( menu->popupMenu(), TQT_SIGNAL( aboutToShow() ), TQT_SLOT( showPopup() )); +} + +SettingsPlugin::~SettingsPlugin() +{ + delete mConfig; +} + +void SettingsPlugin::showPopup() +{ + if( !parent() || !parent()->inherits("KHTMLPart")) + return; + + if (!mConfig) + mConfig = new TDEConfig("settingspluginrc", false, false); + + KHTMLPart *part = static_cast<KHTMLPart *>( parent() ); + + KProtocolManager::reparseConfiguration(); + bool cookies = cookiesEnabled( part->url().url() ); + + ((KToggleAction*)actionCollection()->action("useproxy"))->setChecked(KProtocolManager::useProxy()); + ((KToggleAction*)actionCollection()->action("java"))->setChecked( part->javaEnabled() ); + ((KToggleAction*)actionCollection()->action("javascript"))->setChecked( part->jScriptEnabled() ); + ((KToggleAction*)actionCollection()->action("cookies"))->setChecked( cookies ); + ((KToggleAction*)actionCollection()->action("plugins"))->setChecked( part->pluginsEnabled() ); + ((KToggleAction*)actionCollection()->action("imageloading"))->setChecked( part->autoloadImages() ); + ((KToggleAction*)actionCollection()->action("usecache"))->setChecked(KProtocolManager::useCache()); + + TDEIO::CacheControl cc = KProtocolManager::cacheControl(); + switch ( cc ) + { + case TDEIO::CC_Verify: + ((KSelectAction*)actionCollection()->action("cachepolicy"))->setCurrentItem( 0 ); + break; + case TDEIO::CC_CacheOnly: + ((KSelectAction*)actionCollection()->action("cachepolicy"))->setCurrentItem( 2 ); + break; + case TDEIO::CC_Cache: + ((KSelectAction*)actionCollection()->action("cachepolicy"))->setCurrentItem( 1 ); + break; + case TDEIO::CC_Reload: // nothing for now + case TDEIO::CC_Refresh: + default: + break; + + } +} + +void SettingsPlugin::toggleJava() +{ + if( parent() && parent()->inherits("KHTMLPart")) + { + KHTMLPart *part = static_cast<KHTMLPart *>(parent()); + part->setJavaEnabled( ((KToggleAction*)actionCollection()->action("java"))->isChecked() ); + } +} + +void SettingsPlugin::toggleJavascript() +{ + if( parent() && parent()->inherits("KHTMLPart")) + { + KHTMLPart *part = static_cast<KHTMLPart *>(parent()); + part->setJScriptEnabled( ((KToggleAction*)actionCollection()->action("javascript"))->isChecked() ); + } +} + +void SettingsPlugin::toggleCookies() +{ + if( !parent() || !parent()->inherits("KHTMLPart")) + return; + + KHTMLPart *part = static_cast<KHTMLPart *>( parent() ); + + TQString advice; + bool enable = ((KToggleAction*)actionCollection()->action("cookies"))->isChecked(); + advice = enable ? "Accept" : "Reject"; + + TQCString replyType; + TQByteArray data, replyData; + TQDataStream stream( data, IO_WriteOnly ); + stream << part->url().url() << advice; + bool ok = kapp->dcopClient()->call( "kded", "kcookiejar", + "setDomainAdvice(TQString,TQString)", + data, replyType, replyData, true ); + + if ( !ok ) + KMessageBox::sorry( part->widget(), + i18n("I can't enable cookies, because the " + "cookie daemon could not be started."), + i18n("Cookies Disabled")); +} + +void SettingsPlugin::togglePlugins() +{ + if( parent() && parent()->inherits("KHTMLPart")) + { + KHTMLPart *part = static_cast<KHTMLPart *>(parent()); + part->setPluginsEnabled( ((KToggleAction*)actionCollection()->action("plugins"))->isChecked() ); + } +} + +void SettingsPlugin::toggleImageLoading() +{ + if( parent() && parent()->inherits("KHTMLPart")) + { + KHTMLPart *part = static_cast<KHTMLPart *>(parent()); + part->setAutoloadImages( ((KToggleAction*)actionCollection()->action("imageloading"))->isChecked() ); + } +} + +bool SettingsPlugin::cookiesEnabled( const TQString& url ) +{ + TQByteArray data, reply; + TQCString replyType; + TQDataStream stream( data, IO_WriteOnly ); + stream << url; + kapp->dcopClient()->call( "kcookiejar", "kcookiejar", "getDomainAdvice(TQString)", data, replyType, reply, true ); + + bool enabled = false; + + if ( replyType == TQSTRING_OBJECT_NAME_STRING ) + { + TQString advice; + TQDataStream s( reply, IO_ReadOnly ); + s >> advice; + enabled = ( advice == "Accept" ); + if ( !enabled && advice == "Dunno" ) { + // TODO, check the global setting via dcop + TDEConfig kc( "kcookiejarrc", true, false ); + kc.setGroup( "Cookie Policy" ); + enabled = + (kc.readEntry( "CookieGlobalAdvice", "Reject" ) == "Accept"); + } + } + + return enabled; +} + + +// +// sync with kcontrol/kio/ksaveioconfig.* ! +// + +void SettingsPlugin::toggleProxy() +{ + bool enable = ((KToggleAction*)actionCollection()->action("useproxy"))->isChecked(); + + int type; + + if( enable ) + type = mConfig->readNumEntry( "SavedProxyType", KProtocolManager::ManualProxy ); + else + { + mConfig->writeEntry( "SavedProxyType", KProtocolManager::proxyType() ); + type = KProtocolManager::NoProxy; + } + + TDEConfig config("kioslaverc", false, false); + config.setGroup( "Proxy Settings" ); + config.writeEntry( "ProxyType", type ); + + ((KToggleAction*)actionCollection()->action("useproxy"))->setChecked(enable); + updateIOSlaves(); +} + + +void SettingsPlugin::toggleCache() +{ + bool usesCache = KProtocolManager::useCache(); + TDEConfig config( "kio_httprc", false, false ); + config.writeEntry( "UseCache", !usesCache ); + + ((KToggleAction*)actionCollection()->action("usecache"))->setChecked( !usesCache ); + + updateIOSlaves(); +} + +void SettingsPlugin::cachePolicyChanged( int p ) +{ + TQString policy; + + switch ( p ) { + case 0: + policy = TDEIO::getCacheControlString( TDEIO::CC_Verify ); + break; + case 1: + policy = TDEIO::getCacheControlString( TDEIO::CC_Cache ); + break; + case 2: + policy = TDEIO::getCacheControlString( TDEIO::CC_CacheOnly ); + break; + }; + + if ( !policy.isEmpty() ) { + TDEConfig config("kio_httprc", false, false); + config.writeEntry("cache", policy); + + updateIOSlaves(); + } +} + +void SettingsPlugin::updateIOSlaves() +{ + TQByteArray data; + TQDataStream stream( data, IO_WriteOnly ); + + DCOPClient* client = kapp->dcopClient(); + if ( !client->isAttached() ) + client->attach(); + + TQString protocol; // null -> all of them + stream << protocol; + client->send( "*", "TDEIO::Scheduler", + "reparseSlaveConfiguration(TQString)", data ); +} + +#include "settingsplugin.moc" diff --git a/konq-plugins/tdehtmlsettingsplugin/settingsplugin.h b/konq-plugins/tdehtmlsettingsplugin/settingsplugin.h new file mode 100644 index 0000000..68d40a8 --- /dev/null +++ b/konq-plugins/tdehtmlsettingsplugin/settingsplugin.h @@ -0,0 +1,57 @@ +/* This file is part of the KDE project + Copyright (C) 2001 Carsten Pfeiffer <pfeiffer@kde.org> + + 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 2 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; see the file COPYING. If not, write to + the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, + Boston, MA 02110-1301, USA. +*/ + +#ifndef SETTINGS_PLUGIN +#define SETTINGS_PLUGIN + +#include <tdeparts/plugin.h> +#include <klibloader.h> + +class TDEConfig; + +class SettingsPlugin : public KParts::Plugin +{ + Q_OBJECT + +public: + SettingsPlugin( TQObject* parent, const char* name, + const TQStringList & ); + virtual ~SettingsPlugin(); + +private: + bool cookiesEnabled( const TQString& url ); + void updateIOSlaves(); + +private slots: + void toggleJavascript(); + void toggleJava(); + void toggleCookies(); + void togglePlugins(); + void toggleImageLoading(); + void toggleProxy(); + void toggleCache(); + void cachePolicyChanged( int p ); + + void showPopup(); + +private: + TDEConfig* mConfig; +}; + +#endif // SETTINGS_PLUGIN diff --git a/konq-plugins/tdehtmlsettingsplugin/tdehtmlsettingsplugin.desktop b/konq-plugins/tdehtmlsettingsplugin/tdehtmlsettingsplugin.desktop new file mode 100644 index 0000000..c6af847 --- /dev/null +++ b/konq-plugins/tdehtmlsettingsplugin/tdehtmlsettingsplugin.desktop @@ -0,0 +1,136 @@ +[Desktop Entry] +X-TDE-Library=tdehtmlsettingsplugin +X-TDE-PluginInfo-Author=Carsten Pfeiffer +X-TDE-PluginInfo-Email=pfeiffer@kde.org +X-TDE-PluginInfo-Name=tdehtmlsettingsplugin +X-TDE-PluginInfo-Version=3.3 +X-TDE-PluginInfo-Website= +X-TDE-PluginInfo-Category=Tools +X-TDE-PluginInfo-Depends= +X-TDE-PluginInfo-License=GPL +X-TDE-PluginInfo-EnabledByDefault=true +Name=KHTML Settings +Name[af]=Khtml Instellings +Name[ar]=اعدادات KHTML +Name[az]=KHTML Qurğuları +Name[bg]=Настройки на KHTML +Name[br]=Dibarzhoù KHTML +Name[bs]=KHTML postavke +Name[ca]=Preferències KHTML +Name[cs]=Nastavení KHTML +Name[cy]=Gosodiadau KHTML +Name[da]=KHTML-opsætning +Name[de]=KHTML-Einstellungen +Name[el]=Ρυθμίσεις KHTML +Name[eo]=KHTML-agordo +Name[es]=Preferencias de KHTML +Name[et]=KHTML seadistused +Name[eu]=KHTMLren ezarpenak +Name[fa]=تنظیمات KHTML +Name[fi]=KHTML-asetukset +Name[fo]=KHTML-uppseting +Name[fr]=Réglages KHTML +Name[fy]=KHTML-ynstellingen +Name[ga]=Socruithe KHTML +Name[gl]=Configuración de KHTML +Name[he]=הגדרות KHTML +Name[hi]=के-एचटीएमएल विन्यास +Name[hr]=KHTML postavke +Name[hu]=KHTML-beállítások +Name[it]=Impostazioni KHTML +Name[ja]=KHTML 設定 +Name[ka]=KHTML პარამეტრები +Name[kk]=KHTML параметрлері +Name[km]=ការកំណត់ KHTML +Name[lt]=KHTML nustatymai +Name[mk]=Поставувања за KHTML +Name[ms]=Seting KHTML +Name[nb]=KHTML-innstillinger +Name[nds]=KHTML-Instellen +Name[ne]=केएचटीएमएल सेटिङ +Name[nl]=KHTML-instellingen +Name[nn]=KHTML-innstillingar +Name[pa]=KHTML ਸਥਾਪਨ +Name[pl]=Ustawienia KHTML +Name[pt]=Configuração do KHTML +Name[pt_BR]=Configurações KHTML +Name[ro]=Setări KHTML +Name[ru]=Параметры KHTML +Name[sk]=KHTML nastavenia +Name[sl]=Nastavitve KHTML +Name[sr]=Подешавања KHTML-а +Name[sr@Latn]=Podešavanja KHTML-a +Name[sv]=KHTML-inställningar +Name[ta]=KHTML அமைப்புகள் +Name[tg]=Танзимотҳои KHTML +Name[tr]=KHTML Ayarları +Name[uk]=Параметри KHTML +Name[uz]=KHTML moslamalari +Name[uz@cyrillic]=KHTML мосламалари +Name[vi]=Thiết lập KHTML +Name[xh]=Ucwangciso lwe KHTML +Name[zh_CN]=KHTML 设置 +Name[zh_TW]=KHTML 設定 +Comment=Fast way to change the KHTML settings +Comment[af]=Vinnige weg na verander die Khtml instellings +Comment[ar]=طريقة سهلة لتغيير اعدادات KHTML +Comment[az]=KHTML qurğularını dəyişdirmənin sür'ətli yolu +Comment[bg]=Бърз начин да се променят някои от най-важните настройки на KHTML +Comment[bs]=Brz način za mijenjanje KHTML postavki +Comment[ca]=Per a canviar ràpidament les preferències de KHTML +Comment[cs]=Rychlé přepínání nastavení KHTML +Comment[cy]=Ffordd cyflym o newid y gosodiadau KHTML +Comment[da]=Hurtig måde at ændre KHTML-opsætningen på +Comment[de]=Schnelle Möglichkeiten zur Änderung der KHTML-Einstellungen +Comment[el]=Γρήγορος τρόπος αλλαγής των ρυθμίσεων του KHTML +Comment[eo]=Rapida kielo por ŝanĝi la KHTML-agordon +Comment[es]=Una forma rápida de cambiar las preferencias de KHTML +Comment[et]=Kiirmeetod muuta KHTML seadistusi +Comment[eu]=KHTMLren ezarpenak aldatzeko bide azkarra +Comment[fa]=روش سریع تغییر تنظیمات KHTML +Comment[fi]=Nopea tapa muuttaa KHTML asetuksia +Comment[fo]=Snarvegur uppsetingin av KHTML +Comment[fr]=Méthode rapide pour configurer les réglages KHTML +Comment[fy]=Snelle manier om de ynstellingen fan KHTML te wizigjen +Comment[gl]=Unha forma rápida de alterar a configuración de KHTML +Comment[he]=דרך מהירה לשנות את ההגדרות של KHTML +Comment[hi]=के-एचटीएमएल विन्यास बदलने का तेज तरीका +Comment[hr]=Brz način izmjene KHTML postavki +Comment[hu]=A KHTML objektum beállításai +Comment[is]=Fljótvirk leið til að stilla KHTML +Comment[it]=Modo veloce per cambiare le impostazioni KHTML +Comment[ja]=KHTML 設定を素早く変更します +Comment[ka]=KHTML პარამეტრების შეცვლის სწრაფი გზა +Comment[kk]=KHTML параметрлерін шұғыл өзгертудің жолы +Comment[km]=វិធីដ៏រហ័សដើម្បីផ្លាស់ប្ដូរការកំណត់ KHTML +Comment[lt]=Greitas būdas KHTML parinktims pakeisti +Comment[mk]=Брз начин за промена на поставувањата за KHTML +Comment[ms]=Cara pantas untuk mengubah seting KHTML +Comment[nb]=Rask måte å endre KHTML-innstillinger +Comment[nds]=De KHTML-Instellen gau ännern +Comment[ne]=केएचटीएमएल सेटिङ परिवर्तन गर्ने छिटो तरिका +Comment[nl]=Snelle manier om de instellingen van KHTML te wijzigen +Comment[nn]=Ein rask måte å endra KHTML-innstillingane +Comment[pl]=Szybka zmiana ustawień KHTML +Comment[pt]=Uma forma rápida de alterar a configuração do KHTML +Comment[pt_BR]=Modo rápido de mudar as configurações do KHTML +Comment[ro]=Configurează rapid şi uşor setările KHTML +Comment[ru]=Быстрое изменение параметров KHTML +Comment[sk]=Rýchla cesta ako zmeniť nastavenia KHTML +Comment[sl]=Hiter način za spreminjanje nastavitev KHTML +Comment[sr]=Брз начин за промену подешавања KHTML-а +Comment[sr@Latn]=Brz način za promenu podešavanja KHTML-a +Comment[sv]=Snabbt sätt att ändra KHTML-inställningarna +Comment[ta]=KHTML அமைப்புகளை மாற்றுவதற்கான விரைவான வழி +Comment[tg]=Тағйирёбии тези танзимотҳои KHTML +Comment[tr]=KHTML ayarlarını değiştirmek için hızlı bir yol +Comment[uk]=Швидкий шлях змінити параметри KHTML +Comment[uz]=KHTML moslamalarini tez oʻzgartirish yoʻli +Comment[uz@cyrillic]=KHTML мосламаларини тез ўзгартириш йўли +Comment[vi]=Cách thay đổi nhanh thiết lập KHTML +Comment[xh]=Indlela ekhawulezayo yokutshintsha ucwangciso lwe KHTML +Comment[zh_CN]=改变 KHTML 设置的快速方式 +Comment[zh_TW]=快速變更 KHTML 設定的方法 +X-TDE-ParentApp=konqueror +Icon=configure +DocPath=konq-plugins/tdehtmlsettings/index.html diff --git a/konq-plugins/tdehtmlsettingsplugin/tdehtmlsettingsplugin.lsm b/konq-plugins/tdehtmlsettingsplugin/tdehtmlsettingsplugin.lsm new file mode 100644 index 0000000..59dc147 --- /dev/null +++ b/konq-plugins/tdehtmlsettingsplugin/tdehtmlsettingsplugin.lsm @@ -0,0 +1,15 @@ +Begin4 +Title: KHTMLSettingsPlugin +Version: R14.0.0 +Entered-date: 2010-05-10 +Description: Puts a button with a dropdown menu with settings for Java, Javascript, Cookies + and Image-loading into Konqueror's Extra-Toolbar for the Trinity Desktop Environment +Keywords: TDE Qt +Author: Carsten Pfeiffer <pfeiffer@kde.org> +Maintained-by: The Trinity Desktop Environment (TDE) http://www.trinitydesktop.org/ +Primary-site: http://git.trinitydesktop.org/cgit/ +Alternate-site: +Original-site: http://www.kde.org/ +Platforms: Linux and other Unices running TDE +Copying-policy: GPL +End diff --git a/konq-plugins/tdehtmlsettingsplugin/tdehtmlsettingsplugin.rc b/konq-plugins/tdehtmlsettingsplugin/tdehtmlsettingsplugin.rc new file mode 100644 index 0000000..b747440 --- /dev/null +++ b/konq-plugins/tdehtmlsettingsplugin/tdehtmlsettingsplugin.rc @@ -0,0 +1,11 @@ +<!DOCTYPE kpartgui> +<kpartplugin name="tdehtmlsettingsplugin" library="libtdehtmlsettingsplugin" version="3"> +<MenuBar> + <Menu name="tools"><Text>&Tools</Text> + <Action name="action menu"/> + </Menu> +</MenuBar> +<ToolBar name="extraToolBar"><text>Extra Toolbar</text> + <Action name="action menu"/> +</ToolBar> +</kpartplugin> |