7#include <QCoreApplication>
38 progressLog = logDir +
"/progress.log";
41 fullLog = logDir +
"/mythburn.log";
44 if ((!progressLog.isEmpty()) && (!fullLog.isEmpty()))
48 if (progressLog.isEmpty() && fullLog.isEmpty())
55 logFiles =
d.entryList(filters, QDir::Files | QDir::Readable, QDir::Time);
57 if (!logFiles.isEmpty())
60 progressLog = logDir +
'/' + logFiles[0];
69 if ((!progressLog.isEmpty()) || (!fullLog.isEmpty()))
72 viewer->setFilenames(progressLog, fullLog);
79 "Cannot find any logs to show!"));
114 LOG(VB_GENERAL, LOG_ERR,
"Cannot load screen 'logviewer'");
151 for (
int i = 0; i < actions.size() && !handled; i++)
153 const QString&
action = actions[i];
192 QFile lockFile(tempDir +
"/logs/mythburncancel.lck");
194 if (!lockFile.open(QIODevice::WriteOnly | QIODevice::Truncate))
195 LOG(VB_GENERAL, LOG_ERR,
196 "LogViewer: Failed to create mythburncancel.lck file");
198 lockFile.write(
"Cancel\n\r");
201 ShowOkPopup(tr(
"Background creation has been asked to stop.\n"
202 "This may take a few minutes."));
214 bool bUpdateCurrent =
218 for (
const auto & label : std::as_const(list))
225 bool bRunning = (
getSetting(
"MythArchiveLastRunStatus") ==
"Running");
249 query.
prepare(
"SELECT data FROM settings WHERE value = :VALUE "
250 "AND hostname = :HOSTNAME ;");
256 return query.
value(0).toString();
261 LOG(VB_GENERAL, LOG_ERR,
262 QString(
"Database not open while trying to load setting: %1")
271 bool strip = !(
filename.endsWith(
"progress.log") ||
filename.endsWith(
"mythburn.log"));
280 if (
file.open( QIODevice::ReadOnly ))
283 QTextStream stream(&
file);
286 while ( !stream.atEnd() && startline > 0)
293 while ( !stream.atEnd() )
295 s = stream.readLine();
301 int pos = s.indexOf(
" - ");
342 auto *menuPopup =
new MythDialogBox(tr(
"Menu"), popupStack,
"actionmenu");
344 if (menuPopup->Create())
347 menuPopup->SetReturnEvent(
this,
"action");
void showWarningDialog(const QString &msg)
QString getTempDirectory(bool showError)
void Init(void) override
Used after calling Load() to assign data to widgets and other UI initilisation which is prohibited in...
void updateTimerTimeout(void)
MythUIButton * m_cancelButton
LogViewer(MythScreenStack *parent)
~LogViewer(void) override
void toggleAutoUpdate(void)
static void cancelClicked(void)
MythUIButton * m_updateButton
MythUIButtonList * m_logList
bool Create(void) override
MythUIButton * m_exitButton
void setFilenames(const QString &progressLog, const QString &fullLog)
static bool loadFile(const QString &filename, QStringList &list, int startline)
void updateLogItem(MythUIButtonListItem *item)
bool keyPressEvent(QKeyEvent *e) override
Key event handler.
void showProgressLog(void)
std::chrono::seconds m_updateTime
void ShowMenu(void) override
static QString getSetting(const QString &key)
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 isConnected(void) const
Only updated once during object creation.
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.
QString GetHostName(void)
void SaveSetting(const QString &key, int newValue)
std::enable_if_t< std::chrono::__is_duration< T >::value, void > SaveDurSetting(const QString &key, T newValue)
QString GetSetting(const QString &key, const QString &defaultval="")
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)
void SetEnabled(bool enable)
static bool LoadWindowFromXML(const QString &xmlfile, const QString &windowname, MythUIType *parent)
static const iso6937table * d
static constexpr std::chrono::seconds DEFAULT_UPDATE_TIME
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()
#define LOG(_MASK_, _LEVEL_, _QSTRING_)
MythMainWindow * GetMythMainWindow(void)
static bool Assign(ContainerType *container, UIType *&item, const QString &name, bool *err=nullptr)
VERBOSE_PREAMBLE Most true