Commit 428a77f9 authored by Roman Alifanov's avatar Roman Alifanov

move apply_flags func to flagsdialog

parent 8c1db620
import re
from gi.repository import Gtk, Adw from gi.repository import Gtk, Adw
@Gtk.Template(resource_path='/ru/eepm/PlayGUI/widgets/flagsdialog.ui') @Gtk.Template(resource_path='/ru/eepm/PlayGUI/widgets/flagsdialog.ui')
...@@ -10,6 +12,11 @@ class FlagsDialog(Adw.Dialog): ...@@ -10,6 +12,11 @@ class FlagsDialog(Adw.Dialog):
def __init__(self, **kwargs): def __init__(self, **kwargs):
super().__init__(**kwargs) super().__init__(**kwargs)
def apply_flags(self, tool, flags, full_command):
for flag in flags:
full_command = re.sub(rf"\b{tool}\b", f"{tool} {flag}", full_command)
return full_command
def ipfs(self): def ipfs(self):
if self.ipfs_row.get_active(): if self.ipfs_row.get_active():
return "--ipfs" return "--ipfs"
......
...@@ -225,7 +225,7 @@ class EepmPlayGuiWindow(Adw.ApplicationWindow): ...@@ -225,7 +225,7 @@ class EepmPlayGuiWindow(Adw.ApplicationWindow):
full_command = " && ".join(commands) full_command = " && ".join(commands)
# Apply flags to the command # Apply flags to the command
full_command = self.apply_flags( full_command = self.flagsdialog.apply_flags("epn play",
[ [
self.flagsdialog.force(), self.flagsdialog.force(),
self.flagsdialog.ipfs(), self.flagsdialog.ipfs(),
...@@ -233,9 +233,3 @@ class EepmPlayGuiWindow(Adw.ApplicationWindow): ...@@ -233,9 +233,3 @@ class EepmPlayGuiWindow(Adw.ApplicationWindow):
], full_command) ], full_command)
return full_command return full_command
def apply_flags(self, flags, full_command):
for flag in flags:
full_command = re.sub(r"\bepm play\b", f"epm play {flag}", full_command)
return full_command
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment