9#include <QtCore/QBuffer>
11#include <QtWidgets/QLabel>
12#include <QtWidgets/QPushButton>
13#include <QtWidgets/QLayout>
14#include <QtWidgets/QApplication>
15#include <QtWidgets/QMessageBox>
16#include <QtGui/QDesktopServices>
17#include <QtGui/QScreen>
25 setFrameStyle(QFrame::NoFrame);
27 p.setColor(QPalette::Base, p.color(QPalette::Window));
34 QDataStream in(resources);
37 QTextBrowser::setText(text);
43 QTextDocument *doc = document();
45 return QSize(
int(doc->size().width()),
int(doc->size().height()));
51 if (type == 2 || type == 3) {
52 if (m_resourceMap.contains(name.toString())) {
53 return m_resourceMap.value(name.toString());
63 if (url.isValid() && (!HelpViewer::isLocalUrl(url)
64 || !HelpViewer::canOpenPage(url.path()))) {
65 if (!QDesktopServices::openUrl(url)) {
66 QMessageBox::warning(
this, tr(
"Warning"),
67 tr(
"Unable to launch external application."), QMessageBox::Close);
73 : QDialog(parent, Qt::MSWindowsFixedSizeDialogHint |
74 Qt::WindowTitleHint|Qt::WindowSystemMenuHint)
77 m_pixmapLabel =
nullptr;
80 m_closeButton =
new QPushButton();
81 m_closeButton->setText(tr(
"&Close"));
82 connect(m_closeButton, &QAbstractButton::clicked,
this, &QWidget::close);
84 m_layout =
new QGridLayout(
this);
85 m_layout->addWidget(m_aboutLabel, 1, 0, 1, -1);
86 m_layout->addItem(
new QSpacerItem(20, 10, QSizePolicy::Minimum,
87 QSizePolicy::Fixed), 2, 1, 1, 1);
88 m_layout->addItem(
new QSpacerItem(20, 20, QSizePolicy::Expanding), 3, 0, 1, 1);
89 m_layout->addWidget(m_closeButton, 3, 1, 1, 1);
90 m_layout->addItem(
new QSpacerItem(20, 20, QSizePolicy::Expanding), 3, 2, 1, 1);
96 m_aboutLabel->setText(text, resources);
103 if (!m_pixmapLabel) {
104 m_pixmapLabel =
new QLabel();
105 m_layout->addWidget(m_pixmapLabel, 0, 0, 1, -1, Qt::AlignCenter);
107 m_pixmapLabel->setPixmap(pixmap);
114 return m_aboutLabel->documentTitle();
120 auto screen = QGuiApplication::screenAt(QCursor::pos());
122 screen = QGuiApplication::primaryScreen();
123 const QSize screenSize = screen->availableSize();
124 int limit = qMin(screenSize.width()/2, 500);
127 limit = qMin(screenSize.width()/2, 420);
130 layout()->activate();
131 int width = layout()->totalMinimumSize().width();
136 QFontMetrics fm(qApp->font(
"QWorkspaceTitleBar"));
137 int windowTitleWidth = qMin(fm.horizontalAdvance(windowTitle()) + 50, limit);
138 if (windowTitleWidth > width)
139 width = windowTitleWidth;
141 layout()->activate();
142 int height = (layout()->hasHeightForWidth())
143 ? layout()->totalHeightForWidth(width)
144 : layout()->totalMinimumSize().height();
145 setFixedSize(width, height);
146 QCoreApplication::removePostedEvents(
this, QEvent::LayoutRequest);
QString documentTitle() const
void setText(const QString &text, const QByteArray &resources)
void setPixmap(const QPixmap &pixmap)
QSize minimumSizeHint() const override
QVariant loadResource(int type, const QUrl &name) override
This function is called when the document is loaded and for each image in the document.
void doSetSource(const QUrl &name, QTextDocument::ResourceType type) override
Attempts to load the document at the given url with the specified type.
void setText(const QString &text, const QByteArray &resources)
Combined button and popup list for selecting options.