Commit 9077f373 authored by Jean-Loup Haberbusch's avatar Jean-Loup Haberbusch

ADD Update method for resetting parameters case

If directoryExtension are reloaded while a running session, ‘Open Data Directory’ is rechecked to take into account potential new plugin.
parent 22040dd2
......@@ -112,6 +112,7 @@ void ImpMainWindow::refresh() {
// update all the action states
updateActionStates();
// update menu
updateRecentDocumentsMenu();
}
......@@ -543,6 +544,9 @@ void ImpMainWindow::editSettings() {
// update recent docs
updateRecentDocumentsMenu();
}
// check if there are anything to change in the data directory menu (for data directory manager)
ImpMainWindow::openDataDirectoryMenuBuilder(fileMenu);
}
// ------------- setApplicationConsole -----------------
......@@ -598,15 +602,18 @@ void ImpMainWindow::saveHistoryAsSCXML() {
// ------------------------- openDataDirectoryMenuBuilder ---------------------------
void ImpMainWindow::openDataDirectoryMenuBuilder(QMenu * fm) {
QStringList dirExt = ExtensionManager::getDataDirectoryExtNames();
QString dirExtName;
// Check if there is some dataDirectoryExtension
if (dirExt.size() > 1) {
fileOpenDataDirectoryMenu = new QMenu("Open Data Directory");
if (fileOpenDataDirectoryMenu == nullptr){
fileOpenDataDirectoryMenu = new QMenu("Open Data Directory");
fm->addMenu(fileOpenDataDirectoryMenu);
} else {
disconnect(fileOpenDataDirectoryMenu,0,0,0);
fileOpenDataDirectoryMenu->clear();
}
fileOpenDataDirectoryMenu->setIcon(QPixmap(":/fileOpen"));
fm->addMenu(fileOpenDataDirectoryMenu);
foreach (dirExtName, dirExt) {
QAction* openDirectory = new QAction(dirExtName, this);
openDirectory->setStatusTip(tr(QString("Opens data directory for " + dirExtName).toStdString().c_str()));
......@@ -617,14 +624,31 @@ void ImpMainWindow::openDataDirectoryMenuBuilder(QMenu * fm) {
}
} else if (dirExt.size() == 1) {
QAction* openDirectoryAct;
dirExtName = dirExt.at(0);
QAction* openDirectoryAct = new QAction("Open " + dirExtName + " Directory", this);
int indexAction = 0;
bool updateAction = false;
foreach (QAction * action, fileMenu->actions()) {
if (action->text().contains(" Directory")) {
action->destroyed();
updateAction = true;
break;
}
indexAction++;
}
if (!updateAction) {
openDirectoryAct = new QAction("Open " + dirExtName + " Directory", this);
fm->addAction(openDirectoryAct);
} else {
openDirectoryAct = new QAction("Open " + dirExtName + " Directory", this);
}
openDirectoryAct->setStatusTip(tr(QString("Opens data directory for " + dirExtName).toStdString().c_str()));
openDirectoryAct->setWhatsThis(tr(QString("Opens data directory for " + dirExtName).toStdString().c_str()));
connect(openDirectoryAct, &QAction::triggered, this, [=]() {this->openDicomDirectory(dirExtName);});
fm->addAction(openDirectoryAct);
openDirectoryAct->setIcon(QPixmap(":/fileOpen"));
} else {
fileOpenDataDirectoryMenu = new QMenu("No plugins loaded to Open Data Directory");
......@@ -633,5 +657,3 @@ void ImpMainWindow::openDataDirectoryMenuBuilder(QMenu * fm) {
fm->addMenu(fileOpenDataDirectoryMenu);
}
}
......@@ -83,11 +83,6 @@ public slots:
void openDicomDirectory(QString plugin);
///@}
/// @name file menu slot
///@{
/// Build the open data directory menu
void openDataDirectoryMenuBuilder(QMenu *);
/// @name viewers' slot
///@{
/// this slot is connected to all the viewers selectionChanged() signal, this will call the refresh method of all viewers but whoIsAsking
......@@ -127,6 +122,15 @@ protected:
/// update the viewer's menu
void updateViewMenu();
/// Build the open data directory menu
void openDataDirectoryMenuBuilder(QMenu *);
/** @name Extension and ComponentPlugin attributes */
///@{
/// update the data directory menu depending on registered plugins
void updateOpenDirectoryMenu();
/// update the recent document menu
void updateRecentDocumentsMenu();
///@}
......@@ -161,7 +165,7 @@ private:
///@{
/** file_menu contains all items of the menubar entry "File" */
QMenu* fileMenu;
QMenu* fileOpenDataDirectoryMenu;
QMenu* fileOpenDataDirectoryMenu = nullptr;
QAction* fileOpen;
QAction* fileClose;
QAction* fileCloseAll;
......
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