mirror of https://github.com/zlatinb/muwire
preserve initial font+size+style accross restarts
parent
af218a369c
commit
274edcc599
|
@ -124,7 +124,7 @@ class Initialize extends AbstractLifecycleHandler {
|
||||||
uiSettings.lnf = lnf.getID()
|
uiSettings.lnf = lnf.getID()
|
||||||
}
|
}
|
||||||
|
|
||||||
if (uiSettings.font != null || uiSettings.autoFontSize || uiSettings.fontSize > 0) {
|
if (uiSettings.font != null || uiSettings.autoFontSize || uiSettings.fontSize > 0 ) {
|
||||||
|
|
||||||
FontUIResource defaultFont = lnf.getDefaults().getFont("Label.font")
|
FontUIResource defaultFont = lnf.getDefaults().getFont("Label.font")
|
||||||
|
|
||||||
|
@ -142,7 +142,7 @@ class Initialize extends AbstractLifecycleHandler {
|
||||||
fontSize = uiSettings.fontSize
|
fontSize = uiSettings.fontSize
|
||||||
}
|
}
|
||||||
rowHeight = fontSize + 3
|
rowHeight = fontSize + 3
|
||||||
FontUIResource font = new FontUIResource(fontName, Font.PLAIN, fontSize)
|
FontUIResource font = new FontUIResource(fontName, uiSettings.fontStyle, fontSize)
|
||||||
|
|
||||||
def keys = lnf.getDefaults().keys()
|
def keys = lnf.getDefaults().keys()
|
||||||
while(keys.hasMoreElements()) {
|
while(keys.hasMoreElements()) {
|
||||||
|
@ -158,21 +158,23 @@ class Initialize extends AbstractLifecycleHandler {
|
||||||
Properties props = new Properties()
|
Properties props = new Properties()
|
||||||
uiSettings = new UISettings(props)
|
uiSettings = new UISettings(props)
|
||||||
log.info "will try default lnfs"
|
log.info "will try default lnfs"
|
||||||
|
LookAndFeel chosen
|
||||||
if (isMacOSX()) {
|
if (isMacOSX()) {
|
||||||
if (SystemVersion.isJava9()) {
|
|
||||||
uiSettings.lnf = "metal"
|
uiSettings.lnf = "metal"
|
||||||
lookAndFeel("metal")
|
chosen = lookAndFeel("metal")
|
||||||
} else {
|
|
||||||
uiSettings.lnf = "nimbus"
|
|
||||||
lookAndFeel('nimbus') // otherwise the file chooser doesn't open???
|
|
||||||
}
|
|
||||||
} else {
|
} else {
|
||||||
LookAndFeel chosen = lookAndFeel('system', 'gtk')
|
chosen = lookAndFeel('system', 'gtk')
|
||||||
if (chosen == null)
|
if (chosen == null)
|
||||||
chosen = lookAndFeel('metal')
|
chosen = lookAndFeel('metal')
|
||||||
uiSettings.lnf = chosen.getID()
|
uiSettings.lnf = chosen.getID()
|
||||||
log.info("ended up applying $chosen.name")
|
log.info("ended up applying $chosen.name")
|
||||||
}
|
}
|
||||||
|
|
||||||
|
FontUIResource defaultFont = chosen.getDefaults().getFont("Label.font")
|
||||||
|
uiSettings.font = defaultFont.getName()
|
||||||
|
uiSettings.fontSize = defaultFont.getSize()
|
||||||
|
uiSettings.fontStyle = defaultFont.getStyle()
|
||||||
|
rowHeight = uiSettings.fontSize + 3
|
||||||
}
|
}
|
||||||
|
|
||||||
application.context.put("row-height", rowHeight)
|
application.context.put("row-height", rowHeight)
|
||||||
|
|
|
@ -2,13 +2,15 @@ package com.muwire.gui
|
||||||
|
|
||||||
import com.muwire.core.util.DataUtil
|
import com.muwire.core.util.DataUtil
|
||||||
|
|
||||||
|
import java.awt.Font
|
||||||
|
|
||||||
class UISettings {
|
class UISettings {
|
||||||
|
|
||||||
String lnf
|
String lnf
|
||||||
boolean showMonitor
|
boolean showMonitor
|
||||||
String font
|
String font
|
||||||
boolean autoFontSize
|
boolean autoFontSize
|
||||||
int fontSize
|
int fontSize, fontStyle
|
||||||
boolean clearCancelledDownloads
|
boolean clearCancelledDownloads
|
||||||
boolean clearFinishedDownloads
|
boolean clearFinishedDownloads
|
||||||
boolean excludeLocalResult
|
boolean excludeLocalResult
|
||||||
|
@ -33,6 +35,7 @@ class UISettings {
|
||||||
showSearchHashes = Boolean.parseBoolean(props.getProperty("showSearchHashes","true"))
|
showSearchHashes = Boolean.parseBoolean(props.getProperty("showSearchHashes","true"))
|
||||||
autoFontSize = Boolean.parseBoolean(props.getProperty("autoFontSize","false"))
|
autoFontSize = Boolean.parseBoolean(props.getProperty("autoFontSize","false"))
|
||||||
fontSize = Integer.parseInt(props.getProperty("fontSize","12"))
|
fontSize = Integer.parseInt(props.getProperty("fontSize","12"))
|
||||||
|
fontStyle = Integer.parseInt(props.getProperty("fontStyle", String.valueOf(Font.PLAIN)))
|
||||||
closeWarning = Boolean.parseBoolean(props.getProperty("closeWarning","true"))
|
closeWarning = Boolean.parseBoolean(props.getProperty("closeWarning","true"))
|
||||||
certificateWarning = Boolean.parseBoolean(props.getProperty("certificateWarning","true"))
|
certificateWarning = Boolean.parseBoolean(props.getProperty("certificateWarning","true"))
|
||||||
exitOnClose = Boolean.parseBoolean(props.getProperty("exitOnClose","false"))
|
exitOnClose = Boolean.parseBoolean(props.getProperty("exitOnClose","false"))
|
||||||
|
@ -62,6 +65,7 @@ class UISettings {
|
||||||
props.setProperty("storeSearchHistory", String.valueOf(storeSearchHistory))
|
props.setProperty("storeSearchHistory", String.valueOf(storeSearchHistory))
|
||||||
props.setProperty("groupByFile", String.valueOf(groupByFile))
|
props.setProperty("groupByFile", String.valueOf(groupByFile))
|
||||||
props.setProperty("maxChatLines", String.valueOf(maxChatLines))
|
props.setProperty("maxChatLines", String.valueOf(maxChatLines))
|
||||||
|
props.setProperty("fontStyle", String.valueOf(fontStyle))
|
||||||
if (font != null)
|
if (font != null)
|
||||||
props.setProperty("font", font)
|
props.setProperty("font", font)
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue