Initial commit...
This commit is contained in:
@@ -0,0 +1,40 @@
|
||||
|
||||
import javafx.fxml.FXMLLoader;
|
||||
import javafx.stage.Stage;
|
||||
import javafx.scene.Scene;
|
||||
|
||||
public class BackgroundManager {
|
||||
|
||||
protected final Stage backgroundStage = new Stage();
|
||||
protected Scene scene;
|
||||
|
||||
// Private class to generate singleton
|
||||
private static BackgroundManager backgroundManager = new BackgroundManager();
|
||||
// init
|
||||
|
||||
private BackgroundManager() {
|
||||
// Setup window
|
||||
try {
|
||||
scene = new Scene(FXMLLoader.load(BackgroundManager.class.getResource("resources/BackgroundManagerWindow.fxml")), 800, 600);
|
||||
} catch (Exception e) {
|
||||
// If it fails, write the error message to screen
|
||||
e.printStackTrace();
|
||||
}
|
||||
backgroundStage.setScene(scene);
|
||||
backgroundStage.setTitle("Background");
|
||||
backgroundStage.setMinWidth(300);
|
||||
backgroundStage.setMinHeight(300);
|
||||
}
|
||||
|
||||
// Functions
|
||||
// Geters
|
||||
public static BackgroundManager getInstance() {
|
||||
return backgroundManager;
|
||||
}
|
||||
// Setters
|
||||
|
||||
// Others
|
||||
protected void showWindow() {
|
||||
backgroundStage.show();
|
||||
}
|
||||
}
|
@@ -0,0 +1,147 @@
|
||||
|
||||
import javafx.stage.Stage;
|
||||
import javafx.stage.DirectoryChooser;
|
||||
import javafx.fxml.FXML;
|
||||
import javafx.scene.Scene;
|
||||
import javafx.scene.layout.Pane;
|
||||
import javafx.scene.image.Image;
|
||||
import javafx.scene.image.ImageView;
|
||||
import javafx.scene.layout.TilePane;
|
||||
import javafx.scene.control.Button;
|
||||
import javafx.scene.control.Label;
|
||||
import javafx.scene.control.TextField;
|
||||
import javafx.event.ActionEvent;
|
||||
import javafx.scene.input.KeyEvent;
|
||||
import javafx.scene.input.KeyCode;
|
||||
import javafx.scene.input.MouseEvent;
|
||||
import javafx.scene.input.MouseButton;
|
||||
import java.io.File;
|
||||
import javafx.concurrent.Task;
|
||||
|
||||
public class BackgroundMngrController {
|
||||
// Class objects
|
||||
|
||||
private Settings settings = Settings.getInstance(); // Singleton Class settings
|
||||
|
||||
// Fxml objects
|
||||
@FXML
|
||||
private Label dir;
|
||||
@FXML
|
||||
private TextField txtDirPath;
|
||||
@FXML
|
||||
private Button clear;
|
||||
@FXML
|
||||
private TilePane tilePane;
|
||||
|
||||
// Generics
|
||||
private DirectoryChooser folderChooser = new DirectoryChooser();
|
||||
private Image pth = new Image(".");
|
||||
private Image previewPth = new Image(".");
|
||||
private ImageView imgView = new ImageView(pth);
|
||||
private String textAreaPth = "";
|
||||
private File directory;
|
||||
private File[] fileList;
|
||||
|
||||
@FXML
|
||||
void initialize() {
|
||||
// Initialize any logic here: all @FXML variables will have been injected
|
||||
}
|
||||
|
||||
@FXML
|
||||
void onEnter(KeyEvent event) {
|
||||
if (event.getCode().equals(KeyCode.ENTER)) {
|
||||
textAreaPth = txtDirPath.getText();
|
||||
System.out.println(textAreaPth);
|
||||
newDir();
|
||||
}
|
||||
}
|
||||
|
||||
@FXML
|
||||
void setNewDir(MouseEvent event) {
|
||||
newDir();
|
||||
}
|
||||
|
||||
// Scan selected dir
|
||||
public void newDir() {
|
||||
tilePane.getChildren().clear();
|
||||
Stage stage = new Stage();
|
||||
if (textAreaPth != "") {
|
||||
directory = new File(textAreaPth);
|
||||
} else {
|
||||
directory = folderChooser.showDialog(stage);
|
||||
if (directory != null) {
|
||||
System.out.println("Directory: " + directory);
|
||||
}
|
||||
}
|
||||
|
||||
fileList = directory.listFiles();
|
||||
txtDirPath.setText("" + directory);
|
||||
for (int i = 0; i < fileList.length; i++) {
|
||||
imgView = new ImageView();
|
||||
imgView.setFitWidth(300); // Need these here to get grid properly.
|
||||
imgView.setFitHeight(200);
|
||||
tilePane.getChildren().add(imgView);
|
||||
}
|
||||
|
||||
Task getDir = new Task<Void>() {
|
||||
@Override
|
||||
public Void call() {
|
||||
newDir2();
|
||||
return null;
|
||||
}
|
||||
};
|
||||
new Thread(getDir).start();
|
||||
}
|
||||
|
||||
public void newDir2() {
|
||||
int j = 0; // Used to properly insert to grid when there are files other than an image
|
||||
for (int i = 0; i < fileList.length; i++) {
|
||||
String path = "" + fileList[i];
|
||||
if (fileList[i].getName().contains(".png") || fileList[i].getName().contains(".jpg")
|
||||
|| fileList[i].getName().contains(".gif") || fileList[i].getName().contains(".jpeg")) {
|
||||
String title = "" + fileList[i];
|
||||
pth = new Image("file://" + fileList[i]);
|
||||
ImageView view = (ImageView) (tilePane.getChildren().get(j));
|
||||
|
||||
view.setImage(pth);
|
||||
view.setCache(true);
|
||||
final ImageView imgViewPoped = new ImageView("file://" + fileList[i]);
|
||||
// image click actions
|
||||
view.setOnMouseClicked(mouse -> {
|
||||
MouseButton button = mouse.getButton();
|
||||
if (mouse.getClickCount() == 2 && button == MouseButton.PRIMARY && !mouse.isConsumed()) {
|
||||
mouse.consume();
|
||||
txtDirPath.setText(path);
|
||||
settings.setBackgroundInfo(path);
|
||||
} else if (button == MouseButton.SECONDARY) {
|
||||
displayImg(imgViewPoped, title);
|
||||
}
|
||||
});
|
||||
j++;
|
||||
} else {
|
||||
System.out.println("Not an image file.");
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public void displayImg(ImageView imgViewPoped, String title) {
|
||||
Stage popOut = new Stage();
|
||||
Pane pane = new Pane();
|
||||
imgViewPoped.setLayoutX(0);
|
||||
imgViewPoped.setLayoutY(0);
|
||||
imgViewPoped.fitWidthProperty().bind(pane.widthProperty());
|
||||
imgViewPoped.fitHeightProperty().bind(pane.heightProperty());
|
||||
pane.getChildren().add(imgViewPoped);
|
||||
Scene scene = new Scene(pane, 1280, 900);
|
||||
popOut.setTitle(title);
|
||||
popOut.setScene(scene);
|
||||
popOut.show();
|
||||
}
|
||||
|
||||
@FXML
|
||||
void clearBttnClick(ActionEvent event) {
|
||||
tilePane.getChildren().clear();
|
||||
tilePane.getChildren().addAll(dir);
|
||||
txtDirPath.setText("");
|
||||
}
|
||||
}
|
29
Java Peojects/UDE/UDE-Desktop/src/main/java/CleanPath.java
Normal file
29
Java Peojects/UDE/UDE-Desktop/src/main/java/CleanPath.java
Normal file
@@ -0,0 +1,29 @@
|
||||
// Clear file of special characters and spaces
|
||||
|
||||
import java.io.File;
|
||||
|
||||
public class CleanPath {
|
||||
|
||||
private String preLine = "";
|
||||
|
||||
public String cleanThumbPth(String tmp) {
|
||||
File f = new File(tmp);
|
||||
|
||||
// if it's a directory, don't remove the extention
|
||||
if (f.isDirectory()) {
|
||||
System.out.println("This is a a directory.");
|
||||
}
|
||||
String name = f.getName();
|
||||
final int lastPeriodPos = name.lastIndexOf('.');
|
||||
if (lastPeriodPos <= 0) {
|
||||
preLine = "" + name;
|
||||
} else {
|
||||
// Remove the last period and everything after it
|
||||
File renamed = new File(f.getParent(), name.substring(0, lastPeriodPos));
|
||||
preLine = "" + renamed;
|
||||
preLine = preLine.replaceAll("[^A-Za-z]+", "");
|
||||
preLine = preLine.replaceAll("\\s+", "");
|
||||
}
|
||||
return preLine;
|
||||
}
|
||||
}
|
85
Java Peojects/UDE/UDE-Desktop/src/main/java/Controller.java
Normal file
85
Java Peojects/UDE/UDE-Desktop/src/main/java/Controller.java
Normal file
@@ -0,0 +1,85 @@
|
||||
|
||||
import javafx.fxml.FXML;
|
||||
import javafx.scene.layout.AnchorPane;
|
||||
import javafx.scene.image.ImageView;
|
||||
import javafx.scene.control.ContextMenu;
|
||||
import javafx.scene.input.ContextMenuEvent;
|
||||
import javafx.scene.control.MenuItem;
|
||||
import javafx.event.EventHandler;
|
||||
|
||||
public class Controller {
|
||||
// Class objects
|
||||
|
||||
private Settings settings = Settings.getInstance(); // Singleton Class settings
|
||||
|
||||
// Fxml objects
|
||||
@FXML private AnchorPane desktopArea;
|
||||
@FXML private ImageView backgroundImgView;
|
||||
|
||||
// Generics
|
||||
private int x = 0, y = 0, found = 0; // x & y for grid generation
|
||||
private boolean isMain = false;
|
||||
private ContextMenu contextMenu = new ContextMenu();
|
||||
final private MenuItem settingsMenuItm = new MenuItem("Settings"),
|
||||
chngBckgrndMenuItem = new MenuItem("Desktop Background");
|
||||
|
||||
public Controller(boolean isMain) {
|
||||
this.isMain = isMain;
|
||||
}
|
||||
|
||||
@FXML void initialize() {
|
||||
// Create ContextMenu
|
||||
settingsMenuItm.setOnAction(e -> {
|
||||
settings.showWindow();
|
||||
});
|
||||
chngBckgrndMenuItem.setOnAction(e -> {
|
||||
settings.callBackgroundMngr();
|
||||
});
|
||||
|
||||
// Add MenuItem to ContextMenu
|
||||
contextMenu.getItems().addAll(settingsMenuItm, chngBckgrndMenuItem);
|
||||
|
||||
// When user right-click on desktop
|
||||
desktopArea.setOnContextMenuRequested(new EventHandler<ContextMenuEvent>() {
|
||||
@Override
|
||||
public void handle(ContextMenuEvent event) {
|
||||
contextMenu.show(desktopArea, event.getScreenX(), event.getScreenY());
|
||||
}
|
||||
});
|
||||
|
||||
settings.setsettingsImgView(backgroundImgView);
|
||||
// backgroundImgView.setImage(settings.getBackgroundInfo());
|
||||
backgroundImgView.setFitWidth(1920); // Scale to view Note: need to do based on system parameters
|
||||
backgroundImgView.setFitHeight(1080);
|
||||
|
||||
if (isMain) {
|
||||
addIconTiles();
|
||||
}
|
||||
}
|
||||
|
||||
// set icons to desktop view
|
||||
// Possibly too many calls....
|
||||
void addIconTiles() {
|
||||
if (settings.getDesktopItems() != null) {
|
||||
for (int i = 0; i < settings.getDesktopItems().length; i++) {
|
||||
Icon icon = new Icon();
|
||||
final String fileName = "" + settings.getDesktopItems()[i].getName(),
|
||||
file = "" + settings.getDesktopItems()[i];
|
||||
|
||||
// Create Icon and position icon on grid according to parameters
|
||||
// passes desktop, path, name, index, and x and y coridinits
|
||||
icon.createIcon(desktopArea, file, fileName, i, x, y);
|
||||
desktopArea.getChildren().add(icon.getIcon());
|
||||
desktopArea.setLeftAnchor(icon.getIcon(), (double) x);
|
||||
desktopArea.setTopAnchor(icon.getIcon(), (double) y);
|
||||
|
||||
// Grid management
|
||||
x += 160;
|
||||
if (x >= 1600) {
|
||||
x = 0;
|
||||
y += 150;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
138
Java Peojects/UDE/UDE-Desktop/src/main/java/Icon.java
Normal file
138
Java Peojects/UDE/UDE-Desktop/src/main/java/Icon.java
Normal file
@@ -0,0 +1,138 @@
|
||||
|
||||
import javafx.scene.layout.AnchorPane;
|
||||
import javafx.scene.layout.VBox;
|
||||
import javafx.scene.image.Image;
|
||||
import javafx.scene.image.ImageView;
|
||||
import javafx.scene.control.Label;
|
||||
import javafx.scene.control.Tooltip;
|
||||
import javafx.scene.input.MouseEvent;
|
||||
import javafx.event.EventHandler;
|
||||
import java.util.Scanner;
|
||||
import java.io.File;
|
||||
|
||||
public class Icon {
|
||||
// Class objects
|
||||
|
||||
private Thumbnail thumbnail = new Thumbnail();
|
||||
|
||||
// Generics
|
||||
private VBox icon = new VBox();
|
||||
private Image img;
|
||||
private ImageView imgView = new ImageView();
|
||||
private Label title = new Label("");
|
||||
private Tooltip tooltip;
|
||||
private Process pb; // Process runner
|
||||
private Scanner scanner;
|
||||
private File file;
|
||||
|
||||
private String containsStr = System.getProperty("user.home") + "/Desktop/",
|
||||
toLaunch = "", runCommand = "", thumbImg = "",
|
||||
toShellOut = "", toShellExec = "", line = "",
|
||||
path = "", name = "";
|
||||
private double orgSceneX, orgSceneY, orgTranslateX, orgTranslateY;
|
||||
private double iconWidth = 150.0, iconHeight = 100.0;
|
||||
|
||||
public VBox getIcon() {
|
||||
return icon;
|
||||
}
|
||||
|
||||
public void createIcon(AnchorPane desktopArea, String pth, String nme,
|
||||
int i, int x, int y) {
|
||||
icon.getStyleClass().add("vbox");
|
||||
path = pth;
|
||||
name = nme;
|
||||
|
||||
// Creates Icon parts for desktop and sets click actions
|
||||
getIconImg();
|
||||
mergeIconParts();
|
||||
setExecuteModel();
|
||||
setIconEvents(desktopArea);
|
||||
}
|
||||
|
||||
private void getIconImg() {
|
||||
thumbnail.setIconImg(path, name);
|
||||
thumbImg = thumbnail.getIconImg();
|
||||
System.out.println("b4 insert " + thumbImg);
|
||||
|
||||
img = new Image("file:" + thumbImg);
|
||||
imgView.setImage(img);
|
||||
imgView.setFitWidth(iconWidth); // Need these here to get grid properly.
|
||||
imgView.setFitHeight(iconHeight);
|
||||
imgView.setCache(true); // Improves responsiveness when there are many images
|
||||
}
|
||||
|
||||
private void mergeIconParts() {
|
||||
title.setMaxWidth(iconWidth); // Based On Character Count??
|
||||
title.setText(name);
|
||||
tooltip = new Tooltip(name);
|
||||
tooltip.minHeight(800);
|
||||
tooltip.minWidth(800);
|
||||
Tooltip.install(icon, tooltip);
|
||||
icon.getChildren().addAll(imgView, title); // Insert image and name to icon VBox container
|
||||
}
|
||||
|
||||
private void setExecuteModel() {
|
||||
// Set file execution for .desktop files else use xdg-open
|
||||
toLaunch = path;
|
||||
if (path.contains(".desktop")) {
|
||||
file = new File(path);
|
||||
try {
|
||||
scanner = new Scanner(file);
|
||||
while (scanner.hasNext()) {
|
||||
line = scanner.nextLine();
|
||||
if (line.contains("Exec=")) {
|
||||
toShellOut = line;
|
||||
break;
|
||||
}
|
||||
}
|
||||
} catch (Throwable lineErr) {
|
||||
System.out.println("Failed To Get Exec Info: " + lineErr);
|
||||
}
|
||||
|
||||
if (toShellOut.contains("TryExec=")) {
|
||||
toShellOut = toShellOut.replaceAll("TryExec=", "");
|
||||
} else if (toShellOut.contains("Exec=")) {
|
||||
toShellOut = toShellOut.replaceAll("Exec=", "");
|
||||
}
|
||||
runCommand = toShellOut;
|
||||
} else {
|
||||
runCommand = "xdg-open " + toLaunch;
|
||||
}
|
||||
}
|
||||
|
||||
private void setIconEvents(AnchorPane desktopArea) {
|
||||
icon.addEventFilter(MouseEvent.MOUSE_PRESSED,
|
||||
new EventHandler<MouseEvent>() {
|
||||
@Override
|
||||
public void handle(MouseEvent click) {
|
||||
if (click.getClickCount() == 2) {
|
||||
click.consume();
|
||||
try {
|
||||
System.out.println(runCommand);
|
||||
pb = Runtime.getRuntime().exec(runCommand);
|
||||
} catch (Throwable imgIOErr) {
|
||||
System.out.println(imgIOErr);
|
||||
}
|
||||
} else {
|
||||
orgSceneX = click.getSceneX();
|
||||
orgSceneY = click.getSceneY();
|
||||
orgTranslateX = desktopArea.getLeftAnchor(icon);
|
||||
orgTranslateY = desktopArea.getTopAnchor(icon);
|
||||
}
|
||||
}
|
||||
});
|
||||
|
||||
icon.addEventFilter(MouseEvent.MOUSE_DRAGGED,
|
||||
new EventHandler<MouseEvent>() {
|
||||
@Override
|
||||
public void handle(MouseEvent clck) {
|
||||
double offsetX = clck.getSceneX() - orgSceneX;
|
||||
double offsetY = clck.getSceneY() - orgSceneY;
|
||||
double newTranslateX = orgTranslateX + offsetX;
|
||||
double newTranslateY = orgTranslateY + offsetY;
|
||||
desktopArea.setLeftAnchor(icon, newTranslateX);
|
||||
desktopArea.setTopAnchor(icon, newTranslateY);
|
||||
}
|
||||
});
|
||||
}
|
||||
}
|
136
Java Peojects/UDE/UDE-Desktop/src/main/java/Settings.java
Normal file
136
Java Peojects/UDE/UDE-Desktop/src/main/java/Settings.java
Normal file
@@ -0,0 +1,136 @@
|
||||
// :: NOTES ::
|
||||
// Read file for Icon= to get the desktop's icon. Then look for it in:
|
||||
// Steam --> ~/.local/share/icons/hicolor/256x256/apps/.
|
||||
// --> ~/.local/share/applications/
|
||||
// Other Icons --> /usr/share/icons/<themeName>/<size>
|
||||
|
||||
import javafx.fxml.FXMLLoader;
|
||||
import javafx.stage.Stage;
|
||||
import javafx.scene.Scene;
|
||||
import javafx.scene.image.Image;
|
||||
import javafx.scene.image.ImageView;
|
||||
import java.io.File;
|
||||
import java.util.Scanner;
|
||||
|
||||
public class Settings {
|
||||
// Class objects
|
||||
|
||||
protected final Stage settingsStage = new Stage();
|
||||
private BackgroundManager backgroundManager = BackgroundManager.getInstance(); // Singleton Class backgroundManager
|
||||
|
||||
// Generics
|
||||
protected Scene scene;
|
||||
private File thumbDirPth = new File("thumbs/"),
|
||||
desktopDir = new File(System.getProperty("user.home") + "/Desktop/"),
|
||||
highColorDir = new File(System.getProperty("user.home")
|
||||
+ "/.local/share/icons/hicolor/256x256/apps/"),
|
||||
localApplicationsDir = new File(System.getProperty("user.home")
|
||||
+ "/.local/share/applications/");
|
||||
private File[] desktopItems = desktopDir.listFiles(), // Gets files in desktop folder
|
||||
thumbsList = thumbDirPth.listFiles(), // Gets video thumbnail list
|
||||
highColorDirList = highColorDir.listFiles(),
|
||||
localApplicationsDirList = localApplicationsDir.listFiles();
|
||||
|
||||
private String imgPath, line, defaultBG = "resources/generic-theme/background.png";
|
||||
private Image backgroundImg;
|
||||
private ImageView bgView;
|
||||
private Scanner scanner;
|
||||
private File file = new File(System.getProperty("user.home") + "/ude-config.txt");
|
||||
|
||||
// Private class to generate singleton
|
||||
private static Settings settings = new Settings();
|
||||
// init
|
||||
|
||||
private Settings() {
|
||||
// Setup window
|
||||
try {
|
||||
scene = new Scene(FXMLLoader.load(Settings.class.getResource("resources/SettingsManagerWindow.fxml")), 800, 600);
|
||||
} catch (Exception e) {
|
||||
// If it fails, write the error message to screen
|
||||
e.printStackTrace();
|
||||
}
|
||||
settingsStage.setScene(scene);
|
||||
settingsStage.setTitle("Settings");
|
||||
settingsStage.setMinWidth(300);
|
||||
settingsStage.setMinHeight(300);
|
||||
|
||||
// load settings info from file by reading line by line
|
||||
if (file.exists()) {
|
||||
try {
|
||||
scanner = new Scanner(file);
|
||||
while (scanner.hasNext()) {
|
||||
line = scanner.nextLine();
|
||||
if (line.contains("Background=")) {
|
||||
line = line.replaceAll("Background=", "");
|
||||
if (line.isEmpty()) {
|
||||
backgroundImg = new Image(defaultBG);
|
||||
} else {
|
||||
backgroundImg = new Image("file://" + line);
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
} catch (Throwable lineErr) {
|
||||
backgroundImg = new Image(defaultBG);
|
||||
System.out.println("Failed To Get Config Info: " + lineErr);
|
||||
}
|
||||
} else {
|
||||
backgroundImg = new Image(defaultBG);
|
||||
System.out.println("Config file does not exist.");
|
||||
}
|
||||
}
|
||||
// Functions
|
||||
// Geters
|
||||
|
||||
public static Settings getInstance() {
|
||||
return settings;
|
||||
}
|
||||
|
||||
protected Image getBackgroundInfo() {
|
||||
return backgroundImg;
|
||||
}
|
||||
|
||||
protected String getImgPath() {
|
||||
return imgPath;
|
||||
}
|
||||
|
||||
protected File getThumbDirPth() {
|
||||
return thumbDirPth;
|
||||
}
|
||||
|
||||
protected File[] getDesktopItems() {
|
||||
return desktopItems;
|
||||
}
|
||||
|
||||
protected File[] getThumbsList() {
|
||||
return thumbsList;
|
||||
}
|
||||
|
||||
protected File[] getHighColorDirList() {
|
||||
return highColorDirList;
|
||||
}
|
||||
|
||||
protected File[] getLocalApplicationsDirList() {
|
||||
return localApplicationsDirList;
|
||||
}
|
||||
|
||||
// Setters
|
||||
protected void setsettingsImgView(ImageView imgVw) {
|
||||
bgView = imgVw;
|
||||
}
|
||||
|
||||
protected void setBackgroundInfo(String file) {
|
||||
imgPath = file;
|
||||
bgView.setImage(new Image("file://" + file));
|
||||
}
|
||||
|
||||
// Others
|
||||
protected void callBackgroundMngr() {
|
||||
showWindow();
|
||||
backgroundManager.showWindow();
|
||||
}
|
||||
|
||||
protected void showWindow() {
|
||||
settingsStage.show();
|
||||
}
|
||||
}
|
75
Java Peojects/UDE/UDE-Desktop/src/main/java/Thumbnail.java
Normal file
75
Java Peojects/UDE/UDE-Desktop/src/main/java/Thumbnail.java
Normal file
@@ -0,0 +1,75 @@
|
||||
// Generates the actual image of the icon.
|
||||
|
||||
import java.util.Scanner;
|
||||
import java.io.File;
|
||||
|
||||
public class Thumbnail {
|
||||
// Class objects
|
||||
|
||||
private Settings settings = Settings.getInstance(); // Singleton Class
|
||||
private CleanPath cleaner = new CleanPath(); // Cleans thumbnail names
|
||||
private ThumbnailGenerator vidThumbnailGen = new ThumbnailGenerator();
|
||||
|
||||
// Generics
|
||||
private Scanner scanner;
|
||||
private File file;
|
||||
private String thumbImg = "", line = "", temp = "";
|
||||
|
||||
public String getIconImg() {
|
||||
return thumbImg;
|
||||
}
|
||||
|
||||
public void setIconImg(String path, String name) {
|
||||
File[] highColorDirList = settings.getHighColorDirList();
|
||||
File[] localApplicationsDirList = settings.getLocalApplicationsDirList();
|
||||
temp = path.toLowerCase();
|
||||
|
||||
if (temp.matches("^.*?(avi|webm|mpeg|mpg|mkv|flv|wmv|mp4).*$")) {
|
||||
thumbImg = vidThumbnailGen.generateThumb(path, cleaner.cleanThumbPth(name));
|
||||
} else if (temp.matches("^.*?(png|svg|jpg|jpeg|tiff).*$")) {
|
||||
thumbImg = path;
|
||||
} else if (temp.contains(".desktop")) {
|
||||
file = new File(path);
|
||||
try {
|
||||
scanner = new Scanner(file);
|
||||
while (scanner.hasNext()) {
|
||||
line = scanner.nextLine();
|
||||
if (line.contains("Icon=")) {
|
||||
thumbImg = line;
|
||||
break;
|
||||
}
|
||||
}
|
||||
} catch (Throwable lineErr) {
|
||||
System.out.println("Failed To Get Icon: " + lineErr);
|
||||
}
|
||||
thumbImg = thumbImg.replaceAll("Icon=", ""); // Strip Icon= from the icon info
|
||||
|
||||
// Steam Icons
|
||||
if (thumbImg.contains("steam_icon")) {
|
||||
for (int i = 0; i < highColorDirList.length; i++) {
|
||||
if (highColorDirList[i].toString().contains(thumbImg)) {
|
||||
thumbImg = "" + highColorDirList[i];
|
||||
}
|
||||
}
|
||||
for (int i = 0; i < localApplicationsDirList.length; i++) {
|
||||
if (localApplicationsDirList[i].toString().contains(thumbImg)) {
|
||||
thumbImg = "" + localApplicationsDirList[i];
|
||||
}
|
||||
}
|
||||
}
|
||||
} else {
|
||||
// use getGenericIcon.py to get generic icon
|
||||
// String command = "python getGenericIcon.py " + path, shellOut = "";
|
||||
// try {
|
||||
// scanner = new Scanner(Runtime.getRuntime().exec(command).getInputStream()).useDelimiter("\\A");
|
||||
// shellOut = (scanner.hasNext()) ? scanner.next() : "";
|
||||
// scanner = new Scanner(Runtime.getRuntime().exec("readlink -f " + shellOut).getInputStream()).useDelimiter("\\A");
|
||||
// shellOut = (scanner.hasNext()) ? scanner.next() : "t";
|
||||
// } catch (Throwable e) {
|
||||
// System.out.println("Exception Caught In Thumbnail.\n" + e);
|
||||
// }
|
||||
// thumbImg = shellOut;
|
||||
thumbImg = "generic-theme/genericfile.png";
|
||||
}
|
||||
}
|
||||
}
|
@@ -0,0 +1,21 @@
|
||||
// Generate Thumbnails for videos with ffmpegthumbnailer
|
||||
|
||||
public class ThumbnailGenerator {
|
||||
|
||||
private Process pb; // Process runner
|
||||
private String thumbName, genCommand;
|
||||
|
||||
public String generateThumb(String file, String thumb) {
|
||||
thumbName = thumb;
|
||||
genCommand = "ffmpegthumbnailer -w -t='00:30:00' -c png -i "
|
||||
+ file + " -s 300 -o " + "thumbs/" + thumbName + ".png";
|
||||
try {
|
||||
pb = Runtime.getRuntime().exec(genCommand);
|
||||
pb.waitFor();
|
||||
} catch (Throwable imgIOErr) {
|
||||
System.out.println(imgIOErr);
|
||||
}
|
||||
thumbName = "./thumbs/" + thumbName + ".png";
|
||||
return thumbName;
|
||||
}
|
||||
}
|
63
Java Peojects/UDE/UDE-Desktop/src/main/java/UDEDesktop.java
Normal file
63
Java Peojects/UDE/UDE-Desktop/src/main/java/UDEDesktop.java
Normal file
@@ -0,0 +1,63 @@
|
||||
|
||||
import javafx.application.Application;
|
||||
import javafx.fxml.FXMLLoader;
|
||||
import java.awt.GraphicsDevice;
|
||||
import java.awt.GraphicsEnvironment;
|
||||
import javafx.stage.Stage;
|
||||
import javafx.stage.StageStyle;
|
||||
import javafx.scene.Scene;
|
||||
import javafx.scene.Parent;
|
||||
|
||||
|
||||
public class UDEDesktop extends Application {
|
||||
// Classes
|
||||
|
||||
// Generics
|
||||
private static final GraphicsEnvironment ge = GraphicsEnvironment.getLocalGraphicsEnvironment();
|
||||
private static final GraphicsDevice[] screens = GraphicsEnvironment.getLocalGraphicsEnvironment().getScreenDevices();
|
||||
private static boolean isMain = true;
|
||||
|
||||
@Override public void start(final Stage stg) throws Exception {
|
||||
for (int i=0; i<screens.length; i++) {
|
||||
FXMLLoader loader = new FXMLLoader(getClass().getResource("resources/UDEDesktopWindow.fxml"));
|
||||
Controller ctrllr = new Controller(isMain);
|
||||
loader.setController(ctrllr);
|
||||
Parent root = loader.load();
|
||||
Stage stage = new Stage();
|
||||
double width = (double) screens[i].getDisplayMode().getWidth();
|
||||
double height = (double) screens[i].getDisplayMode().getHeight();
|
||||
Scene scene = new Scene(root, width, height);
|
||||
scene.getStylesheets().add("resources/stylesheet.css");
|
||||
scene.setFill(null);
|
||||
// AnchorPane ap = new AnchorPane();
|
||||
// ap.setMinSize(width, height);
|
||||
// stage.initStyle(StageStyle.TRANSPARENT);
|
||||
stage.initStyle(StageStyle.UNDECORATED);
|
||||
stage.setScene(scene);
|
||||
stage.show();
|
||||
// stage.setX(screens[i].getDisplayMode().getX());
|
||||
// stage.setY(screens[i].getDisplayMode().getY());
|
||||
stage.toBack();
|
||||
isMain = false;
|
||||
}
|
||||
|
||||
|
||||
// int width = screens[0].getDisplayMode().getWidth();
|
||||
// int height = screens[0].getDisplayMode().getHeight();
|
||||
// Controller ctrl = new Controller();
|
||||
// FXMLLoader loader = new FXMLLoader(UDEDesktop.class.getResource("UDEDesktopWindow.fxml"))
|
||||
// loader.setController(mc);
|
||||
//
|
||||
// Scene scene = new Scene(, width, height);
|
||||
// scene.setFill(null);
|
||||
// scene.getStylesheets().add("stylesheet.css");
|
||||
// stage.setScene(scene);
|
||||
// stage.initStyle(StageStyle.UNDECORATED);
|
||||
// stage.setTitle("UDEDesktop");
|
||||
// stage.show();
|
||||
// stage.toBack();
|
||||
}
|
||||
|
||||
// needed because you know... it's java.
|
||||
public static void main(String[] args) { launch(args); }
|
||||
}
|
@@ -0,0 +1,39 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
|
||||
<?import javafx.geometry.Insets?>
|
||||
<?import javafx.scene.control.Button?>
|
||||
<?import javafx.scene.control.Label?>
|
||||
<?import javafx.scene.control.ScrollPane?>
|
||||
<?import javafx.scene.control.TextField?>
|
||||
<?import javafx.scene.layout.AnchorPane?>
|
||||
<?import javafx.scene.layout.HBox?>
|
||||
<?import javafx.scene.layout.TilePane?>
|
||||
<?import javafx.scene.text.Font?>
|
||||
<?scenebuilder-background-color 0x444444ff?>
|
||||
|
||||
<AnchorPane minHeight="300.0" minWidth="300.0" prefHeight="600.0" prefWidth="950.0" xmlns="http://javafx.com/javafx/8.0.60" xmlns:fx="http://javafx.com/fxml/1" fx:controller="BackgroundMngrController">
|
||||
<children>
|
||||
<HBox alignment="TOP_RIGHT" layoutY="0.0" prefHeight="21.0" prefWidth="948.0" AnchorPane.leftAnchor="1.0" AnchorPane.rightAnchor="1.0">
|
||||
<children>
|
||||
<TextField fx:id="txtDirPath" blendMode="DIFFERENCE" onKeyReleased="#onEnter" prefWidth="200.0" promptText="Dir Path" HBox.hgrow="ALWAYS" />
|
||||
<Button fx:id="clear" mnemonicParsing="false" onAction="#clearBttnClick" text="Clear" />
|
||||
</children>
|
||||
</HBox>
|
||||
<ScrollPane id="ScrollPane" minHeight="300.0" minWidth="300.0" prefHeight="547.0" prefViewportHeight="534.0" prefViewportWidth="742.0" prefWidth="770.0" style=" -fx-fit-to-height: true; -fx-fit-to-width: true;" AnchorPane.bottomAnchor="-2.0" AnchorPane.leftAnchor="0.0" AnchorPane.rightAnchor="0.0" AnchorPane.topAnchor="25.0">
|
||||
<content>
|
||||
<TilePane fx:id="tilePane" hgap="15.0" prefHeight="532.0" prefWidth="755.0" vgap="15.0">
|
||||
<children>
|
||||
<Label fx:id="dir" contentDisplay="CENTER" labelFor="$clear" onMouseClicked="#setNewDir" prefHeight="575.0" prefWidth="948.0" text="Choose Dir" textAlignment="LEFT" textFill="#dfdfdf" textOverrun="CLIP" underline="false" wrapText="false" TilePane.alignment="CENTER_LEFT">
|
||||
<font>
|
||||
<Font name="System Bold" size="32.0" />
|
||||
</font>
|
||||
<TilePane.margin>
|
||||
<Insets />
|
||||
</TilePane.margin>
|
||||
</Label>
|
||||
</children>
|
||||
</TilePane>
|
||||
</content>
|
||||
</ScrollPane>
|
||||
</children>
|
||||
</AnchorPane>
|
@@ -0,0 +1,11 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
|
||||
<?import javafx.scene.control.CheckBox?>
|
||||
<?import javafx.scene.layout.AnchorPane?>
|
||||
<?scenebuilder-background-color 0x444444ff?>
|
||||
|
||||
<AnchorPane fx:id="desktopArea" minHeight="300.0" minWidth="300.0" prefHeight="600.0" prefWidth="950.0" xmlns="http://javafx.com/javafx/8.0.60" xmlns:fx="http://javafx.com/fxml/1">
|
||||
<children>
|
||||
<CheckBox fx:id="toGridOrNaw" layoutX="85.0" layoutY="558.0" mnemonicParsing="false" text="Gridded View or Free Form View" />
|
||||
</children>
|
||||
</AnchorPane>
|
@@ -0,0 +1,16 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
|
||||
<?import javafx.geometry.Rectangle2D?>
|
||||
<?import javafx.scene.image.ImageView?>
|
||||
<?import javafx.scene.layout.AnchorPane?>
|
||||
<?scenebuilder-background-color 0x444444ff?>
|
||||
|
||||
<AnchorPane fx:id="desktopArea" minHeight="300.0" minWidth="300.0" prefHeight="600.0" prefWidth="950.0" xmlns="http://javafx.com/javafx/8.0.60" xmlns:fx="http://javafx.com/fxml/1">
|
||||
<children>
|
||||
<ImageView fx:id="backgroundImgView" fitHeight="600.0" fitWidth="950.0" mouseTransparent="true" pickOnBounds="true" preserveRatio="true" x="0.0" AnchorPane.bottomAnchor="0.0" AnchorPane.leftAnchor="0.0" AnchorPane.rightAnchor="0.0" AnchorPane.topAnchor="0.0">
|
||||
<viewport>
|
||||
<Rectangle2D />
|
||||
</viewport>
|
||||
</ImageView>
|
||||
</children>
|
||||
</AnchorPane>
|
Binary file not shown.
After Width: | Height: | Size: 4.1 KiB |
Binary file not shown.
After Width: | Height: | Size: 22 KiB |
@@ -0,0 +1,14 @@
|
||||
.root {
|
||||
/*-fx-background: rgba(68, 68, 68, 0.8); // == #444444;*/
|
||||
-fx-background: rgba(0, 0, 0, 0.0);
|
||||
}
|
||||
.button {
|
||||
}
|
||||
|
||||
.vbox {
|
||||
-fx-background-color: rgba(68, 68, 68, .5);
|
||||
}
|
||||
|
||||
.vbox:hover {
|
||||
-fx-background-color: rgba(68, 68, 68, 1)s
|
||||
}
|
@@ -0,0 +1,2 @@
|
||||
Background=
|
||||
/home/abaddon/LazyShare/Pictures/Background/Budah.jpg
|
Reference in New Issue
Block a user