diff --git a/src/kcms/kio/cache.cpp b/src/kcms/kio/cache.cpp index a5dc3bd8..39da7097 100644 --- a/src/kcms/kio/cache.cpp +++ b/src/kcms/kio/cache.cpp @@ -1,130 +1,135 @@ /* cache.cpp - Proxy configuration dialog Copyright (C) 2001,02,03 Dawit Alemayehu This library is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License (GPL) version 2 as published by the Free Software Foundation. This library 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 Library General Public License for more details. You should have received a copy of the GNU General Public License along with this library; see the file COPYING.LIB. If not, write to the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. */ // Own #include "cache.h" // Qt #include #include #include // KDE #include #include #include #include #include // Local #include "ksaveioconfig.h" K_PLUGIN_FACTORY_DECLARATION(KioConfigFactory) CacheConfigModule::CacheConfigModule(QWidget *parent, const QVariantList &) :KCModule(parent) { ui.setupUi(this); } CacheConfigModule::~CacheConfigModule() { } void CacheConfigModule::load() { ui.cbUseCache->setChecked(KProtocolManager::useCache()); ui.sbMaxCacheSize->setValue( KProtocolManager::maxCacheSize() ); KIO::CacheControl cc = KProtocolManager::cacheControl(); if (cc==KIO::CC_Verify) ui.rbVerifyCache->setChecked( true ); else if (cc==KIO::CC_Refresh) ui.rbVerifyCache->setChecked( true ); else if (cc==KIO::CC_CacheOnly) ui.rbOfflineMode->setChecked( true ); else if (cc==KIO::CC_Cache) ui.rbCacheIfPossible->setChecked( true ); // Config changed notifications... - connect ( ui.cbUseCache, SIGNAL(toggled(bool)), SLOT(configChanged()) ); - connect ( ui.rbVerifyCache, SIGNAL(toggled(bool)), SLOT(configChanged()) ); - connect ( ui.rbOfflineMode, SIGNAL(toggled(bool)), SLOT(configChanged()) ); - connect ( ui.rbCacheIfPossible, SIGNAL(toggled(bool)), SLOT(configChanged()) ); - connect ( ui.sbMaxCacheSize, SIGNAL(valueChanged(int)), SLOT(configChanged()) ); + connect(ui.cbUseCache, &QAbstractButton::toggled, + this, &CacheConfigModule::configChanged); + connect(ui.rbVerifyCache, &QAbstractButton::toggled, + this, &CacheConfigModule::configChanged); + connect(ui.rbOfflineMode, &QAbstractButton::toggled, + this, &CacheConfigModule::configChanged); + connect(ui.rbCacheIfPossible, &QAbstractButton::toggled, + this, &CacheConfigModule::configChanged); + connect(ui.sbMaxCacheSize, QOverload::of(&QSpinBox::valueChanged), + this, &CacheConfigModule::configChanged); emit changed( false ); } void CacheConfigModule::save() { KSaveIOConfig::setUseCache( ui.cbUseCache->isChecked() ); KSaveIOConfig::setMaxCacheSize( ui.sbMaxCacheSize->value() ); if ( !ui.cbUseCache->isChecked() ) KSaveIOConfig::setCacheControl(KIO::CC_Refresh); else if ( ui.rbVerifyCache->isChecked() ) KSaveIOConfig::setCacheControl(KIO::CC_Refresh); else if ( ui.rbOfflineMode->isChecked() ) KSaveIOConfig::setCacheControl(KIO::CC_CacheOnly); else if ( ui.rbCacheIfPossible->isChecked() ) KSaveIOConfig::setCacheControl(KIO::CC_Cache); KProtocolManager::reparseConfiguration(); // Update running io-slaves... KSaveIOConfig::updateRunningIOSlaves (this); emit changed( false ); } void CacheConfigModule::defaults() { ui.cbUseCache->setChecked( true ); ui.rbVerifyCache->setChecked( true ); ui.sbMaxCacheSize->setValue( DEFAULT_MAX_CACHE_SIZE ); } QString CacheConfigModule::quickHelp() const { return i18n( "

Cache

This module lets you configure your cache settings.

" "

This specific cache is an area on the disk where recently " "read web pages are stored. If you want to retrieve a web " "page again that you have recently read, it will not be " "downloaded from the Internet, but rather retrieved from the " "cache, which is a lot faster.

" ); } void CacheConfigModule::configChanged() { emit changed( true ); } void CacheConfigModule::on_clearCacheButton_clicked() { const QString exe = QFile::decodeName(CMAKE_INSTALL_FULL_LIBEXECDIR_KF5 "/kio_http_cache_cleaner"); if (QFile::exists(exe)) { QProcess::startDetached(exe, QStringList(QStringLiteral("--clear-all"))); } } diff --git a/src/kcms/kio/kcookiesmain.cpp b/src/kcms/kio/kcookiesmain.cpp index 55b94487..da900ff2 100644 --- a/src/kcms/kio/kcookiesmain.cpp +++ b/src/kcms/kio/kcookiesmain.cpp @@ -1,96 +1,98 @@ /* kcookiesmain.cpp - Cookies configuration * * First version of cookies configuration: * Copyright (C) Waldo Bastian * This dialog box: * Copyright (C) David Faure * */ // Own #include "kcookiesmain.h" // Local #include "kcookiespolicies.h" #include "kcookiesmanagement.h" // Qt #include // KDE #include #include #include K_PLUGIN_FACTORY_DECLARATION (KioConfigFactory) KCookiesMain::KCookiesMain (QWidget* parent, const QVariantList&) : KCModule (parent) { management = nullptr; bool managerOK = true; QVBoxLayout* layout = new QVBoxLayout (this); tab = new QTabWidget (this); layout->addWidget (tab); policies = new KCookiesPolicies (this); tab->addTab (policies, i18n ("&Policy")); - connect (policies, SIGNAL (changed(bool)), SIGNAL (changed(bool))); + connect(policies, QOverload::of(&KCModule::changed), + this, QOverload::of(&KCModule::changed)); if (managerOK) { management = new KCookiesManagement (this); tab->addTab (management, i18n ("&Management")); - connect (management, SIGNAL (changed(bool)), SIGNAL (changed(bool))); + connect(management, QOverload::of(&KCModule::changed), + this, QOverload::of(&KCModule::changed)); } } KCookiesMain::~KCookiesMain() { } void KCookiesMain::save() { policies->save(); if (management) management->save(); } void KCookiesMain::load() { policies->load(); if (management) management->load(); } void KCookiesMain::defaults() { KCModule* module = static_cast (tab->currentWidget()); if (module == policies) policies->defaults(); else if (management) management->defaults(); } QString KCookiesMain::quickHelp() const { return i18n ("

Cookies

Cookies contain information that KDE applications" " using the HTTP protocol (like Konqueror) store 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.

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.

" " Because most people want a compromise between privacy and the benefits cookies offer," " the HTTP kioslave offers you the ability to customize the way it handles cookies. So you might want" " to set the 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 a cookie is received.

"); } diff --git a/src/kcms/kio/kcookiesmanagement.cpp b/src/kcms/kio/kcookiesmanagement.cpp index ec81d591..e6edf133 100644 --- a/src/kcms/kio/kcookiesmanagement.cpp +++ b/src/kcms/kio/kcookiesmanagement.cpp @@ -1,430 +1,430 @@ /** * kcookiesmanagement.cpp - Cookies manager * * Copyright 2000-2001 Marco Pinelli * Copyright 2000-2001 Dawit Alemayehu * * 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 "kcookiesmanagement.h" // Qt #include #include #include #include #include #include // KDE #include #include #include #include #include #include #include #include #include // Local #include "kcookiesmain.h" #include "kcookiespolicies.h" QString tolerantFromAce(const QByteArray& _domain); struct CookieProp { QString host; QString name; QString value; QString domain; QString path; QString expireDate; QString secure; bool allLoaded; }; CookieListViewItem::CookieListViewItem(QTreeWidget *parent, const QString &dom) :QTreeWidgetItem(parent) { init( nullptr, dom ); } CookieListViewItem::CookieListViewItem(QTreeWidgetItem *parent, CookieProp *cookie) :QTreeWidgetItem(parent) { init( cookie ); } CookieListViewItem::~CookieListViewItem() { delete mCookie; } void CookieListViewItem::init( CookieProp* cookie, const QString &domain, bool cookieLoaded ) { mCookie = cookie; mDomain = domain; mCookiesLoaded = cookieLoaded; if (mCookie) { if (mDomain.isEmpty()) setText(0, tolerantFromAce(mCookie->host.toLatin1())); else setText(0, tolerantFromAce(mDomain.toLatin1())); setText(1, mCookie->name); } else { QString siteName; if (mDomain.startsWith(QLatin1Char('.'))) siteName = mDomain.mid(1); else siteName = mDomain; setText(0, tolerantFromAce(siteName.toLatin1())); } } CookieProp* CookieListViewItem::leaveCookie() { CookieProp *ret = mCookie; mCookie = nullptr; return ret; } KCookiesManagement::KCookiesManagement(QWidget *parent) : KCModule(parent), mDeleteAllFlag(false), mMainWidget(parent) { mUi.setupUi(this); mUi.searchLineEdit->setTreeWidget(mUi.cookiesTreeWidget); mUi.cookiesTreeWidget->setColumnWidth(0, 150); - connect(mUi.cookiesTreeWidget, SIGNAL(itemDoubleClicked(QTreeWidgetItem*,int)), SLOT(on_configPolicyButton_clicked())); + connect(mUi.cookiesTreeWidget, &QTreeWidget::itemDoubleClicked, this, &KCookiesManagement::on_configPolicyButton_clicked); } KCookiesManagement::~KCookiesManagement() { } void KCookiesManagement::load() { defaults(); } void KCookiesManagement::save() { // If delete all cookies was requested! if(mDeleteAllFlag) { QDBusInterface kded(QStringLiteral("org.kde.kcookiejar5"), QStringLiteral("/modules/kcookiejar"), QStringLiteral("org.kde.KCookieServer"), QDBusConnection::sessionBus()); QDBusReply reply = kded.call( QStringLiteral("deleteAllCookies") ); if (!reply.isValid()) { const QString caption = i18n ("D-Bus Communication Error"); const QString message = i18n ("Unable to delete all the cookies as requested."); KMessageBox::sorry (this, message, caption); return; } mDeleteAllFlag = false; // deleted[Cookies|Domains] have been cleared yet } // Certain groups of cookies were deleted... QMutableStringListIterator it (mDeletedDomains); while (it.hasNext()) { QDBusInterface kded(QStringLiteral("org.kde.kcookiejar5"), QStringLiteral("/modules/kcookiejar"), QStringLiteral("org.kde.KCookieServer"), QDBusConnection::sessionBus()); QDBusReply reply = kded.call( QStringLiteral("deleteCookiesFromDomain"),( it.next() ) ); if (!reply.isValid()) { const QString caption = i18n ("D-Bus Communication Error"); const QString message = i18n ("Unable to delete cookies as requested."); KMessageBox::sorry (this, message, caption); return; } it.remove(); } // Individual cookies were deleted... bool success = true; // Maybe we can go on... QMutableHashIterator cookiesDom(mDeletedCookies); while(cookiesDom.hasNext()) { cookiesDom.next(); CookiePropList list = cookiesDom.value(); foreach(CookieProp *cookie, list) { QDBusInterface kded(QStringLiteral("org.kde.kcookiejar5"), QStringLiteral("/modules/kcookiejar"), QStringLiteral("org.kde.KCookieServer"), QDBusConnection::sessionBus()); QDBusReply reply = kded.call( QStringLiteral("deleteCookie"), cookie->domain, cookie->host, cookie->path, cookie->name ); if (!reply.isValid()) { success = false; break; } list.removeOne(cookie); } if (!success) break; mDeletedCookies.remove(cookiesDom.key()); } emit changed( false ); } void KCookiesManagement::defaults() { reset(); on_reloadButton_clicked(); } void KCookiesManagement::reset(bool deleteAll) { if (!deleteAll) mDeleteAllFlag = false; clearCookieDetails(); mDeletedDomains.clear(); mDeletedCookies.clear(); mUi.cookiesTreeWidget->clear(); mUi.deleteButton->setEnabled(false); mUi.deleteAllButton->setEnabled(false); mUi.configPolicyButton->setEnabled(false); } void KCookiesManagement::clearCookieDetails() { mUi.nameLineEdit->clear(); mUi.valueLineEdit->clear(); mUi.domainLineEdit->clear(); mUi.pathLineEdit->clear(); mUi.expiresLineEdit->clear(); mUi.secureLineEdit->clear(); } QString KCookiesManagement::quickHelp() const { return i18n("

Cookie Management Quick Help

" ); } void KCookiesManagement::on_reloadButton_clicked() { QDBusInterface kded(QStringLiteral("org.kde.kcookiejar5"), QStringLiteral("/modules/kcookiejar"), QStringLiteral("org.kde.KCookieServer"), QDBusConnection::sessionBus()); QDBusReply reply = kded.call( QStringLiteral("findDomains") ); if (!reply.isValid()) { const QString caption = i18n ("Information Lookup Failure"); const QString message = i18n ("Unable to retrieve information about the " "cookies stored on your computer."); KMessageBox::sorry (this, message, caption); return; } if (mUi.cookiesTreeWidget->topLevelItemCount() > 0) reset(); CookieListViewItem *dom; const QStringList domains (reply.value()); Q_FOREACH(const QString& domain, domains) { const QString siteName = (domain.startsWith(QLatin1Char('.')) ? domain.mid(1) : domain); if (mUi.cookiesTreeWidget->findItems(siteName, Qt::MatchFixedString).isEmpty()) { dom = new CookieListViewItem(mUi.cookiesTreeWidget, domain); dom->setChildIndicatorPolicy(QTreeWidgetItem::ShowIndicator); } } // are there any cookies? mUi.deleteAllButton->setEnabled(mUi.cookiesTreeWidget->topLevelItemCount() > 0); mUi.cookiesTreeWidget->sortItems(0, Qt::AscendingOrder); emit changed(false); } Q_DECLARE_METATYPE( QList ) void KCookiesManagement::on_cookiesTreeWidget_itemExpanded(QTreeWidgetItem *item) { CookieListViewItem* cookieDom = static_cast(item); if (!cookieDom || cookieDom->cookiesLoaded()) return; QStringList cookies; QList fields; fields << 0 << 1 << 2 << 3; // Always check for cookies in both "foo.bar" and ".foo.bar" domains... const QString domain = cookieDom->domain() + QLatin1String(" .") + cookieDom->domain(); QDBusInterface kded(QStringLiteral("org.kde.kcookiejar5"), QStringLiteral("/modules/kcookiejar"), QStringLiteral("org.kde.KCookieServer"), QDBusConnection::sessionBus()); QDBusReply reply = kded.call(QStringLiteral("findCookies"), QVariant::fromValue(fields), domain, QString(), QString(), QString()); if (reply.isValid()) cookies.append(reply.value()); QStringListIterator it(cookies); while (it.hasNext()) { CookieProp *details = new CookieProp; details->domain = it.next(); details->path = it.next(); details->name = it.next(); details->host = it.next(); details->allLoaded = false; new CookieListViewItem(item, details); } if (!cookies.isEmpty()) { static_cast(item)->setCookiesLoaded(); mUi.searchLineEdit->updateSearch(); } } bool KCookiesManagement::cookieDetails(CookieProp *cookie) { QList fields; fields << 4 << 5 << 7; QDBusInterface kded(QStringLiteral("org.kde.kcookiejar5"), QStringLiteral("/modules/kcookiejar"), QStringLiteral("org.kde.KCookieServer"), QDBusConnection::sessionBus()); QDBusReply reply = kded.call( QStringLiteral("findCookies"), QVariant::fromValue( fields ), cookie->domain, cookie->host, cookie->path, cookie->name); if (!reply.isValid()) return false; const QStringList fieldVal = reply.value(); QStringList::const_iterator c = fieldVal.begin(); if (c == fieldVal.end()) // empty list, do not crash return false; bool ok; cookie->value = *c++; qint64 tmp = (*c++).toLongLong(&ok); if (!ok || tmp == 0) cookie->expireDate = i18n("End of session"); else { QDateTime expDate; expDate.setTime_t(tmp); cookie->expireDate = QLocale().toString((expDate), QLocale::ShortFormat); } tmp = (*c).toUInt(&ok); cookie->secure = i18n((ok && tmp) ? "Yes" : "No"); cookie->allLoaded = true; return true; } void KCookiesManagement::on_cookiesTreeWidget_currentItemChanged(QTreeWidgetItem* item) { if (item) { CookieListViewItem* cookieItem = static_cast(item); CookieProp *cookie = cookieItem->cookie(); if (cookie) { if (cookie->allLoaded || cookieDetails(cookie)) { mUi.nameLineEdit->setText(cookie->name); mUi.valueLineEdit->setText(cookie->value); mUi.domainLineEdit->setText(cookie->domain); mUi.pathLineEdit->setText(cookie->path); mUi.expiresLineEdit->setText(cookie->expireDate); mUi.secureLineEdit->setText(cookie->secure); } mUi.configPolicyButton->setEnabled(false); } else { clearCookieDetails(); mUi.configPolicyButton->setEnabled(true); } } else { mUi.configPolicyButton->setEnabled(false); } mUi.deleteButton->setEnabled(item != nullptr); } void KCookiesManagement::on_configPolicyButton_clicked() { // Get current item CookieListViewItem *item = static_cast(mUi.cookiesTreeWidget->currentItem()); Q_ASSERT(item); // the button is disabled otherwise if (item) { KCookiesMain* mainDlg = qobject_cast(mMainWidget); // must be present or something is really wrong. Q_ASSERT(mainDlg); KCookiesPolicies* policyDlg = mainDlg->policyDlg(); // must be present unless someone rewrote the widget in which case // this needs to be re-written as well. Q_ASSERT(policyDlg); policyDlg->setPolicy(item->domain()); } } void KCookiesManagement::on_deleteButton_clicked() { QTreeWidgetItem* currentItem = mUi.cookiesTreeWidget->currentItem(); Q_ASSERT(currentItem); // the button is disabled otherwise CookieListViewItem *item = static_cast( currentItem ); if (item->cookie()) { CookieListViewItem *parent = static_cast(item->parent()); CookiePropList list = mDeletedCookies.value(parent->domain()); list.append(item->leaveCookie()); mDeletedCookies.insert(parent->domain(), list); delete item; if (parent->childCount() == 0) delete parent; } else { mDeletedDomains.append(item->domain()); delete item; } currentItem = mUi.cookiesTreeWidget->currentItem(); if (currentItem) { mUi.cookiesTreeWidget->setCurrentItem( currentItem ); } else clearCookieDetails(); mUi.deleteAllButton->setEnabled(mUi.cookiesTreeWidget->topLevelItemCount() > 0); emit changed( true ); } void KCookiesManagement::on_deleteAllButton_clicked() { mDeleteAllFlag = true; reset(true); emit changed(true); } diff --git a/src/kcms/kio/kcookiespolicies.cpp b/src/kcms/kio/kcookiespolicies.cpp index 70cebd8e..95438625 100644 --- a/src/kcms/kio/kcookiespolicies.cpp +++ b/src/kcms/kio/kcookiespolicies.cpp @@ -1,458 +1,458 @@ /** * kcookiespolicies.cpp - Cookies configuration * * Original Authors * Copyright (c) Waldo Bastian * Copyright (c) 1999 David Faure * Copyright (c) 2008 Urs Wolfer * * Re-written by: * Copyright (c) 2000- Dawit Alemayehu * * 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 "kcookiespolicies.h" // Local #include "ksaveioconfig.h" // Qt #include #include #include #include // KDE #include #include #include #include #include #include // QUrl::fromAce/toAce don't accept a domain that starts with a '.', like we do here. // So we use these wrappers. QString tolerantFromAce (const QByteArray& _domain) { QByteArray domain (_domain); const bool hasDot = domain.startsWith ('.'); if (hasDot) domain.remove (0, 1); QString ret = QUrl::fromAce(domain); if (hasDot) { ret.prepend(QLatin1Char('.')); } return ret; } static QByteArray tolerantToAce (const QString& _domain) { QString domain (_domain); const bool hasDot = domain.startsWith(QLatin1Char('.')); if (hasDot) domain.remove (0, 1); QByteArray ret = QUrl::toAce (domain); if (hasDot) { ret.prepend ('.'); } return ret; } KCookiesPolicies::KCookiesPolicies (QWidget* parent) : KCModule (parent), mSelectedItemsCount(0) { mUi.setupUi (this); mUi.kListViewSearchLine->setTreeWidget (mUi.policyTreeWidget); QList columns; columns.append (0); mUi.kListViewSearchLine->setSearchColumns (columns); mUi.pbNew->setIcon (QIcon::fromTheme(QStringLiteral("list-add"))); mUi.pbChange->setIcon (QIcon::fromTheme(QStringLiteral("edit-rename"))); mUi.pbDelete->setIcon (QIcon::fromTheme(QStringLiteral("list-remove"))); mUi.pbDeleteAll->setIcon (QIcon::fromTheme(QStringLiteral("edit-delete"))); // Connect the main swicth :) Enable/disable cookie support - connect (mUi.cbEnableCookies, SIGNAL (toggled(bool)), - SLOT (cookiesEnabled(bool))); - connect (mUi.cbEnableCookies, SIGNAL (toggled(bool)), - SLOT (configChanged())); + connect (mUi.cbEnableCookies, &QAbstractButton::toggled, + this, &KCookiesPolicies::cookiesEnabled); + connect (mUi.cbEnableCookies, &QAbstractButton::toggled, + this, &KCookiesPolicies::configChanged); // Connect the preference check boxes... - connect (mUi.cbRejectCrossDomainCookies, SIGNAL (toggled(bool)), - SLOT (configChanged())); - connect (mUi.cbAutoAcceptSessionCookies, SIGNAL (toggled(bool)), - SLOT (configChanged())); - - connect (mUi.rbPolicyAsk, SIGNAL (toggled(bool)), - SLOT (configChanged())); - connect (mUi.rbPolicyAccept, SIGNAL (toggled(bool)), - SLOT (configChanged())); - connect (mUi.rbPolicyAcceptForSession, SIGNAL(toggled(bool)), - SLOT(configChanged())); - connect (mUi.rbPolicyReject, SIGNAL (toggled(bool)), - SLOT (configChanged())); + connect (mUi.cbRejectCrossDomainCookies, &QAbstractButton::toggled, + this, &KCookiesPolicies::configChanged); + connect (mUi.cbAutoAcceptSessionCookies, &QAbstractButton::toggled, + this, &KCookiesPolicies::configChanged); + + connect (mUi.rbPolicyAsk, &QAbstractButton::toggled, + this, &KCookiesPolicies::configChanged); + connect (mUi.rbPolicyAccept, &QAbstractButton::toggled, + this, &KCookiesPolicies::configChanged); + connect (mUi.rbPolicyAcceptForSession, &QAbstractButton::toggled, + this, &KCookiesPolicies::configChanged); + connect (mUi.rbPolicyReject, &QAbstractButton::toggled, + this, &KCookiesPolicies::configChanged); // Connect signals from the domain specific policy listview. - connect (mUi.policyTreeWidget, SIGNAL (itemSelectionChanged()), - SLOT (selectionChanged())); - connect (mUi.policyTreeWidget, SIGNAL (itemDoubleClicked(QTreeWidgetItem*,int)), - SLOT (changePressed())); + connect (mUi.policyTreeWidget, &QTreeWidget::itemSelectionChanged, + this, &KCookiesPolicies::selectionChanged); + connect (mUi.policyTreeWidget, &QTreeWidget::itemDoubleClicked, + this, QOverload<>::of(&KCookiesPolicies::changePressed)); // Connect the buttons... - connect (mUi.pbNew, SIGNAL (clicked()), SLOT (addPressed())); - connect (mUi.pbChange, SIGNAL (clicked()), SLOT (changePressed())); - connect (mUi.pbDelete, SIGNAL (clicked()), SLOT (deletePressed())); - connect (mUi.pbDeleteAll, SIGNAL (clicked()), SLOT (deleteAllPressed())); + connect(mUi.pbNew, &QAbstractButton::clicked, this, QOverload<>::of(&KCookiesPolicies::addPressed)); + connect(mUi.pbChange, &QAbstractButton::clicked, this, QOverload<>::of(&KCookiesPolicies::changePressed)); + connect(mUi.pbDelete, &QAbstractButton::clicked, this, &KCookiesPolicies::deletePressed); + connect(mUi.pbDeleteAll, &QAbstractButton::clicked, this, &KCookiesPolicies::deleteAllPressed); } KCookiesPolicies::~KCookiesPolicies() { } void KCookiesPolicies::configChanged () { //kDebug() << "KCookiesPolicies::configChanged..."; emit changed (true); } void KCookiesPolicies::cookiesEnabled (bool enable) { mUi.bgDefault->setEnabled (enable); mUi.bgPreferences->setEnabled (enable); mUi.gbDomainSpecific->setEnabled (enable); } void KCookiesPolicies::setPolicy (const QString& domain) { QTreeWidgetItemIterator it (mUi.policyTreeWidget); bool hasExistingPolicy = false; while (*it) { if ((*it)->text(0) == domain) { hasExistingPolicy = true; break; } ++it; } if (hasExistingPolicy) { changePressed((*it), false); } else { addPressed(domain); } } void KCookiesPolicies::changePressed() { changePressed(mUi.policyTreeWidget->currentItem()); } void KCookiesPolicies::addPressed() { addPressed(QString()); } void KCookiesPolicies::changePressed(QTreeWidgetItem* item, bool state) { Q_ASSERT(item); const QString oldDomain(item->text (0)); KCookiesPolicySelectionDlg pdlg (this); pdlg.setWindowTitle (i18nc ("@title:window", "Change Cookie Policy")); pdlg.setPolicy (KCookieAdvice::strToAdvice (mDomainPolicyMap.value(oldDomain))); pdlg.setEnableHostEdit (state, oldDomain); if (pdlg.exec() && !pdlg.domain().isEmpty()) { const QString newDomain = tolerantFromAce (pdlg.domain().toLatin1()); int advice = pdlg.advice(); if (newDomain == oldDomain || !handleDuplicate (newDomain, advice)) { mDomainPolicyMap[newDomain] = KCookieAdvice::adviceToStr(advice); item->setText(0, newDomain); item->setText(1, i18n (mDomainPolicyMap.value(newDomain))); configChanged(); } } } void KCookiesPolicies::addPressed(const QString& domain, bool state) { KCookiesPolicySelectionDlg pdlg (this); pdlg.setWindowTitle (i18nc ("@title:window", "New Cookie Policy")); pdlg.setEnableHostEdit(state, domain); if (mUi.rbPolicyAccept->isChecked()) pdlg.setPolicy (KCookieAdvice::Reject); else pdlg.setPolicy (KCookieAdvice::Accept); if (pdlg.exec() && !pdlg.domain().isEmpty()) { const QString domain = tolerantFromAce (pdlg.domain().toLatin1()); int advice = pdlg.advice(); if (!handleDuplicate (domain, advice)) { const char* strAdvice = KCookieAdvice::adviceToStr (advice); QTreeWidgetItem* item = new QTreeWidgetItem (mUi.policyTreeWidget, QStringList() << domain << i18n (strAdvice)); mDomainPolicyMap.insert (item->text(0), strAdvice); configChanged(); updateButtons(); } } } bool KCookiesPolicies::handleDuplicate (const QString& domain, int advice) { QTreeWidgetItem* item = mUi.policyTreeWidget->topLevelItem (0); while (item != nullptr) { if (item->text (0) == domain) { const int res = KMessageBox::warningContinueCancel (this, i18n ("A policy already exists for" "
%1
" "Do you want to replace it?
", domain), i18nc ("@title:window", "Duplicate Policy"), KGuiItem (i18n ("Replace"))); if (res == KMessageBox::Continue) { mDomainPolicyMap[domain] = KCookieAdvice::adviceToStr(advice); item->setText (0, domain); item->setText (1, i18n (mDomainPolicyMap.value(domain))); configChanged(); return true; } else return true; // User Cancelled!! } item = mUi.policyTreeWidget->itemBelow (item); } return false; } void KCookiesPolicies::deletePressed() { QTreeWidgetItem* nextItem = nullptr; Q_FOREACH (QTreeWidgetItem * item, mUi.policyTreeWidget->selectedItems()) { nextItem = mUi.policyTreeWidget->itemBelow (item); if (!nextItem) nextItem = mUi.policyTreeWidget->itemAbove (item); mDomainPolicyMap.remove (item->text(0)); delete item; } if (nextItem) nextItem->setSelected (true); updateButtons(); configChanged(); } void KCookiesPolicies::deleteAllPressed() { mDomainPolicyMap.clear(); mUi.policyTreeWidget->clear(); updateButtons(); configChanged(); } void KCookiesPolicies::updateButtons() { bool hasItems = mUi.policyTreeWidget->topLevelItemCount() > 0; mUi.pbChange->setEnabled((hasItems && mSelectedItemsCount == 1)); mUi.pbDelete->setEnabled((hasItems && mSelectedItemsCount > 0)); mUi.pbDeleteAll->setEnabled(hasItems); } void KCookiesPolicies::updateDomainList (const QStringList& domainConfig) { mUi.policyTreeWidget->clear(); QStringList::ConstIterator it = domainConfig.begin(); for (; it != domainConfig.end(); ++it) { QString domain; KCookieAdvice::Value advice = KCookieAdvice::Dunno; splitDomainAdvice (*it, domain, advice); if (!domain.isEmpty()) { QStringList items; items << tolerantFromAce(domain.toLatin1()) << i18n(KCookieAdvice::adviceToStr(advice)); QTreeWidgetItem* item = new QTreeWidgetItem (mUi.policyTreeWidget, items); mDomainPolicyMap[item->text(0)] = KCookieAdvice::adviceToStr(advice); } } mUi.policyTreeWidget->sortItems(0, Qt::AscendingOrder); } void KCookiesPolicies::selectionChanged () { mSelectedItemsCount = mUi.policyTreeWidget->selectedItems().count(); updateButtons (); } void KCookiesPolicies::load() { mSelectedItemsCount = 0; KConfig cfg (QStringLiteral("kcookiejarrc")); KConfigGroup group = cfg.group ("Cookie Policy"); bool enableCookies = group.readEntry ("Cookies", true); mUi.cbEnableCookies->setChecked (enableCookies); cookiesEnabled (enableCookies); // Warning: the default values are duplicated in kcookiejar.cpp KCookieAdvice::Value advice = KCookieAdvice::strToAdvice (group.readEntry ( "CookieGlobalAdvice", "Accept")); switch (advice) { case KCookieAdvice::Accept: mUi.rbPolicyAccept->setChecked (true); break; case KCookieAdvice::AcceptForSession: mUi.rbPolicyAcceptForSession->setChecked (true); break; case KCookieAdvice::Reject: mUi.rbPolicyReject->setChecked (true); break; case KCookieAdvice::Ask: case KCookieAdvice::Dunno: default: mUi.rbPolicyAsk->setChecked (true); } bool enable = group.readEntry ("RejectCrossDomainCookies", true); mUi.cbRejectCrossDomainCookies->setChecked (enable); bool sessionCookies = group.readEntry ("AcceptSessionCookies", true); mUi.cbAutoAcceptSessionCookies->setChecked (sessionCookies); updateDomainList (group.readEntry ("CookieDomainAdvice", QStringList())); if (enableCookies) { updateButtons(); } } void KCookiesPolicies::save() { KConfig cfg (QStringLiteral("kcookiejarrc")); KConfigGroup group = cfg.group ("Cookie Policy"); bool state = mUi.cbEnableCookies->isChecked(); group.writeEntry ("Cookies", state); state = mUi.cbRejectCrossDomainCookies->isChecked(); group.writeEntry ("RejectCrossDomainCookies", state); state = mUi.cbAutoAcceptSessionCookies->isChecked(); group.writeEntry ("AcceptSessionCookies", state); QString advice; if (mUi.rbPolicyAccept->isChecked()) advice = KCookieAdvice::adviceToStr (KCookieAdvice::Accept); else if (mUi.rbPolicyAcceptForSession->isChecked()) advice = KCookieAdvice::adviceToStr (KCookieAdvice::AcceptForSession); else if (mUi.rbPolicyReject->isChecked()) advice = KCookieAdvice::adviceToStr (KCookieAdvice::Reject); else advice = KCookieAdvice::adviceToStr (KCookieAdvice::Ask); group.writeEntry ("CookieGlobalAdvice", advice); QStringList domainConfig; QMapIterator it (mDomainPolicyMap); while (it.hasNext()) { it.next(); QString policy = tolerantToAce(it.key()); policy += QLatin1Char (':'); policy += QLatin1String (it.value()); domainConfig << policy; } group.writeEntry ("CookieDomainAdvice", domainConfig); group.sync(); // Update the cookiejar... if (!mUi.cbEnableCookies->isChecked()) { QDBusInterface kded (QStringLiteral("org.kde.kcookiejar5"), QStringLiteral("/modules/kcookiejar"), QStringLiteral("org.kde.KCookieServer"), QDBusConnection::sessionBus()); kded.call (QStringLiteral("shutdown")); } else { QDBusInterface kded (QStringLiteral("org.kde.kcookiejar5"), QStringLiteral("/modules/kcookiejar"), QStringLiteral("org.kde.KCookieServer"), QDBusConnection::sessionBus()); QDBusReply reply = kded.call (QStringLiteral("reloadPolicy")); if (!reply.isValid()) KMessageBox::sorry (nullptr, i18n ("Unable to communicate with the cookie handler service.\n" "Any changes you made will not take effect until the service " "is restarted.")); } // Force running io-slave to reload configurations... KSaveIOConfig::updateRunningIOSlaves (this); emit changed (false); } void KCookiesPolicies::defaults() { mUi.cbEnableCookies->setChecked (true); mUi.rbPolicyAsk->setChecked (true); mUi.rbPolicyAccept->setChecked (false); mUi.rbPolicyAcceptForSession->setChecked (false); mUi.rbPolicyReject->setChecked (false); mUi.cbRejectCrossDomainCookies->setChecked (true); mUi.cbAutoAcceptSessionCookies->setChecked (false); mUi.policyTreeWidget->clear(); mDomainPolicyMap.clear(); cookiesEnabled (mUi.cbEnableCookies->isChecked()); updateButtons(); } void KCookiesPolicies::splitDomainAdvice (const QString& cfg, QString& domain, KCookieAdvice::Value& advice) { int sepPos = cfg.lastIndexOf(QLatin1Char(':')); // Ignore any policy that does not contain a domain... if (sepPos <= 0) return; domain = cfg.left (sepPos); advice = KCookieAdvice::strToAdvice (cfg.mid (sepPos + 1)); } QString KCookiesPolicies::quickHelp() const { return i18n ("

Cookies

Cookies contain information that KDE" " application using the HTTP protocol (like Konqueror) stores" " on your computer from 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.

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.

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. You might, for example" " want to set KDE's default policy to ask you whenever a server" " wants to set a cookie or simply reject or accept everything." " For example, you might choose to accept all cookies from your" " favorite shopping web site. For this all you have to do is" " either browse to that particular site and when you are presented" " with the cookie dialog box, click on This domain under" " the 'apply to' tab and choose accept or simply specify the name" " of the site in the Domain Specific Policy tab and set" " it to accept. This enables you to receive cookies from trusted" " web sites without being asked every time KDE receives a cookie.

" ); } diff --git a/src/kcms/kio/kcookiespolicyselectiondlg.cpp b/src/kcms/kio/kcookiespolicyselectiondlg.cpp index 8af2dbef..766bd6d1 100644 --- a/src/kcms/kio/kcookiespolicyselectiondlg.cpp +++ b/src/kcms/kio/kcookiespolicyselectiondlg.cpp @@ -1,139 +1,139 @@ /** * Copyright (c) 2000- Dawit Alemayehu * * 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 #include #include #include // KDE #include #include #include #include class DomainNameValidator : public QValidator { Q_OBJECT public: DomainNameValidator (QObject* parent) :QValidator(parent) { setObjectName(QStringLiteral("domainValidator")); } State validate (QString& input, int&) const override { if (input.isEmpty() || (input == QLatin1String("."))) { return Intermediate; } const int length = input.length(); for (int i = 0 ; i < length; i++) { if (!input[i].isLetterOrNumber() && input[i] != QLatin1Char('.') && input[i] != QLatin1Char('-')) { return Invalid; } } return Acceptable; } }; KCookiesPolicySelectionDlg::KCookiesPolicySelectionDlg (QWidget* parent, Qt::WindowFlags flags) : QDialog (parent, flags) , mOldPolicy(-1) , mButtonBox(nullptr) { QWidget *mainWidget = new QWidget(this); QVBoxLayout *mainLayout = new QVBoxLayout(this); mainLayout->addWidget(mainWidget); mUi.setupUi(mainWidget); mUi.leDomain->setValidator(new DomainNameValidator (mUi.leDomain)); mUi.cbPolicy->setMinimumWidth(mUi.cbPolicy->fontMetrics().maxWidth() * 15); mButtonBox = new QDialogButtonBox(QDialogButtonBox::Ok | QDialogButtonBox::Cancel, this); mainLayout->addWidget(mButtonBox); connect(mButtonBox, &QDialogButtonBox::accepted, this, &QDialog::accept); connect(mButtonBox, &QDialogButtonBox::rejected, this, &QDialog::reject); mButtonBox->button(QDialogButtonBox::Ok)->setEnabled(false); - connect(mUi.leDomain, SIGNAL(textEdited(QString)), - SLOT(slotTextChanged(QString))); - connect(mUi.cbPolicy, SIGNAL(currentIndexChanged(QString)), - SLOT(slotPolicyChanged(QString))); + connect(mUi.leDomain, &QLineEdit::textEdited, + this, &KCookiesPolicySelectionDlg::slotTextChanged); + connect(mUi.cbPolicy, QOverload::of(&QComboBox::currentIndexChanged), + this, &KCookiesPolicySelectionDlg::slotPolicyChanged); mUi.leDomain->setFocus(); } void KCookiesPolicySelectionDlg::setEnableHostEdit (bool state, const QString& host) { if (!host.isEmpty()) { mUi.leDomain->setText (host); mButtonBox->button(QDialogButtonBox::Ok)->setEnabled(state); } mUi.leDomain->setEnabled (state); } void KCookiesPolicySelectionDlg::setPolicy (int policy) { if (policy > -1 && policy <= static_cast (mUi.cbPolicy->count())) { const bool blocked = mUi.cbPolicy->blockSignals(true); mUi.cbPolicy->setCurrentIndex (policy - 1); mUi.cbPolicy->blockSignals(blocked); mOldPolicy = policy; } 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) { mButtonBox->button(QDialogButtonBox::Ok)->setEnabled (text.length() > 1); } void KCookiesPolicySelectionDlg::slotPolicyChanged(const QString& policyText) { const int policy = KCookieAdvice::strToAdvice(policyText); if (!mUi.leDomain->isEnabled()) { mButtonBox->button(QDialogButtonBox::Ok)->setEnabled(policy != mOldPolicy); } else { slotTextChanged(policyText); } } #include "kcookiespolicyselectiondlg.moc" diff --git a/src/kcms/kio/kproxydlg.cpp b/src/kcms/kio/kproxydlg.cpp index f6f40d1d..a1421980 100644 --- a/src/kcms/kio/kproxydlg.cpp +++ b/src/kcms/kio/kproxydlg.cpp @@ -1,571 +1,571 @@ /* kproxydlg.cpp - Proxy configuration dialog Copyright (C) 2001, 2011 Dawit Alemayehu This library is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License (GPL) version 2 as published by the Free Software Foundation. This library 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 Library General Public License for more details. You should have received a copy of the GNU General Public License along with this library; see the file COPYING.LIB. If not, write to the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. */ // Own #include "kproxydlg.h" // Local #include "ksaveioconfig.h" // KDE #include #include #include #include #include // Qt #include #include #define QL1C(x) QLatin1Char(x) #define QL1S(x) QLatin1String(x) #define ENV_HTTP_PROXY QStringLiteral("HTTP_PROXY,http_proxy,HTTPPROXY,httpproxy,PROXY,proxy") #define ENV_HTTPS_PROXY QStringLiteral("HTTPS_PROXY,https_proxy,HTTPSPROXY,httpsproxy,PROXY,proxy") #define ENV_FTP_PROXY QStringLiteral("FTP_PROXY,ftp_proxy,FTPPROXY,ftpproxy,PROXY,proxy") #define ENV_SOCKS_PROXY QStringLiteral("SOCKS_PROXY,socks_proxy,SOCKSPROXY,socksproxy,PROXY,proxy") #define ENV_NO_PROXY QStringLiteral("NO_PROXY,no_proxy") K_PLUGIN_FACTORY_DECLARATION (KioConfigFactory) class InputValidator : public QValidator { public: State validate(QString& input, int& pos) const override { if (input.isEmpty()) return Acceptable; const QChar ch = input.at((pos > 0 ? pos - 1 : pos)); if (ch.isSpace()) return Invalid; return Acceptable; } }; static QString manualProxyToText(const QLineEdit* edit, const QSpinBox* spinBox, const QChar& separator) { QString value; value = edit->text(); value += separator; value += QString::number(spinBox->value()); return value; } static void setManualProxyFromText(const QString& value, QLineEdit* edit, QSpinBox* spinBox) { if (value.isEmpty()) return; const QStringList values = value.split(QLatin1Char(' ')); edit->setText(values.at(0)); bool ok = false; const int num = values.at(1).toInt(&ok); if (ok) { spinBox->setValue(num); } } static void showSystemProxyUrl(QLineEdit* edit, QString* value) { Q_ASSERT(edit); Q_ASSERT(value); *value = edit->text(); edit->setEnabled(false); const QByteArray envVar(edit->text().toUtf8()); edit->setText(QString::fromUtf8(qgetenv(envVar.constData()))); } static QString proxyUrlFromInput(KProxyDialog::DisplayUrlFlags* flags, const QLineEdit* edit, const QSpinBox* spinBox, const QString& defaultScheme = QString(), KProxyDialog::DisplayUrlFlag flag = KProxyDialog::HideNone) { Q_ASSERT(edit); Q_ASSERT(spinBox); QString proxyStr; if (edit->text().isEmpty()) return proxyStr; if (flags && !edit->text().contains(QL1S("://"))) { *flags |= flag; } KUriFilterData data; data.setData(edit->text()); data.setCheckForExecutables(false); if (!defaultScheme.isEmpty()) { data.setDefaultUrlScheme(defaultScheme); } if (KUriFilter::self()->filterUri(data, QStringList() << QStringLiteral("kshorturifilter"))) { QUrl url = data.uri(); const int portNum = (spinBox->value() > 0 ? spinBox->value() : url.port()); url.setPort(-1); proxyStr = url.url(); if (portNum > -1) { proxyStr += QL1C(' '); proxyStr += QString::number(portNum); } } else { proxyStr = edit->text(); if (spinBox->value() > 0) { proxyStr += QL1C(' '); proxyStr += QString::number(spinBox->value()); } } return proxyStr; } static void setProxyInformation(const QString& value, int proxyType, QLineEdit* manEdit, QLineEdit* sysEdit, QSpinBox* spinBox , const QString& defaultScheme, KProxyDialog::DisplayUrlFlag flag) { const bool isSysProxy = (!value.contains(QL1C(' ')) && !value.contains(QL1C('.')) && !value.contains(QL1C(',')) && !value.contains(QL1C(':'))); if (proxyType == KProtocolManager::EnvVarProxy || isSysProxy) { #if defined(Q_OS_LINUX) || defined (Q_OS_UNIX) sysEdit->setText(value); #endif return; } if (spinBox) { QString urlStr; int portNum = -1; int index = value.lastIndexOf(QL1C(' ')); if (index > 0) { bool ok = false; portNum = value.midRef(index+1).toInt(&ok); if (!ok) { portNum = -1; } urlStr = value.left(index).trimmed(); } else { urlStr = value.trimmed(); } KUriFilterData data; data.setData(urlStr); data.setCheckForExecutables(false); if (!defaultScheme.isEmpty()) { data.setDefaultUrlScheme(defaultScheme); } if (KUriFilter::self()->filterUri(data, QStringList() << QStringLiteral("kshorturifilter"))) { QUrl url (data.uri()); if (portNum == -1 && url.port() > -1) { portNum = url.port(); } url.setPort(-1); url.setUserName(QString()); url.setPassword(QString()); url.setPath(QString()); manEdit->setText(((KSaveIOConfig::proxyDisplayUrlFlags() & flag) ? url.host(): url.url())); } else { QUrl url(urlStr); if (portNum == -1 && url.port() > -1) { portNum = url.port(); } url.setPort(-1); manEdit->setText((KSaveIOConfig::proxyDisplayUrlFlags() & flag) ? url.host() : urlStr); } if (spinBox && portNum > -1) { spinBox->setValue(portNum); } return; } manEdit->setText(value); // Manual proxy exception... } KProxyDialog::KProxyDialog(QWidget* parent, const QVariantList& args) : KCModule(/*KioConfigFactory::componentData(),*/ parent) { Q_UNUSED(args); mUi.setupUi(this); mUi.systemProxyGroupBox->setVisible(false); mUi.manualProxyGroupBox->setVisible(false); mUi.autoDetectButton->setVisible(false); mUi.proxyConfigScriptGroupBox->setVisible(false); InputValidator* v = new InputValidator; mUi.proxyScriptUrlRequester->lineEdit()->setValidator(v); mUi.manualProxyHttpEdit->setValidator(v); mUi.manualProxyHttpsEdit->setValidator(v); mUi.manualProxyFtpEdit->setValidator(v); mUi.manualProxySocksEdit->setValidator(v); mUi.manualNoProxyEdit->setValidator(v); #if defined(Q_OS_LINUX) || defined (Q_OS_UNIX) - connect(mUi.systemProxyRadioButton, SIGNAL(toggled(bool)), mUi.systemProxyGroupBox, SLOT(setVisible(bool))); + connect(mUi.systemProxyRadioButton, &QAbstractButton::toggled, mUi.systemProxyGroupBox, &QWidget::setVisible); #else mUi.autoDetectButton->setVisible(false); connect(mUi.systemProxyRadioButton, SIGNAL(clicked()), SLOT(slotChanged())); #endif // signals and slots connections - connect(mUi.noProxyRadioButton, SIGNAL(clicked()), SLOT(slotChanged())); - connect(mUi.autoDiscoverProxyRadioButton, SIGNAL(clicked()), SLOT(slotChanged())); - connect(mUi.autoScriptProxyRadioButton, SIGNAL(clicked()), SLOT(slotChanged())); - connect(mUi.manualProxyRadioButton, SIGNAL(clicked()), SLOT(slotChanged())); - connect(mUi.systemProxyRadioButton, SIGNAL(clicked()), SLOT(slotChanged())); - connect(mUi.noProxyRadioButton, SIGNAL(clicked()), SLOT(slotChanged())); - connect(mUi.useReverseProxyCheckBox, SIGNAL(clicked()), SLOT(slotChanged())); - connect(mUi.useSameProxyCheckBox, SIGNAL(clicked()), SLOT(slotChanged())); - - connect(mUi.proxyScriptUrlRequester, SIGNAL(textChanged(QString)), SLOT(slotChanged())); - - connect(mUi.manualProxyHttpEdit, SIGNAL(textChanged(QString)), SLOT(slotChanged())); - connect(mUi.manualProxyHttpsEdit, SIGNAL(textChanged(QString)), SLOT(slotChanged())); - connect(mUi.manualProxyFtpEdit, SIGNAL(textChanged(QString)), SLOT(slotChanged())); - connect(mUi.manualProxySocksEdit, SIGNAL(textChanged(QString)), SLOT(slotChanged())); - connect(mUi.manualNoProxyEdit, SIGNAL(textChanged(QString)), SLOT(slotChanged())); - - connect(mUi.manualProxyHttpSpinBox, SIGNAL(valueChanged(int)), SLOT(slotChanged())); - connect(mUi.manualProxyHttpsSpinBox, SIGNAL(valueChanged(int)), SLOT(slotChanged())); - connect(mUi.manualProxyFtpSpinBox, SIGNAL(valueChanged(int)), SLOT(slotChanged())); - connect(mUi.manualProxySocksSpinBox, SIGNAL(valueChanged(int)), SLOT(slotChanged())); - - connect(mUi.systemProxyHttpEdit, SIGNAL(textEdited(QString)), SLOT(slotChanged())); - connect(mUi.systemProxyHttpsEdit, SIGNAL(textEdited(QString)), SLOT(slotChanged())); - connect(mUi.systemProxyFtpEdit, SIGNAL(textEdited(QString)), SLOT(slotChanged())); - connect(mUi.systemProxySocksEdit, SIGNAL(textEdited(QString)), SLOT(slotChanged())); - connect(mUi.systemNoProxyEdit, SIGNAL(textEdited(QString)), SLOT(slotChanged())); + connect(mUi.noProxyRadioButton, &QAbstractButton::clicked, this, &KProxyDialog::slotChanged); + connect(mUi.autoDiscoverProxyRadioButton, &QAbstractButton::clicked, this, &KProxyDialog::slotChanged); + connect(mUi.autoScriptProxyRadioButton, &QAbstractButton::clicked, this, &KProxyDialog::slotChanged); + connect(mUi.manualProxyRadioButton, &QAbstractButton::clicked, this, &KProxyDialog::slotChanged); + connect(mUi.systemProxyRadioButton, &QAbstractButton::clicked, this, &KProxyDialog::slotChanged); + connect(mUi.noProxyRadioButton, &QAbstractButton::clicked, this, &KProxyDialog::slotChanged); + connect(mUi.useReverseProxyCheckBox, &QAbstractButton::clicked, this, &KProxyDialog::slotChanged); + connect(mUi.useSameProxyCheckBox, &QAbstractButton::clicked, this, &KProxyDialog::slotChanged); + + connect(mUi.proxyScriptUrlRequester, &KUrlRequester::textChanged, this, &KProxyDialog::slotChanged); + + connect(mUi.manualProxyHttpEdit, &QLineEdit::textChanged, this, &KProxyDialog::slotChanged); + connect(mUi.manualProxyHttpsEdit, &QLineEdit::textChanged, this, &KProxyDialog::slotChanged); + connect(mUi.manualProxyFtpEdit, &QLineEdit::textChanged, this, &KProxyDialog::slotChanged); + connect(mUi.manualProxySocksEdit, &QLineEdit::textChanged, this, &KProxyDialog::slotChanged); + connect(mUi.manualNoProxyEdit, &QLineEdit::textChanged, this, &KProxyDialog::slotChanged); + + connect(mUi.manualProxyHttpSpinBox, QOverload::of(&QSpinBox::valueChanged), this, &KProxyDialog::slotChanged); + connect(mUi.manualProxyHttpsSpinBox, QOverload::of(&QSpinBox::valueChanged), this, &KProxyDialog::slotChanged); + connect(mUi.manualProxyFtpSpinBox, QOverload::of(&QSpinBox::valueChanged), this, &KProxyDialog::slotChanged); + connect(mUi.manualProxySocksSpinBox, QOverload::of(&QSpinBox::valueChanged), this, &KProxyDialog::slotChanged); + + connect(mUi.systemProxyHttpEdit, &QLineEdit::textEdited, this, &KProxyDialog::slotChanged); + connect(mUi.systemProxyHttpsEdit, &QLineEdit::textEdited, this, &KProxyDialog::slotChanged); + connect(mUi.systemProxyFtpEdit, &QLineEdit::textEdited, this, &KProxyDialog::slotChanged); + connect(mUi.systemProxySocksEdit, &QLineEdit::textEdited, this, &KProxyDialog::slotChanged); + connect(mUi.systemNoProxyEdit, &QLineEdit::textEdited, this, &KProxyDialog::slotChanged); } KProxyDialog::~KProxyDialog() { } void KProxyDialog::load() { mProxyMap[QStringLiteral("HttpProxy")] = KProtocolManager::proxyFor(QStringLiteral("http")); mProxyMap[QStringLiteral("HttpsProxy")] = KProtocolManager::proxyFor(QStringLiteral("https")); mProxyMap[QStringLiteral("FtpProxy")] = KProtocolManager::proxyFor(QStringLiteral("ftp")); mProxyMap[QStringLiteral("SocksProxy")] = KProtocolManager::proxyFor(QStringLiteral("socks")); mProxyMap[QStringLiteral("ProxyScript")] = KProtocolManager::proxyConfigScript(); mProxyMap[QStringLiteral("NoProxy")] = KSaveIOConfig::noProxyFor(); const int proxyType = KProtocolManager::proxyType(); // Make sure showEnvValueCheckBox is unchecked before setting proxy env var names mUi.showEnvValueCheckBox->setChecked(false); setProxyInformation(mProxyMap.value(QStringLiteral("HttpProxy")), proxyType, mUi.manualProxyHttpEdit, mUi.systemProxyHttpEdit, mUi.manualProxyHttpSpinBox, QStringLiteral("http"), HideHttpUrlScheme); setProxyInformation(mProxyMap.value(QStringLiteral("HttpsProxy")), proxyType, mUi.manualProxyHttpsEdit, mUi.systemProxyHttpsEdit, mUi.manualProxyHttpsSpinBox, QStringLiteral("http"), HideHttpsUrlScheme); setProxyInformation(mProxyMap.value(QStringLiteral("FtpProxy")), proxyType, mUi.manualProxyFtpEdit, mUi.systemProxyFtpEdit, mUi.manualProxyFtpSpinBox, QStringLiteral("ftp"), HideFtpUrlScheme); setProxyInformation(mProxyMap.value(QStringLiteral("SocksProxy")), proxyType, mUi.manualProxySocksEdit, mUi.systemProxySocksEdit, mUi.manualProxySocksSpinBox, QStringLiteral("socks"), HideSocksUrlScheme); setProxyInformation(mProxyMap.value(QStringLiteral("NoProxy")), proxyType, mUi.manualNoProxyEdit, mUi.systemNoProxyEdit, nullptr, QString(), HideNone); // Check the "Use this proxy server for all protocols" if all the proxy URLs are the same... const QString httpProxy(mUi.manualProxyHttpEdit->text()); if (!httpProxy.isEmpty()) { const int httpProxyPort = mUi.manualProxyHttpSpinBox->value(); mUi.useSameProxyCheckBox->setChecked(httpProxy == mUi.manualProxyHttpsEdit->text() && httpProxy == mUi.manualProxyFtpEdit->text() && httpProxy == mUi.manualProxySocksEdit->text() && httpProxyPort == mUi.manualProxyHttpsSpinBox->value() && httpProxyPort == mUi.manualProxyFtpSpinBox->value() && httpProxyPort == mUi.manualProxySocksSpinBox->value()); } // Validate and Set the automatic proxy configuration script url. QUrl u (mProxyMap.value(QStringLiteral("ProxyScript"))); if (u.isValid() && !u.isEmpty()) { u.setUserName (QString()); u.setPassword (QString()); mUi.proxyScriptUrlRequester->setUrl(u); } // Set use reverse proxy checkbox... mUi.useReverseProxyCheckBox->setChecked((!mProxyMap.value(QStringLiteral("NoProxy")).isEmpty() && KProtocolManager::useReverseProxy())); switch (proxyType) { case KProtocolManager::WPADProxy: mUi.autoDiscoverProxyRadioButton->setChecked(true); break; case KProtocolManager::PACProxy: mUi.autoScriptProxyRadioButton->setChecked(true); break; case KProtocolManager::ManualProxy: mUi.manualProxyRadioButton->setChecked(true); break; case KProtocolManager::EnvVarProxy: mUi.systemProxyRadioButton->setChecked(true); break; case KProtocolManager::NoProxy: default: mUi.noProxyRadioButton->setChecked(true); break; } } static bool isPACProxyType(KProtocolManager::ProxyType type) { return (type == KProtocolManager::PACProxy || type == KProtocolManager::WPADProxy); } void KProxyDialog::save() { const KProtocolManager::ProxyType lastProxyType = KProtocolManager::proxyType(); KProtocolManager::ProxyType proxyType = KProtocolManager::NoProxy; DisplayUrlFlags displayUrlFlags = static_cast(KSaveIOConfig::proxyDisplayUrlFlags()); if (mUi.manualProxyRadioButton->isChecked()) { DisplayUrlFlags flags = HideNone; proxyType = KProtocolManager::ManualProxy; mProxyMap[QStringLiteral("HttpProxy")] = proxyUrlFromInput(&flags, mUi.manualProxyHttpEdit, mUi.manualProxyHttpSpinBox, QStringLiteral("http"), HideHttpUrlScheme); mProxyMap[QStringLiteral("HttpsProxy")] = proxyUrlFromInput(&flags, mUi.manualProxyHttpsEdit, mUi.manualProxyHttpsSpinBox, QStringLiteral("http"), HideHttpsUrlScheme); mProxyMap[QStringLiteral("FtpProxy")] = proxyUrlFromInput(&flags, mUi.manualProxyFtpEdit, mUi.manualProxyFtpSpinBox, QStringLiteral("ftp"), HideFtpUrlScheme); mProxyMap[QStringLiteral("SocksProxy")] = proxyUrlFromInput(&flags, mUi.manualProxySocksEdit, mUi.manualProxySocksSpinBox, QStringLiteral("socks"), HideSocksUrlScheme); mProxyMap[QStringLiteral("NoProxy")] = mUi.manualNoProxyEdit->text(); displayUrlFlags = flags; } else if (mUi.systemProxyRadioButton->isChecked()) { proxyType = KProtocolManager::EnvVarProxy; if (!mUi.showEnvValueCheckBox->isChecked()) { mProxyMap[QStringLiteral("HttpProxy")] = mUi.systemProxyHttpEdit->text(); mProxyMap[QStringLiteral("HttpsProxy")] = mUi.systemProxyHttpsEdit->text(); mProxyMap[QStringLiteral("FtpProxy")] = mUi.systemProxyFtpEdit->text(); mProxyMap[QStringLiteral("SocksProxy")] = mUi.systemProxySocksEdit->text(); mProxyMap[QStringLiteral("NoProxy")] = mUi.systemNoProxyEdit->text(); } else { mProxyMap[QStringLiteral("HttpProxy")] = mProxyMap.take(mUi.systemProxyHttpEdit->objectName()); mProxyMap[QStringLiteral("HttpsProxy")] = mProxyMap.take(mUi.systemProxyHttpsEdit->objectName()); mProxyMap[QStringLiteral("FtpProxy")] = mProxyMap.take(mUi.systemProxyFtpEdit->objectName()); mProxyMap[QStringLiteral("SocksProxy")] = mProxyMap.take(mUi.systemProxySocksEdit->objectName()); mProxyMap[QStringLiteral("NoProxy")] = mProxyMap.take(mUi.systemNoProxyEdit->objectName()); } } else if (mUi.autoScriptProxyRadioButton->isChecked()) { proxyType = KProtocolManager::PACProxy; mProxyMap[QStringLiteral("ProxyScript")] = mUi.proxyScriptUrlRequester->text(); } else if (mUi.autoDiscoverProxyRadioButton->isChecked()) { proxyType = KProtocolManager::WPADProxy; } KSaveIOConfig::setProxyType(proxyType); KSaveIOConfig::setProxyDisplayUrlFlags(displayUrlFlags); KSaveIOConfig::setUseReverseProxy(mUi.useReverseProxyCheckBox->isChecked()); // Save the common proxy setting... KSaveIOConfig::setProxyFor(QStringLiteral("http"), mProxyMap.value(QStringLiteral("HttpProxy"))); KSaveIOConfig::setProxyFor(QStringLiteral("https"), mProxyMap.value(QStringLiteral("HttpsProxy"))); KSaveIOConfig::setProxyFor(QStringLiteral("ftp"), mProxyMap.value(QStringLiteral("FtpProxy"))); KSaveIOConfig::setProxyFor(QStringLiteral("socks"), mProxyMap.value(QStringLiteral("SocksProxy"))); KSaveIOConfig::setProxyConfigScript (mProxyMap.value(QStringLiteral("ProxyScript"))); KSaveIOConfig::setNoProxyFor (mProxyMap.value(QStringLiteral("NoProxy"))); KSaveIOConfig::updateRunningIOSlaves (this); if (isPACProxyType(lastProxyType) || isPACProxyType(proxyType)) { KSaveIOConfig::updateProxyScout (this); } emit changed (false); } void KProxyDialog::defaults() { mUi.noProxyRadioButton->setChecked(true); mUi.proxyScriptUrlRequester->clear(); mUi.manualProxyHttpEdit->clear(); mUi.manualProxyHttpsEdit->clear(); mUi.manualProxyFtpEdit->clear(); mUi.manualProxySocksEdit->clear(); mUi.manualNoProxyEdit->clear(); mUi.manualProxyHttpSpinBox->setValue(0); mUi.manualProxyHttpsSpinBox->setValue(0); mUi.manualProxyFtpSpinBox->setValue(0); mUi.manualProxySocksSpinBox->setValue(0); mUi.systemProxyHttpEdit->clear(); mUi.systemProxyHttpsEdit->clear(); mUi.systemProxyFtpEdit->clear(); mUi.systemProxySocksEdit->clear(); emit changed (true); } bool KProxyDialog::autoDetectSystemProxy(QLineEdit* edit, const QString& envVarStr, bool showValue) { const QStringList envVars = envVarStr.split(QL1C(','), QString::SkipEmptyParts); Q_FOREACH (const QString & envVar, envVars) { const QByteArray envVarUtf8(envVar.toUtf8()); const QByteArray envVarValue = qgetenv(envVarUtf8.constData()); if (!envVarValue.isEmpty()) { if (showValue) { mProxyMap[edit->objectName()] = envVar; edit->setText(QString::fromUtf8(envVarValue)); } else { edit->setText(envVar); } edit->setEnabled(!showValue); return true; } } return false; } void KProxyDialog::on_autoDetectButton_clicked() { const bool showValue = mUi.showEnvValueCheckBox->isChecked(); bool wasChanged = false; wasChanged |= autoDetectSystemProxy(mUi.systemProxyHttpEdit, ENV_HTTP_PROXY, showValue); wasChanged |= autoDetectSystemProxy(mUi.systemProxyHttpsEdit, ENV_HTTPS_PROXY, showValue); wasChanged |= autoDetectSystemProxy(mUi.systemProxyFtpEdit, ENV_FTP_PROXY, showValue); wasChanged |= autoDetectSystemProxy(mUi.systemProxySocksEdit, ENV_SOCKS_PROXY, showValue); wasChanged |= autoDetectSystemProxy(mUi.systemNoProxyEdit, ENV_NO_PROXY, showValue); if (wasChanged) emit changed (true); } void KProxyDialog::on_manualProxyHttpEdit_textChanged(const QString& text) { mUi.useSameProxyCheckBox->setEnabled(!text.isEmpty()); } void KProxyDialog::on_manualNoProxyEdit_textChanged (const QString& text) { mUi.useReverseProxyCheckBox->setEnabled(!text.isEmpty()); } void KProxyDialog::on_manualProxyHttpEdit_textEdited(const QString& text) { if (!mUi.useSameProxyCheckBox->isChecked()) { return; } mUi.manualProxyHttpsEdit->setText(text); mUi.manualProxyFtpEdit->setText(text); mUi.manualProxySocksEdit->setText(text); } void KProxyDialog::on_manualProxyHttpSpinBox_valueChanged (int value) { if (!mUi.useSameProxyCheckBox->isChecked()) { return; } mUi.manualProxyHttpsSpinBox->setValue(value); mUi.manualProxyFtpSpinBox->setValue(value); mUi.manualProxySocksSpinBox->setValue(value); } void KProxyDialog::on_showEnvValueCheckBox_toggled (bool on) { if (on) { showSystemProxyUrl(mUi.systemProxyHttpEdit, &mProxyMap[mUi.systemProxyHttpEdit->objectName()]); showSystemProxyUrl(mUi.systemProxyHttpsEdit, &mProxyMap[mUi.systemProxyHttpsEdit->objectName()]); showSystemProxyUrl(mUi.systemProxyFtpEdit, &mProxyMap[mUi.systemProxyFtpEdit->objectName()]); showSystemProxyUrl(mUi.systemProxySocksEdit, &mProxyMap[mUi.systemProxySocksEdit->objectName()]); showSystemProxyUrl(mUi.systemNoProxyEdit, &mProxyMap[mUi.systemNoProxyEdit->objectName()]); return; } mUi.systemProxyHttpEdit->setText(mProxyMap.take(mUi.systemProxyHttpEdit->objectName())); mUi.systemProxyHttpEdit->setEnabled(true); mUi.systemProxyHttpsEdit->setText(mProxyMap.take(mUi.systemProxyHttpsEdit->objectName())); mUi.systemProxyHttpsEdit->setEnabled(true); mUi.systemProxyFtpEdit->setText(mProxyMap.take(mUi.systemProxyFtpEdit->objectName())); mUi.systemProxyFtpEdit->setEnabled(true); mUi.systemProxySocksEdit->setText(mProxyMap.take(mUi.systemProxySocksEdit->objectName())); mUi.systemProxySocksEdit->setEnabled(true); mUi.systemNoProxyEdit->setText(mProxyMap.take(mUi.systemNoProxyEdit->objectName())); mUi.systemNoProxyEdit->setEnabled(true); } void KProxyDialog::on_useSameProxyCheckBox_clicked(bool on) { if (on) { mProxyMap[QStringLiteral("ManProxyHttps")] = manualProxyToText (mUi.manualProxyHttpsEdit, mUi.manualProxyHttpsSpinBox, QL1C (' ')); mProxyMap[QStringLiteral("ManProxyFtp")] = manualProxyToText (mUi.manualProxyFtpEdit, mUi.manualProxyFtpSpinBox, QL1C (' ')); mProxyMap[QStringLiteral("ManProxySocks")] = manualProxyToText (mUi.manualProxySocksEdit, mUi.manualProxySocksSpinBox, QL1C (' ')); const QString& httpProxy = mUi.manualProxyHttpEdit->text(); if (!httpProxy.isEmpty()) { mUi.manualProxyHttpsEdit->setText(httpProxy); mUi.manualProxyFtpEdit->setText(httpProxy); mUi.manualProxySocksEdit->setText(httpProxy); } const int httpProxyPort = mUi.manualProxyHttpSpinBox->value(); if (httpProxyPort > 0) { mUi.manualProxyHttpsSpinBox->setValue(httpProxyPort); mUi.manualProxyFtpSpinBox->setValue(httpProxyPort); mUi.manualProxySocksSpinBox->setValue(httpProxyPort); } return; } setManualProxyFromText(mProxyMap.take (QStringLiteral("ManProxyHttps")), mUi.manualProxyHttpsEdit, mUi.manualProxyHttpsSpinBox); setManualProxyFromText(mProxyMap.take (QStringLiteral("ManProxyFtp")), mUi.manualProxyFtpEdit, mUi.manualProxyFtpSpinBox); setManualProxyFromText(mProxyMap.take (QStringLiteral("ManProxySocks")), mUi.manualProxySocksEdit, mUi.manualProxySocksSpinBox); } void KProxyDialog::slotChanged() { emit changed(true); } QString KProxyDialog::quickHelp() const { return i18n ("

Proxy

" "

A proxy server is an intermediate program that sits between " "your machine and the Internet and provides services such as " "web page caching and/or filtering.

" "

Caching proxy servers give you faster access to sites you have " "already visited by locally storing or caching the content of those " "pages; filtering proxy servers, on the other hand, provide the " "ability to block out requests for ads, spam, or anything else you " "want to block.

" "

Note: Some proxy servers provide both services.

"); } diff --git a/src/kcms/kio/netpref.cpp b/src/kcms/kio/netpref.cpp index e2bf6775..b4d59222 100644 --- a/src/kcms/kio/netpref.cpp +++ b/src/kcms/kio/netpref.cpp @@ -1,174 +1,181 @@ // Own #include "netpref.h" // Qt #include #include #include // KDE #include #include #include #include #include #include #include // Local #include "ksaveioconfig.h" #define MAX_TIMEOUT_VALUE 3600 K_PLUGIN_FACTORY_DECLARATION(KioConfigFactory) KIOPreferences::KIOPreferences(QWidget *parent, const QVariantList &) :KCModule(parent) { QVBoxLayout* mainLayout = new QVBoxLayout( this ); mainLayout->setMargin(0); gb_Timeout = new QGroupBox( i18n("Timeout Values"), this ); gb_Timeout->setWhatsThis( i18np("Here you can set timeout values. " "You might want to tweak them if your " "connection is very slow. The maximum " "allowed value is 1 second." , "Here you can set timeout values. " "You might want to tweak them if your " "connection is very slow. The maximum " "allowed value is %1 seconds.", MAX_TIMEOUT_VALUE)); mainLayout->addWidget( gb_Timeout ); QFormLayout* timeoutLayout = new QFormLayout(gb_Timeout); sb_socketRead = new KPluralHandlingSpinBox( this ); sb_socketRead->setSuffix( ki18np( " second", " seconds" ) ); - connect(sb_socketRead, SIGNAL(valueChanged(int)), SLOT(configChanged())); + connect(sb_socketRead, QOverload::of(&QSpinBox::valueChanged), + this, &KIOPreferences::configChanged); timeoutLayout->addRow(i18n( "Soc&ket read:" ), sb_socketRead); sb_proxyConnect = new KPluralHandlingSpinBox( this ); sb_proxyConnect->setValue(0); sb_proxyConnect->setSuffix( ki18np( " second", " seconds" ) ); - connect(sb_proxyConnect, SIGNAL(valueChanged(int)), SLOT(configChanged())); + connect(sb_proxyConnect, QOverload::of(&QSpinBox::valueChanged), + this, &KIOPreferences::configChanged); timeoutLayout->addRow(i18n( "Pro&xy connect:" ), sb_proxyConnect); sb_serverConnect = new KPluralHandlingSpinBox( this ); sb_serverConnect->setValue(0); sb_serverConnect->setSuffix( ki18np( " second", " seconds" ) ); - connect(sb_serverConnect, SIGNAL(valueChanged(int)), SLOT(configChanged())); + connect(sb_serverConnect, QOverload::of(&QSpinBox::valueChanged), + this, &KIOPreferences::configChanged); timeoutLayout->addRow(i18n("Server co&nnect:"), sb_serverConnect); sb_serverResponse = new KPluralHandlingSpinBox( this ); sb_serverResponse->setValue(0); sb_serverResponse->setSuffix( ki18np( " second", " seconds" ) ); - connect(sb_serverResponse, SIGNAL(valueChanged(int)), SLOT(configChanged())); + connect(sb_serverResponse, QOverload::of(&QSpinBox::valueChanged), + this, &KIOPreferences::configChanged); timeoutLayout->addRow(i18n("&Server response:"), sb_serverResponse); QGroupBox* gb_Global = new QGroupBox( i18n( "Global Options" ), this ); mainLayout->addWidget( gb_Global ); QVBoxLayout* globalLayout = new QVBoxLayout(gb_Global); cb_globalMarkPartial = new QCheckBox( i18n( "Mark &partially uploaded files" ), this ); cb_globalMarkPartial->setWhatsThis( i18n( "

Marks partially uploaded files " "through SMB, SFTP and other protocols." "

When this option is " "enabled, partially uploaded files " "will have a \".part\" extension. " "This extension will be removed " "once the transfer is complete.

") ); - connect(cb_globalMarkPartial, SIGNAL(toggled(bool)), SLOT(configChanged())); + connect(cb_globalMarkPartial, &QAbstractButton::toggled, + this, &KIOPreferences::configChanged); globalLayout->addWidget(cb_globalMarkPartial); gb_Ftp = new QGroupBox( i18n( "FTP Options" ), this ); mainLayout->addWidget( gb_Ftp ); QVBoxLayout* ftpLayout = new QVBoxLayout(gb_Ftp); cb_ftpEnablePasv = new QCheckBox( i18n( "Enable passive &mode (PASV)" ), this ); cb_ftpEnablePasv->setWhatsThis( i18n("Enables FTP's \"passive\" mode. " "This is required to allow FTP to " "work from behind firewalls.") ); - connect(cb_ftpEnablePasv, SIGNAL(toggled(bool)), SLOT(configChanged())); + connect(cb_ftpEnablePasv, &QAbstractButton::toggled, + this, &KIOPreferences::configChanged); ftpLayout->addWidget(cb_ftpEnablePasv); cb_ftpMarkPartial = new QCheckBox( i18n( "Mark &partially uploaded files" ), this ); cb_ftpMarkPartial->setWhatsThis( i18n( "

Marks partially uploaded FTP " "files.

When this option is " "enabled, partially uploaded files " "will have a \".part\" extension. " "This extension will be removed " "once the transfer is complete.

") ); - connect(cb_ftpMarkPartial, SIGNAL(toggled(bool)), SLOT(configChanged())); + connect(cb_ftpMarkPartial, &QAbstractButton::toggled, + this, &KIOPreferences::configChanged); ftpLayout->addWidget(cb_ftpMarkPartial); mainLayout->addStretch( 1 ); } KIOPreferences::~KIOPreferences() { } void KIOPreferences::load() { KProtocolManager proto; sb_socketRead->setRange( MIN_TIMEOUT_VALUE, MAX_TIMEOUT_VALUE ); sb_serverResponse->setRange( MIN_TIMEOUT_VALUE, MAX_TIMEOUT_VALUE ); sb_serverConnect->setRange( MIN_TIMEOUT_VALUE, MAX_TIMEOUT_VALUE ); sb_proxyConnect->setRange( MIN_TIMEOUT_VALUE, MAX_TIMEOUT_VALUE ); sb_socketRead->setValue( proto.readTimeout() ); sb_serverResponse->setValue( proto.responseTimeout() ); sb_serverConnect->setValue( proto.connectTimeout() ); sb_proxyConnect->setValue( proto.proxyConnectTimeout() ); cb_globalMarkPartial->setChecked( proto.markPartial() ); KConfig config( QStringLiteral("kio_ftprc"), KConfig::NoGlobals ); cb_ftpEnablePasv->setChecked( !config.group("").readEntry( "DisablePassiveMode", false ) ); cb_ftpMarkPartial->setChecked( config.group("").readEntry( "MarkPartial", true ) ); emit changed( false ); } void KIOPreferences::save() { KSaveIOConfig::setReadTimeout( sb_socketRead->value() ); KSaveIOConfig::setResponseTimeout( sb_serverResponse->value() ); KSaveIOConfig::setConnectTimeout( sb_serverConnect->value() ); KSaveIOConfig::setProxyConnectTimeout( sb_proxyConnect->value() ); KSaveIOConfig::setMarkPartial( cb_globalMarkPartial->isChecked() ); KConfig config(QStringLiteral("kio_ftprc"), KConfig::NoGlobals); config.group("").writeEntry( "DisablePassiveMode", !cb_ftpEnablePasv->isChecked() ); config.group("").writeEntry( "MarkPartial", cb_ftpMarkPartial->isChecked() ); config.sync(); KSaveIOConfig::updateRunningIOSlaves(this); emit changed( false ); } void KIOPreferences::defaults() { sb_socketRead->setValue( DEFAULT_READ_TIMEOUT ); sb_serverResponse->setValue( DEFAULT_RESPONSE_TIMEOUT ); sb_serverConnect->setValue( DEFAULT_CONNECT_TIMEOUT ); sb_proxyConnect->setValue( DEFAULT_PROXY_CONNECT_TIMEOUT ); cb_globalMarkPartial->setChecked( true ); cb_ftpEnablePasv->setChecked( true ); cb_ftpMarkPartial->setChecked( true ); emit changed(true); } QString KIOPreferences::quickHelp() const { return i18n("

Network Preferences

Here you can define" " the behavior of KDE programs when using Internet" " and network connections. If you experience timeouts" " or use a modem to connect to the Internet, you might" " want to adjust these settings." ); } diff --git a/src/kcms/kio/smbrodlg.cpp b/src/kcms/kio/smbrodlg.cpp index 502eeb50..eb3b2f25 100644 --- a/src/kcms/kio/smbrodlg.cpp +++ b/src/kcms/kio/smbrodlg.cpp @@ -1,185 +1,185 @@ /* This file is part of the KDE project Copyright (C) 2000 Alexander Neundorf This library is free software; you can redistribute it and/or modify it under the terms of the GNU Library General Public License as published by the Free Software Foundation; either version 2 of the License, or (at your option) any later version. This library 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 Library General Public License for more details. You should have received a copy of the GNU Library General Public License along with this library; see the file COPYING.LIB. If not, write to the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. */ // Own #include "smbrodlg.h" // Qt #include #include #include // KDE #include #include #include #include #include #include //#include #include K_PLUGIN_FACTORY_DECLARATION(KioConfigFactory) SMBRoOptions::SMBRoOptions(QWidget *parent, const QVariantList &) : KCModule(parent) { QGridLayout *layout = new QGridLayout(this ); QLabel *label=new QLabel(i18n("These settings apply to network browsing only."),this); layout->addWidget(label,0,0, 1, 2 ); m_userLe=new QLineEdit(this); label=new QLabel(i18n("Default user name:"),this); label->setAlignment(Qt::AlignRight | Qt::AlignVCenter); label->setBuddy( m_userLe ); layout->addWidget(label,1,0); layout->addWidget(m_userLe,1,1); m_passwordLe=new QLineEdit(this); m_passwordLe->setEchoMode(QLineEdit::Password); label=new QLabel(i18n("Default password:"),this); label->setAlignment(Qt::AlignRight | Qt::AlignVCenter); label->setBuddy( m_passwordLe ); layout->addWidget(label,2,0); layout->addWidget(m_passwordLe,2,1); /* m_workgroupLe=new QLineEdit(this); label=new QLabel(m_workgroupLe,i18n("Workgroup:"),this); layout->addWidget(label,3,0); layout->addWidget(m_workgroupLe,3,1); m_showHiddenShares=new QCheckBox(i18n("Show hidden shares"),this); layout->addWidget(m_showHiddenShares,4,0, 1, 2 ); m_encodingList = new KComboBox( false, this ); QStringList _strList = KCharsets::charsets()->availableEncodingNames(); m_encodingList->addItems( _strList ); label = new QLabel( i18n( "MS Windows encoding:" ), this ); label->setBuddy( m_encodingList ); layout->addWidget( label, 3, 0 ); layout->addWidget( m_encodingList, 3, 1 ); */ layout->addWidget(new QWidget(this),4,0); // connect(m_showHiddenShares, SIGNAL(toggled(bool)), this, SLOT(changed())); - connect(m_userLe, SIGNAL(textChanged(QString)), this, SLOT(changed())); - connect(m_passwordLe, SIGNAL(textChanged(QString)), this, SLOT(changed())); + connect(m_userLe, &QLineEdit::textChanged, this, &SMBRoOptions::changed); + connect(m_passwordLe, &QLineEdit::textChanged, this, &SMBRoOptions::changed); // connect(m_workgroupLe, SIGNAL(textChanged(QString)), this, SLOT(changed())); // connect( m_encodingList, SIGNAL(activated(QString)), this , SLOT(changed()) ); layout->setRowStretch(4, 1); } SMBRoOptions::~SMBRoOptions() { } void SMBRoOptions::load() { KConfig *cfg = new KConfig(QStringLiteral("kioslaverc")); KConfigGroup group = cfg->group("Browser Settings/SMBro" ); m_userLe->setText(group.readEntry("User")); // m_workgroupLe->setText(group.readEntry("Workgroup")); // m_showHiddenShares->setChecked(group.readEntry("ShowHiddenShares", QVariant(false)).toBool()); //QStringList _strList = KCharsets::charsets()->availableEncodingNames(); //QString m_encoding = QTextCodec::codecForLocale()->name(); //m_encodingList->setCurrentIndex( _strList.indexOf( group.readEntry( "Encoding", m_encoding.toLower() ) ) ); // unscramble QString scrambled = group.readEntry( "Password" ); QString password; const int passwordLength = scrambled.length() / 3; password.reserve(passwordLength); for (int i=0; isetText(password); delete cfg; } void SMBRoOptions::save() { KConfig *cfg = new KConfig(QStringLiteral("kioslaverc")); KConfigGroup group = cfg->group("Browser Settings/SMBro" ); group.writeEntry( "User", m_userLe->text()); // group.writeEntry( "Workgroup", m_workgroupLe->text()); // group.writeEntry( "ShowHiddenShares", m_showHiddenShares->isChecked()); // group.writeEntry( "Encoding", m_encodingList->currentText() ); //taken from Nicola Brodu's smb ioslave //it's not really secure, but at //least better than storing the plain password QString password(m_passwordLe->text()); QString scrambled; for (int i=0; i> 10; unsigned int a2 = (num & 0x3E0) >> 5; unsigned int a3 = (num & 0x1F); scrambled += (char)(a1+'0'); scrambled += (char)(a2+'A'); scrambled += (char)(a3+'0'); } group.writeEntry( "Password", scrambled); delete cfg; } void SMBRoOptions::defaults() { m_userLe->setText(QString()); m_passwordLe->setText(QString()); // m_workgroupLe->setText(""); // m_showHiddenShares->setChecked(false); } void SMBRoOptions::changed() { emit KCModule::changed(true); } QString SMBRoOptions::quickHelp() const { return i18n("

Windows Shares

Applications using the " "SMB kioslave (like Konqueror) are able to access shared Microsoft " "Windows file systems, if properly configured.

You can specify " "here the credentials used to access the shared resources. " "Passwords will be stored locally, and scrambled so as to render them " "unreadable to the human eye. For security reasons, you may not want to " "do that, as entries with passwords are clearly indicated as such.

"); } diff --git a/src/kcms/kio/useragentselectordlg.cpp b/src/kcms/kio/useragentselectordlg.cpp index a79ba8ad..1655c9bb 100644 --- a/src/kcms/kio/useragentselectordlg.cpp +++ b/src/kcms/kio/useragentselectordlg.cpp @@ -1,160 +1,160 @@ /** * Copyright (c) 2001 Dawit Alemayehu * * 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 "useragentselectordlg.h" // Local #include "useragentinfo.h" // Qt #include #include #include #include // KDE #include #include #include #include #include class UserAgentSiteNameValidator : public QValidator { Q_OBJECT public: UserAgentSiteNameValidator (QObject* parent) : QValidator (parent) { setObjectName (QStringLiteral ("UserAgentSiteNameValidator")); } State validate (QString& input, int&) const override { if (input.isEmpty()) return Intermediate; if (input.startsWith(QLatin1Char('.'))) return Invalid; const int length = input.length(); for (int i = 0 ; i < length; i++) { if (!input[i].isLetterOrNumber() && input[i] != QLatin1Char('.') && input[i] != QLatin1Char('-')) return Invalid; } return Acceptable; } }; UserAgentSelectorDlg::UserAgentSelectorDlg (UserAgentInfo* info, QWidget* parent, Qt::WindowFlags f) : QDialog (parent, f), mUserAgentInfo (info), mButtonBox(nullptr) { QWidget *mainWidget = new QWidget(this); QVBoxLayout *mainLayout = new QVBoxLayout(this); mainLayout->addWidget(mainWidget); mUi.setupUi (mainWidget); mButtonBox = new QDialogButtonBox(QDialogButtonBox::Ok | QDialogButtonBox::Cancel, this); mainLayout->addWidget(mButtonBox); - connect(mButtonBox, SIGNAL(accepted()), this, SLOT(accept())); - connect(mButtonBox, SIGNAL(rejected()), this, SLOT(reject())); + connect(mButtonBox, &QDialogButtonBox::accepted, this, &QDialog::accept); + connect(mButtonBox, &QDialogButtonBox::rejected, this, &QDialog::reject); 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))); + connect (mUi.siteLineEdit, &QLineEdit::textEdited, + this, &UserAgentSelectorDlg::onHostNameChanged); + connect (mUi.aliasComboBox, QOverload::of(&QComboBox::activated), + this, &UserAgentSelectorDlg::onAliasChanged); mButtonBox->button(QDialogButtonBox::Ok)->setEnabled (false); } UserAgentSelectorDlg::~UserAgentSelectorDlg() { } void UserAgentSelectorDlg::onAliasChanged (const QString& text) { if (text.isEmpty()) mUi.identityLineEdit->setText (QString()); else mUi.identityLineEdit->setText (mUserAgentInfo->agentStr (text)); const bool enable = (!mUi.siteLineEdit->text().isEmpty() && !text.isEmpty()); mButtonBox->button(QDialogButtonBox::Ok)->setEnabled (enable); } void UserAgentSelectorDlg::onHostNameChanged (const QString& text) { const bool enable = (!text.isEmpty() && !mUi.aliasComboBox->currentText().isEmpty()); mButtonBox->button(QDialogButtonBox::Ok)->setEnabled (enable); } void UserAgentSelectorDlg::setSiteName (const QString& text) { mUi.siteLineEdit->setText (text); } void UserAgentSelectorDlg::setIdentity (const QString& text) { 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 mUi.siteLineEdit->text().toLower(); } QString UserAgentSelectorDlg::identity() { return mUi.aliasComboBox->currentText(); } QString UserAgentSelectorDlg::alias() { return mUi.identityLineEdit->text(); } #include "useragentselectordlg.moc" diff --git a/src/kcms/webshortcuts/main.cpp b/src/kcms/webshortcuts/main.cpp index ab849c34..4d930863 100644 --- a/src/kcms/webshortcuts/main.cpp +++ b/src/kcms/webshortcuts/main.cpp @@ -1,127 +1,128 @@ /* * Copyright (c) 2000 Yves Arrouye * * 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 "main.h" // Qt #include #include // KDE #include #include #include #include #include #include K_PLUGIN_FACTORY(KURIFilterModuleFactory, registerPlugin();) KURIFilterModule::KURIFilterModule(QWidget *parent, const QVariantList &args) : KCModule(parent, args), m_widget(nullptr) { KAboutData *about = new KAboutData(QStringLiteral("kcm_webshortcuts"), i18n("Web Shortcuts"), QStringLiteral("0.1"), i18n("Configure enhanced browsing features"), KAboutLicense::GPL); setAboutData(about); KCModule::setButtons(KCModule::Buttons(KCModule::Default | KCModule::Apply | KCModule::Help)); filter = KUriFilter::self(); setQuickHelp(i18n("

Enhanced Browsing

In this module you can configure some enhanced browsing" " features of KDE. " "

Web Shortcuts

Web Shortcuts are a quick way of using Web search engines. For example, type \"duckduckgo:frobozz\"" " or \"dd:frobozz\" and your web browser will do a search on DuckDuckGo for \"frobozz\"." " Even easier: just press Alt+F2 (if you have not" " changed this keyboard shortcut) and enter the shortcut in the Run Command dialog.")); QVBoxLayout *layout = new QVBoxLayout(this); QMap helper; // Load the plugins. This saves a public method in KUriFilter just for this. QVector plugins = KPluginLoader::findPlugins(QStringLiteral("kf5/urifilters")); for (const KPluginMetaData &pluginMetaData : plugins) { KPluginFactory *factory = qobject_cast(pluginMetaData.instantiate()); if (factory) { KUriFilterPlugin *plugin = factory->create(nullptr); if (plugin) { KCModule *module = plugin->configModule(this, nullptr); if (module) { modules.append(module); helper.insert(plugin->configName(), module); - connect(module, SIGNAL(changed(bool)), SIGNAL(changed(bool))); + connect(module, QOverload::of(&KCModule::changed), + this, QOverload::of(&KCModule::changed)); } } } } if (modules.count() > 1) { QTabWidget *tab = new QTabWidget(this); QMap::iterator it2; for (it2 = helper.begin(); it2 != helper.end(); ++it2) { tab->addTab(it2.value(), it2.key()); } tab->setCurrentIndex(tab->indexOf(modules.first())); m_widget = tab; } else if (modules.count() == 1) { m_widget = modules.first(); if (m_widget->layout()) { m_widget->layout()->setMargin(0); } } if (m_widget) { layout->addWidget(m_widget); } } void KURIFilterModule::load() { // seems not to be necessary, since modules automatically call load() on show (uwolfer) // foreach( KCModule* module, modules ) // { // module->load(); // } } void KURIFilterModule::save() { foreach(KCModule * module, modules) { module->save(); } } void KURIFilterModule::defaults() { foreach(KCModule * module, modules) { module->defaults(); } } KURIFilterModule::~KURIFilterModule() { qDeleteAll(modules); } #include "main.moc"