Exemple #1
0
    def __init__(self):
        super().__init__()
        class CalendarDay(QtGui.QLabel): pass
        class CalendarFiller(CalendarDay): pass
        class CalendarWeekNumber(CalendarDay): pass

        firstweek = datetime.date(2013,1,1).isocalendar()[1]

        days = [[''.join(y).strip() for y in zip(row[::3], row[1::3])]
                    for row in calendar.month(2013,1).splitlines()[2:]]
        if len(days[-1]) < 7:
            days[-1].extend(['']*(7-len(days[-1])))
        if len(days) < 6:
            days.append(['']*7)
        days = [[str(weeknum)] + week for weeknum, week in zip(range(firstweek, firstweek+6), days)]

        layout = QtGui.QGridLayout(self)
        kill_theming(layout)

        item = []

        for y in range(6):
            item.append([])
            for x in range(8):
                if x == 0:
                    widget = CalendarWeekNumber
                elif days[y][x] == '':
                    widget = CalendarFiller
                else:
                    widget = CalendarDay
                item[y].append(widget(days[y][x]))
                layout.addWidget(item[y][x], y, x)
Exemple #2
0
    def create_sort_buttons(self, parent_layout):
        class SortButtonContainer(QtGui.QFrame):
            pass

        btn_container = SortButtonContainer(self)
        btn_layout = QtGui.QHBoxLayout(btn_container)
        parent_layout.addWidget(btn_container)
        kill_theming(btn_layout)

        btn_group = QtGui.QButtonGroup(self)

        class SortButtonLabel(QtGui.QLabel):
            pass

        btn_layout.addWidget(SortButtonLabel("Sort by:"))

        class SortButton(QtGui.QPushButton):
            pass

        for num, name in enumerate(["number", "date", "name"]):
            btn = SortButton(name)
            btn.setCheckable(True)
            btn.setChecked(num == 0)  # The first should be checked
            btn.setFlat(True)
            btn_group.addButton(btn, num)
            btn_layout.addWidget(btn)
        btn_layout.addStretch()

        btn_group.buttonClicked.connect(self.sort_list)
Exemple #3
0
 def __init__(self, list_widget_background, item_constructor):
     super().__init__()
     self.internal_widget = ListWidgetScrollArea(list_widget_background)
     self.internal_widget.item_constructor = item_constructor
     self.main_layout = QtGui.QVBoxLayout(self)
     kill_theming(self.main_layout)
     self.main_layout.addWidget(self.internal_widget)
Exemple #4
0
    def __init__(self, name):
        super().__init__()
        self.name = name

        self.setFlat(True)
        self.setCheckable(True)

        main_layout = QtGui.QHBoxLayout(self)
        self.name_lbl = self.TagName(name, self)
        main_layout.addWidget(self.name_lbl)
        main_layout.addStretch()

        class TagTotalCount(self.TagName): pass
        self.total_count_lbl = TagTotalCount('1', self)
        main_layout.addWidget(self.total_count_lbl)

        class TagCount(self.TagName): pass
        self.count_lbl = TagCount('1', self)
        main_layout.addWidget(self.count_lbl)

        kill_theming(main_layout)
        self.setLayout(main_layout)

        def toggle_children():
            for i in (self.name_lbl, self.count_lbl, self.total_count_lbl):
                i.setChecked(self.isChecked())
        self.toggled.connect(toggle_children)
Exemple #5
0
    def __init__(self):
        super().__init__()
        self.setWindowTitle('Mnemosyn')

        main_layout = QtGui.QHBoxLayout(self)
        kill_theming(main_layout)

        self.taglist, self.tasklist, self.counter \
            = read_tasklist(local_path('tasklist.json'))

        splitter = QtGui.QSplitter(self)
        main_layout.addWidget(splitter)

        # Create right (task) column
        self.date_interval_widget,\
        self.task_list_widget,\
        self.task_input_form,\
        task_column\
            = self.create_right_ui_column(self.tasklist)

        # Create left (tag and calendar) column
        self.tag_list_widget,\
        self.date_interval_input,\
        self.calendar_widget,\
        tag_column,\
            = self.create_left_ui_column(self.task_list_widget.list_items,
                                         self.taglist)

        # Connect slots/signals
        self.task_input_form.task_created.connect(self.task_created)
        self.tag_list_widget.tag_selection_updated.connect(\
                        self.task_list_widget.update_tag_selection)
        self.date_interval_input.interval_entered.connect(\
                        self.set_date_interval)

        splitter.addWidget(tag_column)
        splitter.addWidget(task_column)
        splitter.setStretchFactor(0,0)
        splitter.setStretchFactor(1,1)

        def reload_css():
            with open(local_path('qtstylesheet.css'), encoding='utf8') as f:
                stylesheet = f.read()
            self.setStyleSheet(stylesheet)
        reload_css()

        QtGui.QShortcut(QtGui.QKeySequence("Ctrl+R"), self, reload_css)

        def save_tasks():
            write_tasklist(local_path('tasklist.json'), self.taglist,
                            self.tasklist)

        QtGui.QShortcut(QtGui.QKeySequence("Ctrl+N"), self,
                        lambda: self.task_input_form.activate(self.counter))
        QtGui.QShortcut(QtGui.QKeySequence("Ctrl+S"), self, save_tasks)

        self.show()
        self.resize(800,600)
        splitter.moveSplitter(200,1)
        self.tag_list_widget.update_tag_count()
Exemple #6
0
 def __init__(self, list_widget_background):
     super().__init__()
     container = list_widget_background()
     self.list_items = []
     self.layout = QtGui.QVBoxLayout(container)
     kill_theming(self.layout)
     self.setWidget(container)
     self.setWidgetResizable(True)
    def __init__(self):
        super().__init__()
        class DateIntervalInputField(QtGui.QLineEdit): pass
        class DateIntervalInputLabel(QtGui.QLabel): pass

        layout = QtGui.QVBoxLayout(self)
        kill_theming(layout)
        self.interval_input = DateIntervalInputField()

        layout.addWidget(DateIntervalInputLabel('Date interval:'))
        layout.addWidget(self.interval_input)

        self.interval_input.returnPressed.connect(self.enter)
Exemple #8
0
    def __init__(self):
        super().__init__()
        class DateIntervalLabel(QtGui.QLabel): pass
        class DateIntervalDummyLabel(QtGui.QLabel): pass

        layout = QtGui.QHBoxLayout(self)
        kill_theming(layout)
        self.date_label = DateIntervalLabel()

        layout.addStretch()
        layout.addWidget(self.date_label)
        layout.addStretch()
        self.hide()
Exemple #9
0
    def __init__(self, parent=None):
        super().__init__(parent)
        self.number = -1

        class TaskInputFormTitle(QtGui.QLabel): pass
        self.title_label = TaskInputFormTitle('Title')

        class TaskInputFormLabel(QtGui.QLabel): pass
        text_label = TaskInputFormLabel('Text:', self)
        date_label = TaskInputFormLabel('Due date:', self)
        desc_label = TaskInputFormLabel('Description:', self)
        tags_label = TaskInputFormLabel('Tags:', self)

        class TaskInputFormField(QtGui.QLineEdit): pass
        self.text_input = self.TaskInputFormField(self)
        self.date_input = self.TaskInputFormField(self)
        self.desc_input = self.TaskInputFormMultiLine(self)
        self.tags_input = self.TaskInputFormField(self)

        self.desc_input.setFixedHeight(100)
        self.desc_input.setTabStopWidth(30)

        self.text_input.shift_tab_pressed.connect(self.tags_input.setFocus)
        self.text_input.tab_pressed.connect(self.date_input.setFocus)

        self.date_input.shift_tab_pressed.connect(self.text_input.setFocus)
        self.date_input.tab_pressed.connect(self.desc_input.setFocus)

        self.desc_input.shift_tab_pressed.connect(self.date_input.setFocus)
        self.desc_input.tab_pressed.connect(self.tags_input.setFocus)

        self.tags_input.shift_tab_pressed.connect(self.desc_input.setFocus)
        self.tags_input.tab_pressed.connect(self.text_input.setFocus)

        layout = QtGui.QFormLayout(self)
        layout.setLabelAlignment(Qt.AlignRight)
        kill_theming(layout)
        layout.addWidget(self.title_label)
        layout.addRow(text_label, self.text_input)
        layout.addRow(date_label, self.date_input)
        layout.addRow(desc_label, self.desc_input)
        layout.addRow(tags_label, self.tags_input)

        QtGui.QShortcut(QtGui.QKeySequence("Enter"), self, self.accept)
        QtGui.QShortcut(QtGui.QKeySequence("Escape"), self, self.hide)
        self.text_input.returnPressed.connect(self.accept)
        self.date_input.returnPressed.connect(self.accept)
        self.tags_input.returnPressed.connect(self.accept)

        self.hide()
Exemple #10
0
    def __init__(self, task):
        super().__init__()
        self.task = task

        self.is_visible = True

        if task['closed']:
            self.hide()

        main_layout = QtGui.QVBoxLayout(self)
        kill_theming(main_layout)

        self.num = None
        self.text = None
        self.date = None
        self.desc = None

        self.create_number_and_name_row(task, main_layout)
        self.create_date_row(task, main_layout)
        self.create_tag_row(task, main_layout)
        if task['desc']:
            self.create_description_row(task, main_layout)
Exemple #11
0
def create_basic_layout():
    container = QtGui.QWidget()
    layout = QtGui.QVBoxLayout(container)
    kill_theming(layout)
    return container, layout