Skip to content

Commit

Permalink
v3.5
Browse files Browse the repository at this point in the history
  • Loading branch information
Mararsh committed Oct 1, 2018
1 parent a8ec6ca commit 1d71d85
Show file tree
Hide file tree
Showing 31 changed files with 17,535 additions and 170 deletions.
2 changes: 1 addition & 1 deletion MyBox/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@

<groupId>mara</groupId>
<artifactId>MyBox</artifactId>
<version>3.4</version>
<version>3.5</version>
<packaging>jar</packaging>

<name>MyBox</name>
Expand Down
6 changes: 5 additions & 1 deletion MyBox/src/main/java/mara/mybox/MainApp.java
Original file line number Diff line number Diff line change
Expand Up @@ -86,7 +86,11 @@ public void handle(WindowEvent event) {
}
});
}
pane.getStylesheets().add(getClass().getResource(CommonValues.MyBoxStyle).toExternalForm());
try {
pane.getStylesheets().add(getClass().getResource(AppVaribles.currentStyle).toExternalForm());
} catch (Exception e) {
logger.error(e.toString());
}

stage.getIcons().add(CommonValues.AppIcon);
stage.setTitle(AppVaribles.getMessage("AppTitle"));
Expand Down
16 changes: 13 additions & 3 deletions MyBox/src/main/java/mara/mybox/controller/BaseController.java
Original file line number Diff line number Diff line change
Expand Up @@ -123,9 +123,7 @@ public BaseController() {
@Override
public void initialize(URL url, ResourceBundle rb) {
try {
if (thisPane != null) {
thisPane.getStylesheets().add(getClass().getResource(CommonValues.MyBoxStyle).toExternalForm());
}
setInterfaceStyle(AppVaribles.currentStyle);

myFxml = FxmlTools.getFxmlPath(url.getPath());
AppVaribles.currentController = this;
Expand Down Expand Up @@ -271,6 +269,18 @@ protected void initializeNext() {

}

public void setInterfaceStyle(String style) {
try {
if (thisPane != null) {
thisPane.getStylesheets().clear();
thisPane.getStylesheets().add(getClass().getResource(style).toExternalForm());
thisPane.getStylesheets().add(getClass().getResource(CommonValues.MyBoxStyle).toExternalForm());
}
} catch (Exception e) {
logger.error(e.toString());
}
}

@FXML
protected void selectSourceFile(ActionEvent event) {
try {
Expand Down
153 changes: 108 additions & 45 deletions MyBox/src/main/java/mara/mybox/controller/MainMenuController.java
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,6 @@
import mara.mybox.tools.FxmlTools;
import static mara.mybox.controller.BaseController.logger;
import static mara.mybox.objects.AppVaribles.getConfigValue;
import org.apache.pdfbox.io.MemoryUsageSetting;

/**
* @Author Mara
Expand All @@ -41,54 +40,59 @@ public class MainMenuController extends BaseController {
@Override
protected void initializeNext() {
try {
if (AppVaribles.CurrentBundle == CommonValues.BundleZhCN) {
chineseMenuItem.setSelected(true);
} else {
englishMenuItem.setSelected(true);
}

stopAlarmCheck.setSelected(AppVaribles.getConfigBoolean("StopAlarmsWhenExit"));

showCommentsCheck.setSelected(AppVaribles.showComments);

if (AppVaribles.alphaAsBlack) {
replaceBlackMenu.setSelected(true);
} else {
replaceWhiteMenu.setSelected(true);
}

String pm = getConfigValue("PdfMemDefault", "1GB");
switch (pm) {
case "1GB":
pdf1gbRadio.setSelected(true);
break;
case "2GB":
pdf2gbRadio.setSelected(true);
break;
case "unlimit":
pdfUnlimitRadio.setSelected(true);
break;
case "500MB":
default:
pdf500mbRadio.setSelected(true);
}

settingsMenu.setOnShowing(new EventHandler<Event>() {
@Override
public void handle(Event e) {
if (AppVaribles.alphaAsBlack) {
replaceBlackMenu.setSelected(true);
} else {
replaceWhiteMenu.setSelected(true);
}
checkAlpha();
checkPdfMem();
}
});
checkLanguage();
checkAlpha();
checkPdfMem();
stopAlarmCheck.setSelected(AppVaribles.getConfigBoolean("StopAlarmsWhenExit"));
showCommentsCheck.setSelected(AppVaribles.showComments);

} catch (Exception e) {
logger.debug(e.toString());
}
}

private void checkLanguage() {
if (AppVaribles.CurrentBundle == CommonValues.BundleZhCN) {
chineseMenuItem.setSelected(true);
} else {
englishMenuItem.setSelected(true);
}
}

private void checkAlpha() {
if (AppVaribles.alphaAsBlack) {
replaceBlackMenu.setSelected(true);
} else {
replaceWhiteMenu.setSelected(true);
}
}

private void checkPdfMem() {
String pm = getConfigValue("PdfMemDefault", "1GB");
switch (pm) {
case "1GB":
pdf1gbRadio.setSelected(true);
break;
case "2GB":
pdf2gbRadio.setSelected(true);
break;
case "Unlimit":
pdfUnlimitRadio.setSelected(true);
break;
case "500MB":
default:
pdf500mbRadio.setSelected(true);
}
}

@FXML
private void showHome(ActionEvent event) {
openStage(CommonValues.MyboxFxml, false, true);
Expand Down Expand Up @@ -131,26 +135,22 @@ private void replaceBlackAction(ActionEvent event) {

@FXML
private void PdfMem500MB(ActionEvent event) {
AppVaribles.setConfigValue("PdfMemDefault", "500MB");
AppVaribles.PdfMemUsage = MemoryUsageSetting.setupMixed(500 * 1024 * 1024, -1);
AppVaribles.setPdfMem("500MB");
}

@FXML
private void PdfMem1GB(ActionEvent event) {
AppVaribles.setConfigValue("PdfMemDefault", "1GB");
AppVaribles.PdfMemUsage = MemoryUsageSetting.setupMixed(1024 * 1024 * 1024, -1);
AppVaribles.setPdfMem("1GB");
}

@FXML
private void PdfMem2GB(ActionEvent event) {
AppVaribles.setConfigValue("PdfMemDefault", "2GB");
AppVaribles.PdfMemUsage = MemoryUsageSetting.setupMixed(2048 * 1024 * 1024, -1);
AppVaribles.setPdfMem("2GB");
}

@FXML
private void pdfMemUnlimit(ActionEvent event) {
AppVaribles.setConfigValue("PdfMemDefault", "unlimit");
AppVaribles.PdfMemUsage = MemoryUsageSetting.setupMixed(-1, -1);
AppVaribles.setPdfMem("Unlimit");
}

@FXML
Expand All @@ -171,6 +171,69 @@ private void clearSettings(ActionEvent event) {
}
}

@FXML
private void setDefaultStyle(ActionEvent event) {
setInterfaceStyle(CommonValues.DefaultStyle);
}

@FXML
private void setWhiteOnBlackStyle(ActionEvent event) {
setInterfaceStyle(CommonValues.WhiteOnBlackStyle);
}

@FXML
private void setYellowOnBlackStyle(ActionEvent event) {
setInterfaceStyle(CommonValues.YellowOnBlackStyle);
}

@FXML
private void setWhiteOnGreenStyle(ActionEvent event) {
setInterfaceStyle(CommonValues.WhiteOnGreenStyle);
}

@FXML
private void setCaspianStyle(ActionEvent event) {
setInterfaceStyle(CommonValues.caspianStyle);
}

@FXML
private void setGreenOnBlackStyle(ActionEvent event) {
setInterfaceStyle(CommonValues.GreenOnBlackStyle);
}

@FXML
private void setPinkOnBlackStyle(ActionEvent event) {
setInterfaceStyle(CommonValues.PinkOnBlackStyle);
}

@FXML
private void setBlackOnYellowStyle(ActionEvent event) {
setInterfaceStyle(CommonValues.BlackOnYellowStyle);
}

@FXML
private void setWhiteOnPurpleStyle(ActionEvent event) {
setInterfaceStyle(CommonValues.WhiteOnPurpleStyle);
}

@FXML
private void setWhiteOnBlueStyle(ActionEvent event) {
setInterfaceStyle(CommonValues.WhiteOnBlueStyle);
}

@Override
public void setInterfaceStyle(String style) {
try {
AppVaribles.currentStyle = style;
AppVaribles.setConfigValue("InterfaceStyle", AppVaribles.currentStyle);
if (parentController != null) {
parentController.setInterfaceStyle(AppVaribles.currentStyle);
}
} catch (Exception e) {
logger.error(e.toString());
}
}

@FXML
private void exit(ActionEvent event) {
// This statement is internel call to close the stage, so itself can not tigger stageClosing()
Expand Down
Loading

0 comments on commit 1d71d85

Please sign in to comment.