File indexing completed on 2024-05-19 05:17:28
0001 // SPDX-FileCopyrightText: 2002 Marc Mutz <mutz@kde.org> 0002 // SPDX-License-Identifier: LGPL-2.0-or-later 0003 0004 #pragma once 0005 0006 #include "kidentitymanagementwidgets_export.h" 0007 #include <KIdentityManagementCore/Identity> 0008 0009 #include <QComboBox> 0010 0011 namespace KIdentityManagementCore 0012 { 0013 class IdentityManager; 0014 class Identity; 0015 } 0016 namespace KIdentityManagementWidgets 0017 { 0018 class IdentityComboPrivate; 0019 0020 /// \brief A combo box that always shows the up-to-date identity list. 0021 /// \author Marc Mutz \<mutz@kde.org\> 0022 class KIDENTITYMANAGEMENTWIDGETS_EXPORT IdentityCombo : public QComboBox 0023 { 0024 Q_OBJECT 0025 public: 0026 /// IdentityCombo contructor 0027 explicit IdentityCombo(KIdentityManagementCore::IdentityManager *manager, QWidget *parent = nullptr); 0028 0029 ~IdentityCombo() override; 0030 0031 /// Return the current identity name. 0032 [[nodiscard]] QString currentIdentityName() const; 0033 0034 /// Return the current identity id 0035 [[nodiscard]] KIdentityManagementCore::Identity::Id currentIdentity() const; 0036 0037 /// Return whether the current identity is the default identity. 0038 [[nodiscard]] bool isDefaultIdentity() const; 0039 0040 /// Set the current identity 0041 void setCurrentIdentity(const KIdentityManagementCore::Identity &identity); 0042 0043 /// Set the current identity by name. 0044 void setCurrentIdentity(const QString &identityName); 0045 0046 /// Set the current identity by Id 0047 void setCurrentIdentity(KIdentityManagementCore::Identity::Id uoid); 0048 0049 /// Show (default) on the default identity. By default this behavior is disabled. 0050 void setShowDefault(bool showDefault); 0051 0052 /// Returns the IdentityManager used in this combo box. 0053 /// @since 4.5 0054 [[nodiscard]] KIdentityManagementCore::IdentityManager *identityManager() const; 0055 0056 Q_SIGNALS: 0057 0058 /// \em Really emitted whenever the current identity changes. Either 0059 /// by user intervention or on setCurrentIdentity() or if the 0060 /// current identity disappears. 0061 /// 0062 /// You might also want to listen to IdentityManager::changed, 0063 /// IdentityManager::deleted and IdentityManager::added. 0064 void identityChanged(KIdentityManagementCore::Identity::Id uoid); 0065 void identityDeleted(KIdentityManagementCore::Identity::Id uoid); 0066 void invalidIdentity(); 0067 0068 public Q_SLOTS: 0069 /// Connected to IdentityManager::changed(). Reloads the list of identities. 0070 void slotIdentityManagerChanged(); 0071 0072 protected Q_SLOTS: 0073 void slotEmitChanged(int); 0074 void slotUpdateTooltip(uint uoid); 0075 0076 private: 0077 //@cond PRIVATE 0078 std::unique_ptr<IdentityComboPrivate> const d; 0079 //@endcond 0080 }; 0081 }