Skip to content

Commit 4b5b357

Browse files
committed
✨ feat(config): 增加翻译和配置页面
1 parent 53b585c commit 4b5b357

File tree

7 files changed

+66
-12
lines changed

7 files changed

+66
-12
lines changed

.gitignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@ build/
55
!**/src/test/**/build/
66

77
### IntelliJ IDEA ###
8+
.idea
89
.idea/modules.xml
910
.idea/jarRepositories.xml
1011
.idea/compiler.xml

src/main/kotlin/irony/pycharm/qsseditor/ApplyAction.kt

Lines changed: 2 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -2,15 +2,10 @@ package irony.pycharm.qsseditor
22

33
import com.intellij.openapi.actionSystem.AnAction
44
import com.intellij.openapi.actionSystem.AnActionEvent
5-
import com.intellij.openapi.actionSystem.CommonDataKeys
6-
import com.intellij.openapi.project.Project
7-
import com.intellij.openapi.ui.Messages
85

96

10-
class ApplyAction : AnAction() {
7+
class ApplyAction : AnAction(LangBundle.message("action.apply.title", "Apply Style")) {
118
override fun actionPerformed(e: AnActionEvent) {
12-
// TODO: insert action logic here
13-
val project: Project? = e.project
14-
Messages.showInfoMessage(e.getData(CommonDataKeys.PSI_ELEMENT).toString(), "Caret Parameters Inside The Editor")
9+
1510
}
1611
}
Lines changed: 35 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,35 @@
1+
package irony.pycharm.qsseditor
2+
3+
import com.intellij.DynamicBundle
4+
import org.jetbrains.annotations.Nls
5+
import org.jetbrains.annotations.NonNls
6+
import org.jetbrains.annotations.Nullable
7+
import org.jetbrains.annotations.PropertyKey
8+
import java.util.function.Supplier
9+
10+
object LangBundle {
11+
private const val BUNDLE: @NonNls String = "messages.LangBundle"
12+
private val INSTANCE = DynamicBundle(LangBundle::class.java, BUNDLE)
13+
14+
fun message(
15+
key: @PropertyKey(resourceBundle = BUNDLE) String,
16+
vararg params: Any
17+
): @Nls String {
18+
return INSTANCE.messageOrDefault(key, key, *params)
19+
}
20+
21+
fun message(
22+
key: @PropertyKey(resourceBundle = BUNDLE) String,
23+
@Nullable @Nls defaultValue: String,
24+
vararg params: Any
25+
): @Nls String {
26+
return INSTANCE.messageOrDefault(key, defaultValue, *params)
27+
}
28+
29+
fun lazyMessage(
30+
@PropertyKey(resourceBundle = BUNDLE) key: String,
31+
vararg params: Any
32+
): Supplier<@Nls String> {
33+
return INSTANCE.getLazyMessage(key, *params)
34+
}
35+
}

src/main/kotlin/irony/pycharm/qsseditor/SettingsConfigurable.kt

Lines changed: 17 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -2,15 +2,28 @@ package irony.pycharm.qsseditor
22

33
import com.intellij.openapi.options.BoundSearchableConfigurable
44
import com.intellij.openapi.options.Configurable.NoScroll
5+
import com.intellij.openapi.ui.DialogPanel
6+
import com.intellij.ui.dsl.builder.bindIntText
7+
import com.intellij.ui.dsl.builder.bindSelected
8+
import com.intellij.ui.dsl.builder.bindText
59
import com.intellij.ui.dsl.builder.panel
610

711
class SettingsConfigurable : BoundSearchableConfigurable(
8-
"QSS",
9-
"QSS Editor Configurable"
12+
"QSS Editor",
13+
LangBundle.message("setting.topic.title", "QSS Editor Configurable")
1014
), NoScroll {
1115

12-
override fun createPanel() = panel {
13-
row {
16+
override fun createPanel() : DialogPanel {
17+
return panel {
18+
row(LangBundle.message("setting.host.title", "Host")) {
19+
textField().bindText(SettingsState.instance::host)
20+
}
21+
row(LangBundle.message("setting.port.title", "Port")) {
22+
textField().bindIntText(SettingsState.instance::port)
23+
}
24+
row(LangBundle.message("setting.auto.title","Auto Apply")) {
25+
checkBox("").bindSelected(SettingsState.instance::auto)
26+
}
1427
}
1528
}
1629
}

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -35,7 +35,7 @@
3535
displayName="QSS"/>
3636
</extensions>
3737
<actions>
38-
<action id="ApplyAction" class="irony.pycharm.qsseditor.ApplyAction" text="Apply Style" description="Apply Style">
38+
<action id="ApplyAction" class="irony.pycharm.qsseditor.ApplyAction">
3939
<add-to-group group-id="EditorPopupMenu" anchor="first"/>
4040
</action>
4141
</actions>
Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
action.apply.title=Apply Style
2+
setting.topic.title=QSS Editor Configurable
3+
setting.auto.title=Auto Apply
4+
setting.host.title=Host
5+
setting.port.title=Port
Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
action.apply.title=应用样式
2+
setting.topic.title=QSS 编辑器配置
3+
setting.auto.title=自动应用
4+
setting.host.title=地址
5+
setting.port.title=端口

0 commit comments

Comments
 (0)