From aeded8771050652382dc61ddae4652c54314ed3f Mon Sep 17 00:00:00 2001 From: nowrep Date: Sun, 25 Aug 2013 23:50:24 +0200 Subject: [PATCH] License Viewer: Use Courier font + small visual tweaks Added close button and changed default size --- src/lib/other/licenseviewer.cpp | 32 +++++++++++++++++++++++++++++--- src/lib/other/licenseviewer.h | 10 ++++++++-- 2 files changed, 37 insertions(+), 5 deletions(-) diff --git a/src/lib/other/licenseviewer.cpp b/src/lib/other/licenseviewer.cpp index 87b8c45b0..0f0c39ca1 100644 --- a/src/lib/other/licenseviewer.cpp +++ b/src/lib/other/licenseviewer.cpp @@ -18,18 +18,44 @@ #include "licenseviewer.h" #include "qztools.h" +#include +#include +#include +#include + LicenseViewer::LicenseViewer(QWidget* parent) - : QTextBrowser() + : QWidget() { setAttribute(Qt::WA_DeleteOnClose); setWindowTitle(tr("License Viewer")); - resize(450, 500); + m_textBrowser = new QTextBrowser(this); + + QFont serifFont = m_textBrowser->font(); + serifFont.setFamily("Courier"); + m_textBrowser->setFont(serifFont); + + QDialogButtonBox* buttonBox = new QDialogButtonBox(this); + buttonBox->setStandardButtons(QDialogButtonBox::Close); + connect(buttonBox, SIGNAL(rejected()), this, SLOT(close())); + + QVBoxLayout* l = new QVBoxLayout(this); + l->addWidget(m_textBrowser); + l->addWidget(buttonBox); + + setLayout(l); + + resize(600, 500); QzTools::centerWidgetToParent(this, parent); } void LicenseViewer::setLicenseFile(const QString &fileName) { - setText(QzTools::readAllFileContents(fileName)); + m_textBrowser->setText(QzTools::readAllFileContents(fileName)); +} + +void LicenseViewer::setText(const QString &text) +{ + m_textBrowser->setText(text); } diff --git a/src/lib/other/licenseviewer.h b/src/lib/other/licenseviewer.h index bc9df7309..3702a14c7 100644 --- a/src/lib/other/licenseviewer.h +++ b/src/lib/other/licenseviewer.h @@ -18,11 +18,13 @@ #ifndef LICENSEVIEWER_H #define LICENSEVIEWER_H -#include +#include #include "qz_namespace.h" -class QT_QUPZILLA_EXPORT LicenseViewer : public QTextBrowser +class QTextBrowser; + +class QT_QUPZILLA_EXPORT LicenseViewer : public QWidget { Q_OBJECT @@ -30,6 +32,10 @@ public: explicit LicenseViewer(QWidget* parent = 0); void setLicenseFile(const QString &fileName); + void setText(const QString &text); + +private: + QTextBrowser* m_textBrowser; }; #endif // LICENSEVIEWER_H