Beispiel #1
0
 def __init__(self, iface, project_settings):
     self.new_dialog = VtrDialog()
     self.new_dialog.setModal(True)
     self._iface = iface
     self._init_connections()
     self._settings = project_settings
     self._browse_open_path = _default_directory(project_settings)
 def __init__(self, iface, project_settings):
     self.new_dialog = VtrDialog()
     self.new_dialog.setModal(True)
     self._iface = iface
     self._init_connections()
     self._settings = project_settings
     self._browse_open_path = _default_directory(project_settings)
class Dialog:
    def __init__(self, iface, project_settings):
        self.new_dialog = VtrDialog()
        self.new_dialog.setModal(True)
        self._iface = iface
        self._init_connections()
        self._settings = project_settings
        self._browse_open_path = _default_directory(project_settings)

    def create_dialog(self):
        if self.new_dialog.isVisible():
            self.new_dialog.reject()
        self.new_dialog.helpLabel.setOpenExternalLinks(True)
        self.new_dialog.show()
        result = self.new_dialog.exec_()
        if result == 1:
            file_path = self.new_dialog.filePath.text()
            if not os.path.exists(file_path):
                #  take a default mbtile if non is selected.
                dir_path = os.path.dirname(os.path.abspath(__file__))
                file_path = "%s/data/zurich.mbtiles" % dir_path
            model = Model(self._iface, file_path)
            model.mbtiles()

    def _init_connections(self):
        self.new_dialog.acceptButton.clicked.connect(self.new_dialog.accept)
        self.new_dialog.rejectButton.clicked.connect(self.new_dialog.reject)
        self.new_dialog.fileBrowserButton.clicked.connect(self._browse_directory)

    def _browse_directory(self):
        vtr_file_path = QFileDialog.getOpenFileName(
            self.new_dialog,
            QApplication.translate("Dialog", "open mbtile file"),
            self._browse_open_path,
            QApplication.translate("Dialog", "Files (*.mbtiles)"),
        )
        if vtr_file_path:
            self._new_default_directory(QFileInfo(vtr_file_path).path())
            self.new_dialog.filePath.setText(vtr_file_path)
        self.new_dialog.activateWindow()

    def _new_default_directory(self, path):
        self._settings.setValue("lastUsedFileOpenDir", path)
Beispiel #4
0
class Dialog:
    def __init__(self, iface, project_settings):
        self.new_dialog = VtrDialog()
        self.new_dialog.setModal(True)
        self._iface = iface
        self._init_connections()
        self._settings = project_settings
        self._browse_open_path = _default_directory(project_settings)

    def create_dialog(self):
        if self.new_dialog.isVisible():
            self.new_dialog.reject()
        self.new_dialog.helpLabel.setOpenExternalLinks(True)
        self.new_dialog.show()
        result = self.new_dialog.exec_()
        if result == 1:
            file_path = self.new_dialog.filePath.text()
            if not os.path.exists(file_path):
                #  take a default mbtile if non is selected.
                dir_path = os.path.dirname(os.path.abspath(__file__))
                file_path = "%s/data/zurich.mbtiles" % dir_path
            model = Model(self._iface, file_path)
            model.mbtiles()

    def _init_connections(self):
        self.new_dialog.acceptButton.clicked.connect(self.new_dialog.accept)
        self.new_dialog.rejectButton.clicked.connect(self.new_dialog.reject)
        self.new_dialog.fileBrowserButton.clicked.connect(
            self._browse_directory)

    def _browse_directory(self):
        vtr_file_path = QFileDialog.getOpenFileName(
            self.new_dialog,
            QApplication.translate("Dialog", "open mbtile file"),
            self._browse_open_path,
            QApplication.translate("Dialog", "Files (*.mbtiles)"))
        if vtr_file_path:
            self._new_default_directory(QFileInfo(vtr_file_path).path())
            self.new_dialog.filePath.setText(vtr_file_path)
        self.new_dialog.activateWindow()

    def _new_default_directory(self, path):
        self._settings.setValue('lastUsedFileOpenDir', path)