Go to the documentation of this file.
11 #include <QDomDocument>
12 #include <QApplication>
14 #include <QTextStream>
32 #include <mythconfig.h>
49 m_destinationScreen(destinationScreen),
50 m_themeScreen(themeScreen),
51 m_archiveDestination(archiveDestination)
57 LOG(VB_GENERAL, LOG_ERR,
"MythBurn: Failed to clear thumb directory");
97 LOG(VB_GENERAL, LOG_ERR,
"Cannot load screen 'mythburn'");
134 for (
int i = 0; i < actions.size() && !handled; i++)
136 QString
action = actions[i];
156 else if (
action ==
"DOWN")
168 else if (
action ==
"DELETE")
172 else if (
action ==
"INFO")
176 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))
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();
387 QString message = tr(
"Retrieving File Information. Please Wait...");
391 auto *busyPopup =
new
394 if (busyPopup->Create())
402 QCoreApplication::processEvents();
414 QCoreApplication::processEvents();
416 if (a->duration == 0)
419 LOG(VB_GENERAL, LOG_ERR,
420 QString(
"MythBurn: failed to get file details for: %1").
arg(a->filename));
425 if (a->encoderProfile ==
nullptr)
431 item->SetData(QVariant::fromValue(a));
432 item->SetText(a->subtitle,
"subtitle");
433 item->SetText(a->startDate +
" " + a->startTime,
"date");
434 item->SetText(
formatSize(a->newsize / 1024, 2),
"size");
439 item->SetText(tr(
"Using Cut List"),
"cutlist");
440 item->DisplayState(
"using",
"cutliststatus");
444 item->SetText(tr(
"Not Using Cut List"),
"cutlist");
445 item->DisplayState(
"notusing",
"cutliststatus");
450 item->SetText(tr(
"No Cut List"),
"cutlist");
451 item->DisplayState(
"none",
"cutliststatus");
453 item->SetText(tr(
"Encoder: ") + a->encoderProfile->name,
"profile");
470 if (
type ==
"Recording")
475 query.
prepare(
"SELECT title FROM recorded WHERE basename = :FILENAME");
479 LOG(VB_GENERAL, LOG_ERR,
480 QString(
"MythArchive: Recording not found (%1)")
483 else if (
type ==
"Video")
487 " WHERE filename = :FILENAME");
491 LOG(VB_GENERAL, LOG_ERR,
492 QString(
"MythArchive: Video not found (%1)").
arg(
filename));
494 else if (
type ==
"File")
498 LOG(VB_GENERAL, LOG_ERR,
499 QString(
"MythArchive: File not found (%1)").
arg(
filename));
502 LOG(VB_GENERAL, LOG_NOTICE,
"MythArchive: Archive item removed from list");
515 if (item->
videoCodec.toLower() ==
"mpeg2video (main)")
546 QString defaultProfile =
550 if (x->name == defaultProfile)
559 QDomDocument
doc(
"mythburn");
561 QDomElement
root =
doc.createElement(
"mythburn");
564 QDomElement job =
doc.createElement(
"job");
565 job.setAttribute(
"theme",
m_theme);
566 root.appendChild(job);
568 QDomElement media =
doc.createElement(
"media");
569 job.appendChild(media);
582 QDomElement
file =
doc.createElement(
"file");
583 file.setAttribute(
"type", a->type.toLower() );
584 file.setAttribute(
"usecutlist",
static_cast<int>(a->useCutlist));
585 file.setAttribute(
"filename", a->filename);
586 file.setAttribute(
"encodingprofile", a->encoderProfile->name);
587 if (a->editedDetails)
589 QDomElement details =
doc.createElement(
"details");
590 file.appendChild(details);
591 details.setAttribute(
"title", a->title);
592 details.setAttribute(
"subtitle", a->subtitle);
593 details.setAttribute(
"startdate", a->startDate);
594 details.setAttribute(
"starttime", a->startTime);
595 QDomText desc =
doc.createTextNode(a->description);
596 details.appendChild(desc);
599 if (!a->thumbList.empty())
601 QDomElement thumbs =
doc.createElement(
"thumbimages");
602 file.appendChild(thumbs);
604 for (
auto *thumbImage : qAsConst(a->thumbList))
606 QDomElement thumb =
doc.createElement(
"thumb");
607 thumbs.appendChild(thumb);
608 thumb.setAttribute(
"caption", thumbImage->caption);
609 thumb.setAttribute(
"filename", thumbImage->filename);
610 thumb.setAttribute(
"frame", (
int) thumbImage->frame);
614 media.appendChild(
file);
618 QDomElement
options =
doc.createElement(
"options");
629 if (!
f.open(QIODevice::WriteOnly))
631 LOG(VB_GENERAL, LOG_ERR,
632 QString(
"MythBurn::createConfigFile: "
633 "Failed to open file for writing - %1") .
arg(
filename));
638 t <<
doc.toString(4);
656 query.
prepare(
"SELECT type, title, subtitle, description, startdate, "
657 "starttime, size, filename, hascutlist, duration, "
658 "cutduration, videowidth, videoheight, filecodec, "
659 "videocodec, encoderprofile FROM archiveitems "
679 a->hasCutlist = (
query.
value(8).toInt() == 1);
680 a->useCutlist =
false;
688 a->editedDetails =
false;
696 if (x->name == profileName)
722 query.
prepare(
"INSERT INTO archiveitems (type, title, subtitle, "
723 "description, startdate, starttime, size, filename, "
724 "hascutlist, duration, cutduration, videowidth, "
725 "videoheight, filecodec, videocodec, encoderprofile) "
726 "VALUES(:TYPE, :TITLE, :SUBTITLE, :DESCRIPTION, :STARTDATE, "
727 ":STARTTIME, :SIZE, :FILENAME, :HASCUTLIST, :DURATION, "
728 ":CUTDURATION, :VIDEOWIDTH, :VIDEOHEIGHT, :FILECODEC, "
729 ":VIDEOCODEC, :ENCODERPROFILE);");
765 auto *menuPopup =
new MythDialogBox(tr(
"Menu"), popupStack,
"actionmenu");
767 if (menuPopup->Create())
770 menuPopup->SetReturnEvent(
this,
"action");
772 if (curItem->hasCutlist)
774 if (curItem->useCutlist)
776 menuPopup->AddButton(tr(
"Don't Use Cut List"),
781 menuPopup->AddButton(tr(
"Use Cut List"),
820 if (editor->Create())
836 if (finder->Create())
844 if (ok && item && gridItem)
865 if (profileDialog->Create())
867 popupStack->
AddScreen(profileDialog,
false);
899 QString logDir = tempDir +
"logs";
900 QString configDir = tempDir +
"config";
907 if (QFile::exists(logDir +
"/mythburncancel.lck"))
908 QFile::remove(logDir +
"/mythburncancel.lck");
911 commandline = PYTHON_EXE;
912 commandline +=
" " +
GetShareDir() +
"mytharchive/scripts/mythburn.py";
913 commandline +=
" -j " + configDir +
"/mydata.xml";
914 commandline +=
" -l " + logDir +
"/progress.log";
915 commandline +=
" > " + logDir +
"/mythburn.log 2>&1 &";
924 ShowOkPopup(tr(
"It was not possible to create the DVD. "
925 " An error occured when running the scripts"));
947 if (selector->Create())
977 if (selector->Create())
984 "*.mpg *.mpeg *.mov *.avi *.nuv");
994 if (selector->Create())
1025 LOG(VB_GENERAL, LOG_ERR,
"Cannot load screen 'profilepopup'");
1033 item->SetData(QVariant::fromValue(x));
1086 setObjectName(
"BurnMenu");
1094 "The last run failed to create a DVD."));
1099 QString
title = tr(
"Burn DVD");
1100 QString msg = tr(
"\nPlace a blank DVD in the"
1101 " drive and select an option below.");
1104 "actionmenu",
true);
1106 if (menuPopup->Create())
1109 menuPopup->SetReturnEvent(
this,
"action");
1111 menuPopup->AddButton(tr(
"Burn DVD"));
1112 menuPopup->AddButton(tr(
"Burn DVD Rewritable"));
1113 menuPopup->AddButton(tr(
"Burn DVD Rewritable (Force Erase)"));
1120 if (dce->GetId() ==
"action")
1122 doBurn(dce->GetResult());
1130 if ((mode < 0) || (mode > 2))
1138 QString logDir = tempDir +
"logs";
1139 QString commandline;
1142 if (QFile::exists(logDir +
"/progress.log"))
1143 QFile::remove(logDir +
"/progress.log");
1146 if (QFile::exists(logDir +
"/mythburncancel.lck"))
1147 QFile::remove(logDir +
"/mythburncancel.lck");
1149 QString sArchiveFormat = QString::number(mode);
1150 bool bEraseDVDRW = (mode == 2);
1152 .startsWith(
"Native");
1154 commandline =
"mytharchivehelper --burndvd --mediatype " + sArchiveFormat +
1155 (bEraseDVDRW ?
" --erasedvdrw" :
"") +
1156 (bNativeFormat ?
" --nativeformat" :
"");
1159 commandline +=
" --quiet";
1160 commandline +=
" > " + logDir +
"/progress.log 2>&1 &";
1168 "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
uint myth_system(const QString &command, uint flags, uint timeout)
#define GENERIC_EXIT_OK
Exited with no error.
bool keyPressEvent(QKeyEvent *event) override
Key event handler.
MythUIButton * m_cancelButton
@ kMSDontBlockInputDevs
avoid blocking LIRC & Joystick Menu
void updateArchiveList(void)
QList< EncoderProfile * > m_profileList
QDomDocument doc("MYTHARCHIVEITEM")
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
arg(title).arg(filename).arg(doDelete))
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)
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
@ 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)
static QString formatSize(int64_t sizeKB, int prec)
#define GENERIC_EXIT_RUNNING
Process is running.
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)
MSqlQuery query(MSqlQuery::InitCon())
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.