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

CHANGE the "Open Data Directory" Menu Is Now Specialized

To open multiple types of data directory, menu shows all possibilities
from extension as QAction under "Open Data Directory" menu. If there is
only one type of DirectoryExtension menu appears only as one specialized
e-g "Open Dicom Directory" instead of "Open Data Directory".
parent 32e9f2b7
/*****************************************************************************
/*****************************************************************************
* $CAMITK_LICENCE_BEGIN$
*
* CamiTK - Computer Assisted Medical Intervention ToolKit
......@@ -68,7 +68,6 @@ ImpMainWindow::ImpMainWindow() : MainWindow("imp") {
// initialize architecture
updateActionStates();
updateOpenDirectoryMenu();
// now add the different viewers
setCentralViewer(MedicalImageViewer::getInstance());
......@@ -111,8 +110,6 @@ void ImpMainWindow::aboutToShow() {
void ImpMainWindow::refresh() {
MainWindow::refresh();
// update Data directory menu
updateOpenDirectoryMenu();
// update all the action states
updateActionStates();
// update menu
......@@ -229,10 +226,12 @@ void ImpMainWindow::initMenuBar() {
fileMenu = new QMenu(tr("&File"));
fileMenu->addAction(fileOpen);
fileOpenDataDirectoryMenu = new QMenu(tr("Open &Data Directory..."));
fileOpenDataDirectoryMenu->setIcon(QPixmap(":/fileOpen"));
fileOpenDataDirectoryMenu->setEnabled(false);
fileMenu->addMenu(fileOpenDataDirectoryMenu);
openDataDirectoryMenuBuilder(fileMenu);
// fileOpenDataDirectoryMenu = new QMenu(tr("Open &Data Directory..."));
// fileOpenDataDirectoryMenu->setIcon(QPixmap(":/fileOpen"));
// fileOpenDataDirectoryMenu->setEnabled(false);
// fileMenu->addMenu(fileOpenDataDirectoryMenu);
fileMenu->addAction(fileClose);
fileMenu->addAction(fileCloseAll);
......@@ -423,32 +422,9 @@ void ImpMainWindow::resetWindows() {
move(0, 0);
}
// ------------------------ updateDataDirectoryMenu ----------------------------
void ImpMainWindow::updateOpenDirectoryMenu() {
unsigned int nrOfDataDirectoryManager = 0;
disconnect(fileOpenDataDirectoryMenu, SIGNAL(triggered(QAction*)), this, SLOT(openDirectory(QAction*)));
fileOpenDataDirectoryMenu->clear();
fileOpenDataDirectoryMenu->setEnabled(false);
foreach (QString name, ExtensionManager::getDataDirectoryExtNames()) {
nrOfDataDirectoryManager++;
QAction* openDirectory = new QAction(name, this);
openDirectory->setStatusTip(tr(QString("Opens data directory for " + name).toStdString().c_str()));
openDirectory->setWhatsThis(tr(QString("Opens data directory for " + name).toStdString().c_str()));
fileOpenDataDirectoryMenu->addAction(openDirectory);
}
if (nrOfDataDirectoryManager > 0) {
fileOpenDataDirectoryMenu->setEnabled(true);
connect(fileOpenDataDirectoryMenu, SIGNAL(triggered(QAction*)), this, SLOT(openDirectory(QAction*)));
}
}
// ------------- openDataDirectory -----------------
void ImpMainWindow::openDirectory(QAction* emitter) {
QString pluginName = emitter->text().replace("&", "");
void ImpMainWindow::openDicomDirectory() {
QString pluginName = QString("DICOM");
statusBar()->showMessage(tr(QString("Opening " + pluginName + " directory...").toStdString().c_str()));
......@@ -567,9 +543,6 @@ void ImpMainWindow::editSettings() {
// update recent docs
updateRecentDocumentsMenu();
}
// check if there are anything to change in the data directory menu (for data directory manager)
updateOpenDirectoryMenu();
}
// ------------- setApplicationConsole -----------------
......@@ -623,7 +596,36 @@ void ImpMainWindow::saveHistoryAsSCXML() {
Application::saveHistoryAsSXML();
}
// ------------------------- openDataDirectoryMenuBuilder ---------------------------
void ImpMainWindow::openDataDirectoryMenuBuilder(QMenu * fm) {
// QStringList dirExt = { "Arial", "Helvetica", "Times" };
QStringList dirExt = ExtensionManager::getDataDirectoryExtNames();
QString dirExtName;
// Check if there is some dataDirectoryExtension
if (dirExt.size() > 1) {
fileOpenDataDirectoryMenu = new QMenu("Open Data Directory");
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()));
openDirectory->setWhatsThis(tr(QString("Opens data directory for " + dirExtName).toStdString().c_str()));
fileOpenDataDirectoryMenu->addAction(openDirectory);
}
} else if (dirExt.size() == 1) {
dirExtName = dirExt.at(0);
QAction* 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, &ImpMainWindow::openDicomDirectory);
fm->addAction(openDirectoryAct);
openDirectoryAct->setIcon(QPixmap(":/fileOpen"));
}
}
/*****************************************************************************
/*****************************************************************************
* $CAMITK_LICENCE_BEGIN$
*
* CamiTK - Computer Assisted Medical Intervention ToolKit
......@@ -80,9 +80,14 @@ public slots:
/// @name file menu slot
///@{
/// open a data directory, "called" from the fileOpenDataDirectoryMenu
void openDirectory(QAction*);
void openDicomDirectory();
///@}
/// @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
......@@ -122,11 +127,6 @@ protected:
/// update the viewer's menu
void updateViewMenu();
/** @name Extension and ComponentPlugin attributes */
///@{
/// update the data directory menu depending on registered plugins
void updateOpenDirectoryMenu();
/// update the recent document menu
void updateRecentDocumentsMenu();
///@}
......
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