@@ -1074,14 +1074,11 @@ void EditAlbumartDialog::showMenu(void )
1074
1074
1075
1075
menu->AddButton (tr (" Search Internet For Images" ));
1076
1076
1077
- // FIXME this needs updating to work with storage groups
1078
- #if 0
1079
-
1080
- MetaIO *tagger = m_metadata->getTagger();
1077
+ MetaIO *tagger = MetaIO::createTagger (m_metadata->Filename (false ));
1081
1078
1082
1079
if (m_coverartList->GetItemCurrent ())
1083
1080
{
1084
- menu->AddButton(tr("Change Image Type"), NULL, true);
1081
+ // menu->AddButton(tr("Change Image Type"), NULL, true);
1085
1082
1086
1083
if (GetMythDB ()->GetNumSetting (" AllowTagWriting" , 0 ))
1087
1084
{
@@ -1114,7 +1111,7 @@ void EditAlbumartDialog::showMenu(void )
1114
1111
1115
1112
if (tagger)
1116
1113
delete tagger;
1117
- # endif
1114
+
1118
1115
popupStack->AddScreen (menu);
1119
1116
}
1120
1117
@@ -1255,6 +1252,22 @@ void EditAlbumartDialog::customEvent(QEvent *event)
1255
1252
{
1256
1253
if (tokens[0 ] == " BROWSER_DOWNLOAD_FINISHED" )
1257
1254
rescanForImages ();
1255
+ else if (tokens[0 ] == " MUSIC_METADATA_CHANGED" )
1256
+ {
1257
+ if (tokens.size () >= 2 )
1258
+ {
1259
+ int songID = tokens[1 ].toInt ();
1260
+
1261
+ if (m_metadata->ID () == songID)
1262
+ {
1263
+ // force all the image to reload
1264
+ for (int x = 0 ; x < m_metadata->getAlbumArtImages ()->getImageCount (); x++)
1265
+ removeCachedImage (m_metadata->getAlbumArtImages ()->getImageAt (x));
1266
+
1267
+ updateImageGrid ();
1268
+ }
1269
+ }
1270
+ }
1258
1271
}
1259
1272
}
1260
1273
}
@@ -1339,65 +1352,95 @@ void EditAlbumartDialog::doRemoveImageFromTag(bool doIt)
1339
1352
AlbumArtImage *image = qVariantValue<AlbumArtImage*> (item->GetData ());
1340
1353
if (image)
1341
1354
{
1342
- MetaIO *tagger = m_metadata->getTagger ();
1355
+ // ask the backend to remove the image from the tracks tag
1356
+ QStringList strList (" MUSIC_TAG_REMOVEIMAGE" );
1357
+ strList << m_metadata->Hostname ()
1358
+ << QString::number (m_metadata->ID ())
1359
+ << QString::number (image->id );
1343
1360
1344
- if (tagger && !tagger->supportsEmbeddedImages ())
1345
- {
1346
- LOG (VB_GENERAL, LOG_ERR, " EditAlbumartDialog: asked to remove an image from the tag "
1347
- " but the tagger doesn't support it!" );
1348
- delete tagger;
1349
- return ;
1350
- }
1351
-
1352
- if (!tagger->removeAlbumArt (m_metadata->Filename (), image))
1353
- LOG (VB_GENERAL, LOG_ERR, " EditAlbumartDialog: failed to remove album art from tag" );
1354
- else
1355
- LOG (VB_GENERAL, LOG_INFO, " EditAlbumartDialog: album art removed from tag" );
1361
+ gCoreContext ->SendReceiveStringList (strList);
1356
1362
1357
1363
removeCachedImage (image);
1358
1364
rescanForImages ();
1359
-
1360
- if (tagger)
1361
- delete tagger;
1362
1365
}
1363
1366
}
1364
1367
}
1365
1368
1366
- void EditAlbumartDialog::doCopyImageToTag ( const AlbumArtImage *image)
1369
+ class CopyImageThread : public MThread
1367
1370
{
1368
- MetaIO *tagger = m_metadata->getTagger ();
1371
+ public:
1372
+ CopyImageThread (QStringList strList) :
1373
+ MThread (" CopyImage" ), m_strList(strList) {}
1369
1374
1370
- if (tagger && !tagger-> supportsEmbeddedImages () )
1375
+ virtual void run ( )
1371
1376
{
1372
- LOG (VB_GENERAL, LOG_ERR, " EditAlbumartDialog: asked to write album art to the tag "
1373
- " but the tagger does't support it!" );
1374
- delete tagger;
1375
- return ;
1377
+ RunProlog ();
1378
+ gCoreContext ->SendReceiveStringList (m_strList);
1379
+ RunEpilog ();
1376
1380
}
1377
1381
1378
- if (!tagger->writeAlbumArt (m_metadata->Filename (), image))
1379
- LOG (VB_GENERAL, LOG_ERR, " EditAlbumartDialog: failed to write album art to tag" );
1382
+ QStringList getResult (void ) { return m_strList; }
1383
+
1384
+ private:
1385
+ QStringList m_strList;
1386
+ };
1387
+
1388
+ void EditAlbumartDialog::doCopyImageToTag (const AlbumArtImage *image)
1389
+ {
1390
+ MythScreenStack *popupStack = GetMythMainWindow ()->GetStack (" popup stack" );
1391
+ MythUIBusyDialog *busy = new MythUIBusyDialog (tr (" Copying image to tag..." ),
1392
+ popupStack, " copyimagebusydialog" );
1393
+
1394
+ if (busy->Create ())
1395
+ {
1396
+ popupStack->AddScreen (busy, false );
1397
+ }
1380
1398
else
1381
- LOG (VB_GENERAL, LOG_INFO, " EditAlbumartDialog: album art written to tag" );
1399
+ {
1400
+ delete busy;
1401
+ busy = NULL ;
1402
+ }
1403
+
1404
+ // copy the image to the tracks host
1405
+ QFileInfo fi (image->filename );
1406
+ QString saveFilename = gCoreContext ->GenMythURL (m_metadata->Hostname (), 0 ,
1407
+ QString (" AlbumArt/" ) + fi.fileName (),
1408
+ " MusicArt" );
1409
+
1410
+ RemoteFile::CopyFile (image->filename , saveFilename);
1411
+
1412
+ // ask the backend to add the image to the tracks tag
1413
+ QStringList strList (" MUSIC_TAG_ADDIMAGE" );
1414
+ strList << m_metadata->Hostname ()
1415
+ << QString::number (m_metadata->ID ())
1416
+ << fi.fileName ()
1417
+ << QString::number (image->imageType );
1418
+
1419
+ CopyImageThread *copyThread = new CopyImageThread (strList);
1420
+ copyThread->start ();
1421
+
1422
+ while (copyThread->isRunning ())
1423
+ {
1424
+ qApp->processEvents ();
1425
+ usleep (1000 );
1426
+ }
1427
+
1428
+ strList = copyThread->getResult ();
1429
+
1430
+ delete copyThread;
1431
+
1432
+ if (busy)
1433
+ busy->Close ();
1382
1434
1383
1435
removeCachedImage (image);
1384
1436
1385
1437
rescanForImages ();
1386
-
1387
- if (tagger)
1388
- delete tagger;
1389
1438
}
1390
1439
1391
1440
void EditAlbumartDialog::removeCachedImage (const AlbumArtImage *image)
1392
1441
{
1393
1442
if (!image->embedded )
1394
1443
return ;
1395
1444
1396
- QString imageFilename = QString (GetConfDir () + " /MythMusic/AlbumArt/%1-%2.jpg" )
1397
- .arg (m_metadata->ID ()).arg (AlbumArtImages::getTypeFilename (image->imageType ));
1398
-
1399
- if (QFile::exists (imageFilename))
1400
- QFile::remove (imageFilename);
1401
-
1402
- GetMythUI ()->RemoveFromCacheByFile (imageFilename);
1445
+ GetMythUI ()->RemoveFromCacheByFile (image->filename );
1403
1446
}
0 commit comments