File indexing completed on 2024-04-28 16:55:15
0001 /*************************************************************************** 0002 * Copyright (C) 2014 by Nikita Skovoroda <chalkerx@gmail.com> * 0003 * * 0004 * This program is free software; you can redistribute it and/or modify * 0005 * it under the terms of the GNU General Public License as published by * 0006 * the Free Software Foundation; either version 2 of the License, or * 0007 * (at your option) any later version. * 0008 * * 0009 * This program is distributed in the hope that it will be useful, * 0010 * but WITHOUT ANY WARRANTY; without even the implied warranty of * 0011 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * 0012 * GNU General Public License for more details. * 0013 * * 0014 * You should have received a copy of the GNU General Public License * 0015 * along with this program; if not, write to the * 0016 * Free Software Foundation, Inc., * 0017 * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA . * 0018 ***************************************************************************/ 0019 0020 #include "powerdevilkeyboardbrightnesslogic.h" 0021 #include "powerdevil_debug.h" 0022 #include <QDebug> 0023 0024 namespace PowerDevil 0025 { 0026 0027 int KeyboardBrightnessLogic::calculateSteps(int maxValue) const 0028 { 0029 // We assume that a generally good number of steps for keyboard brightness is about 5. 0030 0031 if (maxValue <= 7) { 0032 // Too few steps, return the number of actual steps. 0033 return maxValue; 0034 } 0035 0036 if (maxValue % 5 == 0 || maxValue >= 80) { 0037 // When there are more than 80 actual steps, 20%, 40%, 60%, and 80% are always displayed nicely. 0038 return 5; 0039 } 0040 0041 if (maxValue % 4 == 0) 0042 return 4; 0043 0044 if (maxValue % 6 == 0) 0045 return 6; 0046 0047 if (maxValue % 3 == 0) 0048 return 3; 0049 0050 // 29 different maxValue values between 11 and 79 are left at this point. 0051 //qCDebug(POWERDEVIL) << "maxValue" << maxValue; 0052 0053 // Give up and return 5, there is nothing much we can do here. 0054 return 5; 0055 } 0056 0057 }