From 7422c56d67cd9b68718a02d47cb86b34a8bd008c Mon Sep 17 00:00:00 2001 From: Tommaso Cucinotta Date: Fri, 30 Dec 2011 15:31:56 +0000 Subject: [PATCH] Fixing consistency of replace actions in GUI with readonly status of target document buffer (i.e., it was possible to replace in readonly buffers!) See also http://comments.gmane.org/gmane.editors.lyx.devel/140074 git-svn-id: svn://svn.lyx.org/lyx/lyx-devel/trunk@40548 a592a061-630c-0410-9148-cb99ea01b6c8 --- src/BufferView.cpp | 9 ++++++++- src/frontends/qt4/FindAndReplace.cpp | 5 +++++ 2 files changed, 13 insertions(+), 1 deletion(-) diff --git a/src/BufferView.cpp b/src/BufferView.cpp index ba89032b1a..2820b7e46f 100644 --- a/src/BufferView.cpp +++ b/src/BufferView.cpp @@ -1059,7 +1059,6 @@ bool BufferView::getStatus(FuncRequest const & cmd, FuncStatus & flag) case LFUN_WORD_FIND: case LFUN_WORD_FIND_FORWARD: case LFUN_WORD_FIND_BACKWARD: - case LFUN_WORD_FINDADV: case LFUN_WORD_REPLACE: case LFUN_MARK_OFF: case LFUN_MARK_ON: @@ -1077,6 +1076,14 @@ bool BufferView::getStatus(FuncRequest const & cmd, FuncStatus & flag) flag.setEnabled(true); break; + case LFUN_WORD_FINDADV: { + FindAndReplaceOptions opt; + istringstream iss(to_utf8(cmd.argument())); + iss >> opt; + flag.setEnabled(opt.repl_buf_name.empty() + || !buffer_.isReadonly()); + } + case LFUN_LABEL_GOTO: { flag.setEnabled(!cmd.argument().empty() || getInsetByCode(cur, REF_CODE)); diff --git a/src/frontends/qt4/FindAndReplace.cpp b/src/frontends/qt4/FindAndReplace.cpp index d83132ebe0..49753a639f 100644 --- a/src/frontends/qt4/FindAndReplace.cpp +++ b/src/frontends/qt4/FindAndReplace.cpp @@ -67,6 +67,11 @@ FindAndReplaceWidget::FindAndReplaceWidget(GuiView & view) bool FindAndReplaceWidget::eventFilter(QObject * obj, QEvent * event) { + bool replace_enabled = view_.documentBufferView() && !view_.documentBufferView()->buffer().isReadonly(); + replace_work_area_->setEnabled(replace_enabled); + replacePB->setEnabled(replace_enabled); + replaceallPB->setEnabled(replace_enabled); + if (event->type() != QEvent::KeyPress || (obj != find_work_area_ && obj != replace_work_area_)) return QWidget::eventFilter(obj, event);