Skip to content

Commit 7e83b8e

Browse files
committed
refactor: Remove commit logic
1 parent d388d3c commit 7e83b8e

3 files changed

Lines changed: 12 additions & 127 deletions

File tree

src/dpg.ini

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -63,3 +63,8 @@ Pos=163,200
6363
Size=458,100
6464
Collapsed=0
6565

66+
[Window][###85]
67+
Pos=184,195
68+
Size=416,110
69+
Collapsed=0
70+

src/patchwork/app.py

Lines changed: 6 additions & 70 deletions
Original file line numberDiff line numberDiff line change
@@ -369,10 +369,8 @@ def clear_markers():
369369

370370
# Commands
371371
def add_change():
372-
373372

374373
global refresh_now
375-
376374
create_marker()
377375

378376
print("Fresh")
@@ -387,38 +385,8 @@ def clear_changes():
387385
return
388386

389387
refresh_now = True
390-
391-
def commit_changes():
392-
393-
timeline = resolve.active_timeline
394-
framerate = timeline.settings.frame_rate
395-
min_duration = int(framerate) * 2
396-
markers = timeline.markers.find_all("patchwork_marker")
397-
398-
patchfile = PatchFile(track_patch_file.chosen_filepath)
399-
saved_settings = patchfile.load()
400-
print(saved_settings)
401-
# compare_settings = patchfile.compare()
402-
403-
assert markers
404-
405-
invalid_markers = [x for x in markers if x.duration < min_duration]
406-
if invalid_markers:
407-
dialog_box.prompt(
408-
"Markers shouldn't be shorter than 2 seconds.\n"
409-
f"These markers are invalid:\n{invalid_markers}",
410-
)
411-
return
412-
413-
# TODO: Check for overlapping markers
414-
415-
for x in markers:
416-
x.color = "Green"
417-
418-
patchfile.update(markers)
419-
420-
421-
def push_changes():
388+
389+
def render_changes():
422390

423391
project = resolve.project
424392
timeline = resolve.active_timeline
@@ -547,42 +515,27 @@ def setup_gui():
547515
dpg.add_text("Mark changes on the active timeline to patch the master file with", wrap=500)
548516
dpg.add_spacer(height=20)
549517

550-
551518
with dpg.group(tag="add_group", horizontal=True):
552519

553520
# ADD BUTTON
554521
dpg.add_button(label="Add", tag="add_button", callback=add_change)
555522

556523
# CLEAR BUTTON
557-
dpg.add_button(label="hanges", tag="clear_changes_button", callback=clear_changes)
558-
with dpg.tooltip("clear_changes_button"):
559-
dpg.add_text("Clear all of Patchwork's ranged-markers\nfrom the active timeline")
524+
dpg.add_button(label="Clear All", tag="clear_changes_button", callback=clear_changes)
560525

561526
dpg.add_text("N/A", tag="current_timecode_display", color=[255, 150, 0])
562527

563-
dpg.add_separator()
564-
dpg.add_spacer(height=20)
565-
566-
# COMMIT BUTTON
567-
dpg.add_text("Commit changes and create render jobs", wrap=500)
568-
with dpg.group(tag="commit_group"):
569-
dpg.add_text("No changes to commit", tag="commit_status", color=[255, 100, 100], wrap=500)
570-
dpg.add_button(label="Commit", tag="commit_button", callback=commit_changes)
571-
572528
dpg.add_separator()
573529
dpg.add_spacer(height=20)
574530

575-
# PUSH BUTTON
576-
dpg.add_button(label="Push", tag="push_button", callback=push_changes)
577-
with dpg.tooltip("push_button"):
531+
# RENDER BUTTON
532+
dpg.add_button(label="Render", tag="render_button", callback=render_changes)
533+
with dpg.tooltip("render_button"):
578534
dpg.add_text("Render and merge changes")
579535

580536
dpg.add_separator()
581537
dpg.add_spacer(height=20)
582538

583-
584-
dpg.add_spacer(height=20)
585-
586539
# SOURCE PAGE
587540
with dpg.tab(label="Source"):
588541

@@ -674,24 +627,7 @@ async def render():
674627
logger.debug("[magenta]Running complex routines")
675628
await routines.check_timecode_starts_at_zero(current_frame_rate, current_timecode)
676629
await routines.refresh_add_status(current_markers, current_timecode, current_frame)
677-
await routines.refresh_commit_status(current_markers)
678-
679-
# TODO: Check Resolve is open, lock up whole interface with warning otherwise
680-
# No option to dismiss dialog box. Automatically dismiss box when Resolve is opened
681630

682-
# TODO: Check timeline is open, lock up whole interface with warning otherwise
683-
# No option to dismiss dialog box. Automatically dismiss box when timeline is opened
684-
685-
# TODO: Check timeline is same as tracked timeline, disable changes page
686-
# On each timeline change, ensure custom settings are enabled. Make it so.
687-
688-
# RUN EVERY HALF SECOND REGARDLESS OF ENVIRONMENT STATE
689-
current_timecode = copy.copy(resolve.active_timeline.timecode)
690-
691-
logger.debug("[magenta]Running complex routines")
692-
await routines.refresh_add_status(markers, current_timecode, current_frame)
693-
await routines.refresh_commit_status(markers)
694-
695631
await trio.sleep(0)
696632

697633
async def main():

src/patchwork/routines.py

Lines changed: 1 addition & 57 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,6 @@
66
from widgets import dialog_box
77
import trio
88
import logging
9-
import copy
109

1110
logger = logging.getLogger(__name__)
1211
logger.setLevel(dpg.get_value("loglevel"))
@@ -183,59 +182,4 @@ async def check_timecode_starts_at_zero(current_frame_rate:float, current_timeco
183182
)
184183
dpg.set_value("zero_timecode_warning_dismissed", True)
185184

186-
await trio.sleep(0)
187-
188-
async def refresh_commit_status(current_markers:MarkerCollection):
189-
190-
logger.debug("[magenta]Refreshing 'Commit' status")
191-
192-
committed_changes = []
193-
uncommitted_changes = []
194-
invalid_changes = []
195-
196-
for x in current_markers:
197-
if x.customdata != "patchwork_marker":
198-
continue
199-
if x.color == "Green":
200-
committed_changes.append(x)
201-
elif x.color == "Purple":
202-
uncommitted_changes.append(x)
203-
else:
204-
invalid_changes.append(x)
205-
206-
assert not invalid_changes
207-
208-
if committed_changes and not uncommitted_changes:
209-
dpg.configure_item("commit_status", color=[0, 255, 0])
210-
dpg.set_value("commit_status", f"All changes committed")
211-
dpg.configure_item("push_button", enabled=True)
212-
213-
elif uncommitted_changes and not committed_changes:
214-
dpg.configure_item("commit_status", color=[255, 150, 0])
215-
dpg.configure_item("commit_button", enabled=True)
216-
dpg.configure_item("push_button", enabled=False)
217-
dpg.set_value("commit_status", f"{len(uncommitted_changes)} uncommitted")
218-
219-
elif uncommitted_changes:
220-
dpg.configure_item("commit_button", enabled=True)
221-
dpg.configure_item("push_button", enabled=False)
222-
dpg.configure_item("commit_status", color=[255, 150, 0])
223-
dpg.set_value(
224-
"commit_status",
225-
f"{len(uncommitted_changes)} uncommitted | "
226-
f"{len(committed_changes)} committed"
227-
)
228-
229-
elif not committed_changes and not uncommitted_changes:
230-
dpg.configure_item("commit_button", enabled=False)
231-
dpg.configure_item("push_button", enabled=False)
232-
dpg.configure_item("commit_status", color=[50, 150, 255])
233-
dpg.set_value("commit_status", "No changes")
234-
235-
else:
236-
dpg.configure_item("commit_button", enabled=False)
237-
dpg.configure_item("push_button", enabled=False)
238-
dpg.configure_item("commit_status", color=[255, 150, 0])
239-
dpg.set_value("commit_status", "N/A")
240-
241-
await trio.sleep(0)
185+
await trio.sleep(0)

0 commit comments

Comments
 (0)