Exemplo n.º 1
0
 def RegisterBack(self, msg):
     self.loadingForm.close()
     if msg == Status.Ok:
         # self.close()
         # QtWidgets.QMessageBox.information(self, '注册成功', "注册成功", QtWidgets.QMessageBox.Yes)
         QtBubbleLabel.ShowMsgEx(self, "注册成功")
         self.close()
     else:
         # QtWidgets.QMessageBox.information(self, '注册失败', msg, QtWidgets.QMessageBox.Yes)
         QtBubbleLabel.ShowErrorEx(self, msg)
Exemplo n.º 2
0
    def __init__(self):
        QtWidgets.QMainWindow.__init__(self)
        Ui_MainWindow.__init__(self)
        self.userInfo = None
        self.setupUi(self)
        self.setWindowTitle("哔咔漫画")
        self.msgForm = QtBubbleLabel(self)

        self.qtTask = QtTask()

        icon = QIcon()
        pic = QPixmap()
        pic.loadFromData(resources.DataMgr.GetData("logo_round"))
        icon.addPixmap(pic, QIcon.Normal, QIcon.Off)
        self.setWindowIcon(icon)
        self.aboutForm = QtAbout(self)

        self.searchForm = QtSearch(self)
        self.favoriteForm = QtFavorite(self)
        self.downloadForm = QtDownload(self)
        self.categoryForm = QtCategory(self)
        self.loadingForm = QtLoading(self)
        self.rankForm = QtRank(self)

        self.loginForm = QtLogin(self)
        self.registerForm = QtRegister(self)

        self.historyForm = QtHistory(self)

        self.qtReadImg = QtReadImg(self)

        self.userForm = QtUser(self)
        self.bookInfoForm = QtBookInfo(self)

        self.task = QtTask()
        self.task.SetOwner(self)
        self.timer = QTimer(self)
        self.timer.setInterval(100)
        # self.timer.timeout.connect(self.OnTimeOut)
        # self.timer.start()

        self.stackedWidget.addWidget(self.loginForm)
        self.stackedWidget.addWidget(self.userForm)

        self.settingForm = QtSetting(self)
        self.settingForm.LoadSetting()

        self.resize(self.settingForm.mainSize)
        self.bookInfoForm.resize(self.settingForm.bookSize)
        self.loginForm.userIdEdit.setText(self.settingForm.userId)
        self.loginForm.passwdEdit.setText(self.settingForm.passwd)

        self.menusetting.triggered.connect(self.OpenSetting)
        self.menuabout.triggered.connect(self.OpenAbout)
Exemplo n.º 3
0
    def SaveSetting(self):
        config.DownloadThreadNum = int(self.comboBox.currentText())
        config.ImageQuality = self.buttonGroup.checkedButton().objectName(
        ).replace("quality_", "")
        httpProxy = self.httpEdit.text()
        config.SavePath = self.saveEdit.text()

        self.settings.setValue("DownloadThreadNum", config.DownloadThreadNum)
        self.settings.setValue("ImageQuality", config.ImageQuality)
        config.HttpProxy = httpProxy
        self.settings.setValue("Proxy/Http", config.HttpProxy)

        self.settings.setValue("SavePath", config.SavePath)

        config.Encode = self.encodeSelect.currentIndex()
        config.Waifu2xThread = int(self.threadSelect.currentIndex()) + 1
        config.Scale = int(self.scaleSelect.currentIndex()) + 2
        config.Noise = 3 - int(self.noiseSelect.currentIndex())
        config.Model = int(self.modelSelect.currentIndex()) + 1
        config.IsOpenWaifu = self.checkBox.isChecked()
        self.settings.setValue("Waifu2x/Encode", config.Encode)
        # self.settings.setValue("Waifu2x/Thread", config.Waifu2xThread)
        # self.settings.setValue("Waifu2x/Scale", config.Scale)
        self.settings.setValue("Waifu2x/Noise", config.Noise)
        # self.settings.setValue("Waifu2x/Model", config.Model)
        self.settings.setValue("Waifu2x/Open", config.IsOpenWaifu)

        # QtWidgets.QMessageBox.information(self, '保存成功', "成功", QtWidgets.QMessageBox.Yes)
        QtBubbleLabel.ShowMsgEx(self, "保存成功")
Exemplo n.º 4
0
 def LastPage(self):
     if self.curIndex <= 0:
         QtBubbleLabel.ShowMsgEx(self.parent(), "已经是第一页")
         return
     self.curIndex -= 1
     self.SetData(isInit=True)
     self.parent().ShowImg()
     return
Exemplo n.º 5
0
    def Register(self):
        if not self.buttonGroup.checkedButton():
            # QtWidgets.QMessageBox.information(self, '错误', "不能为空", QtWidgets.QMessageBox.Yes)
            QtBubbleLabel.ShowErrorEx(self, "不能为空")
            return
        if len(self.passwdEdit.text()) < 8:
            # QtWidgets.QMessageBox.information(self, '错误', "密码太短", QtWidgets.QMessageBox.Yes)
            QtBubbleLabel.ShowErrorEx(self, "密码太短")
            return
        data = {
            "email":
            self.userEdit.text(),
            "password":
            self.passwdEdit.text(),
            "name":
            self.nameEdit.text(),
            "birthday":
            self.birthdayEdit.text().replace("/", "-"),
            "gender":
            self.buttonGroup.checkedButton().objectName().replace(
                "gender_", ""),  # m, f, bot
            "answer1":
            self.answer1Edit.text(),
            "answer2":
            self.answer2Edit.text(),
            "answer3":
            self.answer3Edit.text(),
            "question1":
            self.question1Edit.text(),
            "question2":
            self.question2Edit.text(),
            "question3":
            self.question3Edit.text()
        }
        for v in data.values():
            if not v:
                # QtWidgets.QMessageBox.information(self, '错误', "不能为空", QtWidgets.QMessageBox.Yes)
                QtBubbleLabel.ShowErrorEx(self, "不能为空")
                return

        self.loadingForm.show()
        self.owner().qtTask.AddHttpTask(lambda x: User().Register(data, x),
                                        self.RegisterBack)
        return
Exemplo n.º 6
0
 def NextPage(self):
     if self.curIndex >= self.maxPic-1:
         QtBubbleLabel.ShowMsgEx(self.parent(), "已经最后一页")
         return
     t = CTime()
     self.curIndex += 1
     self.SetData(isInit=True)
     self.parent().ShowImg()
     t.Refresh(self.__class__.__name__)
     return
Exemplo n.º 7
0
    def CopyPicture(self):
        clipboard = QApplication.clipboard()
        owner = self.parent()

        if self.checkBox.isChecked():
            data = owner.convertData.get(owner.indexToWaifu2xId.get(owner.curIndex))
            if not data or not data.pData:
                QtBubbleLabel.ShowErrorEx(owner, "解码还未完成")
                return
            clipboard.setPixmap(data.pData)
            QtBubbleLabel.ShowMsgEx(owner, "复制成功")

        else:
            data2 = owner.pictureData.get(owner.curIndex)
            if not data2 or not data2.pData:
                QtBubbleLabel.ShowErrorEx(owner, "下载未完成")
                return
            clipboard.setPixmap(data2.pData)
            QtBubbleLabel.ShowMsgEx(owner, "复制成功")
        return
Exemplo n.º 8
0
class BikaQtMainWindow(QtWidgets.QMainWindow, Ui_MainWindow):
    def __init__(self):
        QtWidgets.QMainWindow.__init__(self)
        Ui_MainWindow.__init__(self)
        self.userInfo = None
        self.setupUi(self)
        self.setWindowTitle("哔咔漫画")
        self.msgForm = QtBubbleLabel(self)

        self.qtTask = QtTask()

        icon = QIcon()
        pic = QPixmap()
        pic.loadFromData(resources.DataMgr.GetData("logo_round"))
        icon.addPixmap(pic, QIcon.Normal, QIcon.Off)
        self.setWindowIcon(icon)
        self.aboutForm = QtAbout(self)

        self.searchForm = QtSearch(self)
        self.favoriteForm = QtFavorite(self)
        self.downloadForm = QtDownload(self)
        self.categoryForm = QtCategory(self)
        self.loadingForm = QtLoading(self)
        self.rankForm = QtRank(self)

        self.loginForm = QtLogin(self)
        self.registerForm = QtRegister(self)

        self.historyForm = QtHistory(self)

        self.qtReadImg = QtReadImg(self)

        self.userForm = QtUser(self)
        self.bookInfoForm = QtBookInfo(self)

        self.task = QtTask()
        self.task.SetOwner(self)
        self.timer = QTimer(self)
        self.timer.setInterval(100)
        # self.timer.timeout.connect(self.OnTimeOut)
        # self.timer.start()

        self.stackedWidget.addWidget(self.loginForm)
        self.stackedWidget.addWidget(self.userForm)

        self.settingForm = QtSetting(self)
        self.settingForm.LoadSetting()

        self.resize(self.settingForm.mainSize)
        self.bookInfoForm.resize(self.settingForm.bookSize)
        self.loginForm.userIdEdit.setText(self.settingForm.userId)
        self.loginForm.passwdEdit.setText(self.settingForm.passwd)

        self.menusetting.triggered.connect(self.OpenSetting)
        self.menuabout.triggered.connect(self.OpenAbout)

    # def ClearExpiredCache(self):
    #     try:
    #         toPath = os.path.join(config.SavePath, config.CachePathDir)
    #         for root, dirs, names in os.walk(toPath):
    #             for name in names:
    #                 isDel = False
    #                 filename = os.path.join(root, name)
    #                 with open(filename, "rb") as f:
    #                     nameSize = int().from_bytes(f.read(2), byteorder='little')
    #                     timeTick = int().from_bytes(f.read(4), byteorder='little')
    #                     # if int(time.time()) - timeTick >= config.CacheExpired:
    #                     #     isDel = True
    #
    #                 if isDel:
    #                     os.remove(filename)
    #
    #     except Exception as es:
    #         Log.Error(es)

    # def OnTimeOut(self):
    #     self.task.run()

    def closeEvent(self, a0: QtGui.QCloseEvent) -> None:
        super().closeEvent(a0)
        userId = self.loginForm.userIdEdit.text()
        passwd = self.loginForm.passwdEdit.text()
        self.bookInfoForm.close()
        self.settingForm.ExitSaveSetting(self.size(), self.bookInfoForm.size(),
                                         userId, passwd)

    def Init(self):
        # self.ClearExpiredCache()
        waifu2x.Set(config.Waifu2xThread, config.Encode,
                    getattr(config, "Model" + str(config.Model)))
        stat = waifu2x.Init()
        if stat < 0:
            self.msgForm.ShowError("waifu2x初始化错误")

        Log.Info("waifu2x初始化: " + str(stat) + " encode: " + str(config.Encode))
        gpuInfo = waifu2x.GetGpuInfo()
        self.settingForm.SetGpuInfos(gpuInfo)

        self.InitUpdate()
        self.loginForm.Init()
        return

    def OpenSetting(self):
        self.settingForm.show()
        pass

    def OpenAbout(self):
        self.aboutForm.show()
        pass

    def InitUpdate(self):
        self.qtTask.AddHttpTask(
            lambda x: Server().Send(req.CheckUpdateReq(), bakParam=x),
            self.InitUpdateBack)

    def InitUpdateBack(self, data):
        try:
            info = re.findall(r"\d+\d*", os.path.basename(data))
            version = int(info[0]) * 100 + int(info[1]) * 10 + int(info[2]) * 1

            info2 = re.findall(r"\d+\d*",
                               os.path.basename(config.UpdateVersion))
            curversion = int(info2[0]) * 100 + int(info2[1]) * 10 + int(
                info2[2]) * 1
            if version > curversion:
                r = QMessageBox.information(
                    self, "更新",
                    "当前版本{} ,检查到更新{},是否前往更新".format(config.UpdateVersion,
                                                    info),
                    QMessageBox.Yes | QMessageBox.No, QMessageBox.Yes)
                if r == QMessageBox.Yes:
                    QDesktopServices.openUrl(
                        QUrl(
                            "https://github.com/tonquer/picacg-windows/releases"
                        ))
        except Exception as Es:
            import sys
            cur_tb = sys.exc_info()[
                2]  # return (exc_type, exc_value, traceback)
            e = sys.exc_info()[1]
            Log.Error(cur_tb, e)