File indexing completed on 2024-04-28 15:34:21

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