def __init__(self, init_ui=True):
     QWidget.__init__(self)
     if init_ui:
         self.setupUi(self)
     self.logger = logging.getLogger(f'DownloaderForReddit.{__name__}')
     self.settings = injector.get_settings_manager()
     self.loaded = False
    def __init__(self, parent=None, **kwargs):
        QDialog.__init__(self, parent=parent)
        self.setupUi(self)
        self.parent = parent
        self.settings_manager = injector.get_settings_manager()

        geom = self.settings_manager.settings_dialog_geom
        self.resize(geom['width'], geom['height'])
        if geom['x'] != 0 or geom['y'] != 0:
            self.move(geom['x'], geom['y'])

        self.settings_map = {
            'Core':
            CoreSettingsWidget(),
            'Download Defaults':
            DownloadSettingsWidget(main_window=self.parent, **kwargs),
            'Display':
            DisplaySettingsWidget(main_window=self.parent),
            'Output':
            OutputSettingsWidget(main_window=self.parent),
            'Imgur':
            ImgurSettingsWidget(),
            'Database View':
            DatabaseSettingsWidget(),
            'Schedule':
            ScheduleSettingsWidget(),
            'Supported Video Sites':
            SupportedVideoSettingsWidget(),
            'Quick Filters':
            QuickFilterSettingsWidget(),
            'Default Filters':
            DefaultFilterSettingsWidget(),
            'Notifications':
            NotificationSettingsWidget(),
        }

        for item in self.settings_map.keys():
            self.settings_list_widget.addItem(item)

        self.current_display = None
        self.settings_list_widget.currentItemChanged.connect(
            lambda x: self.set_current_display(x.text()))
        open_display = kwargs.pop('open_display', None)
        if open_display is None:
            self.settings_list_widget.setCurrentRow(0)
        else:
            self.settings_list_widget.setCurrentRow(
                list(self.settings_map.keys()).index(open_display))

        self.button_box.accepted.connect(self.accept)
        self.button_box.rejected.connect(self.close)
        self.button_box.button(QDialogButtonBox.Apply).clicked.connect(
            self.apply)
    def __init__(self, parent=None):
        QWidget.__init__(self, parent=parent)
        self.setupUi(self)
        self.settings_manager = injector.get_settings_manager()
        self.active = False
        self.filters = {}
        self.list_item_map = {}

        self.filter_input_widget.export_filter.connect(self.add_filters)

        self.filter_box_list_widget.setSpacing(12)
        self.filter_box_list_widget.setResizeMode(QListView.Adjust)
Пример #4
0
    def __init__(self, parent=None):
        QWidget.__init__(self, parent=parent)
        self.setupUi(self)
        self.settings_manager = injector.get_settings_manager()
        self.launch_quick_filter = True
        self.filter_model_map = {
            'DOWNLOAD_SESSION': DownloadSessionFilter,
            'REDDIT_OBJECT': RedditObjectFilter,
            'POST': PostFilter,
            'CONTENT': ContentFilter,
            'COMMENT': CommentFilter
        }

        self.field_type_map = {
            Boolean: self.get_boolean_field,
            Integer: self.get_integer_field,
            String: self.get_string_field,
            DateTime: self.get_datetime_field
        }

        self.value_field = None

        self.add_filter_button.clicked.connect(self.add_filter)
        self.model_combo.currentIndexChanged.connect(self.set_fields)

        self.model_list = [
            'DOWNLOAD_SESSION', 'REDDIT_OBJECT', 'POST', 'CONTENT', 'COMMENT'
        ]
        for model in self.model_list:
            self.model_combo.addItem(model.replace('_', ' ').title(), model)

        operators = [('Equal To', 'eq'), ('Not Equal', 'not'), ('<', 'lt'),
                     ('<=', 'lte'), ('>', 'gt'), ('>=', 'gte'), ('In', 'in'),
                     ('Like', 'like'), ('Contains', 'contains')]
        for x in operators:
            self.operator_combo.addItem(x[0], x[1])

        self.set_fields()
        self.field_combo.currentIndexChanged.connect(self.set_value_field)
        self.set_value_field()

        self.quick_filter_combo.addItem('Quick Filters')
        self.quick_filter_combo.addItems(
            self.settings_manager.database_view_quick_filters.keys())
        self.quick_filter_combo.currentIndexChanged.connect(
            self.handle_quick_filter)