diff --git a/docs/API/knut/rcdocument.md b/docs/API/knut/rcdocument.md
index 02747946..f6a956c2 100644
--- a/docs/API/knut/rcdocument.md
+++ b/docs/API/knut/rcdocument.md
@@ -31,6 +31,7 @@ import Knut
|-|-|
|[ToolBar](../knut/toolbar.md) |**[action](#action)**(string id)|
|array<[Action](../knut/action.md)> |**[actionsFromMenu](#actionsFromMenu)**(string menuId)|
+|array<[Action](../knut/action.md)> |**[actionsFromMenuForLanguage](#actionsFromMenuForLanguage)**(string menuId, string language)|
|array<[Action](../knut/action.md)> |**[actionsFromToolbar](#actionsFromToolbar)**(string toolBarId)|
|void |**[convertActions](#convertActions)**(int flags)|
||**[convertAssets](#convertAssets)**(int flags)|
@@ -41,6 +42,7 @@ import Knut
|bool |**[mergeLanguages](#mergeLanguages)**()|
|bool |**[previewDialog](#previewDialog)**([Widget](../knut/widget.md) dialog)|
|[Menu](../knut/menu.md) |**[ribbon](#ribbon)**(string id)|
+|[Menu](../knut/menu.md) |**[ribbonForLanguage](#ribbonForLanguage)**(string id, string language)|
|string |**[string](#string)**(string id)|
|string |**[stringForDialog](#stringForDialog)**(string dialogId, string id)|
|string |**[stringForDialogAndLanguage](#stringForDialogAndLanguage)**(string language, string dialogId, string id)|
@@ -122,6 +124,10 @@ Returns the action for the given `id`.
Returns all actions used in the menu `menuId`.
+#### array<[Action](../knut/action.md)> **actionsFromMenuForLanguage**(string menuId, string language)
+
+Returns all actions used in the menu `menuId` for language `language`.
+
#### array<[Action](../knut/action.md)> **actionsFromToolbar**(string toolBarId)
Returns all actions used in the toolbar `toolBarId`.
@@ -191,6 +197,10 @@ Previews the result of the conversion RC->UI
Returns the ribbon for the given `id`.
+#### [Menu](../knut/menu.md) **ribbonForLanguage**(string id, string language)
+
+Returns the ribbon for the given `id` for specific `language`.
+
#### string **string**(string id)
Returns the string for the given `id`.
diff --git a/src/core/rcdocument.cpp b/src/core/rcdocument.cpp
index e8b10f15..780433fd 100644
--- a/src/core/rcdocument.cpp
+++ b/src/core/rcdocument.cpp
@@ -296,6 +296,24 @@ RcCore::Ribbon RcDocument::ribbon(const QString &id) const
return {};
}
+/*!
+ * \qmlmethod Menu RcDocument::ribbonForLanguage(string id, string language)
+ * Returns the ribbon for the given `id` for specific `language`.
+ */
+RcCore::Ribbon RcDocument::ribbonForLanguage(const QString &id, const QString &language) const
+{
+ LOG(id);
+
+ if (m_rcFile.isValid && m_rcFile.data.contains(language)) {
+ const RcCore::Data data = const_cast(&m_rcFile)->data[language];
+ if (auto ribbon = data.ribbon(id)) {
+ const_cast(ribbon)->load();
+ return *ribbon;
+ }
+ }
+ return {};
+}
+
QStringList RcDocument::dialogIds() const
{
LOG();
diff --git a/src/core/rcdocument.h b/src/core/rcdocument.h
index 67a2ee8d..02ce326b 100644
--- a/src/core/rcdocument.h
+++ b/src/core/rcdocument.h
@@ -80,6 +80,7 @@ class RcDocument : public Document
Q_INVOKABLE RcCore::Menu menu(const QString &id) const;
Q_INVOKABLE RcCore::Ribbon ribbon(const QString &id) const;
+ Q_INVOKABLE RcCore::Ribbon ribbonForLanguage(const QString &id, const QString &language) const;
QStringList dialogIds() const;
QStringList menuIds() const;
diff --git a/src/rccore/ribbon.cpp b/src/rccore/ribbon.cpp
index ebea4469..fa75b4fe 100644
--- a/src/rccore/ribbon.cpp
+++ b/src/rccore/ribbon.cpp
@@ -10,6 +10,7 @@
#include "ribbon.h"
#include "utils/log.h"
+#include
#include
@@ -264,6 +265,34 @@ bool Ribbon::load()
return true;
}
+/*!
+ * \qmlmethod RibbonElement Ribbon::elementFromId(string id)
+ * This method returns RibbonElement from identifier `id`.
+ */
+RibbonElement Ribbon::elementFromId(const QString &id) const
+{
+ const auto menuElements = menu.elements;
+ auto result = kdalgorithms::find_if(menuElements, [&id](const auto &item) {
+ return item.id == id;
+ });
+ if (result) {
+ return *result;
+ }
+
+ const auto categoriesElements = categories;
+ for (const auto &cat : categoriesElements) {
+ for (const auto &panel : cat.panels) {
+ auto result = kdalgorithms::find_if(panel.elements, [&id](const auto &item) {
+ return item.id == id;
+ });
+ if (result) {
+ return *result;
+ }
+ }
+ }
+ return {};
+}
+
bool operator==(const RibbonElement &lhs, const RibbonElement &rhs)
{
return lhs.id == rhs.id;
diff --git a/src/rccore/ribbon.h b/src/rccore/ribbon.h
index e22849c0..a897da01 100644
--- a/src/rccore/ribbon.h
+++ b/src/rccore/ribbon.h
@@ -125,6 +125,7 @@ struct Ribbon
QString fileName;
bool load();
+ Q_INVOKABLE RcCore::RibbonElement elementFromId(const QString &id) const;
};
} // namespace RcCore