Commit 62a2b689 authored by WINTZ Julien's avatar WINTZ Julien

Enhancing menu framework API.

parent b457bf70
......@@ -18,6 +18,7 @@
#include "dtkWidgetsParameter.h"
#include "dtkWidgetsMenu.h"
#include "dtkWidgetsMenuBar.h"
#include "dtkWidgetsMenuBar_p.h"
#include <dtkCore/dtkCoreParameter>
......@@ -96,7 +97,6 @@ dtkWidgetsParameterMenuBarGenerator::dtkWidgetsParameterMenuBarGenerator(const Q
return;
}
if (menu_file.open(QFile::ReadOnly)) {
QJsonParseError menu_error;
QJsonDocument menu_document = QJsonDocument::fromJson(menu_file.readAll(), &menu_error);
......@@ -144,6 +144,27 @@ void dtkWidgetsParameterMenuBarGenerator::populate(dtkWidgetsMenuBar *menubar)
}
}
void dtkWidgetsParameterMenuBarGenerator::populate(dtkWidgetsMenuBarContainer *container)
{
dtkWidgetsMenuBar *dummy = new dtkWidgetsMenuBar;
for(auto it = d->menu.begin(); it != d->menu.end(); ++it) {
if(it->isObject()) {
QJsonObject content_object = it->toObject();
if(content_object.contains("group")) {
QJsonObject group_object = content_object["group"].toObject();
d->parseGroup(dummy, group_object);
} else {
qWarning() << Q_FUNC_INFO << "'contents' sections are expected to contain objects only. Non object entry is ignored.";
}
} else {
qWarning() << Q_FUNC_INFO << "'contents' sections are expected to contain objects only. Non object entry is ignored.";
}
}
container->build(dummy->menus());
}
dtkCoreParameters dtkWidgetsParameterMenuBarGenerator::parameters(void) const
{
return d->parameters;
......
......@@ -21,6 +21,7 @@
#include <QtCore>
class dtkWidgetsMenuBar;
class dtkWidgetsMenuBarContainer;
class dtkCoreParameter;
// ///////////////////////////////////////////////////////////////////
......@@ -34,7 +35,8 @@ public:
~dtkWidgetsParameterMenuBarGenerator(void);
public:
void populate(dtkWidgetsMenuBar *menubar);
void populate(dtkWidgetsMenuBar *);
void populate(dtkWidgetsMenuBarContainer *);
public:
dtkCoreParameters parameters(void) const;
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment