YARP
Yet Another Robot Platform
 
Loading...
Searching...
No Matches
logwidget.cpp
Go to the documentation of this file.
1/*
2 * SPDX-FileCopyrightText: 2006-2021 Istituto Italiano di Tecnologia (IIT)
3 * SPDX-License-Identifier: LGPL-2.1-or-later
4 */
5
6#include "logwidget.h"
7#include <QFileDialog>
8#include <QCoreApplication>
9
10LogWidget::LogWidget(QWidget *parent) :
11 QListWidget(parent),
12 contextMenu(nullptr)
13{
14 //contextMenu = new QMenu(this);
15 clearLogAction = new QAction("Clear Log",this);
16 saveLogAction = new QAction("Save Log",this);
17
18 clearLogAction->setIcon(QIcon(":/clear.svg"));
19 saveLogAction->setIcon(QIcon(":/file-save.svg"));
20
21 this->addAction(clearLogAction);
22 this->addAction(saveLogAction);
23
24 connect(clearLogAction,SIGNAL(triggered()),this,SLOT(onClearLog()));
25 connect(saveLogAction,SIGNAL(triggered()),this,SLOT(onSaveLog()));
26}
27
28void LogWidget::onClearLog()
29{
30 clear();
31}
32
33void LogWidget::onSaveLog()
34{
35 QString logFileName = QFileDialog::getSaveFileName(this,"Save the Log",QDir::homePath());
36
37 QFile f(logFileName);
38 f.open(QIODevice::WriteOnly);
39
40 for(int i=0; i<count(); i++){
41 QString line = item(i)->text() + "\n";
42 f.write(line.toLatin1().data());
43 }
44
45 f.flush();
46 f.close();
47
48}
int SIGNAL(int pid, int signum)
LogWidget(QWidget *parent=0)
Definition logwidget.cpp:10