1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39
|
#include "textdialog.h"
#include "version.h"
#include <QTextBrowser>
#include <QDialog>
#include <QGridLayout>
#include <QPushButton>
TextDialog::TextDialog (QWidget *parent) : QDialog (parent)
{
QGridLayout *g = new QGridLayout (this);
m_textbrowser = new QTextBrowser (this);
m_textbrowser->setReadOnly (true);
#if QT_VERSION >= 0x040200
m_textbrowser->setOpenExternalLinks (true);
#endif
QPushButton *close = new QPushButton (tr ("Close"), this);
connect (close, SIGNAL (clicked ()), this, SLOT (accept ()));
g->addWidget (m_textbrowser, 0, 0, 3, 3);
g->addWidget (close, 3, 2, 1, 1);
}
void
TextDialog::read_file (const QString &filename)
{
QFile file (filename);
if (file.open (QFile::ReadOnly)) {
QByteArray cont = file.readAll ();
QString s = QString::fromAscii (cont);
s.replace ("@ESP_VERSION@", ESPERANZA_VERSION_STR);
s.replace ("@ESP_DATE@", ESPERANZA_DATE_STR);
s.replace ("@QT_VERSION@", QT_VERSION_STR);
m_textbrowser->setHtml (s);
}
}
|