MythTV  master
channelscanner_gui_scan_pane.cpp
Go to the documentation of this file.
1 /* -*- Mode: c++ -*-
2  * vim: set expandtab tabstop=4 shiftwidth=4:
3  *
4  * Original Project
5  * MythTV http://www.mythtv.org
6  *
7  * Copyright (c) 2004, 2005 John Pullan <john@pullan.org>
8  * Copyright (c) 2005 - 2007 Daniel Kristjansson
9  *
10  * Description:
11  * Collection of classes to provide channel scanning functionallity
12  *
13  * This program is free software; you can redistribute it and/or
14  * modify it under the terms of the GNU General Public License
15  * as published by the Free Software Foundation; either version 2
16  * of the License, or (at your option) any later version.
17  *
18  * This program is distributed in the hope that it will be useful,
19  * but WITHOUT ANY WARRANTY; without even the implied warranty of
20  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
21  * GNU General Public License for more details.
22  *
23  * You should have received a copy of the GNU General Public License
24  * along with this program; if not, write to the Free Software
25  * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA
26  * Or, point your browser to http://www.gnu.org/copyleft/gpl.html
27  *
28  */
29 
31 #include "mythlogging.h"
32 #include "mythuiprogressbar.h"
33 #include "mythuitext.h"
34 #include "mythuibuttonlist.h"
35 #include "mythuibutton.h"
36 
38  bool lock, bool strength,
39  bool snr, bool rotorpos,
40  MythScreenStack *parent)
41  : MythScreenType(parent, "channelscanner"),
42  m_showSignalLock(lock), m_showSignalStrength(strength),
43  m_showSignalNoise(snr), m_showRotorPos(rotorpos),
44  m_signalStrengthBar(nullptr), m_signalNoiseBar(nullptr),
45  m_rotatorPositionBar(nullptr), m_progressBar(nullptr),
46  m_statusText(nullptr), m_scanProgressText(nullptr),
47  m_signalLockedText(nullptr), m_signalStrengthText(nullptr),
48  m_signalNoiseText(nullptr), m_rotatorPositionText(nullptr),
49  m_progressText(nullptr), m_log(nullptr)
50 {
51 }
52 
54 {
55  if (!XMLParseBase::LoadWindowFromXML("config-ui.xml", "channelscanner",
56  this))
57  {
58  LOG(VB_GENERAL, LOG_ERR, "Failed to load channelscanner screen");
59  return false;
60  }
61 
62  bool error = false;
63  UIUtilE::Assign(this, m_statusText, "status", &error);
64  UIUtilE::Assign(this, m_log, "log", &error);
65 
66  UIUtilE::Assign(this, m_progressBar, "scanprogress", &error);
67  if (error)
68  return false;
69 
70  // Percent done
71  UIUtilW::Assign(this, m_progressText, "progresstext");
72  // Found status
73  UIUtilW::Assign(this, m_scanProgressText, "scanprogresstext");
74 
75  UIUtilW::Assign(this, m_signalLockedText, "signallock");
78 
79  UIUtilW::Assign(this, m_rotatorPositionText, "rotorprogresstext");
82 
83  UIUtilW::Assign(this, m_rotatorPositionBar, "rotorprogressbar");
85  {
88  }
89 
90  UIUtilW::Assign(this, m_signalStrengthText, "signalstrengthtext");
93 
94  UIUtilW::Assign(this, m_signalStrengthBar, "signalstrength");
96  {
99  }
100 
101  UIUtilW::Assign(this, m_signalNoiseText, "signalnoisetext");
102  if (m_signalNoiseText)
104 
105  UIUtilW::Assign(this, m_signalNoiseBar, "signalnoise");
106  if (m_signalNoiseBar)
107  {
109  m_signalNoiseBar->SetTotal(65535);
110  }
111 
112  m_statusText->SetText(tr("Tuning"));
113  m_progressBar->SetTotal(65535);
114 
115  MythUIButton *exitButton = nullptr;
116  UIUtilW::Assign(this, exitButton, "exit");
117  if (exitButton)
118  connect(exitButton, SIGNAL(Clicked()), SLOT(Close()));
119 
120  BuildFocusList();
121 
122  return true;
123 }
124 
126 {
128  m_rotatorPositionText->SetText(tr("%1%")
129  .arg(static_cast<uint>(value * 100 / 65535)));
132 }
133 
135 {
136  if (m_signalNoiseText)
137  m_signalNoiseText->SetText(tr("%1%")
138  .arg(static_cast<uint>(value * 100 / 65535)));
139  if (m_signalNoiseBar)
140  m_signalNoiseBar->SetUsed(value);
141 }
142 
144 {
146  m_signalStrengthText->SetText(tr("%1%")
147  .arg(static_cast<uint>(value * 100 / 65535)));
150 }
151 
153 {
154  if (m_signalLockedText)
155  m_signalLockedText->SetText((value) ? tr("Locked") : tr("No Lock"));
156 }
157 
159 {
160  if (m_statusText)
161  m_statusText->SetText(value);
162 }
163 
165 {
166  if (m_scanProgressText)
167  m_scanProgressText->SetText(tr("%1").arg(value));
168 }
169 
170 void ChannelScannerGUIScanPane::AppendLine(const QString &text)
171 {
172  if (m_log)
173  {
174  MythUIButtonListItem *listItem = new MythUIButtonListItem(m_log, text);
175  m_log->SetItemCurrent(listItem);
176  }
177 }
178 
180 {
181  if (m_progressText)
182  m_progressText->SetText(tr("%1%")
183  .arg(static_cast<uint>(value * 100)));
184  if (m_progressBar)
185  m_progressBar->SetUsed(static_cast<uint>(value * 65535));
186 }
void SetStatusText(const QString &value)
void SetVisible(bool visible) override
static void error(const char *str,...)
Definition: vbi.c:41
void SetStatusTitleText(const QString &value)
virtual void SetText(const QString &text)
Definition: mythuitext.cpp:168
void BuildFocusList(void)
virtual void Close()
virtual void SetVisible(bool visible)
static bool Assign(ContainerType *container, UIType *&item, const QString &name, bool *err=nullptr)
Definition: mythuiutils.h:27
static bool LoadWindowFromXML(const QString &xmlfile, const QString &windowname, MythUIType *parent)
A single button widget.
Definition: mythuibutton.h:21
#define LOG(_MASK_, _LEVEL_, _STRING_)
Definition: mythlogging.h:41
ChannelScannerGUIScanPane(bool lock, bool strength, bool snr, bool rotorpos, MythScreenStack *parent)
void SetItemCurrent(MythUIButtonListItem *item)
Screen in which all other widgets are contained and rendered.