mirror of
https://github.com/TermoraDev/termora.git
synced 2026-01-16 02:12:58 +08:00
chore: show close button
This commit is contained in:
@@ -9,6 +9,12 @@ import java.awt.Window
|
|||||||
object NativeMacLibrary {
|
object NativeMacLibrary {
|
||||||
private val log = LoggerFactory.getLogger(NativeMacLibrary::class.java)
|
private val log = LoggerFactory.getLogger(NativeMacLibrary::class.java)
|
||||||
|
|
||||||
|
enum class NSWindowButton {
|
||||||
|
NSWindowCloseButton,
|
||||||
|
NSWindowMiniaturizeButton,
|
||||||
|
NSWindowZoomButton,
|
||||||
|
}
|
||||||
|
|
||||||
fun getNSWindow(window: Window): Long? {
|
fun getNSWindow(window: Window): Long? {
|
||||||
try {
|
try {
|
||||||
val peerField = Component::class.java.getDeclaredField("peer") ?: return null
|
val peerField = Component::class.java.getDeclaredField("peer") ?: return null
|
||||||
@@ -31,13 +37,17 @@ object NativeMacLibrary {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
fun setControlsVisible(window: Window, visible: Boolean) {
|
fun setControlsVisible(
|
||||||
|
window: Window,
|
||||||
|
visible: Boolean,
|
||||||
|
buttons: Array<NSWindowButton> = NSWindowButton.entries.toTypedArray()
|
||||||
|
) {
|
||||||
val nsWindow = ID(getNSWindow(window) ?: return)
|
val nsWindow = ID(getNSWindow(window) ?: return)
|
||||||
try {
|
try {
|
||||||
Foundation.executeOnMainThread(true, true) {
|
Foundation.executeOnMainThread(true, true) {
|
||||||
for (i in 0..2) {
|
for (button in buttons) {
|
||||||
val button = Foundation.invoke(nsWindow, "standardWindowButton:", i)
|
val button = Foundation.invoke(nsWindow, "standardWindowButton:", button.ordinal)
|
||||||
Foundation.invoke(button, "setHidden:", !visible)
|
Foundation.invoke(button, "setHidden:", visible.not())
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
} catch (e: Exception) {
|
} catch (e: Exception) {
|
||||||
|
|||||||
@@ -2,6 +2,7 @@ package app.termora.plugin.internal.plugin
|
|||||||
|
|
||||||
import app.termora.*
|
import app.termora.*
|
||||||
import com.formdev.flatlaf.extras.components.FlatToolBar
|
import com.formdev.flatlaf.extras.components.FlatToolBar
|
||||||
|
import com.formdev.flatlaf.util.SystemInfo
|
||||||
import java.awt.BorderLayout
|
import java.awt.BorderLayout
|
||||||
import java.awt.Dimension
|
import java.awt.Dimension
|
||||||
import java.awt.Window
|
import java.awt.Window
|
||||||
@@ -22,7 +23,6 @@ internal class PluginRepositoryDialog(owner: Window) : DialogWrapper(owner) {
|
|||||||
size = Dimension(UIManager.getInt("Dialog.width") - 200, UIManager.getInt("Dialog.height") - 150)
|
size = Dimension(UIManager.getInt("Dialog.width") - 200, UIManager.getInt("Dialog.height") - 150)
|
||||||
isModal = true
|
isModal = true
|
||||||
isResizable = false
|
isResizable = false
|
||||||
controlsVisible = false
|
|
||||||
title = "Custom Plugin Repository"
|
title = "Custom Plugin Repository"
|
||||||
list.fixedCellHeight = UIManager.getInt("Tree.rowHeight")
|
list.fixedCellHeight = UIManager.getInt("Tree.rowHeight")
|
||||||
for (url in PluginRepositoryManager.getInstance().getRepositories()) {
|
for (url in PluginRepositoryManager.getInstance().getRepositories()) {
|
||||||
@@ -98,6 +98,21 @@ internal class PluginRepositoryDialog(owner: Window) : DialogWrapper(owner) {
|
|||||||
return panel
|
return panel
|
||||||
}
|
}
|
||||||
|
|
||||||
|
override fun addNotify() {
|
||||||
|
super.addNotify()
|
||||||
|
|
||||||
|
if (SystemInfo.isMacOS) {
|
||||||
|
NativeMacLibrary.setControlsVisible(
|
||||||
|
this,
|
||||||
|
false,
|
||||||
|
arrayOf(
|
||||||
|
NativeMacLibrary.NSWindowButton.NSWindowZoomButton,
|
||||||
|
NativeMacLibrary.NSWindowButton.NSWindowMiniaturizeButton
|
||||||
|
)
|
||||||
|
)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
override fun createSouthPanel(): JComponent? {
|
override fun createSouthPanel(): JComponent? {
|
||||||
return null
|
return null
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user