@@ -2,6 +2,7 @@ import { config } from "lib/settings";
22import type { Icon } from "lib/types" ;
33import type { Binding } from "types/service" ;
44import { PopupWindow , showModal } from "window" ;
5+ import { PowerMenu } from "./power-menu" ;
56import { Sliders } from "./sliders" ;
67import { Toggles } from "./toggles" ;
78
@@ -40,6 +41,7 @@ const Button = (props: {
4041export const Quicksettings = ( ) => {
4142 // Used to take a screenshot without including the quicksettings menu.
4243 const opacity = Variable ( 1.0 ) ;
44+ const revealPowerMenu = Variable ( false ) ;
4345
4446 const top_button_battery = Button ( {
4547 icon : battery . bind ( "icon_name" ) ,
@@ -96,24 +98,12 @@ export const Quicksettings = () => {
9698 Button ( {
9799 icon : "system-shutdown-symbolic" ,
98100 async onClick ( ) {
99- App . closeWindow ( "quicksettings" ) ;
100-
101- const shutdown = await showModal ( {
102- title : "Power Off" ,
103- description : "Are you sure you want to power off the computer?" ,
104- noOption : "Cancel" ,
105- yesOption : "Power Off" ,
106- emphasize : "no" ,
107- } ) ;
108-
109- if ( shutdown ) {
110- await Utils . execAsync ( "shutdown now" ) ;
111- }
101+ revealPowerMenu . value = ! revealPowerMenu . value ;
112102 } ,
113103 } ) ,
114104 ] ;
115105
116- return PopupWindow ( {
106+ const window = PopupWindow ( {
117107 name : "quicksettings" ,
118108 location : "top-right" ,
119109 child : Widget . Box ( {
@@ -138,10 +128,22 @@ export const Quicksettings = () => {
138128 } ) ,
139129 } ) ,
140130
131+ PowerMenu ( { reveal : revealPowerMenu . bind ( ) } ) ,
132+
141133 Sliders ( ) ,
142134
143135 Toggles ( ) ,
144136 ] ,
145137 } ) ,
146138 } ) ;
139+
140+ window . hook (
141+ App ,
142+ ( ) => {
143+ revealPowerMenu . value = false ;
144+ } ,
145+ "window-toggled" ,
146+ ) ;
147+
148+ return window ;
147149} ;
0 commit comments