def open(self, containing=False): if self.file: if containing: p = os.path.split(self.file)[0] utils.open_path(p, self.file) else: utils.open_path(self.file)
def skipped_gs(s_list): "Skipped galleries" msg_box = QMessageBox(self) msg_box.setIcon(QMessageBox.Question) msg_box.setText('Do you want to view skipped paths?') msg_box.setStandardButtons(QMessageBox.Yes | QMessageBox.No) msg_box.setDefaultButton(QMessageBox.No) if msg_box.exec() == QMessageBox.Yes: list_wid = QTableWidget(self) list_wid.setAttribute(Qt.WA_DeleteOnClose) list_wid.setRowCount(len(s_list)) list_wid.setColumnCount(2) list_wid.setAlternatingRowColors(True) list_wid.setEditTriggers(list_wid.NoEditTriggers) list_wid.setHorizontalHeaderLabels(['Reason', 'Path']) list_wid.setSelectionBehavior(list_wid.SelectRows) list_wid.setSelectionMode(list_wid.SingleSelection) list_wid.setSortingEnabled(True) list_wid.verticalHeader().hide() list_wid.setAutoScroll(False) for x, g in enumerate(s_list): list_wid.setItem(x, 0, QTableWidgetItem(g[1])) list_wid.setItem(x, 1, QTableWidgetItem(g[0])) list_wid.resizeColumnsToContents() list_wid.setWindowTitle('{} skipped paths'.format(len(s_list))) list_wid.setWindowFlags(Qt.Window) list_wid.resize(900,400) list_wid.doubleClicked.connect(lambda i: utils.open_path( list_wid.item(i.row(), 1).text(), list_wid.item(i.row(), 1).text())) list_wid.show()
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_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) 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("Insert supported gallery URLs 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.setAcceptRichText(True) self.lang_box = QComboBox() self.lang_box.addItems(app_constants.G_LANGUAGES) self.lang_box.addItems(app_constants.G_CUSTOM_LANGUAGES) 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 = misc.CompleterTextEdit() self.tags_edit.setCompleter(misc.GCompleter(self, False, False)) tags_l.addWidget(self.tags_edit, 3) self.tags_edit.setPlaceholderText("Press Tab to autocomplete (Ctrl + E to show popup)") self.type_box = 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 = 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 = 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 = 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()
def open_hp_folder(self): if os.name == 'posix': utils.open_path(app_constants.posix_program_dir) else: utils.open_path(os.getcwd())
def open_path(self, path): utils.open_path(path)