Commit a62cebbe authored by Jean-Loup Haberbusch's avatar Jean-Loup Haberbusch

FIX Code cleaning

parent eb2ad5f7
......@@ -229,7 +229,7 @@ void ImpMainWindow::initMenuBar() {
fileMenu = new QMenu(tr("&File"));
fileMenu->addAction(fileOpen);
openDataDirectoryMenuBuilder(fileMenu);
openDataDirectoryMenuBuilder();
fileMenu->addAction(fileClose);
fileMenu->addAction(fileCloseAll);
......@@ -543,7 +543,7 @@ void ImpMainWindow::editSettings() {
}
// check if there are anything to change in the data directory menu (for data directory manager)
ImpMainWindow::openDataDirectoryMenuBuilder(fileMenu);
ImpMainWindow::openDataDirectoryMenuBuilder();
}
// ------------- setApplicationConsole -----------------
......@@ -598,14 +598,14 @@ void ImpMainWindow::saveHistoryAsSCXML() {
}
// ------------------------- openDataDirectoryMenuBuilder ---------------------------
void ImpMainWindow::openDataDirectoryMenuBuilder(QMenu * fm) {
QStringList dirExt = ExtensionManager::getDataDirectoryExtNames();
void ImpMainWindow::openDataDirectoryMenuBuilder() {
QStringList dirExt = {};
QString dirExtName;
if (dirExt.size() > 1) {
if (fileOpenDataDirectoryMenu == nullptr){
fileOpenDataDirectoryMenu = new QMenu("Open Data Directory");
fm->addMenu(fileOpenDataDirectoryMenu);
fileMenu->addMenu(fileOpenDataDirectoryMenu);
} else {
disconnect(fileOpenDataDirectoryMenu,0,0,0);
fileOpenDataDirectoryMenu->clear();
......@@ -626,17 +626,23 @@ void ImpMainWindow::openDataDirectoryMenuBuilder(QMenu * fm) {
dirExtName = dirExt.at(0);
int indexAction = 0;
bool updateAction = false;
foreach (QAction * action, fileMenu->actions()) {
if (action->text().contains(" Directory")) {
action->destroyed();
bool IDidntFindWhatImLookingFor = true;
QList<QAction *> actions = fileMenu->actions();
int size = actions.size();
while (IDidntFindWhatImLookingFor && indexAction < actions.size() ) {
if (actions.at(indexAction)->text().contains(" Directory")) {
actions.at(indexAction)->destroyed();
updateAction = true;
break;
IDidntFindWhatImLookingFor = false;
}
indexAction++;
}
};
if (!updateAction) {
openDirectoryAct = new QAction("Open " + dirExtName + " Directory", this);
fm->addAction(openDirectoryAct);
fileMenu->addAction(openDirectoryAct);
} else {
openDirectoryAct = new QAction("Open " + dirExtName + " Directory", this);
}
......@@ -651,6 +657,6 @@ void ImpMainWindow::openDataDirectoryMenuBuilder(QMenu * fm) {
fileOpenDataDirectoryMenu = new QMenu("No plugins loaded to Open Data Directory");
fileOpenDataDirectoryMenu->setIcon(QPixmap(":/fileOpen"));
fileOpenDataDirectoryMenu->setEnabled(false);
fm->addMenu(fileOpenDataDirectoryMenu);
fileMenu->addMenu(fileOpenDataDirectoryMenu);
}
}
......@@ -123,7 +123,7 @@ protected:
void updateViewMenu();
/// Build the open data directory menu
void openDataDirectoryMenuBuilder(QMenu *);
void openDataDirectoryMenuBuilder();
/** @name Extension and ComponentPlugin attributes */
///@{
......
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