diff options
author | Eike Ziller <eike.ziller@qt.io> | 2016-08-31 15:39:52 +0200 |
---|---|---|
committer | Eike Ziller <eike.ziller@qt.io> | 2016-09-05 13:00:54 +0000 |
commit | f38531effb59717c642d58c01a22127e8d1542ac (patch) | |
tree | 889f5d8923fa619bc76b132bcb22484393f0c5cb /src/plugins/help/helpplugin.cpp | |
parent | 9a0a2a7d27e26047b213640e3b695ded04ac7fdd (diff) |
Add a menu entry for copying system information
Which outputs the information from qtdiag, installed plugins,
and general Qt Creator build information.
Task-number: QTCREATORBUG-16135
Change-Id: I618b9883369bae45006bb109f8757e89b091b882
Reviewed-by: David Schulz <david.schulz@qt.io>
Diffstat (limited to 'src/plugins/help/helpplugin.cpp')
-rw-r--r-- | src/plugins/help/helpplugin.cpp | 56 |
1 files changed, 56 insertions, 0 deletions
diff --git a/src/plugins/help/helpplugin.cpp b/src/plugins/help/helpplugin.cpp index fc1603a9cf..f0238a7100 100644 --- a/src/plugins/help/helpplugin.cpp +++ b/src/plugins/help/helpplugin.cpp @@ -79,9 +79,12 @@ #include <utils/theme/theme.h> #include <utils/tooltip/tooltip.h> +#include <QClipboard> +#include <QDialog> #include <QDir> #include <QFileInfo> #include <QLibraryInfo> +#include <QPlainTextEdit> #include <QTimer> #include <QTranslator> #include <qplugin.h> @@ -208,6 +211,11 @@ bool HelpPlugin::initialize(const QStringList &arguments, QString *error) ActionManager::actionContainer(Core::Constants::M_HELP)->addAction(cmd, Core::Constants::G_HELP_SUPPORT); connect(action, &QAction::triggered, this, &HelpPlugin::slotReportBug); + action = new QAction(tr("System Information..."), this); + cmd = ActionManager::registerAction(action, "Help.SystemInformation"); + ActionManager::actionContainer(Core::Constants::M_HELP)->addAction(cmd, Core::Constants::G_HELP_SUPPORT); + connect(action, &QAction::triggered, this, &HelpPlugin::slotSystemInformation); + if (ActionContainer *windowMenu = ActionManager::actionContainer(Core::Constants::M_WINDOW)) { // reuse EditorManager constants to avoid a second pair of menu actions // Goto Previous In History Action @@ -647,6 +655,54 @@ void HelpPlugin::slotReportBug() QDesktopServices::openUrl(QUrl("https://bugreports.qt.io")); } +class DialogClosingOnEscape : public QDialog +{ +public: + DialogClosingOnEscape(QWidget *parent = 0) : QDialog(parent) {} + bool event(QEvent *event) + { + if (event->type() == QEvent::ShortcutOverride) { + QKeyEvent *ke = static_cast<QKeyEvent *>(event); + if (ke->key() == Qt::Key_Escape && !ke->modifiers()) { + ke->accept(); + return true; + } + } + return QDialog::event(event); + } +}; + +void HelpPlugin::slotSystemInformation() +{ + auto dialog = new DialogClosingOnEscape(ICore::dialogParent()); + dialog->setAttribute(Qt::WA_DeleteOnClose); + dialog->setModal(true); + dialog->setWindowTitle(tr("System Information")); + auto layout = new QVBoxLayout; + dialog->setLayout(layout); + auto intro = new QLabel(tr("Use the following to provide more detailed information about your system to bug reports:")); + intro->setWordWrap(true); + layout->addWidget(intro); + const QString text = "{noformat}\n" + ICore::systemInformation() + "\n{noformat}"; + auto info = new QPlainTextEdit; + info->setPlainText(text); + layout->addWidget(info); + auto buttonBox = new QDialogButtonBox; + buttonBox->addButton(QDialogButtonBox::Cancel); + buttonBox->addButton(tr("Copy to Clipboard"), QDialogButtonBox::AcceptRole); + connect(buttonBox, &QDialogButtonBox::accepted, dialog, &QDialog::accept); + connect(buttonBox, &QDialogButtonBox::rejected, dialog, &QDialog::reject); + layout->addWidget(buttonBox); + connect(dialog, &QDialog::accepted, info, [info]() { + if (QApplication::clipboard()) + QApplication::clipboard()->setText(info->toPlainText()); + }); + connect(dialog, &QDialog::rejected, dialog, [dialog]{ dialog->close(); }); + dialog->resize(700, 400); + ICore::registerWindow(dialog, Context("Help.SystemInformation")); + dialog->show(); +} + void HelpPlugin::doSetupIfNeeded() { LocalHelpManager::setupGuiHelpEngine(); |