[prev in list] [next in list] [prev in thread] [next in thread]
List: kde-commits
Subject: [kde-baseapps] konqueror/settings/kio: - Renamed policydlg.* to
From: Dawit Alemayehu <adawit () kde ! org>
Date: 2011-09-15 17:33:23
Message-ID: 20110915173323.A8021A607A () git ! kde ! org
[Download RAW message or body]
Git commit c5012ab5c40d9cae3f7232f68016073b6e82331c by Dawit Alemayehu.
Committed on 15/09/2011 at 19:20.
Pushed by adawit into branch 'master'.
- Renamed policydlg.* to kcookiespolicyselectiondlg.*
- Reformatted code to adhere to kde coding style.
- Cleaned up code.
M +14 -5 konqueror/settings/kio/CMakeLists.txt
M +47 -48 konqueror/settings/kio/kcookiesmain.cpp
M +2 -2 konqueror/settings/kio/kcookiesmanagement.h
R +2 -2 konqueror/settings/kio/kcookiesmanagement.ui [from: \
konqueror/settings/kio/kcookiesmanagementdlg.ui - 098% similarity] M +7 -3 \
konqueror/settings/kio/kcookiespolicies.cpp M +4 -3 \
konqueror/settings/kio/kcookiespolicies.h R +2 -2 \
konqueror/settings/kio/kcookiespolicies.ui [from: \
konqueror/settings/kio/kcookiespoliciesdlg.ui - 099% similarity] A +108 -0 \
konqueror/settings/kio/kcookiespolicyselectiondlg.cpp [License: Public Domain GPL \
(v2+)] A +80 -0 konqueror/settings/kio/kcookiespolicyselectiondlg.h \
[License: GPL (v2+)] A +110 -0 \
konqueror/settings/kio/kcookiespolicyselectiondlg.ui D +0 -114 \
konqueror/settings/kio/policydlg.cpp D +0 -94 \
konqueror/settings/kio/policydlg.h D +0 -121 konqueror/settings/kio/policydlg.ui
M +236 -249 konqueror/settings/kio/useragentdlg.cpp
M +67 -85 konqueror/settings/kio/useragentselectordlg.cpp
M +14 -14 konqueror/settings/kio/useragentselectordlg.h
M +2 -2 konqueror/settings/kio/useragentselectordlg.ui
http://commits.kde.org/kde-baseapps/c5012ab5c40d9cae3f7232f68016073b6e82331c
diff --git a/konqueror/settings/kio/CMakeLists.txt \
b/konqueror/settings/kio/CMakeLists.txt index 626f2fe..e5476c9 100644
--- a/konqueror/settings/kio/CMakeLists.txt
+++ b/konqueror/settings/kio/CMakeLists.txt
@@ -4,17 +4,17 @@ add_subdirectory( uasproviders )
########### next target ###############
set(kcm_kio_PART_SRCS
- policydlg.cpp
+ main.cpp
kcookiesmain.cpp
kcookiespolicies.cpp
- main.cpp
+ kcookiesmanagement.cpp
+ kcookiespolicyselectiondlg.cpp
smbrodlg.cpp
useragentdlg.cpp
kproxydlgbase.cpp
kmanualproxydlg.cpp
kenvvarproxydlg.cpp
kproxydlg.cpp
- kcookiesmanagement.cpp
useragentinfo.cpp
useragentselectordlg.cpp
netpref.cpp
@@ -22,8 +22,17 @@ set(kcm_kio_PART_SRCS
bookmarks.cpp
ksaveioconfig.cpp)
-
-kde4_add_ui_files(kcm_kio_PART_SRCS bookmarks.ui cache.ui manualproxy.ui \
envvarproxy.ui policydlg.ui useragentselectordlg.ui kcookiesmanagementdlg.ui \
useragentdlg.ui kproxydlg.ui kcookiespoliciesdlg.ui kcookiesmanagementdlg.ui) \
+kde4_add_ui_files(kcm_kio_PART_SRCS + bookmarks.ui
+ cache.ui
+ useragentselectordlg.ui
+ useragentdlg.ui
+ manualproxy.ui
+ envvarproxy.ui
+ kproxydlg.ui
+ kcookiespolicies.ui
+ kcookiesmanagement.ui
+ kcookiespolicyselectiondlg.ui)
kde4_add_plugin(kcm_kio ${kcm_kio_PART_SRCS})
diff --git a/konqueror/settings/kio/kcookiesmain.cpp \
b/konqueror/settings/kio/kcookiesmain.cpp index e02e37e..0484316 100644
--- a/konqueror/settings/kio/kcookiesmain.cpp
+++ b/konqueror/settings/kio/kcookiesmain.cpp
@@ -10,6 +10,10 @@
// Own
#include "kcookiesmain.h"
+// Local
+#include "kcookiespolicies.h"
+#include "kcookiesmanagement.h"
+
// Qt
#include <QtGui/QLayout>
#include <QtGui/QTabWidget>
@@ -22,43 +26,38 @@
#include <kdebug.h>
#include <kpluginfactory.h>
-// Local
-#include "kcookiespolicies.h"
-#include "kcookiesmanagement.h"
-K_PLUGIN_FACTORY_DECLARATION(KioConfigFactory)
+K_PLUGIN_FACTORY_DECLARATION (KioConfigFactory)
-KCookiesMain::KCookiesMain(QWidget *parent, const QVariantList &)
- : KCModule(KioConfigFactory::componentData(), parent)
+KCookiesMain::KCookiesMain (QWidget* parent, const QVariantList&)
+ : KCModule (KioConfigFactory::componentData(), parent)
{
management = 0;
bool managerOK = true;
- QDBusInterface kded("org.kde.kded", "/kded", "org.kde.kded");
- QDBusReply<bool> reply = kded.call("loadModule",QString( "kcookiejar" ) );
+ QDBusInterface kded ("org.kde.kded", "/kded", "org.kde.kded");
+ QDBusReply<bool> reply = kded.call ("loadModule", QString ("kcookiejar"));
- if( !reply.isValid() )
- {
- managerOK = false;
- kDebug(7103) << "kcm_kio: KDED could not load KCookiejar!";
- KMessageBox::sorry(0, i18n("Unable to start the cookie handler service.\n"
- "You will not be able to manage the cookies that "
- "are stored on your computer."));
+ if (!reply.isValid()) {
+ managerOK = false;
+ kDebug (7103) << "kcm_kio: KDED could not load KCookiejar!";
+ KMessageBox::sorry (0, i18n ("Unable to start the cookie handler service.\n"
+ "You will not be able to manage the cookies \
that " + "are stored on your computer."));
}
- QVBoxLayout *layout = new QVBoxLayout(this);
- tab = new QTabWidget(this);
- layout->addWidget(tab);
+ QVBoxLayout* layout = new QVBoxLayout (this);
+ tab = new QTabWidget (this);
+ layout->addWidget (tab);
- policies = new KCookiesPolicies(componentData(), this);
- tab->addTab(policies, i18n("&Policy"));
- connect(policies, SIGNAL(changed(bool)), SIGNAL(changed(bool)));
+ policies = new KCookiesPolicies (componentData(), this);
+ tab->addTab (policies, i18n ("&Policy"));
+ connect (policies, SIGNAL (changed (bool)), SIGNAL (changed (bool)));
- if( managerOK )
- {
- management = new KCookiesManagement(componentData(), this);
- tab->addTab(management, i18n("&Management"));
- connect(management, SIGNAL(changed(bool)), SIGNAL(changed(bool)));
+ if (managerOK) {
+ management = new KCookiesManagement (componentData(), this);
+ tab->addTab (management, i18n ("&Management"));
+ connect (management, SIGNAL (changed (bool)), SIGNAL (changed (bool)));
}
}
@@ -68,37 +67,37 @@ KCookiesMain::~KCookiesMain()
void KCookiesMain::save()
{
- policies->save();
- if ( management )
- management->save();
+ policies->save();
+ if (management)
+ management->save();
}
void KCookiesMain::defaults()
{
- KCModule* module = static_cast<KCModule*>(tab->currentWidget());
+ KCModule* module = static_cast<KCModule*> (tab->currentWidget());
- if ( module == policies )
- policies->defaults();
- else if( management )
- management->defaults();
+ if (module == policies)
+ policies->defaults();
+ else if (management)
+ management->defaults();
}
QString KCookiesMain::quickHelp() const
{
- return i18n("<p><h1>Cookies</h1> Cookies contain information that Konqueror"
- " (or other KDE applications using the HTTP protocol) stores on your"
- " computer, initiated by a remote Internet server. This means that"
- " a web server can store information about you and your browsing activities"
- " on your machine for later use. You might consider this an invasion of"
- " privacy.</p><p> However, cookies are useful in certain situations. For \
example, they"
- " are often used by Internet shops, so you can 'put things into a shopping \
basket'."
- " Some sites require you have a browser that supports cookies.</p><p>"
- " Because most people want a compromise between privacy and the benefits cookies \
offer,"
- " KDE offers you the ability to customize the way it handles cookies. So you \
might want"
- " to set KDE's default policy to ask you whenever a server wants to set a \
cookie,"
- " allowing you to decide. For your favorite shopping web sites that you trust, \
you might"
- " want to set the policy to accept, then you can access the web sites without \
being prompted"
- " every time KDE receives a cookie.</p>" );
+ return i18n ("<p><h1>Cookies</h1> Cookies contain information that Konqueror"
+ " (or other KDE applications using the HTTP protocol) stores on \
your" + " computer, initiated by a remote Internet server. This means \
that" + " a web server can store information about you and your \
browsing activities" + " on your machine for later use. You might \
consider this an invasion of" + " privacy.</p><p> However, cookies \
are useful in certain situations. For example, they" + " are often \
used by Internet shops, so you can 'put things into a shopping basket'." + \
" Some sites require you have a browser that supports cookies.</p><p>" + \
" Because most people want a compromise between privacy and the benefits cookies \
offer," + " KDE offers you the ability to customize the way it \
handles cookies. So you might want" + " to set KDE's default policy \
to ask you whenever a server wants to set a cookie," + " allowing you \
to decide. For your favorite shopping web sites that you trust, you might" + \
" want to set the policy to accept, then you can access the web sites without being \
prompted" + " every time KDE receives a cookie.</p>");
}
#include "kcookiesmain.moc"
diff --git a/konqueror/settings/kio/kcookiesmanagement.h \
b/konqueror/settings/kio/kcookiesmanagement.h index 25d6ccc..5887a48 100644
--- a/konqueror/settings/kio/kcookiesmanagement.h
+++ b/konqueror/settings/kio/kcookiesmanagement.h
@@ -28,7 +28,7 @@
#include <QtCore/QHash>
#include <kcmodule.h>
-#include "ui_kcookiesmanagementdlg.h"
+#include "ui_kcookiesmanagement.h"
struct CookieProp;
@@ -83,7 +83,7 @@ private:
bool mDeleteAllFlag;
QWidget* mMainWidget;
- Ui::KCookiesManagementDlgUI mUi;
+ Ui::KCookiesManagementUI mUi;
QStringList mDeletedDomains;
typedef QList<CookieProp *> CookiePropList;
diff --git a/konqueror/settings/kio/kcookiesmanagementdlg.ui \
b/konqueror/settings/kio/kcookiesmanagement.ui similarity index 98%
rename from konqueror/settings/kio/kcookiesmanagementdlg.ui
rename to konqueror/settings/kio/kcookiesmanagement.ui
index a550ca4..09d4213 100644
--- a/konqueror/settings/kio/kcookiesmanagementdlg.ui
+++ b/konqueror/settings/kio/kcookiesmanagement.ui
@@ -1,7 +1,7 @@
<?xml version="1.0" encoding="UTF-8"?>
<ui version="4.0">
- <class>KCookiesManagementDlgUI</class>
- <widget class="QWidget" name="KCookiesManagementDlgUI">
+ <class>KCookiesManagementUI</class>
+ <widget class="QWidget" name="KCookiesManagementUI">
<property name="geometry">
<rect>
<x>0</x>
diff --git a/konqueror/settings/kio/kcookiespolicies.cpp \
b/konqueror/settings/kio/kcookiespolicies.cpp index 4b4019e..67d692b5 100644
--- a/konqueror/settings/kio/kcookiespolicies.cpp
+++ b/konqueror/settings/kio/kcookiespolicies.cpp
@@ -27,6 +27,9 @@
// Own
#include "kcookiespolicies.h"
+// Local
+#include "ksaveioconfig.h"
+
// Qt
#include <QtGui/QLayout>
#include <QtGui/QCheckBox>
@@ -44,7 +47,6 @@
#include <kurl.h>
#include <kdebug.h>
-#include "ksaveioconfig.h"
// QUrl::fromAce/toAce don't accept a domain that starts with a '.', like we do \
here. // So we use these wrappers.
@@ -169,7 +171,8 @@ void KCookiesPolicies::autoAcceptSessionCookies (bool enable)
void KCookiesPolicies::addNewPolicy (const QString& domain)
{
- PolicyDlg pdlg (i18nc ("@title:window", "New Cookie Policy"), this);
+ KCookiesPolicySelectionDlg pdlg (this);
+ pdlg.setWindowTitle (i18nc ("@title:window", "New Cookie Policy"));
pdlg.setEnableHostEdit (true, domain);
if (mUi.rbPolicyAccept->isChecked())
@@ -206,7 +209,8 @@ void KCookiesPolicies::changePressed()
QString oldDomain = index->text (0);
- PolicyDlg pdlg (i18nc ("@title:window", "Change Cookie Policy"), this);
+ KCookiesPolicySelectionDlg pdlg (this);
+ pdlg.setWindowTitle (i18nc ("@title:window", "Change Cookie Policy"));
pdlg.setPolicy (KCookieAdvice::strToAdvice (m_pDomainPolicy[index]));
pdlg.setEnableHostEdit (true, oldDomain);
diff --git a/konqueror/settings/kio/kcookiespolicies.h \
b/konqueror/settings/kio/kcookiespolicies.h index 53eaf59..b035ad5 100644
--- a/konqueror/settings/kio/kcookiespolicies.h
+++ b/konqueror/settings/kio/kcookiespolicies.h
@@ -29,8 +29,9 @@
#include <QtCore/QMap>
#include <kcmodule.h>
-#include "policydlg.h"
-#include "ui_kcookiespoliciesdlg.h"
+#include "kcookiespolicyselectiondlg.h"
+#include "ui_kcookiespolicies.h"
+
class QTreeWidgetItem;
@@ -71,7 +72,7 @@ private:
private:
int d_itemsSelected;
- Ui::KCookiesPolicyDlgUI mUi;
+ Ui::KCookiePoliciesUI mUi;
QMap<QTreeWidgetItem*, const char*> m_pDomainPolicy;
};
diff --git a/konqueror/settings/kio/kcookiespoliciesdlg.ui \
b/konqueror/settings/kio/kcookiespolicies.ui similarity index 99%
rename from konqueror/settings/kio/kcookiespoliciesdlg.ui
rename to konqueror/settings/kio/kcookiespolicies.ui
index c33da02..6b88b80 100644
--- a/konqueror/settings/kio/kcookiespoliciesdlg.ui
+++ b/konqueror/settings/kio/kcookiespolicies.ui
@@ -1,6 +1,6 @@
<ui version="4.0" >
- <class>KCookiesPolicyDlgUI</class>
- <widget class="QWidget" name="KCookiesPolicyDlgUI" >
+ <class>KCookiePoliciesUI</class>
+ <widget class="QWidget" name="KCookiePoliciesUI" >
<property name="geometry" >
<rect>
<x>0</x>
diff --git a/konqueror/settings/kio/kcookiespolicyselectiondlg.cpp \
b/konqueror/settings/kio/kcookiespolicyselectiondlg.cpp new file mode 100644
index 0000000..584cb1f
--- /dev/null
+++ b/konqueror/settings/kio/kcookiespolicyselectiondlg.cpp
@@ -0,0 +1,108 @@
+/**
+ * Copyright (c) 2000- Dawit Alemayehu <adawit@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; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
+ */
+
+// Own
+#include "kcookiespolicyselectiondlg.h"
+
+// Qt
+#include <QtGui/QPushButton>
+#include <QtGui/QWhatsThis>
+#include <QtGui/QLayout>
+#include <QtGui/QLabel>
+#include <QtGui/QValidator>
+
+// KDE
+#include <klineedit.h>
+#include <kcombobox.h>
+#include <klocale.h>
+
+class DomainNameValidator : public QValidator
+{
+public:
+ DomainNameValidator (QObject* parent)
+ :QValidator(parent)
+ {
+ setObjectName(QLatin1String("domainValidator"));
+ }
+
+ State validate (QString& input, int&) const
+ {
+ if (input.isEmpty() || (input == ".")) {
+ return Intermediate;
+ }
+
+ const int length = input.length();
+
+ for (int i = 0 ; i < length; i++) {
+ if (!input[i].isLetterOrNumber() && input[i] != '.' && input[i] != '-') \
{ + return Invalid;
+ }
+ }
+
+ return Acceptable;
+ }
+};
+
+
+KCookiesPolicySelectionDlg::KCookiesPolicySelectionDlg (QWidget* parent, \
Qt::WindowFlags flags) + : KDialog (parent, flags)
+{
+ mUi.setupUi(mainWidget());
+ mUi.leDomain->setValidator(new DomainNameValidator (mUi.leDomain));
+ mUi.cbPolicy->setMinimumWidth(mUi.cbPolicy->fontMetrics().maxWidth() * 15);
+
+ enableButtonOk(false);
+ connect(mUi.leDomain, SIGNAL(textEdited(QString)),
+ SLOT(slotTextChanged (QString)));
+
+ mUi.leDomain->setFocus();
+}
+
+void KCookiesPolicySelectionDlg::setEnableHostEdit (bool state, const QString& host)
+{
+ if (!host.isEmpty())
+ mUi.leDomain->setText (host);
+
+ mUi.leDomain->setEnabled (state);
+}
+
+void KCookiesPolicySelectionDlg::setPolicy (int policy)
+{
+ if (policy > -1 && policy <= static_cast<int> (mUi.cbPolicy->count()))
+ mUi.cbPolicy->setCurrentIndex (policy - 1);
+
+ if (!mUi.leDomain->isEnabled())
+ mUi.cbPolicy->setFocus();
+}
+
+int KCookiesPolicySelectionDlg::advice () const
+{
+ return mUi.cbPolicy->currentIndex() + 1;
+}
+
+QString KCookiesPolicySelectionDlg::domain () const
+{
+ return mUi.leDomain->text();
+}
+
+void KCookiesPolicySelectionDlg::slotTextChanged (const QString& text)
+{
+ enableButtonOk (text.length() > 1);
+}
+
+#include "kcookiespolicyselectiondlg.moc"
diff --git a/konqueror/settings/kio/kcookiespolicyselectiondlg.h \
b/konqueror/settings/kio/kcookiespolicyselectiondlg.h new file mode 100644
index 0000000..d40a0f2
--- /dev/null
+++ b/konqueror/settings/kio/kcookiespolicyselectiondlg.h
@@ -0,0 +1,80 @@
+/**
+ * Copyright (c) 2000- Dawit Alemayehu <adawit@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; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
+ */
+
+#ifndef KCOOKIESPOLICYSELECTIONDLG_H
+#define KCOOKIESPOLICYSELECTIONDLG_H
+
+#include <kdialog.h>
+#include "ui_kcookiespolicyselectiondlg.h"
+
+class QWidget;
+
+class KCookieAdvice
+{
+public:
+ enum Value {Dunno = 0, Accept, Reject, Ask};
+
+ static const char* adviceToStr (const int& advice) {
+ switch (advice) {
+ case KCookieAdvice::Accept:
+ return I18N_NOOP ("Accept");
+ case KCookieAdvice::Reject:
+ return I18N_NOOP ("Reject");
+ case KCookieAdvice::Ask:
+ return I18N_NOOP ("Ask");
+ default:
+ return I18N_NOOP ("Dunno");
+ }
+ }
+
+ static KCookieAdvice::Value strToAdvice (const QString& advice) {
+ if (advice.isEmpty())
+ return KCookieAdvice::Dunno;
+
+ if (advice.indexOf (QLatin1String ("accept"), 0, Qt::CaseInsensitive) == 0)
+ return KCookieAdvice::Accept;
+ else if (advice.indexOf (QLatin1String ("reject"), 0, Qt::CaseInsensitive) \
== 0) + return KCookieAdvice::Reject;
+ else if (advice.indexOf (QLatin1String ("ask"), 0, Qt::CaseInsensitive) == \
0) + return KCookieAdvice::Ask;
+
+ return KCookieAdvice::Dunno;
+ }
+};
+
+class KCookiesPolicySelectionDlg : public KDialog
+{
+ Q_OBJECT
+
+public:
+ explicit KCookiesPolicySelectionDlg (QWidget* parent = 0, Qt::WindowFlags f = \
0); + ~KCookiesPolicySelectionDlg () {}
+
+ int advice() const;
+ QString domain() const;
+
+ void setEnableHostEdit (bool, const QString& host = QString());
+ void setPolicy (int policy);
+
+protected Q_SLOTS:
+ void slotTextChanged (const QString&);
+
+private:
+ Ui::KCookiesPolicySelectionDlgUI mUi;
+};
+#endif
diff --git a/konqueror/settings/kio/kcookiespolicyselectiondlg.ui \
b/konqueror/settings/kio/kcookiespolicyselectiondlg.ui new file mode 100644
index 0000000..c7ebb5d
--- /dev/null
+++ b/konqueror/settings/kio/kcookiespolicyselectiondlg.ui
@@ -0,0 +1,110 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<ui version="4.0">
+ <class>KCookiesPolicySelectionDlgUI</class>
+ <widget class="QWidget" name="KCookiesPolicySelectionDlgUI">
+ <property name="geometry">
+ <rect>
+ <x>0</x>
+ <y>0</y>
+ <width>287</width>
+ <height>81</height>
+ </rect>
+ </property>
+ <layout class="QFormLayout" name="formLayout">
+ <property name="fieldGrowthPolicy">
+ <enum>QFormLayout::ExpandingFieldsGrow</enum>
+ </property>
+ <item row="0" column="0">
+ <widget class="QLabel" name="lbDomain">
+ <property name="whatsThis">
+ <string><qt>
+Enter the host or domain to which this policy applies, e.g. \
<b>www.kde.org</b> or <b>.kde.org</b>. +</qt></string>
+ </property>
+ <property name="text">
+ <string>Site name:</string>
+ </property>
+ <property name="wordWrap">
+ <bool>false</bool>
+ </property>
+ <property name="buddy">
+ <cstring>leDomain</cstring>
+ </property>
+ </widget>
+ </item>
+ <item row="0" column="1">
+ <widget class="KLineEdit" name="leDomain">
+ <property name="whatsThis">
+ <string>Enter the host or domain name, e.g. .kde.org, this policy applies \
to.</string> + </property>
+ </widget>
+ </item>
+ <item row="1" column="0">
+ <widget class="QLabel" name="lbPolicy">
+ <property name="whatsThis">
+ <string><qt>
+Select the desired policy:
+<ul>
+<li><b>Accept</b> - Allows this site to set cookies</li>
+<li><b>Reject</b> - Refuse all cookies sent from this \
site</li> +<li><b>Ask</b> - Prompt when cookies are received \
from this site</li> +</ul>
+</qt></string>
+ </property>
+ <property name="text">
+ <string>Policy:</string>
+ </property>
+ <property name="wordWrap">
+ <bool>false</bool>
+ </property>
+ <property name="buddy">
+ <cstring>cbPolicy</cstring>
+ </property>
+ </widget>
+ </item>
+ <item row="1" column="1">
+ <widget class="KComboBox" name="cbPolicy">
+ <property name="whatsThis">
+ <string><qt>
+Select the desired policy:
+<ul>
+<li><b>Accept</b> - Allows this site to set cookies</li>
+<li><b>Reject</b> - Refuse all cookies sent from this \
site</li> +<li><b>Ask</b> - Prompt when cookies are received \
from this site</li> +</ul>
+</qt></string>
+ </property>
+ <item>
+ <property name="text">
+ <string>Accept</string>
+ </property>
+ </item>
+ <item>
+ <property name="text">
+ <string>Reject</string>
+ </property>
+ </item>
+ <item>
+ <property name="text">
+ <string>Ask</string>
+ </property>
+ </item>
+ </widget>
+ </item>
+ </layout>
+ </widget>
+ <customwidgets>
+ <customwidget>
+ <class>KComboBox</class>
+ <extends>QComboBox</extends>
+ <header>kcombobox.h</header>
+ </customwidget>
+ <customwidget>
+ <class>KLineEdit</class>
+ <extends>QLineEdit</extends>
+ <header>klineedit.h</header>
+ </customwidget>
+ </customwidgets>
+ <resources/>
+ <connections/>
+</ui>
diff --git a/konqueror/settings/kio/policydlg.cpp \
b/konqueror/settings/kio/policydlg.cpp deleted file mode 100644
index 3093673..0000000
--- a/konqueror/settings/kio/policydlg.cpp
+++ /dev/null
@@ -1,114 +0,0 @@
-/**
- * Copyright (c) 2000- Dawit Alemayehu <adawit@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; if not, write to the Free Software
- * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
- */
-
-// Own
-#include "policydlg.h"
-
-// Qt
-#include <QtGui/QPushButton>
-#include <QtGui/QWhatsThis>
-#include <QtGui/QLayout>
-#include <QtGui/QLabel>
-#include <QtGui/QValidator>
-
-// KDE
-#include <klineedit.h>
-#include <kcombobox.h>
-#include <klocale.h>
-
-class DomainLineValidator : public QValidator
-{
-public:
- DomainLineValidator(QObject *parent)
- :QValidator(parent)
- {
- setObjectName( QLatin1String("domainValidator" ));
- }
-
- State validate(QString &input, int &) const
- {
- if (input.isEmpty() || (input == "."))
- return Intermediate;
-
- int length = input.length();
-
- for(int i = 0 ; i < length; i++)
- {
- if (!input[i].isLetterOrNumber() && input[i] != '.' && input[i] != '-')
- return Invalid;
- }
-
- return Acceptable;
- }
-};
-
-
-PolicyDlg::PolicyDlg (const QString& caption, QWidget *parent,
- const char *name)
- : KDialog( parent )
-{
- setObjectName( name );
- setModal( true );
- setCaption( caption );
- setButtons( Ok|Cancel );
-
- m_dlgUI = new PolicyDlgUI (this);
- setMainWidget(m_dlgUI);
-
- m_dlgUI->leDomain->setValidator(new DomainLineValidator(m_dlgUI->leDomain));
- m_dlgUI->cbPolicy->setMinimumWidth( m_dlgUI->cbPolicy->fontMetrics().maxWidth() * \
25 );
-
- enableButtonOk( false );
- connect(m_dlgUI->leDomain, SIGNAL(textChanged(QString)),
- SLOT(slotTextChanged(QString)));
-
- setFixedSize (sizeHint());
- m_dlgUI->leDomain->setFocus ();
-}
-
-void PolicyDlg::setEnableHostEdit( bool state, const QString& host )
-{
- if ( !host.isEmpty() )
- m_dlgUI->leDomain->setText( host );
- m_dlgUI->leDomain->setEnabled( state );
-}
-
-void PolicyDlg::setPolicy (int policy)
-{
- if ( policy > -1 && policy <= static_cast<int>(m_dlgUI->cbPolicy->count()) )
- m_dlgUI->cbPolicy->setCurrentIndex(policy-1);
-
- if ( !m_dlgUI->leDomain->isEnabled() )
- m_dlgUI->cbPolicy->setFocus();
-}
-
-int PolicyDlg::advice () const
-{
- return m_dlgUI->cbPolicy->currentIndex() + 1;
-}
-
-QString PolicyDlg::domain () const
-{
- return m_dlgUI->leDomain->text();
-}
-
-void PolicyDlg::slotTextChanged( const QString& text )
-{
- enableButtonOk( text.length() > 1 );
-}
-#include "policydlg.moc"
diff --git a/konqueror/settings/kio/policydlg.h b/konqueror/settings/kio/policydlg.h
deleted file mode 100644
index 2991791..0000000
--- a/konqueror/settings/kio/policydlg.h
+++ /dev/null
@@ -1,94 +0,0 @@
-/**
- * Copyright (c) 2000- Dawit Alemayehu <adawit@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; if not, write to the Free Software
- * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
- */
-
-#ifndef _POLICYDLG_H
-#define _POLICYDLG_H
-
-
-
-#include <kdialog.h>
-#include "ui_policydlg.h"
-
-
-class PolicyDlgUI : public QWidget, public Ui::PolicyDlgUI
-{
-public:
- PolicyDlgUI( QWidget *parent ) : QWidget( parent ) {
- setupUi( this );
- }
-};
-
-
-class KCookieAdvice
-{
-public:
- enum Value {Dunno=0, Accept, Reject, Ask};
-
- static const char * adviceToStr (const int& advice)
- {
- switch (advice)
- {
- case KCookieAdvice::Accept:
- return I18N_NOOP("Accept");
- case KCookieAdvice::Reject:
- return I18N_NOOP("Reject");
- case KCookieAdvice::Ask:
- return I18N_NOOP("Ask");
- default:
- return I18N_NOOP("Dunno");
- }
- }
-
- static KCookieAdvice::Value strToAdvice (const QString& advice)
- {
- if (advice.isEmpty())
- return KCookieAdvice::Dunno;
-
- if (advice.indexOf (QLatin1String("accept"), 0, Qt::CaseInsensitive) == 0)
- return KCookieAdvice::Accept;
- else if (advice.indexOf (QLatin1String("reject"), 0, Qt::CaseInsensitive) == 0)
- return KCookieAdvice::Reject;
- else if (advice.indexOf (QLatin1String("ask"), 0, Qt::CaseInsensitive) == 0)
- return KCookieAdvice::Ask;
-
- return KCookieAdvice::Dunno;
- }
-};
-
-class PolicyDlg : public KDialog
-{
- Q_OBJECT
-
-public:
- explicit PolicyDlg (const QString& caption, QWidget *parent = 0,
- const char *name = 0);
- ~PolicyDlg (){}
-
- int advice() const;
- QString domain() const;
-
- void setEnableHostEdit( bool, const QString& host = QString() );
- void setPolicy (int policy);
-
-protected Q_SLOTS:
- void slotTextChanged( const QString& );
-
-private:
- PolicyDlgUI* m_dlgUI;
-};
-#endif
diff --git a/konqueror/settings/kio/policydlg.ui \
b/konqueror/settings/kio/policydlg.ui deleted file mode 100644
index 4a0b595..0000000
--- a/konqueror/settings/kio/policydlg.ui
+++ /dev/null
@@ -1,121 +0,0 @@
-<ui version="4.0" >
- <class>PolicyDlgUI</class>
- <widget class="QWidget" name="PolicyDlgUI" >
- <property name="geometry" >
- <rect>
- <x>0</x>
- <y>0</y>
- <width>301</width>
- <height>125</height>
- </rect>
- </property>
- <layout class="QFormLayout" name="formLayout" >
- <item row="0" column="0" >
- <widget class="QLabel" name="lbDomain" >
- <property name="whatsThis" >
- <string><qt>
-Enter the host or domain to which this policy applies, e.g. <b>www.kde.org</b> \
or <b>.kde.org</b>.
-</qt></string>
- </property>
- <property name="text" >
- <string>&Domain name:</string>
- </property>
- <property name="wordWrap" >
- <bool>false</bool>
- </property>
- <property name="buddy" >
- <cstring>leDomain</cstring>
- </property>
- </widget>
- </item>
- <item row="0" column="1" >
- <widget class="KLineEdit" name="leDomain" >
- <property name="whatsThis" >
- <string><qt>
-Enter the host or domain to which this policy applies, e.g. <b>www.kde.org</b> \
or <b>.kde.org</b>.
-</qt></string>
- </property>
- </widget>
- </item>
- <item row="1" column="0" >
- <widget class="QLabel" name="lbPolicy" >
- <property name="whatsThis" >
- <string><qt>
-Select the desired policy:
-<ul>
-<li><b>Accept</b> - Allows this site to set cookies</li>
-<li><b>Reject</b> - Refuse all cookies sent from this site</li>
-<li><b>Ask</b> - Prompt when cookies are received from this site</li>
-</ul>
-</qt></string>
- </property>
- <property name="text" >
- <string>&Policy:</string>
- </property>
- <property name="wordWrap" >
- <bool>false</bool>
- </property>
- <property name="buddy" >
- <cstring>cbPolicy</cstring>
- </property>
- </widget>
- </item>
- <item row="1" column="1" >
- <widget class="KComboBox" name="cbPolicy" >
- <property name="whatsThis" >
- <string><qt>
-Select the desired policy:
-<ul>
-<li><b>Accept</b> - Allows this site to set cookies</li>
-<li><b>Reject</b> - Refuse all cookies sent from this site</li>
-<li><b>Ask</b> - Prompt when cookies are received from this site</li>
-</ul>
-</qt></string>
- </property>
- <item>
- <property name="text" >
- <string>Accept</string>
- </property>
- </item>
- <item>
- <property name="text" >
- <string>Reject</string>
- </property>
- </item>
- <item>
- <property name="text" >
- <string>Ask</string>
- </property>
- </item>
- </widget>
- </item>
- <item row="2" column="0" >
- <spacer>
- <property name="orientation" >
- <enum>Qt::Vertical</enum>
- </property>
- <property name="sizeHint" stdset="0" >
- <size>
- <width>20</width>
- <height>40</height>
- </size>
- </property>
- </spacer>
- </item>
- </layout>
- </widget>
- <customwidgets>
- <customwidget>
- <class>KComboBox</class>
- <extends>QComboBox</extends>
- <header>kcombobox.h</header>
- </customwidget>
- <customwidget>
- <class>KLineEdit</class>
- <extends>QLineEdit</extends>
- <header>klineedit.h</header>
- </customwidget>
- </customwidgets>
- <resources/>
- <connections/>
-</ui>
diff --git a/konqueror/settings/kio/useragentdlg.cpp \
b/konqueror/settings/kio/useragentdlg.cpp index 0c935af..2aa6472 100644
--- a/konqueror/settings/kio/useragentdlg.cpp
+++ b/konqueror/settings/kio/useragentdlg.cpp
@@ -47,21 +47,21 @@
#include <kpluginfactory.h>
-K_PLUGIN_FACTORY_DECLARATION(KioConfigFactory)
+K_PLUGIN_FACTORY_DECLARATION (KioConfigFactory)
typedef QList<QTreeWidgetItem*> SiteList;
typedef SiteList::iterator SiteListIterator;
-UserAgentDlg::UserAgentDlg(QWidget *parent, const QVariantList &)
- :KCModule(KioConfigFactory::componentData(), parent),
- m_userAgentInfo(0),
- m_config(0)
+UserAgentDlg::UserAgentDlg (QWidget* parent, const QVariantList&)
+ : KCModule (KioConfigFactory::componentData(), parent),
+ m_userAgentInfo (0),
+ m_config (0)
{
- ui.setupUi(this);
- ui.newButton->setIcon(KIcon("list-add"));
- ui.changeButton->setIcon(KIcon("edit-rename"));
- ui.deleteButton->setIcon(KIcon("list-remove"));
- ui.deleteAllButton->setIcon(KIcon("edit-delete"));
+ ui.setupUi (this);
+ ui.newButton->setIcon (KIcon ("list-add"));
+ ui.changeButton->setIcon (KIcon ("edit-rename"));
+ ui.deleteButton->setIcon (KIcon ("list-remove"));
+ ui.deleteAllButton->setIcon (KIcon ("edit-delete"));
}
UserAgentDlg::~UserAgentDlg()
@@ -72,335 +72,322 @@ UserAgentDlg::~UserAgentDlg()
void UserAgentDlg::on_sendUACheckBox_clicked()
{
- configChanged();
+ configChanged();
}
void UserAgentDlg::on_newButton_clicked()
{
- const QPointer<UserAgentSelectorDlg> pdlg( new UserAgentSelectorDlg( \
i18nc("@title:window", "Add Identification"), m_userAgentInfo, this ) \
);
-
- if ( pdlg->exec() == QDialog::Accepted && pdlg )
- {
- if ( !handleDuplicate( pdlg->siteName(), pdlg->identity(), pdlg->alias() ) )
- {
- QTreeWidgetItem* item = new QTreeWidgetItem( ui.sitePolicyTreeWidget);
- item->setText(0, pdlg->siteName());
- item->setText(1, pdlg->identity());
- item->setText(2, pdlg->alias());
- ui.sitePolicyTreeWidget->setCurrentItem( item );
- configChanged();
+ const QPointer<UserAgentSelectorDlg> pdlg (new UserAgentSelectorDlg \
(m_userAgentInfo, this)); + pdlg->setWindowTitle(i18nc ("@title:window", "Add \
Identification")); +
+ if (pdlg->exec() == QDialog::Accepted && pdlg) {
+ if (!handleDuplicate (pdlg->siteName(), pdlg->identity(), pdlg->alias())) {
+ QTreeWidgetItem* item = new QTreeWidgetItem (ui.sitePolicyTreeWidget);
+ item->setText (0, pdlg->siteName());
+ item->setText (1, pdlg->identity());
+ item->setText (2, pdlg->alias());
+ ui.sitePolicyTreeWidget->setCurrentItem (item);
+ configChanged();
+ }
}
- }
- delete pdlg;
+ delete pdlg;
}
void UserAgentDlg::on_changeButton_clicked()
{
- on_sitePolicyTreeWidget_itemDoubleClicked(ui.sitePolicyTreeWidget->currentItem(), \
-1); + on_sitePolicyTreeWidget_itemDoubleClicked \
(ui.sitePolicyTreeWidget->currentItem(), -1); }
void UserAgentDlg::on_deleteButton_clicked()
{
- SiteList selectedItems = ui.sitePolicyTreeWidget->selectedItems();
- SiteListIterator endIt = selectedItems.end();
+ SiteList selectedItems = ui.sitePolicyTreeWidget->selectedItems();
+ SiteListIterator endIt = selectedItems.end();
- QString siteName;
- for(SiteListIterator it = selectedItems.begin(); it != endIt; ++it)
- delete (*it);
+ QString siteName;
+ for (SiteListIterator it = selectedItems.begin(); it != endIt; ++it)
+ delete (*it);
- updateButtons();
- configChanged();
+ updateButtons();
+ configChanged();
}
void UserAgentDlg::on_deleteAllButton_clicked()
{
- ui.sitePolicyTreeWidget->clear();
- updateButtons();
- configChanged();
+ ui.sitePolicyTreeWidget->clear();
+ updateButtons();
+ configChanged();
}
void UserAgentDlg::on_osNameCheckBox_clicked()
{
- changeDefaultUAModifiers();
+ changeDefaultUAModifiers();
}
void UserAgentDlg::on_osVersionCheckBox_clicked()
{
- changeDefaultUAModifiers();
+ changeDefaultUAModifiers();
}
void UserAgentDlg::on_processorTypeCheckBox_clicked()
{
- changeDefaultUAModifiers();
+ changeDefaultUAModifiers();
}
void UserAgentDlg::on_languageCheckBox_clicked()
{
- changeDefaultUAModifiers();
+ changeDefaultUAModifiers();
}
-void UserAgentDlg::on_sitePolicyTreeWidget_itemDoubleClicked(QTreeWidgetItem* item, \
int) +void UserAgentDlg::on_sitePolicyTreeWidget_itemDoubleClicked (QTreeWidgetItem* \
item, int) {
- if(item)
- {
- // Store the current site name...
- const QString currentSiteName = item->text(0);
-
- UserAgentSelectorDlg pdlg ( i18nc("@title:window", "Modify Identification"), \
m_userAgentInfo, this );
- pdlg.setSiteName( currentSiteName );
- pdlg.setIdentity( item->text(1) );
-
- if ( pdlg.exec() == QDialog::Accepted )
- {
- if ( pdlg.siteName() == currentSiteName ||
- !handleDuplicate( pdlg.siteName(), pdlg.identity(), pdlg.alias() ) )
- {
- item->setText( 0, pdlg.siteName() );
- item->setText( 1, pdlg.identity() );
- item->setText( 2, pdlg.alias() );
- configChanged();
- }
+ if (item) {
+ // Store the current site name...
+ const QString currentSiteName = item->text (0);
+
+ UserAgentSelectorDlg pdlg (m_userAgentInfo, this);
+ pdlg.setWindowTitle (i18nc ("@title:window", "Modify Identification"));
+ pdlg.setSiteName (currentSiteName);
+ pdlg.setIdentity (item->text (1));
+
+ if (pdlg.exec() == QDialog::Accepted) {
+ if (pdlg.siteName() == currentSiteName ||
+ !handleDuplicate (pdlg.siteName(), pdlg.identity(), \
pdlg.alias())) { + item->setText (0, pdlg.siteName());
+ item->setText (1, pdlg.identity());
+ item->setText (2, pdlg.alias());
+ configChanged();
+ }
+ }
}
- }
}
void UserAgentDlg::changeDefaultUAModifiers()
{
- m_ua_keys = ':'; // Make sure it's not empty
+ m_ua_keys = ':'; // Make sure it's not empty
- if ( ui.osNameCheckBox->isChecked() )
- m_ua_keys += 'o';
+ if (ui.osNameCheckBox->isChecked())
+ m_ua_keys += 'o';
- if ( ui.osVersionCheckBox->isChecked() )
- m_ua_keys += 'v';
+ if (ui.osVersionCheckBox->isChecked())
+ m_ua_keys += 'v';
- if ( ui.processorTypeCheckBox->isChecked() )
- m_ua_keys += 'm';
+ if (ui.processorTypeCheckBox->isChecked())
+ m_ua_keys += 'm';
- if ( ui.languageCheckBox->isChecked() )
- m_ua_keys += 'l';
+ if (ui.languageCheckBox->isChecked())
+ m_ua_keys += 'l';
- ui.osVersionCheckBox->setEnabled(m_ua_keys.contains('o'));
+ ui.osVersionCheckBox->setEnabled (m_ua_keys.contains ('o'));
- QString modVal = KProtocolManager::defaultUserAgent( m_ua_keys );
- if ( ui.defaultIdLineEdit->text() != modVal )
- {
- ui.defaultIdLineEdit->setText(modVal);
- configChanged();
- }
+ QString modVal = KProtocolManager::defaultUserAgent (m_ua_keys);
+ if (ui.defaultIdLineEdit->text() != modVal) {
+ ui.defaultIdLineEdit->setText (modVal);
+ configChanged();
+ }
}
-bool UserAgentDlg::handleDuplicate( const QString& site,
+bool UserAgentDlg::handleDuplicate (const QString& site,
const QString& identity,
- const QString& alias )
+ const QString& alias)
{
- SiteList list = ui.sitePolicyTreeWidget->findItems(site, Qt::MatchExactly, 0);
-
- if (!list.isEmpty())
- {
- QString msg = i18n("<qt><center>Found an existing identification for"
- "<br/><b>%1</b><br/>"
- "Do you want to replace it?</center>"
- "</qt>", site);
- int res = KMessageBox::warningContinueCancel(this, msg,
- i18nc("@title:window", "Duplicate \
Identification"),
- KGuiItem(i18n("Replace")));
- if ( res == KMessageBox::Continue )
- {
- list[0]->setText(0, site);
- list[0]->setText(1, identity);
- list[0]->setText(2, alias);
- configChanged();
+ SiteList list = ui.sitePolicyTreeWidget->findItems (site, Qt::MatchExactly, 0);
+
+ if (!list.isEmpty()) {
+ QString msg = i18n ("<qt><center>Found an existing identification for"
+ "<br/><b>%1</b><br/>"
+ "Do you want to replace it?</center>"
+ "</qt>", site);
+ int res = KMessageBox::warningContinueCancel (this, msg,
+ i18nc ("@title:window", "Duplicate Identification"),
+ KGuiItem (i18n ("Replace")));
+ if (res == KMessageBox::Continue) {
+ list[0]->setText (0, site);
+ list[0]->setText (1, identity);
+ list[0]->setText (2, alias);
+ configChanged();
+ }
+
+ return true;
}
- return true;
- }
-
- return false;
+ return false;
}
-void UserAgentDlg::configChanged(bool enable)
+void UserAgentDlg::configChanged (bool enable)
{
- emit changed(enable);
+ emit changed (enable);
}
void UserAgentDlg::updateButtons()
{
- const int selectedItemCount = ui.sitePolicyTreeWidget->selectedItems().count();
- const bool hasItems = ui.sitePolicyTreeWidget->topLevelItemCount() > 0;
+ const int selectedItemCount = ui.sitePolicyTreeWidget->selectedItems().count();
+ const bool hasItems = ui.sitePolicyTreeWidget->topLevelItemCount() > 0;
- ui.changeButton->setEnabled ((hasItems && selectedItemCount == 1));
- ui.deleteButton->setEnabled ((hasItems && selectedItemCount > 0));
- ui.deleteAllButton->setEnabled ( hasItems );
+ ui.changeButton->setEnabled ( (hasItems && selectedItemCount == 1));
+ ui.deleteButton->setEnabled ( (hasItems && selectedItemCount > 0));
+ ui.deleteAllButton->setEnabled (hasItems);
}
void UserAgentDlg::on_sitePolicyTreeWidget_itemSelectionChanged()
{
- updateButtons();
+ updateButtons();
}
void UserAgentDlg::load()
{
- ui.sitePolicyTreeWidget->clear();
-
- if (!m_config)
- m_config = new KConfig("kio_httprc", KConfig::NoGlobals);
- else
- m_config->reparseConfiguration();
-
- if (!m_userAgentInfo)
- m_userAgentInfo = new UserAgentInfo();
-
- const QStringList list = m_config->groupList();
- QStringList::ConstIterator endIt = list.end();
- QString agentStr;
-
- for ( QStringList::ConstIterator it = list.begin(); it != endIt; ++it )
- {
- if ( (*it) == "<default>")
- continue;
-
- KConfigGroup cg(m_config, *it);
- agentStr = cg.readEntry("UserAgent");
- if (!agentStr.isEmpty())
- {
- QTreeWidgetItem* item = new QTreeWidgetItem(ui.sitePolicyTreeWidget);
- item->setText(0, (*it).toLower());
- item->setText(1, m_userAgentInfo->aliasStr(agentStr));
- item->setText(2, agentStr);
+ ui.sitePolicyTreeWidget->clear();
+
+ if (!m_config)
+ m_config = new KConfig ("kio_httprc", KConfig::NoGlobals);
+ else
+ m_config->reparseConfiguration();
+
+ if (!m_userAgentInfo)
+ m_userAgentInfo = new UserAgentInfo();
+
+ const QStringList list = m_config->groupList();
+ QStringList::ConstIterator endIt = list.end();
+ QString agentStr;
+
+ for (QStringList::ConstIterator it = list.begin(); it != endIt; ++it) {
+ if ( (*it) == "<default>")
+ continue;
+
+ KConfigGroup cg (m_config, *it);
+ agentStr = cg.readEntry ("UserAgent");
+ if (!agentStr.isEmpty()) {
+ QTreeWidgetItem* item = new QTreeWidgetItem (ui.sitePolicyTreeWidget);
+ item->setText (0, (*it).toLower());
+ item->setText (1, m_userAgentInfo->aliasStr (agentStr));
+ item->setText (2, agentStr);
+ }
}
- }
-
- // Update buttons and checkboxes...
- KConfigGroup cg2(m_config, QString());
- bool b = cg2.readEntry("SendUserAgent", true);
- ui.sendUACheckBox->setChecked( b );
- m_ua_keys = cg2.readEntry("UserAgentKeys", DEFAULT_USER_AGENT_KEYS).toLower();
- ui.defaultIdLineEdit->setText( KProtocolManager::defaultUserAgent( m_ua_keys ) );
- ui.osNameCheckBox->setChecked( m_ua_keys.contains('o') );
- ui.osVersionCheckBox->setChecked( m_ua_keys.contains('v') );
- ui.processorTypeCheckBox->setChecked( m_ua_keys.contains('m') );
- ui.languageCheckBox->setChecked( m_ua_keys.contains('l') );
-
- updateButtons();
- configChanged(false);
+
+ // Update buttons and checkboxes...
+ KConfigGroup cg2 (m_config, QString());
+ bool b = cg2.readEntry ("SendUserAgent", true);
+ ui.sendUACheckBox->setChecked (b);
+ m_ua_keys = cg2.readEntry ("UserAgentKeys", DEFAULT_USER_AGENT_KEYS).toLower();
+ ui.defaultIdLineEdit->setText (KProtocolManager::defaultUserAgent (m_ua_keys));
+ ui.osNameCheckBox->setChecked (m_ua_keys.contains ('o'));
+ ui.osVersionCheckBox->setChecked (m_ua_keys.contains ('v'));
+ ui.processorTypeCheckBox->setChecked (m_ua_keys.contains ('m'));
+ ui.languageCheckBox->setChecked (m_ua_keys.contains ('l'));
+
+ updateButtons();
+ configChanged (false);
}
void UserAgentDlg::defaults()
{
- ui.sitePolicyTreeWidget->clear();
- m_ua_keys = DEFAULT_USER_AGENT_KEYS;
- ui.defaultIdLineEdit->setText( KProtocolManager::defaultUserAgent(m_ua_keys) );
- ui.osNameCheckBox->setChecked( m_ua_keys.contains('o') );
- ui.osVersionCheckBox->setChecked( m_ua_keys.contains('v') );
- ui.processorTypeCheckBox->setChecked( m_ua_keys.contains('m') );
- ui.languageCheckBox->setChecked( m_ua_keys.contains('l') );
- ui.sendUACheckBox->setChecked( true );
-
- updateButtons();
- configChanged();
+ ui.sitePolicyTreeWidget->clear();
+ m_ua_keys = DEFAULT_USER_AGENT_KEYS;
+ ui.defaultIdLineEdit->setText (KProtocolManager::defaultUserAgent (m_ua_keys));
+ ui.osNameCheckBox->setChecked (m_ua_keys.contains ('o'));
+ ui.osVersionCheckBox->setChecked (m_ua_keys.contains ('v'));
+ ui.processorTypeCheckBox->setChecked (m_ua_keys.contains ('m'));
+ ui.languageCheckBox->setChecked (m_ua_keys.contains ('l'));
+ ui.sendUACheckBox->setChecked (true);
+
+ updateButtons();
+ configChanged();
}
void UserAgentDlg::save()
{
- Q_ASSERT(m_config);
-
- // Put all the groups except the default into the delete list.
- QStringList deleteList = m_config->groupList();
-
- //Remove all the groups that DO NOT contain a "UserAgent" entry...
- QStringList::ConstIterator endIt = deleteList.constEnd();
- for (QStringList::ConstIterator it = deleteList.constBegin(); it != endIt; ++it)
- {
- if ( (*it) == QLatin1String("<default>") )
- continue;
-
- KConfigGroup cg(m_config, *it);
- if (!cg.hasKey("UserAgent"))
- deleteList.removeAll(*it);
- }
-
- QString domain;
- QTreeWidgetItem* item;
- int itemCount = ui.sitePolicyTreeWidget->topLevelItemCount();
-
- // Save and remove from the delete list all the groups that were
- // not deleted by the end user.
- for(int i = 0; i < itemCount; i++)
- {
- item = ui.sitePolicyTreeWidget->topLevelItem(i);
- domain = item->text(0);
- KConfigGroup cg(m_config, domain);
- cg.writeEntry("UserAgent", item->text(2));
- deleteList.removeAll(domain);
- qDebug("UserAgentDlg::save: Removed [%s] from delete list", \
domain.toLatin1().constData());
- }
-
- // Write the global configuration information...
- KConfigGroup cg(m_config, QString());
- cg.writeEntry("SendUserAgent", ui.sendUACheckBox->isChecked());
- cg.writeEntry("UserAgentKeys", m_ua_keys );
-
- // Sync up all the changes so far...
- m_config->sync();
-
- // If delete list is not empty, delete the specified domains.
- if (!deleteList.isEmpty())
- {
- // Remove entries from local file.
- endIt = deleteList.constEnd();
- KConfig cfg ("kio_httprc", KConfig::SimpleConfig);
-
- for ( QStringList::ConstIterator it = deleteList.constBegin(); it != endIt; ++it \
)
- {
- KConfigGroup cg(&cfg, *it);
- cg.deleteEntry("UserAgent");
- qDebug("UserAgentDlg::save: Deleting UserAgent of group [%s]", \
(*it).toLatin1().constData());
- if (cg.keyList().count() < 1)
- cg.deleteGroup();
+ Q_ASSERT (m_config);
+
+ // Put all the groups except the default into the delete list.
+ QStringList deleteList = m_config->groupList();
+
+ //Remove all the groups that DO NOT contain a "UserAgent" entry...
+ QStringList::ConstIterator endIt = deleteList.constEnd();
+ for (QStringList::ConstIterator it = deleteList.constBegin(); it != endIt; ++it) \
{ + if ( (*it) == QLatin1String ("<default>"))
+ continue;
+
+ KConfigGroup cg (m_config, *it);
+ if (!cg.hasKey ("UserAgent"))
+ deleteList.removeAll (*it);
}
- // Sync up the configuration...
- cfg.sync();
-
- // Check everything is gone, reset to blank otherwise.
- m_config->reparseConfiguration();
- endIt = deleteList.constEnd();
- for (QStringList::ConstIterator it = deleteList.constBegin(); it != endIt; ++it \
)
- {
- KConfigGroup cg(m_config, *it);
- if (cg.hasKey("UserAgent"))
- cg.writeEntry("UserAgent", QString());
+ QString domain;
+ QTreeWidgetItem* item;
+ int itemCount = ui.sitePolicyTreeWidget->topLevelItemCount();
+
+ // Save and remove from the delete list all the groups that were
+ // not deleted by the end user.
+ for (int i = 0; i < itemCount; i++) {
+ item = ui.sitePolicyTreeWidget->topLevelItem (i);
+ domain = item->text (0);
+ KConfigGroup cg (m_config, domain);
+ cg.writeEntry ("UserAgent", item->text (2));
+ deleteList.removeAll (domain);
+ qDebug ("UserAgentDlg::save: Removed [%s] from delete list", \
domain.toLatin1().constData()); }
- // Sync up the configuration...
+ // Write the global configuration information...
+ KConfigGroup cg (m_config, QString());
+ cg.writeEntry ("SendUserAgent", ui.sendUACheckBox->isChecked());
+ cg.writeEntry ("UserAgentKeys", m_ua_keys);
+
+ // Sync up all the changes so far...
m_config->sync();
- }
- KSaveIOConfig::updateRunningIOSlaves (this);
- configChanged( false );
+ // If delete list is not empty, delete the specified domains.
+ if (!deleteList.isEmpty()) {
+ // Remove entries from local file.
+ endIt = deleteList.constEnd();
+ KConfig cfg ("kio_httprc", KConfig::SimpleConfig);
+
+ for (QStringList::ConstIterator it = deleteList.constBegin(); it != endIt; \
++it) { + KConfigGroup cg (&cfg, *it);
+ cg.deleteEntry ("UserAgent");
+ qDebug ("UserAgentDlg::save: Deleting UserAgent of group [%s]", \
(*it).toLatin1().constData()); + if (cg.keyList().count() < 1)
+ cg.deleteGroup();
+ }
+
+ // Sync up the configuration...
+ cfg.sync();
+
+ // Check everything is gone, reset to blank otherwise.
+ m_config->reparseConfiguration();
+ endIt = deleteList.constEnd();
+ for (QStringList::ConstIterator it = deleteList.constBegin(); it != endIt; \
++it) { + KConfigGroup cg (m_config, *it);
+ if (cg.hasKey ("UserAgent"))
+ cg.writeEntry ("UserAgent", QString());
+ }
+
+ // Sync up the configuration...
+ m_config->sync();
+ }
+
+ KSaveIOConfig::updateRunningIOSlaves (this);
+ configChanged (false);
}
QString UserAgentDlg::quickHelp() const
{
- return i18n( "<p><h1>Browser Identification</h1> "
- "The browser-identification module allows you to have full "
- "control over how Konqueror will identify itself to web "
- "sites you browse.</p>"
- "<p>This ability to fake identification is necessary because "
- "some web sites do not display properly when they detect that "
- "they are not talking to current versions of either Netscape "
- "Navigator or Internet Explorer, even if the browser actually "
- "supports all the necessary features to render those pages "
- "properly. "
- "For such sites, you can use this feature to try to browse "
- "them. Please understand that this might not always work, since "
- "such sites might be using non-standard web protocols and or "
- "specifications.</p>"
- "<p><u>NOTE:</u> To obtain specific help on a particular section "
- "of the dialog box, simply click on the quick help button on "
- "the window title bar, then click on the section "
- "for which you are seeking help.</p>" );
+ return i18n ("<p><h1>Browser Identification</h1> "
+ "The browser-identification module allows you to have full "
+ "control over how Konqueror will identify itself to web "
+ "sites you browse.</p>"
+ "<p>This ability to fake identification is necessary because "
+ "some web sites do not display properly when they detect that "
+ "they are not talking to current versions of either Netscape "
+ "Navigator or Internet Explorer, even if the browser actually "
+ "supports all the necessary features to render those pages "
+ "properly. "
+ "For such sites, you can use this feature to try to browse "
+ "them. Please understand that this might not always work, since "
+ "such sites might be using non-standard web protocols and or "
+ "specifications.</p>"
+ "<p><u>NOTE:</u> To obtain specific help on a particular section "
+ "of the dialog box, simply click on the quick help button on "
+ "the window title bar, then click on the section "
+ "for which you are seeking help.</p>");
}
#include "useragentdlg.moc"
diff --git a/konqueror/settings/kio/useragentselectordlg.cpp \
b/konqueror/settings/kio/useragentselectordlg.cpp index 744bc62..b527c49 100644
--- a/konqueror/settings/kio/useragentselectordlg.cpp
+++ b/konqueror/settings/kio/useragentselectordlg.cpp
@@ -18,7 +18,6 @@
// Own
#include "useragentselectordlg.h"
-#include "ui_useragentselectordlg.h"
// Local
#include "useragentinfo.h"
@@ -40,131 +39,114 @@
#include <kurllabel.h>
-class UserAgentSelectorWidget : public QWidget, public Ui::UserAgentSelectorWidget
-{
-public:
- UserAgentSelectorWidget(QWidget * parent = 0, Qt::WindowFlags f = 0)
- :QWidget(parent, f)
- {
- setupUi(this);
- }
-};
-
class UserAgentSiteNameValidator : public QValidator
{
public:
- UserAgentSiteNameValidator(QObject *parent)
- :QValidator(parent)
- {
- setObjectName( QLatin1String("UserAgentSiteNameValidator" ));
- }
+ UserAgentSiteNameValidator (QObject* parent)
+ : QValidator (parent)
+ {
+ setObjectName (QLatin1String ("UserAgentSiteNameValidator"));
+ }
- State validate(QString &input, int &) const
- {
- if (input.isEmpty())
- return Intermediate;
+ State validate (QString& input, int&) const
+ {
+ if (input.isEmpty())
+ return Intermediate;
- if (input.startsWith(QChar('.')))
- return Invalid;
+ if (input.startsWith (QChar ('.')))
+ return Invalid;
- const int length = input.length();
+ const int length = input.length();
- for(int i = 0 ; i < length; i++)
- {
- if (!input[i].isLetterOrNumber() && input[i] != '.' && input[i] != '-')
- return Invalid;
- }
+ for (int i = 0 ; i < length; i++) {
+ if (!input[i].isLetterOrNumber() && input[i] != '.' && input[i] != '-')
+ return Invalid;
+ }
- return Acceptable;
- }
+ return Acceptable;
+ }
};
-UserAgentSelectorDlg::UserAgentSelectorDlg( const QString& caption, UserAgentInfo* \
info,
- QWidget *parent, Qt::WindowFlags f )
- :KDialog(parent, f),
- m_userAgentInfo(info)
+UserAgentSelectorDlg::UserAgentSelectorDlg (UserAgentInfo* info, QWidget* parent, \
Qt::WindowFlags f) + : KDialog (parent, f),
+ mUserAgentInfo (info)
{
- m_widget = new UserAgentSelectorWidget(this);
- setMainWidget(m_widget);
-
- setModal( true );
- setWindowTitle ( caption );
- setButtons( Ok|Cancel );
-
- if (!m_userAgentInfo)
- {
- setEnabled( false );
- return;
- }
-
- m_widget->aliasComboBox->clear();
- m_widget->aliasComboBox->addItems( m_userAgentInfo->userAgentAliasList() );
- m_widget->aliasComboBox->insertItem(0, QString());
- m_widget->aliasComboBox->model()->sort(0);
- m_widget->aliasComboBox->setCurrentIndex(0);
- UserAgentSiteNameValidator* validator = new UserAgentSiteNameValidator(this);
- m_widget->siteLineEdit->setValidator(validator);
- m_widget->siteLineEdit->setFocus();
-
- connect(m_widget->siteLineEdit, SIGNAL(textChanged(QString)),
- SLOT(onHostNameChanged(QString)));
-
- connect(m_widget->aliasComboBox, SIGNAL(activated(QString)),
- SLOT(onAliasChanged(QString)));
-
- enableButtonOk(false);
+ mUi.setupUi (mainWidget());
+
+ if (!mUserAgentInfo) {
+ setEnabled (false);
+ return;
+ }
+
+ mUi.aliasComboBox->clear();
+ mUi.aliasComboBox->addItems (mUserAgentInfo->userAgentAliasList());
+ mUi.aliasComboBox->insertItem (0, QString());
+ mUi.aliasComboBox->model()->sort (0);
+ mUi.aliasComboBox->setCurrentIndex (0);
+
+ UserAgentSiteNameValidator* validator = new UserAgentSiteNameValidator (this);
+ mUi.siteLineEdit->setValidator (validator);
+ mUi.siteLineEdit->setFocus();
+
+ connect (mUi.siteLineEdit, SIGNAL (textEdited (QString)),
+ SLOT (onHostNameChanged (QString)));
+ connect (mUi.aliasComboBox, SIGNAL (activated (QString)),
+ SLOT (onAliasChanged (QString)));
+
+ enableButtonOk (false);
}
UserAgentSelectorDlg::~UserAgentSelectorDlg()
{
}
-void UserAgentSelectorDlg::onAliasChanged( const QString& text )
+void UserAgentSelectorDlg::onAliasChanged (const QString& text)
{
- if ( text.isEmpty() )
- m_widget->identityLineEdit->setText( QString() );
- else
- m_widget->identityLineEdit->setText( m_userAgentInfo->agentStr(text) );
+ if (text.isEmpty())
+ mUi.identityLineEdit->setText (QString());
+ else
+ mUi.identityLineEdit->setText (mUserAgentInfo->agentStr (text));
- const bool enable = (!m_widget->siteLineEdit->text().isEmpty() && \
!text.isEmpty());
- enableButtonOk(enable);
+ const bool enable = (!mUi.siteLineEdit->text().isEmpty() && !text.isEmpty());
+ enableButtonOk (enable);
}
-void UserAgentSelectorDlg::onHostNameChanged( const QString& text )
+void UserAgentSelectorDlg::onHostNameChanged (const QString& text)
{
- const bool enable = (!text.isEmpty() && \
!m_widget->aliasComboBox->currentText().isEmpty());
- enableButtonOk(enable);
+ const bool enable = (!text.isEmpty() && \
!mUi.aliasComboBox->currentText().isEmpty()); + enableButtonOk (enable);
}
-void UserAgentSelectorDlg::setSiteName( const QString& text )
+void UserAgentSelectorDlg::setSiteName (const QString& text)
{
- m_widget->siteLineEdit->setText( text );
+ mUi.siteLineEdit->setText (text);
}
-void UserAgentSelectorDlg::setIdentity( const QString& text )
+void UserAgentSelectorDlg::setIdentity (const QString& text)
{
- int id = m_widget->aliasComboBox->findText( text );
- if ( id != -1 )
- m_widget->aliasComboBox->setCurrentIndex( id );
- m_widget->identityLineEdit->setText(m_userAgentInfo->agentStr(m_widget->aliasComboBox->currentText() \
));
- if ( !m_widget->siteLineEdit->isEnabled() )
- m_widget->aliasComboBox->setFocus();
+ const int id = mUi.aliasComboBox->findText (text);
+ if (id != -1)
+ mUi.aliasComboBox->setCurrentIndex (id);
+
+ mUi.identityLineEdit->setText (mUserAgentInfo->agentStr \
(mUi.aliasComboBox->currentText())); + if (!mUi.siteLineEdit->isEnabled())
+ mUi.aliasComboBox->setFocus();
}
QString UserAgentSelectorDlg::siteName()
{
- return m_widget->siteLineEdit->text().toLower();
+ return mUi.siteLineEdit->text().toLower();
}
QString UserAgentSelectorDlg::identity()
{
- return m_widget->aliasComboBox->currentText();
+ return mUi.aliasComboBox->currentText();
}
QString UserAgentSelectorDlg::alias()
{
- return m_widget->identityLineEdit->text();
+ return mUi.identityLineEdit->text();
}
#include "useragentselectordlg.moc"
diff --git a/konqueror/settings/kio/useragentselectordlg.h \
b/konqueror/settings/kio/useragentselectordlg.h index 6e33d0d..b27a81a 100644
--- a/konqueror/settings/kio/useragentselectordlg.h
+++ b/konqueror/settings/kio/useragentselectordlg.h
@@ -22,33 +22,33 @@
// KDE
#include <kdialog.h>
+#include "ui_useragentselectordlg.h"
+
// Forward declarations
class UserAgentInfo;
-class UserAgentSelectorWidget;
class UserAgentSelectorDlg : public KDialog
{
- Q_OBJECT
+ Q_OBJECT
public:
- explicit UserAgentSelectorDlg( const QString& caption, UserAgentInfo* info,
- QWidget *parent = 0, Qt::WindowFlags f = 0 );
- ~UserAgentSelectorDlg();
+ explicit UserAgentSelectorDlg (UserAgentInfo* info, QWidget* parent = 0, \
Qt::WindowFlags f = 0); + ~UserAgentSelectorDlg();
- void setSiteName( const QString& );
- void setIdentity( const QString& );
+ void setSiteName (const QString&);
+ void setIdentity (const QString&);
- QString siteName();
- QString identity();
- QString alias();
+ QString siteName();
+ QString identity();
+ QString alias();
protected Q_SLOTS:
- void onHostNameChanged( const QString& );
- void onAliasChanged( const QString& );
+ void onHostNameChanged (const QString&);
+ void onAliasChanged (const QString&);
private:
- UserAgentInfo* m_userAgentInfo;
- UserAgentSelectorWidget* m_widget;
+ UserAgentInfo* mUserAgentInfo;
+ Ui::UserAgentSelectorUI mUi;
};
#endif // USERAGENTSELECTORDLG_H
diff --git a/konqueror/settings/kio/useragentselectordlg.ui \
b/konqueror/settings/kio/useragentselectordlg.ui index d94dd65..8fef114 100644
--- a/konqueror/settings/kio/useragentselectordlg.ui
+++ b/konqueror/settings/kio/useragentselectordlg.ui
@@ -1,6 +1,6 @@
<ui version="4.0" >
- <class>UserAgentSelectorWidget</class>
- <widget class="QWidget" name="UserAgentSelectorWidget" >
+ <class>UserAgentSelectorUI</class>
+ <widget class="QWidget" name="UserAgentSelectorUI" >
<property name="geometry" >
<rect>
<x>0</x>
[prev in list] [next in list] [prev in thread] [next in thread]
Configure |
About |
News |
Add a list |
Sponsored by KoreLogic