Skip to content

Commit

Permalink
feat: restart popup on settings change (#1)
Browse files Browse the repository at this point in the history
Signed-off-by: Quentin Guidée <[email protected]>
  • Loading branch information
quentinguidee authored Oct 28, 2023
1 parent 2c5a4a6 commit 668b567
Showing 1 changed file with 29 additions and 0 deletions.
Original file line number Diff line number Diff line change
@@ -1,8 +1,17 @@
package com.github.catppuccin.icons.settings

import com.intellij.ide.GeneralSettings
import com.intellij.ide.IdeBundle
import com.intellij.notification.NotificationGroupManager
import com.intellij.openapi.actionSystem.ActionManager
import com.intellij.openapi.actionSystem.AnActionEvent
import com.intellij.openapi.application.ApplicationManager
import com.intellij.openapi.application.ex.ApplicationEx
import com.intellij.openapi.options.Configurable
import com.intellij.openapi.ui.Messages
import javax.swing.JComponent


class PluginSettings : Configurable {
private val panel = PluginSettingsPanel(PluginSettingsState.instance.variant)

Expand All @@ -18,9 +27,29 @@ class PluginSettings : Configurable {
override fun apply() {
val state = PluginSettingsState.instance
state.variant = panel.variant
restart()
}

override fun getDisplayName(): String {
return "Catppuccin Icons"
}

private fun restart() {
val result = if (GeneralSettings.getInstance().isConfirmExit) {
Messages.showYesNoDialog(
"The IDE needs to be restarted for the changes to take effect. Restart now?",
IdeBundle.message("dialog.title.restart.ide"),
IdeBundle.message("dialog.action.restart.yes"),
IdeBundle.message("dialog.action.restart.cancel"),
Messages.getWarningIcon()
) == Messages.YES
} else {
true
}

if (result) {
val app = ApplicationManager.getApplication() as ApplicationEx
app.restart(true)
}
}
}

0 comments on commit 668b567

Please sign in to comment.