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  image->Reset();
39  }
40 }
41 
43 {
44  if (!LoadWindowFromXML("game-ui.xml", "gamedetailspopup", this))
45  return false;
46 
47  UIUtilW::Assign(this, m_playButton, "play_button");
48  UIUtilW::Assign(this, m_doneButton, "done_button");
49 
50  if (m_playButton)
52 
53  if (m_doneButton)
55 
57 
60 
61  handleText("title", m_romInfo->Gamename());
62  handleText("gametype", m_romInfo->GameType());
63  handleText("romname", m_romInfo->Romname());
64  handleText("crc", m_romInfo->CRC_VALUE());
65  handleText("rompath", m_romInfo->Rompath());
66  handleText("genre", m_romInfo->Genre());
67  handleText("year", m_romInfo->Year());
68  handleText("country", m_romInfo->Country());
69  handleText("publisher", m_romInfo->Publisher());
70  handleText("description", m_romInfo->Plot());
71  handleText("allsystems", m_romInfo->AllSystems());
72  handleImage("fanart", m_romInfo->Fanart());
73  handleImage("coverart", m_romInfo->Boxart());
74  handleImage("screenshot", m_romInfo->Screenshot());
75 
76  return true;
77 }
78 
80 {
81  if (m_retObject)
82  {
83  auto *dce = new DialogCompletionEvent(m_id, 0, "", "");
84  QApplication::postEvent(m_retObject, dce);
85  Close();
86  }
87 }
88 
89 void GameDetailsPopup::SetReturnEvent(QObject *retobject,
90  const QString &resultid)
91 {
92  m_retObject = retobject;
93  m_id = resultid;
94 }
95 
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:386
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:966
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:79
MythUIImage::Reset
void Reset(void) override
Reset the image back to the default defined in the theme.
Definition: mythuiimage.cpp:643
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:118
RomInfo::Rompath
QString Rompath() const
Definition: rominfo.h:60
MythScreenType::BuildFocusList
void BuildFocusList(void)
Definition: mythscreentype.cpp:206
GameDetailsPopup::m_romInfo
const RomInfo * m_romInfo
Definition: gamedetails.h:33
GameDetailsPopup::Create
bool Create(void) override
Definition: gamedetails.cpp:42
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:89
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:687
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:132
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:674
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