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

Commit

Permalink
Say Hello to version 1.3
Browse files Browse the repository at this point in the history
- MainWindowController now implements IWindowController
- Added Wiki link for MetaDataToolWindow
  • Loading branch information
Stekeblad committed Nov 9, 2019
1 parent 1d24139 commit c8f6a1a
Show file tree
Hide file tree
Showing 6 changed files with 30 additions and 30 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -65,6 +65,11 @@ private void triggerController(Object controller) {
} else {
event.consume();
}

// Make sure all settings is saved on exit do not save when not needed
if (myWindowPropertyName.equals(ConfigManager.WindowPropertyNames.MAIN)) {
ConfigManager.INSTANCE.saveSettings();
}
});
cont.myInit();
}
Expand Down
46 changes: 19 additions & 27 deletions src/main/java/io/github/stekeblad/videouploader/main/Main.java
Original file line number Diff line number Diff line change
@@ -1,16 +1,17 @@
package io.github.stekeblad.videouploader.main;

import io.github.stekeblad.videouploader.jfxExtension.MyStage;
import io.github.stekeblad.videouploader.utils.AlertUtils;
import io.github.stekeblad.videouploader.utils.ConfigManager;
import io.github.stekeblad.videouploader.utils.Constants;
import io.github.stekeblad.videouploader.utils.translation.TranslationBundles;
import io.github.stekeblad.videouploader.utils.translation.Translations;
import io.github.stekeblad.videouploader.utils.translation.TranslationsManager;
import javafx.application.Application;
import javafx.fxml.FXMLLoader;
import javafx.scene.Parent;
import javafx.scene.Scene;
import javafx.stage.Stage;

import java.io.IOException;
import java.util.Locale;

/**
Expand All @@ -20,33 +21,29 @@ public class Main extends Application {

@Override
public void start(Stage primaryStage) {
FXMLLoader loader = new FXMLLoader(getClass().getResource("mainWindow.fxml"));
Parent root;
try {
root = loader.load();
loadTranslations();
} catch (Exception e) {
AlertUtils.exceptionDialog("Stekeblads Video Uploader",
"Unable to load main window, the program will exit", e);
e.printStackTrace();
AlertUtils.exceptionDialog("ERROR",
"Failed to load translations, unable to launch. Your detected language: " + Locale.getDefault(), e);
return;
}
loadTranslations();
Translations trans = TranslationsManager.getTranslation(TranslationBundles.BASE);
primaryStage.setTitle(trans.getString("app_name"));
primaryStage.setScene(new Scene(root, 900, 825));
// Register MainWindowController.onWindowClose() to be called when the close button is clicked
mainWindowController controller = loader.getController();
primaryStage.setOnCloseRequest(event -> {
if(! controller.onWindowClose()) {
// Close or not close based on return value
event.consume();
}
});
controller.myInit();
primaryStage.show();
}

private void loadTranslations() {
try {
FXMLLoader loader = new FXMLLoader(getClass().getResource("mainWindow.fxml"));
MyStage stage = new MyStage(ConfigManager.WindowPropertyNames.MAIN);
stage.makeScene(loader.load(), Constants.MAIN_WINDOW_DIMENSIONS_RESTRICTION);
stage.setTitle(trans.getString("app_name"));
stage.prepareControllerAndShow(loader.getController());
} catch (IOException e) {
AlertUtils.exceptionDialog("Stekeblads Video Uploader",
"Unable to load main window, the program will exit", e);
}
}

private void loadTranslations() throws Exception {
ConfigManager configManager = ConfigManager.INSTANCE;
configManager.configManager();
String localeString = configManager.getSelectedLanguage();
Expand All @@ -57,11 +54,6 @@ private void loadTranslations() {
locale = Locale.getDefault();
}
TranslationsManager.loadAllTranslations(locale);
} catch (Exception e) {
e.printStackTrace();
AlertUtils.exceptionDialog("ERROR",
"Failed to load a translation, unable to launch. Your detected language: " + Locale.getDefault(), e);
}
}


Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
package io.github.stekeblad.videouploader.main;

import io.github.stekeblad.videouploader.jfxExtension.IWindowController;
import io.github.stekeblad.videouploader.jfxExtension.MyStage;
import io.github.stekeblad.videouploader.utils.AlertUtils;
import io.github.stekeblad.videouploader.utils.ConfigManager;
Expand Down Expand Up @@ -46,7 +47,7 @@
import static io.github.stekeblad.videouploader.youtube.VideoInformationBase.THUMBNAIL_FILE_FORMAT;
import static javafx.scene.control.ProgressIndicator.INDETERMINATE_PROGRESS;

public class mainWindowController {
public class mainWindowController implements IWindowController {
public AnchorPane mainWindowPane;
public ToolBar toolbar;
public ListView<GridPane> listView;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -101,7 +101,7 @@ private void loadSettings() {
setIfMissing("ui_language", String.valueOf(Locale.getDefault()));

setIfMissing(WIN_SIZE + WindowPropertyNames.MAIN, "900x825");
setIfMissing(WIN_LOC + WindowPropertyNames.MAIN, "50x50");
setIfMissing(WIN_LOC + WindowPropertyNames.MAIN, "150x100");
setIfMissing(WIN_SIZE + WindowPropertyNames.PRESETS, "725x700");
setIfMissing(WIN_LOC + WindowPropertyNames.PRESETS, "150x100");
setIfMissing(WIN_SIZE + WindowPropertyNames.SETTINGS, "500x500");
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,8 @@ public class Constants {

public static final String DEFAULT_LOCALE = "default (english)";

public static final WindowDimensionsRestriction MAIN_WINDOW_DIMENSIONS_RESTRICTION =
new WindowDimensionsRestriction(800, 1500, 400, 3000);
public static final WindowDimensionsRestriction SETTINGS_WINDOW_DIMENSIONS_RESTRICTION =
new WindowDimensionsRestriction(550, 550, 450, 450);
public static final WindowDimensionsRestriction PLAYLISTS_WINDOW_DIMENSIONS_RESTRICTION =
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@ public void myInit() {
// F1 for wiki on this window
MetaDataToolWindow.getScene().setOnKeyPressed(event -> {
if (event.getCode() == KeyCode.F1) {
OpenInBrowser.openInBrowser("https://github.com/Stekeblad/Stekeblads-Video-Uploader/wiki/xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx");
OpenInBrowser.openInBrowser("https://github.com/Stekeblad/Stekeblads-Video-Uploader/wiki/Meta-Data-Tool-Window");
event.consume();
}
});
Expand Down

0 comments on commit c8f6a1a

Please sign in to comment.