<div dir="ltr">Hi Dennis<br><div><div class="gmail_extra"><br><div class="gmail_quote">On Tue, Oct 3, 2017 at 3:21 PM, Denis Rouzaud <span dir="ltr"><<a href="mailto:denis.rouzaud@gmail.com" target="_blank">denis.rouzaud@gmail.com</a>></span> wrote:<br><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><div dir="ltr">Hi Ricardo,<div><br></div><div>Sorry to bother, but I think this kind of hack should be discouraged. </div></div></blockquote><div><br></div><div><br></div><div>No bother at all :)</div><div><br></div><div>I am just playing around with some ideas for improving the WMS layer support. The whole 'hijack QGIS native dialog' thing is just a sidetrack that is not really my main goal. It just seemed like a wacky, fun idea to try out. just to see if it is possible!</div><div><br></div><div><br></div><div> </div><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><div dir="ltr"><div><br></div><div>This modifies QGIS behavior in a hidden way by replacing native dialogs. And as you pointed, there is probably no way of uninstalling your plugin properly. It will require QGIS to restart to work as expected, which is not that bad, but still.</div><div><br></div><div>If you think current behavior is not optimal, I would suggest to either:</div><div>* bring your improvements into master instead of a plugin</div></div></blockquote><div><br></div><div><br></div><div>That might be the plan for the long run. For now I'm just having some fun at lunch break ;)</div><div><br></div><div><br></div><div> </div><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><div dir="ltr"><div>* create a dedicated button and menu entry in your plugin for your customized dialog</div><div><br></div><div>With the latter option, I think it would be possible to add your menu entry and button in the layer menu and layer toolbar, respectively. <br></div></div></blockquote><div><br></div><div><br></div><div>Yeah I am aware there is a proper way to do this, and this is not it. This is just toying and poking at stuff to see what is possible. <br></div><div>On a more "serious" tone, I agree with you 100%. This is not something that I'd be putting out there for the world to use.</div><div><br></div><div><br></div><div> </div><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><div dir="ltr"><div><br></div><div>Just my two cents.</div><div><br></div><div>Denis</div><div><br></div></div></blockquote><div><br></div><div><br></div><div>Cheers<br></div><div><br></div><div> </div><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><div dir="ltr"><div></div><div><br></div><div><br></div><div><br></div><div><br><div class="gmail_quote"><div><div class="h5"><div dir="ltr">Le mar. 3 oct. 2017 à 16:09, Ricardo Filipe Soares Garcia da <<a href="mailto:ricardo.garcia.silva@gmail.com" target="_blank">ricardo.garcia.silva@gmail.<wbr>com</a>> a écrit :<br></div></div></div><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><div><div class="h5"><div dir="ltr"><div>Hi all<br></div><div><br></div><div>Answering my own question for posterity<br></div><div><br></div><div>Turns out I can disconnect all slots from a signal by calling `my_action.triggered.<wbr>disconnect()` without any arguments. My goal of replacing the native QGIS 'Add WMS/WMTS layer' dialogue with another one can be achieved like this:</div><div><br></div><div>```python</div><div><br></div><div>def my_handler():</div><div>    print("Hello")<br></div><div><br></div><div>action = iface.actionAddWmsLayer()</div><div>action.triggered.disconnect()</div><div>action.triggered.connect(my_<wbr>handler)<br></div><div>```<br></div><div><br></div><div>This leaves another problem to be solved: How to restore the native QGIS dialogue when my would-be plugin is deactivated by the user. The following seems to work on QGIS 2.18:</div><div><br></div><div>```</div><div>provider_registry = qgis.core.QgsProviderRegistry.<wbr>instance()</div><div>add_wms_dialog = provider_registry.<wbr>selectWidget("wms")</div><div>action.triggered.disconnect()</div><div>action.triggered.connect(add_<wbr>wms_dialog.show)</div><div><br></div><div>```</div><div><br></div><div>Best regards<br></div><div><br></div><div><br></div></div><div class="gmail_extra"><br><div class="gmail_quote">On Mon, Oct 2, 2017 at 12:41 PM, Ricardo Filipe Soares Garcia da <span dir="ltr"><<a href="mailto:ricardo.garcia.silva@gmail.com" target="_blank">ricardo.garcia.silva@gmail.<wbr>com</a>></span> wrote:<br><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><div dir="ltr"><div><div>Hi all<br><br></div>Is it possible to replace one of QGIS' dialogues with a custom one during runtime by using Python?<br></div><div><br></div><div>My concrete goal is to replace the dialogue that shows when clicking the 'Add WMS/WMTS Layer' with something custom. I'd like to enhance the native QGIS dialogue with additional elements for selecting additional dimensions, like time or elevation.</div><div><br></div><div>Can this be done?</div><div><br></div><div>I'm thinking that I'd only have to replace whatever slot is currently defined on the `iface.actionAddWmsLayer()` action with a custom function that would load my UI instead. The problem is that I can't seem to find where a signal's connected slots are stored with Qt.</div><div><br></div><div>Ideally there would be some introspection mechanism by which I'd be able to retrieve which slots are associated with the action's `triggered` signal - I can't seem to find it though. After knowing which slot(s) were connected to the action's signal, I would presumably be able to `disconnect()` them and then connect my own.</div><div><br></div><div>By looking at Qt's docs I thought that the QMetaObject class might be the place to look, but I still cannot find anything that looks seems to hold the registry of a signal's connected slots.</div><div><br></div><div>Thanks in advance :)<span class="m_8749378763274558975m_-6120077855577594610HOEnZb"><font color="#888888"><br></font></span></div><span class="m_8749378763274558975m_-6120077855577594610HOEnZb"><font color="#888888"><div><br></div><div><br></div><div><div><div><br>-- <br><div class="m_8749378763274558975m_-6120077855577594610m_6435077902353583523gmail_signature" data-smartmail="gmail_signature">___________________________ ___ __<br>Ricardo Garcia Silva</div>
</div></div></div></font></span></div>
</blockquote></div><br><br clear="all"><br>-- <br><div class="m_8749378763274558975m_-6120077855577594610gmail_signature" data-smartmail="gmail_signature">___________________________ ___ __<br>Ricardo Garcia Silva</div>
</div></div></div>
______________________________<wbr>_________________<br>
QGIS-Developer mailing list<br>
<a href="mailto:QGIS-Developer@lists.osgeo.org" target="_blank">QGIS-Developer@lists.osgeo.org</a><br>
List info: <a href="https://lists.osgeo.org/mailman/listinfo/qgis-developer" rel="noreferrer" target="_blank">https://lists.osgeo.org/<wbr>mailman/listinfo/qgis-<wbr>developer</a><br>
Unsubscribe: <a href="https://lists.osgeo.org/mailman/listinfo/qgis-developer" rel="noreferrer" target="_blank">https://lists.osgeo.org/<wbr>mailman/listinfo/qgis-<wbr>developer</a></blockquote></div></div></div>
</blockquote></div><br><br clear="all"><br>-- <br><div class="gmail_signature" data-smartmail="gmail_signature">___________________________ ___ __<br>Ricardo Garcia Silva</div>
</div></div></div>