[LyX/master] Fix bug #11497

Richard Kimberly Heck rikiheck at lyx.org
Thu Sep 7 01:35:26 UTC 2023


commit fdcb160ed85bedf66b03072115b699fac673904a
Author: Daniel Ramoeller <d.lyx at web.de>
Date:   Wed Sep 6 22:52:42 2023 -0400

    Fix bug #11497
---
 src/frontends/qt/GuiLabel.cpp |   16 ++++++++++++++--
 src/frontends/qt/GuiLabel.h   |    2 ++
 2 files changed, 16 insertions(+), 2 deletions(-)

diff --git a/src/frontends/qt/GuiLabel.cpp b/src/frontends/qt/GuiLabel.cpp
index 78d1e3f..ab902b1 100644
--- a/src/frontends/qt/GuiLabel.cpp
+++ b/src/frontends/qt/GuiLabel.cpp
@@ -46,7 +46,7 @@ void GuiLabel::paramsToDialog(Inset const * inset)
 {
 	InsetLabel const * label = static_cast<InsetLabel const *>(inset);
 	InsetCommandParams const & params = label->params();
-	keywordED->setText(toqstr(params["name"]));
+	setKeyword(toqstr(params["name"]));
 }
 
 
@@ -63,7 +63,7 @@ bool GuiLabel::initialiseParams(std::string const & sdata)
 	InsetCommandParams p(insetCode());
 	if (!InsetCommand::string2params(sdata, p))
 		return false;
-	keywordED->setText(toqstr(p["name"]));
+	setKeyword(toqstr(p["name"]));
 	return true;
 }
 
@@ -76,6 +76,18 @@ bool GuiLabel::checkWidgets(bool readonly) const
 	return !keywordED->text().isEmpty();
 }
 
+
+void GuiLabel::setKeyword(QString const & keyword)
+{
+	keywordED->setText(keyword);
+	// select without prefix
+	int const colonPos = keyword.indexOf(':');
+	if (colonPos == -1)
+		keywordED->selectAll();
+	else
+		keywordED->setSelection(colonPos + 1, keyword.length() - colonPos + 1);
+}
+
 } // namespace frontend
 } // namespace lyx
 
diff --git a/src/frontends/qt/GuiLabel.h b/src/frontends/qt/GuiLabel.h
index 7eb6fd4..0997a23 100644
--- a/src/frontends/qt/GuiLabel.h
+++ b/src/frontends/qt/GuiLabel.h
@@ -37,6 +37,8 @@ private:
 	docstring dialogToParams() const override;
 	bool checkWidgets(bool readonly) const override;
 	bool initialiseParams(std::string const &) override;
+	///
+	void setKeyword(QString const & keyword);
 	//@}
 };
 


More information about the lyx-cvs mailing list