File indexing completed on 2024-03-24 04:03:44
0001 /* 0002 * SPDX-FileCopyrightText: 2003 Ingo Kloecker <kloecker@kde.org> 0003 * SPDX-FileCopyrightText: 2008 Tom Albers <tomalbers@kde.nl> 0004 * 0005 * SPDX-License-Identifier: LGPL-2.1-or-later 0006 */ 0007 0008 #ifndef SONNET_DICTIONARYCOMBOBOX_H 0009 #define SONNET_DICTIONARYCOMBOBOX_H 0010 0011 #include "sonnetui_export.h" 0012 0013 #include <QComboBox> 0014 0015 #include <memory> 0016 0017 namespace Sonnet 0018 { 0019 class DictionaryComboBoxPrivate; 0020 /** 0021 * @class Sonnet::DictionaryComboBox dictionarycombobox.h <Sonnet/DictionaryComboBox> 0022 * 0023 * @short A combo box for selecting the dictionary used for spell checking. 0024 * @author Ingo Kloecker <kloecker@kde.org> 0025 * @author Tom Albers <tomalbers@kde.nl> 0026 * @since 4.2 0027 **/ 0028 0029 class SONNETUI_EXPORT DictionaryComboBox : public QComboBox 0030 { 0031 Q_OBJECT 0032 public: 0033 /** 0034 * Constructor 0035 */ 0036 explicit DictionaryComboBox(QWidget *parent = nullptr); 0037 0038 /** 0039 * Destructor 0040 */ 0041 ~DictionaryComboBox() override; 0042 0043 /** 0044 * Clears the widget and reloads the dictionaries from Sonnet. 0045 * Remember to set the dictionary you want selected after calling this function. 0046 */ 0047 void reloadCombo(); 0048 0049 /** 0050 * Returns the current dictionary name, for example "German (Switzerland)" 0051 */ 0052 QString currentDictionaryName() const; 0053 0054 /** 0055 * Returns the current dictionary, for example "de_CH" 0056 */ 0057 QString currentDictionary() const; 0058 0059 /** 0060 * Sets the current dictionaryName to the given dictionaryName 0061 */ 0062 void setCurrentByDictionaryName(const QString &dictionaryName); 0063 0064 /** 0065 * Sets the current dictionary to the given dictionary 0066 * Return true if dictionary was found. 0067 * @since 5.40 0068 * TODO merge with previous method in kf6 0069 */ 0070 bool assignByDictionnary(const QString &dictionary); 0071 0072 /** 0073 * Sets the current dictionaryName to the given dictionaryName 0074 * Return true if dictionary was found. 0075 * @since 5.40 0076 * TODO merge with previous method in kf6 0077 */ 0078 bool assignDictionnaryName(const QString &name); 0079 0080 /** 0081 * Sets the current dictionary to the given dictionary. 0082 */ 0083 void setCurrentByDictionary(const QString &dictionary); 0084 0085 Q_SIGNALS: 0086 /** 0087 * @em Emitted whenever the current dictionary changes. Either 0088 * by user intervention or on setCurrentByDictionaryName() or on 0089 * setCurrentByDictionary(). For example "de_CH". 0090 */ 0091 void dictionaryChanged(const QString &dictionary); 0092 0093 /** 0094 * @em Emitted whenever the current dictionary changes. Either 0095 * by user intervention or on setCurrentByDictionaryName() or on 0096 * setCurrentByDictionary(). For example "German (Switzerland)". 0097 */ 0098 void dictionaryNameChanged(const QString &dictionaryName); 0099 0100 private: 0101 std::unique_ptr<DictionaryComboBoxPrivate> const d; 0102 Q_PRIVATE_SLOT(d, void slotDictionaryChanged(int)) 0103 }; 0104 } 0105 0106 #endif