(self, save=False)
| 857 | del self |
| 858 | |
| 859 | def genRunScript(self, save=False): |
| 860 | if not hasattr(self.serverLauncher, "jvmArg"): |
| 861 | self.serverLauncher._setJVMArg() |
| 862 | script = ( |
| 863 | f'$host.ui.RawUI.WindowTitle="{self.serverConfig.serverName}"' |
| 864 | f'\ncd "{osp.abspath("Servers" + osp.sep + self.serverConfig.serverName)}"' |
| 865 | + f'\n$JavaPath = "{self.serverConfig.javaPath}"' |
| 866 | + f'\n$JavaArgs = "{" ".join(self.serverLauncher.jvmArg)}"\n' |
| 867 | + "Start-Process -FilePath $JavaPath -ArgumentList $JavaArgs -NoNewWindow -Wait\n" |
| 868 | + "pause" |
| 869 | ) |
| 870 | if save: |
| 871 | return script |
| 872 | else: |
| 873 | ( |
| 874 | w := MessageBox(self.tr("生成启动脚本 (PowerShell)"), "", parent=self) |
| 875 | ).contentLabel.setParent(None) |
| 876 | w.yesButton.setText(self.tr("保存")) |
| 877 | w.yesSignal.connect(self.saveRunScript) |
| 878 | (copyWidget := QWidget()).setLayout((cmdLayout := QHBoxLayout())) |
| 879 | |
| 880 | copyBtn = PushButton(icon=FIF.COPY, text=self.tr("复制"), parent=w) |
| 881 | copyBtn.setFixedHeight(200) |
| 882 | copyBtn.clicked.connect(lambda: QApplication.clipboard().setText(script)) |
| 883 | copyBtn.clicked.connect( |
| 884 | lambda: InfoBar.success( |
| 885 | self.tr("已复制"), |
| 886 | "", |
| 887 | orient=Qt.Horizontal, |
| 888 | isClosable=False, |
| 889 | position=InfoBarPosition.TOP, |
| 890 | duration=1500, |
| 891 | parent=self, |
| 892 | ) |
| 893 | ) |
| 894 | |
| 895 | textEdit = PlainTextEdit(parent=w) |
| 896 | textEdit.setReadOnly(True) |
| 897 | textEdit.setPlainText(script) |
| 898 | textEdit.setFixedSize(QSize(400, 200)) |
| 899 | |
| 900 | cmdLayout.addWidget(textEdit, 0, Qt.AlignRight) |
| 901 | cmdLayout.addWidget(copyBtn, 1, Qt.AlignRight) |
| 902 | w.textLayout.addWidget(copyWidget) |
| 903 | w.show() |
| 904 | |
| 905 | def saveRunScript(self): |
| 906 | try: |
no test coverage detected