Vous avez reçu un message "Your GitLab account has been locked ..." ? Pas d'inquiétude : lisez cet article https://docs.gricad-pages.univ-grenoble-alpes.fr/help/unlock/

Commit de036ac4 authored by barraud's avatar barraud
Browse files

FEATURE 317 ActionExtension Add method setLocation to retrieve DLL name (such...

FEATURE 317 ActionExtension Add method setLocation to retrieve DLL name (such as ComponentExtension). Add initResources which loads the corresponding extension .qm file.

git-svn-id: svn+ssh://scm.forge.imag.fr/var/lib/gforge/chroot/scmrepos/svn/camitk/trunk/camitk@1707 ec899d31-69d1-42ba-9299-647d76f65fb3
parent e9520be3
/*****************************************************************************
* $CAMITK_LICENCE_BEGIN$
*
* CamiTK - Computer Assisted Medical Intervention ToolKit
* (c) 2001-2014 UJF-Grenoble 1, CNRS, TIMC-IMAG UMR 5525 (GMCAO)
*
* Visit http://camitk.imag.fr for more information
*
* This file is part of CamiTK.
*
* CamiTK is free software: you can redistribute it and/or modify
* it under the terms of the GNU Lesser General Public License version 3
* only, as published by the Free Software Foundation.
*
* CamiTK is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU Lesser General Public License version 3 for more details.
*
* You should have received a copy of the GNU Lesser General Public License
* version 3 along with CamiTK. If not, see <http://www.gnu.org/licenses/>.
*
* $CAMITK_LICENCE_END$
****************************************************************************/
// -- Core stuff
#include "ActionExtension.h"
#include "Action.h"
namespace camitk {
// -------------------- destructor --------------------
ActionExtension::~ActionExtension() {
while (!actions.empty()) {
Action *toDelete = actions.takeFirst();
// do not delete the "Quit" action: it is the action that triggers this delete!
if (toDelete->getName()!= "Quit")
delete toDelete;
}
}
// -------------------- registerAction --------------------
void ActionExtension::registerAction(Action* action) {
// simply add the action in the list
actions.append(action);
}
// -------------------- getActions --------------------
const camitk::ActionList& ActionExtension::getActions() {
return actions;
}
}
/*****************************************************************************
* $CAMITK_LICENCE_BEGIN$
*
* CamiTK - Computer Assisted Medical Intervention ToolKit
* (c) 2001-2014 UJF-Grenoble 1, CNRS, TIMC-IMAG UMR 5525 (GMCAO)
*
* Visit http://camitk.imag.fr for more information
*
* This file is part of CamiTK.
*
* CamiTK is free software: you can redistribute it and/or modify
* it under the terms of the GNU Lesser General Public License version 3
* only, as published by the Free Software Foundation.
*
* CamiTK is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU Lesser General Public License version 3 for more details.
*
* You should have received a copy of the GNU Lesser General Public License
* version 3 along with CamiTK. If not, see <http://www.gnu.org/licenses/>.
*
* $CAMITK_LICENCE_END$
****************************************************************************/
// -- Core stuff
#include "ActionExtension.h"
#include "Action.h"
#include "Application.h"
#include "Core.h"
#include "Log.h"
// -- Qt stuff
#include <QTranslator>
#include <QDir>
namespace camitk {
// -------------------- initResources --------------------
void ActionExtension::initResources(){
// Get the selected language
QString selectedLanguage = Application::getSelectedLanguage();
QString actionExtensionDirName = QDir(this->getLocation()).dirName();
// remove any occurence of "-debug.dll" or ".so" or ".dylib" on the extension file name
actionExtensionDirName.remove("-debug.dll").remove(".so").remove(".dylib");
QString languageFile = ":/translate_" + actionExtensionDirName + "/translate/translate_" + selectedLanguage + ".qm";
QTranslator* translator = new QTranslator();
if (!translator->load(languageFile))
CAMITK_WARNING("Application", "initResources", "Cannot load file: " + languageFile.toStdString());
else
QCoreApplication::installTranslator(translator);
}
// -------------------- destructor --------------------
ActionExtension::~ActionExtension() {
while (!actions.empty()) {
Action *toDelete = actions.takeFirst();
// do not delete the "Quit" action: it is the action that triggers this delete!
if (toDelete->getName()!= "Quit")
delete toDelete;
}
}
// -------------------- registerAction --------------------
void ActionExtension::registerAction(Action* action) {
// simply add the action in the list
actions.append(action);
}
// -------------------- getActions --------------------
const camitk::ActionList& ActionExtension::getActions() {
return actions;
}
}
......@@ -62,11 +62,11 @@ class CAMITK_API ActionExtension : public QObject {
protected :
/// constructor
ActionExtension() {};
ActionExtension() {};
public :
/// destructor
virtual ~ActionExtension();
virtual ~ActionExtension();
/// returns the action extension name (to be overriden in your ActionExtension)
virtual QString getName() = 0;
......@@ -79,6 +79,19 @@ public :
/// get the list of actions registered y this extension
const ActionList & getActions();
/// set the file path (once loaded as a dynamic library)
void setLocation(const QString loc){
dynamicLibraryFileName = loc;
}
/// get the file path (location of the .dll/.so/.dylib) of this plugin
QString getLocation() const {
return dynamicLibraryFileName;
}
/// Load, for the selected langage (asked to the Application), the associated .qm file
void initResources();
protected:
/// register an action instance
......@@ -86,6 +99,10 @@ protected:
/// the list of actions
ActionList actions;
private:
/// the shared lib (.so, .dll or .dylib) used to instanciate the ComponentExtension subclass instance
QString dynamicLibraryFileName;
};
}
......
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