Esempio n. 1
0
    def start_monitoring(cls):
        """Subscribe to the TimeDisplay events for purposes of backing up
        the timer in case of crash.
        """
        if cls._active:
            return

        cls._backup_dir.mkdir(parents=True, exist_ok=True)

        cls._active = True

        def tick(hours, minutes, seconds):
            # Prevent any other instances of Timecard from claiming recoveries
            cls._query.unlink(missing_ok=True)
            cls.remember(hours, minutes, seconds)

        def stop(erase):
            if erase:
                cls.forget()

        TimeDisplay.connect(on_minute=tick, on_stop=stop)
Esempio n. 2
0
    def build(cls):
        """Construct the system tray"""
        cls.systray.setIcon(App.icon)

        cls.act_status.setText("00:00:00")
        cls.menu.addAction(cls.act_status)

        cls.menu.addAction(cls.act_time)
        cls.set_mode_stopped()

        cls.menu.addSeparator()

        cls.act_toggle.setIcon(QIcon.fromTheme('view-restore'))
        cls.act_toggle.setText("Show/Hide Window")
        cls.act_toggle.triggered.connect(cls.toggle_window)
        cls.menu.addAction(cls.act_toggle)

        cls.menu.addSeparator()

        cls.act_quit.setIcon(QIcon.fromTheme('application-exit'))
        cls.act_quit.setText("Quit Timecard")
        cls.act_quit.triggered.connect(cls.quit_app)
        cls.menu.addAction(cls.act_quit)

        cls.systray.setContextMenu(cls.menu)
        cls.systray.show()

        TimeDisplay.connect(on_tick=cls.update_time)
        TimeControls.connect(on_start=cls.set_mode_running,
                             on_resume=cls.set_mode_running,
                             on_pause=cls.set_mode_paused,
                             on_stop=cls.set_mode_save,
                             on_save=cls.set_mode_stopped,
                             on_reset=cls.set_mode_stopped)
        App.connect(on_hide=cls.popup)

        return cls.systray
Esempio n. 3
0
 def initialize(cls):
     """Initialize focus popup notification system."""
     cls.reload_settings()
     TimeDisplay.connect(on_minute=cls.notify)