File indexing completed on 2024-04-28 04:18:53
0001 /* 0002 Gwenview: an image viewer 0003 Copyright 2007 Aurélien Gâteau <agateau@kde.org> 0004 Copyright 2018 Huon Imberger <huon@plonq.org> 0005 0006 This program is free software; you can redistribute it and/or 0007 modify it under the terms of the GNU General Public License 0008 as published by the Free Software Foundation; either version 2 0009 of the License, or (at your option) any later version. 0010 0011 This program is distributed in the hope that it will be useful, 0012 but WITHOUT ANY WARRANTY; without even the implied warranty of 0013 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 0014 GNU General Public License for more details. 0015 0016 You should have received a copy of the GNU General Public License 0017 along with this program; if not, write to the Free Software 0018 Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. 0019 0020 */ 0021 0022 #include "stylesheetutils.h" 0023 0024 // Qt 0025 0026 // KF 0027 0028 // Local 0029 #include "paintutils.h" 0030 0031 namespace Gwenview 0032 { 0033 namespace StyleSheetUtils 0034 { 0035 QString rgba(const QColor &color) 0036 { 0037 return QString::fromLocal8Bit("rgba(%1, %2, %3, %4)").arg(color.red()).arg(color.green()).arg(color.blue()).arg(color.alpha()); 0038 } 0039 0040 QString gradient(Qt::Orientation orientation, const QColor &color, int value) 0041 { 0042 int x2, y2; 0043 if (orientation == Qt::Horizontal) { 0044 x2 = 0; 0045 y2 = 1; 0046 } else { 0047 x2 = 1; 0048 y2 = 0; 0049 } 0050 QString grad = QStringLiteral( 0051 "qlineargradient(x1:0, y1:0, x2:%1, y2:%2," 0052 "stop:0 %3, stop: 1 %4)"); 0053 return grad.arg(x2).arg(y2).arg(rgba(PaintUtils::adjustedHsv(color, 0, 0, qMin(255 - color.value(), value / 2))), 0054 rgba(PaintUtils::adjustedHsv(color, 0, 0, -qMin(color.value(), value / 2)))); 0055 } 0056 0057 } // namespace 0058 0059 } // namespace