Changeset View
Changeset View
Standalone View
Standalone View
src/widgets/logwidget.cpp
Show All 32 Lines | 31 | { | |||
---|---|---|---|---|---|
33 | auto *page = new QWidget; | 33 | auto *page = new QWidget; | ||
34 | textLog = new QPlainTextEdit; | 34 | textLog = new QPlainTextEdit; | ||
35 | textLog->setReadOnly(true); | 35 | textLog->setReadOnly(true); | ||
36 | textLog->setMaximumBlockCount(1000); | 36 | textLog->setMaximumBlockCount(1000); | ||
37 | auto pageLayout = new QVBoxLayout; | 37 | auto pageLayout = new QVBoxLayout; | ||
38 | pageLayout->addWidget(textLog); | 38 | pageLayout->addWidget(textLog); | ||
39 | page->setLayout(pageLayout); | 39 | page->setLayout(pageLayout); | ||
40 | 40 | | |||
41 | QStackedWidget *mainStack = new QStackedWidget; | 41 | auto mainStack = new QStackedWidget; | ||
patrickelectric: (this) ? | |||||
42 | mainStack->insertWidget(0, page); | 42 | mainStack->insertWidget(0, page); | ||
43 | 43 | | |||
44 | page = new QWidget; | 44 | page = new QWidget; | ||
45 | auto textbox = new QTextEdit; | 45 | auto textbox = new QTextEdit; | ||
46 | textbox->setReadOnly(true); | 46 | textbox->setReadOnly(true); | ||
47 | textbox->setHtml(tr("\ | 47 | textbox->setHtml(tr("\ | ||
48 | <h4>Special Log Entries</h4> \ | 48 | <h4>Special Log Entries</h4> \ | ||
49 | <p><strong>Failed to open device in read/write mode.</strong></p> \ | 49 | <p><strong>Failed to open device in read/write mode.</strong></p> \ | ||
▲ Show 20 Lines • Show All 62 Lines • ▼ Show 20 Line(s) | 109 | { | |||
112 | QRegExp _return(QChar::fromLatin1('\r')); | 112 | QRegExp _return(QChar::fromLatin1('\r')); | ||
113 | msg.replace(_newLine, QStringLiteral("\\n")); | 113 | msg.replace(_newLine, QStringLiteral("\\n")); | ||
114 | msg.replace(_return, QStringLiteral("\\r")); | 114 | msg.replace(_return, QStringLiteral("\\r")); | ||
115 | QString message(QStringLiteral("[%1]> %2").arg(getTime(), msg)); | 115 | QString message(QStringLiteral("[%1]> %2").arg(getTime(), msg)); | ||
116 | textLog->appendPlainText(message); | 116 | textLog->appendPlainText(message); | ||
117 | writeTempFile(message); | 117 | writeTempFile(message); | ||
118 | } | 118 | } | ||
119 | 119 | | |||
120 | void LogWidget::writeTempFile(QString text) | 120 | void LogWidget::writeTempFile(const QString &text) | ||
121 | { | 121 | { | ||
122 | //Add text to our unsynced string list when that hits 100 sync to the temp file. | 122 | //Add text to our unsynced string list when that hits 100 sync to the temp file. | ||
123 | unsyncedStrings.append(text); | 123 | unsyncedStrings.append(text); | ||
124 | if (unsyncedStrings.count() > 100) { | 124 | if (unsyncedStrings.count() > 100) { | ||
125 | flushTemp(); | 125 | flushTemp(); | ||
126 | } | 126 | } | ||
127 | } | 127 | } | ||
128 | 128 | | |||
Show All 33 Lines |
(this) ?