jtdx/HelpTextWindow.cpp

30 lines
1,009 B
C++
Raw Normal View History

2020-02-21 11:05:07 +02:00
#include "HelpTextWindow.hpp"
#include <QApplication>
#include <QString>
#include <QPalette>
#include <QFile>
#include <QTextStream>
2020-04-08 08:42:11 +03:00
#include "JTDXMessageBox.hpp"
2020-02-21 11:05:07 +02:00
#include "qt_helpers.hpp"
HelpTextWindow::HelpTextWindow (QString const& title, QString const& file_name, QFont const& font, QWidget * parent)
: QLabel {parent, Qt::WindowCloseButtonHint | Qt::WindowMinimizeButtonHint}
{
QFile source {file_name};
if (!source.open (QIODevice::ReadOnly | QIODevice::Text))
{
2020-04-08 08:42:11 +03:00
JTDXMessageBox::warning_message (this, QApplication::applicationName ()
2021-02-01 22:54:21 +02:00
, tr("Cannot open \"") + source.fileName ()
+ tr("\" for reading:") + source.errorString ());
2020-02-21 11:05:07 +02:00
return;
}
setText (QTextStream {&source}.readAll ());
setWindowTitle(QApplication::applicationName () + " - " + title);
setMargin (10);
setBackgroundRole (QPalette::Base);
setAutoFillBackground (true);
setStyleSheet (font_as_stylesheet (font));
}