MythTV  master
gamedetails.cpp
Go to the documentation of this file.
1 // Qt
2 #include <QApplication>
3 #include <QFile>
4 
5 // MythTV
6 #include <libmyth/mythcontext.h>
10 #include <libmythui/mythuiimage.h>
11 #include <libmythui/mythuitext.h>
12 
13 // MythGame
14 #include "gamedetails.h"
15 
16 void GameDetailsPopup::handleText(const QString &name, const QString &value)
17 {
18  MythUIText *textarea = nullptr;
19  UIUtilE::Assign(this, textarea, name);
20  if (textarea)
21  {
22  textarea->SetText(value);
23  }
24 }
25 
26 void GameDetailsPopup::handleImage(const QString &name, const QString &filename)
27 {
28  MythUIImage *image = nullptr;
29  UIUtilW::Assign(this, image, name);
30  if (image)
31  {
32  if (!filename.isEmpty())
33  {
34  image->SetFilename(filename);
35  image->Load();
36  }
37  else
38  {
39  image->Reset();
40  }
41  }
42 }
43 
45 {
46  if (!LoadWindowFromXML("game-ui.xml", "gamedetailspopup", this))
47  return false;
48 
49  UIUtilW::Assign(this, m_playButton, "play_button");
50  UIUtilW::Assign(this, m_doneButton, "done_button");
51 
52  if (m_playButton)
54 
55  if (m_doneButton)
57 
59 
62 
63  handleText("title", m_romInfo->Gamename());
64  handleText("gametype", m_romInfo->GameType());
65  handleText("romname", m_romInfo->Romname());
66  handleText("crc", m_romInfo->CRC_VALUE());
67  handleText("rompath", m_romInfo->Rompath());
68  handleText("genre", m_romInfo->Genre());
69  handleText("year", m_romInfo->Year());
70  handleText("country", m_romInfo->Country());
71  handleText("publisher", m_romInfo->Publisher());
72  handleText("description", m_romInfo->Plot());
73  handleText("allsystems", m_romInfo->AllSystems());
74  handleImage("fanart", m_romInfo->Fanart());
75  handleImage("coverart", m_romInfo->Boxart());
76  handleImage("screenshot", m_romInfo->Screenshot());
77 
78  return true;
79 }
80 
82 {
83  if (m_retObject)
84  {
85  auto *dce = new DialogCompletionEvent(m_id, 0, "", "");
86  QApplication::postEvent(m_retObject, dce);
87  Close();
88  }
89 }
90 
91 void GameDetailsPopup::SetReturnEvent(QObject *retobject,
92  const QString &resultid)
93 {
94  m_retObject = retobject;
95  m_id = resultid;
96 }
97 
MythUIButton::Clicked
void Clicked()
RomInfo::CRC_VALUE
QString CRC_VALUE() const
Definition: rominfo.h:99
RomInfo::Boxart
QString Boxart() const
Definition: rominfo.h:69
mythuitext.h
MythUIImage
Image widget, displays a single image or multiple images in sequence.
Definition: mythuiimage.h:97
RomInfo::Plot
QString Plot() const
Definition: rominfo.h:102
RomInfo::AllSystems
QString AllSystems() const
Definition: rominfo.h:93
MythScreenType::Close
virtual void Close()
Definition: mythscreentype.cpp:383
RomInfo::Country
QString Country() const
Definition: rominfo.h:84
RomInfo::Gamename
QString Gamename() const
Definition: rominfo.h:78
GameDetailsPopup::m_retObject
QObject * m_retObject
Definition: gamedetails.h:35
MythUIImage::Load
bool Load(bool allowLoadInBackground=true, bool forceStat=false)
Load the image(s), wraps ImageLoader::LoadImage()
Definition: mythuiimage.cpp:971
mythdialogbox.h
RomInfo::Genre
QString Genre() const
Definition: rominfo.h:81
GameDetailsPopup::handleText
void handleText(const QString &name, const QString &value)
Definition: gamedetails.cpp:16
GameDetailsPopup::Play
void Play(void)
Definition: gamedetails.cpp:81
MythUIImage::Reset
void Reset(void) override
Reset the image back to the default defined in the theme.
Definition: mythuiimage.cpp:644
mythuiimage.h
GameDetailsPopup::m_playButton
MythUIButton * m_playButton
Definition: gamedetails.h:51
RomInfo::Screenshot
QString Screenshot() const
Definition: rominfo.h:63
GameDetailsPopup::m_doneButton
MythUIButton * m_doneButton
Definition: gamedetails.h:52
MythScreenType::SetFocusWidget
bool SetFocusWidget(MythUIType *widget=nullptr)
Definition: mythscreentype.cpp:115
RomInfo::Rompath
QString Rompath() const
Definition: rominfo.h:60
MythScreenType::BuildFocusList
void BuildFocusList(void)
Definition: mythscreentype.cpp:203
GameDetailsPopup::m_romInfo
const RomInfo * m_romInfo
Definition: gamedetails.h:33
GameDetailsPopup::Create
bool Create(void) override
Definition: gamedetails.cpp:44
UIUtilDisp::Assign
static bool Assign(ContainerType *container, UIType *&item, const QString &name, bool *err=nullptr)
Definition: mythuiutils.h:27
RomInfo::Publisher
QString Publisher() const
Definition: rominfo.h:105
mythuihelper.h
GameDetailsPopup::SetReturnEvent
void SetReturnEvent(QObject *retobject, const QString &resultid)
Definition: gamedetails.cpp:91
MythUIText
All purpose text widget, displays a text string.
Definition: mythuitext.h:28
RomInfo::Fanart
QString Fanart() const
Definition: rominfo.h:66
XMLParseBase::LoadWindowFromXML
static bool LoadWindowFromXML(const QString &xmlfile, const QString &windowname, MythUIType *parent)
Definition: xmlparsebase.cpp:701
GameDetailsPopup::m_id
QString m_id
Definition: gamedetails.h:34
DialogCompletionEvent
Event dispatched from MythUI modal dialogs to a listening class containing a result of some form.
Definition: mythdialogbox.h:41
MythUIText::SetText
virtual void SetText(const QString &text)
Definition: mythuitext.cpp:115
mythcontext.h
GameDetailsPopup::handleImage
void handleImage(const QString &name, const QString &filename)
Definition: gamedetails.cpp:26
mythuibutton.h
MythUIImage::SetFilename
void SetFilename(const QString &filename)
Must be followed by a call to Load() to load the image.
Definition: mythuiimage.cpp:677
build_compdb.filename
filename
Definition: build_compdb.py:21
RomInfo::GameType
QString GameType() const
Definition: rominfo.h:87
RomInfo::Year
QString Year() const
Definition: rominfo.h:111
gamedetails.h
RomInfo::Romname
QString Romname() const
Definition: rominfo.h:72