diff --git a/src/blackgui/components/abouthtmlcomponent.cpp b/src/blackgui/components/abouthtmlcomponent.cpp new file mode 100644 index 000000000..db8a8ec08 --- /dev/null +++ b/src/blackgui/components/abouthtmlcomponent.cpp @@ -0,0 +1,55 @@ +/* Copyright (C) 2018 + * swift project Community / Contributors + * + * This file is part of swift project. It is subject to the license terms in the LICENSE file found in the top-level + * directory of this distribution and at http://www.swift-project.org/license.html. No part of swift project, + * including this file, may be copied, modified, propagated, or distributed except according to the terms + * contained in the LICENSE file. + */ + +#include "blackgui/guiapplication.h" +#include "blackmisc/fileutils.h" +#include "blackmisc/directoryutils.h" +#include "abouthtmlcomponent.h" +#include "ui_abouthtmlcomponent.h" +#include +#include + +using namespace BlackMisc; + +namespace BlackGui +{ + namespace Components + { + CAboutHtmlComponent::CAboutHtmlComponent(QWidget *parent) : + QFrame(parent), + ui(new Ui::CAboutHtmlComponent) + { + ui->setupUi(this); + const QPointer myself(this); + QTimer::singleShot(2500, this, [ = ] + { + if (!myself) { return; } + myself->loadAbout(); + }); + } + + CAboutHtmlComponent::~CAboutHtmlComponent() + { } + + void CAboutHtmlComponent::loadAbout() + { + // make links absolute + static const QString htmlFixed = [ = ] + { + // workaround: + // 1) Only reading as HTML gives proper formatting + // 2) Reading the file resource fails (likely because of the style sheet) + const QString html = CFileUtils::readFileToString(CDirectoryUtils::aboutFilePath()); + const QString legalDir = sGui->getGlobalSetup().getLegalDirectoryUrl().getFullUrl(); + return QString(html).replace(QLatin1String("href=\"./"), "href=\"" + legalDir); + }(); + ui->tbr_About->setHtml(htmlFixed); + } + } // ns +} // ns diff --git a/src/blackgui/components/abouthtmlcomponent.h b/src/blackgui/components/abouthtmlcomponent.h new file mode 100644 index 000000000..8a7164187 --- /dev/null +++ b/src/blackgui/components/abouthtmlcomponent.h @@ -0,0 +1,47 @@ +/* Copyright (C) 2018 + * swift project Community / Contributors + * + * This file is part of swift project. It is subject to the license terms in the LICENSE file found in the top-level + * directory of this distribution and at http://www.swift-project.org/license.html. No part of swift project, + * including this file, may be copied, modified, propagated, or distributed except according to the terms + * contained in the LICENSE file. + */ + +//! \file + +#ifndef BLACKGUI_COMPONENTS_ABOUTHTMLCOMPONENT_H +#define BLACKGUI_COMPONENTS_ABOUTHTMLCOMPONENT_H + +#include "blackgui/blackguiexport.h" +#include +#include + +namespace Ui { class CAboutHtmlComponent; } +namespace BlackGui +{ + namespace Components + { + /** + * Display the HTML info "about swift" + */ + class BLACKGUI_EXPORT CAboutHtmlComponent : public QFrame + { + Q_OBJECT + + public: + //! Constructor + explicit CAboutHtmlComponent(QWidget *parent = nullptr); + + //! Destructor + virtual ~CAboutHtmlComponent(); + + private: + //! Load credits and legal info + void loadAbout(); + + QScopedPointer ui; + }; + } // ns +} // ns + +#endif // guard diff --git a/src/blackgui/components/abouthtmlcomponent.ui b/src/blackgui/components/abouthtmlcomponent.ui new file mode 100644 index 000000000..97ee42cf0 --- /dev/null +++ b/src/blackgui/components/abouthtmlcomponent.ui @@ -0,0 +1,53 @@ + + + CAboutHtmlComponent + + + + 0 + 0 + 640 + 480 + + + + Frame + + + + 2 + + + 2 + + + 2 + + + 2 + + + + + About swift + + + true + + + <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0//EN" "http://www.w3.org/TR/REC-html40/strict.dtd"> +<html><head><meta name="qrichtext" content="1" /><title>About swift</title><style type="text/css"> +p, li { white-space: pre-wrap; } +</style></head><body style=" font-family:'MS Shell Dlg 2'; font-size:8.1pt; font-weight:400; font-style:normal;"> +<p style=" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;"><span style=" font-size:8.25pt;">Credits will go here</span></p></body></html> + + + true + + + + + + + +