Changeset View
Changeset View
Standalone View
Standalone View
src/widgets/logwidget.cpp
Show All 24 Lines | |||||
25 | #include <QToolButton> | 25 | #include <QToolButton> | ||
26 | #include <QVBoxLayout> | 26 | #include <QVBoxLayout> | ||
27 | 27 | | |||
28 | LogWidget::LogWidget(QTemporaryFile *tempFile, QWidget *parent) : | 28 | LogWidget::LogWidget(QTemporaryFile *tempFile, QWidget *parent) : | ||
29 | QWidget(parent), | 29 | QWidget(parent), | ||
30 | logFile(tempFile) | 30 | logFile(tempFile) | ||
31 | { | 31 | { | ||
32 | QSize iconSize = QSize(fontMetrics().height(), fontMetrics().height()); | 32 | QSize iconSize = QSize(fontMetrics().height(), fontMetrics().height()); | ||
33 | auto *page = new QWidget; | 33 | auto page = new QWidget(this); | ||
34 | textLog = new QPlainTextEdit; | 34 | textLog = new QPlainTextEdit(this); | ||
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(this); | ||
patrickelectric: (this) ? | |||||
42 | mainStack->insertWidget(0, page); | 42 | mainStack->insertWidget(0, page); | ||
43 | 43 | | |||
44 | page = new QWidget; | 44 | page = new QWidget(this); | ||
45 | auto textbox = new QTextEdit; | 45 | auto textbox = new QTextEdit(this); | ||
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> \ | ||
50 | <p> The Device was not able to be opened.</p> \ | 50 | <p> The Device was not able to be opened.</p> \ | ||
51 | <p> Check the device is not opened by another program.</p> \ | 51 | <p> Check the device is not opened by another program.</p> \ | ||
52 | <p> Check you have the correct permissions to open the device.</p> \ | 52 | <p> Check you have the correct permissions to open the device.</p> \ | ||
53 | <p><strong>No plugin found for <Detected Firmware></strong></p> \ | 53 | <p><strong>No plugin found for <Detected Firmware></strong></p> \ | ||
54 | <p> Firmware plugins are missing or your firmware is not currently supported.</p> \ | 54 | <p> Firmware plugins are missing or your firmware is not currently supported.</p> \ | ||
55 | <p> Manually select the Marlin or Repetier plugin.</p> \ | 55 | <p> Manually select the Marlin or Repetier plugin.</p> \ | ||
56 | <p> If your firmware does not have a plugin please let us know.</p> \ | 56 | <p> If your firmware does not have a plugin please let us know.</p> \ | ||
57 | <p><strong>Lots of “Waiting for firmware detect”</strong></p> \ | 57 | <p><strong>Lots of “Waiting for firmware detect”</strong></p> \ | ||
58 | <p> Unable to send the firmware detect waiting for printer to restart</p> \ | 58 | <p> Unable to send the firmware detect waiting for printer to restart</p> \ | ||
59 | <p> Push the restart button on your printer or turn it on and off. </p> \ | 59 | <p> Push the restart button on your printer or turn it on and off. </p> \ | ||
60 | <p> Select a firmware plugin in place of auto detect.</p>")); | 60 | <p> Select a firmware plugin in place of auto detect.</p>")); | ||
61 | pageLayout = new QVBoxLayout; | 61 | pageLayout = new QVBoxLayout; | ||
62 | pageLayout->addWidget(textbox); | 62 | pageLayout->addWidget(textbox); | ||
63 | page->setLayout(pageLayout); | 63 | page->setLayout(pageLayout); | ||
64 | mainStack->insertWidget(1, page); | 64 | mainStack->insertWidget(1, page); | ||
65 | 65 | | |||
66 | auto saveButton = new QPushButton(QIcon::fromTheme(QStringLiteral("document-save"), style()->standardIcon(QStyle::SP_DialogSaveButton)), tr("Save Session Log")); | 66 | auto saveButton = new QPushButton(QIcon::fromTheme(QStringLiteral("document-save"), style()->standardIcon(QStyle::SP_DialogSaveButton)), tr("Save Session Log"), this); | ||
67 | saveButton->setIconSize(iconSize); | 67 | saveButton->setIconSize(iconSize); | ||
68 | connect(saveButton, &QPushButton::clicked, this, &LogWidget::savePressed); | 68 | connect(saveButton, &QPushButton::clicked, this, &LogWidget::savePressed); | ||
69 | 69 | | |||
70 | auto helpButton = new QToolButton(); | 70 | auto helpButton = new QToolButton(this); | ||
71 | helpButton->setCheckable(true); | 71 | helpButton->setCheckable(true); | ||
72 | helpButton->setChecked(false); | 72 | helpButton->setChecked(false); | ||
73 | helpButton->setIconSize(iconSize); | 73 | helpButton->setIconSize(iconSize); | ||
74 | helpButton->setIcon(QIcon::fromTheme(QStringLiteral("help-about"), style()->standardIcon(QStyle::SP_DialogHelpButton))); | 74 | helpButton->setIcon(QIcon::fromTheme(QStringLiteral("help-about"), style()->standardIcon(QStyle::SP_DialogHelpButton))); | ||
75 | connect(helpButton, &QToolButton::clicked, this, [mainStack](bool checked) { | 75 | connect(helpButton, &QToolButton::clicked, this, [mainStack](bool checked) { | ||
76 | mainStack->setCurrentIndex(checked); | 76 | mainStack->setCurrentIndex(checked); | ||
77 | }); | 77 | }); | ||
78 | 78 | | |||
Show All 33 Lines | 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) ?