Example #1
0
 def complete_entry(self, btn_obj):
     db.complete_entry(btn_obj.id)
     self.ready_to_revoke_entries.append(btn_obj.text)
     self.ids.entries_panel_id.remove_widget(btn_obj)
     self.ids.revoke_btn_id.disabled = False
     self.refresh_entries(
     )  # TODO remove and refactor label sizing in refresh_entries
Example #2
0
 def create_list(self, text):
     order_id_of_list = 1  # TODO - fix lists order display
     text = text.strip()
     if text:
         result = db.create_list(text, order_id_of_list)
         if not result:
             MainApp.open_error_popup(lang.get('db_error'))
         else:
             last_list = db.read_last_list()[0]
             self.add_list(
                 last_list[0],  # list id
                 last_list[1],  # list name
                 0,  # index
             )
Example #3
0
 def load_choices(self, entry_name_part):
     self.suggestions.clear()
     for i in db.read_entries_by_name_part(
             int(main.EntriesScreen.current_list_id), entry_name_part):
         self.suggestions.append(i)
     self.suggestions.reverse(
     )  # the first entry hast to be under TextInput - its the last position in suggestions
Example #4
0
 def open_list(self, btn_obj):
     EntriesScreen.current_list_id = btn_obj.id
     EntriesScreen.current_list_name = db.get_list_name(btn_obj.id)
     self.manager.transition = CardTransition(
         direction='left',
         duration=float(
             config.get_option_value('screen_transition_duration')))
     self.manager.current = "entries_screen"
Example #5
0
 def build(self):
     # TODO refactor backgroung - handle list type for config.get()
     backgroung_dict = {
         'Orange': [0.8, 0.4, 0.0, 1],
         "White": [1.0, 1.0, 1.0, 1],
         "Black": [0, 0, 0, 1],
     }
     Window.clearcolor = backgroung_dict[config.get_option_value(
         'background_colour')]
     Window.softinput_mode = 'below_target'  # TextInput keyboard position https://android.developreference.com/article/19684878/Android+on-screen+keyboard+hiding+Python+Kivy+TextInputs
     # TODO move ALL paths to system settings
     self.icon = 'images/icon.png'
     self.title = F"{config.get_option_value('app_title')}  {config.get_option_value('app_version')}"
     config.load_config()
     db.create_db()
     lang.reload_lang()
     return ScreenManagement()
Example #6
0
 def refresh_lists(self, *l):
     lists = db.read_lists()
     self.ids.lists_panel_id.clear_widgets()
     for i in lists:
         self.add_list(
             i[0],  # list id
             i[1],  # list name
             0,  # index
         )
Example #7
0
 def refresh_history(self):
     self.entries_list = db.read_entries_history(
         int(EntriesScreen.current_list_id))
     self.apply_entries_sorting()
     self.ids.history_panel_id.clear_widgets()
     for entry_num in range(len(self.entries_list)):
         self.add_entry(
             self.entries_list[entry_num][0],  # entry_id
             self.entries_list[entry_num][2],  # entry_name
             0,  # index
         )
Example #8
0
    def refresh_entries(self):
        entries_list = db.read_entries(int(self.current_list_id))
        # entries_list_height = self.get_parent_window().height - self.ids.entries_upper_panel_id.height - self.ids.input_id.height
        # entry_height = int(config.get('entries_height')[:-2]) + int(config.get('padding'))

        for i in self.ids.entries_panel_id.children:  # remove all entries buttons and entries note buttons
            i.clear_widgets()
        self.ids.entries_panel_id.clear_widgets()
        # if len(entries_list) > 0 and range(len(entries_list) < 9):
        #
        #     label = Label(
        #         id='entries_label_id',
        #         size=(1,   (entries_list_height - (len(entries_list) * entry_height))),
        #         size_hint=(None, None),
        #     )
        #     self.ids.entries_panel_id.add_widget(label, 0)
        for entry_num in range(len(entries_list)):
            self.add_entry(
                entries_list[entry_num][0],  # entry_id
                entries_list[entry_num][2],  # entry_name
                0,  # index
            )
Example #9
0
 def apply_delete_entry(self):
     for i in self.entries_list_to_delete:
         db.delete_entry(i[0])
     self.entries_list_to_delete.clear()
     self.ids.revoke_btn_id.disabled = True
Example #10
0
 def rename_list(self, text):
     if text != self.list_name:
         db.rename_list(self.list_name, text)
Example #11
0
 def init_entries_notes_screen(self):
     self.note_text = db.get_entry_note(self.entry_id[:-1])
     self.ids.note_id.text = self.note_text
Example #12
0
        self.icon = 'images/icon.png'
        self.title = F"{config.get_option_value('app_title')}  {config.get_option_value('app_version')}"
        config.load_config()
        db.create_db()
        lang.reload_lang()
        return ScreenManagement()

    def build_config(self, app_config):
        app_config.setdefaults(
            '',
            {
                # 'font_size': '15dp',
                # 'entries_font_size': 42,
                # 'lists_font_size': '15dp',
                'app_version': '0.0.20',
                'app_title': 'TODOit',
                'db_path': "..//TODO.db",
            },
        )

    @staticmethod
    def open_error_popup(text):
        CustomWidgets.ErrorPopup.error_text = text
        CustomWidgets.ErrorPopup().open()


if __name__ == '__main__':
    db.create_db()  # create database at first start
    db.run_migrations()  # update db to the actual state
    MainApp().run()
Example #13
0
 def save_note(self, ):
     self.manager.change_screen('entries_screen', "left")
     db.set_entry_note(self.entry_id[:-1], self.ids.note_id.text)
     self.ids.note_id.text = ''
Example #14
0
 def reset_db():
     db.recreate_database()
Example #15
0
 def create_entry(self, text):
     text = text.strip()
     if text:
         db.create_entry(int(self.current_list_id), text)
         self.refresh_entries()
Example #16
0
 def delete_list(self, btn_obj):
     db.delete_list_by_id(btn_obj.id)
     self.ids.lists_panel_id.remove_widget(btn_obj)
Example #17
0
 def delete_list(self):
     list_id = db.get_list_id(
         self.ids.list_name_id.text.replace(lang.get('tap_to_edit'), ''))
     db.delete_list_by_id(list_id)
     self.dismiss()