From 6d4223c5d61fd42144cd1361e76c874c6384049b Mon Sep 17 00:00:00 2001 From: Eike Ziller Date: Tue, 17 Dec 2019 14:38:49 +0100 Subject: [PATCH] Do not show line ending option in read-only editors MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit This avoids showing the option for example in git log or blame views. The user also should not be able to actually change the line ending style of read-only editors. Fixes: QTCREATORBUG-23276 Change-Id: Ifa5cc9f663539928b4d5422b020e348b439684fa Reviewed-by: Orgad Shaneh Reviewed-by: André Hartmann Reviewed-by: Marius Sincovici --- src/plugins/texteditor/texteditor.cpp | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/src/plugins/texteditor/texteditor.cpp b/src/plugins/texteditor/texteditor.cpp index 2d349cecb70..ac84aca67c9 100644 --- a/src/plugins/texteditor/texteditor.cpp +++ b/src/plugins/texteditor/texteditor.cpp @@ -833,6 +833,10 @@ TextEditorWidgetPrivate::TextEditorWidgetPrivate(TextEditorWidget *parent) m_fileLineEnding->addItems(ExtraEncodingSettings::lineTerminationModeNames()); m_fileLineEnding->setContentsMargins(spacing, 0, spacing, 0); m_fileLineEndingAction = m_toolBar->addWidget(m_fileLineEnding); + m_fileLineEndingAction->setVisible(!q->isReadOnly()); + connect(q, &TextEditorWidget::readOnlyChanged, this, [this] { + m_fileLineEndingAction->setVisible(!q->isReadOnly()); + }); m_fileEncodingLabel = new FixedSizeClickLabel; m_fileEncodingLabel->setContentsMargins(spacing, 0, spacing, 0);