File indexing completed on 2024-10-06 10:58:14

0001 /*
0002     SPDX-FileCopyrightText: 2016 Jan Grulich <jgrulich@redhat.com>
0003 
0004     SPDX-License-Identifier: LGPL-2.1-only OR LGPL-3.0-only OR LicenseRef-KDE-Accepted-LGPL
0005 */
0006 
0007 #ifndef PLASMA_NM_KCM_H
0008 #define PLASMA_NM_KCM_H
0009 
0010 #include "connectioneditortabwidget.h"
0011 #include "handler.h"
0012 
0013 #include <KCModule>
0014 #include <ui_kcm.h>
0015 
0016 class KMessageWidget;
0017 
0018 class KCMNetworkmanagement : public KCModule
0019 {
0020     Q_OBJECT
0021 public:
0022     explicit KCMNetworkmanagement(QWidget *parent = nullptr, const QVariantList &args = QVariantList());
0023     ~KCMNetworkmanagement() override;
0024 
0025 public Q_SLOTS:
0026     void defaults() override;
0027     void load() override;
0028     void save() override;
0029 
0030 private Q_SLOTS:
0031     void onConnectionAdded(const QString &connection);
0032     void onSelectedConnectionChanged(const QString &connectionPath);
0033     void onRequestCreateConnection(int connectionType, const QString &vpnType, const QString &specificType, bool shared);
0034     void onRequestExportConnection(const QString &connectionPath);
0035     void onRequestToChangeConnection(const QString &connectionName, const QString &connectionPath);
0036 
0037 private:
0038     struct ImportResult {
0039         bool success;
0040         QString errorMessage;
0041 
0042         static ImportResult pass();
0043         static ImportResult fail(const QString &message);
0044     };
0045 
0046     void addConnection(const NetworkManager::ConnectionSettings::Ptr &connectionSettings);
0047     [[nodiscard]] KCMNetworkmanagement::ImportResult importVpn();
0048     void kcmChanged(bool kcmChanged);
0049     void loadConnectionSettings(const NetworkManager::ConnectionSettings::Ptr &connectionSettings);
0050     void resetSelection();
0051 
0052     QString m_currentConnectionPath;
0053     QString m_createdConnectionUuid;
0054     Handler *const m_handler;
0055     ConnectionEditorTabWidget *m_tabWidget = nullptr;
0056     QTimer *m_timer = nullptr;
0057     KMessageWidget *m_errorWidget;
0058     Ui::KCMForm *const m_ui;
0059 };
0060 
0061 #endif