Commit bafc2113 authored by Laurent Montel's avatar Laurent Montel 😁
Browse files

Start to fix duplicate name

parent c75d4b70
Pipeline #45237 passed with stage
in 9 minutes and 50 seconds
......@@ -50,19 +50,20 @@ QString LoadGroupMenu::defaultWritableGroupPath()
void LoadGroupMenu::init()
{
//Load all ?
mGroupNames.clear();
const QString groupPath = LoadGroupMenu::defaultWritableGroupPath();
if (groupPath.isEmpty()) {
setEnabled(false);
return;
}
QDir dir(groupPath);
const QStringList groups = dir.entryList(QDir::Files | QDir::NoDotAndDotDot);
if (groups.isEmpty()) {
mGroupNames = dir.entryList(QDir::Files | QDir::NoDotAndDotDot);
if (mGroupNames.isEmpty()) {
setEnabled(false);
return;
}
setEnabled(true);
for (const QString &file : groups) {
for (const QString &file : mGroupNames) {
QAction *act = addAction(file);
const QString fullPath = groupPath + QLatin1Char('/') + file;
connect(act, &QAction::triggered, this, [this, fullPath] {
......@@ -73,3 +74,13 @@ void LoadGroupMenu::init()
QAction *manageGroup = addAction(i18n("Manage Group"));
connect(manageGroup, &QAction::triggered, this, &LoadGroupMenu::manageGroupRequested);
}
QStringList LoadGroupMenu::groupNames() const
{
return mGroupNames;
}
void LoadGroupMenu::setGroupNames(const QStringList &groupNames)
{
mGroupNames = groupNames;
}
......@@ -34,12 +34,16 @@ public:
static Q_REQUIRED_RESULT QString defaultWritableGroupPath();
Q_REQUIRED_RESULT QStringList groupNames() const;
void setGroupNames(const QStringList &groupNames);
Q_SIGNALS:
void loadGroupRequested(const QString &filePath);
void manageGroupRequested();
private:
void init();
QStringList mGroupNames;
};
#endif // LOADGROUPMENU_H
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