File indexing completed on 2025-04-27 03:58:40
0001 /* ============================================================ 0002 * 0003 * This file is a part of digiKam project 0004 * https://www.digikam.org 0005 * 0006 * Date : 2009-06-15 0007 * Description : localize selector widget 0008 * 0009 * SPDX-FileCopyrightText: 2009-2024 by Gilles Caulier <caulier dot gilles at gmail dot com> 0010 * 0011 * SPDX-License-Identifier: GPL-2.0-or-later 0012 * 0013 * ============================================================ */ 0014 0015 #ifndef DIGIKAM_LOCALIZE_SELECTOR_H 0016 #define DIGIKAM_LOCALIZE_SELECTOR_H 0017 0018 // Qt includes 0019 0020 #include <QWidget> 0021 #include <QString> 0022 #include <QStringList> 0023 #include <QPoint> 0024 0025 // Local includes 0026 0027 #include "digikam_export.h" 0028 #include "dlayoutbox.h" 0029 0030 class QListWidgetItem; 0031 0032 namespace Digikam 0033 { 0034 0035 class DIGIKAM_EXPORT LocalizeSelector : public DHBox 0036 { 0037 Q_OBJECT 0038 0039 public: 0040 0041 explicit LocalizeSelector(QWidget* const parent); 0042 ~LocalizeSelector() override; 0043 0044 void populateTranslationEntries(); 0045 0046 Q_SIGNALS: 0047 0048 void signalTranslate(const QString& lang); 0049 0050 private Q_SLOTS: 0051 0052 void slotLocalizeChanged(); 0053 void slotOpenLocalizeSetup(); 0054 void slotTranslate(QListWidgetItem*); 0055 0056 private: 0057 0058 class Private; 0059 Private* const d; 0060 }; 0061 0062 // ----------------------------------------------------------------- 0063 0064 class DIGIKAM_EXPORT LocalizeSelectorList : public QWidget 0065 { 0066 Q_OBJECT 0067 0068 public: 0069 0070 explicit LocalizeSelectorList(QWidget* const parent); 0071 ~LocalizeSelectorList() override; 0072 0073 void setTitle(const QString& title); 0074 0075 void clearLanguages(); 0076 void addLanguage(const QString& code); 0077 QStringList languagesList() const; 0078 0079 Q_SIGNALS: 0080 0081 void signalSettingsChanged(); 0082 0083 private Q_SLOTS: 0084 0085 void slotAppendTranslation(const QString& lang); 0086 void slotShowContextMenu(const QPoint& pos); 0087 0088 private: 0089 0090 class Private; 0091 Private* const d; 0092 }; 0093 0094 // ----------------------------------------------------------------- 0095 0096 /** 0097 * Helpher re-entrant static method to translate a string with online translator. 0098 * Language from string is auto-detected, and target language is specified to 'trCode'. 0099 * If string can be processed, translation is returned to 'tr' and function return true, 0100 * else false is returned with a dysfuntion description in 'error'. 0101 */ 0102 bool DIGIKAM_EXPORT s_inlineTranslateString(const QString& text, 0103 const QString& trCode, 0104 QString& tr, 0105 QString& error); 0106 0107 } // namespace Digikam 0108 0109 #endif // DIGIKAM_LOCALIZE_SELECTOR_H