r1rk

CUEparse(spliter)_GUI

Sep 26th, 2025 (edited)
101
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Python 5.33 KB | Source Code | 0 0
  1. # Japanese language only. When using this GUI program, you must also install the CUI program.
  2. # →https://pastebin.com/BkgbGbn7
  3.  
  4. import sys
  5. import os
  6. import json
  7. import subprocess
  8. from PySide6.QtWidgets import (
  9.     QApplication, QWidget, QVBoxLayout, QHBoxLayout, QPushButton,
  10.     QLabel, QFileDialog, QProgressBar, QMessageBox
  11. )
  12. from PySide6.QtCore import Qt
  13.  
  14. CONFIG_FILE = "gui_config.json"
  15.  
  16. def load_config():
  17.     if os.path.exists(CONFIG_FILE):
  18.         with open(CONFIG_FILE, "r", encoding="utf-8") as f:
  19.             return json.load(f)
  20.     return {}
  21.  
  22. def save_config(cfg):
  23.     with open(CONFIG_FILE, "w", encoding="utf-8") as f:
  24.         json.dump(cfg, f, ensure_ascii=False, indent=2)
  25.  
  26. def detect_dark_mode():
  27.     # 窓
  28.     if sys.platform.startswith("win"):
  29.         try:
  30.             import winreg
  31.             reg = winreg.ConnectRegistry(None, winreg.HKEY_CURRENT_USER)
  32.             key = winreg.OpenKey(reg, r"Software\Microsoft\Windows\CurrentVersion\Themes\Personalize")
  33.             val, _ = winreg.QueryValueEx(key, "AppsUseLightTheme")
  34.             return val == 0
  35.         except Exception:
  36.             return False
  37.     # 林檎
  38.     elif sys.platform.startswith("darwin"):
  39.         try:
  40.             import subprocess
  41.             out = subprocess.check_output(
  42.                 ["defaults", "read", "-g", "AppleInterfaceStyle"],
  43.                 stderr=subprocess.DEVNULL
  44.             ).decode().strip()
  45.             return out.lower() == "dark"
  46.         except:
  47.             return False
  48.     # Linuxは省略
  49.     return False
  50.  
  51. class CueGUI(QWidget):
  52.     def __init__(self):
  53.         super().__init__()
  54.         self.setWindowTitle("CUE分割ツール ぶったぎらー!! GUI版 V1.0(buttagira)")
  55.         self.resize(500, 250)
  56.  
  57.         self.config = load_config()
  58.         self.script_path = self.config.get("script_path", "")
  59.  
  60.         self.dark_mode = detect_dark_mode()
  61.         self.setStyleSheet("background-color: #2b2b2b; color: white;" if self.dark_mode else "")
  62.  
  63.         layout = QVBoxLayout()
  64.  
  65.         self.script_label = QLabel(f"分割スクリプト: {os.path.basename(self.script_path) if self.script_path else '未設定'}")
  66.         layout.addWidget(self.script_label)
  67.         self.btn_change_script = QPushButton("分割スクリプトを変更")
  68.         self.btn_change_script.clicked.connect(self.select_script)
  69.         layout.addWidget(self.btn_change_script)
  70.  
  71.         self.cue_label = QLabel("CUEファイル: 未選択")
  72.         layout.addWidget(self.cue_label)
  73.         self.btn_select_cue = QPushButton("CUEファイルを選択")
  74.         self.btn_select_cue.clicked.connect(self.select_cue)
  75.         layout.addWidget(self.btn_select_cue)
  76.  
  77.         self.out_label = QLabel("出力フォルダ: 未選択")
  78.         layout.addWidget(self.out_label)
  79.         self.btn_select_out = QPushButton("出力フォルダを選択")
  80.         self.btn_select_out.clicked.connect(self.select_out_dir)
  81.         layout.addWidget(self.btn_select_out)
  82.  
  83.         self.btn_start = QPushButton("分割開始")
  84.         self.btn_start.clicked.connect(self.start_split)
  85.         layout.addWidget(self.btn_start)
  86.  
  87.         self.progress = QProgressBar()
  88.         self.progress.setRange(0, 0)
  89.         self.progress.setVisible(False)
  90.         layout.addWidget(self.progress)
  91.  
  92.         self.setLayout(layout)
  93.  
  94.         self.cue_path = ""
  95.         self.out_dir = ""
  96.  
  97.     def select_script(self):
  98.         path, _ = QFileDialog.getOpenFileName(self, "分割スクリプトを選択", "", "Python Files (*.py)")
  99.         if path:
  100.             self.script_path = path
  101.             self.script_label.setText(f"分割スクリプト: {os.path.basename(path)}")
  102.             self.config["script_path"] = path
  103.             save_config(self.config)
  104.  
  105.     def select_cue(self):
  106.         path, _ = QFileDialog.getOpenFileName(self, "CUEファイルを選択", "", "CUE Files (*.cue)")
  107.         if path:
  108.             self.cue_path = path
  109.             self.cue_label.setText(f"CUEファイル: {os.path.basename(path)}")
  110.  
  111.     def select_out_dir(self):
  112.         dir_path = QFileDialog.getExistingDirectory(self, "出力フォルダを選択")
  113.         if dir_path:
  114.             self.out_dir = dir_path
  115.             self.out_label.setText(f"出力フォルダ: {dir_path}")
  116.  
  117.     def start_split(self):
  118.         if not self.script_path or not self.cue_path:
  119.             QMessageBox.warning(self, "エラー", "分割スクリプトとCUEファイルを選択してください")
  120.             return
  121.         if not self.out_dir:
  122.             self.out_dir = os.path.join(os.path.dirname(self.cue_path), "split_output")
  123.             self.out_label.setText(f"出力フォルダ: {self.out_dir}")
  124.  
  125.         self.progress.setVisible(True)
  126.         self.btn_start.setEnabled(False)
  127.         QApplication.processEvents()
  128.  
  129.         cmd = [sys.executable, self.script_path, self.cue_path, self.out_dir]
  130.         ret = subprocess.run(cmd)
  131.  
  132.         self.progress.setVisible(False)
  133.         self.btn_start.setEnabled(True)
  134.  
  135.         if ret.returncode == 0:
  136.             QMessageBox.information(self, "完了", "分割処理が完了しました!")
  137.         else:
  138.             QMessageBox.critical(self, "エラー", "分割処理中にエラーが発生しました")
  139.  
  140. if __name__ == "__main__":
  141.     app = QApplication([])
  142.     window = CueGUI()
  143.     window.show()
  144.     sys.exit(app.exec())
Advertisement
Add Comment
Please, Sign In to add comment