Go to the documentation of this file.
7 #include <QCoreApplication>
10 #include <QTextStream>
36 if (QFile::exists(logDir +
"/progress.log"))
37 progressLog = logDir +
"/progress.log";
39 if (QFile::exists(logDir +
"/mythburn.log"))
40 fullLog = logDir +
"/mythburn.log";
43 if ((!progressLog.isEmpty()) && (!fullLog.isEmpty()))
47 if (progressLog.isEmpty() && fullLog.isEmpty())
54 logFiles =
d.entryList(filters, QDir::Files | QDir::Readable, QDir::Time);
56 if (!logFiles.isEmpty())
59 progressLog = logDir +
'/' + logFiles[0];
68 if ((!progressLog.isEmpty()) || (!fullLog.isEmpty()))
71 viewer->setFilenames(progressLog, fullLog);
77 "Cannot find any logs to show!"));
111 LOG(VB_GENERAL, LOG_ERR,
"Cannot load screen 'logviewer'");
148 for (
int i = 0; i < actions.size() && !handled; i++)
150 QString
action = actions[i];
189 QFile lockFile(tempDir +
"/logs/mythburncancel.lck");
191 if (!lockFile.open(QIODevice::WriteOnly | QIODevice::Truncate))
192 LOG(VB_GENERAL, LOG_ERR,
193 "LogViewer: Failed to create mythburncancel.lck file");
195 lockFile.write(
"Cancel\n\r");
198 ShowOkPopup(tr(
"Background creation has been asked to stop.\n"
199 "This may take a few minutes."));
211 bool bUpdateCurrent =
215 for (
const auto & label : qAsConst(list))
222 bool bRunning = (
getSetting(
"MythArchiveLastRunStatus") ==
"Running");
246 query.
prepare(
"SELECT data FROM settings WHERE value = :VALUE "
247 "AND hostname = :HOSTNAME ;");
253 return query.
value(0).toString();
258 LOG(VB_GENERAL, LOG_ERR,
259 QString(
"Database not open while trying to load setting: %1")
268 bool strip = !(
filename.endsWith(
"progress.log") ||
filename.endsWith(
"mythburn.log"));
277 if (
file.open( QIODevice::ReadOnly ))
280 QTextStream stream(&
file);
283 while ( !stream.atEnd() && startline > 0)
290 while ( !stream.atEnd() )
292 s = stream.readLine();
298 int pos = s.indexOf(
" - ");
337 auto *menuPopup =
new MythDialogBox(tr(
"Menu"), popupStack,
"actionmenu");
339 if (menuPopup->Create())
342 menuPopup->SetReturnEvent(
this,
"action");
void toggleAutoUpdate(void)
bool next(void)
Wrap QSqlQuery::next() so we can display the query results.
~LogViewer(void) override
QSqlQuery wrapper that fetches a DB connection from the connection pool.
MythScreenStack * GetMainStack()
void setFilenames(const QString &progressLog, const QString &fullLog)
static constexpr std::chrono::seconds DEFAULT_UPDATE_TIME
void updateLogItem(MythUIButtonListItem *item)
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.
std::enable_if_t< std::chrono::__is_duration< T >::value, void > SaveDurSetting(const QString &key, T newValue)
QString getTempDirectory(bool showError)
static void cancelClicked(void)
bool Create(void) override
MythUIType * GetFocusWidget(void) const
void showWarningDialog(const QString &msg)
static QString getSetting(const QString &key)
MythUIButton * m_exitButton
MythUIButton * m_updateButton
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)
Basic menu dialog, message and a list of options.
void ShowMenu(void) override
static MSqlQueryInfo InitCon(ConnectionReuse _reuse=kNormalConnection)
Only use this in combination with MSqlQuery constructor.
std::enable_if_t< std::chrono::__is_duration< T >::value, T > GetDurSetting(const QString &key, T defaultval=T::zero())
void BuildFocusList(void)
void Init(void) override
Used after calling Load() to assign data to widgets and other UI initilisation which is prohibited in...
void SetEnabled(bool enable)
MythUIButton * m_cancelButton
bool isConnected(void) const
Only updated once during object creation.
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)
bool GetBoolSetting(const QString &key, bool defaultval=false)
bool keyPressEvent(QKeyEvent *event) override
Key event handler.
LogViewer(MythScreenStack *parent)
static bool LoadWindowFromXML(const QString &xmlfile, const QString &windowname, MythUIType *parent)
void bindValue(const QString &placeholder, const QVariant &val)
Add a single binding.
void showProgressLog(void)
void updateTimerTimeout(void)
virtual void SetText(const QString &text)
MythMainWindow * GetMythMainWindow(void)
MythScreenStack * GetStack(const QString &Stackname)
static bool loadFile(const QString &filename, QStringList &list, int startline)
QString GetHostName(void)
std::chrono::seconds m_updateTime
static const iso6937table * d
void SaveSetting(const QString &key, int newValue)
MythUIButtonList * m_logList
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 keyPressEvent(QKeyEvent *e) override
Key event handler.
bool prepare(const QString &query)
QSqlQuery::prepare() is not thread safe in Qt <= 3.3.2.