Skip to content

Commit

Permalink
Merge pull request #287 from amosproj/gui/fix/project-loading
Browse files Browse the repository at this point in the history
Gui/fix/project loading
  • Loading branch information
a-miscellaneous authored Feb 6, 2024
2 parents 4749564 + 2d5e3e6 commit ad07150
Show file tree
Hide file tree
Showing 5 changed files with 29 additions and 20 deletions.
Binary file added Deliverables/sprint-13/build-documentation.pdf
Binary file not shown.
Binary file added Deliverables/sprint-13/design-documentation.pdf
Binary file not shown.
Binary file added Deliverables/sprint-13/user-documentation.pdf
Binary file not shown.
13 changes: 10 additions & 3 deletions GUI/src/main/kotlin/ui/components/general/ProjectManager.kt
Original file line number Diff line number Diff line change
Expand Up @@ -36,10 +36,10 @@ fun ProjectMenu(
state: MutableState<AppState>,
modifier: Modifier = Modifier,
) {
var errorDialogText = remember { mutableStateOf<String?>(null) }
val errorDialogText = remember { mutableStateOf<String?>(null) }
var expanded by remember { mutableStateOf(false) }
val padding = 8.dp
var showConfirmationDialog = remember { mutableStateOf(false) }
val showConfirmationDialog = remember { mutableStateOf(false) }

if (errorDialogText.value != null) {
ErrorDialog(onCloseRequest = { errorDialogText.value = null }, text = errorDialogText.value!!)
Expand Down Expand Up @@ -88,7 +88,7 @@ fun ProjectMenu(
Text("Save Project", fontSize = MaterialTheme.typography.bodyMedium.fontSize)
},
onClick = {
openFileSaverAndGetPath(state.value.saveProjectPath) { path -> handleSaveProject(state, path) }
openFileSaverAndGetPath(state.value.saveProjectPath) { path -> handleSaveProject(state, path, errorDialogText) }
expanded = false
},
enabled = state.value.screen == Screen.DiffScreen,
Expand Down Expand Up @@ -152,12 +152,19 @@ fun handleOpenProject(
fun handleSaveProject(
state: MutableState<AppState>,
path: String,
saveError: MutableState<String?>,
) {
var savePath = path

// add .mkv extension if not present
if (!savePath.endsWith(".mkv")) {
savePath = "$savePath.mkv"
}

if (state.value.outputPath == savePath) {
saveError.value = "The project cannot be saved to the same location as the loaded project. Please choose a different location."
return
}
// set save path
state.value.saveProjectPath = savePath

Expand Down
36 changes: 19 additions & 17 deletions GUI/src/main/kotlin/ui/screens/DiffScreen.kt
Original file line number Diff line number Diff line change
Expand Up @@ -54,12 +54,12 @@ import java.io.File
@Composable
fun DiffScreen(state: MutableState<AppState>) {
// create the navigator, which implements the jumping logic
val navigator = remember { FrameNavigation(state) }
val navigator = FrameNavigation(state)
val showConfirmationDialog = remember { mutableStateOf(false) }
val frameGrabber = FrameGrabber(state)
val thumbnailGrabber = FrameGrabber(state)

DisposableEffect(Unit) {
DisposableEffect(state.value) {
onDispose {
frameGrabber.close()
thumbnailGrabber.close()
Expand Down Expand Up @@ -97,7 +97,23 @@ fun DiffScreen(state: MutableState<AppState>) {
Row {
IconButton(
modifier = Modifier.padding(8.dp),
content = { Icon(Icons.Default.ArrowBack, "back button") },
content = {
Icon(Icons.Default.ArrowBack, "back button")
// ##### Confirmation Dialog #####
ConfirmationPopup(
showDialog = showConfirmationDialog.value,
onConfirm = {
state.value =
state.value.copy(
screen = Screen.SelectVideoScreen,
hasUnsavedChanges = false,
)
},
onCancel = { showConfirmationDialog.value = false },
text =
"Are you sure you want to go back to the main screen without saving the Difference Video?",
)
},
onClick = {
if (state.value.hasUnsavedChanges) {
showConfirmationDialog.value = true
Expand Down Expand Up @@ -170,18 +186,4 @@ fun DiffScreen(state: MutableState<AppState>) {
// ##### Navigation #####
NavigationButtons(navigator, Modifier.weight(1f), Modifier.weight(0.10f))
}
// ##### Confirmation Dialog #####
ConfirmationPopup(
showDialog = showConfirmationDialog.value,
onConfirm = {
state.value =
state.value.copy(
screen = Screen.SelectVideoScreen,
hasUnsavedChanges = false,
)
},
onCancel = { showConfirmationDialog.value = false },
text =
"Are you sure you want to go back to the main screen without saving the Difference Video?",
)
}

0 comments on commit ad07150

Please sign in to comment.