]> cloud.milkyroute.net Git - dolphin.git/blobdiff - src/views/dolphinremoteencoding.cpp
Merge branch 'release/21.12'
[dolphin.git] / src / views / dolphinremoteencoding.cpp
index 961a7c80085f6b392076befdee2ed3a6d1bf68b7..c7c8b09d1f8d7205818bd69c7eae2beeab0247bd 100644 (file)
@@ -1,45 +1,33 @@
-/***************************************************************************
- *   Copyright (C) 2009 by Rahman Duran <rahman.duran@gmail.com>           *
- *                                                                         *
- *   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 <rahman.duran@gmail.com>
+ *
+ * SPDX-License-Identifier: GPL-2.0-or-later
+ */
 
  /*
  * This code is largely based on the kremoteencodingplugin
- * Copyright (c) 2003 Thiago Macieira <thiago.macieira@kdemail.net>
+ * SPDX-FileCopyrightText: 2003 Thiago Macieira <thiago.macieira@kdemail.net>
  * Distributed under the same terms.
  */
 
 #include "dolphinremoteencoding.h"
-#include "dolphinviewactionhandler.h"
 
+#include "dolphinviewactionhandler.h"
 #include "dolphindebug.h"
-#include <KActionMenu>
+
 #include <KActionCollection>
-#include <QIcon>
-#include <KLocalizedString>
-#include <KConfig>
+#include <KActionMenu>
 #include <KCharsets>
-#include <QMenu>
+#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),
@@ -47,13 +35,13 @@ DolphinRemoteEncoding::DolphinRemoteEncoding(QObject* parent, DolphinViewActionH
     m_loaded(false),
     m_idDefault(0)
 {
-    m_menu = new KActionMenu(QIcon::fromTheme("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()
@@ -102,7 +90,7 @@ void DolphinRemoteEncoding::fillMenu()
     QMenu* menu = m_menu->menu();
     menu->clear();
 
-
+    menu->addAction(i18n("Default"), this, SLOT(slotDefault()), 0)->setCheckable(true);
     for (int i = 0; i < m_encodingDescriptions.size();i++) {
         QAction* action = new QAction(m_encodingDescriptions.at(i), this);
         action->setCheckable(true);
@@ -112,7 +100,6 @@ void DolphinRemoteEncoding::fillMenu()
     menu->addSeparator();
 
     menu->addAction(i18n("Reload"), this, SLOT(slotReload()), 0);
-    menu->addAction(i18n("Default"), this, SLOT(slotDefault()), 0)->setCheckable(true);
     m_idDefault = m_encodingDescriptions.size() + 2;
 
     connect(menu, &QMenu::triggered, this, &DolphinRemoteEncoding::slotItemSelected);
@@ -187,7 +174,7 @@ void DolphinRemoteEncoding::slotDefault()
     // settings here since it affects what will be matched.
     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());
 
@@ -206,7 +193,7 @@ void DolphinRemoteEncoding::slotDefault()
                 break;
             }
 
-            domains << partList.join(".");
+            domains << partList.join(QLatin1Char('.'));
             partList.erase(partList.begin());
         }