Go to the documentation of this file.
8 #include <QApplication>
10 #include <QDomDocument>
12 #include <QTextStream>
15 #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 QString
action = actions[i];
155 else if (
action ==
"DOWN")
167 else if (
action ==
"DELETE")
171 else if (
action ==
"INFO")
175 else if (
action ==
"TOGGLECUT")
195 uint usedSpace = size / 1024 / 1024;
208 tmpSize = QString(
"%1 Mb").arg(usedSpace);
230 item->description =
"";
231 item->bitrate = 0.0F;
237 "/MythArchive/ffmpeg_dvd_" +
239 .toLower() ==
"ntsc") ?
"ntsc" :
"pal") +
".xml";
245 "mytharchive/encoder_profiles/ffmpeg_dvd_" +
247 .toLower() ==
"ntsc") ?
"ntsc" :
"pal") +
".xml";
250 LOG(VB_GENERAL, LOG_NOTICE,
251 "MythArchive: Loading encoding profiles from " +
filename);
253 QDomDocument doc(
"mydocument");
255 if (!
file.open(QIODevice::ReadOnly))
258 if (!doc.setContent( &
file ))
265 QDomElement docElem = doc.documentElement();
266 QDomNodeList profileNodeList = doc.elementsByTagName(
"profile");
271 for (
int x = 0; x < profileNodeList.count(); x++)
273 QDomNode n = profileNodeList.item(x);
274 QDomElement e = n.toElement();
275 QDomNode n2 = e.firstChild();
278 QDomElement e2 = n2.toElement();
281 if (e2.tagName() ==
"name")
283 if (e2.tagName() ==
"description")
285 if (e2.tagName() ==
"bitrate")
289 n2 = n2.nextSibling();
295 item2->description = desc;
296 item2->bitrate = bitrate.toFloat();
318 item->
SetText(tr(
"Using Cut List"),
"cutlist");
323 item->
SetText(tr(
"Not Using Cut List"),
"cutlist");
329 item->
SetText(tr(
"No Cut List"),
"cutlist");
340 ShowOkPopup(tr(
"You need to add at least one item to archive!"));
368 if (
file.open( QIODevice::ReadOnly ))
370 QTextStream stream(&
file);
372 while ( !stream.atEnd() )
374 res = res + stream.readLine();
386 QString message = tr(
"Retrieving File Information. Please Wait...");
390 auto *busyPopup =
new
393 if (busyPopup->Create())
401 QCoreApplication::processEvents();
413 QCoreApplication::processEvents();
415 if (a->duration == 0)
418 LOG(VB_GENERAL, LOG_ERR,
419 QString(
"MythBurn: failed to get file details for: %1").arg(a->filename));
424 if (a->encoderProfile ==
nullptr)
430 item->SetData(QVariant::fromValue(a));
431 item->SetText(a->subtitle,
"subtitle");
432 item->SetText(a->startDate +
" " + a->startTime,
"date");
438 item->SetText(tr(
"Using Cut List"),
"cutlist");
439 item->DisplayState(
"using",
"cutliststatus");
443 item->SetText(tr(
"Not Using Cut List"),
"cutlist");
444 item->DisplayState(
"notusing",
"cutliststatus");
449 item->SetText(tr(
"No Cut List"),
"cutlist");
450 item->DisplayState(
"none",
"cutliststatus");
452 item->SetText(tr(
"Encoder: ") + a->encoderProfile->name,
"profile");
469 if (
type ==
"Recording")
474 query.
prepare(
"SELECT title FROM recorded WHERE basename = :FILENAME");
478 LOG(VB_GENERAL, LOG_ERR,
479 QString(
"MythArchive: Recording not found (%1)")
482 else if (
type ==
"Video")
485 query.
prepare(
"SELECT title FROM videometadata"
486 " WHERE filename = :FILENAME");
490 LOG(VB_GENERAL, LOG_ERR,
491 QString(
"MythArchive: Video not found (%1)").arg(
filename));
493 else if (
type ==
"File")
497 LOG(VB_GENERAL, LOG_ERR,
498 QString(
"MythArchive: File not found (%1)").arg(
filename));
501 LOG(VB_GENERAL, LOG_NOTICE,
"MythArchive: Archive item removed from list");
514 if (item->
videoCodec.toLower() ==
"mpeg2video (main)")
545 QString defaultProfile =
549 if (x->name == defaultProfile)
558 QDomDocument doc(
"mythburn");
560 QDomElement root = doc.createElement(
"mythburn");
561 doc.appendChild(root);
563 QDomElement job = doc.createElement(
"job");
564 job.setAttribute(
"theme",
m_theme);
565 root.appendChild(job);
567 QDomElement media = doc.createElement(
"media");
568 job.appendChild(media);
581 QDomElement
file = doc.createElement(
"file");
582 file.setAttribute(
"type", a->type.toLower() );
583 file.setAttribute(
"usecutlist",
static_cast<int>(a->useCutlist));
584 file.setAttribute(
"filename", a->filename);
585 file.setAttribute(
"encodingprofile", a->encoderProfile->name);
586 if (a->editedDetails)
588 QDomElement details = doc.createElement(
"details");
589 file.appendChild(details);
590 details.setAttribute(
"title", a->title);
591 details.setAttribute(
"subtitle", a->subtitle);
592 details.setAttribute(
"startdate", a->startDate);
593 details.setAttribute(
"starttime", a->startTime);
594 QDomText desc = doc.createTextNode(a->description);
595 details.appendChild(desc);
598 if (!a->thumbList.empty())
600 QDomElement thumbs = doc.createElement(
"thumbimages");
601 file.appendChild(thumbs);
603 for (
auto *thumbImage : qAsConst(a->thumbList))
605 QDomElement thumb = doc.createElement(
"thumb");
606 thumbs.appendChild(thumb);
607 thumb.setAttribute(
"caption", thumbImage->caption);
608 thumb.setAttribute(
"filename", thumbImage->filename);
609 thumb.setAttribute(
"frame", (
int) thumbImage->frame);
613 media.appendChild(
file);
617 QDomElement
options = doc.createElement(
"options");
628 if (!f.open(QIODevice::WriteOnly))
630 LOG(VB_GENERAL, LOG_ERR,
631 QString(
"MythBurn::createConfigFile: "
632 "Failed to open file for writing - %1") .arg(
filename));
637 t << doc.toString(4);
655 query.
prepare(
"SELECT type, title, subtitle, description, startdate, "
656 "starttime, size, filename, hascutlist, duration, "
657 "cutduration, videowidth, videoheight, filecodec, "
658 "videocodec, encoderprofile FROM archiveitems "
671 a->title = query.
value(1).toString();
672 a->subtitle = query.
value(2).toString();
673 a->description = query.
value(3).toString();
674 a->startDate = query.
value(4).toString();
675 a->startTime = query.
value(5).toString();
676 a->size = query.
value(6).toLongLong();
677 a->filename = query.
value(7).toString();
678 a->hasCutlist = (query.
value(8).toInt() == 1);
679 a->useCutlist =
false;
680 a->duration = query.
value(9).toInt();
681 a->cutDuration = query.
value(10).toInt();
682 a->videoWidth = query.
value(11).toInt();
683 a->videoHeight = query.
value(12).toInt();
684 a->fileCodec = query.
value(13).toString();
685 a->videoCodec = query.
value(14).toString();
687 a->editedDetails =
false;
695 if (x->name == profileName)
705 query.
prepare(
"DELETE FROM archiveitems;");
721 query.
prepare(
"INSERT INTO archiveitems (type, title, subtitle, "
722 "description, startdate, starttime, size, filename, "
723 "hascutlist, duration, cutduration, videowidth, "
724 "videoheight, filecodec, videocodec, encoderprofile) "
725 "VALUES(:TYPE, :TITLE, :SUBTITLE, :DESCRIPTION, :STARTDATE, "
726 ":STARTTIME, :SIZE, :FILENAME, :HASCUTLIST, :DURATION, "
727 ":CUTDURATION, :VIDEOWIDTH, :VIDEOHEIGHT, :FILECODEC, "
728 ":VIDEOCODEC, :ENCODERPROFILE);");
731 query.
bindValue(
":SUBTITLE", a->subtitle);
732 query.
bindValue(
":DESCRIPTION", a->description);
733 query.
bindValue(
":STARTDATE", a->startDate);
734 query.
bindValue(
":STARTTIME", a->startTime);
735 query.
bindValue(
":SIZE", (qint64)a->size);
736 query.
bindValue(
":FILENAME", a->filename);
737 query.
bindValue(
":HASCUTLIST", a->hasCutlist);
738 query.
bindValue(
":DURATION", a->duration);
739 query.
bindValue(
":CUTDURATION", a->cutDuration);
740 query.
bindValue(
":VIDEOWIDTH", a->videoWidth);
741 query.
bindValue(
":VIDEOHEIGHT", a->videoHeight);
742 query.
bindValue(
":FILECODEC", a->fileCodec);
743 query.
bindValue(
":VIDEOCODEC", a->videoCodec);
744 query.
bindValue(
":ENCODERPROFILE", a->encoderProfile->name);
764 auto *menuPopup =
new MythDialogBox(tr(
"Menu"), popupStack,
"actionmenu");
766 if (menuPopup->Create())
769 menuPopup->SetReturnEvent(
this,
"action");
771 if (curItem->hasCutlist)
773 if (curItem->useCutlist)
775 menuPopup->AddButton(tr(
"Don't Use Cut List"),
780 menuPopup->AddButton(tr(
"Use Cut List"),
819 if (editor->Create())
835 if (finder->Create())
843 if (ok && item && gridItem)
864 if (profileDialog->Create())
866 popupStack->
AddScreen(profileDialog,
false);
898 QString logDir = tempDir +
"logs";
899 QString configDir = tempDir +
"config";
906 if (QFile::exists(logDir +
"/mythburncancel.lck"))
907 QFile::remove(logDir +
"/mythburncancel.lck");
910 commandline = PYTHON_EXE;
911 commandline +=
" " +
GetShareDir() +
"mytharchive/scripts/mythburn.py";
912 commandline +=
" -j " + configDir +
"/mydata.xml";
913 commandline +=
" -l " + logDir +
"/progress.log";
914 commandline +=
" > " + logDir +
"/mythburn.log 2>&1 &";
923 ShowOkPopup(tr(
"It was not possible to create the DVD. "
924 " An error occured when running the scripts"));
946 if (selector->Create())
959 query.
prepare(
"SELECT title FROM videometadata");
976 if (selector->Create())
983 "*.mpg *.mpeg *.mov *.avi *.nuv");
993 if (selector->Create())
1024 LOG(VB_GENERAL, LOG_ERR,
"Cannot load screen 'profilepopup'");
1032 item->SetData(QVariant::fromValue(x));
1085 setObjectName(
"BurnMenu");
1093 "The last run failed to create a DVD."));
1098 QString title = tr(
"Burn DVD");
1099 QString msg = tr(
"\nPlace a blank DVD in the"
1100 " drive and select an option below.");
1103 "actionmenu",
true);
1105 if (menuPopup->Create())
1108 menuPopup->SetReturnEvent(
this,
"action");
1110 menuPopup->AddButton(tr(
"Burn DVD"));
1111 menuPopup->AddButton(tr(
"Burn DVD Rewritable"));
1112 menuPopup->AddButton(tr(
"Burn DVD Rewritable (Force Erase)"));
1119 if (dce->GetId() ==
"action")
1121 doBurn(dce->GetResult());
1129 if ((mode < 0) || (mode > 2))
1137 QString logDir = tempDir +
"logs";
1138 QString commandline;
1141 if (QFile::exists(logDir +
"/progress.log"))
1142 QFile::remove(logDir +
"/progress.log");
1145 if (QFile::exists(logDir +
"/mythburncancel.lck"))
1146 QFile::remove(logDir +
"/mythburncancel.lck");
1148 QString sArchiveFormat = QString::number(mode);
1149 bool bEraseDVDRW = (mode == 2);
1151 .startsWith(
"Native");
1153 commandline =
"mytharchivehelper --burndvd --mediatype " + sArchiveFormat +
1154 (bEraseDVDRW ?
" --erasedvdrw" :
"") +
1155 (bNativeFormat ?
" --nativeformat" :
"");
1158 commandline +=
" --quiet";
1159 commandline +=
" > " + logDir +
"/progress.log 2>&1 &";
1167 "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)
@ GENERIC_EXIT_OK
Exited with no error.
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)
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
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)
@ GENERIC_EXIT_RUNNING
Process is running.
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.