Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Gui/fix/project loading #287

Merged
merged 6 commits into from
Feb 6, 2024
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
@@ -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!!)
@@ -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,
@@ -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

36 changes: 19 additions & 17 deletions GUI/src/main/kotlin/ui/screens/DiffScreen.kt
Original file line number Diff line number Diff line change
@@ -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()
@@ -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
@@ -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?",
)
}