MythTV master
mythchanneloverlay.cpp
Go to the documentation of this file.
1// Qt
2#include <QCoreApplication>
3
4// MythTV
9#include "tv_play.h"
10
11#define LOC QString("ChannelEdit: ")
12
14 : MythScreenType(static_cast<MythScreenType*>(nullptr), Name),
15 m_mainWindow(MainWindow),
16 m_tv(Tv)
17{
18}
19
21{
22 if (!XMLParseBase::LoadWindowFromXML("osd.xml", "ChannelEditor", this))
23 return false;
24
25 MythUIButton *probeButton = nullptr;
26 MythUIButton *okButton = nullptr;
27
28 bool err = false;
29 UIUtilE::Assign(this, m_callsignEdit, "callsign", &err);
30 UIUtilE::Assign(this, m_channumEdit, "channum", &err);
31 UIUtilE::Assign(this, m_channameEdit, "channame", &err);
32 UIUtilE::Assign(this, m_xmltvidEdit, "XMLTV", &err);
33 UIUtilE::Assign(this, probeButton, "probe", &err);
34 UIUtilE::Assign(this, okButton, "ok", &err);
35
36 if (err)
37 {
38 LOG(VB_GENERAL, LOG_ERR, "Cannot load screen 'ChannelEditor'");
39 return false;
40 }
41
43 connect(okButton, &MythUIButton::Clicked, this, &MythChannelOverlay::Confirm);
44 connect(probeButton, &MythUIButton::Clicked, this, &MythChannelOverlay::Probe);
45 SetFocusWidget(okButton);
46
47 return true;
48}
49
51{
52 SendResult(1);
53}
54
56{
57 SendResult(2);
58}
59
61{
62 if (Map.contains("callsign"))
63 m_callsignEdit->SetText(Map.value("callsign"));
64 if (Map.contains("channum"))
65 m_channumEdit->SetText(Map.value("channum"));
66 if (Map.contains("channame"))
67 m_channameEdit->SetText(Map.value("channame"));
68 if (Map.contains("XMLTV"))
69 m_xmltvidEdit->SetText(Map.value("XMLTV"));
70}
71
73{
74 Map["callsign"] = m_callsignEdit->GetText();
75 Map["channum"] = m_channumEdit->GetText();
76 Map["channame"] = m_channameEdit->GetText();
77 Map["XMLTV"] = m_xmltvidEdit->GetText();
78}
79
81{
83 return true;
84
85 QStringList actions;
86 bool handled = m_mainWindow->TranslateKeyPress("qt", Event, actions);
87
88 for (int i = 0; i < actions.size() && !handled; i++)
89 {
90 const QString& action = actions[i];
91 if (action == "ESCAPE" )
92 {
93 SendResult(3);
94 handled = true;
95 }
96 }
97
98 if (!handled && MythScreenType::keyPressEvent(Event))
99 handled = true;
100
101 return handled;
102}
103
105{
106 if (!m_tv)
107 return;
108
109 QString message = "";
110 switch (result)
111 {
112 case 1:
113 message = "DIALOG_EDITOR_OK_0";
114 break;
115 case 2:
116 message = "DIALOG_EDITOR_PROBE_0";
117 break;
118 case 3:
119 message = "DIALOG_EDITOR_QUIT_0";
120 break;
121 }
122
123 auto *dce = new DialogCompletionEvent("", result, "", message);
124 QCoreApplication::postEvent(m_tv, dce);
125}
Event dispatched from MythUI modal dialogs to a listening class containing a result of some form.
Definition: mythdialogbox.h:41
Event details.
Definition: zmdefines.h:28
void SetText(const InfoMap &Map)
MythUITextEdit * m_channameEdit
MythChannelOverlay(MythMainWindow *MainWindow, TV *Tv, const QString &Name)
void GetText(InfoMap &Map)
MythUITextEdit * m_channumEdit
void SendResult(int result)
MythUITextEdit * m_callsignEdit
MythMainWindow * m_mainWindow
MythUITextEdit * m_xmltvidEdit
bool keyPressEvent(QKeyEvent *Event) override
Key event handler.
bool Create() override
bool TranslateKeyPress(const QString &Context, QKeyEvent *Event, QStringList &Actions, bool AllowJumps=true)
Get a list of actions for a keypress in the given context.
Screen in which all other widgets are contained and rendered.
void BuildFocusList(void)
MythUIType * GetFocusWidget(void) const
bool keyPressEvent(QKeyEvent *event) override
Key event handler.
bool SetFocusWidget(MythUIType *widget=nullptr)
A single button widget.
Definition: mythuibutton.h:22
void Clicked()
QString GetText(void) const
void SetText(const QString &text, bool moveCursor=true)
Control TV playback.
Definition: tv_play.h:156
static bool LoadWindowFromXML(const QString &xmlfile, const QString &windowname, MythUIType *parent)
#define LOG(_MASK_, _LEVEL_, _QSTRING_)
Definition: mythlogging.h:39
QHash< QString, QString > InfoMap
Definition: mythtypes.h:15
static bool Assign(ContainerType *container, UIType *&item, const QString &name, bool *err=nullptr)
Definition: mythuiutils.h:27