*/
#include "dolphinremoteencoding.h"
+
#include "dolphinviewactionhandler.h"
+#include "dolphindebug.h"
-#include <KDebug>
-#include <KActionMenu>
#include <KActionCollection>
-#include <KIcon>
-#include <KLocale>
-#include <KGlobal>
-#include <KMimeType>
-#include <KConfig>
+#include <KActionMenu>
#include <KCharsets>
-#include <KMenu>
+#include <KConfig>
+#include <KConfigGroup>
+#include <KIO/Scheduler>
+#include <KLocalizedString>
#include <KProtocolInfo>
#include <KProtocolManager>
-#include <KIO/Scheduler>
-#include <KConfigGroup>
-#define DATA_KEY QLatin1String("Charset")
+#include <QMenu>
+
+#define DATA_KEY QStringLiteral("Charset")
DolphinRemoteEncoding::DolphinRemoteEncoding(QObject* parent, DolphinViewActionHandler* actionHandler)
:QObject(parent),
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);
- connect(m_menu->menu(), SIGNAL(aboutToShow()),
- this, SLOT(slotAboutToShow()));
+ 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);
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() &&
menu->addAction(i18n("Default"), this, SLOT(slotDefault()), 0)->setCheckable(true);
m_idDefault = m_encodingDescriptions.size() + 2;
- connect(menu, SIGNAL(triggered(QAction*)), this, SLOT(slotItemSelected(QAction*)));
+ connect(menu, &QMenu::triggered, this, &DolphinRemoteEncoding::slotItemSelected);
}
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;
}
}
- 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);
}
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();
{
// 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);
if (!partList.isEmpty()) {
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)) {
m_actionHandler->currentView()->reload();
}
-#include "dolphinremoteencoding.moc"