diff options
Diffstat (limited to 'tools/testcon/mainwindow.cpp')
-rw-r--r-- | tools/testcon/mainwindow.cpp | 64 |
1 files changed, 58 insertions, 6 deletions
diff --git a/tools/testcon/mainwindow.cpp b/tools/testcon/mainwindow.cpp index bc69264..682c8e5 100644 --- a/tools/testcon/mainwindow.cpp +++ b/tools/testcon/mainwindow.cpp @@ -35,11 +35,14 @@ #include <QtWidgets/QMdiArea> #include <QtWidgets/QMdiSubWindow> +#include <QtWidgets/QDialogButtonBox> #include <QtWidgets/QFileDialog> #include <QtWidgets/QInputDialog> #include <QtWidgets/QMessageBox> #include <QtGui/QCloseEvent> +#include <QtGui/QPixmap> #include <QtCore/QDebug> +#include <QtCore/QLibraryInfo> #include <QtCore/qt_windows.h> #include <ActiveQt/QAxScriptManager> #include <ActiveQt/QAxSelect> @@ -109,7 +112,8 @@ QAxWidget *MainWindow::activeAxWidget() const QList<QAxWidget *> MainWindow::axWidgets() const { QList<QAxWidget *> result; - foreach (const QMdiSubWindow *subWindow, m_mdiArea->subWindowList()) + const QList<QMdiSubWindow *> mdiSubWindows = m_mdiArea->subWindowList(); + for (const QMdiSubWindow *subWindow : mdiSubWindows) if (QAxWidget *axWidget = qobject_cast<QAxWidget *>(subWindow->widget())) result.push_back(axWidget); return result; @@ -126,9 +130,11 @@ bool MainWindow::addControlFromClsid(const QString &clsid) updateGUI(); } else { delete container; - QMessageBox::information(this, - tr("Error Loading Control"), - tr("The control \"%1\" could not be loaded.").arg(clsid)); + logTabWidget->setCurrentIndex(logTabWidget->count() - 1); + const QString message = + tr("The control \"%1\" could not be loaded." + " See the \"Debug log\" tab for details.").arg(clsid); + QMessageBox::information(this, tr("Error Loading Control"), message); } return result; } @@ -395,7 +401,8 @@ bool MainWindow::loadScript(const QString &file) m_scripts->addObject(this); } - foreach (QAxWidget *axWidget, axWidgets()) { + const QList<QAxWidget *> axw = axWidgets(); + for (QAxWidget *axWidget : axw) { QAxBase *ax = axWidget; m_scripts->addObject(ax); } @@ -413,6 +420,50 @@ bool MainWindow::loadScript(const QString &file) #endif } +void MainWindow::on_actionAbout_Qt_triggered() +{ + QApplication::aboutQt(); +} + +class VersionDialog : public QDialog +{ +public: + explicit VersionDialog(QWidget *parent = nullptr); +}; + +const char aboutTextFormat[] = QT_TRANSLATE_NOOP("MainWindow", +"<h3>Testcon - An ActiveX Test Container</h3>\nVersion: %1<br/><br/>\n" +"This application implements a generic test container for ActiveX controls." +"<br/><br/>Copyright (C) %2 The Qt Company Ltd."); + +VersionDialog::VersionDialog(QWidget *parent) : QDialog(parent) +{ + setWindowFlags(windowFlags() & ~Qt::WindowContextHelpButtonHint); + setWindowTitle(tr("About Testcon")); + QGridLayout *layout = new QGridLayout(this); + QLabel *logoLabel = new QLabel; + logoLabel->setPixmap(QStringLiteral(":/qt-project.org/qmessagebox/images/qtlogo-64.png")); + const QString aboutText = + tr(aboutTextFormat).arg(QLatin1String(QLibraryInfo::build()), + QStringLiteral("2017")); + QLabel *aboutLabel = new QLabel(aboutText); + aboutLabel->setTextInteractionFlags(Qt::TextBrowserInteraction); + aboutLabel->setWordWrap(true); + aboutLabel->setOpenExternalLinks(true); + + QDialogButtonBox *buttonBox = new QDialogButtonBox(QDialogButtonBox::Close); + connect(buttonBox , &QDialogButtonBox::rejected, this, &QDialog::reject); + layout->addWidget(logoLabel, 0, 0, 1, 1); + layout->addWidget(aboutLabel, 0, 1, 4, 4); + layout->addWidget(buttonBox, 4, 2, 1, 1); +} + +void MainWindow::on_actionAbout_Testcon_triggered() +{ + VersionDialog versionDialog(this); + versionDialog.exec(); +} + void MainWindow::updateGUI() { QAxWidget *container = activeAxWidget(); @@ -434,7 +485,8 @@ void MainWindow::updateGUI() if (m_dlgProperties) m_dlgProperties->setControl(hasControl ? container : 0); - foreach (QAxWidget *container, axWidgets()) { + const QList<QAxWidget *> axw = axWidgets(); + for (QAxWidget *container : axw) { container->disconnect(SIGNAL(signal(QString,int,void*))); if (actionLogSignals->isChecked()) connect(container, SIGNAL(signal(QString,int,void*)), this, SLOT(logSignal(QString,int,void*))); |