Exemplo n.º 1
0
 def _show_temp_toolbar(self):
     self._sleep.set()
     self._sleep.clear()
     ui.Ctrl().enable_toolbar_action("light", True)
     ui.Ctrl().enable_toolbar_action("settings", True)
     if not self._sleep.wait(3):
         ui.Ctrl().enable_toolbar_action("light", False)
         ui.Ctrl().enable_toolbar_action("settings", False)
Exemplo n.º 2
0
 def _trigger_alarm(self, uid, success):
     if success:
         play_alarm = self._get_alarm_from_uid(uid)
         if play_alarm is not None:
             ui.Ctrl().set_screen(ui.Screen.SNOOZE)
             if self._player.play(play_alarm.playback()) and self._snoozed:
                 self._snoozed = self._snoozed - 1
                 new_time = datetime.datetime.now() + datetime.timedelta(
                     minutes=self._snooze_time
                 )
             else:
                 self._snoozed = self._default_snoozed
                 new_time = play_alarm.find_next_alarm()
             self._alarms[play_alarm] = self._schedule_alarm(new_time)
             ui.Ctrl().back()
Exemplo n.º 3
0
    def __init__(self, settings, parent=None):
        super(SettingsScreen, self).__init__(parent)
        ui.Ctrl().enable_toolbar_action("save", True, event=self._save)

        self._settings = settings
        self._settings_dict = self._create_settings_dict(settings)
        self._create_layout()
Exemplo n.º 4
0
    def __init__(self, alarm_manager, weather, parent=None):
        super(HomeScreen, self).__init__(parent)
        ui.Ctrl().enable_toolbar_action("back", False)
        self._sleep = threading.Event()

        vert_layout = create_vertical_layout(self)
        vert_layout.addWidget(WeatherGroup(weather))
        vert_layout.addStretch()
        vert_layout.addWidget(Time(FontSize.EXTRALARGE))
        vert_layout.addStretch()
        vert_layout.addWidget(NextAlarm(alarm_manager.get_next_alarm_time()))
Exemplo n.º 5
0
 def _save(self, _):
     try:
         hour, minute = self._time_widget.get_time()
         new_alarm = alarm.alarm.Alarm(
             hour,
             minute,
             self._days_widget.get_active_days(),
             self._playback.get_playback(),
             self._active_switch.is_active(),
         )
         self._alarm_manager.remove_alarm(self._edit_alarm)
         self._alarm_manager.create_alarm(new_alarm)
         ui.Ctrl().back()
     except Exception as err:
         _error_message(str(err))
Exemplo n.º 6
0
 def focusInEvent(self, e):
     super(LineEdit, self).focusInEvent(e)
     self._keyboard = ui.Ctrl().enable_keyboard()
     self._keyboard.connect(self._keyboard_edit)
Exemplo n.º 7
0
def _click_event(_):
    ui.Ctrl().set_screen(ui.Screen.VIEW)
Exemplo n.º 8
0
        os.environ.get("LOGFILE", "piealarm.log"))

    formatter = logging.Formatter(logging.BASIC_FORMAT)
    handler.setFormatter(formatter)
    root = logging.getLogger()
    root.setLevel(os.environ.get("LOGLEVEL", "INFO"))
    root.addHandler(handler)


if __name__ == "__main__":
    setup_logging()
    try:
        w = weather.weather.Weather(weather.darksky.Darksky())
        # w.start_api_poll()
        s = settings.interface.Interface()
        p = sound.player.Player()
        ui.Ctrl().init(
            PyQt5.QtWidgets.QApplication([os.sys.argv]),
            ui.window.Window(),
            alarm.manager.Manager(s),
            w,
            p,
            s,
        )
        ui.Ctrl().exec(screen=ui.Screen.PLAYER, theme="dark")
        # ui.Ctrl().exec(theme="dark")
    except Exception as e:
        logging.exception("Exception in main()")
        print(e)
        exit(1)
Exemplo n.º 9
0
 def _delete(self, _):
     self._alarm_manager.remove_alarm(self._edit_alarm)
     ui.Ctrl().back()