diff src/name/blackcap/clipman/Main.kt @ 41:33fbe3a78d84

Got the settings stuff compiling (untested).
author David Barts <n5jrn@me.com>
date Sat, 08 Feb 2020 22:10:01 -0700
parents 5f8475b37e23
children 339e2da5bf83
line wrap: on
line diff
--- a/src/name/blackcap/clipman/Main.kt	Wed Feb 05 16:47:25 2020 -0800
+++ b/src/name/blackcap/clipman/Main.kt	Sat Feb 08 22:10:01 2020 -0700
@@ -18,6 +18,7 @@
 import javax.swing.*
 import javax.swing.text.html.StyleSheet
 import kotlin.concurrent.thread
+import kotlin.math.roundToInt
 import org.jsoup.Jsoup
 import org.jsoup.nodes.*
 
@@ -75,7 +76,7 @@
                         PasteboardItemView("Plain text", ClipText(contents).apply {
                             contentType = "text/plain"
                             text = plain
-                            font = Font(Font.MONOSPACED, Font.PLAIN, MONO_SIZE)
+                            font = Font(settingsDialog.mFamily, Font.PLAIN, settingsDialog.mSize.roundToInt())
                             resize()
                         })
                     } else {
@@ -108,8 +109,10 @@
 
     private fun preproc(html: String): Pair<String, StyleSheet> {
         val sty = StyleSheet().apply {
-            addRule("body { font-family: serif; font-size: ${PROP_SIZE}; }")
-            addRule("code, kbd, pre, samp, tt { font-family: monospace; font-size: ${MONO_SIZE}; }")
+            addRule("body { font-family: \"%s\"; font-size: %.2f; }".format(
+                settingsDialog.pFamily, settingsDialog.pSize))
+            addRule("code, kbd, pre, samp, tt { font-family: \"%s\"; font-size: %.2f}; }".format(
+                settingsDialog.mFamily, settingsDialog.mSize))
         }
         val scrubbed = Jsoup.parse(html).run {
             select("style").forEach {
@@ -190,7 +193,8 @@
             setVisible(true)
             addWindowListener(KillIt())
         }
+        setMacMenus()
     }
-    queue.v = PasteboardQueue(con, 10)
+    queue.v = PasteboardQueue(con, settingsDialog.qLength)
     UpdateIt(1000).apply { start() }
 }