Falkon Develop
Cross-platform Qt-based web browser
licenseviewer.cpp
Go to the documentation of this file.
1/* ============================================================
2* Falkon - Qt web browser
3* Copyright (C) 2010-2014 David Rosca <nowrep@gmail.com>
4*
5* This program is free software: you can redistribute it and/or modify
6* it under the terms of the GNU General Public License as published by
7* the Free Software Foundation, either version 3 of the License, or
8* (at your option) any later version.
9*
10* This program 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
13* GNU General Public License for more details.
14*
15* You should have received a copy of the GNU General Public License
16* along with this program. If not, see <http://www.gnu.org/licenses/>.
17* ============================================================ */
18#include "licenseviewer.h"
19#include "qztools.h"
20
21#include <QFont>
22#include <QTextBrowser>
23#include <QVBoxLayout>
24#include <QDialogButtonBox>
25
27 : QWidget()
28{
29 setAttribute(Qt::WA_DeleteOnClose);
30 setWindowTitle(tr("License Viewer"));
31
32 m_textBrowser = new QTextBrowser(this);
33
34 QFont serifFont = m_textBrowser->font();
35 serifFont.setFamily(QSL("Courier"));
36 m_textBrowser->setFont(serifFont);
37
38 auto* buttonBox = new QDialogButtonBox(this);
39 buttonBox->setStandardButtons(QDialogButtonBox::Close);
40 connect(buttonBox, &QDialogButtonBox::rejected, this, &QWidget::close);
41
42 auto* l = new QVBoxLayout(this);
43 l->addWidget(m_textBrowser);
44 l->addWidget(buttonBox);
45
46 setLayout(l);
47
48 resize(600, 500);
49
51}
52
53void LicenseViewer::setLicenseFile(const QString &fileName)
54{
55 m_textBrowser->setText(QzTools::readAllFileContents(fileName));
56}
57
58void LicenseViewer::setText(const QString &text)
59{
60 m_textBrowser->setText(text);
61}
LicenseViewer(QWidget *parent=nullptr)
void setText(const QString &text)
void setLicenseFile(const QString &fileName)
static void centerWidgetToParent(QWidget *w, QWidget *parent)
Definition: qztools.cpp:124
static QString readAllFileContents(const QString &filename)
Definition: qztools.cpp:98
#define QSL(x)
Definition: qzcommon.h:40