00001 #include <iostream>
00002 using namespace std;
00003
00004 #include <qpixmap.h>
00005 #include <qimage.h>
00006 #include <qapplication.h>
00007
00008 #include "progdetails.h"
00009 #include "mythcontext.h"
00010 #include "mythdialogs.h"
00011 #include "uitypes.h"
00012
00013 ProgDetails::ProgDetails(MythMainWindow *parent,
00014 QString windowName,
00015 QString details)
00016 : MythThemedDialog(parent, windowName)
00017 {
00018 m_details = details;
00019
00020 wireUpTheme();
00021 assignFirstFocus();
00022
00023 if (m_richText)
00024 {
00025 m_richText->SetText(m_details);
00026 m_richText->SetBackground(&my_background);
00027 }
00028 }
00029
00030 void ProgDetails::setDetails(const QString &details)
00031 {
00032 m_details = details;
00033
00034 if (m_richText)
00035 {
00036 m_richText->SetText(m_details);
00037 }
00038 }
00039
00040 QString ProgDetails::themeText(const QString &fontName, const QString &text, int size)
00041 {
00042 if (size < 1) size = 1;
00043 if (size > 7) size = 7;
00044
00045 XMLParse *theme = getTheme();
00046 if (!theme)
00047 return text;
00048
00049 fontProp *font = getFont(fontName);
00050
00051 if (!font)
00052 return text;
00053
00054 QString res = QString("<font color=\"%1\" face=\"%2\" size=\"%3\"</font>")
00055 .arg(font->color.name())
00056 .arg(font->face.family())
00057 .arg(size);
00058
00059 bool bItalic = font->face.italic();
00060 bool bBold = font->face.bold();
00061 bool bUnderline = font->face.underline();
00062
00063 if (bItalic)
00064 res += "<i>";
00065 if (bBold)
00066 res += "<b>";
00067 if (bUnderline)
00068 res += "<u>";
00069
00070 res += text;
00071
00072 if (bItalic)
00073 res += "</i>";
00074 if (bBold)
00075 res += "</b>";
00076 if (bUnderline)
00077 res += "</u>";
00078
00079 return res;
00080 }
00081
00082 ProgDetails::~ProgDetails(void)
00083 {
00084 }
00085
00086 void ProgDetails::keyPressEvent(QKeyEvent *e)
00087 {
00088 bool handled = false;
00089 QStringList actions;
00090 if (gContext->GetMainWindow()->TranslateKeyPress("qt", e, actions))
00091 {
00092 for (unsigned int i = 0; i < actions.size() && !handled; i++)
00093 {
00094 QString action = actions[i];
00095 handled = true;
00096 if (action == "ESCAPE" || action == "SELECT")
00097 reject();
00098 else if (action == "UP")
00099 {
00100 if (getCurrentFocusWidget() == m_richText)
00101 m_richText->ScrollUp();
00102 else
00103 nextPrevWidgetFocus(false);
00104 }
00105 else if (action == "DOWN")
00106 {
00107 if (getCurrentFocusWidget() == m_richText)
00108 m_richText->ScrollDown();
00109 else
00110 nextPrevWidgetFocus(true);
00111 }
00112 else if (action == "LEFT")
00113 {
00114 nextPrevWidgetFocus(false);
00115 }
00116 else if (action == "RIGHT")
00117 {
00118 nextPrevWidgetFocus(true);
00119 }
00120 else if (action == "PAGEUP")
00121 {
00122 if (getCurrentFocusWidget() == m_richText)
00123 m_richText->ScrollPageUp();
00124 else
00125 nextPrevWidgetFocus(false);
00126 }
00127 else if (action == "PAGEDOWN")
00128 {
00129 if (getCurrentFocusWidget() == m_richText)
00130 m_richText->ScrollPageDown();
00131 else
00132 nextPrevWidgetFocus(true);
00133 }
00134
00135 else
00136 handled = false;
00137 }
00138 }
00139 }
00140
00141 void ProgDetails::wireUpTheme()
00142 {
00143 m_okButton = getUITextButtonType("ok_button");
00144 if (m_okButton)
00145 {
00146 m_okButton->setText(tr("OK"));
00147 connect(m_okButton, SIGNAL(pushed()), this, SLOT(accept()));
00148 }
00149
00150 m_richText = getUIRichTextType("richtext");
00151
00152 buildFocusList();
00153 }