forked from qt-creator/qt-creator
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>
This commit is contained in:
@@ -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
|
||||
@@ -289,6 +291,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(); });
|
||||
@@ -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);
|
||||
|
@@ -67,6 +67,8 @@ public:
|
||||
bool regexp,
|
||||
bool isInverted);
|
||||
|
||||
void setOutputFileNameHint(const QString &fileName);
|
||||
|
||||
signals:
|
||||
void wheelZoom();
|
||||
|
||||
|
@@ -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());
|
||||
|
@@ -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,
|
||||
|
Reference in New Issue
Block a user