Changeset View
Changeset View
Standalone View
Standalone View
daemon/powerdevilprofilegenerator.cpp
Show First 20 Lines • Show All 52 Lines • ▼ Show 20 Line(s) | 52 | if (group != "Activities") { | |||
---|---|---|---|---|---|
53 | profilesConfig->deleteGroup(group); | 53 | profilesConfig->deleteGroup(group); | ||
54 | } | 54 | } | ||
55 | } | 55 | } | ||
56 | 56 | | |||
57 | // Let's start: AC profile before anything else | 57 | // Let's start: AC profile before anything else | ||
58 | KConfigGroup acProfile(profilesConfig, "AC"); | 58 | KConfigGroup acProfile(profilesConfig, "AC"); | ||
59 | acProfile.writeEntry("icon", "battery-charging"); | 59 | acProfile.writeEntry("icon", "battery-charging"); | ||
60 | 60 | | |||
61 | const bool mobile = !qEnvironmentVariableIsEmpty("QT_QUICK_CONTROLS_MOBILE"); | | |||
62 | const Modes defaultPowerButtonAction = mobile ? LockScreenMode : LogoutDialogMode; | | |||
63 | | ||||
64 | // We want to dim the screen after a while, definitely | 61 | // We want to dim the screen after a while, definitely | ||
65 | { | 62 | { | ||
66 | KConfigGroup dimDisplay(&acProfile, "DimDisplay"); | 63 | KConfigGroup dimDisplay(&acProfile, "DimDisplay"); | ||
67 | dimDisplay.writeEntry< int >("idleTime", 300000); | 64 | dimDisplay.writeEntry< int >("idleTime", 300000); | ||
68 | } | 65 | } | ||
69 | // Show the dialog when power button is pressed and suspend on suspend button pressed and lid closed (if supported) | 66 | | ||
67 | auto initLid = [toRam](KConfigGroup &profile) | ||||
70 | { | 68 | { | ||
71 | KConfigGroup handleButtonEvents(&acProfile, "HandleButtonEvents"); | 69 | const bool mobile = !qEnvironmentVariableIsEmpty("QT_QUICK_CONTROLS_MOBILE"); | ||
70 | const Modes defaultPowerButtonAction = mobile ? ToRamMode : LogoutDialogMode; | ||||
72 | 71 | | |||
72 | KConfigGroup handleButtonEvents(&profile, "HandleButtonEvents"); | ||||
73 | handleButtonEvents.writeEntry< uint >("powerButtonAction", defaultPowerButtonAction); | 73 | handleButtonEvents.writeEntry< uint >("powerButtonAction", defaultPowerButtonAction); | ||
74 | 74 | handleButtonEvents.writeEntry< uint >("powerDownAction", LogoutDialogMode); | |||
75 | if (toRam) { | 75 | if (toRam) { | ||
76 | handleButtonEvents.writeEntry< uint >("lidAction", ToRamMode); | 76 | handleButtonEvents.writeEntry< uint >("lidAction", ToRamMode); | ||
77 | } else { | 77 | } else { | ||
78 | handleButtonEvents.writeEntry< uint >("lidAction", TurnOffScreenMode); | 78 | handleButtonEvents.writeEntry< uint >("lidAction", TurnOffScreenMode); | ||
79 | } | 79 | } | ||
80 | } | 80 | }; | ||
81 | | ||||
82 | // Show the dialog when power button is pressed and suspend on suspend button pressed and lid closed (if supported) | ||||
83 | initLid(acProfile); | ||||
81 | 84 | | |||
82 | // And we also want to turn off the screen after another while | 85 | // And we also want to turn off the screen after another while | ||
83 | { | 86 | { | ||
84 | KConfigGroup dpmsControl(&acProfile, "DPMSControl"); | 87 | KConfigGroup dpmsControl(&acProfile, "DPMSControl"); | ||
85 | dpmsControl.writeEntry< uint >("idleTime", 600); | 88 | dpmsControl.writeEntry< uint >("idleTime", 600); | ||
86 | } | 89 | } | ||
87 | 90 | | |||
88 | // Powersave | 91 | // Powersave | ||
89 | KConfigGroup batteryProfile(profilesConfig, "Battery"); | 92 | KConfigGroup batteryProfile(profilesConfig, "Battery"); | ||
90 | batteryProfile.writeEntry("icon", "battery-060"); | 93 | batteryProfile.writeEntry("icon", "battery-060"); | ||
91 | // We want to dim the screen after a while, definitely | 94 | // We want to dim the screen after a while, definitely | ||
92 | { | 95 | { | ||
93 | KConfigGroup dimDisplay(&batteryProfile, "DimDisplay"); | 96 | KConfigGroup dimDisplay(&batteryProfile, "DimDisplay"); | ||
94 | dimDisplay.writeEntry< int >("idleTime", 120000); | 97 | dimDisplay.writeEntry< int >("idleTime", 120000); | ||
95 | } | 98 | } | ||
96 | // Show the dialog when power button is pressed and suspend on suspend button pressed and lid closed (if supported) | 99 | // Show the dialog when power button is pressed and suspend on suspend button pressed and lid closed (if supported) | ||
97 | { | 100 | initLid(batteryProfile); | ||
98 | KConfigGroup handleButtonEvents(&batteryProfile, "HandleButtonEvents"); | 101 | | ||
99 | handleButtonEvents.writeEntry< uint >("powerButtonAction", defaultPowerButtonAction); | | |||
100 | if (toRam) { | | |||
101 | handleButtonEvents.writeEntry< uint >("lidAction", ToRamMode); | | |||
102 | } else { | | |||
103 | handleButtonEvents.writeEntry< uint >("lidAction", TurnOffScreenMode); | | |||
104 | } | | |||
105 | } | | |||
106 | // We want to turn off the screen after another while | 102 | // We want to turn off the screen after another while | ||
107 | { | 103 | { | ||
108 | KConfigGroup dpmsControl(&batteryProfile, "DPMSControl"); | 104 | KConfigGroup dpmsControl(&batteryProfile, "DPMSControl"); | ||
109 | dpmsControl.writeEntry< uint >("idleTime", 300); | 105 | dpmsControl.writeEntry< uint >("idleTime", 300); | ||
110 | } | 106 | } | ||
111 | // Last but not least, we want to suspend after a rather long period of inactivity | 107 | // Last but not least, we want to suspend after a rather long period of inactivity | ||
112 | if (toRam) { | 108 | if (toRam) { | ||
113 | KConfigGroup suspendSession(&batteryProfile, "SuspendSession"); | 109 | KConfigGroup suspendSession(&batteryProfile, "SuspendSession"); | ||
Show All 11 Lines | 119 | { | |||
125 | brightnessControl.writeEntry< int >("value", 30); | 121 | brightnessControl.writeEntry< int >("value", 30); | ||
126 | } | 122 | } | ||
127 | // We want to dim the screen after a while, definitely | 123 | // We want to dim the screen after a while, definitely | ||
128 | { | 124 | { | ||
129 | KConfigGroup dimDisplay(&lowBatteryProfile, "DimDisplay"); | 125 | KConfigGroup dimDisplay(&lowBatteryProfile, "DimDisplay"); | ||
130 | dimDisplay.writeEntry< int >("idleTime", 60000); | 126 | dimDisplay.writeEntry< int >("idleTime", 60000); | ||
131 | } | 127 | } | ||
132 | // Show the dialog when power button is pressed and suspend on suspend button pressed and lid closed (if supported) | 128 | // Show the dialog when power button is pressed and suspend on suspend button pressed and lid closed (if supported) | ||
133 | { | 129 | initLid(lowBatteryProfile); | ||
134 | KConfigGroup handleButtonEvents(&lowBatteryProfile, "HandleButtonEvents"); | 130 | | ||
135 | handleButtonEvents.writeEntry< uint >("powerButtonAction", defaultPowerButtonAction); | | |||
136 | if (toRam) { | | |||
137 | handleButtonEvents.writeEntry< uint >("lidAction", ToRamMode); | | |||
138 | } else { | | |||
139 | handleButtonEvents.writeEntry< uint >("lidAction", TurnOffScreenMode); | | |||
140 | } | | |||
141 | } | | |||
142 | // We want to turn off the screen after another while | 131 | // We want to turn off the screen after another while | ||
143 | { | 132 | { | ||
144 | KConfigGroup dpmsControl(&lowBatteryProfile, "DPMSControl"); | 133 | KConfigGroup dpmsControl(&lowBatteryProfile, "DPMSControl"); | ||
145 | dpmsControl.writeEntry< uint >("idleTime", 120); | 134 | dpmsControl.writeEntry< uint >("idleTime", 120); | ||
146 | } | 135 | } | ||
147 | // Last but not least, we want to suspend after a rather long period of inactivity | 136 | // Last but not least, we want to suspend after a rather long period of inactivity | ||
148 | if (toRam) { | 137 | if (toRam) { | ||
149 | KConfigGroup suspendSession(&lowBatteryProfile, "SuspendSession"); | 138 | KConfigGroup suspendSession(&lowBatteryProfile, "SuspendSession"); | ||
Show All 9 Lines |