def __init__(self, year, week_number, parent=None): """Construct a week wrapper object.""" self.logger = logging.getLogger(__name__) self.parent = parent # get the default work time, to use it as this week value default_time = SettingModel.default_week_time() self.logger.info('Default time for new week: %s', default_time) self._week = Week.get_or_create( year=year, week_number=week_number, defaults={'minutes_to_work': default_time})[0] self.logger.debug('Week: %s', self._week) self.__create_days()
def __init__(self, parent=None): """Construct a settings dialog.""" super().__init__(parent) self.logger = logging.getLogger(__name__) self.logger.info('Opening setting dialog') self.setWindowTitle(self.tr('Edit preferences')) self.center() self.invalid_color = None self.valid_color = None self.current_cell_color = None self.__update_colors() week_time_label = QLabel(self.tr('Default week time'), self) self.week_time = DurationEdit(parent=self, hour_length=2) self.week_time.minutes = SettingModel.default_week_time() self.logger.info('Read default week time minutes: %s', SettingModel.default_week_time()) self.week_time.valueChanged.connect(self.__week_time_changed) man_day_time_label = QLabel(self.tr('Default man day time'), self) self.man_day_time = QTimeEdit(SettingModel.default_man_day_time(), self) self.logger.info('Read default man day time: %s', SettingModel.default_man_day_time().toString('hh:mm')) self.man_day_time.timeChanged.connect(self.__man_day_time_changed) invalid_color_label = QLabel(self.tr('Invalid color'), self) self.invalid_color_button = QPushButton(self.tr('Text'), self) self.invalid_color_button.clicked.connect( self.__open_invalid_color_dialog) valid_color_label = QLabel(self.tr('Valid color'), self) self.valid_color_button = QPushButton(self.tr('Text'), self) self.valid_color_button.clicked.connect(self.__open_valid_color_dialog) current_cell_color_label = QLabel(self.tr('Current cell color'), self) self.current_cell_color_button = QPushButton(self.tr('Text'), self) self.current_cell_color_button.clicked.connect( self.__open_current_cell_color_dialog) self.__update_buttons_colors() main_layout = QGridLayout() main_layout.addWidget(week_time_label, 0, 0) main_layout.addWidget(self.week_time, 0, 1) main_layout.addWidget(man_day_time_label, 1, 0) main_layout.addWidget(self.man_day_time, 1, 1) main_layout.addWidget(invalid_color_label, 2, 0) main_layout.addWidget(self.invalid_color_button, 2, 1) main_layout.addWidget(valid_color_label, 3, 0) main_layout.addWidget(self.valid_color_button, 3, 1) main_layout.addWidget(current_cell_color_label, 4, 0) main_layout.addWidget(self.current_cell_color_button, 4, 1) self.setLayout(main_layout)