MythTV  master
lcdprocclient.h
Go to the documentation of this file.
1 #ifndef LCDPROCCLIENT_H_
2 #define LCDPROCCLIENT_H_
3 
4 #include <QStringList>
5 #include <QObject>
6 #include <QList>
7 #include <QTcpSocket>
8 
9 #include "tvremoteutil.h"
10 
11 using namespace std::chrono_literals;
12 
13 class LCDServer;
14 class LCDTextItem;
15 class LCDMenuItem;
16 class QEvent;
17 class QTimer;
18 
19 
20 class LCDProcClient : public QObject
21 {
22  Q_OBJECT
23 
24  public:
25 
26  explicit LCDProcClient(LCDServer *lparent);
27 
28  void customEvent(QEvent *e) override; // QObject
29 
30  ~LCDProcClient() override;
31 
32  bool SetupLCD(void);
33  void reset(void);
34 
35  void setStartupMessage(QString msg, std::chrono::seconds messagetime);
36 
37  // Used to actually connect to an LCD device
38  bool connectToHost(const QString &hostname, unsigned int port);
39 
40  void switchToTime();
41  void switchToMusic(const QString &artist, const QString &album, const QString &track);
42  void setMusicProgress(QString time, float value);
43  void setMusicRepeat(int repeat);
44  void setMusicShuffle(int shuffle);
45  void switchToChannel(const QString& channum = "", const QString& title = "",
46  const QString& subtitle = "");
47  void setChannelProgress(const QString &time, float value);
48  void switchToMenu(QList<LCDMenuItem> *menuItems, const QString& app_name = "",
49  bool popMenu = true);
50  void switchToGeneric(QList<LCDTextItem> *textItems);
51  void setGenericProgress(bool busy, float value);
52 
53  void switchToVolume(const QString& app_name);
54  void setVolumeLevel(float value);
55 
56  void switchToNothing();
57 
58  void shutdown();
59  void removeWidgets();
60  void updateLEDs(int mask);
61  void stopAll(void);
62 
63  int getLCDWidth(void) const { return m_lcdWidth; }
64  int getLCDHeight(void) const { return m_lcdHeight; }
65 
66  private slots:
67  void veryBadThings(QAbstractSocket::SocketError error); // Communication Errors
68  void serverSendingData(); // Data coming back from LCDd
69 
70  void checkConnections(); // check connections to LCDd and mythbackend
71  // every 10 seconds
72 
73  void dobigclock(void); // Large display
74  void dostdclock(); // Small display
75  void outputTime(); // Fire from a timer
76  void outputMusic(); // Short timer (equalizer)
77  void outputChannel(); // Longer timer (progress bar)
78  void outputGeneric(); // Longer timer (progress bar)
79  void outputVolume();
80  void outputRecStatus();
81  void scrollMenuText(); // Scroll the menu items if need be
82  void beginScrollingMenuText(); // But only after a bit of time has gone by
83  void unPopMenu(); // Remove the Pop Menu display
84  void scrollList(); // display a list line by line
85  void updateRecordingList(void);
86  void removeStartupMessage(void);
87  void beginScrollingWidgets(void);
88  void scrollWidgets(void);
89 
90  private:
91  void outputCenteredText(const QString& theScreen, QString theText,
92  const QString& widget = "topWidget", int row = 1);
93 
94  void outputLeftText(const QString& theScreen, QString theText,
95  const QString& widget = "topWidget", int row = 1);
96  void outputRightText(const QString& theScreen, QString theText,
97  const QString& widget = "topWidget", int row = 1);
98 
99  void outputScrollerText(const QString& theScreen, const QString& theText,
100  const QString& widget = "scroller", int top = 1, int bottom = 1);
101 
102  QStringList formatScrollerText(const QString &text) const;
103  void outputText(QList<LCDTextItem> *textItems);
104 
105  void sendToServer(const QString &someText);
106 
107  enum PRIORITY {TOP, URGENT, HIGH, MEDIUM, LOW, OFF};
108  void setPriority(const QString &screen, PRIORITY priority);
109 
110  void setHeartbeat (const QString &screen, bool onoff);
111  QString expandString(const QString &aString) const;
112 
113  void init();
114  void loadSettings(); //reload the settings from the db
115 
116  void assignScrollingList(QStringList theList, QString theScreen,
117  QString theWidget = "topWidget", int theRow = 1);
118 
119  // Scroll 1 or more widgets on a screen
120  void assignScrollingWidgets(const QString& theText, const QString& theScreen,
121  const QString& theWidget = "topWidget", int theRow = 1);
122  void formatScrollingWidgets(void);
123 
124  void startTime();
125  void startMusic(QString artist, const QString& album, const QString& track);
126  void startChannel(const QString& channum, const QString& title, const QString& subtitle);
127  void startGeneric(QList<LCDTextItem> * textItems);
128  void startMenu(QList<LCDMenuItem> *menuItems, QString app_name,
129  bool popMenu);
130  void startVolume(const QString& app_name);
131  void showStartupMessage(void);
132 
133  void setWidth(unsigned int x);
134  void setHeight(unsigned int x);
135  void setCellWidth(unsigned int x);
136  void setCellHeight(unsigned int x);
137  void setVersion(const QString &sversion, const QString &pversion);
138  void describeServer();
139 
140  QString m_activeScreen;
141 
142  QTcpSocket *m_socket {nullptr};
143  QTimer *m_timeTimer {nullptr};
144  QTimer *m_scrollWTimer {nullptr};
145  QTimer *m_preScrollWTimer {nullptr};
146  QTimer *m_menuScrollTimer {nullptr};
147  QTimer *m_menuPreScrollTimer {nullptr};
148  QTimer *m_popMenuTimer {nullptr};
149  QTimer *m_checkConnectionsTimer {nullptr};
150  QTimer *m_recStatusTimer {nullptr};
151  QTimer *m_scrollListTimer {nullptr};
152  QTimer *m_showMessageTimer {nullptr};
153  QTimer *m_updateRecInfoTimer {nullptr};
154 
155  QString m_prioTop;
156  QString m_prioUrgent;
157  QString m_prioHigh;
158  QString m_prioMedium;
159  QString m_prioLow;
160  QString m_prioOff;
161 
162  unsigned int m_lcdWidth {5};
163  unsigned int m_lcdHeight {1};
164  unsigned int m_cellWidth {1};
165  unsigned int m_cellHeight {1};
166 
169  int m_pVersion {0};
170 
171  float m_progress {0.0};
172  QString m_channelTime;
175  bool m_busyProgress {false};
178  int m_busyPos {0};
181  float m_busyIndicatorSize {0.0};
184  int m_busyDirection {1};
185  float m_genericProgress {0.0};
186  float m_volumeLevel {0.0};
187 
188  float m_musicProgress {0.0};
189  QString m_musicTime;
190  int m_musicRepeat {0};
191  int m_musicShuffle {0};
192 
193  QList<LCDTextItem> *m_lcdTextItems {nullptr};
194  //QString m_scrollingText;
195  QString m_scrollScreen;
196  unsigned int m_scrollPosition {0};
197  QString m_timeFormat;
198  QString m_dateFormat;
199 
200  QStringList m_scrollListItems;
203  int m_scrollListRow {0};
204  unsigned int m_scrollListItem {0};
205 
206  unsigned int m_menuScrollPosition {0};
207  QList<LCDMenuItem> *m_lcdMenuItems {nullptr};
208 
209  bool m_connected {false};
210  bool m_timeFlash {false};
211 
212  QString m_sendBuffer;
213  QString m_lastCommand;
214  QString m_hostname;
215  unsigned int m_port {13666};
216 
217  bool m_lcdReady {false};
218 
219  bool m_lcdShowTime {true};
220  bool m_lcdShowMenu {true};
221  bool m_lcdShowGeneric {true};
222  bool m_lcdShowMusic {true};
223  bool m_lcdShowChannel {true};
224  bool m_lcdShowVolume {true};
225  bool m_lcdShowRecstatus {true};
226  bool m_lcdBacklightOn {true};
227  bool m_lcdHeartbeatOn {true};
228  bool m_lcdBigClock {true};
229  std::chrono::milliseconds m_lcdPopupTime {0ms};
231  QString m_lcdKeyString;
232  LCDServer * m_parentLCDServer {nullptr};
234  std::chrono::seconds m_startupShowTime {0s};
235 
236  bool m_isRecording {false};
237  bool m_isTimeVisible {false};
238  int m_lcdTunerNo {0};
239 
240  std::vector<TunerStatus> m_tunerList;
241 };
242 
243 #endif
LCDProcClient::m_tunerList
std::vector< TunerStatus > m_tunerList
Definition: lcdprocclient.h:240
LCDProcClient::m_dateFormat
QString m_dateFormat
Definition: lcdprocclient.h:198
LCDProcClient::m_timeFormat
QString m_timeFormat
Definition: lcdprocclient.h:197
error
static void error(const char *str,...)
Definition: vbi.cpp:42
LCDProcClient::m_prioOff
QString m_prioOff
Definition: lcdprocclient.h:160
LCDProcClient::m_lcdShowMusicItems
QString m_lcdShowMusicItems
Definition: lcdprocclient.h:230
LCDProcClient::m_lastCommand
QString m_lastCommand
Definition: lcdprocclient.h:213
LCDProcClient::PRIORITY
PRIORITY
Definition: lcdprocclient.h:107
LCDProcClient::getLCDWidth
int getLCDWidth(void) const
Definition: lcdprocclient.h:63
LCDProcClient::m_activeScreen
QString m_activeScreen
Definition: lcdprocclient.h:140
LCDProcClient::m_scrollListScreen
QString m_scrollListScreen
Definition: lcdprocclient.h:201
LCDProcClient::m_prioHigh
QString m_prioHigh
Definition: lcdprocclient.h:157
LCDProcClient::m_lcdKeyString
QString m_lcdKeyString
Definition: lcdprocclient.h:231
LCDProcClient::m_serverVersion
QString m_serverVersion
Definition: lcdprocclient.h:167
LCDProcClient::m_protocolVersion
QString m_protocolVersion
Definition: lcdprocclient.h:168
LCDProcClient::m_prioTop
QString m_prioTop
Definition: lcdprocclient.h:155
LCDProcClient::m_hostname
QString m_hostname
Definition: lcdprocclient.h:214
LCDProcClient::m_channelTime
QString m_channelTime
Definition: lcdprocclient.h:172
LCDProcClient::m_prioLow
QString m_prioLow
Definition: lcdprocclient.h:159
LCDProcClient::m_sendBuffer
QString m_sendBuffer
Definition: lcdprocclient.h:212
shutdown
static int shutdown()
Definition: mythtv/programs/mythshutdown/main.cpp:454
tvremoteutil.h
LCDMenuItem
Definition: lcddevice.h:25
LCDServer
Definition: lcdserver.h:27
LCDProcClient::m_scrollScreen
QString m_scrollScreen
Definition: lcdprocclient.h:195
LCDProcClient
Definition: lcdprocclient.h:20
LCDProcClient::m_prioMedium
QString m_prioMedium
Definition: lcdprocclient.h:158
LCDProcClient::getLCDHeight
int getLCDHeight(void) const
Definition: lcdprocclient.h:64
LCDTextItem
Definition: lcddevice.h:63
LCDProcClient::m_scrollListWidget
QString m_scrollListWidget
Definition: lcdprocclient.h:202
LCDProcClient::m_startupMessage
QString m_startupMessage
Definition: lcdprocclient.h:233
LCDProcClient::m_musicTime
QString m_musicTime
Definition: lcdprocclient.h:189
LCDProcClient::m_prioUrgent
QString m_prioUrgent
Definition: lcdprocclient.h:156
musicbrainzngs.caa.hostname
string hostname
Definition: caa.py:17
LCDProcClient::m_scrollListItems
QStringList m_scrollListItems
Definition: lcdprocclient.h:200
LCDProcClient::URGENT
@ URGENT
Definition: lcdprocclient.h:107