Пример #1
0
 def on_btn_stop(self):
     enable_finish = config.read_conf('run_commands', 'active_after')
     if enable_finish == 1 and \
             isinstance(self.fms.state, state.TomatoState):
         utils.run('after')
     icon = utils.image_tray('init-tomat.png')
     self.trayIcon.setIcon(icon)
     self.fms.next_state(state.StopEvent(), time.time())
Пример #2
0
 def on_btn_start(self):
     icon = utils.image_tray('red-tomat.png')
     enable_start = config.read_conf('run_commands', 'active_before')
     if enable_start == 1:
         utils.run('before')
     self.trayIcon.setIcon(icon)
     self.fms.next_state(state.StartEvent, time.time())
     self.timer.start(100)
Пример #3
0
    def create_tray_icon(self):
        icon = utils.image_tray('init-tomat.png')
        menu = QtGui.QMenu(self)

        self.startAction = menu.addAction("Start Tomacco")
        self.startAction.triggered.connect(self.start_tray)

        self.stopAction = menu.addAction("Stop")
        self.stopAction.triggered.connect(self.stop_tray)

        self.shortAction = menu.addAction("Short Pause")
        self.shortAction.triggered.connect(self.short_tray)

        self.longAction = menu.addAction("Long Pause")
        self.longAction.triggered.connect(self.long_tray)

        menu.addSeparator()

        self.forceTomacco = menu.addAction("Force Tomacco")
        self.forceTomacco.triggered.connect(self.start_tray)

        self.forceShort = menu.addAction("Force Short")
        self.forceShort.triggered.connect(self.short_tray)

        self.forceLong = menu.addAction("Force Long")
        self.forceLong.triggered.connect(self.long_tray)

        resetAction = menu.addAction("Reset Tomacco")
        resetAction.triggered.connect(self.forse_stop)
        menu.addSeparator()

        settingAction = menu.addAction("Settings")
        settingAction.triggered.connect(self.dialog.show)
        exitAction = menu.addAction("Quit")
        exitAction.triggered.connect(self.quit_app)

        self.trayIcon = QtGui.QSystemTrayIcon(self)
        self.trayIcon.setContextMenu(menu)
        self.trayIcon.setIcon(icon)
Пример #4
0
 def on_btn_lpause(self):
     icon = utils.image_tray('long-tomat.png')
     self.trayIcon.setIcon(icon)
     self.fms.next_state(state.LongEvent(), time.time())
     self.timer.start(100)
Пример #5
0
 def on_btn_spause(self):
     icon = utils.image_tray('short-tomat.png')
     self.trayIcon.setIcon(icon)
     self.fms.next_state(state.ShortEvent(), time.time())
     self.timer.start(100)
Пример #6
0
    def update_window(self):
        if isinstance(self.fms.state, state.InitState):
            self.timer.stop()
            icon = utils.image_tray('init-tomat.png')
            self.trayIcon.setIcon(icon)
            self.trayIcon.setToolTip(self.tomacco_label())
            self.ui.status_bar.showMessage("Tomacco - " +
                                           str(self.fms.tomacco))
            self.ui.lcd.display(str('00:00'))
            self.ui.btn_start.show()
            self.ui.btn_stop.hide()
            self.ui.btn_lpause.hide()
            self.ui.btn_spause.hide()
            self.startAction.setDisabled(False)
            self.stopAction.setDisabled(True)
            self.shortAction.setDisabled(True)
            self.longAction.setDisabled(True)

        elif isinstance(self.fms.state, state.TomatoState):
            self.ui.btn_stop.setText('Stop \n Tomacco')
            self.ui.status_bar.showMessage(self.tomacco_label() +
                                           ' Counting...')
            self.ui.lcd.display(self.view_time(self.fms.tomat))
            self.trayIcon.setToolTip(self.tomacco_label() + '\n' +
                                     self.view_time(self.fms.tomat))
            self.ui.btn_start.hide()
            self.ui.btn_stop.show()
            self.stopAction.setDisabled(False)
            self.startAction.setDisabled(True)
            self.shortAction.setDisabled(True)
            self.longAction.setDisabled(True)

        elif isinstance(self.fms.state, state.SelectState):
            self.timer.stop()
            icon = utils.image_tray('init-tomat.png')
            self.trayIcon.setIcon(icon)
            self.trayIcon.setToolTip(self.tomacco_label())
            self.ui.status_bar.showMessage(self.tomacco_label() +
                                           " Select Pause")
            self.ui.lcd.display(str('--:--'))
            self.ui.btn_start.hide()
            self.ui.btn_stop.hide()
            self.ui.btn_lpause.show()
            self.ui.btn_spause.show()
            self.stopAction.setDisabled(True)
            self.startAction.setDisabled(True)
            self.shortAction.setDisabled(False)
            self.longAction.setDisabled(False)

        elif isinstance(self.fms.state, state.ShortState):
            self.ui.status_bar.showMessage(self.tomacco_label() +
                                           " Short Pause")
            self.ui.lcd.display(self.view_time(self.fms.spause))
            self.trayIcon.setToolTip(self.tomacco_label() + '\n' +
                                     self.view_time(self.fms.spause))
            self.ui.btn_lpause.hide()
            self.ui.btn_spause.hide()
            self.ui.btn_start.hide()
            self.ui.btn_stop.show()
            self.ui.btn_stop.setText('Stop \n Short Pause')
            self.stopAction.setDisabled(False)
            self.startAction.setDisabled(True)
            self.shortAction.setDisabled(True)
            self.longAction.setDisabled(True)

        elif isinstance(self.fms.state, state.LongState):
            self.ui.status_bar.showMessage(self.tomacco_label() +
                                           " Long Pause")
            self.ui.lcd.display(self.view_time(self.fms.lpause))
            self.trayIcon.setToolTip(self.tomacco_label() + '\n' +
                                     self.view_time(self.fms.lpause))
            self.ui.btn_lpause.hide()
            self.ui.btn_spause.hide()
            self.ui.btn_start.hide()
            self.ui.btn_stop.show()
            self.ui.btn_stop.setText('Stop \n Long Pause')
            self.stopAction.setDisabled(False)
            self.startAction.setDisabled(True)
            self.shortAction.setDisabled(True)
            self.longAction.setDisabled(True)