Skip to content

Commit

Permalink
Metadata: Add a Universal Image Search Results dialog.
Browse files Browse the repository at this point in the history
This dialog is used to display the results of an image search for a particular item, allowing the user to select the one they like.

This is basically the old "artworksel" window that few themes have implemented yet, renamed and made usable everywhere.  It will be used in the edit recording rule dialogs to select artwork the user prefers for a recording rule.
  • Loading branch information
Robert McNamara committed Jul 3, 2011
1 parent 5c683c1 commit cbb9036
Show file tree
Hide file tree
Showing 9 changed files with 248 additions and 400 deletions.
2 changes: 1 addition & 1 deletion mythtv/libs/libmythbase/mythversion.h
Expand Up @@ -12,7 +12,7 @@
/// Update this whenever the plug-in API changes.
/// Including changes in the libmythbase, libmyth, libmythtv, libmythav* and
/// libmythui class methods used by plug-ins.
#define MYTH_BINARY_VERSION "0.25.20110702-3"
#define MYTH_BINARY_VERSION "0.25.20110703-1"

/** \brief Increment this whenever the MythTV network protocol changes.
*
Expand Down
3 changes: 3 additions & 0 deletions mythtv/libs/libmythmetadata/libmythmetadata.pro
Expand Up @@ -16,12 +16,14 @@ HEADERS += cleanup.h dbaccess.h dirscan.h globals.h parentalcontrols.h
HEADERS += videoscan.h videoutils.h videometadata.h videometadatalistmanager.h
HEADERS += quicksp.h metadatacommon.h metadatadownload.h metadataimagedownload.h
HEADERS += bluraymetadata.h mythmetaexp.h metadatafactory.h mythuimetadataresults.h
HEADERS += mythuiimageresults.h

SOURCES += cleanup.cpp dbaccess.cpp dirscan.cpp globals.cpp
SOURCES += parentalcontrols.cpp videoscan.cpp videoutils.cpp
SOURCES += videometadata.cpp videometadatalistmanager.cpp
SOURCES += metadatacommon.cpp metadatadownload.cpp metadataimagedownload.cpp
SOURCES += bluraymetadata.cpp metadatafactory.cpp mythuimetadataresults.cpp
SOURCES += mythuiimageresults.cpp

INCLUDEPATH += ../libmythbase ../libmythtv
INCLUDEPATH += ../.. ../ ./ ../libmythupnp ../libmythui
Expand Down Expand Up @@ -61,6 +63,7 @@ inc.files = cleanup.h dbaccess.h dirscan.h globals.h parentalcontrols.h
inc.files += videoscan.h videoutils.h videometadata.h videometadatalistmanager.h
inc.files += quicksp.h metadatacommon.h metadatadownload.h metadataimagedownload.h
inc.files += bluraymetadata.h mythmetaexp.h metadatafactory.h mythuimetadataresults.h
inc.files += mythuiimageresults.h

INSTALLS += inc

Expand Down
157 changes: 1 addition & 156 deletions mythtv/programs/mythfrontend/editvideometadata.cpp
Expand Up @@ -15,6 +15,7 @@
#include "mythuicheckbox.h"
#include "mythuispinbox.h"
#include "mythuifilebrowser.h"
#include "mythuiimageresults.h"
#include "mythuihelper.h"
#include "mythprogressdialog.h"
#include "remoteutil.h"
Expand Down Expand Up @@ -283,160 +284,6 @@ namespace
const QString CEID_SCREENSHOTFILE = "screenshotfile";
const QString CEID_TRAILERFILE = "trailerfile";
const QString CEID_NEWCATEGORY = "newcategory";

class ImageSearchResultsDialog : public MythScreenType
{
Q_OBJECT

public:
ImageSearchResultsDialog(MythScreenStack *lparent,
const ArtworkList list, const VideoArtworkType type) :
MythScreenType(lparent, "videosearchresultspopup"),
m_list(list), m_type(type), m_resultsList(0)
{
m_imageDownload = new MetadataImageDownload(this);
}

~ImageSearchResultsDialog()
{
cleanCacheDir();

if (m_imageDownload)
{
delete m_imageDownload;
m_imageDownload = NULL;
}
}

bool Create()
{
if (!LoadWindowFromXML("video-ui.xml", "artworksel", this))
return false;

bool err = false;
UIUtilE::Assign(this, m_resultsList, "results", &err);
if (err)
{
VERBOSE(VB_IMPORTANT, "Cannot load screen 'moviesel'");
return false;
}

for (ArtworkList::const_iterator i = m_list.begin();
i != m_list.end(); ++i)
{
ArtworkInfo info = (*i);
MythUIButtonListItem *button =
new MythUIButtonListItem(m_resultsList,
QString());
button->SetText(info.label, "label");
button->SetText(info.thumbnail, "thumbnail");
button->SetText(info.url, "url");
QString width = QString::number(info.width);
QString height = QString::number(info.height);
button->SetText(width, "width");
button->SetText(height, "height");
if (info.width > 0 && info.height > 0)
button->SetText(QString("%1x%2").arg(width).arg(height),
"resolution");

QString artfile = info.thumbnail;

if (artfile.isEmpty())
artfile = info.url;

QString dlfile = getDownloadFilename(info.label,
artfile);

if (!artfile.isEmpty())
{
int pos = m_resultsList->GetItemPos(button);

if (QFile::exists(dlfile))
button->SetImage(dlfile);
else
m_imageDownload->addThumb(info.label,
artfile,
qVariantFromValue<uint>(pos));
}

button->SetData(qVariantFromValue<ArtworkInfo>(*i));
}

connect(m_resultsList, SIGNAL(itemClicked(MythUIButtonListItem *)),
SLOT(sendResult(MythUIButtonListItem *)));

BuildFocusList();

return true;
}

void cleanCacheDir()
{
QString cache = QString("%1/thumbcache")
.arg(GetConfDir());
QDir cacheDir(cache);
QStringList thumbs = cacheDir.entryList(QDir::Files);

for (QStringList::const_iterator i = thumbs.end() - 1;
i != thumbs.begin() - 1; --i)
{
QString filename = QString("%1/%2").arg(cache).arg(*i);
QFileInfo fi(filename);
QDateTime lastmod = fi.lastModified();
if (lastmod.addDays(2) < QDateTime::currentDateTime())
{
VERBOSE(VB_GENERAL|VB_EXTRA, QString("Deleting file %1")
.arg(filename));
QFile::remove(filename);
}
}
}

void customEvent(QEvent *event)
{
if (event->type() == ThumbnailDLEvent::kEventType)
{
ThumbnailDLEvent *tde = (ThumbnailDLEvent *)event;

ThumbnailData *data = tde->thumb;

QString file = data->url;
uint pos = qVariantValue<uint>(data->data);

if (file.isEmpty())
return;

if (!((uint)m_resultsList->GetCount() >= pos))
return;

MythUIButtonListItem *item =
m_resultsList->GetItemAt(pos);

if (item)
{
item->SetImage(file);
}
delete data;
}
}

signals:
void haveResult(ArtworkInfo, VideoArtworkType);

private:
ArtworkList m_list;
VideoArtworkType m_type;
MythUIButtonList *m_resultsList;
MetadataImageDownload *m_imageDownload;

private slots:
void sendResult(MythUIButtonListItem* item)
{
emit haveResult(qVariantValue<ArtworkInfo>(item->GetData()),
m_type);
Close();
}
};
}

void EditMetadataDialog::createBusyDialog(QString title)
Expand Down Expand Up @@ -1227,5 +1074,3 @@ void EditMetadataDialog::customEvent(QEvent *levent)
handleDownloadedImages(lookup);
}
}

#include "editvideometadata.moc"
81 changes: 81 additions & 0 deletions mythtv/themes/MythCenter-wide/base.xml
Expand Up @@ -1196,4 +1196,85 @@
</buttonlist>
</window>

<window name="MythArtworkResults">
<area>-1,-1,413,426</area>

<imagetype name="box">
<area>0,0,413,426</area>
<filename>mv_results_popup.png</filename>
</imagetype>

<buttonlist name="results">
<area>20,22,363,378</area>
<layout>vertical</layout>
<spacing>5</spacing>
<wrapstyle>selection</wrapstyle>
<buttonarea>0,0,100%,97%</buttonarea>
<statetype name="buttonitem">
<state name="active">
<area>0,0,100%,85</area>
<shape name="buttonbackground">
<area>0,0,100%,100%</area>
<fill style="gradient">
<gradient start="#505050" end="#000000" alpha="200" direction="vertical" />
</fill>
</shape>
<imagetype name="buttonimage">
<area>5,2,150,80</area>
<preserveaspect>true</preserveaspect>
</imagetype>
<textarea name="resolution">
<area>160,0,175,85</area>
<font>basesmall</font>
<cutdown>yes</cutdown>
<align>left,vcenter</align>
</textarea>
</state>
<state name="selectedactive" from="active">
<shape name="buttonbackground">
<fill style="gradient">
<gradient start="#52CA38" end="#349838" alpha="255" />
</fill>
</shape>
</state>
<state name="selectedinactive" from="active">
<shape name="buttonbackground">
<fill style="gradient">
<gradient start="#52CA38" end="#349838" alpha="100" />
</fill>
</shape>
<textarea name="resolution">
<font>basesmallpurple</font>
</textarea>
</state>
</statetype>
<statetype name="upscrollarrow">
<position>10,96%</position>
<state type="off">
<imagetype name="upon">
<filename>lb-uparrow-reg.png</filename>
</imagetype>
</state>
<state type="full">
<imagetype name="upoff">
<filename>lb-uparrow-sel.png</filename>
</imagetype>
</state>
</statetype>
<statetype name="downscrollarrow">
<position>40,96%</position>
<state type="off">
<imagetype name="dnon">
<filename>lb-dnarrow-reg.png</filename>
</imagetype>
</state>
<state type="full">
<imagetype name="dnoff">
<filename>lb-dnarrow-sel.png</filename>
</imagetype>
</state>
</statetype>
</buttonlist>
</window>

</mythuitheme>
81 changes: 0 additions & 81 deletions mythtv/themes/MythCenter-wide/video-ui.xml
@@ -1,87 +1,6 @@
<mythuitheme>

<!-- Popups -->
<window name="artworksel">
<area>-1,-1,413,426</area>

<imagetype name="box">
<area>0,0,413,426</area>
<filename>mv_results_popup.png</filename>
</imagetype>

<buttonlist name="results">
<area>20,22,363,378</area>
<layout>vertical</layout>
<spacing>5</spacing>
<wrapstyle>selection</wrapstyle>
<buttonarea>0,0,100%,97%</buttonarea>
<statetype name="buttonitem">
<state name="active">
<area>0,0,100%,85</area>
<shape name="buttonbackground">
<area>0,0,100%,100%</area>
<fill style="gradient">
<gradient start="#505050" end="#000000" alpha="200" direction="vertical" />
</fill>
</shape>
<imagetype name="buttonimage">
<area>5,2,150,80</area>
<preserveaspect>true</preserveaspect>
</imagetype>
<textarea name="resolution">
<area>160,0,175,85</area>
<font>basesmall</font>
<cutdown>yes</cutdown>
<align>left,vcenter</align>
</textarea>
</state>
<state name="selectedactive" from="active">
<shape name="buttonbackground">
<fill style="gradient">
<gradient start="#52CA38" end="#349838" alpha="255" />
</fill>
</shape>
</state>
<state name="selectedinactive" from="active">
<shape name="buttonbackground">
<fill style="gradient">
<gradient start="#52CA38" end="#349838" alpha="100" />
</fill>
</shape>
<textarea name="resolution">
<font>basesmallpurple</font>
</textarea>
</state>
</statetype>
<statetype name="upscrollarrow">
<position>10,96%</position>
<state type="off">
<imagetype name="upon">
<filename>lb-uparrow-reg.png</filename>
</imagetype>
</state>
<state type="full">
<imagetype name="upoff">
<filename>lb-uparrow-sel.png</filename>
</imagetype>
</state>
</statetype>
<statetype name="downscrollarrow">
<position>40,96%</position>
<state type="off">
<imagetype name="dnon">
<filename>lb-dnarrow-reg.png</filename>
</imagetype>
</state>
<state type="full">
<imagetype name="dnoff">
<filename>lb-dnarrow-sel.png</filename>
</imagetype>
</state>
</statetype>
</buttonlist>
</window>

<window name="castpopup">
<area>-1,-1,413,426</area>

Expand Down

0 comments on commit cbb9036

Please sign in to comment.