예제 #1
0
    def __init__(self, m, d, i):
        GUIModule.__init__(self, m, d, i)

        # some constants
        self.msLongPress = 400
        self.centeringDisableThreshold = 2048
        self.firstTimeSignal = signal.Signal()
        size = (800, 480) # initial window size

        # register exit handler
        pyotherside.atexit(self._shutdown)

        # window state
        self._fullscreen = False

        # get screen resolution
        # TODO: implement this
        #screenWH = self.getScreenWH()
        #print(" @ screen size: %dx%d" % screenWH)
        #if self.highDPI:
        #    print(" @ high DPI")
        #else:
        #    print(" @ normal DPI")

        # NOTE: what about multi-display devices ? :)

        ## add image providers

        self._imageProviders = {
            "icon" : IconImageProvider(self),
            "tile" : TileImageProvider(self),
        }

        with open("data/tile_not_found.png", "rb") as f:
            self._tileNotFoundImage = f.read()

        ## register the actual callback, that
        ## will call the appropriate provider base on
        ## image id prefix
        pyotherside.set_image_provider(self._selectImageProviderCB)

        # initialize theming
        self._theme = Theme(self)

        ## make constants accessible
        #self.constants = self.getConstants()
        #rc.setContextProperty("C", self.constants)

        ## connect to the close event
        #self.window.closeEvent = self._qtWindowClosed
        ##self.window.show()

        self._notificationQueue = []

        # provides easy access to modRana modules from QML
        self.modules = Modules(self)

        # search functionality for the QML context
        self.search = Search(self)
예제 #2
0
    def __init__(self, *args, **kwargs):
        GUIModule.__init__(self, *args, **kwargs)

        # some constants
        self.msLongPress = 400

        # window state
        self.fullscreen = False

        # map center shifting variables
        self.centerShift = (0, 0)
        self.expandViewportTiles = 0.0

        # viewport
        self.viewportWH = (0,0)

        """
        NOTE: we are calling the device module through the main class
        as it otherwise is first available in firstTime
        """

        # create the GTK window

        # when on N900, use a hildon StackableWindow, which
        # enables app menu and other features on Maemo 5
        if self.modrana.dmod.device_id == 'n900':
            try:
                import hildon

                win = hildon.StackableWindow()
            except Exception:
                self.log.exception("creating hildon stackable window failed")
                win = gtk.Window()
        else:
            win = gtk.Window()
        self.win = win
        win.connect("destroy", self._destroyCB)

        # register centering.shift callbacks
        self._registerCenteringShiftCallbacks()

        # resize it to preferred width x height
        (w, h) = self.modrana.dmod.window_wh
        self.resize(w, h)
        self.modrana.addTime("window created")
        # set title
        self.setWindowTitle("modRana")
        # connect delete event
        win.connect('delete-event', gtk.main_quit)

        ## Instantiate the main widget ##
        self.mw = MainWidget(self)
        self.mw.topWindow = win
        # make the main window accessible from modules
        self.topWindow = win
        self.modrana.addTime("map widget created")

        # check if we should start in fullscreen
        if self.shouldStartInFullscreen():
            self.setFullscreen(True)

        # Event handling
        event_box = gtk.EventBox()

        event_box.connect("button_press_event", self.mw.pressed)
        event_box.connect("button_release_event", self.mw.released)
        event_box.connect("scroll_event", self.mw.scrolled)
        event_box.connect("motion_notify_event", self.mw.moved)
        win.add(event_box)

        # add redraw request watch
        self.watch('needRedraw', self.mw._checkForRedrawCB) # react on redraw requests
        # TODO: add a function for directly requesting redraw

        event_box.add(self.mw)
        # Finalise the window
        win.show_all()
        self.modrana.addTime("window finalized")
예제 #3
0
    def __init__(self, *args, **kwargs):
        GUIModule.__init__(self, *args, **kwargs)

        # some constants
        self.msLongPress = 400
        self.centeringDisableThreshold = 2048
        self.firstTimeSignal = signal.Signal()
        size = (800, 480)  # initial window size
        self._screen_size = None

        # positioning related
        self._pythonPositioning = False

        # we handle notifications by forwarding them to the QML context
        self.modrana.notificationTriggered.connect(
            self._dispatchNotificationCB)

        # register exit handler
        #pyotherside.atexit(self._shutdown)
        # FIXME: for some reason the exit handler is never
        # called on Sailfish OS, so we use a onDestruction
        # handler on the QML side to trigger shutdown

        # window state
        self._fullscreen = False

        # get screen resolution
        # TODO: implement this
        #screenWH = self.getScreenWH()
        #self.log.debug(" @ screen size: %dx%d" % screenWH)
        #if self.highDPI:
        #    self.log.debug(" @ high DPI")
        #else:
        #    self.log.debug(" @ normal DPI")

        # NOTE: what about multi-display devices ? :)

        ## add image providers

        self._imageProviders = {
            "icon": IconImageProvider(self),
            "tile": TileImageProvider(self),
        }

        # log what version of PyOtherSide we are using
        # - we log this without prefix as this shows up early
        #   during startup, so it looks nicer that way :-)
        no_prefix_log.info("using PyOtherSide %s", pyotherside.version)

        ## register the actual callback, that
        ## will call the appropriate provider base on
        ## image id prefix
        pyotherside.set_image_provider(self._selectImageProviderCB)

        # initialize theming
        self._theme = Theme(self)

        ## make constants accessible
        #self.constants = self.getConstants()
        #rc.setContextProperty("C", self.constants)

        ## connect to the close event
        #self.window.closeEvent = self._qtWindowClosed
        ##self.window.show()

        self._notificationQueue = []

        # provides easy access to modRana modules from QML
        self.modules = Modules(self)

        # search functionality for the QML context
        self.search = Search(self)

        # POI handling for the QML context
        self.POI = POI(self)

        # make the log manager easily accessible
        self.log_manager = modrana_log.log_manager

        # log for log messages from the QML context
        self.qml_log = qml_log
        # queue a notification to QML context that
        # a Python loggers is available
        pyotherside.send("loggerAvailable")

        # tracklogs
        self.tracklogs = Tracklogs(self)

        #routing
        self.routing = Routing(self)

        # turn by turn navigation
        self.navigation = Navigation(self)
예제 #4
0
    def __init__(self, m, d, i):
        GUIModule.__init__(self, m, d, i)

        # some constants
        self.msLongPress = 400

        # window state
        self.fullscreen = False

        # map center shifting variables
        self.centerShift = (0, 0)
        self.expandViewportTiles = 0.0

        # viewport
        self.viewportWH = (0,0)

        """
        NOTE: we are calling the device module through the main class
        as it otherwise is first available in firstTime
        """

        # create the GTK window

        # when on N900, use a hildon StackableWindow, which
        # enables app menu and other features on Maemo 5
        if self.modrana.dmod.getDeviceIDString() == 'n900':
            try:
                import hildon

                win = hildon.StackableWindow()
            except Exception:
                import sys

                e = sys.exc_info()[1]
                print("creating hildon stackable window failed")
                print(e)
                win = gtk.Window()
        else:
            win = gtk.Window()
        self.win = win
        win.connect("destroy", self._destroyCB)

        # register centering.shift callbacks
        self._registerCenteringShiftCallbacks()

        # resize it to preferred width x height
        (w, h) = self.modrana.dmod.getWinWH()
        self.resize(w, h)
        self.modrana.addTime("window created")
        # set title
        self.setWindowTitle("modRana")
        # connect delete event
        win.connect('delete-event', gtk.main_quit)

        ## Instantiate the main widget ##
        self.mw = MainWidget(self)
        self.mw.topWindow = win
        # make the main window accessible from modules
        self.topWindow = win
        self.modrana.addTime("map widget created")

        # Event handling
        event_box = gtk.EventBox()

        event_box.connect("button_press_event", self.mw.pressed)
        event_box.connect("button_release_event", self.mw.released)
        event_box.connect("motion_notify_event", self.mw.moved)
        win.add(event_box)

        # add redraw request watch
        self.watch('needRedraw', self.mw._checkForRedrawCB) # react on redraw requests
        # TODO: add a function for directly requesting redraw

        event_box.add(self.mw)
        # Finalise the window
        win.show_all()
        self.modrana.addTime("window finalized")
예제 #5
0
파일: gui_qml.py 프로젝트: fferner/modrana
    def __init__(self, *args, **kwargs):
        GUIModule.__init__(self, *args, **kwargs)

        # some constants
        self.msLongPress = 400
        self.centeringDisableThreshold = 2048
        self.firstTimeSignal = signal.Signal()
        size = (800, 480) # initial window size

        # window state
        self.fullscreen = False

        # Create Qt application and the QDeclarative view
        class ModifiedQDeclarativeView(QDeclarativeView):
            def __init__(self, modrana):
                QDeclarativeView.__init__(self)
                self.modrana = modrana

            def closeEvent(self, event):
                print("shutting down")
                self.modrana.shutdown()

        self.app = QApplication(sys.argv)
        startDragDistance = self.modrana.dmod.getStartDragDistance()
        if startDragDistance:
            self.app.setStartDragDistance(startDragDistance)

        # get screen resolution
        screenWH = self.getScreenWH()
        print(" @ screen size: %dx%d" % screenWH)
        if self.highDPI:
            print(" @ high DPI")
        else:
            print(" @ normal DPI")

        # NOTE: what about multi-display devices ? :)

        # register custom modRana types
        # NOTE: custom types need to be registered AFTER
        # QApplication is created but BEFORE QDeclarativeView
        # is instantiated, or else horrible breakage occurs :)
        qmlRegisterType(drawing.PieChart, 'Charts', 1, 0, 'PieChart')
        qmlRegisterType(drawing.PieSlice, "Charts", 1, 0, "PieSlice")

        # m-declarative stuff implemented in Python
        qmlRegisterType(Screen, "mpBackend", 1, 0, "Screen")
        qmlRegisterType(Snapshot, "mpBackend", 1, 0, "Snapshot")

        self.view = ModifiedQDeclarativeView(self.modrana)
        self.window = QMainWindow()
        self.window.setWindowTitle("modRana")
        self.window.resize(*size)
        self.window.setCentralWidget(self.view)
        self.view.setResizeMode(QDeclarativeView.SizeRootObjectToView)
        #    self.view.setResizeMode(QDeclarativeView.SizeViewToRootObject)

        # add image providers
        self.iconProvider = IconImageProvider(self)
        self.view.engine().addImageProvider("icons", self.iconProvider)
        # add tiles provider
        self.tilesProvider = TileImageProvider(self)
        self.view.engine().addImageProvider("tiles", self.tilesProvider)

        rc = self.view.rootContext()
        # make core modRana functionality accessible from QML
        modRanaCore = ModRana(self.modrana, self)
        rc.setContextProperty("modrana", modRanaCore)
        # make options accessible from QML
        options = Options(self.modrana)
        rc.setContextProperty("options", options)
        # make GPS accessible from QML
        gps = GPSDataWrapper(self.modrana, self)
        rc.setContextProperty("gps", gps)
        # make the platform accessible from QML
        platform = Platform(self.modrana)
        rc.setContextProperty("platform", platform)
        # make the modules accessible from QML
        modules = Modules(self.modrana)
        rc.setContextProperty("modules", modules)
        # make tile loading accessible from QML
        tiles = MapTiles(self)
        rc.setContextProperty("mapTiles", tiles)
        # make map layers accessible from QML
        layers = MapLayers(self)
        rc.setContextProperty("mapLayers", layers)
        # make search accessible from QML
        search = Search(self)
        rc.setContextProperty("search", search)

        # make constants accessible
        self.constants = self.getConstants()
        rc.setContextProperty("C", self.constants)

        # connect to the close event
        self.window.closeEvent = self._qtWindowClosed
        #self.window.show()

        self.rootObject = None

        self._location = None # location module
        self._mapTiles = None # map tiles module
        self._mapLayers = None # map tiles module

        self._notificationQueue = []

        # list models
        self._addressSearchListModel = None
        self._layersListModel = None
예제 #6
0
파일: gui_qml.py 프로젝트: fferner/modrana
    def __init__(self, *args, **kwargs):
        GUIModule.__init__(self, *args, **kwargs)

        # some constants
        self.msLongPress = 400
        self.centeringDisableThreshold = 2048
        self.firstTimeSignal = signal.Signal()
        size = (800, 480)  # initial window size

        # window state
        self.fullscreen = False

        # Create Qt application and the QDeclarative view
        class ModifiedQDeclarativeView(QDeclarativeView):
            def __init__(self, modrana):
                QDeclarativeView.__init__(self)
                self.modrana = modrana

            def closeEvent(self, event):
                print("shutting down")
                self.modrana.shutdown()

        self.app = QApplication(sys.argv)
        startDragDistance = self.modrana.dmod.getStartDragDistance()
        if startDragDistance:
            self.app.setStartDragDistance(startDragDistance)

        # get screen resolution
        screenWH = self.getScreenWH()
        print(" @ screen size: %dx%d" % screenWH)
        if self.highDPI:
            print(" @ high DPI")
        else:
            print(" @ normal DPI")

        # NOTE: what about multi-display devices ? :)

        # register custom modRana types
        # NOTE: custom types need to be registered AFTER
        # QApplication is created but BEFORE QDeclarativeView
        # is instantiated, or else horrible breakage occurs :)
        qmlRegisterType(drawing.PieChart, 'Charts', 1, 0, 'PieChart')
        qmlRegisterType(drawing.PieSlice, "Charts", 1, 0, "PieSlice")

        # m-declarative stuff implemented in Python
        qmlRegisterType(Screen, "mpBackend", 1, 0, "Screen")
        qmlRegisterType(Snapshot, "mpBackend", 1, 0, "Snapshot")

        self.view = ModifiedQDeclarativeView(self.modrana)
        self.window = QMainWindow()
        self.window.setWindowTitle("modRana")
        self.window.resize(*size)
        self.window.setCentralWidget(self.view)
        self.view.setResizeMode(QDeclarativeView.SizeRootObjectToView)
        #    self.view.setResizeMode(QDeclarativeView.SizeViewToRootObject)

        # add image providers
        self.iconProvider = IconImageProvider(self)
        self.view.engine().addImageProvider("icons", self.iconProvider)
        # add tiles provider
        self.tilesProvider = TileImageProvider(self)
        self.view.engine().addImageProvider("tiles", self.tilesProvider)

        rc = self.view.rootContext()
        # make core modRana functionality accessible from QML
        modRanaCore = ModRana(self.modrana, self)
        rc.setContextProperty("modrana", modRanaCore)
        # make options accessible from QML
        options = Options(self.modrana)
        rc.setContextProperty("options", options)
        # make GPS accessible from QML
        gps = GPSDataWrapper(self.modrana, self)
        rc.setContextProperty("gps", gps)
        # make the platform accessible from QML
        platform = Platform(self.modrana)
        rc.setContextProperty("platform", platform)
        # make the modules accessible from QML
        modules = Modules(self.modrana)
        rc.setContextProperty("modules", modules)
        # make tile loading accessible from QML
        tiles = MapTiles(self)
        rc.setContextProperty("mapTiles", tiles)
        # make map layers accessible from QML
        layers = MapLayers(self)
        rc.setContextProperty("mapLayers", layers)
        # make search accessible from QML
        search = Search(self)
        rc.setContextProperty("search", search)

        # make constants accessible
        self.constants = self.getConstants()
        rc.setContextProperty("C", self.constants)

        # connect to the close event
        self.window.closeEvent = self._qtWindowClosed
        #self.window.show()

        self.rootObject = None

        self._location = None  # location module
        self._mapTiles = None  # map tiles module
        self._mapLayers = None  # map tiles module

        self._notificationQueue = []

        # list models
        self._addressSearchListModel = None
        self._layersListModel = None
예제 #7
0
파일: gui_qt5.py 프로젝트: ryfx/modrana
    def __init__(self, *args, **kwargs):
        GUIModule.__init__(self, *args, **kwargs)

        # some constants
        self.msLongPress = 400
        self.centeringDisableThreshold = 2048
        self.firstTimeSignal = signal.Signal()
        size = (800, 480) # initial window size

        # positioning related
        self._pythonPositioning = False

        # we handle notifications by forwarding them to the QML context
        self.modrana.notificationTriggered.connect(self._dispatchNotificationCB)

        # register exit handler
        #pyotherside.atexit(self._shutdown)
        # FIXME: for some reason the exit handler is never
        # called on Sailfish OS, so we use a onDestruction
        # handler on the QML side to trigger shutdown

        # window state
        self._fullscreen = False

        # get screen resolution
        # TODO: implement this
        #screenWH = self.getScreenWH()
        #self.log.debug(" @ screen size: %dx%d" % screenWH)
        #if self.highDPI:
        #    self.log.debug(" @ high DPI")
        #else:
        #    self.log.debug(" @ normal DPI")

        # NOTE: what about multi-display devices ? :)

        ## add image providers

        self._imageProviders = {
            "icon" : IconImageProvider(self),
            "tile" : TileImageProvider(self),
        }

        ## register the actual callback, that
        ## will call the appropriate provider base on
        ## image id prefix
        pyotherside.set_image_provider(self._selectImageProviderCB)

        # initialize theming
        self._theme = Theme(self)

        ## make constants accessible
        #self.constants = self.getConstants()
        #rc.setContextProperty("C", self.constants)

        ## connect to the close event
        #self.window.closeEvent = self._qtWindowClosed
        ##self.window.show()

        self._notificationQueue = []

        # provides easy access to modRana modules from QML
        self.modules = Modules(self)

        # search functionality for the QML context
        self.search = Search(self)

        # make the log manager easily accessible
        self.log_manager = modrana_log.log_manager

        # log for log messages from the QML context
        self.qml_log = qml_log
        # queue a notification to QML context that
        # a Python loggers is available
        pyotherside.send("loggerAvailable")

        # tracklogs
        self.tracklogs = Tracklogs(self)

        #routing
        self.routing = Routing(self)
예제 #8
0
파일: gui_qml.py 프로젝트: Wikiwide/modrana
  def __init__(self, m, d, i):
    GUIModule.__init__(self, m, d, i)

    # some constants
    self.msLongPress = 400
    self.centeringDisableThreshold = 2048
    size = (800, 480) # initial window size

    # window state
    self.fullscreen = False

    # Create Qt application and the QDeclarative view
    class ModifiedQDeclarativeView(QDeclarativeView):
      def __init__(self, modrana):
        QDeclarativeView.__init__(self)
        self.modrana = modrana

      def closeEvent(self, event):
        print("shutting down")
        self.modrana.shutdown()

    self.app = QApplication(sys.argv)

    # register custom modRana types
    # NOTE: custom types need to be registered AFTER
    # QApplication is created but BEFORE QDeclarativeView
    # is instantiated, or else horrible breakage occurs :)
    qmlRegisterType(drawing.PieChart, 'Charts', 1, 0, 'PieChart')
    qmlRegisterType(drawing.PieSlice, "Charts", 1, 0, "PieSlice")

    self.view = ModifiedQDeclarativeView(self.modrana)
    self.window = QMainWindow()
    self.window.setWindowTitle("modRana")
    self.window.resize(*size)
    self.window.setCentralWidget(self.view)
    self.view.setResizeMode(QDeclarativeView.SizeRootObjectToView)
    #    self.view.setResizeMode(QDeclarativeView.SizeViewToRootObject)

    # add image providers
    self.iconProvider = IconImageProvider()
    self.view.engine().addImageProvider("icons", self.iconProvider)
    # add tiles provider
    self.tilesProvider = TileImageProvider(self)
    self.view.engine().addImageProvider("tiles", self.tilesProvider)

    rc = self.view.rootContext()
    # make options accessible from QML
    options = Options(self.modrana)
    rc.setContextProperty("options", options)
    # make GPS accessible from QML
    gps = GPSDataWrapper(self.modrana, self)
    rc.setContextProperty("gps", gps)
    # make the platform accessible from QML
    platform = Platform(self.modrana)
    rc.setContextProperty("platform", platform)
    # make the modules accessible from QML
    modules = Modules(self.modrana)
    rc.setContextProperty("modules", modules)
    # make tile loading accessible from QML
    tiles = MapTiles(self)
    rc.setContextProperty("mapTiles", tiles)

    self.window.closeEvent = self._qtWindowClosed
    #self.window.show()

    self.rootObject = None

    self._location = None # location module
    self._mapTiles = None # map tiles module

    self._notificationQueue = []