source: psi/trunk/src/showtextdlg.cpp@ 183

Last change on this file since 183 was 2, checked in by dmik, 19 years ago

Imported original Psi 0.10 sources from Affinix

File size: 1.7 KB
Line 
1/*
2 * showtextdlg.cpp - dialog for displaying a text file
3 * Copyright (C) 2003 Justin Karneges
4 *
5 * This library is free software; you can redistribute it and/or
6 * modify it under the terms of the GNU Lesser General Public
7 * License as published by the Free Software Foundation; either
8 * version 2.1 of the License, or (at your option) any later version.
9 *
10 * This library is distributed in the hope that it will be useful,
11 * but WITHOUT ANY WARRANTY; without even the implied warranty of
12 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
13 * Lesser General Public License for more details.
14 *
15 * You should have received a copy of the GNU Lesser General Public
16 * License along with this library; if not, write to the Free Software
17 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
18 *
19 */
20
21#include"showtextdlg.h"
22
23#include<qlayout.h>
24#include<qtextedit.h>
25#include<qpushbutton.h>
26#include<qfile.h>
27#include<qtextstream.h>
28
29
30ShowTextDlg::ShowTextDlg(const QString &fname, bool rich, QWidget *parent, const char *name)
31:QDialog(parent, name, FALSE, WDestructiveClose)
32{
33 QString text;
34
35 QFile f(fname);
36 if(f.open(IO_ReadOnly)) {
37 QTextStream t(&f);
38 while(!t.eof())
39 text += t.readLine() + '\n';
40 f.close();
41 }
42
43 QVBoxLayout *vb1 = new QVBoxLayout(this, 8);
44 QTextEdit *te = new QTextEdit(this);
45 te->setReadOnly(TRUE);
46 te->setTextFormat(rich ? QTextEdit::RichText : QTextEdit::PlainText);
47 te->setText(text);
48
49 vb1->addWidget(te);
50
51 QHBoxLayout *hb1 = new QHBoxLayout(vb1);
52 hb1->addStretch(1);
53 QPushButton *pb = new QPushButton(tr("&OK"), this);
54 connect(pb, SIGNAL(clicked()), SLOT(accept()));
55 hb1->addWidget(pb);
56 hb1->addStretch(1);
57
58 resize(560, 384);
59}
Note: See TracBrowser for help on using the repository browser.