Skip to content
This repository has been archived by the owner on Apr 3, 2022. It is now read-only.

Commit

Permalink
Reorganised the Start/Hide/Abort all button group
Browse files Browse the repository at this point in the history
Added a abortAndClearAll button
Added $(rawname) tag
  • Loading branch information
Stekeblad committed Mar 13, 2018
1 parent bf22885 commit cadecb8
Show file tree
Hide file tree
Showing 5 changed files with 40 additions and 27 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -3,9 +3,12 @@
#### Right now
- Bugs and small things

#### More important things to do
#### Higher priority things to do
- Change "Abort all and clear" button to not affect started uploads.
users can currently not remove all not started at once and it would
only be two extra click to first abort all before clearing.

#### Less important things to do
#### Lower priority things to do
- Creating localization support and moving all strings visible for the
users there (resourceBundle)
- add notice for that Edge does not work for authentication!
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,18 +19,18 @@
<TextField fx:id="text_autoNum" maxWidth="-Infinity" prefHeight="25.0" prefWidth="72.0" />
<Button fx:id="btn_applyPreset" mnemonicParsing="false" onAction="#onApplyPresetClicked" text="Apply preset" />
</VBox>
<VBox alignment="TOP_RIGHT" layoutX="809.0" layoutY="40.0" maxHeight="180.0" prefWidth="279.0" spacing="5.0"
AnchorPane.rightAnchor="17.0" AnchorPane.topAnchor="40.0">
<VBox alignment="TOP_RIGHT" layoutX="809.0" layoutY="40.0" maxHeight="180.0" prefHeight="145.0" prefWidth="279.0"
spacing="10.0" AnchorPane.rightAnchor="17.0" AnchorPane.topAnchor="40.0">
<opaqueInsets>
<Insets/>
</opaqueInsets>
<Button fx:id="btn_startAll" mnemonicParsing="false" onAction="#onStartAllUploadsClicked"
text="Start All Ready Uploads"/>
<Button fx:id="btn_removeFinished" mnemonicParsing="false" onAction="#onRemoveFinishedUploadsClicked"
text="Remove All Finished Uploads"/>
<Button fx:id="btn_abortAll" mnemonicParsing="false" onAction="#onAbortAllUploadsClicked"
text="Abort All Uploads"/>
<Button fx:id="btn_abortAndClear" mnemonicParsing="false" onAction="#onAbortAndClearClicked"
text="Abort All and Clear Uploads Area"/>
<Button fx:id="btn_startAll" maxWidth="1.7976931348623157E308" mnemonicParsing="false"
onAction="#onStartAllUploadsClicked" text="Start All Ready Uploads"/>
<Button fx:id="btn_removeFinished" maxWidth="1.7976931348623157E308" mnemonicParsing="false"
onAction="#onRemoveFinishedUploadsClicked" text="Remove All Finished Uploads"/>
<Button fx:id="btn_abortAll" maxWidth="1.7976931348623157E308" mnemonicParsing="false"
onAction="#onAbortAllUploadsClicked" text="Abort All Uploads"/>
<Button fx:id="btn_abortAndClear" maxWidth="1.7976931348623157E308" mnemonicParsing="false"
onAction="#onAbortAndClearClicked" text="Abort All and Clear Uploads Area"/>
</VBox>
</AnchorPane>
Original file line number Diff line number Diff line change
Expand Up @@ -82,7 +82,7 @@ public void initialize(URL location, ResourceBundle resources) {
choice_presets.setItems(FXCollections.observableArrayList(configManager.getPresetNames()));
btn_startAll.setTooltip(new Tooltip("Starts all uploads that have the \"Start Upload\" button visible"));
btn_abortAll.setTooltip(new Tooltip("Aborts all uploads that have the \"Abort\" button visible"));
btn_abortAndClear.setTooltip(new Tooltip("Aborts all uploads and removes all uploads from the list below"));
btn_abortAndClear.setTooltip(new Tooltip("Aborts all started uploads and removes all uploads from the list below"));

// Only allow numbers in autoNum textField
text_autoNum.textProperty().addListener((observable, oldValue, newValue) -> {
Expand Down Expand Up @@ -229,6 +229,11 @@ public void onApplyPresetClicked(ActionEvent actionEvent) {
for (File videoFile : videosToAdd) {
// Apply automatic numbering on video name
String name = chosenPreset.getVideoName().replace("$(ep)", String.valueOf(autoNum++));
// Insert raw file name in title, exclude file extension
if (name.contains("$(rawname)")) {
String rawFileName = videoFile.getName().substring(0, videoFile.getName().lastIndexOf("."));
name = name.replace("$(rawname)", rawFileName);
}
// Insert playlist URL in description
String description = chosenPreset.getVideoDescription()
.replace("$(playlist)", playlistUrl);
Expand Down Expand Up @@ -361,12 +366,14 @@ public void onRemoveFinishedUploadsClicked(ActionEvent actionEvent) {
*/
public void onAbortAllUploadsClicked(ActionEvent actionEvent) {
// Show confirmation dialog
Optional<ButtonType> buttonChoice = AlertUtils.yesNo("Abort ALL Uploads?",
"Are you sure you want to abort the uploading of all started uploads?").showAndWait();
if (buttonChoice.isPresent()) {
if (buttonChoice.get() != ButtonType.YES) {
// ButtonType.NO or Closed with [X] button
return;
if (!bybassAbortWarning) { // can be set from onAbortAndClearClicked
Optional<ButtonType> buttonChoice = AlertUtils.yesNo("Abort ALL Uploads?",
"Are you sure you want to abort the uploading of all started uploads?").showAndWait();
if (buttonChoice.isPresent()) {
if (buttonChoice.get() != ButtonType.YES) {
// ButtonType.NO or Closed with [X] button
return;
}
}
}
// Prevent the "Are you sure you want to abort X?" dialog for every upload
Expand Down Expand Up @@ -394,6 +401,7 @@ public void onAbortAndClearClicked(ActionEvent actionEvent) {
"all started, aborted, finished and not yet started uploads?").showAndWait();
if (choice.isPresent()) {
if (choice.get() == ButtonType.YES) {
bybassAbortWarning = true; // is set back to false by onAbortAllUploadsClicked
onAbortAllUploadsClicked(new ActionEvent());
uploadQueueVideos.clear();
uploadPaneCounter = 0;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -163,6 +163,7 @@ public void onTipsClicked(ActionEvent actionEvent) {
"comma a part of the tag.\nOk, tips!" +
"\n- In the video title field you can write \"$(ep)\" to tell the program where to insert the episode " +
"number/name defined when adding videos for upload." +
"\n- In the video title field you can also write \"$(rawname)\" to insert the name of the video file used" +
"\n- In the description field you can add \"$(playlist)\" to insert a link to the playlist the " +
"video will be added to then uploaded.";
AlertUtils.simpleClose("Tips", messageContent).showAndWait();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@
import java.math.BigDecimal;
import java.nio.file.Files;
import java.nio.file.Paths;
import java.util.ArrayList;
import java.util.List;

import static io.github.stekeblad.videouploader.youtube.VideoInformationBase.THUMBNAIL_FILE_FORMAT;
Expand Down Expand Up @@ -51,20 +52,20 @@ public static List<File> pickVideos() {
FileChooser fileChooser = new FileChooser();
fileChooser.setTitle("Choose video files to upload");
Stage fileChooserStage = new Stage();
List<File> filesToUpload = fileChooser.showOpenMultipleDialog(fileChooserStage);
if (filesToUpload != null) {
List<File> chosenFiles = fileChooser.showOpenMultipleDialog(fileChooserStage);
List<File> filesToUpload = new ArrayList<>();
if (chosenFiles != null) {
boolean fileWasSkipped = false;
for (int i = 0; i < filesToUpload.size(); i++) {
for (File chosenFile : chosenFiles) {
try { // Check file MIME to see if it is a video file
if (!Files.probeContentType(Paths.get(filesToUpload.get(i).toURI())).startsWith(VIDEO_FILE_FORMAT)) {
String contentType = Files.probeContentType(Paths.get(chosenFile.toURI()));
if (contentType == null || !contentType.startsWith(VIDEO_FILE_FORMAT)) {
fileWasSkipped = true; // at leased one selected file is not a video file
filesToUpload.remove(filesToUpload.get(i));
i--;
} else {
filesToUpload.add(chosenFile);
}
} catch (Exception e) {
fileWasSkipped = true;
filesToUpload.remove(filesToUpload.get(i));
i--;
}
}
if (fileWasSkipped) {
Expand Down

0 comments on commit cadecb8

Please sign in to comment.