MCPcopy Create free account
hub / github.com/computationalpathologygroup/ASAP / loadPlugins

Method loadPlugins

ASAP/ASAP_Window.cpp:103–194  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

101}
102
103void ASAP_Window::loadPlugins() {
104 PathologyViewer* viewer = this->findChild<PathologyViewer*>("pathologyView");
105 _pluginsDir = QDir(qApp->applicationDirPath());
106 if (_pluginsDir.cd("plugins")) {
107 if (_pluginsDir.cd("tools")) {
108 foreach(QString fileName, _pluginsDir.entryList(QDir::Files)) {
109 if (fileName.toLower().endsWith(sharedLibraryExtensions)) {
110 QPluginLoader loader(_pluginsDir.absoluteFilePath(fileName));
111 QObject *plugin = loader.instance();
112 if (plugin) {
113 std::shared_ptr<ToolPluginInterface> tool(qobject_cast<ToolPluginInterface*>(plugin));
114 if (tool) {
115 tool->setViewer(viewer);
116 QAction* toolAction = tool->getToolButton();
117 connect(toolAction, SIGNAL(triggered(bool)), viewer, SLOT(changeActiveTool()));
118 _toolPluginFileNames.push_back(fileName.toStdString());
119 viewer->addTool(tool);
120 QToolBar* mainToolBar = this->findChild<QToolBar *>("mainToolBar");
121 toolAction->setCheckable(true);
122 _toolActions->addAction(toolAction);
123 mainToolBar->addAction(toolAction);
124 }
125 }
126 }
127 }
128 _pluginsDir.cdUp();
129 }
130 if (_pluginsDir.cd("workstationextension")) {
131 QDockWidget* lastDockWidget = NULL;
132 QDockWidget* firstDockWidget = NULL;
133 foreach(QString fileName, _pluginsDir.entryList(QDir::Files)) {
134 if (fileName.toLower().endsWith(sharedLibraryExtensions)) {
135 QPluginLoader loader(_pluginsDir.absoluteFilePath(fileName));
136 QObject *plugin = loader.instance();
137 if (plugin) {
138 std::unique_ptr<WorkstationExtensionPluginInterface> extension(qobject_cast<WorkstationExtensionPluginInterface*>(plugin));
139 if (extension) {
140 _extensionPluginFileNames.push_back(fileName.toStdString());
141 connect(this, SIGNAL(newImageLoaded(std::weak_ptr<MultiResolutionImage>, std::string)), &*extension, SLOT(onNewImageLoaded(std::weak_ptr<MultiResolutionImage>, std::string)));
142 connect(this, SIGNAL(imageClosed()), &*extension, SLOT(onImageClosed()));
143 extension->initialize(viewer);
144 if (extension->getToolBar()) {
145 this->addToolBar(extension->getToolBar());
146 }
147 if (extension->getDockWidget()) {
148 QDockWidget* extensionDW = extension->getDockWidget();
149 extensionDW->setAllowedAreas(Qt::LeftDockWidgetArea | Qt::RightDockWidgetArea);
150 if (lastDockWidget) {
151 this->tabifyDockWidget(lastDockWidget, extensionDW);
152 }
153 else {
154 this->addDockWidget(Qt::LeftDockWidgetArea, extensionDW);
155 firstDockWidget = extensionDW;
156 }
157 extensionDW->setTitleBarWidget(new QWidget());
158 lastDockWidget = extensionDW;
159 QMenu* viewMenu = this->findChild<QMenu*>("menuView");
160 QMenu* viewDocksMenu = viewMenu->findChild<QMenu*>("menuViewDocks");

Callers 1

ASAP_WindowMethod · 0.95

Calls

no outgoing calls

Tested by

no test coverage detected