Go to the documentation of this file.
7 #include <QApplication>
9 #include <QDomDocument>
11 #include <QTextStream>
14 #include <mythconfig.h>
47 m_destinationScreen(destinationScreen),
48 m_themeScreen(themeScreen),
49 m_archiveDestination(archiveDestination)
55 LOG(VB_GENERAL, LOG_ERR,
"MythBurn: Failed to clear thumb directory");
95 LOG(VB_GENERAL, LOG_ERR,
"Cannot load screen 'mythburn'");
132 for (
int i = 0; i < actions.size() && !handled; i++)
134 const QString&
action = actions[i];
154 else if (
action ==
"DOWN")
166 else if (
action ==
"DELETE")
170 else if (
action ==
"INFO")
174 else if (
action ==
"TOGGLECUT")
196 uint usedSpace = size / 1024 / 1024;
209 tmpSize = QString(
"%1 Mb").arg(usedSpace);
231 item->description =
"";
232 item->bitrate = 0.0F;
238 "/MythArchive/ffmpeg_dvd_" +
240 .toLower() ==
"ntsc") ?
"ntsc" :
"pal") +
".xml";
246 "mytharchive/encoder_profiles/ffmpeg_dvd_" +
248 .toLower() ==
"ntsc") ?
"ntsc" :
"pal") +
".xml";
251 LOG(VB_GENERAL, LOG_NOTICE,
252 "MythArchive: Loading encoding profiles from " +
filename);
254 QDomDocument doc(
"mydocument");
256 if (!
file.open(QIODevice::ReadOnly))
259 if (!doc.setContent( &
file ))
266 QDomElement docElem = doc.documentElement();
267 QDomNodeList profileNodeList = doc.elementsByTagName(
"profile");
272 for (
int x = 0; x < profileNodeList.count(); x++)
274 QDomNode n = profileNodeList.item(x);
275 QDomElement e = n.toElement();
276 QDomNode n2 = e.firstChild();
279 QDomElement e2 = n2.toElement();
282 if (e2.tagName() ==
"name")
284 if (e2.tagName() ==
"description")
286 if (e2.tagName() ==
"bitrate")
290 n2 = n2.nextSibling();
296 item2->description = desc;
297 item2->bitrate = bitrate.toFloat();
319 item->
SetText(tr(
"Using Cut List"),
"cutlist");
324 item->
SetText(tr(
"Not Using Cut List"),
"cutlist");
330 item->
SetText(tr(
"No Cut List"),
"cutlist");
341 ShowOkPopup(tr(
"You need to add at least one item to archive!"));
369 if (
file.open( QIODevice::ReadOnly ))
371 QTextStream stream(&
file);
373 while ( !stream.atEnd() )
375 res = res + stream.readLine();
389 QString message = tr(
"Retrieving File Information. Please Wait...");
393 auto *busyPopup =
new
396 if (busyPopup->Create())
404 QCoreApplication::processEvents();
416 QCoreApplication::processEvents();
418 if (a->duration == 0)
421 LOG(VB_GENERAL, LOG_ERR,
422 QString(
"MythBurn: failed to get file details for: %1").arg(a->filename));
427 if (a->encoderProfile ==
nullptr)
433 item->SetData(QVariant::fromValue(a));
434 item->SetText(a->subtitle,
"subtitle");
435 item->SetText(a->startDate +
" " + a->startTime,
"date");
441 item->SetText(tr(
"Using Cut List"),
"cutlist");
442 item->DisplayState(
"using",
"cutliststatus");
446 item->SetText(tr(
"Not Using Cut List"),
"cutlist");
447 item->DisplayState(
"notusing",
"cutliststatus");
452 item->SetText(tr(
"No Cut List"),
"cutlist");
453 item->DisplayState(
"none",
"cutliststatus");
455 item->SetText(tr(
"Encoder: ") + a->encoderProfile->name,
"profile");
472 if (
type ==
"Recording")
477 query.
prepare(
"SELECT title FROM recorded WHERE basename = :FILENAME");
481 LOG(VB_GENERAL, LOG_ERR,
482 QString(
"MythArchive: Recording not found (%1)")
485 else if (
type ==
"Video")
488 query.
prepare(
"SELECT title FROM videometadata"
489 " WHERE filename = :FILENAME");
493 LOG(VB_GENERAL, LOG_ERR,
494 QString(
"MythArchive: Video not found (%1)").arg(
filename));
496 else if (
type ==
"File")
500 LOG(VB_GENERAL, LOG_ERR,
501 QString(
"MythArchive: File not found (%1)").arg(
filename));
504 LOG(VB_GENERAL, LOG_NOTICE,
"MythArchive: Archive item removed from list");
517 if (item->
videoCodec.toLower() ==
"mpeg2video (main)")
548 QString defaultProfile =
552 if (x->name == defaultProfile)
561 QDomDocument doc(
"mythburn");
563 QDomElement root = doc.createElement(
"mythburn");
564 doc.appendChild(root);
566 QDomElement job = doc.createElement(
"job");
567 job.setAttribute(
"theme",
m_theme);
568 root.appendChild(job);
570 QDomElement media = doc.createElement(
"media");
571 job.appendChild(media);
584 QDomElement
file = doc.createElement(
"file");
585 file.setAttribute(
"type", a->type.toLower() );
586 file.setAttribute(
"usecutlist",
static_cast<int>(a->useCutlist));
587 file.setAttribute(
"filename", a->filename);
588 file.setAttribute(
"encodingprofile", a->encoderProfile->name);
589 if (a->editedDetails)
591 QDomElement details = doc.createElement(
"details");
592 file.appendChild(details);
593 details.setAttribute(
"title", a->title);
594 details.setAttribute(
"subtitle", a->subtitle);
595 details.setAttribute(
"startdate", a->startDate);
596 details.setAttribute(
"starttime", a->startTime);
597 QDomText desc = doc.createTextNode(a->description);
598 details.appendChild(desc);
601 if (!a->thumbList.empty())
603 QDomElement thumbs = doc.createElement(
"thumbimages");
604 file.appendChild(thumbs);
606 for (
auto *thumbImage : std::as_const(a->thumbList))
608 QDomElement thumb = doc.createElement(
"thumb");
609 thumbs.appendChild(thumb);
610 thumb.setAttribute(
"caption", thumbImage->caption);
611 thumb.setAttribute(
"filename", thumbImage->filename);
612 thumb.setAttribute(
"frame", (
int) thumbImage->frame);
616 media.appendChild(
file);
620 QDomElement
options = doc.createElement(
"options");
631 if (!f.open(QIODevice::WriteOnly))
633 LOG(VB_GENERAL, LOG_ERR,
634 QString(
"MythBurn::createConfigFile: "
635 "Failed to open file for writing - %1") .arg(
filename));
640 t << doc.toString(4);
658 query.
prepare(
"SELECT type, title, subtitle, description, startdate, "
659 "starttime, size, filename, hascutlist, duration, "
660 "cutduration, videowidth, videoheight, filecodec, "
661 "videocodec, encoderprofile FROM archiveitems "
674 a->title = query.
value(1).toString();
675 a->subtitle = query.
value(2).toString();
676 a->description = query.
value(3).toString();
677 a->startDate = query.
value(4).toString();
678 a->startTime = query.
value(5).toString();
679 a->size = query.
value(6).toLongLong();
680 a->filename = query.
value(7).toString();
681 a->hasCutlist = (query.
value(8).toInt() == 1);
682 a->useCutlist =
false;
683 a->duration = query.
value(9).toInt();
684 a->cutDuration = query.
value(10).toInt();
685 a->videoWidth = query.
value(11).toInt();
686 a->videoHeight = query.
value(12).toInt();
687 a->fileCodec = query.
value(13).toString();
688 a->videoCodec = query.
value(14).toString();
690 a->editedDetails =
false;
698 if (x->name == profileName)
708 query.
prepare(
"DELETE FROM archiveitems;");
724 query.
prepare(
"INSERT INTO archiveitems (type, title, subtitle, "
725 "description, startdate, starttime, size, filename, "
726 "hascutlist, duration, cutduration, videowidth, "
727 "videoheight, filecodec, videocodec, encoderprofile) "
728 "VALUES(:TYPE, :TITLE, :SUBTITLE, :DESCRIPTION, :STARTDATE, "
729 ":STARTTIME, :SIZE, :FILENAME, :HASCUTLIST, :DURATION, "
730 ":CUTDURATION, :VIDEOWIDTH, :VIDEOHEIGHT, :FILECODEC, "
731 ":VIDEOCODEC, :ENCODERPROFILE);");
734 query.
bindValue(
":SUBTITLE", a->subtitle);
735 query.
bindValue(
":DESCRIPTION", a->description);
736 query.
bindValue(
":STARTDATE", a->startDate);
737 query.
bindValue(
":STARTTIME", a->startTime);
738 query.
bindValue(
":SIZE", (qint64)a->size);
739 query.
bindValue(
":FILENAME", a->filename);
740 query.
bindValue(
":HASCUTLIST", a->hasCutlist);
741 query.
bindValue(
":DURATION", a->duration);
742 query.
bindValue(
":CUTDURATION", a->cutDuration);
743 query.
bindValue(
":VIDEOWIDTH", a->videoWidth);
744 query.
bindValue(
":VIDEOHEIGHT", a->videoHeight);
745 query.
bindValue(
":FILECODEC", a->fileCodec);
746 query.
bindValue(
":VIDEOCODEC", a->videoCodec);
747 query.
bindValue(
":ENCODERPROFILE", a->encoderProfile->name);
767 auto *menuPopup =
new MythDialogBox(tr(
"Menu"), popupStack,
"actionmenu");
769 if (menuPopup->Create())
772 menuPopup->SetReturnEvent(
this,
"action");
774 if (curItem->hasCutlist)
776 if (curItem->useCutlist)
778 menuPopup->AddButton(tr(
"Don't Use Cut List"),
783 menuPopup->AddButton(tr(
"Use Cut List"),
822 if (editor->Create())
838 if (finder->Create())
846 if (ok && item && gridItem)
867 if (profileDialog->Create())
869 popupStack->
AddScreen(profileDialog,
false);
901 QString logDir = tempDir +
"logs";
902 QString configDir = tempDir +
"config";
910 QFile::remove(logDir +
"/mythburncancel.lck");
913 commandline = PYTHON_EXE;
914 commandline +=
" " +
GetShareDir() +
"mytharchive/scripts/mythburn.py";
915 commandline +=
" -j " + configDir +
"/mydata.xml";
916 commandline +=
" -l " + logDir +
"/progress.log";
917 commandline +=
" > " + logDir +
"/mythburn.log 2>&1 &";
926 ShowOkPopup(tr(
"It was not possible to create the DVD. "
927 " An error occured when running the scripts"));
949 if (selector->Create())
962 query.
prepare(
"SELECT title FROM videometadata");
979 if (selector->Create())
986 "*.mpg *.mpeg *.mov *.avi *.nuv");
996 if (selector->Create())
1027 LOG(VB_GENERAL, LOG_ERR,
"Cannot load screen 'profilepopup'");
1035 item->SetData(QVariant::fromValue(x));
1088 setObjectName(
"BurnMenu");
1096 "The last run failed to create a DVD."));
1101 QString title = tr(
"Burn DVD");
1102 QString msg = tr(
"\nPlace a blank DVD in the"
1103 " drive and select an option below.");
1106 "actionmenu",
true);
1108 if (menuPopup->Create())
1111 menuPopup->SetReturnEvent(
this,
"action");
1113 menuPopup->AddButton(tr(
"Burn DVD"));
1114 menuPopup->AddButton(tr(
"Burn DVD Rewritable"));
1115 menuPopup->AddButton(tr(
"Burn DVD Rewritable (Force Erase)"));
1122 if (dce->GetId() ==
"action")
1124 doBurn(dce->GetResult());
1132 if ((mode < 0) || (mode > 2))
1140 QString logDir = tempDir +
"logs";
1141 QString commandline;
1145 QFile::remove(logDir +
"/progress.log");
1149 QFile::remove(logDir +
"/mythburncancel.lck");
1151 QString sArchiveFormat = QString::number(mode);
1152 bool bEraseDVDRW = (mode == 2);
1154 .startsWith(
"Native");
1156 commandline =
"mytharchivehelper --burndvd --mediatype " + sArchiveFormat +
1157 (bEraseDVDRW ?
" --erasedvdrw" :
"") +
1158 (bNativeFormat ?
" --nativeformat" :
"");
1161 commandline +=
" --quiet";
1162 commandline +=
" > " + logDir +
"/progress.log 2>&1 &";
1170 "mytharchivehelper to burn the DVD."));
bool next(void)
Wrap QSqlQuery::next() so we can display the query results.
QSqlQuery wrapper that fetches a DB connection from the connection pool.
MythScreenStack * GetMainStack()
MythUIButton * m_okButton
bool keyPressEvent(QKeyEvent *event) override
Key event handler.
MythUIButton * m_cancelButton
@ kMSDontBlockInputDevs
avoid blocking LIRC & Joystick Menu
void updateArchiveList(void)
QList< EncoderProfile * > m_profileList
MythUIText * m_currentsizeErrorText
MythUIText * m_minsizeText
void handlePrevPage(void)
ArchiveItem * m_archiveItem
MythUIButton * m_prevButton
MythUIText * m_oldSizeText
void saveConfiguration(void)
MythUIButton * m_addrecordingButton
MythScreenType * m_destinationScreen
void toggleUseCutlist(void)
QVariant value(int i) const
bool exec(void)
Wrap QSqlQuery::exec() so we can display SQL.
#define LOG(_MASK_, _LEVEL_, _QSTRING_)
Screen in which all other widgets are contained and rendered.
EncoderProfile * getProfileFromName(const QString &profileName)
void itemClicked(MythUIButtonListItem *item)
uint myth_system(const QString &command, uint flags, std::chrono::seconds timeout)
QString getTempDirectory(bool showError)
MythUIText * m_currentsizeText
QList< EncoderProfile * > m_profileList
static QString loadFile(const QString &filename)
MythUIType * GetFocusWidget(void) const
void showWarningDialog(const QString &msg)
MythUIButton * m_nextButton
void editorClosed(bool ok, ArchiveItem *item)
bool MythRemoveDirectory(QDir &aDir)
void ShowMenu(void) override
ArchiveDestination m_archiveDestination
bool TranslateKeyPress(const QString &Context, QKeyEvent *Event, QStringList &Actions, bool AllowJumps=true)
Get a list of actions for a keypress in the given context.
bool SetFocusWidget(MythUIType *widget=nullptr)
bool getFileDetails(ArchiveItem *a)
@ GENERIC_EXIT_OK
Exited with no error.
Basic menu dialog, message and a list of options.
static MSqlQueryInfo InitCon(ConnectionReuse _reuse=kNormalConnection)
Only use this in combination with MSqlQuery constructor.
static void DBError(const QString &where, const MSqlQuery &query)
void haveResult(int profile)
QString GetShareDir(void)
void BuildFocusList(void)
MythUIButton * m_addvideoButton
void profileChanged(MythUIButtonListItem *item)
MythUIButton * m_addfileButton
MythUIButtonList * m_archiveButtonList
MythBurn(MythScreenStack *parent, MythScreenType *destinationScreen, MythScreenType *themeScreen, const ArchiveDestination &archiveDestination, const QString &name)
bool Create(void) override
MythCoreContext * gCoreContext
This global variable contains the MythCoreContext instance for the app.
static bool Assign(ContainerType *container, UIType *&item, const QString &name, bool *err=nullptr)
static bool isArchiveItemValid(const QString &type, const QString &filename)
QList< ArchiveItem * > m_archiveList
@ GENERIC_EXIT_RUNNING
Process is running.
EncoderProfile * encoderProfile
MBASE_PUBLIC QString formatKBytes(int64_t sizeKB, int prec=1)
@ kMSRunBackground
run child in the background
void loadConfiguration(void)
MythUIButtonList * m_profileBtnList
MythUIText * m_captionText
bool keyPressEvent(QKeyEvent *event) override
Key event handler.
MythUIProgressBar * m_sizeBar
void selectorClosed(bool ok)
static bool LoadWindowFromXML(const QString &xmlfile, const QString &windowname, MythUIType *parent)
MythUIText * m_newSizeText
MythUIText * m_nofilesText
void editThumbnails(void)
void bindValue(const QString &placeholder, const QVariant &val)
Add a single binding.
Event dispatched from MythUI modal dialogs to a listening class containing a result of some form.
void handleNextPage(void)
virtual void SetText(const QString &text)
void loadEncoderProfiles(void)
MythUIText * m_descriptionText
MythMainWindow * GetMythMainWindow(void)
void handleAddVideo(void)
void profileChanged(int profileNo)
void createConfigFile(const QString &filename)
void recalcItemSize(ArchiveItem *item)
bool logPropagateQuiet(void)
Check if we are propagating a "--quiet".
MythScreenStack * GetStack(const QString &Stackname)
void handleAddRecording(void)
MythUIText * m_maxsizeText
@ kMSDontDisableDrawing
avoid disabling UI drawing
void SaveSetting(const QString &key, int newValue)
QString getBaseName(const QString &filename)
MythScreenType * m_themeScreen
EncoderProfile * getDefaultProfile(ArchiveItem *item)
virtual void AddScreen(MythScreenType *screen, bool allowFade=true)
MythConfirmationDialog * ShowOkPopup(const QString &message, bool showCancel)
Non-blocking version of MythPopupBox::showOkPopup()
QString GetSetting(const QString &key, const QString &defaultval="")
bool prepare(const QString &query)
QSqlQuery::prepare() is not thread safe in Qt <= 3.3.2.