1 #include "common/common_pch.h"
2 
3 #include <QLineEdit>
4 
5 #include "common/qt.h"
6 #include "mkvtoolnix-gui/header_editor/string_value_page.h"
7 
8 namespace mtx::gui::HeaderEditor {
9 
10 using namespace mtx::gui;
11 
StringValuePage(Tab & parent,PageBase & topLevelPage,EbmlMaster & master,EbmlCallbacks const & callbacks,translatable_string_c const & title,translatable_string_c const & description)12 StringValuePage::StringValuePage(Tab &parent,
13                                  PageBase &topLevelPage,
14                                  EbmlMaster &master,
15                                  EbmlCallbacks const &callbacks,
16                                  translatable_string_c const &title,
17                                  translatable_string_c const &description)
18   : ValuePage{parent, topLevelPage, master, callbacks, ValueType::String, title, description}
19 {
20 }
21 
~StringValuePage()22 StringValuePage::~StringValuePage() {
23 }
24 
25 QWidget *
createInputControl()26 StringValuePage::createInputControl() {
27   if (m_element)
28     m_originalValue = Q(static_cast<EbmlUnicodeString *>(m_element)->GetValue());
29 
30   m_leValue = new QLineEdit{this};
31   m_leValue->setText(m_originalValue);
32   m_leValue->setClearButtonEnabled(true);
33 
34   return m_leValue;
35 }
36 
37 QString
originalValueAsString() const38 StringValuePage::originalValueAsString()
39   const {
40   return m_originalValue;
41 }
42 
43 QString
currentValueAsString() const44 StringValuePage::currentValueAsString()
45   const {
46   return m_leValue->text();
47 }
48 
49 void
resetValue()50 StringValuePage::resetValue() {
51   m_leValue->setText(m_originalValue);
52 }
53 
54 bool
validateValue() const55 StringValuePage::validateValue()
56   const {
57   return true;
58 }
59 
60 void
copyValueToElement()61 StringValuePage::copyValueToElement() {
62   static_cast<EbmlUnicodeString *>(m_element)->SetValue(to_wide(m_leValue->text()));
63 }
64 
65 }
66