MessageDialog.py 2.0 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758
  1. """
  2. ***************************************************************************
  3. MessageDialog.py
  4. ---------------------
  5. Date : October 2014
  6. Copyright : (C) 2014 by Alexander Bruy
  7. Email : alexander dot bruy at gmail dot com
  8. ***************************************************************************
  9. * *
  10. * This program is free software; you can redistribute it and/or modify *
  11. * it under the terms of the GNU General Public License as published by *
  12. * the Free Software Foundation; either version 2 of the License, or *
  13. * (at your option) any later version. *
  14. * *
  15. ***************************************************************************
  16. """
  17. __author__ = 'Alexander Bruy'
  18. __date__ = 'October 2014'
  19. __copyright__ = '(C) 2014, Alexander Bruy'
  20. import os
  21. import warnings
  22. from qgis.PyQt import uic
  23. from qgis.PyQt.QtGui import QDesktopServices
  24. from qgis.PyQt.QtWidgets import QDockWidget
  25. from qgis.utils import iface
  26. pluginPath = os.path.split(os.path.dirname(__file__))[0]
  27. with warnings.catch_warnings():
  28. warnings.filterwarnings("ignore", category=DeprecationWarning)
  29. WIDGET, BASE = uic.loadUiType(
  30. os.path.join(pluginPath, 'ui', 'DlgMessage.ui'))
  31. class MessageDialog(BASE, WIDGET):
  32. def __init__(self):
  33. super().__init__(None)
  34. self.setupUi(self)
  35. self.txtMessage.anchorClicked.connect(self.openLink)
  36. def setTitle(self, title):
  37. self.setWindowTitle(title)
  38. def setMessage(self, message):
  39. self.txtMessage.setHtml(message)
  40. def openLink(self, url):
  41. if url.toString() == "log":
  42. self.close()
  43. logDock = iface.mainWindow().findChild(QDockWidget, 'MessageLog')
  44. logDock.show()
  45. else:
  46. QDesktopServices.openUrl(url)