2 This file is part of Faster Application Manager.
4 Faster Application Manager is free software: you can redistribute it and/or modify
5 it under the terms of the GNU General Public License as published by
6 the Free Software Foundation, either version 3 of the License, or
7 (at your option) any later version.
9 Faster Application Manager is distributed in the hope that it will be useful,
10 but WITHOUT ANY WARRANTY; without even the implied warranty of
11 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12 GNU General Public License for more details.
14 You should have received a copy of the GNU General Public License
15 along with Faster Application Manager. If not, see <http://www.gnu.org/licenses/>.
17 (C) Heikki Holstila 2010
27 #include "ui_logview.h"
28 #include "aaptinterface.h"
30 LogView::LogView(QByteArray text, QWidget *parent) :
36 QFont f = ui->plainTextEdit->font();
37 f.setPointSize( f.pointSize()-2 );
39 ui->plainTextEdit->setFont(f);
42 QStringList lines = t.split('\n');
44 if( lines.count()>100 )
45 ui->label->setText("Showing last 100 lines");
47 while( lines.count()>100 )
49 lines << "" << "" << "" << "" << "";
51 ui->plainTextEdit->setPlainText("");
52 ui->plainTextEdit->appendPlainText(lines.join("\n"));
62 #ifdef Q_WS_MAEMO_5 // workaround for buggy Qt autorotation
63 QRect r = dynamic_cast<QWidget*>(this->parent())->rect();
64 if(r.width() < r.height())
65 this->setAttribute(Qt::WA_Maemo5PortraitOrientation);
69 //ui->plainTextEdit->setMinimumHeight( ui->plainTextEdit->contentsRect().height() );
70 //ui->scrollAreaWidgetContents->setMinimumHeight( ui->scrollAreaWidgetContents->contentsRect().height() );
71 //ui->plainTextEdit->setMinimumHeight( 800 );
72 //ui->plainTextEdit->adjustSize();
73 //ui->scrollAreaWidgetContents->adjustSize();
75 // taken from a Qt example, should auto-resize the textedit
76 QTextDocument *doc = ui->plainTextEdit->document();
77 QSize s = doc->size().toSize();
78 if (ui->plainTextEdit)
79 s.setHeight((s.height() + 1) * ui->plainTextEdit->fontMetrics().lineSpacing());
80 const QRect fr = ui->plainTextEdit->frameRect();
81 const QRect cr = ui->plainTextEdit->contentsRect();
82 ui->plainTextEdit->setMinimumHeight(qMax(70, s.height() + (fr.height() - cr.height() - 1)));
84 int e = QDialog::exec();
86 #ifdef Q_WS_MAEMO_5 // workaround for buggy Qt autorotation
87 this->setAttribute(Qt::WA_Maemo5AutoOrientation);
92 void LogView::changeEvent(QEvent *e)
94 QDialog::changeEvent(e);
96 case QEvent::LanguageChange:
97 ui->retranslateUi(this);
104 void LogView::on_btnClear_clicked()
106 QFile logfile(KLogFile);
112 void LogView::on_btnCopy_clicked()
114 ui->plainTextEdit->selectAll();
115 ui->plainTextEdit->copy();
117 QMaemo5InformationBox::information ( this, "Copied" );