예제 #1
0
    def __init__(self, iface):
        Plugin.__init__(self, iface, "PointsInPolygons")

        userPluginPath = QtCore.QFileInfo(QgsApplication.qgisUserDbFilePath()).path() + '/python/plugins/points_in_polygons'
        systemPluginPath = QgsApplication.prefixPath() + '/python/plugins/points_in_polygons'

        overrideLocale = QtCore.QSettings().value('locale/overrideFlag', False, type=bool)
        if not overrideLocale:
            localeFullName = QtCore.QLocale.system().name()[:2]
        else:
            localeFullName = QtCore.QSettings().value("locale/userLocale", "")

        if QtCore.QFileInfo(userPluginPath).exists():
            translationPath = userPluginPath + '/i18n/pointsinpolygons_' + localeFullName + '.qm'
            self.pluginPath = userPluginPath
        else:
            translationPath = systemPluginPath + '/i18n/pointsinpolygons_' + localeFullName + '.qm'
            self.pluginPath = systemPluginPath

        self.localePath = translationPath
        if QtCore.QFileInfo(self.localePath).exists():
            self.translator = QtCore.QTranslator()
            self.translator.load(self.localePath)
            QgsApplication.installTranslator(self.translator)

        self.pointLayerName = ""
        self.polygonLayerName = ""
        self.fieldName = ""
예제 #2
0
    def __init__(self, iface):
        # Save reference to the QGIS interface
        self.iface = iface

        # initialize plugin directory
        self.plugin_dir = QFileInfo(QgsApplication.qgisUserDatabaseFilePath()).path() + "/python/plugins/" + __package__

        # initialize locale. Default to Danish
        self.config = QSettings()
        localePath = ""
        try:
            locale = self.config.value("locale/userLocale")[0:2]
        except:
            locale = 'da'

        if QFileInfo(self.plugin_dir).exists():
            localePath = self.plugin_dir + "/i18n/" + locale + ".qt.qm"

        if QFileInfo(localePath).exists():
            self.translator = QTranslator()
            self.translator.load(localePath)

            if qVersion() > '4.3.3':
                QgsApplication.installTranslator(self.translator)
        
        # new config method
        self.settings = Settings()
        self.options_factory = OptionsFactory(self.settings)
        self.options_factory.setTitle('Geosearch DK')
        iface.registerOptionsWidgetFactory(self.options_factory)
예제 #3
0
    def __init__(self, iface):
        # Save reference to the QGIS interface
        self.iface = iface

        # initialize plugin directory
        self.plugin_dir = QFileInfo(QgsApplication.qgisUserDatabaseFilePath()
                                    ).path() + "/python/plugins/" + __package__

        # initialize locale. Default to Danish
        self.config = QSettings()
        localePath = ""
        try:
            locale = self.config.value("locale/userLocale")[0:2]
        except:
            locale = 'da'

        if QFileInfo(self.plugin_dir).exists():
            localePath = self.plugin_dir + "/i18n/" + locale + ".qt.qm"

        if QFileInfo(localePath).exists():
            self.translator = QTranslator()
            self.translator.load(localePath)

            if qVersion() > '4.3.3':
                QgsApplication.installTranslator(self.translator)

        # new config method
        self.settings = Settings()
        self.options_factory = OptionsFactory(self.settings)
        self.options_factory.setTitle('Geosearch DK')
        iface.registerOptionsWidgetFactory(self.options_factory)
예제 #4
0
파일: environ.py 프로젝트: GRSEB9S/Roam
class RoamApp(object):
    def __init__(self, sysargv, apppath, prefixpath, settingspath, libspath,
                 i18npath):
        self.sysargv = sysargv
        self.apppath = apppath
        self.prefixpath = prefixpath
        self.settingspath = settingspath
        self.libspath = libspath
        self.i18npath = i18npath
        self.app = None
        self.translationFile = None

    def init(self):
        from qgis.core import QgsApplication
        from PyQt4.QtGui import QApplication, QFont
        from PyQt4.QtCore import QLocale, QTranslator
        try:
            import PyQt4.QtSql
        except ImportError:
            pass

        self.app = QgsApplication(self.sysargv, True)
        QgsApplication.setPrefixPath(self.prefixpath, True)
        QgsApplication.initQgis()

        locale = QLocale.system().name()
        self.translationFile = os.path.join(self.i18npath,
                                            '{0}.qm'.format(locale))
        translator = QTranslator()
        translator.load(self.translationFile, "i18n")
        self.app.installTranslator(translator)

        QApplication.setStyle("Plastique")
        QApplication.setFont(QFont('Segoe UI'))
        return self

    def exec_(self):
        self.app.exec_()

    def exit(self):
        from qgis.core import QgsApplication
        QgsApplication.exitQgis()
        QgsApplication.quit()

    def setActiveWindow(self, widget):
        self.app.setActiveWindow(widget)

    def dump_configinfo(self):
        from qgis.core import QgsApplication, QgsProviderRegistry
        from PyQt4.QtGui import QImageReader, QImageWriter
        yield QgsProviderRegistry.instance().pluginList()
        yield QImageReader.supportedImageFormats()
        yield QImageWriter.supportedImageFormats()
        yield QgsApplication.libraryPaths()
        yield "Translation file: {}".format(self.translationFile)
예제 #5
0
파일: environ.py 프로젝트: Kenyat1989/Roam
class RoamApp(object):
    def __init__(self, sysargv, apppath, prefixpath, settingspath, libspath, i18npath):
        self.sysargv = sysargv
        self.apppath = apppath
        self.prefixpath = prefixpath
        self.settingspath = settingspath
        self.libspath = libspath
        self.i18npath = i18npath
        self.app = None
        self.translationFile = None

    def init(self):
        from qgis.core import QgsApplication
        from PyQt4.QtGui import QApplication, QFont
        from PyQt4.QtCore import QLocale, QTranslator
        try:
            import PyQt4.QtSql
        except ImportError:
            pass

        self.app = QgsApplication(self.sysargv, True)
        QgsApplication.setPrefixPath(self.prefixpath, True)
        QgsApplication.initQgis()

        locale = QLocale.system().name()
        self.translationFile = os.path.join(self.i18npath, '{0}.qm'.format(locale))
        translator = QTranslator()
        translator.load(self.translationFile, "i18n")
        self.app.installTranslator(translator)

        QApplication.setStyle("Plastique")
        QApplication.setFont(QFont('Segoe UI'))
        return self

    def exec_(self):
        self.app.exec_()

    def exit(self):
        from qgis.core import QgsApplication
        QgsApplication.exitQgis()
        QgsApplication.quit()

    def setActiveWindow(self, widget):
        self.app.setActiveWindow(widget)

    def dump_configinfo(self):
        from qgis.core import QgsApplication, QgsProviderRegistry
        from PyQt4.QtGui import QImageReader, QImageWriter
        yield QgsProviderRegistry.instance().pluginList()
        yield QImageReader.supportedImageFormats()
        yield QImageWriter.supportedImageFormats()
        yield QgsApplication.libraryPaths()
        yield "Translation file: {}".format(self.translationFile)
예제 #6
0
class RoamApp(object):
    def __init__(self, sysargv, apppath, prefixpath, settingspath, libspath, i18npath, projectsroot):
        self.sysargv = sysargv
        self.apppath = apppath
        self.prefixpath = prefixpath
        self.settingspath = settingspath
        self.libspath = libspath
        self.i18npath = i18npath
        self.app = None
        self.translationFile = None
        self.projectsroot = projectsroot
        self._oldhook = sys.excepthook

    def init(self, logo, title):
        from qgis.core import QgsApplication
        from PyQt4.QtGui import QApplication, QFont, QIcon
        from PyQt4.QtCore import QLocale, QTranslator
        try:
            import PyQt4.QtSql
        except ImportError:
            pass

        self.app = QgsApplication(self.sysargv, True)
        import roam.roam_style
        self.app.setStyleSheet(roam.roam_style.appstyle)
        QgsApplication.setPrefixPath(self.prefixpath, True)
        QgsApplication.initQgis()

        locale = QLocale.system().name()
        self.translationFile = os.path.join(self.i18npath, '{0}.qm'.format(locale))
        translator = QTranslator()
        translator.load(self.translationFile, "i18n")
        self.app.installTranslator(translator)

        QApplication.setStyle("Plastique")
        QApplication.setFont(QFont('Segoe UI'))
        QApplication.setWindowIcon(QIcon(logo))
        QApplication.setApplicationName(title)

        import roam.editorwidgets.core
        roam.editorwidgets.core.registerallwidgets()
        return self

    def set_error_handler(self, errorhandler, logger):
        sys.excepthook = functools.partial(self.excepthook, errorhandler)
        self.logger = logger

    def excepthook(self, errorhandler, exctype, value, traceback):
        self.logger.error("Uncaught exception", exc_info=(exctype, value, traceback))
        errorhandler(exctype, value, traceback)

    def exec_(self):
        self.app.exec_()

    def exit(self):
        sys.excepthook = self._oldhook
        from qgis.core import QgsApplication
        QgsApplication.exitQgis()
        QgsApplication.quit()

    def setActiveWindow(self, widget):
        self.app.setActiveWindow(widget)

    def dump_configinfo(self):
        from qgis.core import QgsApplication, QgsProviderRegistry
        from PyQt4.QtGui import QImageReader, QImageWriter
        import roam
        from qgis.core import QGis

        config = []
        config.append("====Providers===")
        config.append(QgsProviderRegistry.instance().pluginList())
        config.append("====Library paths===")
        config.append('\n'.join(QgsApplication.libraryPaths()))
        config.append("====Translation File===")
        config.append(self.translationFile)
        config.append("Roam Version: {}".format(roam.__version__))
        config.append("QGIS Version: {}".format(str(QGis.QGIS_VERSION)))
        return '\n'.join(config)
예제 #7
0
파일: environ.py 프로젝트: skylning/Roam
class RoamApp(object):
    def __init__(self, sysargv, apppath, prefixpath, settingspath, libspath,
                 i18npath, projectsroot):
        self.sysargv = sysargv
        self.apppath = apppath
        self.prefixpath = prefixpath
        self.settingspath = settingspath
        self.approot = apppath
        self.profileroot = apppath
        self.libspath = libspath
        self.i18npath = i18npath
        self.app = None
        self.translationFile = None
        self.projectsroot = projectsroot
        self._oldhook = sys.excepthook
        self.sourcerun = False
        self.config = None

    def init(self, logo, title, **kwargs):
        from qgis.core import QgsApplication
        from qgis.PyQt.QtWidgets import QApplication
        from qgis.PyQt.QtGui import QFont, QIcon
        from qgis.PyQt.QtCore import QLocale, QTranslator
        try:
            import qgis.PyQt.QtSql
        except ImportError:
            pass

        # In python3 we need to convert to a bytes object (or should
        # QgsApplication accept a QString instead of const char* ?)
        try:
            argvb = list(map(os.fsencode, sys.argv))
        except AttributeError:
            argvb = sys.argv

        self.app = QgsApplication(argvb, True)
        QgsApplication.setPrefixPath(self.prefixpath, True)
        QgsApplication.initQgis()

        locale = QLocale.system().name()
        self.translationFile = os.path.join(self.i18npath,
                                            '{0}.qm'.format(locale))
        translator = QTranslator()
        translator.load(self.translationFile, "i18n")
        self.app.installTranslator(translator)

        QApplication.setStyle("Plastique")
        QApplication.setFont(QFont('Segoe UI'))
        QApplication.setWindowIcon(QIcon(logo))
        QApplication.setApplicationName(title)

        import roam.editorwidgets.core
        if "register_widgets" not in kwargs:
            register_widgets = True
        else:
            register_widgets = False

        if register_widgets:
            roam.editorwidgets.core.registerallwidgets()
        import roam.qgisfunctions
        return self

    @property
    def data_folder(self):
        return os.path.join(self.projectsroot, "_data")

    def set_error_handler(self, errorhandler, logger):
        sys.excepthook = functools.partial(self.excepthook, errorhandler)
        self.logger = logger

    def excepthook(self, errorhandler, exctype, value, traceback):
        self.logger.error("Uncaught exception",
                          exc_info=(exctype, value, traceback))
        errorhandler(exctype, value, traceback)

    def exec_(self):
        self.app.exec_()

    def exit(self):
        sys.excepthook = self._oldhook
        from qgis.core import QgsApplication
        QgsApplication.exitQgis()
        QgsApplication.quit()

    def setActiveWindow(self, widget):
        self.app.setActiveWindow(widget)

    def dump_configinfo(self):
        from qgis.core import QgsApplication, QgsProviderRegistry
        import roam
        from qgis.core import Qgis

        config = []
        config.append("====Providers===")
        config.append(QgsProviderRegistry.instance().pluginList())
        config.append("====Library paths===")
        config.append('\n'.join(QgsApplication.libraryPaths()))
        config.append("====Translation File===")
        config.append(self.translationFile)
        config.append("Roam Version: {}".format(roam.__version__))
        config.append(u"QGIS Version: {}".format(str(Qgis.QGIS_VERSION)))
        return '\n'.join(config)
예제 #8
0
파일: __main__.py 프로젝트: SFrav/Roam
from PyQt4.QtGui import QApplication, QFont, QImageReader, QImageWriter
from PyQt4.QtCore import QDir, QCoreApplication, QLibrary
import PyQt4.QtSql

uic.uiparser.logger.setLevel(logging.INFO)
uic.properties.logger.setLevel(logging.INFO)

# We have to start this here or else the image drivers don't load for some reason
app = QgsApplication(sys.argv, True)
locale = PyQt4.QtCore.QLocale.system().name()

translationFile = os.path.join(roamapp.i18npath, '{0}.qm'.format(locale))

translator = PyQt4.QtCore.QTranslator()
translator.load(translationFile, "i18n")
app.installTranslator(translator)

import roam
import roam.yaml as yaml
import roam.utils
from roam.mainwindow import MainWindow

def excepthook(errorhandler, exctype, value, traceback):
    errorhandler(exctype, value, traceback)
    roam.utils.error("Uncaught exception", exc_info=(exctype, value, traceback))

start = time.time()
roam.utils.info("Loading Roam")


roam.utils.info("Attempted to load translation file: " + translationFile)
예제 #9
0
파일: environ.py 프로젝트: FSAS-NUS/Roam
class RoamApp(object):
    def __init__(self, sysargv, apppath, prefixpath, settingspath, libspath,
                 i18npath, projectsroot):
        self.sysargv = sysargv
        self.apppath = apppath
        self.prefixpath = prefixpath
        self.settingspath = settingspath
        self.approot = apppath
        self.profileroot = apppath
        self.libspath = libspath
        self.i18npath = i18npath
        self.app = None
        self.translationFile = None
        self.projectsroot = projectsroot
        self._oldhook = sys.excepthook
        self.sourcerun = False

    def init(self, logo, title):
        from qgis.core import QgsApplication
        from PyQt4.QtGui import QApplication, QFont, QIcon
        from PyQt4.QtCore import QLocale, QTranslator
        try:
            import PyQt4.QtSql
        except ImportError:
            pass

        self.app = QgsApplication(self.sysargv, True)
        QgsApplication.setPrefixPath(self.prefixpath, True)
        QgsApplication.initQgis()

        locale = QLocale.system().name()
        self.translationFile = os.path.join(self.i18npath,
                                            '{0}.qm'.format(locale))
        translator = QTranslator()
        translator.load(self.translationFile, "i18n")
        self.app.installTranslator(translator)

        QApplication.setStyle("Plastique")
        QApplication.setFont(QFont('Segoe UI'))
        QApplication.setWindowIcon(QIcon(logo))
        QApplication.setApplicationName(title)

        import roam.editorwidgets.core
        roam.editorwidgets.core.registerallwidgets()
        import roam.qgisfunctions
        return self

    def set_error_handler(self, errorhandler, logger):
        sys.excepthook = functools.partial(self.excepthook, errorhandler)
        self.logger = logger

    def excepthook(self, errorhandler, exctype, value, traceback):
        self.logger.error("Uncaught exception",
                          exc_info=(exctype, value, traceback))
        errorhandler(exctype, value, traceback)

    def exec_(self):
        self.app.exec_()

    def exit(self):
        sys.excepthook = self._oldhook
        from qgis.core import QgsApplication
        QgsApplication.exitQgis()
        QgsApplication.quit()

    def setActiveWindow(self, widget):
        self.app.setActiveWindow(widget)

    def dump_configinfo(self):
        from qgis.core import QgsApplication, QgsProviderRegistry
        from PyQt4.QtGui import QImageReader, QImageWriter
        import roam
        from qgis.core import QGis

        config = []
        config.append("====Providers===")
        config.append(QgsProviderRegistry.instance().pluginList())
        config.append("====Library paths===")
        config.append('\n'.join(QgsApplication.libraryPaths()))
        config.append("====Translation File===")
        config.append(self.translationFile)
        config.append("Roam Version: {}".format(roam.__version__))
        config.append(u"QGIS Version: {}".format(unicode(QGis.QGIS_VERSION)))
        return '\n'.join(config)