Hi all, I tested this feature with MITK 2016.03 (I was testing with 2015.05 before) and I still can't get any context menu icons. I tested with a random datamanager icon: icon=":/org.mitk.gui.qt.datamanager/Refresh_48.png" just to confirm Sascha'a concern and I can see the damn icon.
Then I tried @zimmerm suggestion (in the linked bug). I changed nothing else except: QIcon icon; if (QFile::exists(cmIcon)) { icon = QIcon(cmIcon); } else { icon = berry::AbstractUICTKPlugin::ImageDescriptorFromPlugin( (*cmActionsIt)->GetContributor()->GetName(), cmIcon); } contextMenuAction = new QAction(icon, cmLabel, parent); And it actually works. I see my icons now and I still see MITK's (which is normal because there's no mitk's plugins using this code). Tested on Windows, OS X and linux. Nil Le 2016-09-19 à 16:18, Nil Goyette a écrit : > Hi all, > > Can I get an update on this? I lost many hours trying to to load an icon > for my action and I can't get it to work. There's is still this old task > https://phabricator.mitk.org/rMITKa5312246035bdf65d22364816b508129ce06c16d > on this bug. > > I couldn't find any plugin in MITK's code that loads an icon for a > context menu using plugin.xml so I can't copy what you did. > > Are Sascha's concerns still valid? It won't work if my plugin > (resources) are loaded after this line > contextMenuAction = new QAction( QIcon(cmIcon), cmLabel, parent); > in QmitkDataManagerView.cpp? Is there a safe place to put my icon? > > Nil > > Le 2014-12-01 à 13:19, Martin Klemm a écrit : >> Hi >> >> I merged the patch into the master and closed the bug last week. The >> changes (without the additions of Sascha) are already included in the >> MITK 2014.10 release. >> >> Best >> >> Martin >> >> On 12/01/2014 12:40 AM, Sascha Zelzer wrote: >>> I just shortly looked at the patch. It indeed relies on a qrc location. >>> This will only work if the contributing plug-in is loaded (otherwise, >>> the Qt resources would not be accessible). The final fix should rely on >>> the CTK resource system to retrieve the icon (as specified in the >>> CACHED_RESOURCE_FILES variable) and create a QIcon instance from an >>> in-memory representation of the icon similar to the code creating the >>> MITK Workbench toolbar and menu entries showing the view icons. >>> >>> Best, >>> Sascha >>> >>> On 11/09/2014 10:27 PM, Rostislav Khlebnikov wrote: >>>> Hm, setting it to the "qrc" location (i.e. ":/icons/icon.png") seems to >>>> work. >>>> >>>> All best, >>>> Rostislav. >>>> >>>> On 09/11/2014 20:41, Rostislav Khlebnikov wrote: >>>>> Hi guys, >>>>> >>>>> am I missing something? I applied the patch attached to the bug, but the >>>>> icon is still missing. >>>>> >>>>> I added my icon to the CACHED_RESOURCE_FILES in files.cmake for my >>>>> plugin. The location is, say, "resources/icon.png" and in plugin.xml I >>>>> have >>>>> <contextMenuAction nodeDescriptorName="mydescriptor" label="My label" >>>>> icon="resources/icon.png" class="MyAction" /> >>>>> >>>>> Any ideas on why this might not work? >>>>> >>>>> Thanks, >>>>> Rostislav. >>>>> >>>>> On 10/07/2014 10:43, Martin Klemm wrote: >>>>>> Hi Sascha, >>>>>> >>>>>> thanks for the answer and sorry for not writing you for so long. I >>>>>> opened a bug report http://bugs.mitk.org/show_bug.cgi?id=17907 and >>>>>> attached the patch file. Is there something else I have to do now? Or >>>>>> will you do the rest? >>>>>> >>>>>> Best regards, >>>>>> >>>>>> Martin >>>>>> >>>>>> >>>>>> >>>>>> On 28.05.2014 18:09, Sascha Zelzer wrote: >>>>>>> Hi Martin, >>>>>>> >>>>>>> I think it just hasn't been done yet. I also don't see a reason for not >>>>>>> doing it. Would you be up for contributing a patch to enable icons in >>>>>>> the context menu? >>>>>>> >>>>>>> Thanks, >>>>>>> >>>>>>> Sascha >>>>>>> >>>>>>> On 05/06/2014 10:37 AM, Martin Klemm wrote: >>>>>>>> Hello, >>>>>>>> >>>>>>>> I was successful in adding a new context menu action to the data >>>>>>>> manager >>>>>>>> menu: >>>>>>>> >>>>>>>> <extension >>>>>>>> point="org.mitk.gui.qt.datamanager.contextMenuActions"> >>>>>>>> <contextMenuAction nodeDescriptorName="Unknown" >>>>>>>> label="Group" >>>>>>>> icon="resources/grouping_icon.png" class="GroupAction" /> >>>>>>>> </extension> >>>>>>>> >>>>>>>> The action is shown and works as expected, however, the icon is >>>>>>>> missing. >>>>>>>> In QmitkDataManagerView::CreateQtPartControl(QWidget* parent) the >>>>>>>> context menu extension service is opened to read the descriptor name, >>>>>>>> label, class and icon attribute but is not using the icon to create the >>>>>>>> action: >>>>>>>> >>>>>>>> ... >>>>>>>> if((*cmActionsIt)->GetAttribute("nodeDescriptorName", >>>>>>>> cmNodeDescriptorName) >>>>>>>> && (*cmActionsIt)->GetAttribute("label", cmLabel) >>>>>>>> && (*cmActionsIt)->GetAttribute("class", cmClass)) >>>>>>>> { >>>>>>>> (*cmActionsIt)->GetAttribute("icon", cmIcon); >>>>>>>> // create context menu entry here >>>>>>>> tmpDescriptor = >>>>>>>> QmitkNodeDescriptorManager::GetInstance()->GetDescriptor(QString::fromStdString(cmNodeDescriptorName)); >>>>>>>> >>>>>>>> >>>>>>>> contextMenuAction = new QAction( >>>>>>>> QString::fromStdString(cmLabel), >>>>>>>> parent); >>>>>>>> ... >>>>>>>> >>>>>>>> Is there a reason why the icon is not used? >>>>>>>> >>>>>>>> Best regards, >>>>>>>> >>>>>>>> Martin >>>>>>>> >>>>>>>> ------------------------------------------------------------------------------ >>>>>>>> >>>>>>>> Is your legacy SCM system holding you back? Join Perforce May 7 to >>>>>>>> find out: >>>>>>>> • 3 signs your SCM is hindering your productivity >>>>>>>> • Requirements for releasing software faster >>>>>>>> • Expert tips and advice for migrating your SCM now >>>>>>>> http://p.sf.net/sfu/perforce >>>>>>>> _______________________________________________ >>>>>>>> mitk-users mailing list >>>>>>>> mitk-users@lists.sourceforge.net >>>>>>>> https://lists.sourceforge.net/lists/listinfo/mitk-users >>>>> ------------------------------------------------------------------------------ >>>>> _______________________________________________ >>>>> mitk-users mailing list >>>>> mitk-users@lists.sourceforge.net >>>>> https://lists.sourceforge.net/lists/listinfo/mitk-users >>>> ------------------------------------------------------------------------------ >>>> _______________________________________________ >>>> mitk-users mailing list >>>> mitk-users@lists.sourceforge.net >>>> https://lists.sourceforge.net/lists/listinfo/mitk-users >>> ------------------------------------------------------------------------------ >>> Download BIRT iHub F-Type - The Free Enterprise-Grade BIRT Server >>> from Actuate! Instantly Supercharge Your Business Reports and Dashboards >>> with Interactivity, Sharing, Native Excel Exports, App Integration & more >>> Get technology previously reserved for billion-dollar corporations, FREE >>> http://pubads.g.doubleclick.net/gampad/clk?id=157005751&iu=/4140/ostg.clktrk >>> _______________________________________________ >>> mitk-users mailing list >>> mitk-users@lists.sourceforge.net >>> https://lists.sourceforge.net/lists/listinfo/mitk-users >> ------------------------------------------------------------------------------ >> Download BIRT iHub F-Type - The Free Enterprise-Grade BIRT Server >> from Actuate! Instantly Supercharge Your Business Reports and Dashboards >> with Interactivity, Sharing, Native Excel Exports, App Integration & more >> Get technology previously reserved for billion-dollar corporations, FREE >> http://pubads.g.doubleclick.net/gampad/clk?id=157005751&iu=/4140/ostg.clktrk >> _______________________________________________ >> mitk-users mailing list >> mitk-users@lists.sourceforge.net >> https://lists.sourceforge.net/lists/listinfo/mitk-users > > ------------------------------------------------------------------------------ > _______________________________________________ > mitk-users mailing list > mitk-users@lists.sourceforge.net > https://lists.sourceforge.net/lists/listinfo/mitk-users ------------------------------------------------------------------------------ _______________________________________________ mitk-users mailing list mitk-users@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/mitk-users