MythTV  master
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 
13 void GameDetailsPopup::handleText(const QString &name, const QString &value)
14 {
15  MythUIText *textarea = nullptr;
16  UIUtilE::Assign(this, textarea, name);
17  if (textarea)
18  {
19  textarea->SetText(value);
20  }
21 }
22 
23 void GameDetailsPopup::handleImage(const QString &name, const QString &filename)
24 {
25  MythUIImage *image = nullptr;
26  UIUtilW::Assign(this, image, name);
27  if (image)
28  {
29  if (filename.size())
30  {
31  image->SetFilename(filename);
32  image->Load();
33  }
34  else
35  image->Reset();
36  }
37 }
38 
40 {
41  if (!LoadWindowFromXML("game-ui.xml", "gamedetailspopup", this))
42  return false;
43 
44  UIUtilW::Assign(this, m_playButton, "play_button");
45  UIUtilW::Assign(this, m_doneButton, "done_button");
46 
47  if (m_playButton)
48  connect(m_playButton, SIGNAL(Clicked()), SLOT(Play()));
49 
50  if (m_doneButton)
51  connect(m_doneButton, SIGNAL(Clicked()), SLOT(Close()));
52 
54 
57 
58  handleText("title", m_romInfo->Gamename());
59  handleText("gametype", m_romInfo->GameType());
60  handleText("romname", m_romInfo->Romname());
61  handleText("crc", m_romInfo->CRC_VALUE());
62  handleText("rompath", m_romInfo->Rompath());
63  handleText("genre", m_romInfo->Genre());
64  handleText("year", m_romInfo->Year());
65  handleText("country", m_romInfo->Country());
66  handleText("publisher", m_romInfo->Publisher());
67  handleText("description", m_romInfo->Plot());
68  handleText("allsystems", m_romInfo->AllSystems());
69  handleImage("fanart", m_romInfo->Fanart());
70  handleImage("coverart", m_romInfo->Boxart());
71  handleImage("screenshot", m_romInfo->Screenshot());
72 
73  return true;
74 }
75 
77 {
78  if (m_retObject)
79  {
81  new DialogCompletionEvent(m_id, 0, "", "");
82  QApplication::postEvent(m_retObject, dce);
83  Close();
84  }
85 }
86 
87 void GameDetailsPopup::SetReturnEvent(QObject *retobject,
88  const QString &resultid)
89 {
90  m_retObject = retobject;
91  m_id = resultid;
92 }
93 
QString AllSystems() const
Definition: rominfo.h:112
bool Create(void) override
Definition: gamedetails.cpp:39
All purpose text widget, displays a text string.
Definition: mythuitext.h:28
QString Screenshot() const
Definition: rominfo.h:82
QString Plot() const
Definition: rominfo.h:121
Image widget, displays a single image or multiple images in sequence.
Definition: mythuiimage.h:97
const RomInfo * m_romInfo
Definition: gamedetails.h:29
virtual void SetText(const QString &text)
Definition: mythuitext.cpp:136
QString Gamename() const
Definition: rominfo.h:97
QString Country() const
Definition: rominfo.h:103
QString Romname() const
Definition: rominfo.h:91
void handleImage(const QString &name, const QString &filename)
Definition: gamedetails.cpp:23
void SetReturnEvent(QObject *retobject, const QString &resultid)
Definition: gamedetails.cpp:87
bool Load(bool allowLoadInBackground=true, bool forceStat=false)
Load the image(s), wraps ImageLoader::LoadImage()
void BuildFocusList(void)
virtual void Close()
void Reset(void) override
Reset the image back to the default defined in the theme.
static bool Assign(ContainerType *container, UIType *&item, const QString &name, bool *err=nullptr)
Definition: mythuiutils.h:27
const char * name
Definition: ParseText.cpp:328
QObject * m_retObject
Definition: gamedetails.h:31
static bool LoadWindowFromXML(const QString &xmlfile, const QString &windowname, MythUIType *parent)
QString Year() const
Definition: rominfo.h:130
QString Rompath() const
Definition: rominfo.h:79
QString CRC_VALUE() const
Definition: rominfo.h:118
QString Boxart() const
Definition: rominfo.h:88
QString Genre() const
Definition: rominfo.h:100
void SetFilename(const QString &filename)
Must be followed by a call to Load() to load the image.
void handleText(const QString &name, const QString &value)
Definition: gamedetails.cpp:13
QString Fanart() const
Definition: rominfo.h:85
void Play(void)
Definition: gamedetails.cpp:76
bool SetFocusWidget(MythUIType *widget=nullptr)
QString GameType() const
Definition: rominfo.h:106
QString Publisher() const
Definition: rominfo.h:124
MythUIButton * m_doneButton
Definition: gamedetails.h:48
Event dispatched from MythUI modal dialogs to a listening class containing a result of some form.
Definition: mythdialogbox.h:37
MythUIButton * m_playButton
Definition: gamedetails.h:47