Skip to content

Commit

Permalink
- subtitle dialog code refactor
Browse files Browse the repository at this point in the history
  • Loading branch information
derreisende77 committed Nov 1, 2024
1 parent a48ac5b commit 9cd540f
Show file tree
Hide file tree
Showing 2 changed files with 20 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -56,6 +56,7 @@ public MergeSubripVideoDialog(Window owner) {
btnMerge.setEnabled(false);

fillLanguageComboBox();
cbLanguage.setSelectedItem(getLanguageText(LanguageCode.de));

btnCancel.addActionListener(_ -> dispose());

Expand All @@ -79,13 +80,19 @@ public MergeSubripVideoDialog(Window owner) {
if (file != null) {
tfVideoFilePath.setText(file.getAbsolutePath());
}
else {
tfVideoFilePath.setText("");
}
});

btnSelectVideoOutputPath.addActionListener(_ -> {
var file = FileDialogs.chooseSaveFileLocation(this, "Videospeicherort wählen", "");
if (file != null) {
tfVideoOutputPath.setText(file.getAbsolutePath());
}
else {
tfVideoOutputPath.setText("");
}
});

btnMerge.addActionListener(_ -> {
Expand Down Expand Up @@ -176,11 +183,14 @@ private void shutdownMergeProcess() {
btnCancel.setEnabled(true);
}

private String getLanguageText(LanguageCode code) {
return String.format("%s [%s]", code.nativeName(), code.getISO3Language());
}

public void fillLanguageComboBox() {
List<String> languages = new ArrayList<>();
for (var item : LanguageCode.values()) {
var entry = String.format("%s [%s]", item.nativeName(), item.getISO3Language());
languages.add(entry);
languages.add(getLanguageText(item));
}
cbLanguage.setModel(new DefaultComboBoxModel<>(languages.toArray(new String[0])));
}
Expand Down Expand Up @@ -225,13 +235,19 @@ private void initComponents() {
label1.setText("Untertitel-Datei:"); //NON-NLS
label1.setHorizontalAlignment(SwingConstants.RIGHT);

//---- tfSubripFilePath ----
tfSubripFilePath.setToolTipText("Pfad zur Untertiteldatei im Subrip Text Format (.srt)"); //NON-NLS

//---- btnSelectInputSubrip ----
btnSelectInputSubrip.setText("..."); //NON-NLS

//---- label2 ----
label2.setText("Video-Datei:"); //NON-NLS
label2.setHorizontalAlignment(SwingConstants.RIGHT);

//---- tfVideoFilePath ----
tfVideoFilePath.setToolTipText("Pfad zu einer von ffmpeg unterst\u00fctzten Videodatei als Eingabemedium"); //NON-NLS

//---- btnSelectInputVideo ----
btnSelectInputVideo.setText("..."); //NON-NLS

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,7 @@ new FormModel {
} )
add( new FormComponent( "javax.swing.JTextField" ) {
name: "tfSubripFilePath"
"toolTipText": "Pfad zur Untertiteldatei im Subrip Text Format (.srt)"
} )
add( new FormComponent( "javax.swing.JButton" ) {
name: "btnSelectInputSubrip"
Expand All @@ -47,6 +48,7 @@ new FormModel {
} )
add( new FormComponent( "javax.swing.JTextField" ) {
name: "tfVideoFilePath"
"toolTipText": "Pfad zu einer von ffmpeg unterstützten Videodatei als Eingabemedium"
} )
add( new FormComponent( "javax.swing.JButton" ) {
name: "btnSelectInputVideo"
Expand Down

0 comments on commit 9cd540f

Please sign in to comment.