Remove RC menu from uninstalled plugins

This commit is contained in:
downthecrop 2025-09-18 21:21:30 -07:00
parent c74e5f2a4d
commit 5dd299ecdd
2 changed files with 33 additions and 11 deletions

View file

@ -32,6 +32,19 @@ class CustomSearchField(private val parentPanel: JPanel, private val onSearch: (
}
}
// Method to set the text programmatically
fun setText(newText: String) {
text = newText
SwingUtilities.invokeLater {
repaint()
}
}
// Method to get the current text
fun getText(): String {
return text
}
init {
preferredSize = Dimension(230, 30) // SEARCH_FIELD_DIMENSION
background = WIDGET_COLOR // COLOR_BACKGROUND_DARK

View file

@ -55,6 +55,9 @@ object ReflectiveEditorView : View {
// Store the cog icon to be reused
private var cogIcon: Icon? = null
// Store reference to the search field
private var searchField: CustomSearchField? = null
private fun loadCogIcon() {
try {
val imageStream = this::class.java.getResourceAsStream("res/cog.png")
@ -144,6 +147,12 @@ object ReflectiveEditorView : View {
addPlugins(reflectiveEditorView!!)
}
}
// Store reference to the search field
this.searchField = searchField
// Restore the search text if it exists
if (pluginSearchText.isNotBlank()) {
searchField.setText(pluginSearchText)
}
val searchFieldWrapperPanel = JPanel().apply {
layout = BoxLayout(this, BoxLayout.X_AXIS)
@ -438,7 +447,7 @@ object ReflectiveEditorView : View {
nameLabel.foreground = secondaryColor
nameLabel.font = Font("RuneScape Small", Font.PLAIN, 16)
// Download button (placeholder for now)
// Download button
val downloadButton = JButton("Download")
downloadButton.background = TITLE_BAR_COLOR
downloadButton.foreground = secondaryColor
@ -448,11 +457,6 @@ object ReflectiveEditorView : View {
showToast(mainPanel, "Download functionality not yet implemented", JOptionPane.INFORMATION_MESSAGE)
}
// Plugin toggle switch (iOS style) - initially off for GitLab plugins
val toggleSwitch = ToggleSwitch()
toggleSwitch.setActivated(false)
toggleSwitch.isEnabled = false // Disable toggle for GitLab plugins until downloaded
// Layout
val infoPanel = JPanel(BorderLayout())
infoPanel.background = WIDGET_COLOR
@ -461,7 +465,6 @@ object ReflectiveEditorView : View {
val controlsPanel = JPanel(FlowLayout(FlowLayout.RIGHT, 5, 0))
controlsPanel.background = WIDGET_COLOR
controlsPanel.add(downloadButton)
controlsPanel.add(toggleSwitch)
panel.add(infoPanel, BorderLayout.CENTER)
panel.add(controlsPanel, BorderLayout.EAST)
@ -527,6 +530,9 @@ object ReflectiveEditorView : View {
// Reset for now since functionality not implemented
toggleSwitch.setActivated(true)
}
} else {
// Hide the toggle switch for non-installed plugins
toggleSwitch.isVisible = false
}
// Layout
@ -538,14 +544,17 @@ object ReflectiveEditorView : View {
controlsPanel.background = WIDGET_COLOR
controlsPanel.add(actionButton)
controlsPanel.add(progressBar)
controlsPanel.add(toggleSwitch)
// Only add toggle switch if it's visible
if (toggleSwitch.isVisible) {
controlsPanel.add(toggleSwitch)
}
panel.add(infoPanel, BorderLayout.CENTER)
panel.add(controlsPanel, BorderLayout.EAST)
// Add right-click context menu (except for KondoKit itself)
if (pluginStatus.name != "KondoKit") {
val popupMenu = createPluginContextMenu(null, null, pluginStatus.name, false)
// Add right-click context menu only for installed plugins (except for KondoKit itself)
if (pluginStatus.name != "KondoKit" && pluginStatus.isInstalled) {
val popupMenu = createPluginContextMenu(null, null, pluginStatus.name, !pluginStatus.needsUpdate)
addContextMenuToPanel(panel, popupMenu)
}