New UI for theme autodetection. Additional fixes.

GitOrigin-RevId: 2ceb4c28ebcfe62e23618a995ef41a1996c87795
This commit is contained in:
Kirill Kirichenko
2020-09-22 14:39:03 +00:00
committed by intellij-monorepo-bot
parent a59c48d5a6
commit f10684a78f
2 changed files with 20 additions and 2 deletions
@@ -5,6 +5,7 @@ import com.intellij.application.options.editor.CheckboxDescriptor
import com.intellij.application.options.editor.checkBox
import com.intellij.ide.GeneralSettings
import com.intellij.ide.IdeBundle.message
import com.intellij.ide.actions.QuickChangeLookAndFeel
import com.intellij.ide.ui.search.OptionDescription
import com.intellij.openapi.actionSystem.ActionManager
import com.intellij.openapi.actionSystem.ActionPlaces
@@ -93,13 +94,17 @@ internal class AppearanceConfigurable : BoundSearchableConfigurable(message("tit
blockRow {
fullRow {
label(message("combobox.look.and.feel"))
comboBox(lafManager.lafComboBoxModel, { lafManager.lookAndFeelReference }, {},
val theme = comboBox(lafManager.lafComboBoxModel,
{ lafManager.lookAndFeelReference },
{ QuickChangeLookAndFeel.switchLafAndUpdateUI(lafManager, lafManager.findLaf(it), true) },
lafManager.lookAndFeelCellRenderer).shouldUpdateLaF()
val syncCheckBox = checkBox(message("preferred.theme.autodetect.selector"),
{ lafManager.autodetect }, { lafManager.autodetect = it }).withLargeLeftGap().shouldUpdateLaF()
{ lafManager.autodetect },
{ lafManager.autodetect = it }).withLargeLeftGap().shouldUpdateLaF()
syncCheckBox.visible(lafManager.autodetectSupported)
theme.enableIf(syncCheckBox.selected.not())
component(lafManager.settingsToolbar)
.visibleIf(syncCheckBox.selected)
@@ -41,6 +41,10 @@ infix fun ComponentPredicate.or(other: ComponentPredicate): ComponentPredicate {
return OrPredicate(this, other)
}
fun ComponentPredicate.not() : ComponentPredicate {
return NotPredicate(this)
}
private class AndPredicate(private val lhs: ComponentPredicate, private val rhs: ComponentPredicate) : ComponentPredicate() {
override fun invoke(): Boolean = lhs.invoke() && rhs.invoke()
@@ -60,3 +64,12 @@ private class OrPredicate(private val lhs: ComponentPredicate, private val rhs:
rhs.addListener(andListener)
}
}
private class NotPredicate(private val that: ComponentPredicate) : ComponentPredicate() {
override fun invoke(): Boolean = !that.invoke()
override fun addListener(listener: (Boolean) -> Unit) {
val notListener: (Boolean) -> Unit = { listener(!that.invoke()) }
that.addListener(notListener)
}
}