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 QString
action = actions[i];
154 else if (
action ==
"DOWN")
166 else if (
action ==
"DELETE")
170 else if (
action ==
"INFO")
174 else if (
action ==
"TOGGLECUT")
194 uint usedSpace = size / 1024 / 1024;
207 tmpSize = QString(
"%1 Mb").arg(usedSpace);
229 item->description =
"";
230 item->bitrate = 0.0F;
236 "/MythArchive/ffmpeg_dvd_" +
238 .toLower() ==
"ntsc") ?
"ntsc" :
"pal") +
".xml";
244 "mytharchive/encoder_profiles/ffmpeg_dvd_" +
246 .toLower() ==
"ntsc") ?
"ntsc" :
"pal") +
".xml";
249 LOG(VB_GENERAL, LOG_NOTICE,
250 "MythArchive: Loading encoding profiles from " +
filename);
252 QDomDocument doc(
"mydocument");
254 if (!
file.open(QIODevice::ReadOnly))
257 if (!doc.setContent( &
file ))
264 QDomElement docElem = doc.documentElement();
265 QDomNodeList profileNodeList = doc.elementsByTagName(
"profile");
270 for (
int x = 0; x < profileNodeList.count(); x++)
272 QDomNode n = profileNodeList.item(x);
273 QDomElement e = n.toElement();
274 QDomNode n2 = e.firstChild();
277 QDomElement e2 = n2.toElement();
280 if (e2.tagName() ==
"name")
282 if (e2.tagName() ==
"description")
284 if (e2.tagName() ==
"bitrate")
288 n2 = n2.nextSibling();
294 item2->description = desc;
295 item2->bitrate = bitrate.toFloat();
317 item->
SetText(tr(
"Using Cut List"),
"cutlist");
322 item->
SetText(tr(
"Not Using Cut List"),
"cutlist");
328 item->
SetText(tr(
"No Cut List"),
"cutlist");
339 ShowOkPopup(tr(
"You need to add at least one item to archive!"));
367 if (
file.open( QIODevice::ReadOnly ))
369 QTextStream stream(&
file);
371 while ( !stream.atEnd() )
373 res = res + stream.readLine();
385 QString message = tr(
"Retrieving File Information. Please Wait...");
389 auto *busyPopup =
new
392 if (busyPopup->Create())
400 QCoreApplication::processEvents();
412 QCoreApplication::processEvents();
414 if (a->duration == 0)
417 LOG(VB_GENERAL, LOG_ERR,
418 QString(
"MythBurn: failed to get file details for: %1").arg(a->filename));
423 if (a->encoderProfile ==
nullptr)
429 item->SetData(QVariant::fromValue(a));
430 item->SetText(a->subtitle,
"subtitle");
431 item->SetText(a->startDate +
" " + a->startTime,
"date");
437 item->SetText(tr(
"Using Cut List"),
"cutlist");
438 item->DisplayState(
"using",
"cutliststatus");
442 item->SetText(tr(
"Not Using Cut List"),
"cutlist");
443 item->DisplayState(
"notusing",
"cutliststatus");
448 item->SetText(tr(
"No Cut List"),
"cutlist");
449 item->DisplayState(
"none",
"cutliststatus");
451 item->SetText(tr(
"Encoder: ") + a->encoderProfile->name,
"profile");
468 if (
type ==
"Recording")
473 query.
prepare(
"SELECT title FROM recorded WHERE basename = :FILENAME");
477 LOG(VB_GENERAL, LOG_ERR,
478 QString(
"MythArchive: Recording not found (%1)")
481 else if (
type ==
"Video")
484 query.
prepare(
"SELECT title FROM videometadata"
485 " WHERE filename = :FILENAME");
489 LOG(VB_GENERAL, LOG_ERR,
490 QString(
"MythArchive: Video not found (%1)").arg(
filename));
492 else if (
type ==
"File")
496 LOG(VB_GENERAL, LOG_ERR,
497 QString(
"MythArchive: File not found (%1)").arg(
filename));
500 LOG(VB_GENERAL, LOG_NOTICE,
"MythArchive: Archive item removed from list");
513 if (item->
videoCodec.toLower() ==
"mpeg2video (main)")
544 QString defaultProfile =
548 if (x->name == defaultProfile)
557 QDomDocument doc(
"mythburn");
559 QDomElement root = doc.createElement(
"mythburn");
560 doc.appendChild(root);
562 QDomElement job = doc.createElement(
"job");
563 job.setAttribute(
"theme",
m_theme);
564 root.appendChild(job);
566 QDomElement media = doc.createElement(
"media");
567 job.appendChild(media);
580 QDomElement
file = doc.createElement(
"file");
581 file.setAttribute(
"type", a->type.toLower() );
582 file.setAttribute(
"usecutlist",
static_cast<int>(a->useCutlist));
583 file.setAttribute(
"filename", a->filename);
584 file.setAttribute(
"encodingprofile", a->encoderProfile->name);
585 if (a->editedDetails)
587 QDomElement details = doc.createElement(
"details");
588 file.appendChild(details);
589 details.setAttribute(
"title", a->title);
590 details.setAttribute(
"subtitle", a->subtitle);
591 details.setAttribute(
"startdate", a->startDate);
592 details.setAttribute(
"starttime", a->startTime);
593 QDomText desc = doc.createTextNode(a->description);
594 details.appendChild(desc);
597 if (!a->thumbList.empty())
599 QDomElement thumbs = doc.createElement(
"thumbimages");
600 file.appendChild(thumbs);
602 for (
auto *thumbImage : qAsConst(a->thumbList))
604 QDomElement thumb = doc.createElement(
"thumb");
605 thumbs.appendChild(thumb);
606 thumb.setAttribute(
"caption", thumbImage->caption);
607 thumb.setAttribute(
"filename", thumbImage->filename);
608 thumb.setAttribute(
"frame", (
int) thumbImage->frame);
612 media.appendChild(
file);
616 QDomElement
options = doc.createElement(
"options");
627 if (!f.open(QIODevice::WriteOnly))
629 LOG(VB_GENERAL, LOG_ERR,
630 QString(
"MythBurn::createConfigFile: "
631 "Failed to open file for writing - %1") .arg(
filename));
636 t << doc.toString(4);
654 query.
prepare(
"SELECT type, title, subtitle, description, startdate, "
655 "starttime, size, filename, hascutlist, duration, "
656 "cutduration, videowidth, videoheight, filecodec, "
657 "videocodec, encoderprofile FROM archiveitems "
670 a->title = query.
value(1).toString();
671 a->subtitle = query.
value(2).toString();
672 a->description = query.
value(3).toString();
673 a->startDate = query.
value(4).toString();
674 a->startTime = query.
value(5).toString();
675 a->size = query.
value(6).toLongLong();
676 a->filename = query.
value(7).toString();
677 a->hasCutlist = (query.
value(8).toInt() == 1);
678 a->useCutlist =
false;
679 a->duration = query.
value(9).toInt();
680 a->cutDuration = query.
value(10).toInt();
681 a->videoWidth = query.
value(11).toInt();
682 a->videoHeight = query.
value(12).toInt();
683 a->fileCodec = query.
value(13).toString();
684 a->videoCodec = query.
value(14).toString();
686 a->editedDetails =
false;
694 if (x->name == profileName)
704 query.
prepare(
"DELETE FROM archiveitems;");
720 query.
prepare(
"INSERT INTO archiveitems (type, title, subtitle, "
721 "description, startdate, starttime, size, filename, "
722 "hascutlist, duration, cutduration, videowidth, "
723 "videoheight, filecodec, videocodec, encoderprofile) "
724 "VALUES(:TYPE, :TITLE, :SUBTITLE, :DESCRIPTION, :STARTDATE, "
725 ":STARTTIME, :SIZE, :FILENAME, :HASCUTLIST, :DURATION, "
726 ":CUTDURATION, :VIDEOWIDTH, :VIDEOHEIGHT, :FILECODEC, "
727 ":VIDEOCODEC, :ENCODERPROFILE);");
730 query.
bindValue(
":SUBTITLE", a->subtitle);
731 query.
bindValue(
":DESCRIPTION", a->description);
732 query.
bindValue(
":STARTDATE", a->startDate);
733 query.
bindValue(
":STARTTIME", a->startTime);
734 query.
bindValue(
":SIZE", (qint64)a->size);
735 query.
bindValue(
":FILENAME", a->filename);
736 query.
bindValue(
":HASCUTLIST", a->hasCutlist);
737 query.
bindValue(
":DURATION", a->duration);
738 query.
bindValue(
":CUTDURATION", a->cutDuration);
739 query.
bindValue(
":VIDEOWIDTH", a->videoWidth);
740 query.
bindValue(
":VIDEOHEIGHT", a->videoHeight);
741 query.
bindValue(
":FILECODEC", a->fileCodec);
742 query.
bindValue(
":VIDEOCODEC", a->videoCodec);
743 query.
bindValue(
":ENCODERPROFILE", a->encoderProfile->name);
763 auto *menuPopup =
new MythDialogBox(tr(
"Menu"), popupStack,
"actionmenu");
765 if (menuPopup->Create())
768 menuPopup->SetReturnEvent(
this,
"action");
770 if (curItem->hasCutlist)
772 if (curItem->useCutlist)
774 menuPopup->AddButton(tr(
"Don't Use Cut List"),
779 menuPopup->AddButton(tr(
"Use Cut List"),
818 if (editor->Create())
834 if (finder->Create())
842 if (ok && item && gridItem)
863 if (profileDialog->Create())
865 popupStack->
AddScreen(profileDialog,
false);
897 QString logDir = tempDir +
"logs";
898 QString configDir = tempDir +
"config";
905 if (QFile::exists(logDir +
"/mythburncancel.lck"))
906 QFile::remove(logDir +
"/mythburncancel.lck");
909 commandline = PYTHON_EXE;
910 commandline +=
" " +
GetShareDir() +
"mytharchive/scripts/mythburn.py";
911 commandline +=
" -j " + configDir +
"/mydata.xml";
912 commandline +=
" -l " + logDir +
"/progress.log";
913 commandline +=
" > " + logDir +
"/mythburn.log 2>&1 &";
922 ShowOkPopup(tr(
"It was not possible to create the DVD. "
923 " An error occured when running the scripts"));
945 if (selector->Create())
958 query.
prepare(
"SELECT title FROM videometadata");
975 if (selector->Create())
982 "*.mpg *.mpeg *.mov *.avi *.nuv");
992 if (selector->Create())
1023 LOG(VB_GENERAL, LOG_ERR,
"Cannot load screen 'profilepopup'");
1031 item->SetData(QVariant::fromValue(x));
1084 setObjectName(
"BurnMenu");
1092 "The last run failed to create a DVD."));
1097 QString title = tr(
"Burn DVD");
1098 QString msg = tr(
"\nPlace a blank DVD in the"
1099 " drive and select an option below.");
1102 "actionmenu",
true);
1104 if (menuPopup->Create())
1107 menuPopup->SetReturnEvent(
this,
"action");
1109 menuPopup->AddButton(tr(
"Burn DVD"));
1110 menuPopup->AddButton(tr(
"Burn DVD Rewritable"));
1111 menuPopup->AddButton(tr(
"Burn DVD Rewritable (Force Erase)"));
1118 if (dce->GetId() ==
"action")
1120 doBurn(dce->GetResult());
1128 if ((mode < 0) || (mode > 2))
1136 QString logDir = tempDir +
"logs";
1137 QString commandline;
1140 if (QFile::exists(logDir +
"/progress.log"))
1141 QFile::remove(logDir +
"/progress.log");
1144 if (QFile::exists(logDir +
"/mythburncancel.lck"))
1145 QFile::remove(logDir +
"/mythburncancel.lck");
1147 QString sArchiveFormat = QString::number(mode);
1148 bool bEraseDVDRW = (mode == 2);
1150 .startsWith(
"Native");
1152 commandline =
"mytharchivehelper --burndvd --mediatype " + sArchiveFormat +
1153 (bEraseDVDRW ?
" --erasedvdrw" :
"") +
1154 (bNativeFormat ?
" --nativeformat" :
"");
1157 commandline +=
" --quiet";
1158 commandline +=
" > " + logDir +
"/progress.log 2>&1 &";
1166 "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.