Fixed #2047 (GUI: save log to file)
This commit is contained in:
parent
05ebf120c3
commit
500c0a19c3
|
@ -16,7 +16,11 @@
|
||||||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
|
#include <QFile>
|
||||||
|
#include <QFileDialog>
|
||||||
|
#include <QMessageBox>
|
||||||
#include <QSettings>
|
#include <QSettings>
|
||||||
|
#include <QTextStream>
|
||||||
#include "common.h"
|
#include "common.h"
|
||||||
#include "logview.h"
|
#include "logview.h"
|
||||||
|
|
||||||
|
@ -29,6 +33,7 @@ LogView::LogView(QSettings *programSettings, QWidget *parent)
|
||||||
|
|
||||||
connect(mUI.mCloseButton, SIGNAL(clicked()), this, SLOT(CloseButtonClicked()));
|
connect(mUI.mCloseButton, SIGNAL(clicked()), this, SLOT(CloseButtonClicked()));
|
||||||
connect(mUI.mClearButton, SIGNAL(clicked()), this, SLOT(ClearButtonClicked()));
|
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(),
|
resize(mSettings->value(SETTINGS_LOG_VIEW_WIDTH, 400).toInt(),
|
||||||
mSettings->value(SETTINGS_LOG_VIEW_HEIGHT, 300).toInt());
|
mSettings->value(SETTINGS_LOG_VIEW_HEIGHT, 300).toInt());
|
||||||
|
@ -54,3 +59,22 @@ void LogView::ClearButtonClicked()
|
||||||
{
|
{
|
||||||
mUI.mLogEdit->clear();
|
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();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
|
@ -59,6 +59,12 @@ protected slots:
|
||||||
*/
|
*/
|
||||||
void ClearButtonClicked();
|
void ClearButtonClicked();
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @brief Called when save button is clicked.
|
||||||
|
*
|
||||||
|
*/
|
||||||
|
void SaveButtonClicked();
|
||||||
|
|
||||||
private:
|
private:
|
||||||
Ui::LogView mUI;
|
Ui::LogView mUI;
|
||||||
|
|
||||||
|
|
|
@ -42,6 +42,13 @@
|
||||||
</property>
|
</property>
|
||||||
</spacer>
|
</spacer>
|
||||||
</item>
|
</item>
|
||||||
|
<item>
|
||||||
|
<widget class="QPushButton" name="mSaveButton">
|
||||||
|
<property name="text">
|
||||||
|
<string>&Save</string>
|
||||||
|
</property>
|
||||||
|
</widget>
|
||||||
|
</item>
|
||||||
<item>
|
<item>
|
||||||
<widget class="QPushButton" name="mClearButton">
|
<widget class="QPushButton" name="mClearButton">
|
||||||
<property name="text">
|
<property name="text">
|
||||||
|
|
Loading…
Reference in New Issue