MythTV  master
mythdialogs.h
Go to the documentation of this file.
1 #ifndef MYTHDIALOGS_H_
2 #define MYTHDIALOGS_H_
3 
4 #include <QDialog>
5 #include <QObject>
6 #include <QFrame>
7 
8 #include "mythexp.h"
9 #include "mythmainwindow.h"
10 
11 class MythMediaDevice;
12 class MythLineEdit;
13 class MythRemoteLineEdit;
14 class MythListBox;
15 class MythLabel;
16 struct fontProp;
17 class QVBoxLayout;
18 class QProgressBar;
19 class QAbstractButton;
20 
21 typedef enum DialogCode
22 {
23  kDialogCodeRejected = QDialog::Rejected,
24  kDialogCodeAccepted = QDialog::Accepted,
36 } DialogCode;
37 
38 inline bool operator==(const DialogCode &a, const QDialog::DialogCode &b)
39 { return ((int)a) == ((int)b); }
40 inline bool operator==(const QDialog::DialogCode &a, const DialogCode &b)
41 { return ((int)a) == ((int)b); }
42 inline bool operator!=(const DialogCode &a, const QDialog::DialogCode &b)
43 { return ((int)a) == ((int)b); }
44 inline bool operator!=(const QDialog::DialogCode &a, const DialogCode &b)
45 { return ((int)a) == ((int)b); }
46 
50 class MPUBLIC MythDialog : public QFrame
51 {
52  Q_OBJECT
53 
54  public:
55  MythDialog(MythMainWindow *parent, const char *name = "MythDialog",
56  bool setsize = true);
57 
58  // these are for backward compatibility..
59  static const DialogCode Rejected = kDialogCodeRejected;
60  static const DialogCode Accepted = kDialogCodeAccepted;
61  static const DialogCode ListStart = kDialogCodeListStart;
62 
63  DialogCode result(void) const { return rescode; }
64 
65  // QFrame::Show is not virtual, so this isn't an override.
66  virtual void Show(void);
67 
68  void hide(void);
69 
70  void setNoErase(void);
71 
72  virtual bool onMediaEvent(MythMediaDevice * mediadevice);
73 
74  void setResult(DialogCode r);
75 
76  // Not an override because the underlying QObject::deleteLater
77  // function isn't virtual. This is a new virtual function, which
78  // calls QFrame::deleteLater.
79  virtual void deleteLater(void);
80 
81  static int CalcItemIndex(DialogCode code);
82 
83  signals:
84  void menuButtonPressed();
85  void leaveModality();
86 
87  public slots:
88  DialogCode exec(void);
89  virtual void done(int); // Must be given a valid DialogCode
90  virtual void AcceptItem(int);
91  virtual void accept();
92  virtual void reject();
93 
94  protected:
95  ~MythDialog();
96  void TeardownAll(void);
97 
98  void keyPressEvent(QKeyEvent *e) override; // QWidget
99 
100  float wmult, hmult;
101  int screenwidth, screenheight;
102  int xbase, ybase;
103 
105 
107 
108  bool in_loop;
109 
110  QFont defaultBigFont, defaultMediumFont, defaultSmallFont;
111 };
112 
118 {
119  Q_OBJECT
120 
121  public:
122  MythPopupBox(MythMainWindow *parent, const char *name = "MythPopupBox") MDEPRECATED;
123  MythPopupBox(MythMainWindow *parent, bool graphicPopup,
124  QColor popupForeground, QColor popupBackground,
125  QColor popupHighlight, const char *name = "MythPopupBox") MDEPRECATED;
126 
127  void addWidget(QWidget *widget, bool setAppearance = true);
128  void addLayout(QLayout *layout, int stretch = 0);
129 
130  typedef enum { Large, Medium, Small } LabelSize;
131 
132  MythLabel *addLabel(QString caption, LabelSize size = Medium,
133  bool wrap = false);
134 
135  QAbstractButton *addButton(QString caption, QObject *target = nullptr,
136  const char *slot = nullptr);
137 
138  void ShowPopup(QObject *target = nullptr, const char *slot = nullptr);
139  void ShowPopupAtXY(int destx, int desty,
140  QObject *target = nullptr, const char *slot = nullptr);
141 
142  DialogCode ExecPopup(QObject *target = nullptr, const char *slot = nullptr);
143  DialogCode ExecPopupAtXY(int destx, int desty,
144  QObject *target = nullptr, const char *slot = nullptr);
145 
146  static bool showOkPopup(MythMainWindow *parent,
147  const QString &title,
148  const QString &message,
149  QString button_msg = QString());
150 
151  static DialogCode Show2ButtonPopup(
152  MythMainWindow *parent,
153  const QString &title, const QString &message,
154  const QString &button1msg, const QString &button2msg,
155  DialogCode default_button);
156 
157  static DialogCode ShowButtonPopup(
158  MythMainWindow *parent,
159  const QString &title, const QString &message,
160  const QStringList &buttonmsgs,
161  DialogCode default_button);
162 
163  static bool showGetTextPopup(MythMainWindow *parent, QString title,
164  QString message, QString& text);
165 
166  public slots:
167  void AcceptItem(int) override; // MythDialog
168  void accept(void) override; // MythDialog
169  void reject(void) override; // MythDialog
170 
171  signals:
172  void popupDone(int);
173 
174  protected:
175  ~MythPopupBox() = default; // use deleteLater() instead for thread safety
176  bool focusNextPrevChild(bool next) override; // QWidget
177  void keyPressEvent(QKeyEvent *e) override; // QWidget
178 
179  protected slots:
180  void defaultButtonPressedHandler(void);
181 
182  private:
183  QVBoxLayout *vbox;
185  int hpadding, wpadding;
186 };
187 
199 {
200  Q_OBJECT
201 
202  public:
212  MythProgressDialog(const QString& message, int totalSteps = 0,
213  bool cancelButton = false,
214  const QObject * target = nullptr,
215  const char * slot = nullptr) MDEPRECATED;
216 
217  /* \brief Close the dialog.
218 
219  This will close the dialog and return the LCD to the Time screen
220  */
221  void Close(void);
222  /* \brief Update the progress bar.
223 
224  This will move the progress bar the percentage-completed as
225  determined by \p curprogress and the totalsteps as set by the
226  call to the constructor.
227 
228  The LCD is updated as well.
229  */
230  void setProgress(int curprogress);
231 
232  void setLabel(QString newlabel);
233 
234  void keyPressEvent(QKeyEvent *) override; // QWidget
235 
236  void deleteLater(void) override; // MythDialog
237 
238  signals:
239  void pressed();
240 
241  protected:
242  ~MythProgressDialog() = default; // use deleteLater() instead for thread safety
243  QProgressBar *progress;
245 
246  private:
247  void setTotalSteps(int totalSteps);
248  int steps;
250 };
251 
252 
253 #endif
MythLabel * msglabel
Definition: mythdialogs.h:244
unsigned int slots[4]
Definition: element.c:38
QColor popupForegroundColor
Definition: mythdialogs.h:184
#define MPUBLIC
Definition: mythexp.h:10
int screenwidth
Definition: mythdialogs.h:101
QVBoxLayout * vbox
Definition: mythdialogs.h:183
bool in_loop
Definition: mythdialogs.h:108
DialogCode result(void) const
Definition: mythdialogs.h:63
QProgressBar * progress
Definition: mythdialogs.h:243
unsigned char r
Definition: ParseText.cpp:340
unsigned char b
Definition: ParseText.cpp:340
DialogCode
Definition: mythdialogs.h:21
virtual void deleteLater(void)
Definition: mythdialogs.cpp:88
virtual void reject()
virtual void accept()
const char * name
Definition: ParseText.cpp:339
bool operator!=(const DialogCode &a, const QDialog::DialogCode &b)
Definition: mythdialogs.h:42
Child of MythDialog used for most popup menus in MythTV.
Definition: mythdialogs.h:117
Base dialog for most dialogs in MythTV using the old UI.
Definition: mythdialogs.h:50
PictureAttribute next(PictureAttributeSupported supported, PictureAttribute attribute)
virtual void AcceptItem(int)
DialogCode rescode
Definition: mythdialogs.h:106
bool operator==(const DialogCode &a, const QDialog::DialogCode &b)
Definition: mythdialogs.h:38
QFont defaultSmallFont
Definition: mythdialogs.h:110
void keyPressEvent(QKeyEvent *e) override
A LineEdit that does special things when you press number keys (enter letters with multiple presses,...
Definition: mythwidgets.h:163
#define MDEPRECATED
Definition: mythexp.h:17
MythMainWindow * m_parent
Definition: mythdialogs.h:104
float wmult
Definition: mythdialogs.h:100
static void addButton(const MenuItemContext &c, OSD *osd, bool active, bool &result, const QString &action, const QString &defaultTextActive, const QString &defaultTextInactive, bool isMenu, const QString &textArg)
Definition: tv_play.cpp:11496