14#include <mythconfig.h>
48 m_destinationScreen(destinationScreen),
49 m_themeScreen(themeScreen),
50 m_archiveDestination(archiveDestination)
56 LOG(VB_GENERAL, LOG_ERR,
"MythBurn: Failed to clear thumb directory");
96 LOG(VB_GENERAL, LOG_ERR,
"Cannot load screen 'mythburn'");
133 for (
int i = 0; i < actions.size() && !handled; i++)
135 const QString&
action = actions[i];
155 else if (
action ==
"DOWN")
167 else if (
action ==
"DELETE")
171 else if (
action ==
"INFO")
175 else if (
action ==
"TOGGLECUT")
197 uint usedSpace = size / 1024 / 1024;
210 tmpSize = QString(
"%1 Mb").arg(usedSpace);
232 item->description =
"";
233 item->bitrate = 0.0F;
239 "/MythArchive/ffmpeg_dvd_" +
241 .toLower() ==
"ntsc") ?
"ntsc" :
"pal") +
".xml";
247 "mytharchive/encoder_profiles/ffmpeg_dvd_" +
249 .toLower() ==
"ntsc") ?
"ntsc" :
"pal") +
".xml";
252 LOG(VB_GENERAL, LOG_NOTICE,
253 "MythArchive: Loading encoding profiles from " +
filename);
255 QDomDocument doc(
"mydocument");
257 if (!
file.open(QIODevice::ReadOnly))
260 if (!doc.setContent( &
file ))
267 QDomElement docElem = doc.documentElement();
268 QDomNodeList profileNodeList = doc.elementsByTagName(
"profile");
273 for (
int x = 0; x < profileNodeList.count(); x++)
275 QDomNode n = profileNodeList.item(x);
276 QDomElement e = n.toElement();
277 QDomNode n2 = e.firstChild();
280 QDomElement e2 = n2.toElement();
283 if (e2.tagName() ==
"name")
285 if (e2.tagName() ==
"description")
287 if (e2.tagName() ==
"bitrate")
291 n2 = n2.nextSibling();
297 item2->description = desc;
298 item2->bitrate = bitrate.toFloat();
320 item->
SetText(tr(
"Using Cut List"),
"cutlist");
325 item->
SetText(tr(
"Not Using Cut List"),
"cutlist");
331 item->
SetText(tr(
"No Cut List"),
"cutlist");
342 ShowOkPopup(tr(
"You need to add at least one item to archive!"));
370 if (
file.open( QIODevice::ReadOnly ))
372 QTextStream stream(&
file);
374 while ( !stream.atEnd() )
376 res = res + stream.readLine();
390 QString message = tr(
"Retrieving File Information. Please Wait...");
394 auto *busyPopup =
new
397 if (busyPopup->Create())
405 QCoreApplication::processEvents();
417 QCoreApplication::processEvents();
419 if (a->duration == 0)
422 LOG(VB_GENERAL, LOG_ERR,
423 QString(
"MythBurn: failed to get file details for: %1").arg(a->filename));
428 if (a->encoderProfile ==
nullptr)
434 item->SetData(QVariant::fromValue(a));
435 item->SetText(a->subtitle,
"subtitle");
436 item->SetText(a->startDate +
" " + a->startTime,
"date");
442 item->SetText(tr(
"Using Cut List"),
"cutlist");
443 item->DisplayState(
"using",
"cutliststatus");
447 item->SetText(tr(
"Not Using Cut List"),
"cutlist");
448 item->DisplayState(
"notusing",
"cutliststatus");
453 item->SetText(tr(
"No Cut List"),
"cutlist");
454 item->DisplayState(
"none",
"cutliststatus");
456 item->SetText(tr(
"Encoder: ") + a->encoderProfile->name,
"profile");
473 if (
type ==
"Recording")
478 query.
prepare(
"SELECT title FROM recorded WHERE basename = :FILENAME");
482 LOG(VB_GENERAL, LOG_ERR,
483 QString(
"MythArchive: Recording not found (%1)")
486 else if (
type ==
"Video")
489 query.
prepare(
"SELECT title FROM videometadata"
490 " WHERE filename = :FILENAME");
494 LOG(VB_GENERAL, LOG_ERR,
495 QString(
"MythArchive: Video not found (%1)").arg(
filename));
497 else if (
type ==
"File")
501 LOG(VB_GENERAL, LOG_ERR,
502 QString(
"MythArchive: File not found (%1)").arg(
filename));
505 LOG(VB_GENERAL, LOG_NOTICE,
"MythArchive: Archive item removed from list");
518 if (item->
videoCodec.toLower() ==
"mpeg2video (main)")
549 QString defaultProfile =
553 if (x->name == defaultProfile)
562 QDomDocument doc(
"mythburn");
564 QDomElement root = doc.createElement(
"mythburn");
565 doc.appendChild(root);
567 QDomElement job = doc.createElement(
"job");
568 job.setAttribute(
"theme",
m_theme);
569 root.appendChild(job);
571 QDomElement media = doc.createElement(
"media");
572 job.appendChild(media);
585 QDomElement
file = doc.createElement(
"file");
586 file.setAttribute(
"type", a->type.toLower() );
587 file.setAttribute(
"usecutlist",
static_cast<int>(a->useCutlist));
588 file.setAttribute(
"filename", a->filename);
589 file.setAttribute(
"encodingprofile", a->encoderProfile->name);
590 if (a->editedDetails)
592 QDomElement details = doc.createElement(
"details");
593 file.appendChild(details);
594 details.setAttribute(
"title", a->title);
595 details.setAttribute(
"subtitle", a->subtitle);
596 details.setAttribute(
"startdate", a->startDate);
597 details.setAttribute(
"starttime", a->startTime);
598 QDomText desc = doc.createTextNode(a->description);
599 details.appendChild(desc);
602 if (!a->thumbList.empty())
604 QDomElement thumbs = doc.createElement(
"thumbimages");
605 file.appendChild(thumbs);
607 for (
auto *thumbImage : std::as_const(a->thumbList))
609 QDomElement thumb = doc.createElement(
"thumb");
610 thumbs.appendChild(thumb);
611 thumb.setAttribute(
"caption", thumbImage->caption);
612 thumb.setAttribute(
"filename", thumbImage->filename);
613 thumb.setAttribute(
"frame", (
int) thumbImage->frame);
617 media.appendChild(
file);
621 QDomElement
options = doc.createElement(
"options");
632 if (!f.open(QIODevice::WriteOnly))
634 LOG(VB_GENERAL, LOG_ERR,
635 QString(
"MythBurn::createConfigFile: "
636 "Failed to open file for writing - %1") .arg(
filename));
641 t << doc.toString(4);
659 query.
prepare(
"SELECT type, title, subtitle, description, startdate, "
660 "starttime, size, filename, hascutlist, duration, "
661 "cutduration, videowidth, videoheight, filecodec, "
662 "videocodec, encoderprofile FROM archiveitems "
675 a->title = query.
value(1).toString();
676 a->subtitle = query.
value(2).toString();
677 a->description = query.
value(3).toString();
678 a->startDate = query.
value(4).toString();
679 a->startTime = query.
value(5).toString();
680 a->size = query.
value(6).toLongLong();
681 a->filename = query.
value(7).toString();
682 a->hasCutlist = (query.
value(8).toInt() == 1);
683 a->useCutlist =
false;
684 a->duration = query.
value(9).toInt();
685 a->cutDuration = query.
value(10).toInt();
686 a->videoWidth = query.
value(11).toInt();
687 a->videoHeight = query.
value(12).toInt();
688 a->fileCodec = query.
value(13).toString();
689 a->videoCodec = query.
value(14).toString();
691 a->editedDetails =
false;
699 if (x->name == profileName)
709 query.
prepare(
"DELETE FROM archiveitems;");
725 query.
prepare(
"INSERT INTO archiveitems (type, title, subtitle, "
726 "description, startdate, starttime, size, filename, "
727 "hascutlist, duration, cutduration, videowidth, "
728 "videoheight, filecodec, videocodec, encoderprofile) "
729 "VALUES(:TYPE, :TITLE, :SUBTITLE, :DESCRIPTION, :STARTDATE, "
730 ":STARTTIME, :SIZE, :FILENAME, :HASCUTLIST, :DURATION, "
731 ":CUTDURATION, :VIDEOWIDTH, :VIDEOHEIGHT, :FILECODEC, "
732 ":VIDEOCODEC, :ENCODERPROFILE);");
735 query.
bindValue(
":SUBTITLE", a->subtitle);
736 query.
bindValue(
":DESCRIPTION", a->description);
737 query.
bindValue(
":STARTDATE", a->startDate);
738 query.
bindValue(
":STARTTIME", a->startTime);
739 query.
bindValue(
":SIZE", (qint64)a->size);
740 query.
bindValue(
":FILENAME", a->filename);
741 query.
bindValue(
":HASCUTLIST", a->hasCutlist);
742 query.
bindValue(
":DURATION", a->duration);
743 query.
bindValue(
":CUTDURATION", a->cutDuration);
744 query.
bindValue(
":VIDEOWIDTH", a->videoWidth);
745 query.
bindValue(
":VIDEOHEIGHT", a->videoHeight);
746 query.
bindValue(
":FILECODEC", a->fileCodec);
747 query.
bindValue(
":VIDEOCODEC", a->videoCodec);
748 query.
bindValue(
":ENCODERPROFILE", a->encoderProfile->name);
768 auto *menuPopup =
new MythDialogBox(tr(
"Menu"), popupStack,
"actionmenu");
770 if (menuPopup->Create())
773 menuPopup->SetReturnEvent(
this,
"action");
775 if (curItem->hasCutlist)
777 if (curItem->useCutlist)
779 menuPopup->AddButton(tr(
"Don't Use Cut List"),
784 menuPopup->AddButton(tr(
"Use Cut List"),
823 if (editor->Create())
839 if (finder->Create())
847 if (ok && item && gridItem)
868 if (profileDialog->Create())
870 popupStack->
AddScreen(profileDialog,
false);
902 QString logDir = tempDir +
"logs";
903 QString configDir = tempDir +
"config";
911 QFile::remove(logDir +
"/mythburncancel.lck");
914 commandline = PYTHON_EXE;
915 commandline +=
" " +
GetShareDir() +
"mytharchive/scripts/mythburn.py";
916 commandline +=
" -j " + configDir +
"/mydata.xml";
917 commandline +=
" -l " + logDir +
"/progress.log";
918 commandline +=
" > " + logDir +
"/mythburn.log 2>&1 &";
927 ShowOkPopup(tr(
"It was not possible to create the DVD. "
928 " An error occured when running the scripts"));
950 if (selector->Create())
963 query.
prepare(
"SELECT title FROM videometadata");
980 if (selector->Create())
987 "*.mpg *.mpeg *.mov *.avi *.nuv");
997 if (selector->Create())
1028 LOG(VB_GENERAL, LOG_ERR,
"Cannot load screen 'profilepopup'");
1036 item->SetData(QVariant::fromValue(x));
1089 setObjectName(
"BurnMenu");
1097 "The last run failed to create a DVD."));
1102 QString title = tr(
"Burn DVD");
1103 QString msg = tr(
"\nPlace a blank DVD in the"
1104 " drive and select an option below.");
1107 "actionmenu",
true);
1109 if (menuPopup->Create())
1112 menuPopup->SetReturnEvent(
this,
"action");
1114 menuPopup->AddButton(tr(
"Burn DVD"));
1115 menuPopup->AddButton(tr(
"Burn DVD Rewritable"));
1116 menuPopup->AddButton(tr(
"Burn DVD Rewritable (Force Erase)"));
1123 if (dce->GetId() ==
"action")
1125 doBurn(dce->GetResult());
1133 if ((mode < 0) || (mode > 2))
1141 QString logDir = tempDir +
"logs";
1142 QString commandline;
1146 QFile::remove(logDir +
"/progress.log");
1150 QFile::remove(logDir +
"/mythburncancel.lck");
1152 QString sArchiveFormat = QString::number(mode);
1153 bool bEraseDVDRW = (mode == 2);
1155 .startsWith(
"Native");
1157 commandline =
"mytharchivehelper --burndvd --mediatype " + sArchiveFormat +
1158 (bEraseDVDRW ?
" --erasedvdrw" :
"") +
1159 (bNativeFormat ?
" --nativeformat" :
"");
1162 commandline +=
" --quiet";
1163 commandline +=
" > " + logDir +
"/progress.log 2>&1 &";
1171 "mytharchivehelper to burn the DVD."));
void recalcItemSize(ArchiveItem *item)
bool getFileDetails(ArchiveItem *a)
void showWarningDialog(const QString &msg)
QString getBaseName(const QString &filename)
QString getTempDirectory(bool showError)
Event dispatched from MythUI modal dialogs to a listening class containing a result of some form.
QSqlQuery wrapper that fetches a DB connection from the connection pool.
bool prepare(const QString &query)
QSqlQuery::prepare() is not thread safe in Qt <= 3.3.2.
QVariant value(int i) const
bool exec(void)
Wrap QSqlQuery::exec() so we can display SQL.
void bindValue(const QString &placeholder, const QVariant &val)
Add a single binding.
bool next(void)
Wrap QSqlQuery::next() so we can display the query results.
static MSqlQueryInfo InitCon(ConnectionReuse _reuse=kNormalConnection)
Only use this in combination with MSqlQuery constructor.
void selectorClosed(bool ok)
void toggleUseCutlist(void)
MythUIProgressBar * m_sizeBar
MythUIButton * m_prevButton
MythScreenType * m_destinationScreen
void editThumbnails(void)
MythBurn(MythScreenStack *parent, MythScreenType *destinationScreen, MythScreenType *themeScreen, const ArchiveDestination &archiveDestination, const QString &name)
EncoderProfile * getDefaultProfile(ArchiveItem *item)
void updateArchiveList(void)
MythUIButton * m_addfileButton
static bool isArchiveItemValid(const QString &type, const QString &filename)
void loadEncoderProfiles(void)
MythUIButtonList * m_archiveButtonList
MythScreenType * m_themeScreen
MythUIText * m_currentsizeErrorText
MythUIButton * m_addrecordingButton
MythUIButton * m_nextButton
MythUIText * m_nofilesText
bool Create(void) override
void loadConfiguration(void)
MythUIText * m_maxsizeText
MythUIButton * m_addvideoButton
static QString loadFile(const QString &filename)
ArchiveDestination m_archiveDestination
void handleAddVideo(void)
void handleAddRecording(void)
bool keyPressEvent(QKeyEvent *event) override
Key event handler.
void saveConfiguration(void)
MythUIText * m_minsizeText
void profileChanged(int profileNo)
MythUIButton * m_cancelButton
EncoderProfile * getProfileFromName(const QString &profileName)
void itemClicked(MythUIButtonListItem *item)
void createConfigFile(const QString &filename)
QList< ArchiveItem * > m_archiveList
void editorClosed(bool ok, ArchiveItem *item)
void handleNextPage(void)
void handlePrevPage(void)
QList< EncoderProfile * > m_profileList
void ShowMenu(void) override
MythUIText * m_currentsizeText
void SaveSetting(const QString &key, int newValue)
QString GetSetting(const QString &key, const QString &defaultval="")
static void DBError(const QString &where, const MSqlQuery &query)
Basic menu dialog, message and a list of options.
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)
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.
bool SetFocusWidget(MythUIType *widget=nullptr)
virtual void SetText(const QString &text)
MythUIText * m_captionText
ArchiveItem * m_archiveItem
QList< EncoderProfile * > m_profileList
MythUIButton * m_okButton
void haveResult(int profile)
MythUIText * m_newSizeText
MythUIButtonList * m_profileBtnList
MythUIText * m_descriptionText
void profileChanged(MythUIButtonListItem *item)
MythUIText * m_oldSizeText
static bool LoadWindowFromXML(const QString &xmlfile, const QString &windowname, MythUIType *parent)
@ GENERIC_EXIT_OK
Exited with no error.
@ GENERIC_EXIT_RUNNING
Process is running.
bool logPropagateQuiet(void)
Check if we are propagating a "--quiet".
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()
QString GetShareDir(void)
#define LOG(_MASK_, _LEVEL_, _QSTRING_)
MythMainWindow * GetMythMainWindow(void)
bool MythRemoveDirectory(QDir &aDir)
@ kMSDontBlockInputDevs
avoid blocking LIRC & Joystick Menu
@ kMSRunBackground
run child in the background
@ kMSDontDisableDrawing
avoid disabling UI drawing
uint myth_system(const QString &command, uint flags, std::chrono::seconds timeout)
MBASE_PUBLIC QString formatKBytes(int64_t sizeKB, int prec=1)
EncoderProfile * encoderProfile
static bool Assign(ContainerType *container, UIType *&item, const QString &name, bool *err=nullptr)