コード例 #1
0
    def search_bar(self):
        text = self.ui.SearchBar.text()
        n = 0
        results = []

        # ! not part of search - joke
        if text == "wii bric":
            self.ui.listAppsWidget.clear()
            item = QListWidgetItem()
            item.setText("Wii Pong\n"
                         "9.000MiB | 9.0.0.0 | Danbo | Wii Pong")
            item.setIcon(QIcon(resource_path("assets/gui/icons/bricks.png")))
            self.ui.listAppsWidget.addItem(item)
            self.close_the_shop()
            return

        # Filter items with search term
        for i in self.ui.listAppsWidget.findItems(text, Qt.MatchContains):
            if self.current_category == "all" and (self.current_developer in i.data(Qt.UserRole)["coder"]):
                results.append(i.text())
                n += 1
            elif i.data(Qt.UserRole)["category"] == self.current_category and (self.current_developer in i.data(Qt.UserRole)["coder"]):
                results.append(i.text())
                n += 1
            else:
                pass

        # Get All Items
        for i in self.ui.listAppsWidget.findItems("", Qt.MatchContains):
            # Hide and unhide!
            if i.text() in results:
                i.setHidden(False)
            else:
                i.setHidden(True)
        if text == "":
            if n == 1:
                self.ui.AppsAmountLabel.setText(f"{n} App")
            else:
                self.ui.AppsAmountLabel.setText(f"{n} Apps")
        else:
            if n == 1:
                self.ui.AppsAmountLabel.setText(f"{n} Result")
            else:
                self.ui.AppsAmountLabel.setText(f"{n} Results")
コード例 #2
0
    def selection_changed(self):
        try:
            if not splash.isHidden():
                splash.showMessage(f"Finishing (2/2) - Loading first app..", color=splash_color)
        except NameError:
            pass
        try:
            data = self.ui.listAppsWidget.currentItem().data(Qt.UserRole)
            app_name = data["internal_name"]
        except Exception:
            app_name = None
        if app_name is not None:
            # Set active tab to first
            self.ui.tabMetadata.setCurrentIndex(0)

            # Set loading animation
            self.ui.HomebrewIconLabel.setMovie(self.spinner)

            # Clear supported controllers listview:
            self.ui.SupportedControllersListWidget.clear()

            # Set data
            data = self.ui.listAppsWidget.currentItem().data(Qt.UserRole)

            # check if send to wii is supported
            if utils.is_supported_by_wiiload(data):
                self.ui.WiiLoadButton.setEnabled(True)
                self.ui.WiiLoadButton.setText("Send to Wii")
            else:
                self.ui.WiiLoadButton.setEnabled(False)
                self.ui.WiiLoadButton.setText("Send Not Supported")

            # -- Get actual metadata
            # App Name
            self.ui.appname.setText(data["display_name"])
            self.ui.SelectionInfoBox.setTitle("Metadata: " + data["display_name"])
            self.ui.label_displayname.setText(data["display_name"])

            # File Size
            try:
                self.ui.filesize.setText(metadata.file_size(data["extracted"]))
            except KeyError:
                self.ui.filesize.setText("Unknown")

            # Category
            self.ui.HomebrewCategoryLabel.setText(metadata.category_display_name(data["category"]))

            # Release Date
            self.ui.releasedate.setText(datetime.fromtimestamp(int(data["release_date"])).strftime('%B %e, %Y at %R'))

            # Controllers
            controllers = metadata.parse_controllers(data["controllers"])
            # Add icons for Wii Remotes
            if controllers[0] > 1:
                item = QListWidgetItem()
                item.setText(f"{str(controllers[0])} Wii Remotes")
                item.setIcon(QIcon(resource_path(f"assets/gui/icons/controllers/{str(controllers[0])}WiiRemote.png")))
                item.setToolTip(f"This app supports up to {str(controllers[0])} Wii Remotes.")
                self.ui.SupportedControllersListWidget.addItem(item)
            elif controllers[0] == 1:
                item = QListWidgetItem()
                item.setText(f"1 Wii Remote")
                item.setIcon(QIcon(resource_path(f"assets/gui/icons/controllers/1WiiRemote.png")))
                item.setToolTip("This app supports a single Wii Remote.")
                self.ui.SupportedControllersListWidget.addItem(item)
            if controllers[1] is True:
                item = QListWidgetItem()
                item.setText(f"Nunchuk")
                item.setIcon(QIcon(resource_path(f"assets/gui/icons/controllers/Nunchuk.png")))
                item.setToolTip("This app can be used with a Nunchuk.")
                self.ui.SupportedControllersListWidget.addItem(item)
            if controllers[2] is True:
                item = QListWidgetItem()
                item.setText(f"Classic Controller")
                item.setIcon(QIcon(resource_path(f"assets/gui/icons/controllers/ClassicController.png")))
                item.setToolTip("This app can be used with a Classic Controller.")
                self.ui.SupportedControllersListWidget.addItem(item)
            if controllers[3] is True:
                item = QListWidgetItem()
                item.setText(f"GameCube Controller")
                item.setIcon(QIcon(resource_path(f"assets/gui/icons/controllers/GamecubeController.png")))
                item.setToolTip("This app can be used with a Gamecube Controller.")
                self.ui.SupportedControllersListWidget.addItem(item)
            if controllers[4] is True:
                item = QListWidgetItem()
                item.setText(f"Wii Zapper")
                item.setIcon(QIcon(resource_path(f"assets/gui/icons/controllers/WiiZapper.png")))
                item.setToolTip("This app can be used with a Wii Zapper.")
                self.ui.SupportedControllersListWidget.addItem(item)
            if controllers[5] is True:
                item = QListWidgetItem()
                item.setText(f"USB Keyboard")
                item.setIcon(QIcon(resource_path(f"assets/gui/icons/controllers/USBKeyboard.png")))
                item.setToolTip("This app can be used with a USB Keyboard.")
                self.ui.SupportedControllersListWidget.addItem(item)
            if controllers[6] is True:
                item = QListWidgetItem()
                item.setText(f"SDHC Card")
                item.setIcon(QIcon(resource_path(f"assets/gui/icons/controllers/SDHC.png")))
                item.setToolTip("This app is confirmed to support SDHC cards.")
                self.ui.SupportedControllersListWidget.addItem(item)

            # Version
            self.ui.version.setText(data["version"])

            # Coder
            self.ui.developer.setText(data["coder"])

            # Short Description
            if data["short_description"] == "":
                self.ui.label_description.setText("No description specified.")
            else:
                self.ui.label_description.setText(data["short_description"])

            # Long Description
            self.ui.longDescriptionBrowser.setText(data["long_description"])

            # File Name Line Edit
            self.ui.FileNameLineEdit.setText(app_name + ".zip")
        self.ui.progressBar.setValue(0)
        self.repaint()
        # Load icon
        t = threading.Thread(target=self.load_icon, args=[app_name, HOST])
        t.start()
        self.status_message("Ready to download")