Go to the documentation of this file.
44 const QString &name) :
63 for (
int x = 0; x < allMusic->count(); x++)
68 allMusic->at(x)->reloadAlbumArtImages();
94 for (
int i = 0; i < actions.size() && !handled; i++)
96 QString
action = actions[i];
164 QString label = tr(
"Save Changes?");
176 menu->SetReturnEvent(
this,
"savechangesmenu");
223 if (
GetMythDB()->GetBoolSetting(
"AllowTagWriting",
false))
226 strList <<
"MUSIC_TAG_UPDATE_METADATA %1 %2"
243 albumartButton->
Hide();
248 bool changed =
false;
268 artist = QUrl::toPercentEncoding(artist,
"+");
271 album = QUrl::toPercentEncoding(album,
"+");
273 QUrl url(
"http://www.google.co.uk/images?q=" + artist +
"+" + album, QUrl::TolerantMode);
310 bool err = CreateCommon();
343 LOG(VB_GENERAL, LOG_ERR,
"Cannot load screen 'editmetadata'");
410 s_metadata->incRating();
416 s_metadata->decRating();
425 s_metadata->setRating(
rating);
449 for (
int i = 0; i < actions.size() && !handled; i++)
451 QString
action = actions[i];
456 else if (
action ==
"THMBDOWN")
458 else if (
action ==
"MENU")
475 QString label = tr(
"Options");
487 menu->SetReturnEvent(
this,
"optionsmenu");
489 menu->AddButton(tr(
"Edit Albumart Images"));
490 menu->AddButton(tr(
"Search Internet For Artist Image"));
491 menu->AddButton(tr(
"Search Internet For Album Image"));
492 menu->AddButton(tr(
"Search Internet For Genre Image"));
493 menu->AddButton(tr(
"Check Track Length"));
506 if (!editDialog->Create())
535 QString msg = tr(
"Select an Artist");
537 QString s = s_metadata->Artist();
542 if (!searchDlg->Create())
565 QString
file =
findIcon(
"artist", artist.toLower(),
true);
578 QString msg = tr(
"Select a Compilation Artist");
580 QString s = s_metadata->CompilationArtist();
585 if (!searchDlg->Create())
603 QString msg = tr(
"Select an Album");
605 QString s = s_metadata->Album();
610 if (!searchDlg->Create())
631 QString
file = s_metadata->getAlbumArtFile();
644 QString msg = tr(
"Select a Genre");
654 QString s = s_metadata->Genre();
659 if (!searchDlg->Create())
682 QString
file =
findIcon(
"genre", genre.toLower(),
true);
711 QString genre= s_metadata->Genre().replace(
' ',
'+');
712 genre = QUrl::toPercentEncoding(genre,
"+");
714 QUrl url(
"http://www.flickr.com/search/groups/?w=908425%40N22&m=pool&q=" + genre, QUrl::TolerantMode);
716 m_searchType =
"genre";
723 QString artist = s_metadata->Artist().replace(
' ',
'+');
724 artist = QUrl::toPercentEncoding(artist,
"+");
726 QUrl url(
"http://www.google.co.uk/images?q=" + artist, QUrl::TolerantMode);
728 m_searchType =
"artist";
738 if ((dce ==
nullptr) || (dce->GetResult() < 0))
741 QString resultid = dce->
GetId();
742 QString resulttext = dce->GetResultText();
745 if (resultid ==
"optionsmenu")
747 if (resulttext == tr(
"Edit Albumart Images"))
749 else if (resulttext == tr(
"Search Internet For Genre Image"))
754 else if (resulttext == tr(
"Search Internet For Artist Image"))
759 else if (resulttext == tr(
"Search Internet For Album Image"))
762 searchForAlbumImages();
764 else if (resulttext == tr(
"Check Track Length"))
767 strList <<
"MUSIC_CALC_TRACK_LENGTH"
768 << s_metadata->Hostname()
769 << QString::number(s_metadata->ID());
774 ShowOkPopup(tr(
"Asked the backend to check the tracks length"));
780 auto *me =
dynamic_cast<MythEvent *
>(event);
783 #if QT_VERSION < QT_VERSION_CHECK(5,14,0)
784 QStringList tokens = me->
Message().split(
" ", QString::SkipEmptyParts);
786 QStringList tokens = me->Message().split(
" ", Qt::SkipEmptyParts);
789 if (!tokens.isEmpty())
791 if (tokens[0] ==
"BROWSER_DOWNLOAD_FINISHED")
793 QStringList
args = me->ExtraDataList();
794 QString oldFilename =
args[1];
795 int fileSize =
args[2].toInt();
796 int errorCode =
args[4].toInt();
798 if ((errorCode != 0) || (fileSize == 0))
803 if (m_searchType ==
"artist")
805 QString cleanName =
fixFilename(s_metadata->Artist().toLower());
806 QString
file = QString(
"Icons/%1/%2.jpg").arg(
"artist", cleanName);
808 0,
file,
"MusicArt");
810 else if (m_searchType ==
"genre")
812 QString cleanName =
fixFilename(s_metadata->Genre().toLower());
813 QString
file = QString(
"Icons/%1/%2.jpg").arg(
"genre", cleanName);
815 0,
file,
"MusicArt");
817 else if (m_searchType ==
"album")
821 newFilename = s_metadata->Filename();
822 newFilename = newFilename.section(
'/', 0, -2);
823 newFilename = newFilename +
'/' + oldFilename.section(
'/', -1, -1);
827 LOG(VB_GENERAL, LOG_ERR, QString(
"Got unknown search type '%1' "
828 "in BROWSER_DOWNLOAD_FINISHED event")
834 QFile::remove(oldFilename);
836 if (m_searchType ==
"album")
844 s_metadata->getAlbumArtImages()->dumpToDatabase();
847 for (
int x = 0; x < allMusic->count(); x++)
849 if ((allMusic->at(x)->ID() == s_sourceMetadata->ID()) ||
850 (allMusic->at(x)->getDirectoryId() == s_sourceMetadata->getDirectoryId()))
852 allMusic->at(x)->reloadAlbumArtImages();
891 LOG(VB_GENERAL, LOG_ERR,
"Cannot load screen 'editalbumart'");
923 QFileInfo fi(image->m_filename);
936 for (
auto *art : qAsConst(*albumArtList))
940 QVariant::fromValue(art));
941 item->SetImage(art->m_filename);
942 QString state = art->m_embedded ?
"tag" :
"file";
943 item->DisplayState(state,
"locationstate");
955 for (
int i = 0; i < actions.size() && !handled; i++)
957 QString
action = actions[i];
962 else if (
action ==
"INFO")
980 if (!editDialog->Create())
999 label = tr(
"Change Image Type");
1001 label = tr(
"What image type do you want to use for this image?");
1015 menu->SetReturnEvent(
this,
"changetypemenu");
1018 menu->SetReturnEvent(
this,
"asktypemenu");
1034 QString label = tr(
"Options");
1046 menu->SetReturnEvent(
this,
"optionsmenu");
1048 menu->AddButton(tr(
"Edit Metadata"));
1049 menu->AddButton(tr(
"Rescan For Images"));
1052 menu->AddButton(tr(
"Search Internet For Images"));
1058 menu->AddButton(tr(
"Change Image Type"),
nullptr,
true);
1060 if (
GetMythDB()->GetBoolSetting(
"AllowTagWriting",
false))
1068 if (!image->m_embedded)
1071 menu->AddButton(tr(
"Copy Selected Image To Tag"));
1076 menu->AddButton(tr(
"Remove Selected Image From Tag"));
1083 if (
GetMythDB()->GetBoolSetting(
"AllowTagWriting",
false))
1086 menu->AddButton(tr(
"Copy Image To Tag"));
1100 if ((dce ==
nullptr) || (dce->GetResult() < 0))
1103 QString resultid = dce->
GetId();
1104 QString resulttext = dce->GetResultText();
1106 if (resultid ==
"changetypemenu")
1108 int type = dce->GetData().toInt();
1120 QStringList strList(
"MUSIC_TAG_CHANGEIMAGE");
1123 << QString::number(image->m_imageType)
1124 << QString::number(
type);
1135 else if (resultid ==
"asktypemenu")
1137 int type = dce->GetData().toInt();
1142 else if (resultid ==
"optionsmenu")
1144 if (resulttext == tr(
"Edit Metadata"))
1146 else if (resulttext == tr(
"Rescan For Images"))
1148 else if (resulttext == tr(
"Search Internet For Images"))
1150 else if (resulttext == tr(
"Change Image Type"))
1152 else if (resulttext == tr(
"Copy Selected Image To Tag"))
1154 else if (resulttext == tr(
"Remove Selected Image From Tag"))
1156 else if (resulttext == tr(
"Copy Image To Tag"))
1159 else if (resultid ==
"imagelocation")
1172 auto *me =
dynamic_cast<MythEvent *
>(event);
1175 #if QT_VERSION < QT_VERSION_CHECK(5,14,0)
1176 QStringList tokens = me->
Message().split(
" ", QString::SkipEmptyParts);
1178 QStringList tokens = me->Message().split(
" ", Qt::SkipEmptyParts);
1181 if (!tokens.isEmpty())
1183 if (tokens[0] ==
"BROWSER_DOWNLOAD_FINISHED")
1185 else if (tokens[0] ==
"MUSIC_ALBUMART_CHANGED")
1187 if (tokens.size() >= 2)
1225 fb->SetTypeFilter(QDir::AllDirs | QDir::Files | QDir::Readable);
1227 QStringList filters;
1228 filters <<
"*.png" <<
"*.jpg" <<
"*.jpeg" <<
"*.gif";
1229 fb->SetNameFilter(filters);
1233 fb->SetReturnEvent(
this,
"imagelocation");
1268 QString msg = tr(
"Are you sure you want to permanently remove this image from the tag?");
1286 QStringList strList(
"MUSIC_TAG_REMOVEIMAGE");
1289 << QString::number(image->m_id);
1322 popupStack,
"copyimagebusydialog");
1337 QString(
"AlbumArt/") + fi.fileName(),
1343 QStringList strList(
"MUSIC_TAG_ADDIMAGE");
1350 copyThread->start();
1352 while (copyThread->isRunning())
1354 qApp->processEvents();
1355 const struct timespec onems {0, 1000000};
1356 nanosleep(&onems,
nullptr);
1359 strList = copyThread->getResult();
CopyImageThread(QStringList strList)
MythScreenStack * GetMainStack()
Provide a dialog to quickly find an entry in a list.
QString findIcon(const QString &type, const QString &name, bool ignoreCache)
find an image for a artist or genre
QString GetMasterHostName(void)
static const Type kMythEventMessage
EditAlbumartDialog(MythScreenStack *parent)
void copySelectedImageToTag(void)
bool SendReceiveStringList(QStringList &strlist, bool quickTimeout=false, bool block=true)
Send a message to the backend and wait for a response.
AlbumArtList * getImageList(void)
MythUIType * GetChild(const QString &name) const
Get a named child of this UIType.
bool Load(bool allowLoadInBackground=true, bool forceStat=false)
Load the image(s), wraps ImageLoader::LoadImage()
This class is used as a container for messages.
bool GetBooleanCheckState(void) const
A text entry and edit widget.
void doCopyImageToTag(const AlbumArtImage *image)
#define LOG(_MASK_, _LEVEL_, _QSTRING_)
void RunProlog(void)
Sets up a thread, call this if you reimplement run().
Screen in which all other widgets are contained and rendered.
static ImageType guessImageType(const QString &filename)
QString GetText(void) const
void Reset(void) override
Reset the image back to the default defined in the theme.
void SetRange(int low, int high, int step, uint pageMultiple=5)
Set the lower and upper bounds of the spinbox, the interval and page amount.
const QString & Message() const
bool HandleMedia(const QString &Handler, const QString &Mrl, const QString &Plot="", const QString &Title="", const QString &Subtitle="", const QString &Director="", int Season=0, int Episode=0, const QString &Inetref="", std::chrono::minutes LenMins=2h, const QString &Year="1895", const QString &Id="", bool UseBookmarks=false)
void showTypeMenu(bool changeType=true)
static void removeCachedImage(const AlbumArtImage *image)
MythUIType * GetFocusWidget(void) const
MetadataPtrList * getAllMetadata(void)
void addListener(QObject *listener)
Add a listener to the observable.
void SetValue(int val) override
void run() override
Runs the Qt event loop unless we have a QRunnable, in which case we run the runnable run instead.
void SetText(const QString &text, bool moveCursor=true)
void doRemoveImageFromTag(bool doIt)
static QString GenMythURL(const QString &host=QString(), int port=0, QString path=QString(), const QString &storageGroup=QString())
MythUIImage * m_coverartImage
bool TranslateKeyPress(const QString &Context, QKeyEvent *Event, QStringList &Actions, bool AllowJumps=true)
Get a list of actions for a keypress in the given context.
QString fixFilename(const QString &filename)
remove any bad filename characters
Basic menu dialog, message and a list of options.
static MythThemedMenu * menu
int GetIntValue(void) const override
void BuildFocusList(void)
def rating(profile, smoonURL, gate)
~EditAlbumartDialog() override
AlbumArtImage * getImageAt(uint index)
send a message to the master BE without blocking the UI thread
void RemoveFromCacheByFile(const QString &File)
MythUIText * m_imagefilenameText
MythUIText * m_imagetypeText
void RunEpilog(void)
Cleans up a thread's resources, call this if you reimplement run().
QStringList getResult(void)
MythUIButton * m_metadataButton
static QString getTypeName(ImageType type)
void sendMetadataChangedEvent(int trackID)
void copyImageToTag(ImageType imageType)
MythCoreContext * gCoreContext
This global variable contains the MythCoreContext instance for the app.
A checkbox widget supporting three check states - on,off,half and two conditions - selected and unsel...
void removeSelectedImageFromTag(void)
static bool CopyFile(const QString &src, const QString &dst, bool overwrite=false, bool verify=false)
static bool Assign(ContainerType *container, UIType *&item, const QString &name, bool *err=nullptr)
bool keyPressEvent(QKeyEvent *event) override
Key event handler.
bool keyPressEvent(QKeyEvent *event) override
Key event handler.
void gridItemChanged(MythUIButtonListItem *item)
void SetCheckState(MythUIStateType::StateType state)
static bool LoadWindowFromXML(const QString &xmlfile, const QString &windowname, MythUIType *parent)
Event dispatched from MythUI modal dialogs to a listening class containing a result of some form.
virtual void SetText(const QString &text)
This is a wrapper around QThread that does several additional things.
static const Type kEventType
MythMainWindow * GetMythMainWindow(void)
void customEvent(QEvent *event) override
A widget for offering a range of numerical values where only the the bounding values and interval are...
void sendAlbumArtChangedEvent(int trackID)
void switchToMetadata(void)
MythScreenStack * GetStack(const QString &Stackname)
MythUIButtonList * m_coverartList
void startCopyImageToTag(void)
void updateImageGrid(void)
void SaveSetting(const QString &key, int newValue)
void SetFilename(const QString &filename)
Must be followed by a call to Load() to load the image.
MythUIHelper * GetMythUI()
static MThreadPool * globalInstance(void)
bool Create(void) override
void dumpToDatabase(void)
saves or updates the image details in the DB
virtual void AddScreen(MythScreenType *screen, bool allowFade=true)
void rescanForImages(void)
search the tracks tag and the tracks directory for images
void AddSelection(int value, const QString &label="")
Add a special label for a value of the spinbox, it does not need to be in the range.
MythConfirmationDialog * ShowOkPopup(const QString &message, bool showCancel)
Non-blocking version of MythPopupBox::showOkPopup()
void removeListener(QObject *listener)
Remove a listener to the observable.
void start(QRunnable *runnable, const QString &debugName, int priority=0)
bool DisplayState(const QString &name)
QString GetSetting(const QString &key, const QString &defaultval="")