mirror of
https://github.com/TermoraDev/termora.git
synced 2026-01-16 02:12:58 +08:00
chore: improve settings action
This commit is contained in:
@@ -1,9 +1,6 @@
|
|||||||
package app.termora.actions
|
package app.termora.actions
|
||||||
|
|
||||||
import app.termora.ApplicationScope
|
import app.termora.*
|
||||||
import app.termora.I18n
|
|
||||||
import app.termora.Icons
|
|
||||||
import app.termora.SettingsDialog
|
|
||||||
import com.formdev.flatlaf.extras.FlatDesktop
|
import com.formdev.flatlaf.extras.FlatDesktop
|
||||||
import org.apache.commons.lang3.StringUtils
|
import org.apache.commons.lang3.StringUtils
|
||||||
import java.awt.KeyboardFocusManager
|
import java.awt.KeyboardFocusManager
|
||||||
@@ -32,13 +29,13 @@ class SettingsAction private constructor() : AnAction(
|
|||||||
private val action get() = this
|
private val action get() = this
|
||||||
|
|
||||||
init {
|
init {
|
||||||
FlatDesktop.setPreferencesHandler {
|
FlatDesktop.setPreferencesHandler(object : Runnable {
|
||||||
val owner = KeyboardFocusManager.getCurrentKeyboardFocusManager().focusOwner
|
override fun run() {
|
||||||
// Doorman 的情况下不允许打开
|
val focusedWindow = KeyboardFocusManager.getCurrentKeyboardFocusManager().focusedWindow ?: return
|
||||||
if (owner != null && ApplicationScope.windowScopes().isNotEmpty()) {
|
if (focusedWindow !is TermoraFrame) return
|
||||||
actionPerformed(ActionEvent(owner, ActionEvent.ACTION_PERFORMED, StringUtils.EMPTY))
|
actionPerformed(ActionEvent(focusedWindow, ActionEvent.ACTION_PERFORMED, StringUtils.EMPTY))
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
override fun actionPerformed(evt: AnActionEvent) {
|
override fun actionPerformed(evt: AnActionEvent) {
|
||||||
|
|||||||
Reference in New Issue
Block a user