Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
24 changes: 23 additions & 1 deletion Desktop/modules/ribbonmodel.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,7 @@ RibbonModel::RibbonModel() : QAbstractListModel(DynamicModules::dynMods())
connect(DynamicModules::dynMods(), &DynamicModules::dynamicModuleUninstalled, this, &RibbonModel::removeDynamicRibbonButtonModel );
connect(DynamicModules::dynMods(), &DynamicModules::dynamicModuleReplaced, this, &RibbonModel::dynamicModuleReplaced );
connect(DynamicModules::dynMods(), &DynamicModules::dynamicModuleChanged, this, &RibbonModel::dynamicModuleChanged );
connect(PreferencesModel::prefs(), &PreferencesModel::languageCodeChanged, this, &RibbonModel::reloadModulesMenu );
}

void RibbonModel::loadModules(std::vector<std::string> commonModulesToLoad, std::vector<std::string> extraModulesToLoad)
Expand Down Expand Up @@ -110,6 +111,27 @@ void RibbonModel::loadModules(std::vector<std::string> commonModulesToLoad, std:
}
}

// So we reload the special module to ensure translations can be hot updated.
void RibbonModel::reloadModulesMenu()
{
std::vector<std::string> allButtons;

for (const auto& rowButtons : _buttonNames)
{
for (const auto& button : rowButtons)
{
allButtons.push_back(button);
}
}

for (const auto& button : allButtons)
{
removeRibbonButtonModel(button);
}

loadModules();
}

void RibbonModel::addRibbonButtonModelFromDynamicModule(Modules::DynamicModule * module)
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I don't think this is the right way to do this. The loadModules(I) will recreate the modules, make some memory leakage (_entriesInsert, _entriesDelete, etc...), this is quite dangerous I think.
I don't understand why the 'special ribbon entries' are not translated, and the module ribbon buttons are. I remember that @JorisGoosen knew why. Maybe it is better to wait for his return of his holidays.

{
addRibbonButtonModel(new RibbonButton(this, module), size_t(RowType::Analyses));
Expand Down Expand Up @@ -308,7 +330,7 @@ void RibbonModel::removeRibbonButtonModel(std::string moduleName)
if(!isModuleName(moduleName))
return;

for(size_t row=0; row<size_t(RowType::Data); row++)
for(size_t row=0; row<=size_t(RowType::Data); row++)
{
int indexRemoved = -1;

Expand Down
2 changes: 1 addition & 1 deletion Desktop/modules/ribbonmodel.h
Original file line number Diff line number Diff line change
Expand Up @@ -66,7 +66,7 @@ class RibbonModel : public QAbstractListModel
virtual QHash<int, QByteArray> roleNames() const override;

void loadModules(std::vector<std::string> commonModulesToLoad = {}, std::vector<std::string> extraModulesToLoad = {});

void reloadModulesMenu();
void addSpecialRibbonButtonsEarly();
void addSpecialRibbonButtonsLate();
void setDataMode(bool data);
Expand Down
6 changes: 3 additions & 3 deletions Modules/pkgdepends.lock
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,7 @@
},
"curl": {
"Package": "curl",
"Version": "5.0.2",
"Version": "5.2.1",
"Source": "Repository",
"Repository": "CRAN",
"Requirements": [
Expand Down Expand Up @@ -99,7 +99,7 @@
},
"jsonlite": {
"Package": "jsonlite",
"Version": "1.8.7",
"Version": "1.8.8",
"Source": "Repository",
"Repository": "CRAN",
"Requirements": [
Expand All @@ -109,7 +109,7 @@
},
"lpSolve": {
"Package": "lpSolve",
"Version": "5.6.18",
"Version": "5.6.20",
"Source": "Repository",
"Repository": "CRAN",
"Hash": "12c7a918599d5700e4265dd8a21f684f"
Expand Down