diff --git a/gui/logview.cpp b/gui/logview.cpp
index c84b0bec4..817f55b7a 100644
--- a/gui/logview.cpp
+++ b/gui/logview.cpp
@@ -16,7 +16,11 @@
* along with this program. If not, see .
*/
+#include
+#include
+#include
#include
+#include
#include "common.h"
#include "logview.h"
@@ -29,6 +33,7 @@ LogView::LogView(QSettings *programSettings, QWidget *parent)
connect(mUI.mCloseButton, SIGNAL(clicked()), this, SLOT(CloseButtonClicked()));
connect(mUI.mClearButton, SIGNAL(clicked()), this, SLOT(ClearButtonClicked()));
+ connect(mUI.mSaveButton, SIGNAL(clicked()), this, SLOT(SaveButtonClicked()));
resize(mSettings->value(SETTINGS_LOG_VIEW_WIDTH, 400).toInt(),
mSettings->value(SETTINGS_LOG_VIEW_HEIGHT, 300).toInt());
@@ -54,3 +59,22 @@ void LogView::ClearButtonClicked()
{
mUI.mLogEdit->clear();
}
+
+void LogView::SaveButtonClicked()
+{
+ QString fileName = QFileDialog::getSaveFileName(this, tr("Save Log"),
+ "", tr("Text files (*.txt *.log);;All files (*.*)"));
+ if (!fileName.isEmpty())
+ {
+ QFile file(fileName);
+ if (!file.open(QIODevice::WriteOnly | QIODevice::Text))
+ {
+ QMessageBox::warning(this, tr("Cppcheck"),
+ tr("Could not open file for writing: \"%1\"").arg(fileName));
+ return;
+ }
+
+ QTextStream out(&file);
+ out << mUI.mLogEdit->toPlainText();
+ }
+}
diff --git a/gui/logview.h b/gui/logview.h
index 166c2d161..5f36b3540 100644
--- a/gui/logview.h
+++ b/gui/logview.h
@@ -59,6 +59,12 @@ protected slots:
*/
void ClearButtonClicked();
+ /**
+ * @brief Called when save button is clicked.
+ *
+ */
+ void SaveButtonClicked();
+
private:
Ui::LogView mUI;
diff --git a/gui/logview.ui b/gui/logview.ui
index 642e34436..f49cc06e2 100644
--- a/gui/logview.ui
+++ b/gui/logview.ui
@@ -42,6 +42,13 @@
+ -
+
+
+ &Save
+
+
+
-