46 const QString &name) :
65 for (
int x = 0; x < allMusic->count(); x++)
70 allMusic->at(x)->reloadAlbumArtImages();
96 for (
int i = 0; i < actions.size() && !handled; i++)
98 const QString&
action = actions[i];
166 QString label = tr(
"Save Changes?");
178 menu->SetReturnEvent(
this,
"savechangesmenu");
225 if (
GetMythDB()->GetBoolSetting(
"AllowTagWriting",
false))
228 strList <<
"MUSIC_TAG_UPDATE_METADATA %1 %2"
245 albumartButton->
Hide();
250 bool changed =
false;
270 artist = QUrl::toPercentEncoding(artist,
"+");
273 album = QUrl::toPercentEncoding(album,
"+");
275 QUrl url(
"http://www.google.co.uk/images?q=" + artist +
"+" + album, QUrl::TolerantMode);
345 LOG(VB_GENERAL, LOG_ERR,
"Cannot load screen 'editmetadata'");
451 for (
int i = 0; i < actions.size() && !handled; i++)
453 const QString&
action = actions[i];
458 else if (
action ==
"THMBDOWN")
460 else if (
action ==
"MENU")
477 QString label = tr(
"Options");
489 menu->SetReturnEvent(
this,
"optionsmenu");
491 menu->AddButton(tr(
"Edit Albumart Images"));
492 menu->AddButton(tr(
"Search Internet For Artist Image"));
493 menu->AddButton(tr(
"Search Internet For Album Image"));
494 menu->AddButton(tr(
"Search Internet For Genre Image"));
495 menu->AddButton(tr(
"Check Track Length"));
508 if (!editDialog->Create())
537 QString msg = tr(
"Select an Artist");
544 if (!searchDlg->Create())
567 QString
file =
findIcon(
"artist", artist.toLower(),
true);
582 QString msg = tr(
"Select a Compilation Artist");
589 if (!searchDlg->Create())
607 QString msg = tr(
"Select an Album");
614 if (!searchDlg->Create())
650 QString msg = tr(
"Select a Genre");
665 if (!searchDlg->Create())
688 QString
file =
findIcon(
"genre", genre.toLower(),
true);
720 genre = QUrl::toPercentEncoding(genre,
"+");
722 QUrl url(
"http://www.flickr.com/search/groups/?w=908425%40N22&m=pool&q=" + genre, QUrl::TolerantMode);
732 artist = QUrl::toPercentEncoding(artist,
"+");
734 QUrl url(
"http://www.google.co.uk/images?q=" + artist, QUrl::TolerantMode);
746 if ((dce ==
nullptr) || (dce->GetResult() < 0))
749 QString resultid = dce->
GetId();
750 QString resulttext = dce->GetResultText();
753 if (resultid ==
"optionsmenu")
755 if (resulttext == tr(
"Edit Albumart Images"))
757 else if (resulttext == tr(
"Search Internet For Genre Image"))
762 else if (resulttext == tr(
"Search Internet For Artist Image"))
767 else if (resulttext == tr(
"Search Internet For Album Image"))
772 else if (resulttext == tr(
"Check Track Length"))
775 strList <<
"MUSIC_CALC_TRACK_LENGTH"
782 ShowOkPopup(tr(
"Asked the backend to check the tracks length"));
788 auto *me =
dynamic_cast<MythEvent *
>(event);
791 QStringList tokens = me->
Message().split(
" ", Qt::SkipEmptyParts);
793 if (!tokens.isEmpty())
795 if (tokens[0] ==
"BROWSER_DOWNLOAD_FINISHED")
797 QStringList
args = me->ExtraDataList();
798 const QString& oldFilename =
args[1];
799 int fileSize =
args[2].toInt();
800 int errorCode =
args[4].toInt();
802 if ((errorCode != 0) || (fileSize == 0))
810 QString
file = QString(
"Icons/%1/%2.jpg").arg(
"artist", cleanName);
812 0,
file,
"MusicArt");
817 QString
file = QString(
"Icons/%1/%2.jpg").arg(
"genre", cleanName);
819 0,
file,
"MusicArt");
826 newFilename = newFilename.section(
'/', 0, -2);
827 newFilename = newFilename +
'/' + oldFilename.section(
'/', -1, -1);
831 LOG(VB_GENERAL, LOG_ERR, QString(
"Got unknown search type '%1' "
832 "in BROWSER_DOWNLOAD_FINISHED event")
838 QFile::remove(oldFilename);
851 for (
int x = 0; x < allMusic->count(); x++)
856 allMusic->at(x)->reloadAlbumArtImages();
895 LOG(VB_GENERAL, LOG_ERR,
"Cannot load screen 'editalbumart'");
927 QFileInfo fi(image->m_filename);
940 for (
auto *art : std::as_const(*albumArtList))
944 QVariant::fromValue(art));
945 item->SetImage(art->m_filename);
946 QString state = art->m_embedded ?
"tag" :
"file";
947 item->DisplayState(state,
"locationstate");
959 for (
int i = 0; i < actions.size() && !handled; i++)
961 const QString&
action = actions[i];
966 else if (
action ==
"INFO")
984 if (!editDialog->Create())
1003 label = tr(
"Change Image Type");
1005 label = tr(
"What image type do you want to use for this image?");
1019 menu->SetReturnEvent(
this,
"changetypemenu");
1022 menu->SetReturnEvent(
this,
"asktypemenu");
1038 QString label = tr(
"Options");
1050 menu->SetReturnEvent(
this,
"optionsmenu");
1052 menu->AddButton(tr(
"Edit Metadata"));
1053 menu->AddButton(tr(
"Rescan For Images"));
1056 menu->AddButton(tr(
"Search Internet For Images"));
1062 menu->AddButton(tr(
"Change Image Type"),
nullptr,
true);
1064 if (
GetMythDB()->GetBoolSetting(
"AllowTagWriting",
false))
1072 if (!image->m_embedded)
1075 menu->AddButton(tr(
"Copy Selected Image To Tag"));
1080 menu->AddButton(tr(
"Remove Selected Image From Tag"));
1087 if (
GetMythDB()->GetBoolSetting(
"AllowTagWriting",
false))
1090 menu->AddButton(tr(
"Copy Image To Tag"));
1104 if ((dce ==
nullptr) || (dce->GetResult() < 0))
1107 QString resultid = dce->
GetId();
1108 QString resulttext = dce->GetResultText();
1110 if (resultid ==
"changetypemenu")
1112 int type = dce->GetData().toInt();
1124 QStringList strList(
"MUSIC_TAG_CHANGEIMAGE");
1127 << QString::number(image->m_imageType)
1128 << QString::number(
type);
1139 else if (resultid ==
"asktypemenu")
1141 int type = dce->GetData().toInt();
1146 else if (resultid ==
"optionsmenu")
1148 if (resulttext == tr(
"Edit Metadata"))
1150 else if (resulttext == tr(
"Rescan For Images"))
1152 else if (resulttext == tr(
"Search Internet For Images"))
1154 else if (resulttext == tr(
"Change Image Type"))
1156 else if (resulttext == tr(
"Copy Selected Image To Tag"))
1158 else if (resulttext == tr(
"Remove Selected Image From Tag"))
1160 else if (resulttext == tr(
"Copy Image To Tag"))
1163 else if (resultid ==
"imagelocation")
1176 auto *me =
dynamic_cast<MythEvent *
>(event);
1179 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");
1270 QString msg = tr(
"Are you sure you want to permanently remove this image from the tag?");
1288 QStringList strList(
"MUSIC_TAG_REMOVEIMAGE");
1291 << QString::number(image->m_id);
1324 popupStack,
"copyimagebusydialog");
1339 QString(
"AlbumArt/") + fi.fileName(),
1345 QStringList strList(
"MUSIC_TAG_ADDIMAGE");
1352 copyThread->start();
1354 while (copyThread->isRunning())
1356 qApp->processEvents();
1357 std::this_thread::sleep_for(1ms);
1360 strList = copyThread->getResult();
AlbumArtList * getImageList(void)
AlbumArtImage * getImageAt(uint index)
static QString getTypeName(ImageType type)
void dumpToDatabase(void)
saves or updates the image details in the DB
static ImageType guessImageType(const QString &filename)
MetadataPtrList * getAllMetadata(void)
QStringList getResult(void)
void run() override
Runs the Qt event loop unless we have a QRunnable, in which case we run the runnable run instead.
CopyImageThread(QStringList strList)
Event dispatched from MythUI modal dialogs to a listening class containing a result of some form.
static const Type kEventType
static void removeCachedImage(const AlbumArtImage *image)
MythUIImage * m_coverartImage
MythUIButtonList * m_coverartList
void updateImageGrid(void)
MythUIButton * m_metadataButton
EditAlbumartDialog(MythScreenStack *parent)
~EditAlbumartDialog() override
bool Create(void) override
bool keyPressEvent(QKeyEvent *event) override
Key event handler.
void copyImageToTag(ImageType imageType)
void copySelectedImageToTag(void)
void switchToMetadata(void)
void removeSelectedImageFromTag(void)
void rescanForImages(void)
search the tracks tag and the tracks directory for images
void showTypeMenu(bool changeType=true)
void gridItemChanged(MythUIButtonListItem *item)
void startCopyImageToTag(void)
void doRemoveImageFromTag(bool doIt)
MythUIText * m_imagefilenameText
MythUIText * m_imagetypeText
void doCopyImageToTag(const AlbumArtImage *image)
void customEvent(QEvent *event) override
static MThreadPool * globalInstance(void)
void start(QRunnable *runnable, const QString &debugName, int priority=0)
This is a wrapper around QThread that does several additional things.
void RunProlog(void)
Sets up a thread, call this if you reimplement run().
void RunEpilog(void)
Cleans up a thread's resources, call this if you reimplement run().
void sendMetadataChangedEvent(int trackID)
void sendAlbumArtChangedEvent(int trackID)
void SaveSetting(const QString &key, int newValue)
QString GetSetting(const QString &key, const QString &defaultval="")
bool SendReceiveStringList(QStringList &strlist, bool quickTimeout=false, bool block=true)
Send a message to the backend and wait for a response.
static QString GenMythURL(const QString &host=QString(), int port=0, QString path=QString(), const QString &storageGroup=QString())
QString GetMasterHostName(void)
Basic menu dialog, message and a list of options.
This class is used as a container for messages.
const QString & Message() const
static const Type kMythEventMessage
MythScreenStack * GetMainStack()
bool TranslateKeyPress(const QString &Context, QKeyEvent *Event, QStringList &Actions, bool AllowJumps=true)
Get a list of actions for a keypress in the given context.
MythScreenStack * GetStack(const QString &Stackname)
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 addListener(QObject *listener)
Add a listener to the observable.
void removeListener(QObject *listener)
Remove a listener to the observable.
virtual void AddScreen(MythScreenType *screen, bool allowFade=true)
Screen in which all other widgets are contained and rendered.
void BuildFocusList(void)
MythUIType * GetFocusWidget(void) const
bool keyPressEvent(QKeyEvent *event) override
Key event handler.
A checkbox widget supporting three check states - on,off,half and two conditions - selected and unsel...
void SetCheckState(MythUIStateType::StateType state)
bool GetBooleanCheckState(void) const
bool Load(bool allowLoadInBackground=true, bool forceStat=false)
Load the image(s), wraps ImageLoader::LoadImage()
void SetFilename(const QString &filename)
Must be followed by a call to Load() to load the image.
void Reset(void) override
Reset the image back to the default defined in the theme.
Provide a dialog to quickly find an entry in a list.
A widget for offering a range of numerical values where only the the bounding values and interval are...
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.
void SetValue(int val) override
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.
int GetIntValue(void) const override
bool DisplayState(const QString &name)
A text entry and edit widget.
QString GetText(void) const
void SetText(const QString &text, bool moveCursor=true)
virtual void SetText(const QString &text)
void RemoveFromCacheByFile(const QString &File)
MythUIType * GetChild(const QString &name) const
Get a named child of this UIType.
static bool CopyFile(const QString &src, const QString &dst, bool overwrite=false, bool verify=false)
send a message to the master BE without blocking the UI thread
static bool LoadWindowFromXML(const QString &xmlfile, const QString &windowname, MythUIType *parent)
QString fixFilename(const QString &filename)
remove any bad filename characters
QString findIcon(const QString &type, const QString &name, bool ignoreCache)
find an image for a artist or genre
MythCoreContext * gCoreContext
This global variable contains the MythCoreContext instance for the app.
MythConfirmationDialog * ShowOkPopup(const QString &message, bool showCancel)
Non-blocking version of MythPopupBox::showOkPopup()
#define LOG(_MASK_, _LEVEL_, _QSTRING_)
MythMainWindow * GetMythMainWindow(void)
static MythThemedMenu * menu
MythUIHelper * GetMythUI()
def rating(profile, smoonURL, gate)
static bool Assign(ContainerType *container, UIType *&item, const QString &name, bool *err=nullptr)