Skip to content

Commit

Permalink
More UI changes
Browse files Browse the repository at this point in the history
  • Loading branch information
SheinH committed Jan 10, 2019
1 parent 221566c commit f1f53cd
Show file tree
Hide file tree
Showing 10 changed files with 180 additions and 44 deletions.
111 changes: 111 additions & 0 deletions dependency-reduced-pom.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,111 @@
<?xml version="1.0" encoding="UTF-8"?>
<project xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns="http://maven.apache.org/POM/4.0.0"
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd">
<modelVersion>4.0.0</modelVersion>
<groupId>com.sheinh</groupId>
<artifactId>YouTube-Split</artifactId>
<version>1.0-SNAPSHOT</version>
<build>
<sourceDirectory>src</sourceDirectory>
<outputDirectory>out</outputDirectory>
<resources>
<resource>
<directory>resources</directory>
</resource>
</resources>
<plugins>
<plugin>
<artifactId>maven-compiler-plugin</artifactId>
<version>3.8.0</version>
<configuration>
<source>11</source>
<target>8</target>
</configuration>
</plugin>
<plugin>
<groupId>org.codehaus.mojo</groupId>
<artifactId>exec-maven-plugin</artifactId>
<version>1.2.1</version>
<executions>
<execution>
<goals>
<goal>java</goal>
</goals>
</execution>
</executions>
<configuration>
<mainClass>com.sheinh.ytsplit.MainKt</mainClass>
</configuration>
</plugin>
<plugin>
<artifactId>maven-shade-plugin</artifactId>
<version>3.0.0</version>
<executions>
<execution>
<phase>package</phase>
<goals>
<goal>shade</goal>
</goals>
<configuration>
<transformers>
<transformer>
<mainClass>com.sheinh.ytsplit.MainKt</mainClass>
</transformer>
</transformers>
</configuration>
</execution>
</executions>
</plugin>
<plugin>
<groupId>org.jetbrains.kotlin</groupId>
<artifactId>kotlin-maven-plugin</artifactId>
<version>${kotlin.version}</version>
<executions>
<execution>
<id>compile</id>
<phase>compile</phase>
<goals>
<goal>compile</goal>
</goals>
</execution>
<execution>
<id>test-compile</id>
<phase>test-compile</phase>
<goals>
<goal>test-compile</goal>
</goals>
</execution>
</executions>
<configuration>
<jvmTarget>1.8</jvmTarget>
</configuration>
</plugin>
</plugins>
</build>
<repositories>
<repository>
<id>jaudiotagger-repository</id>
<url>https://dl.bintray.com/ijabz/maven</url>
</repository>
</repositories>
<dependencies>
<dependency>
<groupId>org.jetbrains.kotlin</groupId>
<artifactId>kotlin-test</artifactId>
<version>1.3.11</version>
<scope>test</scope>
<exclusions>
<exclusion>
<artifactId>kotlin-test-common</artifactId>
<groupId>org.jetbrains.kotlin</groupId>
</exclusion>
</exclusions>
</dependency>
</dependencies>
<distributionManagement/>
<properties>
<kotlin.version>1.3.11</kotlin.version>
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
</properties>
</project>

20 changes: 15 additions & 5 deletions resources/FirstPane.fxml
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,8 @@
<?import com.sheinh.ytsplit.AutoCompleteTextField?>
<?import javafx.geometry.Insets?>
<?import javafx.scene.control.*?>
<?import javafx.scene.image.Image?>
<?import javafx.scene.image.ImageView?>
<?import javafx.scene.layout.*?>
<?import javafx.scene.text.*?>
<?import java.net.URL?>
Expand All @@ -26,10 +28,12 @@
</font>
</TextField>
<Button fx:id="getDescriptionButton" focusTraversable="false" maxHeight="29.0" minWidth="40.0"
mnemonicParsing="false" text="">
<HBox.margin>
<Insets/>
</HBox.margin>
mnemonicParsing="false">
<graphic>
<ImageView fitHeight="100.0" fitWidth="20.0" pickOnBounds="true" preserveRatio="true">
<Image url="@fetch.png"/>
</ImageView>
</graphic>
</Button>
</HBox>
<Label fx:id="descriptionLabel" text="Description">
Expand Down Expand Up @@ -60,6 +64,12 @@
</AutoCompleteTextField>
<Button fx:id="regexButton" disable="true" defaultButton="true" focusTraversable="false"
maxHeight="1.7976931348623157E308"
mnemonicParsing="false" prefWidth="40.0" text=""/>
mnemonicParsing="false" prefWidth="40.0">
<graphic>
<ImageView fitHeight="100.0" fitWidth="10.0" pickOnBounds="true" preserveRatio="true">
<Image url="@forward_arrow.png"/>
</ImageView>
</graphic>
</Button>
</HBox>
</VBox>
11 changes: 9 additions & 2 deletions resources/SecondPane.fxml
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
<?import javafx.collections.FXCollections?>
<?import javafx.geometry.Insets?>
<?import javafx.scene.control.*?>
<?import javafx.scene.image.Image?>
<?import javafx.scene.image.ImageView?>
<?import javafx.scene.layout.*?>
<?import javafx.scene.text.*?>
Expand Down Expand Up @@ -67,8 +68,14 @@
</ComboBox>
</HBox>
<HBox fx:id="secondPaneBottomBar" maxWidth="1.7976931348623157E308" spacing="8.0">
<Button fx:id="backButton" cancelButton="true" mnemonicParsing="false" text=""
maxHeight="1.7976931348623157E308" minHeight="29" prefWidth="40.0"/>
<Button fx:id="backButton" cancelButton="true" maxHeight="1.7976931348623157E308" mnemonicParsing="false"
prefWidth="40.0">
<graphic>
<ImageView fitHeight="100.0" fitWidth="10.0" pickOnBounds="true" preserveRatio="true">
<Image url="@back_arrow.png"/>
</ImageView>
</graphic>
</Button>
<Button fx:id="downloadButton" defaultButton="true" disable="true" maxWidth="Infinity" mnemonicParsing="false"
text="Save Music" HBox.hgrow="ALWAYS"/>
</HBox>
Expand Down
Binary file added resources/back_arrow.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added resources/fetch.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added resources/forward_arrow.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
3 changes: 3 additions & 0 deletions resources/style.css
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,9 @@
.button, .text-field, .combo-box{
-fx-background-radius: 4px
}
.button .stop{
-fx-background-color: #edabab;
}
.success {
-fx-background-color: #00FF0055;
}
Expand Down
26 changes: 14 additions & 12 deletions src/com/sheinh/ytsplit/Controller.kt
Original file line number Diff line number Diff line change
Expand Up @@ -98,10 +98,12 @@ class Controller(private val stage : Stage) {
}
}

fun getDependanciesWin() {
if (!Dependencies.checkDependencies() && isWindows) {
showLoadingDialog {
Dependencies.getDependencies()
fun getDependenciesWin() {
if (!Dependencies.check && isWindows) {
Platform.runLater {
showLoadingDialog {
Dependencies.getDependencies()
}
}
}
}
Expand Down Expand Up @@ -215,12 +217,13 @@ class Controller(private val stage : Stage) {
item1.setOnAction { songs.forEach { it.artist = cell.text } }
cell.contextMenu = ContextMenu()
cell.contextMenu.items.add(item1)
songsTable.items = FXCollections.observableList(songs)
cell
}
song.minWidth = 170.0
artist.minWidth = 170.0
artist.setOnEditCommit { it.rowValue.artist = it.newValue }
artist.setOnEditCommit {
if (songs.none { it.artist.isNotBlank() }) songs.forEach { s -> s.artist = it.newValue }
}
songsTable.editableProperty().value = true
songsTable.columns.addAll(track, song, artist)
}
Expand Down Expand Up @@ -315,11 +318,11 @@ class Controller(private val stage : Stage) {
val alert = Alert(Alert.AlertType.INFORMATION)
alert.title = "Save Complete"
alert.headerText = null
alert.contentText = "Files saved to ${directory}"
alert.contentText = "Files saved to $directory"

alert.buttonTypes.clear()
alert.buttonTypes.add(ButtonType.CLOSE)
alert.buttonTypes.add(ButtonType("MYBUTTON", ButtonBar.ButtonData.YES))
alert.buttonTypes.add(ButtonType("Open Folder", ButtonBar.ButtonData.YES))

val out = alert.showAndWait()

Expand Down Expand Up @@ -372,11 +375,11 @@ class Controller(private val stage : Stage) {
}

private fun handleDescriptionButton() {
if (getDescriptionButton.graphic != null) return
if (getDescriptionButton.graphic is ProgressIndicator) return
regexField.requestFocus()
descriptionBox.disableProperty().value = true
regexButton.disableProperty().value = true
val oldtext = getDescriptionButton.text
val oldtext = getDescriptionButton.graphic
getDescriptionButton.text = ""
val indicator = ProgressIndicator()
indicator.maxHeight = 20.0
Expand Down Expand Up @@ -404,8 +407,7 @@ class Controller(private val stage : Stage) {
regexField.styleClass -= "error"
getDescriptionButton.disableProperty().value = false
Platform.runLater {
getDescriptionButton.text = oldtext
getDescriptionButton.graphic = null
getDescriptionButton.graphic = oldtext
}
}
}
Expand Down
31 changes: 15 additions & 16 deletions src/com/sheinh/ytsplit/Dependencies.kt
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,19 @@ import java.util.zip.ZipInputStream


object Dependencies {
val check by lazy {
val yt = checkExe("youtube-dl")
var ffmpeg = checkExe("ffmpeg")
if (isWindows) {
yt == yt || File("youtube-dl.exe").exists()
ffmpeg = ffmpeg || File("ffmpeg.exe").exists()
if (File("ffmpeg.exe").exists()) FFMPEG = File("ffmpeg.exe").absolutePath
if (yt && ffmpeg) {
if (File("ffmpeg.zip").exists()) File("ffmpeg.zip").delete()
}
}
return@lazy yt && ffmpeg
}
private fun decompress() {
if (File("ffmpeg.exe").exists()) return
val fileZip = "ffmpeg.zip"
Expand All @@ -39,7 +52,7 @@ object Dependencies {
}


fun handleMacDependancies(stage : Stage) {
fun handleMacDependencies(stage : Stage) {
val mycontroller = object {
@FXML
lateinit var tf1 : TextField
Expand Down Expand Up @@ -78,26 +91,12 @@ object Dependencies {
val fxmlLoader = FXMLLoader(javaClass.getResource("/SetupMac.fxml"))
fxmlLoader.setController(mycontroller)
val root = fxmlLoader.load<Any>() as Parent
stage.title = "Dependancies"
stage.title = "Dependencies"
stage.scene = Scene(root)
stage.isResizable = false
stage.show()
}

fun checkDependencies() : Boolean {
val yt = checkExe("youtube-dl")
var ffmpeg = checkExe("ffmpeg")
if (isWindows) {
yt == yt || File("youtube-dl.exe").exists()
ffmpeg = ffmpeg || File("ffmpeg.exe").exists()
if (File("ffmpeg.exe").exists()) FFMPEG = File("ffmpeg.exe").absolutePath
if (yt && ffmpeg) {
if (File("ffmpeg.zip").exists()) File("ffmpeg.zip").delete()
}
}
return yt && ffmpeg
}

fun getDependencies() {
if (!checkExe("ffmpeg") && isWindows) {
val localFile = File("ffmpeg.exe")
Expand Down
22 changes: 13 additions & 9 deletions src/com/sheinh/ytsplit/Main.kt
Original file line number Diff line number Diff line change
Expand Up @@ -5,17 +5,19 @@ import javafx.fxml.FXMLLoader
import javafx.scene.Parent
import javafx.scene.Scene
import javafx.stage.Stage
import kotlinx.coroutines.GlobalScope
import kotlinx.coroutines.launch


class MainApp : Application() {
private lateinit var controller : Controller
override fun start(stage : Stage) {
if (isMac && !Dependencies.checkDependencies()) {
Dependencies.handleMacDependancies(stage)
if (isMac && !Dependencies.check) {
Dependencies.handleMacDependencies(stage)
} else startMainApp(stage)
}

fun startMainApp(stage : Stage) {
private fun startMainApp(stage : Stage) {
controller = Controller(stage)
var fxmlLoader = FXMLLoader(javaClass.getResource("/FirstPane.fxml"))
fxmlLoader.setController(controller)
Expand All @@ -27,12 +29,14 @@ class MainApp : Application() {
stage.scene.stylesheets.add("style.css")
stage.isResizable = false
stage.show()
controller.getDependanciesWin()
fxmlLoader = FXMLLoader(javaClass.getResource("/SecondPane.fxml"))
fxmlLoader.setController(controller)
root = fxmlLoader.load<Any>() as Parent
controller.secondPane = root
controller.secondPaneInit()
GlobalScope.launch {
controller.getDependenciesWin()
fxmlLoader = FXMLLoader(javaClass.getResource("/SecondPane.fxml"))
fxmlLoader.setController(controller)
root = fxmlLoader.load<Any>() as Parent
controller.secondPane = root
controller.secondPaneInit()
}
}
}

Expand Down

0 comments on commit f1f53cd

Please sign in to comment.