def show_by_local_debfile(self, path): # clear reviews self.reviewpage = 1 self.currentreviewready = False self.ui.reviewListWidget.clear() # self.detailWidget.resize(805, 790) # self.ui.reviewListWidget.resize(805, 0) self.detailWidget.resize(860, 790) self.ui.reviewListWidget.resize(860, 0) self.reviewload.move(self.ui.reviewListWidget.x(), self.ui.reviewListWidget.y()) # clear sshot self.sshotcount = 0 self.ui.thumbnail.hide() # self.ui.btnUpdate.setText("不可用") # self.ui.btnUninstall.setText("不可用") # self.ui.btnUpdate.setEnabled(False) # self.ui.btnUninstall.setEnabled(False) # self.ui.btnUpdate.setStyleSheet("QPushButton{background-image:url('res/btn-notenable.png');border:0px;color:#9AA2AF;}") # self.ui.btnUninstall.setStyleSheet("QPushButton{background-image:url('res/btn-notenable.png');border:0px;color:#9AA2AF;}") self.ui.btnUpdate.setVisible(False) self.ui.btnUninstall.setVisible(False) self.debfile = DebFile(path) self.app = self.debfile self.ui.icon.setStyleSheet("QLabel{background-image:url('" + UBUNTUKYLIN_RES_ICON_PATH + "default.png')}") self.ui.name.setText(self.debfile.name) self.ui.installedVersion.setText("软件版本: " + self.debfile.version) sizek = self.debfile.installedsize if(sizek <= 1024): self.ui.size.setText("安装大小: " + str(sizek) + " KB") else: self.ui.size.setText("安装大小: " + str('%.2f'%(sizek/1024.0)) + " MB") self.ui.description.setText(self.debfile.description) if(self.debfile.is_installable()): deps = self.debfile.get_missing_deps() self.ui.summary.setText("需要安装的依赖包: " + str(deps)) self.ui.btnInstall.setText("安装此包") self.ui.btnInstall.setEnabled(True) else: self.ui.btnInstall.setText("无法安装") self.ui.btnInstall.setEnabled(False) #add by kobe self.ui.btnInstall.setVisible(True) self.ui.btnUpdate.setVisible(False) self.ui.btnUninstall.setVisible(False) self.show() self.mainwindow.loadingDiv.stop_loading()
def show_softinfo(self,path=None,softname=None): if path != None: self.debfile = DebFile(path) self.install_pkgname = self.debfile.name self.install_version = _("version: ") + self.debfile.version self.parse = parseThread(self.install_pkgname) self.parse.parse_over.connect(self.parse_desktop) self.exec_word = None elif softname != None: self.cache = apt.Cache() pkg = self.cache[softname] self.uninstall_pkgname = pkg.shortname self.uninstall_version = _("version: ") + pkg.versions.keys()[0] if LAUNCH_MODE == 'normal': self.ui.install.setText(_("installation")) self.adaptiveLength(_("select an installation file"), _("version: no")) # 设置包名、版本信息 elif LAUNCH_MODE == 'manual': self.ui.install.setText(_("installation")) self.ui.install.clicked.connect(self.install_debfile) self.adaptiveLength(self.install_pkgname, self.install_version) # 设置包名、版本信息 iconpath = get_icon.get_icon_path(str(self.install_pkgname)) if iconpath: self.ui.icon.setStyleSheet("QLabel{background-image:url('" + iconpath + "');background-color:transparent;background-position:center;background-repeat:none}") elif LAUNCH_MODE == 'remove': if pkg.is_installed: self.ui.install.setText(_("uninstallation")) self.ui.install.clicked.connect(lambda : self.remove(pkg.name)) self.adaptiveLength(self.uninstall_pkgname, self.uninstall_version) # 设置包名、版本信息 iconpath = get_icon.get_icon_path(str(self.uninstall_pkgname)) if iconpath: self.ui.icon.setStyleSheet("QLabel{background-image:url('" + iconpath + "');background-color:transparent;background-position:center;background-repeat:none}") else: #软件未安装时,提示信息 self.ui.install.setText(_("uninstalled")) self.ui.install.setStyleSheet("QPushButton{background-color:#A9A9A9;border:0px;font-size:16px;border-radius:4px;color:#ffffff}") self.ui.install.setEnabled(False) self.adaptiveLength(_("version: no"), _("software not installed")) # 设置包名、版本信息 iconpath = get_icon.get_icon_path(self.uninstall_version) if iconpath: self.ui.icon.setStyleSheet("QLabel{background-image:url('" + iconpath + "');background-color:transparent;background-position:center;background-repeat:none}")
def show_debfile(self,path): self.debfile = DebFile(path) self.ui.pkgname.setStyleSheet(".QLabel{background-color:transparent;border:0px;font-size:26px;color:#444444}") if path == '': # self.ui.pkgname.setText() text = get_icon.setLongTextToElideFormat(self.ui.pkgname, _("暂无可安装文件")) else: text = get_icon.setLongTextToElideFormat(self.ui.pkgname, _(str(self.debfile.name))) if str(text).endswith("…") is True: self.ui.pkgname.setToolTip(self.debfile.name) self.app = self.debfile iconpath = get_icon.get_icon_path(str(self.debfile.name)) if iconpath: self.ui.icon.setStyleSheet("QLabel{background-image:url('" + iconpath + "');background-color:transparent;}") if self.debfile.version: text = get_icon.setLongTextToElideFormat(self.ui.Version, "版本号: " + self.debfile.version) if str(text).endswith("…") is True: self.ui.Version.setToolTip(self.debfile.version) else: self.ui.Version.setText("版本号:暂无") self.ui.install.clicked.connect(self.install_debfile)
class DetailScrollWidget(QScrollArea): mainwindow = '' app = None debfile = '' sshotcount = 0 bigsshot = '' reviewpage = '' maxpage = '' currentreviewready = '' def __init__(self, parent=None): QScrollArea.__init__(self,parent.ui.rightWidget) self.detailWidget = QWidget() # self.setWindowFlags(Qt.FramelessWindowHint) self.setStyleSheet("QWidget{border:0px;}") self.ui_init() self.mainwindow = parent self.setGeometry(QRect(5, 87, 860, 565)) # self.setGeometry(QRect(20, 60, 860 + 6 + (20 - 6) / 2, 605)) self.setWidget(self.detailWidget) self.bigsshot = ScreenShotBig() # self.ui.btnCloseDetail.setText("返回") self.ui.btnCloseDetail.setFocusPolicy(Qt.NoFocus) self.ui.btnInstall.setFocusPolicy(Qt.NoFocus) self.ui.btnUpdate.setFocusPolicy(Qt.NoFocus) self.ui.btnUninstall.setFocusPolicy(Qt.NoFocus) self.ui.btnSshotBack.setFocusPolicy(Qt.NoFocus) self.ui.btnSshotNext.setFocusPolicy(Qt.NoFocus) self.ui.reviewListWidget.setFocusPolicy(Qt.NoFocus) self.ui.thumbnail.setFocusPolicy(Qt.NoFocus) self.ui.sshot.setFocusPolicy(Qt.NoFocus) self.ui.summary.setReadOnly(True) self.ui.description.setReadOnly(True) self.setHorizontalScrollBarPolicy(Qt.ScrollBarAlwaysOff) self.ui.btnCloseDetail.clicked.connect(self.slot_close_detail) self.ui.btnInstall.clicked.connect(self.slot_click_install) self.ui.btnUpdate.clicked.connect(self.slot_click_upgrade) self.ui.btnUninstall.clicked.connect(self.slot_click_uninstall) self.ui.thumbnail.clicked.connect(self.slot_show_sshot) self.ui.sshot.clicked.connect(self.ui.sshot.hide) self.verticalScrollBar().valueChanged.connect(self.slot_scroll_end) self.setAutoFillBackground(True) palette = QPalette() palette.setColor(QPalette.Background, QColor(238, 237, 240)) self.setPalette(palette) self.verticalScrollBar().setStyleSheet("QScrollBar:vertical{margin:0px 0px 0px 0px;background-color:rgb(255,255,255,100);border:0px;width:6px;}\ QScrollBar::sub-line:vertical{subcontrol-origin:margin;border:1px solid red;height:13px}\ QScrollBar::up-arrow:vertical{subcontrol-origin:margin;background-color:blue;height:13px}\ QScrollBar::sub-page:vertical{background-color:#EEEDF0;}\ QScrollBar::handle:vertical{background-color:#D1D0D2;width:6px;} QScrollBar::handle:vertical:hover{background-color:#14ACF5;width:6px;} QScrollBar::handle:vertical:pressed{background-color:#0B95D7;width:6px;}\ QScrollBar::add-page:vertical{background-color:#EEEDF0;}\ QScrollBar::down-arrow:vertical{background-color:yellow;}\ QScrollBar::add-line:vertical{subcontrol-origin:margin;border:1px solid green;height:13px}") # self.verticalScrollBar().setStyleSheet("QScrollBar:vertical{margin:0px 0px 0px 0px;background-color:rgb(255,255,255,100);border:0px;width:6px;}\ # QScrollBar::sub-line:vertical{subcontrol-origin:margin;border:1px solid red;height:13px}\ # QScrollBar::up-arrow:vertical{subcontrol-origin:margin;background-color:blue;height:13px}\ # QScrollBar::sub-page:vertical{background-color:#EEEDF0;}\ # QScrollBar::handle:vertical{background-color:#D1D0D2;width:6px;} QScrollBar::handle:vertical:hover{background-color:#14ACF5;width:6px;} QScrollBar::handle:vertical:pressed{background-color:#0B95D7;width:6px;}\ # QScrollBar::add-page:vertical{background-color:#EEEDF0;}\ # QScrollBar::down-arrow:vertical{background-color:yellow;}\ # QScrollBar::add-line:vertical{subcontrol-origin:margin;border:1px solid green;height:13px}") # self.verticalScrollBar().setStyleSheet("QScrollBar:vertical{width:12px;background-color:black;margin:0px,0px,0px,0px;padding-top:0px;padding-bottom:0px;}" # "QScrollBar:sub-page:vertical{background:qlineargradient(x1: 0.5, y1: 1, x2: 0.5, y2: 0, stop: 0 #D4DCE1, stop: 1 white);}QScrollBar:add-page:vertical{background:qlineargradient(x1: 0.5, y1: 0, x2: 0.5, y2: 1, stop: 0 #D4DCE1, stop: 1 white);}" # "QScrollBar:handle:vertical{background:qlineargradient(x1: 0, y1: 0.5, x2: 1, y2: 0.5, stop: 0 #CACACA, stop: 1 #818486);}QScrollBar:add-line:vertical{background-color:green;}") self.ui.name.setStyleSheet("QLabel{font-size:16px;font-weight:bold;}") self.ui.splitText1.setStyleSheet("QLabel{color:#1E66A4;font-size:16px;}") self.ui.splitText2.setStyleSheet("QLabel{color:#1E66A4;font-size:16px;}") self.ui.splitText3.setStyleSheet("QLabel{color:#1E66A4;font-size:16px;}") # self.ui.splitLine1.setStyleSheet("QLabel{background-color:#E0E0E0;}") # self.ui.splitLine2.setStyleSheet("QLabel{background-color:#E0E0E0;}") # self.ui.splitLine3.setStyleSheet("QLabel{background-color:#E0E0E0;}") self.ui.btnCloseDetail.setStyleSheet("QPushButton{background-image:url('res/btn-back-default.png');border:0px;}QPushButton:hover{background:url('res/btn-back-hover.png');}QPushButton:pressed{background:url('res/btn-back-pressed.png');}") # self.ui.btnCloseDetail.setStyleSheet("QPushButton{background-image:url('res/btn-back-default.png');}QPushButton:hover{background:url('res/btn-back-hover.png');}QPushButton:pressed{background:url('res/btn-back-pressed.png');}") # self.ui.detailHeader.setStyleSheet("QLabel{background-image:url('res/detailheadbg.png');color:black;font-size:16px;color:#1E66A4;}") # self.ui.btnCloseDetail.setStyleSheet("QPushButton{background-image:url('res/btn-back-default.png');border:0px;color:white;}QPushButton:hover{background:url('res/btn-back-hover.png');}QPushButton:pressed{background:url('res/btn-back-pressed.png');}") self.ui.candidateVersion.setStyleSheet("QLabel{color:#FF7D15;}") # self.ui.gradeBG.setStyleSheet("QLabel{background-image:url('res/gradebg.png')}") self.ui.grade.setStyleSheet("QLabel{font-size:42px;color:#FA7053;}") self.ui.gradeText2.setStyleSheet("QLabel{font-size:13px;}") # self.ui.gradeText3.setStyleSheet("QLabel{font-size:13px;color:#9AA2AF;}") self.ui.summary.setStyleSheet("QTextEdit{border:0px;}") self.ui.description.setStyleSheet("QTextEdit{border:0px;}") self.ui.description.verticalScrollBar().setStyleSheet("QScrollBar:vertical{margin:0px 0px 0px 0px;background-color:rgb(255,255,255,100);border:0px;width:6px;}\ QScrollBar::sub-line:vertical{subcontrol-origin:margin;border:1px solid red;height:13px}\ QScrollBar::up-arrow:vertical{subcontrol-origin:margin;background-color:blue;height:13px}\ QScrollBar::sub-page:vertical{background-color:#EEEDF0;}\ QScrollBar::handle:vertical{background-color:#D1D0D2;width:6px;} QScrollBar::handle:vertical:hover{background-color:#14ACF5;width:6px;} QScrollBar::handle:vertical:pressed{background-color:#0B95D7;width:6px;}\ QScrollBar::add-page:vertical{background-color:#EEEDF0;}\ QScrollBar::down-arrow:vertical{background-color:yellow;}\ QScrollBar::add-line:vertical{subcontrol-origin:margin;border:1px solid green;height:13px}") # self.ui.description.verticalScrollBar().setStyleSheet("QScrollBar:vertical{width:11px;background-color:black;margin:0px,0px,0px,0px;padding-top:0px;padding-bottom:0px;}" # "QScrollBar:sub-page:vertical{background:qlineargradient(x1: 0.5, y1: 1, x2: 0.5, y2: 0, stop: 0 #D4DCE1, stop: 1 white);}QScrollBar:add-page:vertical{background:qlineargradient(x1: 0.5, y1: 0, x2: 0.5, y2: 1, stop: 0 #D4DCE1, stop: 1 white);}" # "QScrollBar:handle:vertical{background:qlineargradient(x1: 0, y1: 0.5, x2: 1, y2: 0.5, stop: 0 #CACACA, stop: 1 #818486);}QScrollBar:add-line:vertical{background-color:green;}") # self.ui.sshotBG.setStyleSheet("QLabel{background-image:url('res/sshotbg.png')}") self.ui.btnSshotBack.setStyleSheet("QPushButton{border:0px;background-image:url('res/btn-sshot-back-1.png')}QPushButton:hover{background-image:url('res/btn-sshot-back-2')}QPushButton:pressed{background-image:url('res/btn-sshot-back-2')}") self.ui.btnSshotNext.setStyleSheet("QPushButton{border:0px;background-image:url('res/btn-sshot-next-1.png')}QPushButton:hover{background-image:url('res/btn-sshot-next-2')}QPushButton:pressed{background-image:url('res/btn-sshot-next-2')}") self.ui.reviewListWidget.setStyleSheet("QListWidget{background-color:transparent; border:0px;}QListWidget::item{height:85px;margin-top:-1px;border:0px;}") self.ui.thumbnail.hide() self.hide() # mini loading div self.sshotload = MiniLoadingDiv(self.ui.sshotBG, self.detailWidget) self.reviewload = MiniLoadingDiv(self.ui.reviewListWidget, self.detailWidget) self.connect(self.mainwindow,Signals.apt_process_finish,self.slot_work_finished) self.connect(self.mainwindow,Signals.apt_process_cancel,self.slot_work_cancel) def ui_init(self): self.ui = Ui_DetailWidget() self.ui.setupUi(self.detailWidget) # self.ui.setStyleSheet("QWidget{border:0px;}") self.ui.btnInstall.setStyleSheet("QPushButton{background:#0bc406;border:1px solid #03a603;color:white;}QPushButton:hover{background-color:#16d911;border:1px solid #03a603;color:white;}QPushButton:pressed{background-color:#07b302;border:1px solid #037800;color:white;}") self.ui.btnUpdate.setStyleSheet("QPushButton{background:#edac3a;border:1px solid #df9b23;color:white;}QPushButton:hover{background-color:#fdbf52;border:1px solid #df9b23;color:white;}QPushButton:pressed{background-color:#e29f29;border:1px solid #c07b04;color:white;}") self.ui.btnUninstall.setStyleSheet("QPushButton{background:#b2bbc7;border:1px solid #97a5b9;color:white;}QPushButton:hover{background-color:#bac7d7;border:1px solid #97a5b9;color:white;}QPushButton:pressed{background-color:#97a5b9;border:1px solid #7e8da1;color:white;}") def show_by_local_debfile(self, path): # clear reviews self.reviewpage = 1 self.currentreviewready = False self.ui.reviewListWidget.clear() # self.detailWidget.resize(805, 790) # self.ui.reviewListWidget.resize(805, 0) self.detailWidget.resize(860, 790) self.ui.reviewListWidget.resize(860, 0) self.reviewload.move(self.ui.reviewListWidget.x(), self.ui.reviewListWidget.y()) # clear sshot self.sshotcount = 0 self.ui.thumbnail.hide() # self.ui.btnUpdate.setText("不可用") # self.ui.btnUninstall.setText("不可用") # self.ui.btnUpdate.setEnabled(False) # self.ui.btnUninstall.setEnabled(False) # self.ui.btnUpdate.setStyleSheet("QPushButton{background-image:url('res/btn-notenable.png');border:0px;color:#9AA2AF;}") # self.ui.btnUninstall.setStyleSheet("QPushButton{background-image:url('res/btn-notenable.png');border:0px;color:#9AA2AF;}") self.ui.btnUpdate.setVisible(False) self.ui.btnUninstall.setVisible(False) self.debfile = DebFile(path) self.app = self.debfile self.ui.icon.setStyleSheet("QLabel{background-image:url('" + UBUNTUKYLIN_RES_ICON_PATH + "default.png')}") self.ui.name.setText(self.debfile.name) self.ui.installedVersion.setText("软件版本: " + self.debfile.version) sizek = self.debfile.installedsize if(sizek <= 1024): self.ui.size.setText("安装大小: " + str(sizek) + " KB") else: self.ui.size.setText("安装大小: " + str('%.2f'%(sizek/1024.0)) + " MB") self.ui.description.setText(self.debfile.description) if(self.debfile.is_installable()): deps = self.debfile.get_missing_deps() self.ui.summary.setText("需要安装的依赖包: " + str(deps)) self.ui.btnInstall.setText("安装此包") self.ui.btnInstall.setEnabled(True) else: self.ui.btnInstall.setText("无法安装") self.ui.btnInstall.setEnabled(False) #add by kobe self.ui.btnInstall.setVisible(True) self.ui.btnUpdate.setVisible(False) self.ui.btnUninstall.setVisible(False) self.show() self.mainwindow.loadingDiv.stop_loading() # fill fast property, show ui, request remote property def showSimple(self, app, nowpage): # clear reviews self.reviewpage = 1 self.currentreviewready = False self.ui.reviewListWidget.clear() # self.detailWidget.resize(805, 790) # self.ui.reviewListWidget.resize(805, 0) self.detailWidget.resize(860, 790) self.ui.reviewListWidget.resize(860, 0) self.reviewload.move(self.ui.reviewListWidget.x(), self.ui.reviewListWidget.y()) # clear sshot self.sshotcount = 0 self.ui.thumbnail.hide() self.app = app self.ui.name.setText(app.name) self.ui.installedVersion.setText("当前版本: " + app.installed_version) self.ui.candidateVersion.setText("最新版本: " + app.candidate_version) self.ui.summary.setText(app.summary) self.ui.description.setText(app.description) if(os.path.isfile(UBUNTUKYLIN_RES_ICON_PATH + str(self.app.name) + ".png")): self.ui.icon.setStyleSheet("QLabel{background-image:url('" + UBUNTUKYLIN_RES_ICON_PATH + str(app.name) + ".png')}") elif(os.path.isfile(UBUNTUKYLIN_RES_ICON_PATH + str(self.app.name) + ".jpg")): self.ui.icon.setStyleSheet("QLabel{background-image:url('" + UBUNTUKYLIN_RES_ICON_PATH + str(app.name) + ".jpg')}") elif(os.path.isfile(UBUNTUKYLIN_RES_TMPICON_PATH + app.name + ".png")): self.ui.icon.setStyleSheet("QLabel{background-image:url('" + UBUNTUKYLIN_RES_TMPICON_PATH + str(app.name) + ".png')}") elif(os.path.isfile(UBUNTUKYLIN_RES_TMPICON_PATH + app.name + ".jpg")): self.ui.icon.setStyleSheet("QLabel{background-image:url('" + UBUNTUKYLIN_RES_TMPICON_PATH + str(app.name) + ".jpg')}") else: self.ui.icon.setStyleSheet("QLabel{background-image:url('" + UBUNTUKYLIN_RES_ICON_PATH + "default.png')}") size = app.packageSize sizek = size / 1024 if(sizek < 1024): self.ui.size.setText("下载大小: " + str(sizek) + " KB") else: self.ui.size.setText("下载大小: " + str('%.2f'%(sizek/1024.0)) + " MB") installedsize = app.installedSize installedsizek = installedsize / 1024 if(installedsizek < 1024): self.ui.size_install.setText("安装大小: " + str(installedsizek) + " KB") else: self.ui.size_install.setText("安装大小: " + str('%.2f'%(installedsizek/1024.0)) + " MB") self.ui.gradeText1.setText("我的评分: ") # self.ui.gradeText2.setStyleSheet("QLabel{text-align:center;}") self.ui.gradeText2.setText((str(app.ratings_total)) + "人参加评分") # self.ui.commentNumber.setText("共 " + str(app.ratings_total) + " 条评论") # self.ui.gradeText3.setText("满分5分") # self.ui.grade.setStyleSheet("QLabel{text-align:center;}") self.ui.grade.setText(str(app.ratings_average)) self.star = StarWidget('big', app.ratings_average, self.detailWidget) self.star.move(65, 665) self.star2 = StarWidget('big', app.ratings_average, self.detailWidget) self.star2.move(710, 653) if nowpage == "homepage" or nowpage == "winpage": if(app.is_installed): self.ui.status.setStyleSheet("QLabel{background-image:url('res/installed.png')}") self.ui.status.show() if(run.get_run_command(self.app.name) == ""): self.ui.btnInstall.setEnabled(False) self.ui.btnUpdate.setEnabled(False) self.ui.btnUninstall.setEnabled(False) self.ui.btnInstall.setVisible(True) self.ui.btnUpdate.setVisible(False) self.ui.btnUninstall.setVisible(False) self.ui.btnInstall.setText("已安装") else: if self.app.is_upgradable: self.ui.btnUpdate.setText("升级") self.ui.btnInstall.setEnabled(False) self.ui.btnUpdate.setEnabled(True) self.ui.btnUninstall.setEnabled(False) self.ui.btnInstall.setVisible(False) self.ui.btnUpdate.setVisible(True) self.ui.btnUninstall.setVisible(False) else: self.ui.btnInstall.setText("启动") self.ui.btnUpdate.setText("升级") self.ui.btnInstall.setEnabled(True) self.ui.btnUpdate.setEnabled(False) self.ui.btnUninstall.setEnabled(False) self.ui.btnInstall.setVisible(True) self.ui.btnUpdate.setVisible(False) self.ui.btnUninstall.setVisible(False) else: self.ui.status.hide() self.ui.btnInstall.setText("安装") self.ui.btnUpdate.setText("升级") self.ui.btnUninstall.setText("卸载") self.ui.btnInstall.setEnabled(True) self.ui.btnUpdate.setEnabled(False) self.ui.btnUninstall.setEnabled(False) self.ui.btnInstall.setVisible(True) self.ui.btnUpdate.setVisible(False) self.ui.btnUninstall.setVisible(False) elif nowpage == "allpage": self.ui.status.hide() self.ui.btnInstall.setText("安装") self.ui.btnUpdate.setText("升级") self.ui.btnUninstall.setText("卸载") self.ui.btnInstall.setEnabled(True) self.ui.btnUpdate.setEnabled(False) self.ui.btnUninstall.setEnabled(False) self.ui.btnInstall.setVisible(True) self.ui.btnUpdate.setVisible(False) self.ui.btnUninstall.setVisible(False) elif nowpage == "uppage": self.ui.status.hide() self.ui.btnInstall.setText("安装") self.ui.btnUpdate.setText("升级") self.ui.btnUninstall.setText("卸载") self.ui.btnInstall.setEnabled(False) self.ui.btnUpdate.setEnabled(True) self.ui.btnUninstall.setEnabled(False) self.ui.btnInstall.setVisible(False) self.ui.btnUpdate.setVisible(True) self.ui.btnUninstall.setVisible(False) elif nowpage == "unpage": self.ui.status.hide() self.ui.btnInstall.setText("安装") self.ui.btnUpdate.setText("升级") self.ui.btnUninstall.setText("卸载") self.ui.btnInstall.setEnabled(False) self.ui.btnUpdate.setEnabled(False) self.ui.btnUninstall.setEnabled(True) self.ui.btnInstall.setVisible(False) self.ui.btnUpdate.setVisible(False) self.ui.btnUninstall.setVisible(True) self.show() # show loading self.reviewload.start_loading() self.sshotload.start_loading() # send request self.mainwindow.appmgr.get_application_screenshots(app.name,UBUNTUKYLIN_RES_SCREENSHOT_PATH) self.mainwindow.appmgr.get_application_reviews(app.name) def add_review(self, reviewlist): # get maxpage self.maxpage = self.mainwindow.appmgr.db.get_pagecount_by_pkgname(self.app.pkgname) for review in reviewlist: # not this app's review break if(review.package_name != self.app.name): break self.add_one_review(review) self.reviewpage += 1 self.currentreviewready = True self.reviewload.stop_loading() def add_one_review(self, review): count = self.ui.reviewListWidget.count() reviewHeight = (count + 1) * 85 # self.detailWidget.resize(805, 790 + reviewHeight) # self.ui.reviewListWidget.resize(805, reviewHeight) self.detailWidget.resize(860, 790 + reviewHeight) self.ui.reviewListWidget.resize(860, reviewHeight) oneitem = QListWidgetItem() rliw = ReviewWidget(self.app.ratings_average, review) self.ui.reviewListWidget.addItem(oneitem) self.ui.reviewListWidget.setItemWidget(oneitem, rliw) def add_sshot(self, sclist): self.sshotcount = len(sclist) if(self.sshotcount > 0): img = QPixmap(self.app.thumbnailfile) self.ui.thumbnail.resize(img.width(), img.height()) self.ui.thumbnail.setStyleSheet("QPushButton{background-image:url('" + self.app.thumbnailfile + "');border:0px;}") self.ui.thumbnail.move(400 - img.width() / 2, 521 - img.height() / 2) self.ui.thumbnail.show() if(self.sshotcount > 1): img = QPixmap(self.app.screenshotfile) self.bigsshot.resize(img.width(), img.height()) self.bigsshot.bg.resize(img.width(), img.height()) self.bigsshot.bg.setStyleSheet("QLabel{background-image:url('" + self.app.screenshotfile + "');}") self.sshotload.stop_loading() def slot_show_sshot(self): if(self.sshotcount > 1): self.bigsshot.move_to_center() self.bigsshot.show() def slot_close_detail(self): self.hide() def slot_click_install(self): if(self.ui.btnInstall.text() == "启动"): run.run_app(self.app.name) elif(self.ui.btnInstall.text() == "安装此包"): self.emit(Signals.install_debfile, self.debfile) self.ui.btnInstall.setText("处理中") self.ui.btnInstall.setEnabled(False) else: self.emit(Signals.install_app, self.app) self.ui.btnInstall.setText("处理中") self.ui.btnInstall.setEnabled(False) self.ui.btnUpdate.setEnabled(False) self.ui.btnUninstall.setEnabled(False) def slot_click_upgrade(self): self.emit(Signals.upgrade_app, self.app) self.ui.btnUpdate.setText("处理中") self.ui.btnInstall.setEnabled(False) self.ui.btnUpdate.setEnabled(False) self.ui.btnUninstall.setEnabled(False) def slot_click_uninstall(self): self.emit(Signals.remove_app, self.app) self.ui.btnUninstall.setText("处理中") self.ui.btnInstall.setEnabled(False) self.ui.btnUpdate.setEnabled(False) self.ui.btnUninstall.setEnabled(False) def slot_work_finished(self, pkgname, action): #add this to prevent slot received from other signal before show_detail is not called if self.app is None: return if self.app.name == pkgname: self.ui.status.show() if action == AppActions.INSTALLDEBFILE: if(run.get_run_command(self.app.name) == ""): self.ui.btnInstall.setEnabled(False) self.ui.btnInstall.setText("已安装") else: self.ui.btnInstall.setEnabled(True) self.ui.btnInstall.setText("启动") self.ui.btnUpdate.setEnabled(False) self.ui.btnUninstall.setEnabled(False) self.ui.btnInstall.setVisible(True) self.ui.btnUpdate.setVisible(False) self.ui.btnUninstall.setVisible(False) elif action == AppActions.INSTALL: if(run.get_run_command(self.app.name) == ""): self.ui.btnInstall.setText("已安装") self.ui.btnInstall.setEnabled(False) self.ui.btnUpdate.setEnabled(False) self.ui.btnUninstall.setEnabled(False) self.ui.btnInstall.setVisible(True) self.ui.btnUpdate.setVisible(False) self.ui.btnUninstall.setVisible(False) else: self.ui.btnInstall.setVisible(True) if self.app.is_upgradable: self.ui.btnUpdate.setText("升级")#可 self.ui.btnInstall.setEnabled(False) self.ui.btnUpdate.setEnabled(True) self.ui.btnUninstall.setEnabled(False) self.ui.btnInstall.setVisible(False) self.ui.btnUpdate.setVisible(True) self.ui.btnUninstall.setVisible(False) else: self.ui.btnInstall.setText("启动") self.ui.btnUpdate.setText("不可升级") self.ui.btnInstall.setEnabled(True) self.ui.btnUpdate.setEnabled(False) self.ui.btnUninstall.setEnabled(False) self.ui.btnInstall.setVisible(True) self.ui.btnUpdate.setVisible(False) self.ui.btnUninstall.setVisible(False) elif action == AppActions.REMOVE: self.ui.btnInstall.setText("安装") self.ui.btnUpdate.setText("不可升级") self.ui.btnUninstall.setText("卸载")#已 self.ui.btnInstall.setEnabled(False) self.ui.btnUpdate.setEnabled(False) self.ui.btnUninstall.setEnabled(True) self.ui.btnInstall.setVisible(False) self.ui.btnUpdate.setVisible(False) self.ui.btnUninstall.setVisible(True) elif action == AppActions.UPGRADE: if(run.get_run_command(self.app.name) == ""): self.ui.btnInstall.setText("已安装") self.ui.btnInstall.setEnabled(False) self.ui.btnUpdate.setEnabled(False) self.ui.btnUninstall.setEnabled(False) self.ui.btnInstall.setVisible(True) self.ui.btnUpdate.setVisible(False) self.ui.btnUninstall.setVisible(False) else: if self.app.is_upgradable: self.ui.btnUpdate.setText("升级")#可 self.ui.btnInstall.setEnabled(False) self.ui.btnUpdate.setEnabled(True) self.ui.btnUninstall.setEnabled(False) self.ui.btnInstall.setVisible(False) self.ui.btnUpdate.setVisible(True) self.ui.btnUninstall.setVisible(False) else: self.ui.btnInstall.setText("启动") self.ui.btnUpdate.setText("不可升级") self.ui.btnInstall.setEnabled(True) self.ui.btnUpdate.setEnabled(False) self.ui.btnUninstall.setEnabled(False) self.ui.btnInstall.setVisible(True) self.ui.btnUpdate.setVisible(False) self.ui.btnUninstall.setVisible(False) def slot_work_cancel(self, pkgname, action): if self.app is None: return if self.app.name == pkgname: self.ui.status.show() if action == AppActions.INSTALL: if self.app.is_upgradable: self.ui.btnUpdate.setText("升级")#可 self.ui.btnInstall.setEnabled(False) self.ui.btnUpdate.setEnabled(True) self.ui.btnUninstall.setEnabled(False) self.ui.btnInstall.setVisible(False) self.ui.btnUpdate.setVisible(True) self.ui.btnUninstall.setVisible(False) else: self.ui.btnUpdate.setText("不可升级") self.ui.btnInstall.setText("安装") self.ui.btnInstall.setEnabled(True) self.ui.btnUpdate.setEnabled(False) self.ui.btnUninstall.setEnabled(False) self.ui.btnInstall.setVisible(True) self.ui.btnUpdate.setVisible(False) self.ui.btnUninstall.setVisible(False) elif action == AppActions.REMOVE: self.ui.btnUninstall.setText("卸载")#可 self.ui.btnInstall.setEnabled(False) self.ui.btnUpdate.setEnabled(False) self.ui.btnUninstall.setEnabled(True) self.ui.btnInstall.setVisible(False) self.ui.btnUpdate.setVisible(False) self.ui.btnUninstall.setVisible(True) elif action == AppActions.UPGRADE: if(run.get_run_command(self.app.name) == ""): self.ui.btnInstall.setText("已安装") self.ui.btnInstall.setEnabled(False) self.ui.btnUpdate.setEnabled(False) self.ui.btnUninstall.setEnabled(False) self.ui.btnInstall.setVisible(True) self.ui.btnUpdate.setVisible(False) self.ui.btnUninstall.setVisible(False) else: if self.app.is_upgradable: self.ui.btnUpdate.setText("升级")#可 self.ui.btnInstall.setEnabled(False) self.ui.btnUpdate.setEnabled(True) self.ui.btnUninstall.setEnabled(False) self.ui.btnInstall.setVisible(False) self.ui.btnUpdate.setVisible(True) self.ui.btnUninstall.setVisible(False) else: self.ui.btnInstall.setText("启动") self.ui.btnUpdate.setText("不可升级") self.ui.btnInstall.setEnabled(True) self.ui.btnUpdate.setEnabled(False) self.ui.btnUninstall.setEnabled(False) self.ui.btnInstall.setVisible(True) self.ui.btnUpdate.setVisible(False) self.ui.btnUninstall.setVisible(False) def slot_scroll_end(self, now): # current page not ready if(self.currentreviewready == False): pass else: max = self.verticalScrollBar().maximum() if(now == max): # maxpage check if(self.reviewpage <= self.maxpage): self.currentreviewready = False reviewcount = self.ui.reviewListWidget.count() self.reviewload.move(self.reviewload.x(), self.ui.reviewListWidget.y() + 84 * reviewcount) self.reviewload.start_loading() self.mainwindow.appmgr.get_application_reviews(self.app.name, page=self.reviewpage)
def update_xapiandb(self, kwargs): database = xapian.WritableDatabase(XAPIAN_DB_PATH, xapian.DB_OPEN) DB = xapian.Database(XAPIAN_DB_PATH) enquire = xapian.Enquire(database) indexer = xapian.TermGenerator() if "" == kwargs["pkgname"]: modified_num = 0 add_num = 0 xapiandb_update = "No" query_xapiandb_version = xapian.Query("the_#ukxapiandb#_version") enquire.set_query(query_xapiandb_version) matches = enquire.get_mset(0, 1) for re in matches: docid_for_xapiandb_version = re.document.get_docid() doc_for_xapiandb_version = re.document doc_data = doc_for_xapiandb_version.get_data() if (isinstance(doc_data, bytes)): doc_data = doc_data.decode(encoding='utf-8') if ("XAPIANDB_VERSION" == doc_data): the_latest_update_time = doc_for_xapiandb_version.get_value( 2) #valueslot:2 xapiandb update time if (isinstance(the_latest_update_time, bytes)): the_latest_update_time = the_latest_update_time.decode( encoding='utf-8') else: the_latest_update_time = time.strftime( '%Y-%m-%dT%H:%M:%S', time.localtime()) if (Globals.DEBUG_SWITCH): print( "Failed to get the latest update time from client xapiandb,use default time.localtime()" ) reslist = self.premoter.newerapp_for_xapianupdate( the_latest_update_time) for app in reslist: app_name = str(app["app_name"]) display_name_cn = str(app["display_name_cn"]) keywords_for_search = str(app["keywords_for_search"]) query = xapian.Query(app_name) enquire.set_query(query) doccount = DB.get_doccount() matches = enquire.get_mset(0, doccount) if matches.size() != 0: for re in matches: get_name = re.document.get_data() if (isinstance(get_name, bytes)): get_name = get_name.decode(encoding='utf-8') if get_name == app_name: docid = re.docid doc = re.document doc.clear_terms() indexer.set_document(doc) doc.add_term(app_name, 10) if keywords_for_search != "None": keywords = display_name_cn + ";" + keywords_for_search + ";" + app_name else: keywords = display_name_cn + ";" + app_name indexer.index_text(keywords, 10) try: from mmseg.search import seg_txt_search, seg_txt_2_dict for word, value in seg_txt_2_dict( keywords).items(): if word != "none": doc.add_term(word, 10) else: pass except: if (Globals.DEBUG_SWITCH): print("----No mmseg model---") database.replace_document(docid, doc) xapiandb_update = "Yes" modified_num = modified_num + 1 else: continue else: doc = xapian.Document() doc.set_data(app_name) doc.add_term(app_name, 10) indexer.set_document(doc) if keywords_for_search != "None": keywords = display_name_cn + ";" + keywords_for_search + ";" + app_name else: keywords = display_name_cn + ";" + app_name indexer.index_text(keywords, 10) try: for word, value in seg_txt_2_dict(keywords).items(): if word != "none": doc.add_term(word, 10) else: pass except: pass database.add_document(doc) add_num = add_num + 1 if (Globals.DEBUG_SWITCH): print("App:", doc.get_data(), " ", "terms:", end=' ') for itr in doc.termlist(): if (Globals.DEBUG_SWITCH): print(itr.term, end=' ') xapiandb_update = "Yes" if (Globals.DEBUG_SWITCH): print(" ") try: if xapiandb_update == "Yes": now = time.strftime('%Y-%m-%dT%H:%M:%S', time.localtime()) doc_for_xapiandb_version.add_value(2, now) database.replace_document(docid_for_xapiandb_version, doc_for_xapiandb_version) database.commit() if (Globals.DEBUG_SWITCH): print( "Xapiandb has updated . %d app modified, %d app add. Tatal: %d app updated" % (modified_num, add_num, len(reslist))) except: if (Globals.DEBUG_SWITCH): print( "The xapian database (/home/ice_bird/.cache/uksc/xapiandb) is crashed,please remove it and install a new one!" ) if (Globals.DEBUG_SWITCH): print("update uksc xapiandb over") else: appinfo_query = xapian.Query(kwargs["pkgname"]) enquire.set_query(appinfo_query) matches = enquire.get_mset(0, DB.get_doccount()) for re in matches: doc_for_appinfo = re.document doc_data = doc_for_appinfo.get_data() if kwargs["pkgname"] == doc_data: return doc = xapian.Document() doc.set_data(kwargs["pkgname"]) doc.add_term(kwargs["pkgname"], 10) if (Globals.DEBUG_SWITCH): print("debfile path:", kwargs["path"]) deb = DebFile(kwargs["path"]) terms = kwargs["pkgname"] try: terms = terms + " " + deb.description except: if (Globals.DEBUG_SWITCH): print("Failed to get app description") indexer.set_document(doc) indexer.index_text(terms) database.add_document(doc) database.commit() if (Globals.DEBUG_SWITCH): print("update xapiandb over: ", kwargs["pkgname"], "terms:", end=' ') for itr in doc.termlist(): if (Globals.DEBUG_SWITCH): print(itr.term, end=' ') if (Globals.DEBUG_SWITCH): print(" ")