MythTV  master
mythchanneloverlay.cpp
Go to the documentation of this file.
1 // Qt
2 #include <QCoreApplication>
3 
4 // MythTV
5 #include "mythlogging.h"
6 #include "mythdialogbox.h"
7 #include "mythuibutton.h"
8 #include "tv_play.h"
9 #include "mythchanneloverlay.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  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 }
MythUIButton::Clicked
void Clicked()
MythChannelOverlay::m_xmltvidEdit
MythUITextEdit * m_xmltvidEdit
Definition: mythchanneloverlay.h:31
MythChannelOverlay::m_mainWindow
MythMainWindow * m_mainWindow
Definition: mythchanneloverlay.h:32
MythChannelOverlay::m_tv
TV * m_tv
Definition: mythchanneloverlay.h:33
MythChannelOverlay::SendResult
void SendResult(int result)
Definition: mythchanneloverlay.cpp:104
mythdialogbox.h
LOG
#define LOG(_MASK_, _LEVEL_, _QSTRING_)
Definition: mythlogging.h:23
MythScreenType
Screen in which all other widgets are contained and rendered.
Definition: mythscreentype.h:44
MythUITextEdit::GetText
QString GetText(void) const
Definition: mythuitextedit.h:47
MythScreenType::GetFocusWidget
MythUIType * GetFocusWidget(void) const
Definition: mythscreentype.cpp:112
InfoMap
QHash< QString, QString > InfoMap
Definition: mythtypes.h:15
MythUITextEdit::SetText
void SetText(const QString &text, bool moveCursor=true)
Definition: mythuitextedit.cpp:216
MythChannelOverlay::m_channumEdit
MythUITextEdit * m_channumEdit
Definition: mythchanneloverlay.h:29
MythChannelOverlay::Probe
void Probe()
Definition: mythchanneloverlay.cpp:55
mythlogging.h
MythMainWindow::TranslateKeyPress
bool TranslateKeyPress(const QString &Context, QKeyEvent *Event, QStringList &Actions, bool AllowJumps=true)
Get a list of actions for a keypress in the given context.
Definition: mythmainwindow.cpp:1114
Event
Event details.
Definition: zmdefines.h:26
MythScreenType::SetFocusWidget
bool SetFocusWidget(MythUIType *widget=nullptr)
Definition: mythscreentype.cpp:117
MythChannelOverlay::m_callsignEdit
MythUITextEdit * m_callsignEdit
Definition: mythchanneloverlay.h:28
MythScreenType::BuildFocusList
void BuildFocusList(void)
Definition: mythscreentype.cpp:222
MythChannelOverlay::MythChannelOverlay
MythChannelOverlay(MythMainWindow *MainWindow, TV *Tv, const QString &Name)
Definition: mythchanneloverlay.cpp:13
MythUIButton
A single button widget.
Definition: mythuibutton.h:21
MythChannelOverlay::m_channameEdit
MythUITextEdit * m_channameEdit
Definition: mythchanneloverlay.h:30
UIUtilDisp::Assign
static bool Assign(ContainerType *container, UIType *&item, const QString &name, bool *err=nullptr)
Definition: mythuiutils.h:27
MythScreenType::keyPressEvent
bool keyPressEvent(QKeyEvent *event) override
Key event handler.
Definition: mythscreentype.cpp:414
MythChannelOverlay::Create
bool Create() override
Definition: mythchanneloverlay.cpp:20
XMLParseBase::LoadWindowFromXML
static bool LoadWindowFromXML(const QString &xmlfile, const QString &windowname, MythUIType *parent)
Definition: xmlparsebase.cpp:692
Name
Definition: channelsettings.cpp:46
DialogCompletionEvent
Event dispatched from MythUI modal dialogs to a listening class containing a result of some form.
Definition: mythdialogbox.h:41
build_compdb.action
action
Definition: build_compdb.py:9
mythuibutton.h
mythchanneloverlay.h
MythChannelOverlay::keyPressEvent
bool keyPressEvent(QKeyEvent *Event) override
Key event handler.
Definition: mythchanneloverlay.cpp:80
MythChannelOverlay::SetText
void SetText(const InfoMap &Map)
Definition: mythchanneloverlay.cpp:60
MythChannelOverlay::Confirm
void Confirm()
Definition: mythchanneloverlay.cpp:50
MythMainWindow
Definition: mythmainwindow.h:34
MythChannelOverlay::GetText
void GetText(InfoMap &Map)
Definition: mythchanneloverlay.cpp:72
tv_play.h
TV
Control TV playback.
Definition: tv_play.h:152