diff options
author | Eike Ziller <eike.ziller@qt.io> | 2024-02-06 15:21:13 +0100 |
---|---|---|
committer | Eike Ziller <eike.ziller@qt.io> | 2024-02-12 07:44:19 +0000 |
commit | 7a055a2f0ad7bd99eb5629f8ce6dfa5ae7a27080 (patch) | |
tree | 75fe80388a0a12ea48a12c7d44937ccc85843812 | |
parent | 971bcb1a5abd396819510644e55ef437978adcd5 (diff) |
OutputWindow: Add "Save Contents" to context menu
And give individual output windows the option to set a default file name.
Change-Id: If3090063055c1b37f4f2d63b971fe0476f11806e
Reviewed-by: Orgad Shaneh <orgads@gmail.com>
Reviewed-by: André Hartmann <aha_1980@gmx.de>
Reviewed-by: <github-actions-qt-creator@cristianadam.eu>
Reviewed-by: Tasuku Suzuki <tasuku.suzuki@signal-slot.co.jp>
-rw-r--r-- | src/plugins/coreplugin/outputwindow.cpp | 14 | ||||
-rw-r--r-- | src/plugins/coreplugin/outputwindow.h | 2 | ||||
-rw-r--r-- | src/plugins/projectexplorer/appoutputpane.cpp | 2 | ||||
-rw-r--r-- | src/plugins/projectexplorer/compileoutputwindow.cpp | 2 |
4 files changed, 20 insertions, 0 deletions
diff --git a/src/plugins/coreplugin/outputwindow.cpp b/src/plugins/coreplugin/outputwindow.cpp index ca0de97456..dbbcdde585 100644 --- a/src/plugins/coreplugin/outputwindow.cpp +++ b/src/plugins/coreplugin/outputwindow.cpp @@ -73,6 +73,8 @@ public: QTimer scrollTimer; QElapsedTimer lastMessage; QHash<unsigned int, QPair<int, int>> taskPositions; + //: default file name suggested for saving text from output views + QString outputFileNameHint{Tr::tr("output.txt")}; }; } // namespace Internal @@ -290,6 +292,13 @@ void OutputWindow::contextMenuEvent(QContextMenuEvent *event) adaptContextMenu(menu, event->pos()); menu->addSeparator(); + QAction *saveAction = menu->addAction(Tr::tr("Save Contents...")); + connect(saveAction, &QAction::triggered, this, [this] { + QFileDialog::saveFileContent(toPlainText().toUtf8(), d->outputFileNameHint); + }); + saveAction->setEnabled(!document()->isEmpty()); + + menu->addSeparator(); QAction *clearAction = menu->addAction(Tr::tr("Clear")); connect(clearAction, &QAction::triggered, this, [this] { clear(); }); clearAction->setEnabled(!document()->isEmpty()); @@ -368,6 +377,11 @@ void OutputWindow::updateFilterProperties( filterNewContent(); } +void OutputWindow::setOutputFileNameHint(const QString &fileName) +{ + d->outputFileNameHint = fileName; +} + void OutputWindow::filterNewContent() { QTextBlock lastBlock = document()->findBlockByNumber(d->lastFilteredBlockNumber); diff --git a/src/plugins/coreplugin/outputwindow.h b/src/plugins/coreplugin/outputwindow.h index cfcea8aae0..cd44e5678e 100644 --- a/src/plugins/coreplugin/outputwindow.h +++ b/src/plugins/coreplugin/outputwindow.h @@ -67,6 +67,8 @@ public: bool regexp, bool isInverted); + void setOutputFileNameHint(const QString &fileName); + signals: void wheelZoom(); diff --git a/src/plugins/projectexplorer/appoutputpane.cpp b/src/plugins/projectexplorer/appoutputpane.cpp index 898acaba2a..94e2694acc 100644 --- a/src/plugins/projectexplorer/appoutputpane.cpp +++ b/src/plugins/projectexplorer/appoutputpane.cpp @@ -429,6 +429,8 @@ void AppOutputPane::createNewOutputWindow(RunControl *rc) ow->setWindowIcon(Icons::WINDOW.icon()); ow->setWordWrapEnabled(m_settings.wrapOutput); ow->setMaxCharCount(m_settings.maxCharCount); + //: file name suggested for saving application output, %1 = run configuration display name + ow->setOutputFileNameHint(Tr::tr("application-output-%1.txt").arg(rc->displayName())); auto updateFontSettings = [ow] { ow->setBaseFont(TextEditor::TextEditorSettings::fontSettings().font()); diff --git a/src/plugins/projectexplorer/compileoutputwindow.cpp b/src/plugins/projectexplorer/compileoutputwindow.cpp index 8d2b12983b..c5255d127f 100644 --- a/src/plugins/projectexplorer/compileoutputwindow.cpp +++ b/src/plugins/projectexplorer/compileoutputwindow.cpp @@ -61,6 +61,8 @@ CompileOutputWindow::CompileOutputWindow(QAction *cancelBuildAction) : m_outputWindow->setReadOnly(true); m_outputWindow->setUndoRedoEnabled(false); m_outputWindow->setMaxCharCount(Core::Constants::DEFAULT_MAX_CHAR_COUNT); + //: file name suggested for saving compile output + m_outputWindow->setOutputFileNameHint(Tr::tr("compile-output.txt")); Utils::ProxyAction *cancelBuildProxyButton = Utils::ProxyAction::proxyActionWithIcon(cancelBuildAction, |