File indexing completed on 2024-05-05 04:38:44
0001 /* 0002 SPDX-FileCopyrightText: 2007 Dukju Ahn <dukjuahn@gmail.com> 0003 0004 SPDX-License-Identifier: LGPL-2.0-or-later 0005 */ 0006 0007 #ifndef KDEVPLATFORM_ENVIRONMENTSELECTIONWIDGET_H 0008 #define KDEVPLATFORM_ENVIRONMENTSELECTIONWIDGET_H 0009 0010 #include <QWidget> 0011 0012 #include "utilexport.h" 0013 0014 namespace KDevelop { 0015 class EnvironmentProfileList; 0016 class EnvironmentSelectionWidgetPrivate; 0017 0018 /** 0019 * Simple combobox which allows each plugin to decide which environment 0020 * variable group to use. 0021 * 0022 * Can be used just like a KComboBox in Configuration dialogs including usage 0023 * with KConfigXT. 0024 * 0025 * @note The widget is populated and defaulted automatically. 0026 * 0027 */ 0028 class KDEVPLATFORMUTIL_EXPORT EnvironmentSelectionWidget : public QWidget 0029 { 0030 Q_OBJECT 0031 Q_PROPERTY(QString currentProfile READ currentProfile WRITE setCurrentProfile NOTIFY currentProfileChanged USER true) 0032 0033 public: 0034 explicit EnvironmentSelectionWidget(QWidget* parent = nullptr); 0035 ~EnvironmentSelectionWidget() override; 0036 0037 /** 0038 * @returns The currently selected environment profile name, as written to KConfigXT 0039 */ 0040 QString currentProfile() const; 0041 0042 /** 0043 * Sets the environment profile to be written to KConfigXT and updates the combo-box. 0044 * 0045 * @param text The environment profile name to select 0046 */ 0047 void setCurrentProfile(const QString& text); 0048 0049 /** 0050 * @returns The currently effective environment profile name (like @ref currentProfile(), 0051 * but with empty value resolved to the default profile). 0052 */ 0053 QString effectiveProfileName() const; 0054 0055 /** 0056 * @returns The @ref EnvironmentProfileList which has been used to populate this 0057 * widget. 0058 */ 0059 EnvironmentProfileList environmentProfiles() const; 0060 0061 public Q_SLOTS: 0062 /** 0063 * Makes the widget re-read its environment group list. 0064 */ 0065 void reconfigure(); 0066 0067 Q_SIGNALS: 0068 void currentProfileChanged(const QString& currentProfile); 0069 0070 private: 0071 const QScopedPointer<class EnvironmentSelectionWidgetPrivate> d_ptr; 0072 Q_DECLARE_PRIVATE(EnvironmentSelectionWidget) 0073 friend class EnvironmentSelectionWidgetPrivate; 0074 }; 0075 0076 } 0077 0078 #endif