summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorFriedemann Kleint <Friedemann.Kleint@qt.io>2020-04-06 12:26:47 +0200
committerFriedemann Kleint <Friedemann.Kleint@qt.io>2020-04-08 07:37:48 +0200
commitcdd58e2c155063f9b52b69a47f45c2430214e3a4 (patch)
tree903989713351c3bcf54a1298ac62afd036439640
parent8ca337213f1e79abca96a70a17f771f322c58319 (diff)
Add a manual test for dumpcppv5.15.0-beta4
Let it generate code for the WebBrowser and display the meta object. Factor out useful code from axviewer. Change-Id: Ib250c749459836e2145f83f4f68fa0caee2a2ad9 Reviewed-by: Volker Hilsheimer <volker.hilsheimer@qt.io>
-rw-r--r--tests/manual/axviewer/axviewer.pro3
-rw-r--r--tests/manual/axviewer/main.cpp196
-rw-r--r--tests/manual/dumpcpp/dumpcpp.pro13
-rw-r--r--tests/manual/dumpcpp/main.cpp112
-rw-r--r--tests/manual/manual.pro2
-rw-r--r--tests/manual/shared/metaobjectdump.cpp204
-rw-r--r--tests/manual/shared/metaobjectdump.h39
-rw-r--r--tests/manual/shared/shared.pri3
-rw-r--r--tests/manual/shared/textdialog.cpp49
-rw-r--r--tests/manual/shared/textdialog.h40
10 files changed, 468 insertions, 193 deletions
diff --git a/tests/manual/axviewer/axviewer.pro b/tests/manual/axviewer/axviewer.pro
index 2c06290..a609e49 100644
--- a/tests/manual/axviewer/axviewer.pro
+++ b/tests/manual/axviewer/axviewer.pro
@@ -1,6 +1,9 @@
TEMPLATE = app
QT = core gui widgets axcontainer
CONFIG += console c++11
+
SOURCES += main.cpp
+include(../shared/shared.pri)
+
DIAGLIB = ../../../../qtbase/tests/manual/diaglib
exists($$DIAGLIB):include($$DIAGLIB/diaglib.pri)
diff --git a/tests/manual/axviewer/main.cpp b/tests/manual/axviewer/main.cpp
index 4828009..2f6c4bf 100644
--- a/tests/manual/axviewer/main.cpp
+++ b/tests/manual/axviewer/main.cpp
@@ -26,17 +26,17 @@
**
****************************************************************************/
+#include "metaobjectdump.h"
+#include "textdialog.h"
+
#include <ActiveQt/QAxSelect>
#include <ActiveQt/QAxWidget>
#include <QtWidgets/QAction>
#include <QtWidgets/QApplication>
-#include <QtWidgets/QDialog>
-#include <QtWidgets/QDialogButtonBox>
#include <QtWidgets/QMainWindow>
#include <QtWidgets/QMenu>
#include <QtWidgets/QMenuBar>
-#include <QtWidgets/QPlainTextEdit>
#include <QtWidgets/QStatusBar>
#include <QtWidgets/QToolBar>
#include <QtWidgets/QVBoxLayout>
@@ -47,7 +47,6 @@
#include <QtCore/QCommandLineOption>
#include <QtCore/QCommandLineParser>
#include <QtCore/QDebug>
-#include <QtCore/QMetaMethod>
#include <QtCore/QMetaObject>
#include <QtCore/QPair>
#include <QtCore/QStringList>
@@ -71,195 +70,6 @@ static inline bool isOptionSet(int argc, char *argv[], const char *option)
[option] (const char *arg) { return !qstrcmp(arg, option); });
}
-using rightAlignNumber = QPair<int, int>; // Use as str << rightAlignNumber(value, width)
-
-QTextStream &operator<<(QTextStream &str, const rightAlignNumber &r)
-{
- auto oldWidth = str.fieldWidth();
- str.setFieldWidth(r.second);
- auto oldAlignment = str.fieldAlignment();
- str.setFieldAlignment(QTextStream::AlignRight);
- str << r.first;
- str.setFieldAlignment(oldAlignment);
- str.setFieldWidth(oldWidth);
- return str;
-}
-
-QTextStream &operator<<(QTextStream &str, const QMetaEnum &me)
-{
- const int keyCount = me.keyCount();
- str << me.name() << ' ' << keyCount << " keys";
- if (me.isFlag())
- str << " [flag]";
- if (me.isScoped())
- str << " [scoped]";
- const int maxLogCount = std::min(6, keyCount);
- str << " {";
- for (int k = 0; k < maxLogCount; ++k) {
- if (k)
- str << ", ";
- str << me.key(k) << " = " << me.value(k);
- }
- if (maxLogCount < keyCount)
- str << ",...";
- str << '}';
- return str;
-}
-
-QTextStream &operator<<(QTextStream &str, const QMetaClassInfo &mc)
-{
- str << '"' << mc.name() << "\": \"" << mc.value() << '"';
- return str;
-}
-
-QTextStream &operator<<(QTextStream &str, const QMetaProperty &mp)
-{
- str << mp.typeName() << ' ' << mp.name();
- if (mp.isWritable())
- str << " [writable]";
- if (mp.isResettable())
- str << " [resettable]";
- if (mp.isDesignable())
- str << " [designable]";
- if (mp.isStored())
- str << " [stored]";
- if (mp.isUser())
- str << " [user]";
- if (mp.isConstant())
- str << " [constant]";
- if (mp.isFinal())
- str << " [final]";
- if (mp.isRequired())
- str << " [required]";
- if (mp.isFlagType())
- str << " [flag]";
- if (mp.isEnumType())
- str << " [enum " << mp.enumerator().name() << ']';
- if (mp.hasNotifySignal())
- str << " [notify " << mp.notifySignal().name() << ']';
- return str;
-}
-
-QTextStream &operator<<(QTextStream &str, const QMetaMethod &m)
-{
- switch (m.access()) {
- case QMetaMethod::Private:
- str << "private ";
- break;
- case QMetaMethod::Protected:
- str << "protected ";
- break;
- case QMetaMethod::Public:
- break;
- }
- str << m.typeName() << ' ' << m.methodSignature();
- switch (m.methodType()) {
- case QMetaMethod::Method:
- break;
- case QMetaMethod::Signal:
- str << " [signal]";
- break;
- case QMetaMethod::Slot:
- str << " [slot]";
- break;
- case QMetaMethod::Constructor:
- str << " [ct]";
- break;
- }
- if (auto attributes = m.attributes()) {
- str << " attributes: " << Qt::hex << Qt::showbase << attributes
- << Qt::dec << Qt::noshowbase;
- }
- if (const int count = m.parameterCount()) {
- str << " Parameters: ";
- const auto parameterNames = m.parameterNames();
- const auto parameterTypes = m.parameterTypes();
- for (int p = 0; p < count; ++p) {
- if (p)
- str << ", ";
- str << parameterTypes.at(p) << ' ' << parameterNames.at(p);
- }
- }
- return str;
-}
-
-static void formatMetaObject(QTextStream &str, const QMetaObject *mo, const QByteArray &indent)
-{
- str << indent << "--- " << mo->className() << " ---\n";
-
- const int classInfoOffset = mo->classInfoOffset();
- const int classInfoCount = mo->classInfoCount();
- if (classInfoOffset < classInfoCount) {
- str << indent << " Class Info of " << mo->className() << ": "
- << classInfoOffset << ".." << classInfoCount << '\n';
- for (int i = classInfoOffset; i < classInfoCount; ++i) {
- str << indent << " " << rightAlignNumber(i, 3) << ' '
- << mo->classInfo(i) << '\n';
- }
- }
-
- const int enumOffset = mo->enumeratorOffset();
- const int enumCount = mo->enumeratorCount();
- if (enumOffset < enumCount) {
- str << indent << " Enums of " << mo->className() << ": " << enumOffset
- << ".." << enumCount << '\n';
- for (int e = enumOffset; e < enumCount; ++e)
- str << indent << " " << rightAlignNumber(e, 3) << ' ' << mo->enumerator(e) << '\n';
- }
-
- const int methodOffset = mo->methodOffset();
- const int methodCount = mo->methodCount();
- if (methodOffset < methodCount) {
- str << indent << " Methods of " << mo->className() << ": " << methodOffset
- << ".." << methodCount << '\n';
- for (int m = methodOffset; m < methodCount; ++m)
- str << indent << " " << rightAlignNumber(m, 3) << ' ' << mo->method(m) << '\n';
- }
-
- const int propertyOffset = mo->propertyOffset();
- const int propertyCount = mo-> propertyCount();
- if (propertyOffset < propertyCount) {
- str << indent << " Properties of " << mo->className() << ": " << propertyOffset
- << ".." << propertyCount << '\n';
- for (int p = propertyOffset; p < propertyCount; ++p)
- str << indent << " " << rightAlignNumber(p, 3) << ' ' << mo->property(p) << '\n';
- }
-}
-
-QTextStream &operator<<(QTextStream &str, const QMetaObject &o)
-{
- QVector<const QMetaObject *> klasses;
- for (auto s = &o; s; s = s->superClass())
- klasses.prepend(s);
-
- QByteArray indent;
- for (auto k : klasses) {
- formatMetaObject(str, k, indent);
- indent += " ";
- }
- return str;
-}
-
-class TextDialog : public QDialog
-{
-public:
- explicit TextDialog(const QString &text, QWidget *parent = nullptr);
-};
-
-TextDialog::TextDialog(const QString &text, QWidget *parent) : QDialog(parent)
-{
- setWindowFlags(windowFlags() & ~Qt::WindowContextHelpButtonHint);
- auto layout = new QVBoxLayout(this);
- auto pe = new QPlainTextEdit(text, this);
- pe->setReadOnly(true);
- pe->setFont(QFontDatabase::systemFont(QFontDatabase::FixedFont));
- layout->addWidget(pe);
-
- auto buttonBox = new QDialogButtonBox(QDialogButtonBox::Close, this);
- layout->addWidget(buttonBox);
- connect(buttonBox, &QDialogButtonBox::rejected, this, &QDialog::reject);
-}
-
class MainWindow : public QMainWindow
{
Q_OBJECT
diff --git a/tests/manual/dumpcpp/dumpcpp.pro b/tests/manual/dumpcpp/dumpcpp.pro
new file mode 100644
index 0000000..6f116c0
--- /dev/null
+++ b/tests/manual/dumpcpp/dumpcpp.pro
@@ -0,0 +1,13 @@
+TEMPLATE=app
+CONFIG += QMAKE_LFLAGS_CONSOLE
+QT += widgets axcontainer testlib
+
+SOURCES += main.cpp
+include(../shared/shared.pri)
+
+# Assume Web Browser type library is available in all windows installations
+TYPELIBS = $$(SystemRoot)\\system32\\ieframe.dll
+
+!exists($$TYPELIBS) {
+ message("Web Browser type library for test not found!")
+}
diff --git a/tests/manual/dumpcpp/main.cpp b/tests/manual/dumpcpp/main.cpp
new file mode 100644
index 0000000..2f3cef8
--- /dev/null
+++ b/tests/manual/dumpcpp/main.cpp
@@ -0,0 +1,112 @@
+/****************************************************************************
+**
+** Copyright (C) 2020 The Qt Company Ltd.
+** Contact: https://www.qt.io/licensing/
+**
+** This file is part of the test suite of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:GPL-EXCEPT$
+** Commercial License Usage
+** Licensees holding valid commercial Qt licenses may use this file in
+** accordance with the commercial license agreement provided with the
+** Software or, alternatively, in accordance with the terms contained in
+** a written agreement between you and The Qt Company. For licensing terms
+** and conditions see https://www.qt.io/terms-conditions. For further
+** information use the contact form at https://www.qt.io/contact-us.
+**
+** GNU General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU
+** General Public License version 3 as published by the Free Software
+** Foundation with exceptions as appearing in the file LICENSE.GPL3-EXCEPT
+** included in the packaging of this file. Please review the following
+** information to ensure the GNU General Public License requirements will
+** be met: https://www.gnu.org/licenses/gpl-3.0.html.
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+#include "ieframe.h" // generated header
+
+#include <metaobjectdump.h>
+#include <textdialog.h>
+
+#include <QAction>
+#include <QApplication>
+#include <QMainWindow>
+#include <QMenu>
+#include <QMenuBar>
+#include <QToolBar>
+
+#include <QScreen>
+
+#include <QDebug>
+
+class MainWindow :public QMainWindow
+{
+ Q_OBJECT
+public:
+ MainWindow();
+
+public slots:
+ void navigate(const QString &);
+ void showMetaObject();
+
+private:
+ SHDocVw::WebBrowser *m_browser;
+};
+
+MainWindow::MainWindow() : m_browser(new SHDocVw::WebBrowser)
+{
+ setCentralWidget(m_browser);
+
+ auto fileMenu = menuBar()->addMenu("File");
+ auto toolbar = new QToolBar;
+ addToolBar(Qt::TopToolBarArea, toolbar);
+
+ auto action = fileMenu->addAction("Dump MetaObject...",
+ this, &MainWindow::showMetaObject);
+ action->setShortcut(Qt::CTRL + Qt::Key_D);
+ toolbar->addAction(action);
+
+ action = fileMenu->addAction("Quit", this, &QWidget::close);
+ action->setShortcut(Qt::CTRL + Qt::Key_Q);
+ toolbar->addAction(action);
+}
+
+void MainWindow::navigate(const QString &url)
+{
+ m_browser->Navigate(url);
+}
+
+void MainWindow::showMetaObject()
+{
+ auto mo = m_browser->metaObject();
+ QString dump;
+ {
+ QTextStream str(&dump);
+ str << *mo;
+ }
+ auto dialog = new TextDialog(dump, this);
+ dialog->setWindowTitle(QLatin1String("MetaObject of ") + QLatin1String(mo->className()));
+ dialog->setAttribute(Qt::WA_DeleteOnClose);
+ dialog->resize(screen()->geometry().size() * 2 / 3);
+ dialog->show();
+}
+
+int main(int argc, char *argv[])
+{
+ QCoreApplication::setAttribute(Qt::AA_UseHighDpiPixmaps);
+ QCoreApplication::setAttribute(Qt::AA_EnableHighDpiScaling);
+
+ QApplication a(argc, argv);
+
+ MainWindow w;
+ w.setWindowTitle(qVersion());
+ w.show();
+ w.navigate("https://qt.io/");
+
+ return a.exec();
+}
+
+#include "main.moc"
diff --git a/tests/manual/manual.pro b/tests/manual/manual.pro
new file mode 100644
index 0000000..5749606
--- /dev/null
+++ b/tests/manual/manual.pro
@@ -0,0 +1,2 @@
+TEMPLATE = subdirs
+SUBDIRS += axviewer dumpcpp testcontrol
diff --git a/tests/manual/shared/metaobjectdump.cpp b/tests/manual/shared/metaobjectdump.cpp
new file mode 100644
index 0000000..70a9737
--- /dev/null
+++ b/tests/manual/shared/metaobjectdump.cpp
@@ -0,0 +1,204 @@
+/****************************************************************************
+**
+** Copyright (C) 2020 The Qt Company Ltd.
+** Contact: https://www.qt.io/licensing/
+**
+** This file is part of the test suite of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:GPL-EXCEPT$
+** Commercial License Usage
+** Licensees holding valid commercial Qt licenses may use this file in
+** accordance with the commercial license agreement provided with the
+** Software or, alternatively, in accordance with the terms contained in
+** a written agreement between you and The Qt Company. For licensing terms
+** and conditions see https://www.qt.io/terms-conditions. For further
+** information use the contact form at https://www.qt.io/contact-us.
+**
+** GNU General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU
+** General Public License version 3 as published by the Free Software
+** Foundation with exceptions as appearing in the file LICENSE.GPL3-EXCEPT
+** included in the packaging of this file. Please review the following
+** information to ensure the GNU General Public License requirements will
+** be met: https://www.gnu.org/licenses/gpl-3.0.html.
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+#include "metaobjectdump.h"
+
+#include <QMetaMethod>
+#include <QMetaObject>
+#include <QTextStream>
+
+QT_USE_NAMESPACE
+
+using rightAlignNumber = QPair<int, int>; // Use as str << rightAlignNumber(value, width)
+
+QTextStream &operator<<(QTextStream &str, const rightAlignNumber &r)
+{
+ auto oldWidth = str.fieldWidth();
+ str.setFieldWidth(r.second);
+ auto oldAlignment = str.fieldAlignment();
+ str.setFieldAlignment(QTextStream::AlignRight);
+ str << r.first;
+ str.setFieldAlignment(oldAlignment);
+ str.setFieldWidth(oldWidth);
+ return str;
+}
+
+QTextStream &operator<<(QTextStream &str, const QMetaEnum &me)
+{
+ const int keyCount = me.keyCount();
+ str << me.name() << ' ' << keyCount << " keys";
+ if (me.isFlag())
+ str << " [flag]";
+ if (me.isScoped())
+ str << " [scoped]";
+ const int maxLogCount = std::min(6, keyCount);
+ str << " {";
+ for (int k = 0; k < maxLogCount; ++k) {
+ if (k)
+ str << ", ";
+ str << me.key(k) << " = " << me.value(k);
+ }
+ if (maxLogCount < keyCount)
+ str << ",...";
+ str << '}';
+ return str;
+}
+
+QTextStream &operator<<(QTextStream &str, const QMetaClassInfo &mc)
+{
+ str << '"' << mc.name() << "\": \"" << mc.value() << '"';
+ return str;
+}
+
+QTextStream &operator<<(QTextStream &str, const QMetaProperty &mp)
+{
+ str << mp.typeName() << ' ' << mp.name();
+ if (mp.isWritable())
+ str << " [writable]";
+ if (mp.isResettable())
+ str << " [resettable]";
+ if (mp.isDesignable())
+ str << " [designable]";
+ if (mp.isStored())
+ str << " [stored]";
+ if (mp.isUser())
+ str << " [user]";
+ if (mp.isConstant())
+ str << " [constant]";
+ if (mp.isFinal())
+ str << " [final]";
+ if (mp.isRequired())
+ str << " [required]";
+ if (mp.isFlagType())
+ str << " [flag]";
+ if (mp.isEnumType())
+ str << " [enum " << mp.enumerator().name() << ']';
+ if (mp.hasNotifySignal())
+ str << " [notify " << mp.notifySignal().name() << ']';
+ return str;
+}
+
+QTextStream &operator<<(QTextStream &str, const QMetaMethod &m)
+{
+ switch (m.access()) {
+ case QMetaMethod::Private:
+ str << "private ";
+ break;
+ case QMetaMethod::Protected:
+ str << "protected ";
+ break;
+ case QMetaMethod::Public:
+ break;
+ }
+ str << m.typeName() << ' ' << m.methodSignature();
+ switch (m.methodType()) {
+ case QMetaMethod::Method:
+ break;
+ case QMetaMethod::Signal:
+ str << " [signal]";
+ break;
+ case QMetaMethod::Slot:
+ str << " [slot]";
+ break;
+ case QMetaMethod::Constructor:
+ str << " [ct]";
+ break;
+ }
+ if (auto attributes = m.attributes()) {
+ str << " attributes: " << Qt::hex << Qt::showbase << attributes
+ << Qt::dec << Qt::noshowbase;
+ }
+ if (const int count = m.parameterCount()) {
+ str << " Parameters: ";
+ const auto parameterNames = m.parameterNames();
+ const auto parameterTypes = m.parameterTypes();
+ for (int p = 0; p < count; ++p) {
+ if (p)
+ str << ", ";
+ str << parameterTypes.at(p) << ' ' << parameterNames.at(p);
+ }
+ }
+ return str;
+}
+
+static void formatMetaObject(QTextStream &str, const QMetaObject *mo, const QByteArray &indent)
+{
+ str << indent << "--- " << mo->className() << " ---\n";
+
+ const int classInfoOffset = mo->classInfoOffset();
+ const int classInfoCount = mo->classInfoCount();
+ if (classInfoOffset < classInfoCount) {
+ str << indent << " Class Info of " << mo->className() << ": "
+ << classInfoOffset << ".." << classInfoCount << '\n';
+ for (int i = classInfoOffset; i < classInfoCount; ++i) {
+ str << indent << " " << rightAlignNumber(i, 3) << ' '
+ << mo->classInfo(i) << '\n';
+ }
+ }
+
+ const int enumOffset = mo->enumeratorOffset();
+ const int enumCount = mo->enumeratorCount();
+ if (enumOffset < enumCount) {
+ str << indent << " Enums of " << mo->className() << ": " << enumOffset
+ << ".." << enumCount << '\n';
+ for (int e = enumOffset; e < enumCount; ++e)
+ str << indent << " " << rightAlignNumber(e, 3) << ' ' << mo->enumerator(e) << '\n';
+ }
+
+ const int methodOffset = mo->methodOffset();
+ const int methodCount = mo->methodCount();
+ if (methodOffset < methodCount) {
+ str << indent << " Methods of " << mo->className() << ": " << methodOffset
+ << ".." << methodCount << '\n';
+ for (int m = methodOffset; m < methodCount; ++m)
+ str << indent << " " << rightAlignNumber(m, 3) << ' ' << mo->method(m) << '\n';
+ }
+
+ const int propertyOffset = mo->propertyOffset();
+ const int propertyCount = mo-> propertyCount();
+ if (propertyOffset < propertyCount) {
+ str << indent << " Properties of " << mo->className() << ": " << propertyOffset
+ << ".." << propertyCount << '\n';
+ for (int p = propertyOffset; p < propertyCount; ++p)
+ str << indent << " " << rightAlignNumber(p, 3) << ' ' << mo->property(p) << '\n';
+ }
+}
+
+QTextStream &operator<<(QTextStream &str, const QMetaObject &o)
+{
+ QVector<const QMetaObject *> klasses;
+ for (auto s = &o; s; s = s->superClass())
+ klasses.prepend(s);
+
+ QByteArray indent;
+ for (auto k : klasses) {
+ formatMetaObject(str, k, indent);
+ indent += " ";
+ }
+ return str;
+}
diff --git a/tests/manual/shared/metaobjectdump.h b/tests/manual/shared/metaobjectdump.h
new file mode 100644
index 0000000..b3bde57
--- /dev/null
+++ b/tests/manual/shared/metaobjectdump.h
@@ -0,0 +1,39 @@
+/****************************************************************************
+**
+** Copyright (C) 2020 The Qt Company Ltd.
+** Contact: https://www.qt.io/licensing/
+**
+** This file is part of the test suite of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:GPL-EXCEPT$
+** Commercial License Usage
+** Licensees holding valid commercial Qt licenses may use this file in
+** accordance with the commercial license agreement provided with the
+** Software or, alternatively, in accordance with the terms contained in
+** a written agreement between you and The Qt Company. For licensing terms
+** and conditions see https://www.qt.io/terms-conditions. For further
+** information use the contact form at https://www.qt.io/contact-us.
+**
+** GNU General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU
+** General Public License version 3 as published by the Free Software
+** Foundation with exceptions as appearing in the file LICENSE.GPL3-EXCEPT
+** included in the packaging of this file. Please review the following
+** information to ensure the GNU General Public License requirements will
+** be met: https://www.gnu.org/licenses/gpl-3.0.html.
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+#ifndef METAOBJECTDUMP_H
+#define METAOBJECTDUMP_H
+
+#include <QtGlobal>
+
+QT_FORWARD_DECLARE_STRUCT(QMetaObject);
+QT_FORWARD_DECLARE_CLASS(QTextStream);
+
+QTextStream &operator<<(QTextStream &str, const QMetaObject &o);
+
+#endif
diff --git a/tests/manual/shared/shared.pri b/tests/manual/shared/shared.pri
new file mode 100644
index 0000000..ffd18b3
--- /dev/null
+++ b/tests/manual/shared/shared.pri
@@ -0,0 +1,3 @@
+SOURCES += $$PWD/metaobjectdump.cpp $$PWD/textdialog.cpp
+HEADERS += $$PWD/metaobjectdump.h $$PWD/textdialog.h
+INCLUDEPATH += $$PWD
diff --git a/tests/manual/shared/textdialog.cpp b/tests/manual/shared/textdialog.cpp
new file mode 100644
index 0000000..f8ad7fc
--- /dev/null
+++ b/tests/manual/shared/textdialog.cpp
@@ -0,0 +1,49 @@
+/****************************************************************************
+**
+** Copyright (C) 2020 The Qt Company Ltd.
+** Contact: https://www.qt.io/licensing/
+**
+** This file is part of the test suite of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:GPL-EXCEPT$
+** Commercial License Usage
+** Licensees holding valid commercial Qt licenses may use this file in
+** accordance with the commercial license agreement provided with the
+** Software or, alternatively, in accordance with the terms contained in
+** a written agreement between you and The Qt Company. For licensing terms
+** and conditions see https://www.qt.io/terms-conditions. For further
+** information use the contact form at https://www.qt.io/contact-us.
+**
+** GNU General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU
+** General Public License version 3 as published by the Free Software
+** Foundation with exceptions as appearing in the file LICENSE.GPL3-EXCEPT
+** included in the packaging of this file. Please review the following
+** information to ensure the GNU General Public License requirements will
+** be met: https://www.gnu.org/licenses/gpl-3.0.html.
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+#include "textdialog.h"
+
+#include <QtWidgets/QDialogButtonBox>
+#include <QtWidgets/QPlainTextEdit>
+#include <QtWidgets/QVBoxLayout>
+
+#include <QtGui/QFontDatabase>
+
+TextDialog::TextDialog(const QString &text, QWidget *parent) : QDialog(parent)
+{
+ setWindowFlags(windowFlags() & ~Qt::WindowContextHelpButtonHint);
+ auto layout = new QVBoxLayout(this);
+ auto pe = new QPlainTextEdit(text, this);
+ pe->setReadOnly(true);
+ pe->setFont(QFontDatabase::systemFont(QFontDatabase::FixedFont));
+ layout->addWidget(pe);
+
+ auto buttonBox = new QDialogButtonBox(QDialogButtonBox::Close, this);
+ layout->addWidget(buttonBox);
+ connect(buttonBox, &QDialogButtonBox::rejected, this, &QDialog::reject);
+}
diff --git a/tests/manual/shared/textdialog.h b/tests/manual/shared/textdialog.h
new file mode 100644
index 0000000..74bfaf5
--- /dev/null
+++ b/tests/manual/shared/textdialog.h
@@ -0,0 +1,40 @@
+/****************************************************************************
+**
+** Copyright (C) 2020 The Qt Company Ltd.
+** Contact: https://www.qt.io/licensing/
+**
+** This file is part of the test suite of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:GPL-EXCEPT$
+** Commercial License Usage
+** Licensees holding valid commercial Qt licenses may use this file in
+** accordance with the commercial license agreement provided with the
+** Software or, alternatively, in accordance with the terms contained in
+** a written agreement between you and The Qt Company. For licensing terms
+** and conditions see https://www.qt.io/terms-conditions. For further
+** information use the contact form at https://www.qt.io/contact-us.
+**
+** GNU General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU
+** General Public License version 3 as published by the Free Software
+** Foundation with exceptions as appearing in the file LICENSE.GPL3-EXCEPT
+** included in the packaging of this file. Please review the following
+** information to ensure the GNU General Public License requirements will
+** be met: https://www.gnu.org/licenses/gpl-3.0.html.
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+#include <QtWidgets/QDialog>
+
+#ifndef TEXTDIALOG_H
+#define TEXTDIALOG_H
+
+class TextDialog : public QDialog
+{
+public:
+ explicit TextDialog(const QString &text, QWidget *parent = nullptr);
+};
+
+#endif