File indexing completed on 2024-04-28 05:36:16
0001 /* 0002 * SPDX-FileCopyrightText: 2014 Nikita Skovoroda <chalkerx@gmail.com> 0003 * 0004 * SPDX-License-Identifier: GPL-2.0-or-later 0005 */ 0006 0007 #include "powerdevilkeyboardbrightnesslogic.h" 0008 #include "powerdevil_debug.h" 0009 #include <QDebug> 0010 0011 namespace PowerDevil 0012 { 0013 int KeyboardBrightnessLogic::calculateSteps(int maxValue) const 0014 { 0015 // We assume that a generally good number of steps for keyboard brightness is about 5. 0016 0017 if (maxValue <= 7) { 0018 // Too few steps, return the number of actual steps. 0019 return maxValue; 0020 } 0021 0022 if (maxValue % 5 == 0 || maxValue >= 80) { 0023 // When there are more than 80 actual steps, 20%, 40%, 60%, and 80% are always displayed nicely. 0024 return 5; 0025 } 0026 0027 if (maxValue % 4 == 0) 0028 return 4; 0029 0030 if (maxValue % 6 == 0) 0031 return 6; 0032 0033 if (maxValue % 3 == 0) 0034 return 3; 0035 0036 // 29 different maxValue values between 11 and 79 are left at this point. 0037 // qCDebug(POWERDEVIL) << "maxValue" << maxValue; 0038 0039 // Give up and return 5, there is nothing much we can do here. 0040 return 5; 0041 } 0042 0043 }