File indexing completed on 2024-12-01 08:10:06
0001 /* 0002 SPDX-FileCopyrightText: 2013-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_CONNECTION_EDITOR_BASE_H 0008 #define PLASMA_NM_CONNECTION_EDITOR_BASE_H 0009 0010 #include "plasmanm_editor_export.h" 0011 0012 #include <QDBusPendingCallWatcher> 0013 #include <QWidget> 0014 0015 #include <NetworkManagerQt/ConnectionSettings> 0016 0017 class ConnectionWidget; 0018 class SettingWidget; 0019 class WifiSecurity; 0020 0021 class PLASMANM_EDITOR_EXPORT ConnectionEditorBase : public QWidget 0022 { 0023 Q_OBJECT 0024 public: 0025 explicit ConnectionEditorBase(const NetworkManager::ConnectionSettings::Ptr &connection, QWidget *parent = nullptr, Qt::WindowFlags f = Qt::WindowFlags()); 0026 explicit ConnectionEditorBase(QWidget *parent = nullptr, Qt::WindowFlags f = Qt::WindowFlags()); 0027 ~ConnectionEditorBase() override; 0028 0029 // When reimplementing do not forget to call the base method as well to initialize widgets 0030 virtual void setConnection(const NetworkManager::ConnectionSettings::Ptr &connection); 0031 0032 NMVariantMapMap setting() const; 0033 0034 // Returns whether the editor is fully initialized (including secrets) 0035 bool isInitialized() const; 0036 0037 // Returns whether the filled values are valid 0038 bool isValid() const; 0039 0040 Q_SIGNALS: 0041 // The default value is supposed to be false, watch this property for validity change after 0042 // proper initialization with secrets 0043 void validityChanged(bool valid); 0044 0045 // Emitted when user changed configuration 0046 void settingChanged(); 0047 0048 private Q_SLOTS: 0049 void replyFinished(QDBusPendingCallWatcher *watcher); 0050 void validChanged(bool valid); 0051 void onAllUsersChanged(); 0052 0053 protected: 0054 // Subclassed widget is supposed to take care of layouting for setting widgets 0055 virtual void addWidget(QWidget *widget, const QString &text) = 0; 0056 0057 // Subclassed widget is supposed to provide an UI (input label) for editing connection name separately 0058 virtual QString connectionName() const = 0; 0059 0060 // Subclassed widget is supposed to call initialization after the UI is initialized 0061 void initialize(); 0062 0063 private: 0064 bool m_initialized; 0065 bool m_valid; 0066 int m_pendingReplies; 0067 NetworkManager::ConnectionSettings::Ptr m_connection; 0068 ConnectionWidget *m_connectionWidget = nullptr; 0069 QList<SettingWidget *> m_settingWidgets; 0070 WifiSecurity *m_wifiSecurity = nullptr; 0071 0072 void addConnectionWidget(ConnectionWidget *widget, const QString &text); 0073 void addSettingWidget(SettingWidget *widget, const QString &text); 0074 }; 0075 0076 #endif // PLASMA_NM_CONNECTION_EDITOR_BASE_H