1 /* ============================================================ 2 * 3 * This file is a part of digiKam project 4 * https://www.digikam.org 5 * 6 * Date : 2009-06-15 7 * Description : multi-languages string editor 8 * 9 * Copyright (C) 2009-2021 by Gilles Caulier <caulier dot gilles at gmail dot com> 10 * 11 * This program is free software; you can redistribute it 12 * and/or modify it under the terms of the GNU General 13 * Public License as published by the Free Software Foundation; 14 * either version 2, or (at your option) 15 * any later version. 16 * 17 * This program is distributed in the hope that it will be useful, 18 * but WITHOUT ANY WARRANTY; without even the implied warranty of 19 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 20 * GNU General Public License for more details. 21 * 22 * ============================================================ */ 23 24 #ifndef DIGIKAM_ALT_LANG_STR_EDIT_H 25 #define DIGIKAM_ALT_LANG_STR_EDIT_H 26 27 // Qt includes 28 29 #include <QWidget> 30 #include <QString> 31 #include <QTextEdit> 32 33 // Local includes 34 35 #include "digikam_export.h" 36 #include "dmetadata.h" 37 38 namespace Digikam 39 { 40 41 class DIGIKAM_EXPORT AltLangStrEdit : public QWidget 42 { 43 Q_OBJECT 44 45 public: 46 47 explicit AltLangStrEdit(QWidget* const parent); 48 ~AltLangStrEdit() override; 49 50 void setTitle(const QString& title); 51 void setPlaceholderText(const QString& msg); 52 53 void setCurrentLanguageCode(const QString& lang); 54 QString currentLanguageCode() const; 55 56 QString languageCode(int index) const; 57 58 void setValues(const MetaEngine::AltLangMap& values); 59 MetaEngine::AltLangMap& values() const; 60 61 /** 62 * Fix lines visibile in text editor to lines. If zero, do not fix layout to number of lines visible. 63 */ 64 void setLinesVisible(uint lines); 65 uint linesVisible() const; 66 67 QString defaultAltLang() const; 68 bool asDefaultAltLang() const; 69 70 /** 71 * Reset widget, clear all entries 72 */ 73 void reset(); 74 75 /** 76 * Ensure that the current language is added to the list of entries, 77 * even if the text is empty. 78 * signalValueAdded() will be emitted. 79 */ 80 void addCurrent(); 81 82 QTextEdit* textEdit() const; 83 84 Q_SIGNALS: 85 86 /// Emitted when the user changes the text for the current language. 87 void signalModified(const QString& lang, const QString& text); 88 89 /// Emitted when the current language changed. 90 void signalSelectionChanged(const QString& lang); 91 92 /// Emitted when an entry for a new language is added. 93 void signalValueAdded(const QString& lang, const QString& text); 94 95 /// Emitted when the entry for a language is removed. 96 void signalValueDeleted(const QString& lang); 97 98 protected Q_SLOTS: 99 100 void slotTextChanged(); 101 void slotSelectionChanged(); 102 void slotDeleteValue(); 103 104 protected: 105 106 void loadLangAltListEntries(); 107 108 void changeEvent(QEvent* e) override; 109 110 private: 111 112 class Private; 113 Private* const d; 114 115 friend class Private; 116 }; 117 118 } // namespace Digikam 119 120 #endif // DIGIKAM_ALT_LANG_STR_EDIT_H 121