[education/rkward] rkward: Partially revert c7f10c59, disabling the individual action, instead (previous solution did not function as intended).

Thomas Friedrichsmeier null at kde.org
Mon Jun 13 19:46:14 BST 2022


Git commit 4af0ae2591ec68a12c2186c268086104fbb256a4 by Thomas Friedrichsmeier.
Committed on 13/06/2022 at 18:44.
Pushed by tfry into branch 'master'.

Partially revert c7f10c59, disabling the individual action, instead (previous solution did not function as intended).

Also show search terms as section header. If a selection is present, use that as search term, instead of guessing current symbol.

M  +11   -4    rkward/misc/rkstandardactions.cpp
M  +5    -1    rkward/rkconsole.cpp
M  +7    -4    rkward/windows/rkcommandeditorwindow.cpp

https://invent.kde.org/education/rkward/commit/4af0ae2591ec68a12c2186c268086104fbb256a4

diff --git a/rkward/misc/rkstandardactions.cpp b/rkward/misc/rkstandardactions.cpp
index 72e0fb55..a66fbfef 100644
--- a/rkward/misc/rkstandardactions.cpp
+++ b/rkward/misc/rkstandardactions.cpp
@@ -121,13 +121,19 @@ public slots:
 	void init () {
 		RK_TRACE (MISC);
 		QString symbol, package;
+		bool enabled = true;
 		provider->currentHelpContext (&symbol, &package);
-		menu->menuAction()->setEnabled(!symbol.isEmpty());
-		if (symbol.isEmpty()) return;
-
-		actions->setSelectedText(symbol + " " + package + " R");
+		QString searchtext = symbol + " " + package + " R";
+		actions->setSelectedText(searchtext);
 		menu->clear();
 
+		if (symbol.isEmpty()) {
+			menu->addSection(i18n("[No keyword detected]"));
+			enabled = false;
+		} else {
+			menu->addSection(searchtext);
+		}
+
 		// Coerce WebshortcutsMenu to single level
 		if (container) container->deleteLater();
 		container = new QMenu;
@@ -141,6 +147,7 @@ public slots:
 		if (actions.isEmpty()) actions = cactions;
 		for (int i = 0; i < actions.count(); ++i) {
 			menu->addAction(actions[i]);
+			actions[i]->setEnabled(enabled || (i == actions.count() - 1));
 		}
 	};
 private:
diff --git a/rkward/rkconsole.cpp b/rkward/rkconsole.cpp
index 967d37c3..d4701b9f 100644
--- a/rkward/rkconsole.cpp
+++ b/rkward/rkconsole.cpp
@@ -825,7 +825,11 @@ void RKConsole::currentHelpContext (QString* symbol, QString* package) {
 	RK_TRACE (APP);
 	Q_UNUSED (package);
 
-	*symbol = RKCommonFunctions::getCurrentSymbol (currentEditingLine (), currentCursorPositionInCommand ());
+	if (view->selection()) {
+		*symbol = view->selectionText();
+	} else {
+		*symbol = RKCommonFunctions::getCurrentSymbol (currentEditingLine (), currentCursorPositionInCommand ());
+	}
 }
 
 void RKConsole::initializeActions (KActionCollection *ac) {
diff --git a/rkward/windows/rkcommandeditorwindow.cpp b/rkward/windows/rkcommandeditorwindow.cpp
index 483b762c..b3fc4f35 100644
--- a/rkward/windows/rkcommandeditorwindow.cpp
+++ b/rkward/windows/rkcommandeditorwindow.cpp
@@ -764,10 +764,13 @@ void RKCommandEditorWindow::currentHelpContext (QString *symbol, QString *packag
 	RK_TRACE (COMMANDEDITOR);
 	Q_UNUSED (package);
 
-	KTextEditor::Cursor c = m_view->cursorPosition();
-	QString line = m_doc->line(c.line ()) + ' ';
-
-	*symbol = RKCommonFunctions::getCurrentSymbol (line, c.column ());
+	if (m_view->selection()) {
+		*symbol = m_view->selectionText();
+	} else {
+		KTextEditor::Cursor c = m_view->cursorPosition();
+		QString line = m_doc->line(c.line()) + ' ';
+		*symbol = RKCommonFunctions::getCurrentSymbol(line, c.column());
+	}
 }
 
 QString RKCommandEditorWindow::provideContext (int line_rev) {


More information about the rkward-tracker mailing list