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 {
|
||||
private val log = LoggerFactory.getLogger(NativeMacLibrary::class.java)
|
||||
|
||||
enum class NSWindowButton {
|
||||
NSWindowCloseButton,
|
||||
NSWindowMiniaturizeButton,
|
||||
NSWindowZoomButton,
|
||||
}
|
||||
|
||||
fun getNSWindow(window: Window): Long? {
|
||||
try {
|
||||
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)
|
||||
try {
|
||||
Foundation.executeOnMainThread(true, true) {
|
||||
for (i in 0..2) {
|
||||
val button = Foundation.invoke(nsWindow, "standardWindowButton:", i)
|
||||
Foundation.invoke(button, "setHidden:", !visible)
|
||||
for (button in buttons) {
|
||||
val button = Foundation.invoke(nsWindow, "standardWindowButton:", button.ordinal)
|
||||
Foundation.invoke(button, "setHidden:", visible.not())
|
||||
}
|
||||
}
|
||||
} catch (e: Exception) {
|
||||
|
||||
@@ -2,6 +2,7 @@ package app.termora.plugin.internal.plugin
|
||||
|
||||
import app.termora.*
|
||||
import com.formdev.flatlaf.extras.components.FlatToolBar
|
||||
import com.formdev.flatlaf.util.SystemInfo
|
||||
import java.awt.BorderLayout
|
||||
import java.awt.Dimension
|
||||
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)
|
||||
isModal = true
|
||||
isResizable = false
|
||||
controlsVisible = false
|
||||
title = "Custom Plugin Repository"
|
||||
list.fixedCellHeight = UIManager.getInt("Tree.rowHeight")
|
||||
for (url in PluginRepositoryManager.getInstance().getRepositories()) {
|
||||
@@ -98,6 +98,21 @@ internal class PluginRepositoryDialog(owner: Window) : DialogWrapper(owner) {
|
||||
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? {
|
||||
return null
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user