2009-08-15 17:02:25 +00:00
|
|
|
/***************************************************************************
|
|
|
|
* __________ __ ___.
|
|
|
|
* Open \______ \ ____ ____ | | _\_ |__ _______ ___
|
|
|
|
* Source | _// _ \_/ ___\| |/ /| __ \ / _ \ \/ /
|
|
|
|
* Jukebox | | ( <_> ) \___| < | \_\ ( <_> > < <
|
|
|
|
* Firmware |____|_ /\____/ \___ >__|_ \|___ /\____/__/\_ \
|
|
|
|
* \/ \/ \/ \/ \/
|
|
|
|
*
|
|
|
|
* Copyright (C) 2007 by Dominik Riebeling
|
|
|
|
* $Id$
|
|
|
|
*
|
|
|
|
* All files in this archive are subject to the GNU General Public License.
|
|
|
|
* See the file COPYING in the source tree root for full license agreement.
|
|
|
|
*
|
|
|
|
* This software is distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY
|
|
|
|
* KIND, either express or implied.
|
|
|
|
*
|
|
|
|
****************************************************************************/
|
|
|
|
|
|
|
|
#include <QtGui>
|
|
|
|
#include "systrace.h"
|
|
|
|
#include "ui_systracefrm.h"
|
|
|
|
|
|
|
|
|
|
|
|
QString SysTrace::debugbuffer;
|
|
|
|
|
|
|
|
SysTrace::SysTrace(QWidget *parent) : QDialog(parent)
|
|
|
|
{
|
|
|
|
ui.setupUi(this);
|
|
|
|
ui.textTrace->setReadOnly(true);
|
2009-10-31 17:16:34 +00:00
|
|
|
ui.textTrace->setLayoutDirection(Qt::LeftToRight);
|
2009-08-15 17:02:25 +00:00
|
|
|
refresh();
|
|
|
|
|
|
|
|
connect(ui.buttonClose, SIGNAL(clicked()), this, SLOT(close()));
|
|
|
|
connect(ui.buttonSave, SIGNAL(clicked()), this, SLOT(save()));
|
|
|
|
connect(ui.buttonRefresh, SIGNAL(clicked()), this, SLOT(refresh()));
|
|
|
|
}
|
|
|
|
|
|
|
|
void SysTrace::refresh(void)
|
|
|
|
{
|
|
|
|
int pos = ui.textTrace->verticalScrollBar()->value();
|
|
|
|
ui.textTrace->setHtml("<pre>" + debugbuffer + "</pre>");
|
|
|
|
ui.textTrace->verticalScrollBar()->setValue(pos);
|
|
|
|
}
|
|
|
|
|
|
|
|
void SysTrace::save(void)
|
|
|
|
{
|
|
|
|
QString fp = QFileDialog::getSaveFileName(this, tr("Save system trace log"),
|
|
|
|
QDir::homePath(), "*.log");
|
2009-08-29 18:55:52 +00:00
|
|
|
if(fp == "")
|
|
|
|
return;
|
|
|
|
|
2009-08-15 17:02:25 +00:00
|
|
|
QFile fh(fp);
|
2009-08-29 18:55:52 +00:00
|
|
|
if(!fh.open(QIODevice::WriteOnly))
|
|
|
|
return;
|
2009-08-15 17:02:25 +00:00
|
|
|
fh.write(debugbuffer.toUtf8(), debugbuffer.size());
|
|
|
|
fh.close();
|
|
|
|
}
|
|
|
|
|
|
|
|
void SysTrace::debug(QtMsgType type, const char* msg)
|
|
|
|
{
|
2009-08-15 18:57:58 +00:00
|
|
|
(void)type;
|
2009-08-15 17:02:25 +00:00
|
|
|
debugbuffer.append(msg);
|
|
|
|
debugbuffer.append("\n");
|
|
|
|
#if !defined(NODEBUG)
|
|
|
|
fprintf(stderr, "%s\n", msg);
|
|
|
|
#endif
|
|
|
|
|
|
|
|
}
|
|
|
|
|