v27: weather flyout with sun and cloud icon, ZIP code in settings
This commit is contained in:
@@ -20,6 +20,7 @@ const (
|
||||
trayVolume
|
||||
trayWifi
|
||||
trayChevron
|
||||
trayWeather // added after the others so saved orders from older versions still mean the same thing
|
||||
)
|
||||
|
||||
const (
|
||||
@@ -41,6 +42,9 @@ const (
|
||||
menuSoundID = 23
|
||||
menuNetID = 24
|
||||
menuMuteID = 25
|
||||
|
||||
menuWeatherID = 26
|
||||
menuWeatherZipID = 27
|
||||
)
|
||||
|
||||
var (
|
||||
@@ -101,7 +105,7 @@ func trayItemsAt(x, clientH int32) []trayItem {
|
||||
continue // this PC has no battery
|
||||
}
|
||||
w = px(36)
|
||||
case trayVolume, trayWifi:
|
||||
case trayVolume, trayWifi, trayWeather:
|
||||
w = px(36)
|
||||
case trayChevron:
|
||||
w = px(28)
|
||||
@@ -290,6 +294,8 @@ func drawTray(hdc uintptr, w, h int32) {
|
||||
drawNetwork(hdc, it.r)
|
||||
case trayChevron:
|
||||
drawChevron(hdc, it.r)
|
||||
case trayWeather:
|
||||
drawWeatherIcon(hdc, it.r)
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -568,6 +574,8 @@ func trayClick(kind int) {
|
||||
tapChord(vkLWin, 'N') // notification center and calendar
|
||||
case trayBattery, trayVolume, trayWifi:
|
||||
tapChord(vkLWin, 'A') // quick settings
|
||||
case trayWeather:
|
||||
weatherToggle()
|
||||
case trayChevron:
|
||||
// If the hidden icons are already showing, a second click closes them. Sending
|
||||
// Win+B and Enter again would instead press Enter on the highlighted icon.
|
||||
@@ -650,6 +658,10 @@ func addTrayMenu(add func(flags uintptr, id uintptr, text string), sep func(), k
|
||||
add(mfGrayed, 0, networkText())
|
||||
add(0, menuNetID, "Network && internet settings")
|
||||
sep()
|
||||
case trayWeather:
|
||||
add(0, menuWeatherID, "Show weather")
|
||||
add(0, menuWeatherZipID, "Weather ZIP code...")
|
||||
sep()
|
||||
}
|
||||
}
|
||||
|
||||
@@ -664,6 +676,12 @@ func handleTrayCommand(cmd uintptr) bool {
|
||||
shellOpen("ms-settings:sound", "")
|
||||
case menuNetID:
|
||||
shellOpen("ms-settings:network", "")
|
||||
case menuWeatherID:
|
||||
if !wxShown {
|
||||
weatherToggle()
|
||||
}
|
||||
case menuWeatherZipID:
|
||||
openSettings()
|
||||
case menuAutostartID:
|
||||
setAutostart(!autostartEnabled())
|
||||
case menuMuteID:
|
||||
@@ -679,7 +697,7 @@ func handleTrayCommand(cmd uintptr) bool {
|
||||
// ---------- the right row can be rearranged too ----------
|
||||
|
||||
// trayOrder is the left to right order of the items to the right of center.
|
||||
var trayOrder = []int{trayClock, trayBattery, trayVolume, trayWifi, trayChevron}
|
||||
var trayOrder = []int{trayClock, trayWeather, trayBattery, trayVolume, trayWifi, trayChevron}
|
||||
|
||||
var (
|
||||
dragTray int // the tray item the mouse went down on, 0 for none
|
||||
@@ -698,12 +716,23 @@ func loadTrayOrder() {
|
||||
seen := map[int]bool{}
|
||||
for _, p := range strings.Split(strings.TrimSpace(string(b)), ",") {
|
||||
n, err := strconv.Atoi(strings.TrimSpace(p))
|
||||
if err != nil || n < trayClock || n > trayChevron || seen[n] {
|
||||
if err != nil || n < trayClock || n > trayWeather || seen[n] {
|
||||
return
|
||||
}
|
||||
seen[n] = true
|
||||
order = append(order, n)
|
||||
}
|
||||
// An order saved before the weather cloud existed: put the cloud next to the clock.
|
||||
if !seen[trayWeather] {
|
||||
withCloud := make([]int, 0, len(order)+1)
|
||||
for _, k := range order {
|
||||
withCloud = append(withCloud, k)
|
||||
if k == trayClock {
|
||||
withCloud = append(withCloud, trayWeather)
|
||||
}
|
||||
}
|
||||
order = withCloud
|
||||
}
|
||||
if len(order) == len(trayOrder) {
|
||||
trayOrder = order
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user