Example #1
0
 def save_settings(self) -> None:
     """Save Pyslvs settings (auto save when close event)."""
     if self.prefer.not_save_option:
         f = QFile(self.settings.fileName())
         if f.exists():
             f.remove()
         return
     self.settings.setValue("ENV", self.env)
     for field in fields(self.prefer):  # type: Field
         self.settings.setValue(field.name, getattr(self.prefer, field.name))
Example #2
0
    def deleteItem(self):
        """Delete the selected item (either a file or folder)."""
        # ToDo: use Move2Trash, instead of deleting the file
        index = self.selectionModel().currentIndex()
        path = self.model.filePath(index)
        if path:
            file_info = QFileInfo(path)
            if file_info.isFile():
                if not self.ask_dialog("Do you wan't to delete the selected file?"):
                    return
                q_file = QFile(path)
                q_file.remove()

            elif file_info.isDir():
                if not self.ask_dialog("Do you wan't to delete the selected directory?"):
                    return
                directory = QDir(path)
                directory.removeRecursively()