Beispiel #1
0
    def save_image(self, label):
        if not self.preview:
            pop_up(
                "Mark an image first.",
                "Before you can save an image, you need to take a screenshot (with the take screenshot button),"
                "Then you need to mark the top left corner of the poker window (or load a previously saved one)"
                "After that an image needs to be marked by clicking on the top left and then bottom right corner of that image."
            )
            return

        log.info(f"flattening button {label}")
        self.signal_flatten_button.emit(label)

        self.table_name = self.ui.table_name.currentText()
        mongo = MongoManager()
        owner = mongo.get_table_owner(self.table_name)
        if owner != COMPUTER_NAME:
            pop_up(
                "Not authorized.",
                "You can only edit your own tables. Please create a new copy or start with a new blank table"
            )
            return
        log.info(f"Saving {label}")
        mongo.update_table_image(pil_image=self.preview,
                                 label=label,
                                 table_name=self.table_name)
        log.info("Saving complete")
Beispiel #2
0
    def delete(self):
        self.table_name = self.ui.table_name.currentText()
        mongo = MongoManager()
        owner = mongo.get_table_owner(self.table_name)
        if owner != COMPUTER_NAME:
            pop_up("Not authorized.",
                   "You can only delete the tables that you created")
            return

        resp = pop_up(
            "Are you sure?",
            "Are you sure you want to delete this table? This cannot be undone.",
            ok_cancel=True)
        if resp == 1024:
            mongo.delete_table(table_name=self.table_name)
Beispiel #3
0
    def save_coordinates(self, label, player=None):
        if not self.cropped:
            pop_up(
                "Image not yet cropped",
                "Before you can mark coordinates, you need to mark or load a top left corner, then crop the image."
            )
            return

        if self.x1 > self.x2 or self.y1 > self.y2:
            pop_up(
                "Invalid coordinates",
                "Top left corner of image is more to the right/bottom the lower right coordinates. Please try again."
            )
            return

        self.table_name = self.ui.table_name.currentText()

        log.info(
            f"Saving coordinates for {label} with coordinates {self.x1, self.y1, self.x2, self.y2}"
        )
        mongo = MongoManager()
        owner = mongo.get_table_owner(self.table_name)

        if owner != COMPUTER_NAME:
            pop_up(
                "Not authorized.",
                "You can only edit your own tables. Please create a new copy or start with a new blank table"
            )
            return

        if player:
            label = label + '.' + player
        mongo.save_coordinates(self.table_name, label, {
            'x1': self.x1,
            'y1': self.y1,
            'x2': self.x2,
            'y2': self.y2
        })