From b557bdf3921cb329a000ff759a169b08c93abff4 Mon Sep 17 00:00:00 2001 From: Michal Kubecek Date: Fri, 17 Apr 2015 09:06:09 +0200 Subject: automatic conversion of logviewform.ui --- src/gui/logviewform.cpp | 93 ++++++++++++++++++++++ src/gui/logviewform.h | 30 +++++++ src/gui/logviewform.ui | 203 +++++++++++++++++++++-------------------------- src/gui/logviewform.ui.h | 101 ----------------------- src/gui/twinkle.pro | 6 +- 5 files changed, 218 insertions(+), 215 deletions(-) create mode 100644 src/gui/logviewform.cpp create mode 100644 src/gui/logviewform.h delete mode 100644 src/gui/logviewform.ui.h diff --git a/src/gui/logviewform.cpp b/src/gui/logviewform.cpp new file mode 100644 index 0000000..0b0c28b --- /dev/null +++ b/src/gui/logviewform.cpp @@ -0,0 +1,93 @@ +#include "logviewform.h" + +#include "audits/memman.h" +#include "log.h" + +/* + * Constructs a LogViewForm which is a child of 'parent', with the + * name 'name' and widget flags set to 'f' + * + * The dialog will by default be modeless, unless you set 'modal' to + * true to construct a modal dialog. + */ +LogViewForm::LogViewForm(QWidget* parent) + : QDialog(parent) +{ + setupUi(this); +} + +/* + * Destroys the object and frees any allocated resources + */ +LogViewForm::~LogViewForm() +{ + // no need to delete child widgets, Qt does it all for us +} + +void LogViewForm::show() +{ + if (isShown()) { + raise(); + return; + } + + QString fname = log_file->get_filename().c_str(); + logfile = new QFile(fname); + MEMMAN_NEW(logfile); + logstream = NULL; + if (logfile->open(QIODevice::ReadOnly)) { + logstream = new Q3TextStream(logfile); + MEMMAN_NEW(logstream); + logTextEdit->setText(logstream->read()); + + // Set cursor position at the end of text + logTextEdit->scrollToBottom(); + } + + log_file->enable_inform_user(true); + + QDialog::show(); + raise(); +} + +void LogViewForm::closeEvent(QCloseEvent* ev) +{ + log_file->enable_inform_user(false); + logTextEdit->clear(); + + if (logstream) { + MEMMAN_DELETE(logstream); + delete logstream; + logstream = NULL; + } + + logfile->close(); + MEMMAN_DELETE(logfile); + delete logfile; + logfile = NULL; + + QDialog::closeEvent(ev); +} + +void LogViewForm::update(bool log_zapped) +{ + if (!isShown()) return; + + if (log_zapped) { + close(); + show(); + return; + } + + if (logstream) { + QString s = logstream->read(); + if (!s.isNull() && !s.isEmpty()) { + logTextEdit->append(s); + } + } +} + +void LogViewForm::clear() +{ + logTextEdit->clear(); +} diff --git a/src/gui/logviewform.h b/src/gui/logviewform.h new file mode 100644 index 0000000..821f15e --- /dev/null +++ b/src/gui/logviewform.h @@ -0,0 +1,30 @@ +#ifndef LOGVIEWFORM_H +#define LOGVIEWFORM_H + +#include +#include +#include + +#include "ui_logviewform.h" + +class LogViewForm : public QDialog, protected Ui::LogViewForm +{ + Q_OBJECT + +private: + QFile* logfile; + Q3TextStream* logstream; + +public: + LogViewForm(QWidget* parent = 0); + ~LogViewForm(); + +public slots: + void show(); + void closeEvent(QCloseEvent* ev); + void update(bool log_zapped); + void clear(); + +}; + +#endif // LOGVIEWFORM_H diff --git a/src/gui/logviewform.ui b/src/gui/logviewform.ui index c99d24c..496c529 100644 --- a/src/gui/logviewform.ui +++ b/src/gui/logviewform.ui @@ -1,123 +1,102 @@ - -LogViewForm - - - LogViewForm - + + + + + + LogViewForm + - - 0 - 0 - 599 - 472 - + + 0 + 0 + 599 + 472 + - - Twinkle - Log + + Twinkle - Log - - - unnamed - - - - logTextEdit - - - PlainText - - - NoWrap - - - true - - - Contents of the current log file (~/.twinkle/twinkle.log) - + + + + + Qt::PlainText + + + Q3TextEdit::NoWrap + + + true + + + Contents of the current log file (~/.twinkle/twinkle.log) + - - - closePushButton - - - &Close - - - Alt+C - + + + + + &Close + + + Alt+C + - - - spacer23 - - - Horizontal - - - Expanding - - - - 360 - 20 - - + + + + + + 360 + 20 + + + + QSizePolicy::Expanding + + + Qt::Horizontal + - - - clearPushButton - - - C&lear - - - Alt+L - - - Clear the log window. This does <b>not</b> clear the log file itself. - + + + + + C&lear + + + Alt+L + + + Clear the log window. This does <b>not</b> clear the log file itself. + - - - + + + + + qPixmapFromMimeSource + + logTextEdit + clearPushButton + closePushButton + + + qfile.h + q3textstream.h + + - closePushButton - clicked() - LogViewForm - close() + closePushButton + clicked() + LogViewForm + close() - clearPushButton - clicked() - LogViewForm - clear() + clearPushButton + clicked() + LogViewForm + clear() - - - logTextEdit - clearPushButton - closePushButton - - - qfile.h - qtextstream.h - log.h - qdialog.h - qstring.h - audits/memman.h - logviewform.ui.h - - - QFile *logfile; - QTextStream *logstream; - - - show() - closeEvent( QCloseEvent * ev ) - update( bool log_zapped ) - clear() - - - - + + diff --git a/src/gui/logviewform.ui.h b/src/gui/logviewform.ui.h deleted file mode 100644 index 6563015..0000000 --- a/src/gui/logviewform.ui.h +++ /dev/null @@ -1,101 +0,0 @@ -//Added by qt3to4: -#include -#include -/**************************************************************************** -** ui.h extension file, included from the uic-generated form implementation. -** -** If you want to add, delete, or rename functions or slots, use -** Qt Designer to update this file, preserving your code. -** -** You should not define a constructor or destructor in this file. -** Instead, write your code in functions called init() and destroy(). -** These will automatically be called by the form's constructor and -** destructor. -*****************************************************************************/ - -/* - Copyright (C) 2005-2009 Michel de Boer - - This program 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. - - This program 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 this program; if not, write to the Free Software - Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA -*/ - -void LogViewForm::show() -{ - if (isShown()) { - raise(); - return; - } - - QString fname = log_file->get_filename().c_str(); - logfile = new QFile(fname); - MEMMAN_NEW(logfile); - logstream = NULL; - if (logfile->open(QIODevice::ReadOnly)) { - logstream = new Q3TextStream(logfile); - MEMMAN_NEW(logstream); - logTextEdit->setText(logstream->read()); - - // Set cursor position at the end of text - logTextEdit->scrollToBottom(); - } - - log_file->enable_inform_user(true); - - QDialog::show(); - raise(); -} - -void LogViewForm::closeEvent( QCloseEvent *ev ) -{ - log_file->enable_inform_user(false); - logTextEdit->clear(); - - if (logstream) { - MEMMAN_DELETE(logstream); - delete logstream; - logstream = NULL; - } - - logfile->close(); - MEMMAN_DELETE(logfile); - delete logfile; - logfile = NULL; - - QDialog::closeEvent(ev); -} - -void LogViewForm::update(bool log_zapped) -{ - if (!isShown()) return; - - if (log_zapped) { - close(); - show(); - return; - } - - if (logstream) { - QString s = logstream->read(); - if (!s.isNull() && !s.isEmpty()) { - logTextEdit->append(s); - } - } -} - -void LogViewForm::clear() -{ - logTextEdit->clear(); -} - diff --git a/src/gui/twinkle.pro b/src/gui/twinkle.pro index 78e8a8e..6c7e7f6 100644 --- a/src/gui/twinkle.pro +++ b/src/gui/twinkle.pro @@ -12,6 +12,7 @@ INCLUDEPATH += .. HEADERS += gui.h \ dtmfform.h \ deregisterform.h \ + logviewform.h \ historylistview.h \ freedesksystray.h \ twinklesystray.h \ @@ -30,6 +31,7 @@ SOURCES += main.cpp \ gui.cpp \ dtmfform.cpp \ deregisterform.cpp \ + logviewform.cpp \ historylistview.cpp \ freedesksystray.cpp \ twinklesystray.cpp \ @@ -41,7 +43,8 @@ SOURCES += main.cpp \ twinkleapplication.cpp FORMS = dtmfform.ui \ - deregisterform.ui + deregisterform.ui \ + logviewform.ui #The following line was changed from FORMS to FORMS3 by qt3to4 FORMS3 = mphoneform.ui \ @@ -56,7 +59,6 @@ FORMS3 = mphoneform.ui \ getprofilenameform.ui \ transferform.ui \ syssettingsform.ui \ - logviewform.ui \ wizardform.ui \ getaddressform.ui \ historyform.ui \ -- cgit v1.2.3