Skip to content

Commit

Permalink
feat: show models submenu on hover (#681)
Browse files Browse the repository at this point in the history
  • Loading branch information
carlrobertoh committed Sep 23, 2024
1 parent a360cb7 commit 35e7ca8
Showing 1 changed file with 13 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -13,12 +13,15 @@
import com.intellij.openapi.actionSystem.ActionUpdateThread;
import com.intellij.openapi.actionSystem.AnAction;
import com.intellij.openapi.actionSystem.AnActionEvent;
import com.intellij.openapi.actionSystem.DataContext;
import com.intellij.openapi.actionSystem.DefaultActionGroup;
import com.intellij.openapi.actionSystem.Presentation;
import com.intellij.openapi.actionSystem.ex.ComboBoxAction;
import com.intellij.openapi.application.ApplicationManager;
import com.intellij.openapi.project.DumbAwareAction;
import com.intellij.openapi.project.Project;
import com.intellij.openapi.ui.popup.JBPopup;
import com.intellij.openapi.ui.popup.ListPopup;
import ee.carlrobert.codegpt.CodeGPTKeys;
import ee.carlrobert.codegpt.Icons;
import ee.carlrobert.codegpt.completions.llama.LlamaModel;
Expand All @@ -41,6 +44,7 @@
import javax.swing.Icon;
import javax.swing.JComponent;
import org.jetbrains.annotations.NotNull;
import org.jetbrains.annotations.Nullable;

public class ModelComboBoxAction extends ComboBoxAction {

Expand All @@ -63,6 +67,7 @@ public ModelComboBoxAction(
this.project = project;
this.onModelChange = onModelChange;
this.availableProviders = availableProviders;
setSmallVariant(true);
updateTemplatePresentation(selectedProvider);
ApplicationManager.getApplication().getMessageBus()
.connect()
Expand All @@ -85,6 +90,14 @@ public JComponent createCustomComponent(
return button;
}

@Override
protected JBPopup createActionPopup(DefaultActionGroup group, @NotNull DataContext context,
@Nullable Runnable disposeCallback) {
ListPopup popup = (ListPopup) super.createActionPopup(group, context, disposeCallback);
popup.setShowSubmenuOnHover(true);
return popup;
}

private AnAction[] getCodeGPTModelActions(Project project, Presentation presentation) {
var userDetails = CodeGPTKeys.CODEGPT_USER_DETAILS.get(project);
return CodeGPTAvailableModels.getToolWindowModels(
Expand Down

0 comments on commit 35e7ca8

Please sign in to comment.