commit 40603a75521b73b84dad846a9273ce0da5da9379
Author: Richard Kimberly Heck <[email protected]>
Date: Wed Jan 6 03:50:47 2021 -0500
Fix bug #3964.
As suggested there, we attach ourselves to the newly created inset,
if we in fact just created an inset. (This will only matter if Apply
was clicked, so the dialog is still open, but I did the calcuation
anyway, as it seems cheap enough.) This allows the user to modify
that inset (e.g., change the format) and also prevents another click
on Apply, or OK, from creating another dialog.
I've also removed the override of disconnectOnApply(). It does not
work, anyway, I think because it only works with GuiDialog, not with
DialogView-based dialogs.
---
src/frontends/qt/GuiCitation.cpp | 21 +++++++++++++++++++++
src/frontends/qt/GuiCitation.h | 4 ----
2 files changed, 21 insertions(+), 4 deletions(-)
diff --git a/src/frontends/qt/GuiCitation.cpp b/src/frontends/qt/GuiCitation.cpp
index fe8fe28..e6df310 100644
--- a/src/frontends/qt/GuiCitation.cpp
+++ b/src/frontends/qt/GuiCitation.cpp
@@ -19,12 +19,14 @@
#include "FancyLineEdit.h"
#include "GuiApplication.h"
#include "GuiSelectionManager.h"
+#include "GuiView.h"
#include "qt_helpers.h"
#include "Buffer.h"
#include "BufferView.h"
#include "BufferParams.h"
#include "Citation.h"
+#include "Cursor.h"
#include "TextClass.h"
#include "FuncRequest.h"
@@ -196,6 +198,25 @@ void GuiCitation::applyView()
QString const after = textAfterED->text();
applyParams(choice, full, force, before, after);
+
+ // If we have just created a citation inset, then we want to attach the
+ // dialog to it. This (i) allows further modification of that inset and
+ // (ii) prevents an additional click on Apply or OK from unexpectedly
+ // creating another inset. (See #3964.)
+ GuiView & view = const_cast<GuiView &>(lyxview());
+ BufferView * bv = view.currentBufferView();
+ // should have one, but just to be safe...
+ if (bv) {
+ // are we attached to an inset already?
+ Inset * ins = bv->editedInset("citation");
+ if (!ins) {
+ // no, so we just inserted one, and now we are behind
it.
+ Cursor const & cur = bv->cursor();
+ ins = cur.prevInset();
+ if (ins)
+ bv->editInset("citation", ins);
+ }
+ }
}
diff --git a/src/frontends/qt/GuiCitation.h b/src/frontends/qt/GuiCitation.h
index 36a3eb2..948933a 100644
--- a/src/frontends/qt/GuiCitation.h
+++ b/src/frontends/qt/GuiCitation.h
@@ -79,10 +79,6 @@ private:
bool isBufferDependent() const override { return true; }
void saveSession(QSettings & settings) const override;
void restoreSession() override;
- /** Disconnect from the inset when the Apply button is pressed.
- * Allows easy insertion of multiple citations.
- */
- bool disconnectOnApply() const override { return true; }
//@}
///
--
lyx-cvs mailing list
[email protected]
http://lists.lyx.org/mailman/listinfo/lyx-cvs