00001 #include <QFile>
00002 #include <QApplication>
00003
00004 #include "mythcontext.h"
00005 #include "mythuihelper.h"
00006 #include "mythuitext.h"
00007 #include "mythuiimage.h"
00008 #include "mythuibutton.h"
00009 #include "mythdialogbox.h"
00010
00011 #include "gamedetails.h"
00012
00013 GameDetailsPopup::GameDetailsPopup(MythScreenStack *parent,
00014 const RomInfo *romInfo)
00015 : MythScreenType (parent, "gamedetailspopup"),
00016 m_romInfo(romInfo), m_id(""), m_retObject(NULL),
00017 m_gameName(NULL), m_gameType(NULL), m_romName(NULL),
00018 m_crc(NULL), m_romPath(NULL), m_genre(NULL),
00019 m_year(NULL), m_country(NULL), m_plot(NULL),
00020 m_publisher(NULL), m_allSystems(NULL), m_fanartImage(NULL),
00021 m_boxImage(NULL), m_playButton(NULL), m_doneButton(NULL)
00022 {
00023 m_romInfo = romInfo;
00024 }
00025
00026 GameDetailsPopup::~GameDetailsPopup(void)
00027 {
00028 }
00029
00030 void GameDetailsPopup::handleText(const QString &name, const QString &value)
00031 {
00032 MythUIText *textarea = NULL;
00033 UIUtilE::Assign(this, textarea, name);
00034 if (textarea)
00035 {
00036 textarea->SetText(value);
00037 }
00038 }
00039
00040 void GameDetailsPopup::handleImage(const QString &name, const QString &filename)
00041 {
00042 MythUIImage *image = NULL;
00043 UIUtilW::Assign(this, image, name);
00044 if (image)
00045 {
00046 if (filename.size())
00047 {
00048 image->SetFilename(filename);
00049 image->Load();
00050 }
00051 else
00052 image->Reset();
00053 }
00054 }
00055
00056 bool GameDetailsPopup::Create(void)
00057 {
00058 if (!LoadWindowFromXML("game-ui.xml", "gamedetailspopup", this))
00059 return false;
00060
00061 UIUtilW::Assign(this, m_playButton, "play_button");
00062 UIUtilW::Assign(this, m_doneButton, "done_button");
00063
00064 if (m_playButton)
00065 connect(m_playButton, SIGNAL(Clicked()), SLOT(Play()));
00066
00067 if (m_doneButton)
00068 connect(m_doneButton, SIGNAL(Clicked()), SLOT(Close()));
00069
00070 BuildFocusList();
00071
00072 if (m_playButton || m_doneButton)
00073 SetFocusWidget(m_playButton ? m_playButton : m_doneButton);
00074
00075 handleText("title", m_romInfo->Gamename());
00076 handleText("gametype", m_romInfo->GameType());
00077 handleText("romname", m_romInfo->Romname());
00078 handleText("crc", m_romInfo->CRC_VALUE());
00079 handleText("rompath", m_romInfo->Rompath());
00080 handleText("genre", m_romInfo->Genre());
00081 handleText("year", m_romInfo->Year());
00082 handleText("country", m_romInfo->Country());
00083 handleText("publisher", m_romInfo->Publisher());
00084 handleText("description", m_romInfo->Plot());
00085 handleText("allsystems", m_romInfo->AllSystems());
00086 handleImage("fanart", m_romInfo->Fanart());
00087 handleImage("coverart", m_romInfo->Boxart());
00088 handleImage("screenshot", m_romInfo->Screenshot());
00089
00090 return true;
00091 }
00092
00093 void GameDetailsPopup::Play()
00094 {
00095 if (m_retObject)
00096 {
00097 DialogCompletionEvent *dce =
00098 new DialogCompletionEvent(m_id, 0, "", "");
00099 QApplication::postEvent(m_retObject, dce);
00100 Close();
00101 }
00102 }
00103
00104 void GameDetailsPopup::SetReturnEvent(QObject *retobject,
00105 const QString &resultid)
00106 {
00107 m_retObject = retobject;
00108 m_id = resultid;
00109 }
00110