MythTV  0.27pre
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Groups Pages
gamedetails.cpp
Go to the documentation of this file.
1 #include <QFile>
2 #include <QApplication>
3 
4 #include "mythcontext.h"
5 #include "mythuihelper.h"
6 #include "mythuitext.h"
7 #include "mythuiimage.h"
8 #include "mythuibutton.h"
9 #include "mythdialogbox.h"
10 
11 #include "gamedetails.h"
12 
14  const RomInfo *romInfo)
15  : MythScreenType (parent, "gamedetailspopup"),
16  m_romInfo(romInfo), m_id(""), m_retObject(NULL),
17  m_gameName(NULL), m_gameType(NULL), m_romName(NULL),
18  m_crc(NULL), m_romPath(NULL), m_genre(NULL),
19  m_year(NULL), m_country(NULL), m_plot(NULL),
20  m_publisher(NULL), m_allSystems(NULL), m_fanartImage(NULL),
21  m_boxImage(NULL), m_playButton(NULL), m_doneButton(NULL)
22 {
23  m_romInfo = romInfo;
24 }
25 
27 {
28 }
29 
30 void GameDetailsPopup::handleText(const QString &name, const QString &value)
31 {
32  MythUIText *textarea = NULL;
33  UIUtilE::Assign(this, textarea, name);
34  if (textarea)
35  {
36  textarea->SetText(value);
37  }
38 }
39 
40 void GameDetailsPopup::handleImage(const QString &name, const QString &filename)
41 {
42  MythUIImage *image = NULL;
43  UIUtilW::Assign(this, image, name);
44  if (image)
45  {
46  if (filename.size())
47  {
48  image->SetFilename(filename);
49  image->Load();
50  }
51  else
52  image->Reset();
53  }
54 }
55 
57 {
58  if (!LoadWindowFromXML("game-ui.xml", "gamedetailspopup", this))
59  return false;
60 
61  UIUtilW::Assign(this, m_playButton, "play_button");
62  UIUtilW::Assign(this, m_doneButton, "done_button");
63 
64  if (m_playButton)
65  connect(m_playButton, SIGNAL(Clicked()), SLOT(Play()));
66 
67  if (m_doneButton)
68  connect(m_doneButton, SIGNAL(Clicked()), SLOT(Close()));
69 
71 
74 
75  handleText("title", m_romInfo->Gamename());
76  handleText("gametype", m_romInfo->GameType());
77  handleText("romname", m_romInfo->Romname());
78  handleText("crc", m_romInfo->CRC_VALUE());
79  handleText("rompath", m_romInfo->Rompath());
80  handleText("genre", m_romInfo->Genre());
81  handleText("year", m_romInfo->Year());
82  handleText("country", m_romInfo->Country());
83  handleText("publisher", m_romInfo->Publisher());
84  handleText("description", m_romInfo->Plot());
85  handleText("allsystems", m_romInfo->AllSystems());
86  handleImage("fanart", m_romInfo->Fanart());
87  handleImage("coverart", m_romInfo->Boxart());
88  handleImage("screenshot", m_romInfo->Screenshot());
89 
90  return true;
91 }
92 
94 {
95  if (m_retObject)
96  {
98  new DialogCompletionEvent(m_id, 0, "", "");
99  QApplication::postEvent(m_retObject, dce);
100  Close();
101  }
102 }
103 
104 void GameDetailsPopup::SetReturnEvent(QObject *retobject,
105  const QString &resultid)
106 {
107  m_retObject = retobject;
108  m_id = resultid;
109 }
110