/* Copyright 2003 Rikard Björklind, Mikael Gransell This file is part of dc-qt. dc-qt is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation; either version 2 of the License, or (at your option) any later version. dc-qt is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. You should have received a copy of the GNU General Public License along with dc-qt; if not, write to the Free Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA */ #include "debugdlg.h" #include #include #include #include "dc_settings.h" #include "util.h" static QFile *file; DebugDlg::DebugDlg( QWidget* parent, const char* name ) : QDialog( parent, name ) { #ifdef _DEBUG // load window pos and size wnd_setting wndset(settings.get_setting("wndset_debug")); if (wndset.isValid()) { setGeometry(wndset.x(), wndset.y(),wndset.w(), wndset.h()); move(QPoint(wndset.x(), wndset.y())); resize(wndset.w(), wndset.h()); printf("dbgok\n"); } else { setGeometry(0,0,400,700); resize(400,700); } setCaption( "Debug Window" ); QGridLayout* layout = new QGridLayout( this, 1, 1 ); text = new QTextEdit( this, "debug text" ); text->setTextFormat( PlainText ); text->setReadOnly( true ); text->setMinimumSize( QSize( 100, 200 ) ); text->setText("Hello and welcome to dcqt2!\n"); text->viewport()->setFocus(); layout->addWidget( text, 0, 0 ); file = new QFile("dctcoutput.log"); file->open(IO_WriteOnly); stream.setDevice(file); show(); #endif } #ifdef _DEBUG void DebugDlg::print( const QString& str ) { text->append( str ); log(str); } void DebugDlg::log( const QString& str) { stream << str; } void DebugDlg::closeEvent(QCloseEvent * e) { // save window position and size wnd_setting wndset(x(), y(), width(), height()); if (wndset.isValid()) { settings.set_setting("common","wndset_debug", wndset.toString()); settings.save_to_file(); } e->accept(); } #endif /* * * $Log: * */