RenderingStyleFilePanel.py 2.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960
  1. """
  2. ***************************************************************************
  3. RenderingStyleFilePanel.py
  4. ---------------------
  5. Date : August 2012
  6. Copyright : (C) 2012 by Victor Olaya
  7. Email : volayaf 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__ = 'Victor Olaya'
  18. __date__ = 'August 2012'
  19. __copyright__ = '(C) 2012, Victor Olaya'
  20. import os
  21. import warnings
  22. from qgis.PyQt import uic
  23. from qgis.PyQt.QtWidgets import QFileDialog
  24. from processing.tools.system import isWindows
  25. pluginPath = os.path.split(os.path.dirname(__file__))[0]
  26. with warnings.catch_warnings():
  27. warnings.filterwarnings("ignore", category=DeprecationWarning)
  28. WIDGET, BASE = uic.loadUiType(
  29. os.path.join(pluginPath, 'ui', 'widgetBaseSelector.ui'))
  30. class RenderingStyleFilePanel(BASE, WIDGET):
  31. def __init__(self):
  32. super().__init__(None)
  33. self.setupUi(self)
  34. self.btnSelect.clicked.connect(self.showSelectionDialog)
  35. def showSelectionDialog(self):
  36. filename, selected_filter = QFileDialog.getOpenFileName(self,
  37. self.tr('Select Style File'), '',
  38. self.tr('QGIS Layer Style File (*.qml *.QML)'))
  39. if filename:
  40. self.leText.setText(filename)
  41. def setText(self, text):
  42. self.leText.setText(text)
  43. def getValue(self):
  44. s = self.leText.text()
  45. if isWindows():
  46. s = s.replace('\\', '/')
  47. return s