X-Git-Url: https://cloud.milkyroute.net/gitweb/dolphin.git/blobdiff_plain/05f2c9c320694ee79dd0b60b35d98003f2d8df96..769d1470267247efdffe8b9a2464f21c905d195d:/src/views/dolphinremoteencoding.cpp diff --git a/src/views/dolphinremoteencoding.cpp b/src/views/dolphinremoteencoding.cpp index bf00e33fe..41b3b6890 100644 --- a/src/views/dolphinremoteencoding.cpp +++ b/src/views/dolphinremoteencoding.cpp @@ -1,47 +1,33 @@ -/*************************************************************************** - * Copyright (C) 2009 by Rahman Duran * - * * - * 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 * - ***************************************************************************/ +/* + * SPDX-FileCopyrightText: 2009 Rahman Duran + * + * SPDX-License-Identifier: GPL-2.0-or-later + */ /* * This code is largely based on the kremoteencodingplugin - * Copyright (c) 2003 Thiago Macieira + * SPDX-FileCopyrightText: 2003 Thiago Macieira * Distributed under the same terms. */ #include "dolphinremoteencoding.h" + #include "dolphinviewactionhandler.h" +#include "dolphindebug.h" -#include -#include #include -#include -#include -#include -#include -#include +#include #include -#include +#include +#include +#include +#include #include #include -#include -#include -#define DATA_KEY QLatin1String("Charset") +#include + +#define DATA_KEY QStringLiteral("Charset") DolphinRemoteEncoding::DolphinRemoteEncoding(QObject* parent, DolphinViewActionHandler* actionHandler) :QObject(parent), @@ -49,13 +35,13 @@ DolphinRemoteEncoding::DolphinRemoteEncoding(QObject* parent, DolphinViewActionH m_loaded(false), m_idDefault(0) { - m_menu = new KActionMenu(KIcon("character-set"), i18n("Select Remote Charset"), this); - m_actionHandler->actionCollection()->addAction("change_remote_encoding", m_menu); + m_menu = new KActionMenu(QIcon::fromTheme(QStringLiteral("character-set")), i18n("Select Remote Charset"), this); + m_actionHandler->actionCollection()->addAction(QStringLiteral("change_remote_encoding"), m_menu); connect(m_menu->menu(), &QMenu::aboutToShow, this, &DolphinRemoteEncoding::slotAboutToShow); m_menu->setEnabled(false); - m_menu->setDelayed(false); + m_menu->setPopupMode(QToolButton::InstantPopup); } DolphinRemoteEncoding::~DolphinRemoteEncoding() @@ -70,17 +56,17 @@ void DolphinRemoteEncoding::slotReload() void DolphinRemoteEncoding::loadSettings() { m_loaded = true; - m_encodingDescriptions = KGlobal::charsets()->descriptiveEncodingNames(); + m_encodingDescriptions = KCharsets::charsets()->descriptiveEncodingNames(); fillMenu(); } void DolphinRemoteEncoding::slotAboutToOpenUrl() { - KUrl oldURL = m_currentURL; + QUrl oldURL = m_currentURL; m_currentURL = m_actionHandler->currentView()->url(); - if (m_currentURL.protocol() != oldURL.protocol()) { + if (m_currentURL.scheme() != oldURL.scheme()) { // This plugin works on ftp, fish, etc. // everything whose type is T_FILESYSTEM except for local files if (!m_currentURL.isLocalFile() && @@ -131,7 +117,7 @@ void DolphinRemoteEncoding::updateMenu() m_menu->menu()->actions().at(i)->setChecked(false); } - const QString charset = KGlobal::charsets()->descriptionForEncoding(KProtocolManager::charsetFor(m_currentURL)); + const QString charset = KCharsets::charsets()->descriptionForEncoding(KProtocolManager::charsetFor(m_currentURL)); if (!charset.isEmpty()) { int id = 0; bool isFound = false; @@ -143,10 +129,10 @@ void DolphinRemoteEncoding::updateMenu() } } - kDebug() << "URL=" << m_currentURL << " charset=" << charset; + qCDebug(DolphinDebug) << "URL=" << m_currentURL << " charset=" << charset; if (!isFound) { - kWarning() << "could not find entry for charset=" << charset ; + qCWarning(DolphinDebug) << "could not find entry for charset=" << charset ; } else { m_menu->menu()->actions().at(id)->setChecked(true); } @@ -169,10 +155,10 @@ void DolphinRemoteEncoding::slotItemSelected(QAction* action) if (action) { int id = action->data().toInt(); - KConfig config(("kio_" + m_currentURL.protocol() + "rc").toLatin1()); + KConfig config(("kio_" + m_currentURL.scheme() + "rc").toLatin1()); QString host = m_currentURL.host(); if (m_menu->menu()->actions().at(id)->isChecked()) { - QString charset = KGlobal::charsets()->encodingForName(m_encodingDescriptions.at(id)); + QString charset = KCharsets::charsets()->encodingForName(m_encodingDescriptions.at(id)); KConfigGroup cg(&config, host); cg.writeEntry(DATA_KEY, charset); config.sync(); @@ -187,9 +173,9 @@ void DolphinRemoteEncoding::slotDefault() { // We have no choice but delete all higher domain level // settings here since it affects what will be matched. - KConfig config(("kio_" + m_currentURL.protocol() + "rc").toLatin1()); + KConfig config(("kio_" + m_currentURL.scheme() + "rc").toLatin1()); - QStringList partList = m_currentURL.host().split('.', QString::SkipEmptyParts); + QStringList partList = m_currentURL.host().split('.', Qt::SkipEmptyParts); if (!partList.isEmpty()) { partList.erase(partList.begin()); @@ -208,12 +194,12 @@ void DolphinRemoteEncoding::slotDefault() break; } - domains << partList.join("."); + domains << partList.join(QLatin1Char('.')); partList.erase(partList.begin()); } for (QStringList::const_iterator it = domains.constBegin(); it != domains.constEnd();++it) { - kDebug() << "Domain to remove: " << *it; + qCDebug(DolphinDebug) << "Domain to remove: " << *it; if (config.hasGroup(*it)) { config.deleteGroup(*it); } else if (config.group("").hasKey(*it)) { @@ -235,4 +221,3 @@ void DolphinRemoteEncoding::updateView() m_actionHandler->currentView()->reload(); } -#include "dolphinremoteencoding.moc"