def __init__(self, parent=None): super().__init__(parent, blur=False) main_layout = QFormLayout(self.main_widget) self.name_edit = QLineEdit(self) main_layout.addRow("Name:", self.name_edit) self.filter_edit = QPlainTextEdit(self) self.filter_edit.setPlaceholderText( "tag1, namespace:tag2, namespace2:[tag1, tag2] ...") self.filter_edit.setFixedHeight(100) what_is_filter = misc.ClickedLabel("What is Filter/Enforce? (Hover)") what_is_filter.setToolTip(app_constants.WHAT_IS_FILTER) what_is_filter.setToolTipDuration(9999999999) self.enforce = QCheckBox(self) self.regex = QCheckBox(self) self.case = QCheckBox(self) self.strict = QCheckBox(self) main_layout.addRow(what_is_filter) main_layout.addRow("Filter", self.filter_edit) main_layout.addRow("Enforce", self.enforce) main_layout.addRow("Regex", self.regex) main_layout.addRow("Case sensitive", self.case) main_layout.addRow("Match whole terms", self.strict) main_layout.addRow(self.buttons_layout) self.add_buttons("Close")[0].clicked.connect(self.hide) self.add_buttons("Apply")[0].clicked.connect(self.accept) old_v = self.width() self.adjustSize() self.resize(old_v, self.height())
def __init__(self, parent): super().__init__(parent, blur=False) main_layout = QFormLayout(self.main_widget) self.name_edit = QLineEdit(self) main_layout.addRow("Name:", self.name_edit) self.filter_edit = QLineEdit(self) what_is_filter = misc.ClickedLabel("What is filter/enforce? (Hover)") what_is_filter.setToolTip(app_constants.WHAT_IS_FILTER) what_is_filter.setToolTipDuration(9999999999) self.enforce = QCheckBox(self) self.regex = QCheckBox(self) self.case = QCheckBox(self) self.strict = QCheckBox(self) main_layout.addRow(what_is_filter) main_layout.addRow("Filter", self.filter_edit) main_layout.addRow("Enforce", self.enforce) main_layout.addRow("Regex", self.regex) main_layout.addRow("Case sensitive", self.case) main_layout.addRow("Match whole terms", self.strict) main_layout.addRow(self.buttons_layout) self.add_buttons("Close")[0].clicked.connect(self.hide) self.add_buttons("Apply")[0].clicked.connect(self.accept)
def commonUI(self): if not self._multiple_galleries: f_web = QGroupBox("Metadata from the Web") f_web.setCheckable(False) self.main_layout.addWidget(f_web) web_main_layout = QVBoxLayout() web_info = misc.ClickedLabel( "Which gallery URLs are supported? (hover)", parent=self) web_info.setToolTip(app_constants.SUPPORTED_METADATA_URLS) web_info.setToolTipDuration(999999999) web_main_layout.addWidget(web_info) web_layout = QHBoxLayout() web_main_layout.addLayout(web_layout) f_web.setLayout(web_main_layout) def basic_web(name): return QLabel(name), QLineEdit(), QPushButton( "Get metadata"), QProgressBar() url_lbl, self.url_edit, url_btn, url_prog = basic_web("URL:") url_btn.clicked.connect(lambda: self.web_metadata( self.url_edit.text(), url_btn, url_prog)) url_prog.setTextVisible(False) url_prog.setMinimum(0) url_prog.setMaximum(0) web_layout.addWidget(url_lbl, 0, Qt.AlignLeft) web_layout.addWidget(self.url_edit, 0) web_layout.addWidget(url_btn, 0, Qt.AlignRight) web_layout.addWidget(url_prog, 0, Qt.AlignRight) self.url_edit.setPlaceholderText( "Insert supported gallery URLs or just press the button!") url_prog.hide() f_gallery = QGroupBox("Gallery Info") f_gallery.setCheckable(False) self.main_layout.addWidget(f_gallery) gallery_layout = QFormLayout() f_gallery.setLayout(gallery_layout) def checkbox_layout(widget): if self._multiple_galleries: l = QHBoxLayout() l.addWidget(widget.g_check) widget.setSizePolicy(QSizePolicy.Expanding, QSizePolicy.Preferred) l.addWidget(widget) return l else: widget.g_check.setChecked(True) widget.g_check.hide() return widget def add_check(widget): widget.g_check = QCheckBox(self) return widget self.title_edit = add_check(QLineEdit()) self.author_edit = add_check(QLineEdit()) author_completer = misc.GCompleter(self, False, True, False) author_completer.setCaseSensitivity(Qt.CaseInsensitive) self.author_edit.setCompleter(author_completer) self.descr_edit = add_check(QTextEdit()) self.descr_edit.setAcceptRichText(True) self.lang_box = add_check(QComboBox()) self.lang_box.addItems(app_constants.G_LANGUAGES) self.lang_box.addItems(app_constants.G_CUSTOM_LANGUAGES) self.rating_box = add_check(QSpinBox()) self.rating_box.setMaximum(5) self.rating_box.setMinimum(0) self._find_combobox_match(self.lang_box, app_constants.G_DEF_LANGUAGE, 0) tags_l = QVBoxLayout() tag_info = misc.ClickedLabel( "How do i write namespace & tags? (hover)", parent=self) tag_info.setToolTip( "Ways to write tags:\n\nNormal tags:\ntag1, tag2, tag3\n\n" + "Namespaced tags:\nns1:tag1, ns1:tag2\n\nNamespaced tags with one or more" + " tags under same namespace:\nns1:[tag1, tag2, tag3], ns2:[tag1, tag2]\n\n" + "Those three ways of writing namespace & tags can be combined freely.\n" + "Tags are seperated by a comma, NOT whitespace.\nNamespaces will be capitalized while tags" + " will be lowercased.") tag_info.setToolTipDuration(99999999) tags_l.addWidget(tag_info) self.tags_edit = add_check(misc.CompleterTextEdit()) self.tags_edit.setCompleter(misc.GCompleter(self, False, False)) self.tags_append = QCheckBox("Append tags", self) self.tags_append.setChecked(False) if not self._multiple_galleries: self.tags_append.hide() if self._multiple_galleries: self.tags_append.setChecked(app_constants.APPEND_TAGS_GALLERIES) tags_ml = QVBoxLayout() tags_ml.addWidget(self.tags_append) tags_ml.addLayout(checkbox_layout(self.tags_edit), 5) tags_l.addLayout(tags_ml, 3) else: tags_l.addWidget(checkbox_layout(self.tags_edit), 5) self.tags_edit.setPlaceholderText( "Press Tab to autocomplete (Ctrl + E to show popup)") self.type_box = add_check(QComboBox()) self.type_box.addItems(app_constants.G_TYPES) self._find_combobox_match(self.type_box, app_constants.G_DEF_TYPE, 0) #self.type_box.currentIndexChanged[int].connect(self.doujin_show) #self.doujin_parent = QLineEdit() #self.doujin_parent.setVisible(False) self.status_box = add_check(QComboBox()) self.status_box.addItems(app_constants.G_STATUS) self._find_combobox_match(self.status_box, app_constants.G_DEF_STATUS, 0) self.pub_edit = add_check(QDateEdit()) self.pub_edit.setCalendarPopup(True) self.pub_edit.setDate(QDate.currentDate()) self.path_lbl = misc.ClickedLabel("") self.path_lbl.setWordWrap(True) self.path_lbl.clicked.connect(lambda a: utils.open_path(a, a) if a else None) link_layout = QHBoxLayout() self.link_lbl = add_check(QLabel("")) self.link_lbl.setWordWrap(True) self.link_edit = QLineEdit() link_layout.addWidget(self.link_edit) if self._multiple_galleries: link_layout.addLayout(checkbox_layout(self.link_lbl)) else: link_layout.addWidget(checkbox_layout(self.link_lbl)) self.link_edit.hide() self.link_btn = QPushButton("Modify") self.link_btn.setFixedWidth(50) self.link_btn2 = QPushButton("Set") self.link_btn2.setFixedWidth(40) self.link_btn.clicked.connect(self.link_modify) self.link_btn2.clicked.connect(self.link_set) link_layout.addWidget(self.link_btn) link_layout.addWidget(self.link_btn2) self.link_btn2.hide() rating_ = checkbox_layout(self.rating_box) lang_ = checkbox_layout(self.lang_box) if self._multiple_galleries: rating_.insertWidget(0, QLabel("Rating:")) lang_.addLayout(rating_) lang_l = lang_ else: lang_l = QHBoxLayout() lang_l.addWidget(lang_) lang_l.addWidget(QLabel("Rating:"), 0, Qt.AlignRight) lang_l.addWidget(rating_) gallery_layout.addRow("Title:", checkbox_layout(self.title_edit)) gallery_layout.addRow("Author:", checkbox_layout(self.author_edit)) gallery_layout.addRow("Description:", checkbox_layout(self.descr_edit)) gallery_layout.addRow("Language:", lang_l) gallery_layout.addRow("Tags:", tags_l) gallery_layout.addRow("Type:", checkbox_layout(self.type_box)) gallery_layout.addRow("Status:", checkbox_layout(self.status_box)) gallery_layout.addRow("Publication Date:", checkbox_layout(self.pub_edit)) gallery_layout.addRow("Path:", self.path_lbl) gallery_layout.addRow("URL:", link_layout) self.title_edit.setFocus()
def commonUI(self): f_web = QGroupBox("Metadata from the Web") f_web.setCheckable(False) self.main_layout.addWidget(f_web) web_main_layout = QVBoxLayout() web_layout = QHBoxLayout() web_main_layout.addLayout(web_layout) f_web.setLayout(web_main_layout) f_gallery = QGroupBox("Gallery Info") f_gallery.setCheckable(False) self.main_layout.addWidget(f_gallery) gallery_layout = QFormLayout() f_gallery.setLayout(gallery_layout) def basic_web(name): return QLabel(name), QLineEdit(), QPushButton( "Get metadata"), QProgressBar() url_lbl, self.url_edit, url_btn, url_prog = basic_web("URL:") url_btn.clicked.connect( lambda: self.web_metadata(self.url_edit.text(), url_btn, url_prog)) url_prog.setTextVisible(False) url_prog.setMinimum(0) url_prog.setMaximum(0) web_layout.addWidget(url_lbl, 0, Qt.AlignLeft) web_layout.addWidget(self.url_edit, 0) web_layout.addWidget(url_btn, 0, Qt.AlignRight) web_layout.addWidget(url_prog, 0, Qt.AlignRight) self.url_edit.setPlaceholderText( "Paste g.e-hentai/exhentai gallery url or just press the button.") url_prog.hide() self.title_edit = QLineEdit() self.author_edit = QLineEdit() author_completer = misc.GCompleter(self, False, True, False) author_completer.setCaseSensitivity(Qt.CaseInsensitive) self.author_edit.setCompleter(author_completer) self.descr_edit = QTextEdit() self.descr_edit.setFixedHeight(45) self.descr_edit.setAcceptRichText(True) self.lang_box = QComboBox() self.lang_box.addItems(["English", "Japanese", "Other"]) self.lang_box.setCurrentIndex(0) tags_l = QVBoxLayout() tag_info = misc.ClickedLabel( "How do i write namespace & tags? (hover)", parent=self) tag_info.setToolTip( "Ways to write tags:\n\nNormal tags:\ntag1, tag2, tag3\n\n" + "Namespaced tags:\nns1:tag1, ns1:tag2\n\nNamespaced tags with one or more" + " tags under same namespace:\nns1:[tag1, tag2, tag3], ns2:[tag1, tag2]\n\n" + "Those three ways of writing namespace & tags can be combined freely.\n" + "Tags are seperated by a comma, NOT whitespace.\nNamespaces will be capitalized while tags" + " will be lowercased.") tag_info.setToolTipDuration(99999999) tags_l.addWidget(tag_info) self.tags_edit = misc.CompleterTextEdit() self.tags_edit.setCompleter(misc.GCompleter(self, False, False)) tags_l.addWidget(self.tags_edit, 3) self.tags_edit.setFixedHeight(70) self.tags_edit.setPlaceholderText( "Press Tab to autocomplete (Ctrl + E to show popup)") self.type_box = QComboBox() self.type_box.addItems([ "Manga", "Doujinshi", "Artist CG Sets", "Game CG Sets", "Western", "Image Sets", "Non-H", "Cosplay", "Other" ]) self.type_box.setCurrentIndex(0) #self.type_box.currentIndexChanged[int].connect(self.doujin_show) #self.doujin_parent = QLineEdit() #self.doujin_parent.setVisible(False) self.status_box = QComboBox() self.status_box.addItems(["Unknown", "Ongoing", "Completed"]) self.status_box.setCurrentIndex(0) self.pub_edit = QDateEdit() self.pub_edit.setCalendarPopup(True) self.pub_edit.setDate(QDate.currentDate()) self.path_lbl = QLabel("") self.path_lbl.setWordWrap(True) link_layout = QHBoxLayout() self.link_lbl = QLabel("") self.link_lbl.setWordWrap(True) self.link_edit = QLineEdit() link_layout.addWidget(self.link_edit) link_layout.addWidget(self.link_lbl) self.link_edit.hide() self.link_btn = QPushButton("Modify") self.link_btn.setFixedWidth(50) self.link_btn2 = QPushButton("Set") self.link_btn2.setFixedWidth(40) self.link_btn.clicked.connect(self.link_modify) self.link_btn2.clicked.connect(self.link_set) link_layout.addWidget(self.link_btn) link_layout.addWidget(self.link_btn2) self.link_btn2.hide() gallery_layout.addRow("Title:", self.title_edit) gallery_layout.addRow("Author:", self.author_edit) gallery_layout.addRow("Description:", self.descr_edit) gallery_layout.addRow("Language:", self.lang_box) gallery_layout.addRow("Tags:", tags_l) gallery_layout.addRow("Type:", self.type_box) gallery_layout.addRow("Status:", self.status_box) gallery_layout.addRow("Publication Date:", self.pub_edit) gallery_layout.addRow("Path:", self.path_lbl) gallery_layout.addRow("Link:", link_layout) self.title_edit.setFocus()