Skip to content

Commit f8d0f29

Browse files
committed
add setting state
1 parent b350d0a commit f8d0f29

File tree

3 files changed

+35
-3
lines changed

3 files changed

+35
-3
lines changed

src/main/kotlin/irony/pycharm/qsseditor/QSSConfigurable.kt renamed to src/main/kotlin/irony/pycharm/qsseditor/SettingsConfigurable.kt

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,10 +4,11 @@ import com.intellij.openapi.options.BoundSearchableConfigurable
44
import com.intellij.openapi.options.Configurable.NoScroll
55
import com.intellij.ui.dsl.builder.panel
66

7-
class QSSConfigurable : BoundSearchableConfigurable(
7+
class SettingsConfigurable : BoundSearchableConfigurable(
88
"QSS",
99
"QSS Editor Configurable"
1010
), NoScroll {
11+
1112
override fun createPanel() = panel {
1213
row {
1314
}
Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,29 @@
1+
package irony.pycharm.qsseditor
2+
3+
import com.intellij.openapi.application.ApplicationManager
4+
import com.intellij.openapi.components.PersistentStateComponent
5+
import com.intellij.openapi.components.State
6+
import com.intellij.openapi.components.Storage
7+
import com.intellij.util.xmlb.XmlSerializerUtil
8+
9+
@State(name = "irony.pycharm.qsseditor.SettingsState", storages = [Storage("QSSEditorSetting.xml")])
10+
internal class SettingsState : PersistentStateComponent<SettingsState> {
11+
var auto: Boolean = true
12+
var host: String = "localhost"
13+
var port: Int = 61052
14+
15+
override fun getState(): SettingsState {
16+
return this
17+
}
18+
19+
override fun loadState(state: SettingsState) {
20+
XmlSerializerUtil.copyBean(state, this)
21+
}
22+
23+
companion object {
24+
val instance: SettingsState
25+
get() = ApplicationManager.getApplication().getService(
26+
SettingsState::class.java
27+
)
28+
}
29+
}

src/main/resources/META-INF/plugin.xml

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -25,11 +25,13 @@
2525
<!-- Extension points defined by the plugin.
2626
Read more: https://plugins.jetbrains.com/docs/intellij/plugin-extension-points.html -->
2727
<extensions defaultExtensionNs="com.intellij">
28+
<applicationService
29+
serviceImplementation="irony.pycharm.qsseditor.SettingsState"/>
2830
<applicationConfigurable
2931
parentId="language"
3032
groupWeight="-500"
31-
instance="irony.pycharm.qsseditor.QSSConfigurable"
32-
id="irony.pycharm.qsseditor.QSSConfigurable"
33+
instance="irony.pycharm.qsseditor.SettingsConfigurable"
34+
id="irony.pycharm.qsseditor.SettingsConfigurable"
3335
displayName="QSS"/>
3436
</extensions>
3537
<actions>

0 commit comments

Comments
 (0)