Skip to content

Commit

Permalink
(#319) Settings: add the Developer Mode
Browse files Browse the repository at this point in the history
  • Loading branch information
ForNeVeR committed Aug 31, 2024
1 parent f2bafc5 commit 3f74a43
Show file tree
Hide file tree
Showing 5 changed files with 64 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,7 @@ import com.jetbrains.rider.xaml.splitEditor.XamlSplitEditor
import com.jetbrains.rider.xaml.splitEditor.XamlSplitEditorSplitLayout
import kotlinx.coroutines.Dispatchers
import me.fornever.avaloniarider.AvaloniaRiderBundle
import me.fornever.avaloniarider.idea.editor.actions.DebugPreviewerAction
import me.fornever.avaloniarider.idea.editor.actions.RestartPreviewerAction
import me.fornever.avaloniarider.idea.editor.actions.RunnableAssemblySelectorAction
import me.fornever.avaloniarider.idea.editor.actions.TogglePreviewerLogAction
Expand Down Expand Up @@ -183,6 +184,7 @@ abstract class AvaloniaPreviewEditorBase(
add(RestartPreviewerAction(lifetime, sessionController, selectedProjectPath))
addAll(*actions)
add(TogglePreviewerLogAction(isLogManuallyVisible))
add(DebugPreviewerAction())
}

val toolbar = ActionManager.getInstance().createActionToolbar(ActionPlaces.EDITOR_TOOLBAR, actionGroup, true).apply {
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
package me.fornever.avaloniarider.idea.editor.actions

import com.intellij.openapi.actionSystem.ActionUpdateThread
import com.intellij.openapi.actionSystem.AnAction
import com.intellij.openapi.actionSystem.AnActionEvent
import me.fornever.avaloniarider.idea.settings.AvaloniaApplicationSettings

class DebugPreviewerAction : AnAction() {
override fun getActionUpdateThread() = ActionUpdateThread.BGT
override fun update(e: AnActionEvent) {
val presentation = e.presentation
if (!AvaloniaApplicationSettings.getInstance().isDeveloperModeEnabled) {
presentation.isEnabledAndVisible = false
return
}

presentation.isEnabledAndVisible = true
}

override fun actionPerformed(p0: AnActionEvent) {

}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
package me.fornever.avaloniarider.idea.settings

import com.intellij.openapi.components.BaseState
import com.intellij.openapi.components.Service
import com.intellij.openapi.components.SimplePersistentStateComponent
import com.intellij.openapi.components.State
import com.intellij.openapi.components.Storage
import com.intellij.openapi.components.service

@State(name = "AvaloniaRider", storages = [Storage("AvaloniaRider.xml")])
@Service
class AvaloniaApplicationSettings : SimplePersistentStateComponent<AvaloniaApplicationState>(
AvaloniaApplicationState()
) {
companion object {
fun getInstance(): AvaloniaApplicationSettings = service()
}

val isDeveloperModeEnabled: Boolean
get() = state.isDeveloperModeEnabled
}

class AvaloniaApplicationState : BaseState() {
var isDeveloperModeEnabled by property(false)
}
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@ import javax.swing.JList

class AvaloniaProjectSettingsConfigurable(private val project: Project) : Configurable {

private val applicationSettings by lazy { AvaloniaApplicationSettings.getInstance() }
private val projectSettings by lazy { AvaloniaProjectSettings.getInstance(project) }
private val workspaceSettings by lazy { AvaloniaWorkspaceSettings.getInstance(project) }

Expand Down Expand Up @@ -60,6 +61,16 @@ class AvaloniaProjectSettingsConfigurable(private val project: Project) : Config
}
)
}
group(AvaloniaRiderBundle.message("settings.application-wide.label")) {
row {
checkBox(AvaloniaRiderBundle.message("settings.developer-mode.label"))
.bindSelected(
{ applicationSettings.isDeveloperModeEnabled },
{ applicationSettings.state.isDeveloperModeEnabled = it }
)
.comment(AvaloniaRiderBundle.message("settings.developer-mode.comment"))
}
}
}
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,9 @@ previewer.no-output-assembly=<html><center>No build output assembly detected at
previewer.termination-message=Previewer has been terminated
previewer.error.jcef-not-supported=JCEF support is not available.

settings.application-wide.label=IDE-Wide Settings
settings.developer-mode.comment=Enables an action to debug the previewer process on the previewer toolbar.
settings.developer-mode.label=Developer mode
settings.fpsLimit=FPS limit (0 = no limit):
settings.page.name=Avalonia
settings.previewerMethod=Previewer method:
Expand Down

0 comments on commit 3f74a43

Please sign in to comment.