Go to the documentation of this file.
7 #include <QCoreApplication>
10 #include <QTextStream>
35 if (QFile::exists(logDir +
"/progress.log"))
36 progressLog = logDir +
"/progress.log";
38 if (QFile::exists(logDir +
"/mythburn.log"))
39 fullLog = logDir +
"/mythburn.log";
42 if ((!progressLog.isEmpty()) && (!fullLog.isEmpty()))
46 if (progressLog.isEmpty() && fullLog.isEmpty())
53 logFiles =
d.entryList(filters, QDir::Files | QDir::Readable, QDir::Time);
55 if (!logFiles.isEmpty())
58 progressLog = logDir +
'/' + logFiles[0];
67 if ((!progressLog.isEmpty()) || (!fullLog.isEmpty()))
70 viewer->setFilenames(progressLog, fullLog);
76 "Cannot find any logs to show!"));
102 LOG(VB_GENERAL, LOG_ERR,
"Cannot load screen 'logviewer'");
139 for (
int i = 0; i < actions.size() && !handled; i++)
141 QString
action = actions[i];
180 QFile lockFile(tempDir +
"/logs/mythburncancel.lck");
182 if (!lockFile.open(QIODevice::WriteOnly | QIODevice::Truncate))
183 LOG(VB_GENERAL, LOG_ERR,
184 "LogViewer: Failed to create mythburncancel.lck file");
186 lockFile.write(
"Cancel\n\r");
189 ShowOkPopup(tr(
"Background creation has been asked to stop.\n"
190 "This may take a few minutes."));
202 bool bUpdateCurrent =
206 for (
const auto & label : qAsConst(list))
213 bool bRunning = (
getSetting(
"MythArchiveLastRunStatus") ==
"Running");
237 query.
prepare(
"SELECT data FROM settings WHERE value = :VALUE "
238 "AND hostname = :HOSTNAME ;");
244 return query.
value(0).toString();
249 LOG(VB_GENERAL, LOG_ERR,
250 QString(
"Database not open while trying to load setting: %1")
259 bool strip = !(
filename.endsWith(
"progress.log") ||
filename.endsWith(
"mythburn.log"));
268 if (
file.open( QIODevice::ReadOnly ))
271 QTextStream stream(&
file);
274 while ( !stream.atEnd() && startline > 0)
281 while ( !stream.atEnd() )
283 s = stream.readLine();
289 int pos = s.indexOf(
" - ");
328 auto *menuPopup =
new MythDialogBox(tr(
"Menu"), popupStack,
"actionmenu");
330 if (menuPopup->Create())
333 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)
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_)
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.
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 keyPressEvent(QKeyEvent *event) override
Key event handler.
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.