00001 #ifndef MYTHDIALOGS_H_
00002 #define MYTHDIALOGS_H_
00003
00004 #include <QDomElement>
00005 #include <QDialog>
00006 #include <QLabel>
00007 #include <QAbstractButton>
00008 #include <QObject>
00009 #include <QFrame>
00010 #include <QVector>
00011 #include <QList>
00012
00013 #include "mythexp.h"
00014 #include "mythmainwindow.h"
00015 #include <vector>
00016 using namespace std;
00017
00018 class MythMediaDevice;
00019 class MythLineEdit;
00020 class MythRemoteLineEdit;
00021 class MythListBox;
00022 struct fontProp;
00023 class QVBoxLayout;
00024 class QProgressBar;
00025 class UIType;
00026 class UIKeyboardType;
00027 class LayerSet;
00028 class XMLParse;
00029
00030 typedef enum DialogCode
00031 {
00032 kDialogCodeRejected = QDialog::Rejected,
00033 kDialogCodeAccepted = QDialog::Accepted,
00034 kDialogCodeListStart = 0x10,
00035 kDialogCodeButton0 = 0x10,
00036 kDialogCodeButton1 = 0x11,
00037 kDialogCodeButton2 = 0x12,
00038 kDialogCodeButton3 = 0x13,
00039 kDialogCodeButton4 = 0x14,
00040 kDialogCodeButton5 = 0x15,
00041 kDialogCodeButton6 = 0x16,
00042 kDialogCodeButton7 = 0x17,
00043 kDialogCodeButton8 = 0x18,
00044 kDialogCodeButton9 = 0x19,
00045 } DialogCode;
00046
00047 inline bool operator==(const DialogCode &a, const QDialog::DialogCode &b)
00048 { return ((int)a) == ((int)b); }
00049 inline bool operator==(const QDialog::DialogCode &a, const DialogCode &b)
00050 { return ((int)a) == ((int)b); }
00051 inline bool operator!=(const DialogCode &a, const QDialog::DialogCode &b)
00052 { return ((int)a) == ((int)b); }
00053 inline bool operator!=(const QDialog::DialogCode &a, const DialogCode &b)
00054 { return ((int)a) == ((int)b); }
00055
00059 class MPUBLIC MythDialog : public QFrame
00060 {
00061 Q_OBJECT
00062
00063 public:
00064 MythDialog(MythMainWindow *parent, const char *name = "MythDialog",
00065 bool setsize = true);
00066
00067
00068 static const DialogCode Rejected = kDialogCodeRejected;
00069 static const DialogCode Accepted = kDialogCodeAccepted;
00070 static const DialogCode ListStart = kDialogCodeListStart;
00071
00072 DialogCode result(void) const { return rescode; }
00073
00074 virtual void Show(void);
00075
00076 void hide(void);
00077
00078 void setNoErase(void);
00079
00080 virtual bool onMediaEvent(MythMediaDevice * mediadevice);
00081
00082 void setResult(DialogCode r);
00083
00084 virtual void deleteLater(void);
00085
00086 static int CalcItemIndex(DialogCode code);
00087
00088 signals:
00089 void menuButtonPressed();
00090 void leaveModality();
00091
00092 public slots:
00093 DialogCode exec(void);
00094 virtual void done(int);
00095 virtual void AcceptItem(int);
00096 virtual void accept();
00097 virtual void reject();
00098
00099 protected:
00100 ~MythDialog();
00101 void TeardownAll(void);
00102
00103 void keyPressEvent(QKeyEvent *e);
00104
00105 float wmult, hmult;
00106 int screenwidth, screenheight;
00107 int xbase, ybase;
00108
00109 MythMainWindow *m_parent;
00110
00111 DialogCode rescode;
00112
00113 bool in_loop;
00114
00115 QFont defaultBigFont, defaultMediumFont, defaultSmallFont;
00116 };
00117
00122 class MPUBLIC MythPopupBox : public MythDialog
00123 {
00124 Q_OBJECT
00125
00126 public:
00127 MythPopupBox(MythMainWindow *parent, const char *name = "MythPopupBox");
00128 MythPopupBox(MythMainWindow *parent, bool graphicPopup,
00129 QColor popupForeground, QColor popupBackground,
00130 QColor popupHighlight, const char *name = "MythPopupBox");
00131
00132 void addWidget(QWidget *widget, bool setAppearance = true);
00133 void addLayout(QLayout *layout, int stretch = 0);
00134
00135 typedef enum { Large, Medium, Small } LabelSize;
00136
00137 QLabel *addLabel(QString caption, LabelSize size = Medium,
00138 bool wrap = false);
00139
00140 QAbstractButton *addButton(QString caption, QObject *target = NULL,
00141 const char *slot = NULL);
00142
00143 void ShowPopup(QObject *target = NULL, const char *slot = NULL);
00144 void ShowPopupAtXY(int destx, int desty,
00145 QObject *target = NULL, const char *slot = NULL);
00146
00147 DialogCode ExecPopup(QObject *target = NULL, const char *slot = NULL);
00148 DialogCode ExecPopupAtXY(int destx, int desty,
00149 QObject *target = NULL, const char *slot = NULL);
00150
00151 static bool showOkPopup(MythMainWindow *parent,
00152 const QString &title,
00153 const QString &message,
00154 QString button_msg = QString());
00155
00156 static DialogCode Show2ButtonPopup(
00157 MythMainWindow *parent,
00158 const QString &title, const QString &message,
00159 const QString &button1msg, const QString &button2msg,
00160 DialogCode default_button);
00161
00162 static DialogCode ShowButtonPopup(
00163 MythMainWindow *parent,
00164 const QString &title, const QString &message,
00165 const QStringList &buttonmsgs,
00166 DialogCode default_button);
00167
00168 static bool showGetTextPopup(MythMainWindow *parent, QString title,
00169 QString message, QString& text);
00170
00171 public slots:
00172 virtual void AcceptItem(int);
00173 virtual void accept(void);
00174 virtual void reject(void);
00175
00176 signals:
00177 void popupDone(int);
00178
00179 protected:
00180 ~MythPopupBox() {}
00181 bool focusNextPrevChild(bool next);
00182 void keyPressEvent(QKeyEvent *e);
00183
00184 protected slots:
00185 void defaultButtonPressedHandler(void);
00186
00187 private:
00188 QVBoxLayout *vbox;
00189 QColor popupForegroundColor;
00190 int hpadding, wpadding;
00191 };
00192
00203 class MPUBLIC MythProgressDialog: public MythDialog
00204 {
00205 Q_OBJECT
00206
00207 public:
00217 MythProgressDialog(const QString& message, int totalSteps = 0,
00218 bool cancelButton = false,
00219 const QObject * target = NULL,
00220 const char * slot = NULL);
00221
00222
00223
00224
00225
00226 void Close(void);
00227
00228
00229
00230
00231
00232
00233
00234
00235 void setProgress(int curprogress);
00236
00237 void setLabel(QString newlabel);
00238
00239 void keyPressEvent(QKeyEvent *);
00240
00241 virtual void deleteLater(void);
00242
00243 signals:
00244 void pressed();
00245
00246 protected:
00247 ~MythProgressDialog();
00248 QProgressBar *progress;
00249 QLabel *msglabel;
00250
00251 private:
00252 void setTotalSteps(int totalSteps);
00253 int steps;
00254 int m_totalSteps;
00255 };
00256
00257
00261 class MythThemedDialog : public MythDialog
00262 {
00263 Q_OBJECT
00264
00265 public:
00266 MythThemedDialog(MythMainWindow *parent,
00267 const QString &window_name,
00268 const QString &theme_filename = QString(),
00269 const char *name = "MythThemedDialog",
00270 bool setsize = true);
00271 MythThemedDialog(MythMainWindow *parent,
00272 const char *name = "MythThemedDialog",
00273 bool setsize = true);
00274
00275 virtual bool loadThemedWindow(QString window_name, QString theme_filename);
00276 virtual void loadWindow(QDomElement &);
00277 virtual void parseContainer(QDomElement &);
00278 virtual void parseFont(QDomElement &);
00279 bool buildFocusList();
00280
00281 UIType *getUIObject(const QString &name);
00282
00283 UIType *getCurrentFocusWidget();
00284 void setCurrentFocusWidget(UIType *widget);
00285
00286 UIKeyboardType *getUIKeyboardType(const QString &name);
00287
00288 LayerSet* getContainer(const QString &name);
00289 fontProp* getFont(const QString &name);
00290
00291 void setContext(int a_context) { context = a_context; }
00292 int getContext(){return context;}
00293
00294 public slots:
00295 virtual void deleteLater(void);
00296 virtual void updateBackground();
00297 virtual void initForeground();
00298 virtual void updateForeground();
00300 virtual void updateForeground(const QRect &);
00302 virtual void updateForegroundRegion(const QRect &);
00303 virtual bool assignFirstFocus();
00304 virtual bool nextPrevWidgetFocus(bool up_or_down);
00305 virtual void activateCurrent();
00306
00307 protected:
00308 ~MythThemedDialog();
00309
00310 void paintEvent(QPaintEvent* e);
00311 UIType *widget_with_current_focus;
00312
00313
00314 XMLParse *getTheme() {return theme;}
00315 QDomElement& getXmlData() {return xmldata;}
00316
00317 QPixmap my_background;
00318 QPixmap my_foreground;
00319
00320 private:
00321
00322 void ReallyUpdateForeground(const QRect &);
00323
00324 void UpdateForegroundRect(const QRect &inv_rect);
00325
00326 XMLParse *theme;
00327 QDomElement xmldata;
00328 int context;
00329
00330 QList<LayerSet*> my_containers;
00331 vector<UIType*> focus_taking_widgets;
00332
00333 QRect redrawRect;
00334 };
00335
00336 #endif