Skip to content

Commit

Permalink
bugfixes, library upgrades, library for dark mode changed
Browse files Browse the repository at this point in the history
  • Loading branch information
moritzfl committed Jul 29, 2019
1 parent 5f33406 commit 1eace4f
Show file tree
Hide file tree
Showing 4 changed files with 53 additions and 22 deletions.
21 changes: 11 additions & 10 deletions build.gradle
Original file line number Diff line number Diff line change
@@ -1,15 +1,17 @@
/*
* This file was generated by the Gradle 'init' task.
* Execute with following command to create executables: gradle build createExe dependencyUpdates -Drevision=release
*/

plugins {
id 'java'
id 'edu.sc.seis.launch4j' version '2.4.6'
id 'com.github.johnrengelman.shadow' version '5.0.0'
id 'com.github.johnrengelman.shadow' version '5.1.0'
id 'application'
id "edu.sc.seis.macAppBundle" version "2.3.0"
id "com.github.ben-manes.versions" version "0.21.0"
}


repositories {
mavenLocal()
maven {
Expand All @@ -30,19 +32,18 @@ repositories {
}

dependencies {
compile 'org.slf4j:slf4j-simple:1.7.26'
compile 'org.slf4j:slf4j-simple:2.0.0-alpha0'
compile 'javax.activation:activation:1.1.1'
compile 'com.google.code.gson:gson:2.8.5'
compile 'org.apache.pdfbox:pdfbox:2.0.15'
compile 'com.github.moritzfl:gutenberg:1.3.4'
compile 'org.apache.pdfbox:pdfbox:2.0.16'
compile 'com.github.Arnauld:gutenberg:18d761ddba'
compile 'org.scilab.forge:jlatexmath:1.0.7'
compile 'com.itextpdf:itextpdf:5.5.13'
compile 'com.itextpdf.tool:xmlworker:5.5.13'
compile 'com.itextpdf:itextpdf:5.5.13.1'
compile 'com.itextpdf.tool:xmlworker:5.5.13.1'
compile files("${projectDir}/lib/jai_core-1.1.3.jar")
compile files("${projectDir}/lib/mathocr-0.0.3.jar")
compile files("${projectDir}/lib/VAqua7.jar")
compile 'io.github.soc:directories:11'

compile 'com.bulenkov:darcula:2018.2'
}
application {
mainClassName = "${project.mainClassName}"
Expand All @@ -53,7 +54,7 @@ run {
}

group = 'com.github.moritzfl'
version = '2.2.2.0'
version = '2.2.2.1'
description = 'mathematicallatexhelper'
sourceCompatibility = JavaVersion.VERSION_1_8
targetCompatibility = JavaVersion.VERSION_1_8
Expand Down
2 changes: 1 addition & 1 deletion gradle/wrapper/gradle-wrapper.properties
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
distributionBase=GRADLE_USER_HOME
distributionPath=wrapper/dists
distributionUrl=https\://services.gradle.org/distributions/gradle-5.4.1-bin.zip
distributionUrl=https\://services.gradle.org/distributions/gradle-5.5.1-bin.zip
zipStoreBase=GRADLE_USER_HOME
zipStorePath=wrapper/dists
Binary file removed lib/VAqua7.jar
Binary file not shown.
52 changes: 41 additions & 11 deletions src/main/java/de/moritzf/latexhelper/util/GuiUtil.java
Original file line number Diff line number Diff line change
Expand Up @@ -13,11 +13,14 @@
*/
package de.moritzf.latexhelper.util;

import com.bulenkov.darcula.DarculaLaf;

import java.awt.GraphicsDevice;
import java.awt.MouseInfo;
import java.awt.Rectangle;
import java.awt.Window;

import java.io.BufferedReader;
import java.io.InputStreamReader;


import javax.swing.*;
Expand Down Expand Up @@ -57,7 +60,11 @@ public static final void centerWindow(final Window window) {
*/
public static void enableOSXFullscreen(JFrame window) {
if (OsUtil.getOperatingSystemType().equals(OsUtil.OSType.MacOS)) {
window.getRootPane().putClientProperty("apple.awt.fullscreenable", Boolean.valueOf(true));
try {
window.getRootPane().putClientProperty("apple.awt.fullscreenable", Boolean.valueOf(true));
} catch (Exception e) {
// full screen will not be available
}
}
}

Expand All @@ -69,28 +76,51 @@ public static void setSystemLookAndFeel() {
// Set System look and feel according to the current OS
try {
if (OsUtil.getOperatingSystemType().equals(OsUtil.OSType.MacOS)) {
try {
UIManager.setLookAndFeel("org.violetlib.aqua.AquaLookAndFeel");
} catch (Exception e) {
e.printStackTrace();
activateMacMenu();
if (isDarkModeActive()) {
UIManager.setLookAndFeel(new DarculaLaf());
} else {
UIManager.setLookAndFeel(UIManager.getSystemLookAndFeelClassName());
}
activateMacMenu();
} else {
UIManager.setLookAndFeel(UIManager.getSystemLookAndFeelClassName());
}

} catch (Exception e) {
//no "system like" style will be available
e.printStackTrace();
// No System look and feel will be available
}
}

/**
* Activate mac menu. This enables the native mac menu bar instead of the "Windows-like" menu inside of frames.
*/
private static void activateMacMenu() {
System.setProperty("apple.laf.useScreenMenuBar", "true");
try {
System.setProperty("apple.laf.useScreenMenuBar", "true");
} catch (Exception e) {
// No screen menu bar will be available.
}
}

public static boolean isDarkModeActive() {
//defaults read -g AppleInterfaceStyle
if (OsUtil.getOperatingSystemType().equals(OsUtil.OSType.MacOS)) {
try {
String cmd = "defaults read -g AppleInterfaceStyle";
Process p = Runtime.getRuntime().exec(cmd);
p.waitFor();
BufferedReader reader = new BufferedReader(new InputStreamReader(p.getInputStream()));
String completeText = "";
String line;
while ((line = reader.readLine()) != null) {
completeText += line;
}
return completeText.equalsIgnoreCase("Dark");
} catch (Exception e) {
return false;
}
} else {
return false;
}
}


Expand Down

0 comments on commit 1eace4f

Please sign in to comment.