Exemplo n.º 1
0
    def _browse(self):
        if os.path.exists(DICT_DIR):
            openFolder(DICT_DIR)
        elif ALT_BUILD_VERSION:
            from aqt import moduleDir
            openFolder(moduleDir)

        if ALT_BUILD_VERSION:
            showInfo(ALT_BUILD_INSTRUCTIONS, title="Instructions", textFormat="rich")
Exemplo n.º 2
0
    def onViewFiles(self):
        # if nothing selected, open top level folder
        selected = self.selectedAddons()
        if not selected:
            openFolder(self.mgr.addonsFolder())
            return

        # otherwise require a single selection
        addon = self.onlyOneSelected()
        if not addon:
            return
        path = self.mgr.addonsFolder(addon)
        openFolder(path)
Exemplo n.º 3
0
Arquivo: stats.py Projeto: ChYi/ankiqt
 def browser(self):
     # dump to a temporary file
     path = namedtmp("report.png")
     p = self.form.web.page()
     oldsize = p.viewportSize()
     p.setViewportSize(p.mainFrame().contentsSize())
     image = QImage(p.viewportSize(), QImage.Format_ARGB32)
     painter = QPainter(image)
     p.mainFrame().render(painter)
     painter.end()
     image.save(path, "png")
     p.setViewportSize(oldsize)
     openFolder(path)
Exemplo n.º 4
0
    def onViewFiles(self):
        # if nothing selected, open top level folder
        selected = self.selectedAddons()
        if not selected:
            openFolder(self.mgr.addonsFolder())
            return

        # otherwise require a single selection
        addon = self.onlyOneSelected()
        if not addon:
            return
        path = self.mgr.addonsFolder(addon)
        openFolder(path)
Exemplo n.º 5
0
 def browser(self):
     # dump to a temporary file
     path = namedtmp("report.png")
     p = self.form.web.page()
     oldsize = p.viewportSize()
     p.setViewportSize(p.mainFrame().contentsSize())
     image = QImage(p.viewportSize(), QImage.Format_ARGB32)
     painter = QPainter(image)
     p.mainFrame().render(painter)
     painter.end()
     image.save(path, "png")
     p.setViewportSize(oldsize)
     openFolder(path)
Exemplo n.º 6
0
 def onCheckMediaDB(self):
     self.progress.start(immediate=True)
     try:
         (nohave, unused, invalid) = self.col.media.check()
     finally:
         self.progress.finish()
     # generate report
     report = ""
     if invalid:
         report += _("Invalid encoding; please rename:")
         report += "\n" + "\n".join(invalid)
     if unused:
         numberOfUnusedFilesLabel = len(unused)
         if report:
             report += "\n\n\n"
         report += ngettext("%d file found in media folder not used by any cards:",
             "%d files found in media folder not used by any cards:",
             numberOfUnusedFilesLabel) % numberOfUnusedFilesLabel
         report += "\n" + "\n".join(unused)
     if nohave:
         if report:
             report += "\n\n\n"
         report += _(
             "Used on cards but missing from media folder:")
         report += "\n" + "\n".join(nohave)
     if not report:
         tooltip(_("No unused or missing files found."))
         return
     # show report and offer to delete
     diag = QDialog(self)
     diag.setWindowTitle("Anki")
     layout = QVBoxLayout(diag)
     diag.setLayout(layout)
     text = QTextEdit()
     text.setReadOnly(True)
     text.setPlainText(report)
     layout.addWidget(text)
     box = QDialogButtonBox(QDialogButtonBox.Close)
     layout.addWidget(box)
     if unused:
         b = QPushButton(_("Delete Unused"))
         b.setAutoDefault(False)
         b.clicked.connect(lambda:self.deleteUnused(unused,diag))
         box.addButton(b, QDialogButtonBox.ActionRole)
         b = QPushButton(_("Explore Unused"))
         b.setAutoDefault(False)
         b.clicked.connect(lambda:openFolder(self.pm.mediaFolder()))
         box.addButton(b, QDialogButtonBox.ActionRole)
     if nohave:
         b = QPushButton(_("Browse Missing"))
         b.setAutoDefault(False)
         b.clicked.connect(lambda:self.browseMissingMedia(nohave,diag))
         box.addButton(b, QDialogButtonBox.ActionRole)
     diag.connect(box, SIGNAL("rejected()"), diag, SLOT("reject()"))
     diag.setMinimumHeight(400)
     diag.setMinimumWidth(500)
     restoreGeom(diag, "checkmediadb")
     diag.exec_()
     saveGeom(diag, "checkmediadb")
Exemplo n.º 7
0
 def onOpenAddonFolder(self, path=None):
     if path is None:
         path = self.addonsFolder()
     openFolder(path)
Exemplo n.º 8
0
 def onOpenPluginFolder(self, path=None):
     if path is None:
         path = self.pluginsFolder()
     openFolder(path)
Exemplo n.º 9
0
 def onOpenAddonFolder(self, path=None):
     if path is None:
         path = self.addonsFolder()
     openFolder(path)
Exemplo n.º 10
0
 def onOpenAddonFolder(self):
     path = self.addonsFolder()
     openFolder(path)
Exemplo n.º 11
0
    def setupConnections(self):
        f = self.form

        # PushButtons -------------
        f.OkButton.clicked.connect(self.accept)
        f.RestoreButton.clicked.connect(self.resetConfig)

        f.pushButton_randomize.clicked.connect(self.random)
        f.pushButton_imageFolder.clicked.connect(lambda: openFolder(imgfolder))
        f.pushButton_videoTutorial.clicked.connect(
            lambda _: self.openWeb("video"))

        f.toolButton_website.clicked.connect(lambda _: self.openWeb("anking"))
        f.toolButton_youtube.clicked.connect(lambda _: self.openWeb("youtube"))
        f.toolButton_patreon.clicked.connect(lambda _: self.openWeb("patreon"))
        f.toolButton_instagram.clicked.connect(
            lambda _: self.openWeb("instagram"))
        f.toolButton_facebook.clicked.connect(
            lambda _: self.openWeb("facebook"))
        f.toolButton_palace.clicked.connect(lambda _: self.openWeb("palace"))

        # Color Pickers -------------
        controller = {
            f.toolButton_color_main: (f.lineEdit_color_main, ),
            f.toolButton_color_top: (f.lineEdit_color_top, ),
            f.toolButton_color_bottom: (f.lineEdit_color_bottom, ),
        }
        for btn, args in controller.items():
            btn.clicked.connect(
                lambda a="a", args=args: self.getColors(a, *args))

        # File Buttons -----------------------
        controller = {
            # Image Buttons -----------------------
            f.toolButton_background: (f.lineEdit_background, ),
        }
        for btn, args in controller.items():
            # 'a' is used to get around an issue
            # with pything binding
            btn.clicked.connect(
                lambda a="a", args=args: self._getFile(a, *args))
        # File Buttons -----------------------
        controller = {
            # Image Buttons -----------------------
            f.toolButton_gear: (f.lineEdit_gear, ),
        }
        for btn, args in controller.items():
            # 'a' is used to get around an issue
            # with pything binding
            btn.clicked.connect(
                lambda a="a", args=args: self._getGearFile(a, *args))

        # Checkboxes ----------------
        controller = {
            f.checkBox_reviewer: ("Reviewer image", ),
            f.checkBox_toolbar: ("Toolbar image", ),
            f.checkBox_topbottom: ("Toolbar top/bottom", ),
        }
        for cb, args in controller.items():
            cb.stateChanged.connect(
                lambda cb=cb, args=args: self._updateCheckbox(cb, *args))

        # Comboboxes ---------------
        controller = {
            f.comboBox_attachment: ("background-attachment", ),
            f.comboBox_position: ("background-position", ),
            f.comboBox_size: ("background-size", ),
        }
        for cb, args in controller.items():
            t = cb.currentText()
            cb.currentTextChanged.connect(
                lambda t=t, args=args: self._updateComboBox(t, *args))

        # Sliders --------------
        controller = {
            f.Slider_main: ("background opacity main", ),
            f.Slider_review: ("background opacity review", ),
        }
        for slider, args in controller.items():
            s = slider.value()
            slider.valueChanged.connect(
                lambda s=s, args=args: self._updateSliderLabel(s, *args))

        # QDoubleSpinBox ------------
        f.scaleBox.valueChanged.connect(self._updateSpinBox)

        # LineEdits -------------
        a = f.lineEdit_background
        t = a.text()
        a.textChanged.connect(lambda t=a.text(): self._updateLineEdit(
            t, "Image name for background"))

        a = f.lineEdit_gear
        t = a.text()
        a.textChanged.connect(
            lambda t=a.text(): self._updateLineEdit(t, "Image name for gear"))

        a = f.lineEdit_color_main
        t = a.text()
        a.textChanged.connect(lambda t=a.text(): self._updateLineEdit(
            t, "background-color main"))

        a = f.lineEdit_color_top
        t = a.text()
        a.textChanged.connect(
            lambda t=a.text(): self._updateLineEdit(t, "background-color top"))

        a = f.lineEdit_color_bottom
        t = a.text()
        a.textChanged.connect(lambda t=a.text(): self._updateLineEdit(
            t, "background-color bottom"))
Exemplo n.º 12
0
 def onOpenBackup(self):
     path = os.path.join(self.config.confDir, "backups")
     openFolder(path)
    new = f"""<img src='/_addons/{addonfoldername}/user_files/gear/{get_gearfile()}'"""
    if gc("Image name for gear") != "gears.svg":
        content.tree = content.tree.replace(old, new)
    else:
        content.tree = content.tree.replace(old, old)
gui_hooks.deck_browser_will_render_content.append(replace_gears)


menu = QMenu(('Custom Background & Gear Icon'), mw)
mw.form.menuTools.addMenu(menu)

#add config button
def on_advanced_settings():
	addonDlg = AddonsDialog(mw.addonManager)
	addonDlg.accept() #closes addon dialog
	ConfigEditor(addonDlg,__name__,mw.addonManager.getConfig(__name__))

#menu.addSeparator()
advanced_settings = QAction('Set up Background/Gear (Config)', mw)
menu.addAction(advanced_settings)
advanced_settings.triggered.connect(on_advanced_settings)

shortcut = gc("Keyboard Shortcut", "Ctrl+shift+b")
#add folder button
imgfolder = os.path.join(addon_path, "user_files") 
action = QAction(mw) 
action.setText("Background/gear image folder") 
action.setShortcut(QKeySequence(shortcut))
menu.addAction(action) 
action.triggered.connect(lambda: openFolder(imgfolder))
def show_in_filemanager(self, box, tedit):
    p = self.template_save_path(box)
    if os.path.isdir(p):
        openFolder(p)
    else:
        tooltip("folder not found. Maybe no version was saved yet ...")
Exemplo n.º 15
0
 def onOpenBackup(self):
     openFolder(self.mw.pm.backupFolder())
Exemplo n.º 16
0
 def _browse(self):
     openFolder(DICT_DIR)
Exemplo n.º 17
0
 def onOpenBackup(self):
     path = os.path.join(self.config.confDir, "backups")
     openFolder(path)
Exemplo n.º 18
0
 def onOpenBackup(self):
     openFolder(self.mw.pm.backupFolder())
Exemplo n.º 19
0
 def openFolder(self):
     openFolder(self.folder)