| 1 |
/* |
| 2 |
This source file is part of Konsole, a terminal emulator. |
| 3 |
|
| 4 |
Copyright 2007-2008 by Robert Knight <[email protected]> |
| 5 |
|
| 6 |
This program is free software; you can redistribute it and/or modify |
| 7 |
it under the terms of the GNU General Public License as published by |
| 8 |
the Free Software Foundation; either version 2 of the License, or |
| 9 |
(at your option) any later version. |
| 10 |
|
| 11 |
This program is distributed in the hope that it will be useful, |
| 12 |
but WITHOUT ANY WARRANTY; without even the implied warranty of |
| 13 |
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
| 14 |
GNU General Public License for more details. |
| 15 |
|
| 16 |
You should have received a copy of the GNU General Public License |
| 17 |
along with this program; if not, write to the Free Software |
| 18 |
Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA |
| 19 |
02110-1301 USA. |
| 20 |
*/ |
| 21 |
|
| 22 |
// Own |
| 23 |
#include "ColorScheme.h"cxx . . $ `<file>/lib/ColorScheme.h`/ |
| 24 |
#include "tools.h"cxx . . $ `<file>/lib/tools.h`/ |
| 25 |
|
| 26 |
// Qt |
| 27 |
#include <QBrush> |
| 28 |
#include <QFile> |
| 29 |
#include <QFileInfo> |
| 30 |
#include <QtDebug> |
| 31 |
#include <QSettings> |
| 32 |
#include <QDir> |
| 33 |
#include <QRegularExpression> |
| 34 |
|
| 35 |
|
| 36 |
// KDE |
| 37 |
//#include <KColorScheme> |
| 38 |
//#include <KConfig> |
| 39 |
//#include <KLocale> |
| 40 |
//#include <KDebug> |
| 41 |
//#include <KConfigGroup> |
| 42 |
//#include <KStandardDirs> |
| 43 |
|
| 44 |
using namespace Konsole; |
| 45 |
|
| 46 |
const ColorEntrycxx . . $ Konsole/ColorEntry# ColorSchemecxx . . $ Konsole/ColorScheme#::defaultTablecxx . . $ Konsole/ColorScheme#defaultTable.[TABLE_COLORScxx . . $ `lib/CharacterColor.h:103:9`!] = |
| 47 |
// The following are almost IBM standard color codes, with some slight |
| 48 |
// gamma correction for the dim colors to compensate for bright X screens. |
| 49 |
// It contains the 8 ansiterm/xterm colors in 2 intensities. |
| 50 |
{ |
| 51 |
ColorEntrycxx . . $ Konsole/ColorEntry#ColorEntry(357007224962ed03).( QColorcxx . . $ QColor#QColor(2261ffe5112eab06).(0x00,0x00,0x00), false), ColorEntrycxx . . $ Konsole/ColorEntry#ColorEntry(357007224962ed03).( |
| 52 |
QColorcxx . . $ QColor#QColor(2261ffe5112eab06).(0xFF,0xFF,0xFF), true), // Dfore, Dback |
| 53 |
ColorEntrycxx . . $ Konsole/ColorEntry#ColorEntry(357007224962ed03).( QColorcxx . . $ QColor#QColor(2261ffe5112eab06).(0x00,0x00,0x00), false), ColorEntrycxx . . $ Konsole/ColorEntry#ColorEntry(357007224962ed03).( |
| 54 |
QColorcxx . . $ QColor#QColor(2261ffe5112eab06).(0xB2,0x18,0x18), false), // Black, Red |
| 55 |
ColorEntrycxx . . $ Konsole/ColorEntry#ColorEntry(357007224962ed03).( QColorcxx . . $ QColor#QColor(2261ffe5112eab06).(0x18,0xB2,0x18), false), ColorEntrycxx . . $ Konsole/ColorEntry#ColorEntry(357007224962ed03).( |
| 56 |
QColorcxx . . $ QColor#QColor(2261ffe5112eab06).(0xB2,0x68,0x18), false), // Green, Yellow |
| 57 |
ColorEntrycxx . . $ Konsole/ColorEntry#ColorEntry(357007224962ed03).( QColorcxx . . $ QColor#QColor(2261ffe5112eab06).(0x18,0x18,0xB2), false), ColorEntrycxx . . $ Konsole/ColorEntry#ColorEntry(357007224962ed03).( |
| 58 |
QColorcxx . . $ QColor#QColor(2261ffe5112eab06).(0xB2,0x18,0xB2), false), // Blue, Magenta |
| 59 |
ColorEntrycxx . . $ Konsole/ColorEntry#ColorEntry(357007224962ed03).( QColorcxx . . $ QColor#QColor(2261ffe5112eab06).(0x18,0xB2,0xB2), false), ColorEntrycxx . . $ Konsole/ColorEntry#ColorEntry(357007224962ed03).( |
| 60 |
QColorcxx . . $ QColor#QColor(2261ffe5112eab06).(0xB2,0xB2,0xB2), false), // Cyan, White |
| 61 |
// intensive |
| 62 |
ColorEntrycxx . . $ Konsole/ColorEntry#ColorEntry(357007224962ed03).( QColorcxx . . $ QColor#QColor(2261ffe5112eab06).(0x00,0x00,0x00), false), ColorEntrycxx . . $ Konsole/ColorEntry#ColorEntry(357007224962ed03).( |
| 63 |
QColorcxx . . $ QColor#QColor(2261ffe5112eab06).(0xFF,0xFF,0xFF), true), |
| 64 |
ColorEntrycxx . . $ Konsole/ColorEntry#ColorEntry(357007224962ed03).( QColorcxx . . $ QColor#QColor(2261ffe5112eab06).(0x68,0x68,0x68), false), ColorEntrycxx . . $ Konsole/ColorEntry#ColorEntry(357007224962ed03).( |
| 65 |
QColorcxx . . $ QColor#QColor(2261ffe5112eab06).(0xFF,0x54,0x54), false), |
| 66 |
ColorEntrycxx . . $ Konsole/ColorEntry#ColorEntry(357007224962ed03).( QColorcxx . . $ QColor#QColor(2261ffe5112eab06).(0x54,0xFF,0x54), false), ColorEntrycxx . . $ Konsole/ColorEntry#ColorEntry(357007224962ed03).( |
| 67 |
QColorcxx . . $ QColor#QColor(2261ffe5112eab06).(0xFF,0xFF,0x54), false), |
| 68 |
ColorEntrycxx . . $ Konsole/ColorEntry#ColorEntry(357007224962ed03).( QColorcxx . . $ QColor#QColor(2261ffe5112eab06).(0x54,0x54,0xFF), false), ColorEntrycxx . . $ Konsole/ColorEntry#ColorEntry(357007224962ed03).( |
| 69 |
QColorcxx . . $ QColor#QColor(2261ffe5112eab06).(0xFF,0x54,0xFF), false), |
| 70 |
ColorEntrycxx . . $ Konsole/ColorEntry#ColorEntry(357007224962ed03).( QColorcxx . . $ QColor#QColor(2261ffe5112eab06).(0x54,0xFF,0xFF), false), ColorEntrycxx . . $ Konsole/ColorEntry#ColorEntry(357007224962ed03).( |
| 71 |
QColorcxx . . $ QColor#QColor(2261ffe5112eab06).(0xFF,0xFF,0xFF), false) |
| 72 |
}; |
| 73 |
|
| 74 |
const char* const ColorSchemecxx . . $ Konsole/ColorScheme#::colorNamescxx . . $ Konsole/ColorScheme#colorNames.[TABLE_COLORScxx . . $ `lib/CharacterColor.h:103:9`!] = |
| 75 |
{ |
| 76 |
"Foreground", |
| 77 |
"Background", |
| 78 |
"Color0", |
| 79 |
"Color1", |
| 80 |
"Color2", |
| 81 |
"Color3", |
| 82 |
"Color4", |
| 83 |
"Color5", |
| 84 |
"Color6", |
| 85 |
"Color7", |
| 86 |
"ForegroundIntense", |
| 87 |
"BackgroundIntense", |
| 88 |
"Color0Intense", |
| 89 |
"Color1Intense", |
| 90 |
"Color2Intense", |
| 91 |
"Color3Intense", |
| 92 |
"Color4Intense", |
| 93 |
"Color5Intense", |
| 94 |
"Color6Intense", |
| 95 |
"Color7Intense" |
| 96 |
}; |
| 97 |
// dummy silently comment out the tr_NOOP |
| 98 |
#define tr_NOOPcxx . . $ `lib/ColorScheme.cpp:98:9`! |
| 99 |
const char* const ColorSchemecxx . . $ Konsole/ColorScheme#::translatedColorNamescxx . . $ Konsole/ColorScheme#translatedColorNames.[TABLE_COLORScxx . . $ `lib/CharacterColor.h:103:9`!] = |
| 100 |
{ |
| 101 |
tr_NOOPcxx . . $ `lib/ColorScheme.cpp:98:9`!("Foreground"), |
| 102 |
tr_NOOPcxx . . $ `lib/ColorScheme.cpp:98:9`!("Background"), |
| 103 |
tr_NOOPcxx . . $ `lib/ColorScheme.cpp:98:9`!("Color 1"), |
| 104 |
tr_NOOPcxx . . $ `lib/ColorScheme.cpp:98:9`!("Color 2"), |
| 105 |
tr_NOOPcxx . . $ `lib/ColorScheme.cpp:98:9`!("Color 3"), |
| 106 |
tr_NOOPcxx . . $ `lib/ColorScheme.cpp:98:9`!("Color 4"), |
| 107 |
tr_NOOPcxx . . $ `lib/ColorScheme.cpp:98:9`!("Color 5"), |
| 108 |
tr_NOOPcxx . . $ `lib/ColorScheme.cpp:98:9`!("Color 6"), |
| 109 |
tr_NOOPcxx . . $ `lib/ColorScheme.cpp:98:9`!("Color 7"), |
| 110 |
tr_NOOPcxx . . $ `lib/ColorScheme.cpp:98:9`!("Color 8"), |
| 111 |
tr_NOOPcxx . . $ `lib/ColorScheme.cpp:98:9`!("Foreground (Intense)"), |
| 112 |
tr_NOOPcxx . . $ `lib/ColorScheme.cpp:98:9`!("Background (Intense)"), |
| 113 |
tr_NOOPcxx . . $ `lib/ColorScheme.cpp:98:9`!("Color 1 (Intense)"), |
| 114 |
tr_NOOPcxx . . $ `lib/ColorScheme.cpp:98:9`!("Color 2 (Intense)"), |
| 115 |
tr_NOOPcxx . . $ `lib/ColorScheme.cpp:98:9`!("Color 3 (Intense)"), |
| 116 |
tr_NOOPcxx . . $ `lib/ColorScheme.cpp:98:9`!("Color 4 (Intense)"), |
| 117 |
tr_NOOPcxx . . $ `lib/ColorScheme.cpp:98:9`!("Color 5 (Intense)"), |
| 118 |
tr_NOOPcxx . . $ `lib/ColorScheme.cpp:98:9`!("Color 6 (Intense)"), |
| 119 |
tr_NOOPcxx . . $ `lib/ColorScheme.cpp:98:9`!("Color 7 (Intense)"), |
| 120 |
tr_NOOPcxx . . $ `lib/ColorScheme.cpp:98:9`!("Color 8 (Intense)") |
| 121 |
}; |
| 122 |
|
| •123 |
ColorSchemecxx . . $ Konsole/ColorScheme#::ColorSchemecxx . . $ Konsole/ColorScheme#ColorScheme(749de1b6ae65bddd).(QObjectcxx . . $ QObject# *parent) : QObjectcxx . . $ QObject#QObject(749de1b6ae65bddd).(parent) |
| 124 |
{ |
| 125 |
_tablecxx . . $ Konsole/ColorScheme#_table. = nullptr; |
| 126 |
_randomTablecxx . . $ Konsole/ColorScheme#_randomTable. = nullptr; |
| 127 |
_opacitycxx . . $ Konsole/ColorScheme#_opacity. = 1.0; |
| 128 |
} |
| 129 |
ColorSchemecxx . . $ Konsole/ColorScheme#::~cxx . . $ Konsole/ColorScheme#`~ColorScheme`(ced63f7c635d850d).ColorSchemecxx . . $ Konsole/ColorScheme#() |
| 130 |
{ |
| 131 |
delete[] _tablecxx . . $ Konsole/ColorScheme#_table.; |
| 132 |
delete[] _randomTablecxx . . $ Konsole/ColorScheme#_randomTable.; |
| 133 |
} |
| 134 |
|
| 135 |
void ColorSchemecxx . . $ Konsole/ColorScheme#::setDescriptioncxx . . $ Konsole/ColorScheme#setDescription(3520e46b33348bf6).(const QStringcxx . . $ QString#& description) { _descriptioncxx . . $ Konsole/ColorScheme#_description. =cxx . . $ QString#`operator=`(b79fde0b0ce9b948). description; } |
| 136 |
QStringcxx . . $ QString# ColorSchemecxx . . $ Konsole/ColorScheme#::descriptioncxx . . $ Konsole/ColorScheme#description(6ef7b6c27b00b43d).() const { return _descriptioncxx . . $ QString#QString(132dd6869045752b).; } |
| 137 |
|
| 138 |
void ColorSchemecxx . . $ Konsole/ColorScheme#::setNamecxx . . $ Konsole/ColorScheme#setName(3520e46b33348bf6).(const QStringcxx . . $ QString#& name) { _namecxx . . $ Konsole/ColorScheme#_name. =cxx . . $ QString#`operator=`(b79fde0b0ce9b948). name; } |
| 139 |
QStringcxx . . $ QString# ColorSchemecxx . . $ Konsole/ColorScheme#::namecxx . . $ Konsole/ColorScheme#name(6ef7b6c27b00b43d).() const { return _namecxx . . $ QString#QString(132dd6869045752b).; } |
| 140 |
|
| 141 |
void ColorSchemecxx . . $ Konsole/ColorScheme#::setColorTableEntrycxx . . $ Konsole/ColorScheme#setColorTableEntry(3c6840e24643ea34).(int index , const ColorEntrycxx . . $ Konsole/ColorEntry#& entry) |
| 142 |
{ |
| 143 |
Q_ASSERTcxx . . $ `<external>/15045578679651060896/qglobal.h:859:13`!( index >= 0 && index < TABLE_COLORScxx . . $ `lib/CharacterColor.h:103:9`! ); |
| 144 |
|
| 145 |
if ( !_tablecxx . . $ Konsole/ColorScheme#_table. ) |
| 146 |
{ |
| 147 |
_tablecxx . . $ Konsole/ColorScheme#_table. = new ColorEntrycxx . . $ Konsole/ColorEntry#[TABLE_COLORScxx . . $ `lib/CharacterColor.h:103:9`!]; |
| 148 |
|
| 149 |
for (int i=0;i<TABLE_COLORScxx . . $ `lib/CharacterColor.h:103:9`!;i++) |
| 150 |
_tablecxx . . $ Konsole/ColorScheme#_table.[i] =cxx . . $ Konsole/ColorEntry#`operator=`(281706dbae4a8f9). defaultTablecxx . . $ Konsole/ColorScheme#defaultTable.[i]; |
| 151 |
} |
| 152 |
|
| 153 |
_tablecxx . . $ Konsole/ColorScheme#_table.[index] =cxx . . $ Konsole/ColorEntry#`operator=`(281706dbae4a8f9). entry; |
| 154 |
} |
| 155 |
ColorEntrycxx . . $ Konsole/ColorEntry# ColorSchemecxx . . $ Konsole/ColorScheme#::colorEntrycxx . . $ Konsole/ColorScheme#colorEntry(fa55034f524c1199).(int index , uintcxx . . $ uint# randomSeed) const |
| 156 |
{ |
| 157 |
Q_ASSERTcxx . . $ `<external>/15045578679651060896/qglobal.h:859:13`!( index >= 0 && index < TABLE_COLORScxx . . $ `lib/CharacterColor.h:103:9`! ); |
| 158 |
|
| 159 |
if ( randomSeed != 0 ) |
| 160 |
qsrandcxx . . $ qsrand(cb2f890c2fdad230).(randomSeed); |
| 161 |
|
| 162 |
ColorEntrycxx . . $ Konsole/ColorEntry# entry = colorTablecxx . . $ Konsole/ColorScheme#colorTable(ec15202fc6ea9dfb).()[index]; |
| 163 |
|
| 164 |
if ( randomSeed != 0 && |
| 165 |
_randomTablecxx . . $ Konsole/ColorScheme#_randomTable. != nullptr && |
| 166 |
!_randomTablecxx . . $ Konsole/ColorScheme#_randomTable.[index].isNullcxx . . $ Konsole/ColorScheme#RandomizationRange#isNull(50ce9a9e25b4a850).() ) |
| 167 |
{ |
| 168 |
const RandomizationRangecxx . . $ Konsole/ColorScheme#RandomizationRange#& range = _randomTablecxx . . $ Konsole/ColorScheme#_randomTable.[index]; |
| 169 |
|
| 170 |
|
| 171 |
int hueDifference = range.huecxx . . $ Konsole/ColorScheme#RandomizationRange#hue. ? (qrandcxx . . $ qrand(b126dc7c1de90089).() % range.huecxx . . $ Konsole/ColorScheme#RandomizationRange#hue.) - range.huecxx . . $ Konsole/ColorScheme#RandomizationRange#hue./2 : 0; |
| 172 |
int saturationDifference = range.saturationcxx . . $ Konsole/ColorScheme#RandomizationRange#saturation. ? (qrandcxx . . $ qrand(b126dc7c1de90089).() % range.saturationcxx . . $ Konsole/ColorScheme#RandomizationRange#saturation.) - range.saturationcxx . . $ Konsole/ColorScheme#RandomizationRange#saturation./2 : 0; |
| 173 |
int valueDifference = range.valuecxx . . $ Konsole/ColorScheme#RandomizationRange#value. ? (qrandcxx . . $ qrand(b126dc7c1de90089).() % range.valuecxx . . $ Konsole/ColorScheme#RandomizationRange#value.) - range.valuecxx . . $ Konsole/ColorScheme#RandomizationRange#value./2 : 0; |
| 174 |
|
| 175 |
QColorcxx . . $ QColor#& color = entry.colorcxx . . $ Konsole/ColorEntry#color.; |
| 176 |
|
| 177 |
int newHue = qAbscxx . . $ qAbs(6dab451e9a9cc561).( (color.huecxx . . $ QColor#hue(ea6fe5115c70a13f).() + hueDifference) % MAX_HUEcxx . . $ Konsole/ColorScheme#MAX_HUE. ); |
| 178 |
int newValue = qMincxx . . $ qMin(2a338fce5842aa6a).( qAbscxx . . $ qAbs(6dab451e9a9cc561).(color.valuecxx . . $ QColor#value(ea6fe5115c70a13f).() + valueDifference) , 255 ); |
| 179 |
int newSaturation = qMincxx . . $ qMin(2a338fce5842aa6a).( qAbscxx . . $ qAbs(6dab451e9a9cc561).(color.saturationcxx . . $ QColor#saturation(ea6fe5115c70a13f).() + saturationDifference) , 255 ); |
| 180 |
|
| 181 |
color.setHsvcxx . . $ QColor#setHsv(748afa4755bc9595).(newHue,newSaturation,newValue); |
| 182 |
} |
| 183 |
|
| 184 |
return entry; |
| 185 |
} |
| •186 |
QColorcxx . . $ QColor# ColorSchemecxx . . $ Konsole/ColorScheme#::getColorcxx . . $ Konsole/ColorScheme#getColor(579fadac8368efbd).(int index) const |
| 187 |
{ |
| 188 |
return colorEntrycxx . . $ QColor#QColor(8255ad9db0ee6797).(index).colorcxx . . $ Konsole/ColorEntry#color.; |
| 189 |
} |
| 190 |
void ColorSchemecxx . . $ Konsole/ColorScheme#::setColorcxx . . $ Konsole/ColorScheme#setColor(9df84616657c19d9).(int index, QColorcxx . . $ QColor# color) |
| 191 |
{ |
| 192 |
ColorEntrycxx . . $ Konsole/ColorEntry# colorEntry = ColorSchemecxx . . $ Konsole/ColorScheme#::colorEntrycxx . . $ Konsole/ColorScheme#colorEntry(fa55034f524c1199).(index); |
| 193 |
if (colorEntry.colorcxx . . $ Konsole/ColorEntry#color. !=cxx . . $ QColor#`operator!=`(8df5130dab4f572b). color) { |
| 194 |
colorEntry.colorcxx . . $ Konsole/ColorEntry#color. =cxx . . $ QColor#`operator=`(a3db1be773b26671). color; |
| 195 |
setColorTableEntrycxx . . $ Konsole/ColorScheme#setColorTableEntry(3c6840e24643ea34).(index, colorEntry); |
| 196 |
Q_EMITcxx . . $ `<external>/1208926524888476972/qobjectdefs.h:95:10`! colorChangedcxx . . $ Konsole/ColorScheme#colorChanged(d4f767463ce0a6b3).(index); |
| 197 |
} |
| 198 |
} |
| 199 |
void ColorSchemecxx . . $ Konsole/ColorScheme#::getColorTablecxx . . $ Konsole/ColorScheme#getColorTable(3c246d1658e3993f).(ColorEntrycxx . . $ Konsole/ColorEntry#* table , uintcxx . . $ uint# randomSeed) const |
| 200 |
{ |
| 201 |
for ( int i = 0 ; i < TABLE_COLORScxx . . $ `lib/CharacterColor.h:103:9`! ; i++ ) |
| 202 |
table[i] =cxx . . $ Konsole/ColorEntry#`operator=`(ccdfd42835551f34). colorEntrycxx . . $ Konsole/ColorScheme#colorEntry(fa55034f524c1199).(i,randomSeed); |
| 203 |
} |
| 204 |
bool ColorSchemecxx . . $ Konsole/ColorScheme#::randomizedBackgroundColorcxx . . $ Konsole/ColorScheme#randomizedBackgroundColor(50ce9a9e25b4a850).() const |
| 205 |
{ |
| 206 |
return _randomTablecxx . . $ Konsole/ColorScheme#_randomTable. == nullptr ? false : !_randomTablecxx . . $ Konsole/ColorScheme#_randomTable.[1].isNullcxx . . $ Konsole/ColorScheme#RandomizationRange#isNull(50ce9a9e25b4a850).(); |
| 207 |
} |
| 208 |
void ColorSchemecxx . . $ Konsole/ColorScheme#::setRandomizedBackgroundColorcxx . . $ Konsole/ColorScheme#setRandomizedBackgroundColor(b45ddcbc8423892c).(bool randomize) |
| 209 |
{ |
| 210 |
// the hue of the background colour is allowed to be randomly |
| 211 |
// adjusted as much as possible. |
| 212 |
// |
| 213 |
// the value and saturation are left alone to maintain read-ability |
| 214 |
if ( randomize ) |
| 215 |
{ |
| 216 |
setRandomizationRangecxx . . $ Konsole/ColorScheme#setRandomizationRange(1345fdb3466ed04e).( 1 /* background color index */ , MAX_HUEcxx . . $ Konsole/ColorScheme#MAX_HUE. , 255 , 0 ); |
| 217 |
} |
| 218 |
else |
| 219 |
{ |
| 220 |
if ( _randomTablecxx . . $ Konsole/ColorScheme#_randomTable. ) |
| 221 |
setRandomizationRangecxx . . $ Konsole/ColorScheme#setRandomizationRange(1345fdb3466ed04e).( 1 /* background color index */ , 0 , 0 , 0 ); |
| 222 |
} |
| 223 |
} |
| 224 |
|
| 225 |
void ColorSchemecxx . . $ Konsole/ColorScheme#::setRandomizationRangecxx . . $ Konsole/ColorScheme#setRandomizationRange(1345fdb3466ed04e).( int index , quint16cxx . . $ quint16# hue , quint8cxx . . $ quint8# saturation , |
| 226 |
quint8cxx . . $ quint8# value ) |
| 227 |
{ |
| 228 |
Q_ASSERTcxx . . $ `<external>/15045578679651060896/qglobal.h:859:13`!( hue <= MAX_HUE ); |
| 229 |
Q_ASSERTcxx . . $ `<external>/15045578679651060896/qglobal.h:859:13`!( index >= 0 && index < TABLE_COLORScxx . . $ `lib/CharacterColor.h:103:9`! ); |
| 230 |
|
| 231 |
if ( _randomTablecxx . . $ Konsole/ColorScheme#_randomTable. == nullptr ) |
| 232 |
_randomTablecxx . . $ Konsole/ColorScheme#_randomTable. = new RandomizationRangecxx . . $ Konsole/ColorScheme#RandomizationRange#[TABLE_COLORScxx . . $ `lib/CharacterColor.h:103:9`!]; |
| 233 |
|
| 234 |
_randomTablecxx . . $ Konsole/ColorScheme#_randomTable.[index].huecxx . . $ Konsole/ColorScheme#RandomizationRange#hue. = hue; |
| 235 |
_randomTablecxx . . $ Konsole/ColorScheme#_randomTable.[index].valuecxx . . $ Konsole/ColorScheme#RandomizationRange#value. = value; |
| 236 |
_randomTablecxx . . $ Konsole/ColorScheme#_randomTable.[index].saturationcxx . . $ Konsole/ColorScheme#RandomizationRange#saturation. = saturation; |
| 237 |
} |
| 238 |
|
| 239 |
const ColorEntrycxx . . $ Konsole/ColorEntry#* ColorSchemecxx . . $ Konsole/ColorScheme#::colorTablecxx . . $ Konsole/ColorScheme#colorTable(ec15202fc6ea9dfb).() const |
| 240 |
{ |
| 241 |
if ( _tablecxx . . $ Konsole/ColorScheme#_table. ) |
| 242 |
return _tablecxx . . $ Konsole/ColorScheme#_table.; |
| 243 |
else |
| 244 |
return defaultTablecxx . . $ Konsole/ColorScheme#defaultTable.; |
| 245 |
} |
| 246 |
QColorcxx . . $ QColor# ColorSchemecxx . . $ Konsole/ColorScheme#::foregroundColorcxx . . $ Konsole/ColorScheme#foregroundColor(6d62b116d5d1b12f).() const |
| 247 |
{ |
| 248 |
return colorTablecxx . . $ QColor#QColor(c396aab421781ee8).()[0].colorcxx . . $ Konsole/ColorEntry#color.; |
| 249 |
} |
| 250 |
QColorcxx . . $ QColor# ColorSchemecxx . . $ Konsole/ColorScheme#::backgroundColorcxx . . $ Konsole/ColorScheme#backgroundColor(6d62b116d5d1b12f).() const |
| 251 |
{ |
| 252 |
return colorTablecxx . . $ QColor#QColor(c396aab421781ee8).()[1].colorcxx . . $ Konsole/ColorEntry#color.; |
| 253 |
} |
| 254 |
bool ColorSchemecxx . . $ Konsole/ColorScheme#::hasDarkBackgroundcxx . . $ Konsole/ColorScheme#hasDarkBackground(50ce9a9e25b4a850).() const |
| 255 |
{ |
| 256 |
// value can range from 0 - 255, with larger values indicating higher brightness. |
| 257 |
// so 127 is in the middle, anything less is deemed 'dark' |
| 258 |
return backgroundColorcxx . . $ Konsole/ColorScheme#backgroundColor(6d62b116d5d1b12f).().valuecxx . . $ QColor#value(ea6fe5115c70a13f).() < 127; |
| 259 |
} |
| •260 |
void ColorSchemecxx . . $ Konsole/ColorScheme#::setOpacitycxx . . $ Konsole/ColorScheme#setOpacity(ba8836b59fb42830).(qrealcxx . . $ qreal# opacity) { _opacitycxx . . $ Konsole/ColorScheme#_opacity. = opacity; opacityChangedcxx . . $ Konsole/ColorScheme#opacityChanged(49f6e7a06ebc5aa8).(); } |
| 261 |
qrealcxx . . $ qreal# ColorSchemecxx . . $ Konsole/ColorScheme#::opacitycxx . . $ Konsole/ColorScheme#opacity(21b6c25e127938e2).() const { return _opacitycxx . . $ Konsole/ColorScheme#_opacity.; } |
| 262 |
|
| 263 |
void ColorSchemecxx . . $ Konsole/ColorScheme#::readcxx . . $ Konsole/ColorScheme#read(3520e46b33348bf6).(const QStringcxx . . $ QString# & fileName) |
| 264 |
{ |
| 265 |
QSettingscxx . . $ QSettings# scxx . . $ QSettings#QSettings(3a5f799f337fd20b).(fileName, QSettingscxx . . $ QSettings#::IniFormatcxx . . $ QSettings#IniFormat.); |
| 266 |
s.beginGroupcxx . . $ QSettings#beginGroup(3520e46b33348bf6).(QLatin1Stringcxx . . $ QString#QString(4641beeb24e75d60).("General")); |
| 267 |
|
| 268 |
_descriptioncxx . . $ Konsole/ColorScheme#_description. =cxx . . $ QString#`operator=`(4f35bf974e7f8568). s.valuecxx . . $ QSettings#value(12a1b1749da49362).(QLatin1Stringcxx . . $ QString#QString(4641beeb24e75d60).("Description"), QObjectcxx . . $ QVariant#QVariant(3520e46b33348bf6).::trcxx . . $ QObject#tr(75d9f1c324b4579d).("Un-named Color Scheme")).toStringcxx . . $ QVariant#toString(6ef7b6c27b00b43d).(); |
| 269 |
_opacitycxx . . $ Konsole/ColorScheme#_opacity. = s.valuecxx . . $ QSettings#value(12a1b1749da49362).(QLatin1Stringcxx . . $ QString#QString(4641beeb24e75d60).("Opacity"),qrealcxx . . $ QVariant#QVariant(ba8836b59fb42830).(1.0)).toDoublecxx . . $ QVariant#toDouble(1bd8e57dd4a29c14).(); |
| 270 |
s.endGroupcxx . . $ QSettings#endGroup(49f6e7a06ebc5aa8).(); |
| 271 |
|
| 272 |
for (int i=0 ; i < TABLE_COLORScxx . . $ `lib/CharacterColor.h:103:9`! ; i++) |
| 273 |
{ |
| 274 |
readColorEntrycxx . . $ Konsole/ColorScheme#readColorEntry(2bca0edb2e1897ed).(&s, i); |
| 275 |
} |
| 276 |
} |
| •277 |
|
| 278 |
void ColorSchemecxx . . $ Konsole/ColorScheme#::writecxx . . $ Konsole/ColorScheme#write(7fba01612ab56717).(const QStringcxx . . $ QString# & fileName) const |
| 279 |
{ |
| 280 |
QSettingscxx . . $ QSettings# scxx . . $ QSettings#QSettings(3a5f799f337fd20b).(fileName, QSettingscxx . . $ QSettings#::IniFormatcxx . . $ QSettings#IniFormat.); |
| 281 |
s.beginGroupcxx . . $ QSettings#beginGroup(3520e46b33348bf6).("General"cxx . . $ QString#QString(85c52e162fed56f9).); |
| 282 |
|
| 283 |
s.setValuecxx . . $ QSettings#setValue(1c60a90c724e6bfb).("Description"cxx . . $ QString#QString(85c52e162fed56f9)., _descriptioncxx . . $ QVariant#QVariant(3520e46b33348bf6).); |
| 284 |
s.setValuecxx . . $ QSettings#setValue(1c60a90c724e6bfb).("Opacity"cxx . . $ QString#QString(85c52e162fed56f9)., _opacitycxx . . $ QVariant#QVariant(ba8836b59fb42830).); |
| 285 |
s.endGroupcxx . . $ QSettings#endGroup(49f6e7a06ebc5aa8).(); |
| 286 |
|
| 287 |
for (int i=0 ; i < TABLE_COLORScxx . . $ `lib/CharacterColor.h:103:9`! ; i++) |
| 288 |
{ |
| 289 |
writeColorEntrycxx . . $ Konsole/ColorScheme#writeColorEntry(40501a4d721c9e5d).(&s, i, colorTablecxx . . $ Konsole/ColorScheme#colorTable(ec15202fc6ea9dfb).()[i]); |
| 290 |
} |
| 291 |
} |
| 292 |
#if 0 |
| 293 |
// implemented upstream - user apps |
| 294 |
void ColorScheme::read(KConfig& config) |
| 295 |
{ |
| 296 |
KConfigGroup configGroup = config.group("General"); |
| 297 |
|
| 298 |
QString description = configGroup.readEntry("Description", QObject::tr("Un-named Color Scheme")); |
| 299 |
|
| 300 |
_description = tr(description.toUtf8()); |
| 301 |
_opacity = configGroup.readEntry("Opacity",qreal(1.0)); |
| 302 |
|
| 303 |
for (int i=0 ; i < TABLE_COLORS ; i++) |
| 304 |
{ |
| 305 |
readColorEntry(config,i); |
| 306 |
} |
| 307 |
} |
| 308 |
void ColorScheme::write(KConfig& config) const |
| 309 |
{ |
| 310 |
KConfigGroup configGroup = config.group("General"); |
| 311 |
|
| 312 |
configGroup.writeEntry("Description",_description); |
| 313 |
configGroup.writeEntry("Opacity",_opacity); |
| 314 |
|
| 315 |
for (int i=0 ; i < TABLE_COLORS ; i++) |
| 316 |
{ |
| 317 |
RandomizationRange random = _randomTable != 0 ? _randomTable[i] : RandomizationRange(); |
| 318 |
writeColorEntry(config,colorNameForIndex(i),colorTable()[i],random); |
| 319 |
} |
| 320 |
} |
| 321 |
#endif |
| 322 |
|
| 323 |
QStringcxx . . $ QString# ColorSchemecxx . . $ Konsole/ColorScheme#::colorNameForIndexcxx . . $ Konsole/ColorScheme#colorNameForIndex(ce915ed341d4a7f0).(int index) |
| 324 |
{ |
| 325 |
Q_ASSERTcxx . . $ `<external>/15045578679651060896/qglobal.h:859:13`!( index >= 0 && index < TABLE_COLORScxx . . $ `lib/CharacterColor.h:103:9`! ); |
| 326 |
|
| 327 |
return QStringcxx . . $ QString#::fromLatin1cxx . . $ QString#fromLatin1(5ac70cc0fa2a874e).(colorNamescxx . . $ Konsole/ColorScheme#colorNames.[index]); |
| 328 |
} |
| 329 |
QStringcxx . . $ QString# ColorSchemecxx . . $ Konsole/ColorScheme#::translatedColorNameForIndexcxx . . $ Konsole/ColorScheme#translatedColorNameForIndex(ce915ed341d4a7f0).(int index) |
| 330 |
{ |
| 331 |
Q_ASSERTcxx . . $ `<external>/15045578679651060896/qglobal.h:859:13`!( index >= 0 && index < TABLE_COLORScxx . . $ `lib/CharacterColor.h:103:9`! ); |
| 332 |
|
| 333 |
return QStringcxx . . $ QString#::fromLatin1cxx . . $ QString#fromLatin1(5ac70cc0fa2a874e).(translatedColorNamescxx . . $ Konsole/ColorScheme#translatedColorNames.[index]); |
| 334 |
} |
| 335 |
|
| 336 |
void ColorSchemecxx . . $ Konsole/ColorScheme#::readColorEntrycxx . . $ Konsole/ColorScheme#readColorEntry(2bca0edb2e1897ed).(QSettingscxx . . $ QSettings# * s , int index) |
| 337 |
{ |
| 338 |
QStringcxx . . $ QString# colorName = colorNameForIndexcxx . . $ Konsole/ColorScheme#colorNameForIndex(ce915ed341d4a7f0).(index); |
| 339 |
|
| 340 |
s->beginGroupcxx . . $ QSettings#beginGroup(3520e46b33348bf6).(colorName); |
| 341 |
|
| 342 |
ColorEntrycxx . . $ Konsole/ColorEntry# entrycxx . . $ Konsole/ColorEntry#ColorEntry(49f6e7a06ebc5aa8).; |
| 343 |
|
| 344 |
QVariantcxx . . $ QVariant# colorValue = s->valuecxx . . $ QSettings#value(12a1b1749da49362).(QLatin1Stringcxx . . $ QString#QString(4641beeb24e75d60).("Color")); |
| 345 |
QStringcxx . . $ QString# colorStrcxx . . $ QString#QString(ced63f7c635d850d).; |
| 346 |
int r, g, b; |
| 347 |
bool ok = false; |
| 348 |
// XXX: Undocumented(?) QSettings behavior: values with commas are parsed |
| 349 |
// as QStringList and others QString |
| 350 |
if (colorValue.typecxx . . $ QVariant#type(5e54638cd06c4ff1).() == QVariantcxx . . $ QVariant#::StringListcxx . . $ QVariant#StringList.) |
| 351 |
{ |
| 352 |
QStringListcxx . . $ QStringList# rgbList = colorValue.toStringListcxx . . $ QVariant#toStringList(e1dbd5c4feadc8f5).(); |
| 353 |
colorStr =cxx . . $ QString#`operator=`(4f35bf974e7f8568). rgbList.joincxx . . $ QListSpecialMethods#join(227e33e1a3bf1f91).(QLatin1Charcxx . . $ QChar#QChar(a50889c09eec06d9).(',')); |
| 354 |
if (rgbList.countcxx . . $ QList#count(455f465bc33b4cdf).() == 3) |
| 355 |
{ |
| 356 |
bool parse_ok; |
| 357 |
|
| 358 |
ok = true; |
| 359 |
r = rgbList[cxx . . $ QList#`operator[]`(7a0ef1c7079e8533).0].toIntcxx . . $ QString#toInt(d7972accae11ee1f).(&parse_ok); |
| 360 |
ok = ok && parse_ok && (r >= 0 && r <= 0xff); |
| 361 |
g = rgbList[cxx . . $ QList#`operator[]`(7a0ef1c7079e8533).1].toIntcxx . . $ QString#toInt(d7972accae11ee1f).(&parse_ok); |
| 362 |
ok = ok && parse_ok && (g >= 0 && g <= 0xff); |
| 363 |
b = rgbList[cxx . . $ QList#`operator[]`(7a0ef1c7079e8533).2].toIntcxx . . $ QString#toInt(d7972accae11ee1f).(&parse_ok); |
| 364 |
ok = ok && parse_ok && (b >= 0 && b <= 0xff); |
| 365 |
} |
| 366 |
} |
| 367 |
else |
| 368 |
{ |
| 369 |
colorStr =cxx . . $ QString#`operator=`(4f35bf974e7f8568). colorValue.toStringcxx . . $ QVariant#toString(6ef7b6c27b00b43d).(); |
| 370 |
QRegularExpressioncxx . . $ QRegularExpression# hexColorPatterncxx . . $ QRegularExpression#QRegularExpression(4279d2539df7cd4a).(QLatin1Stringcxx . . $ QString#QString(4641beeb24e75d60).("^#[0-9a-f]{6}$"), |
| 371 |
QRegularExpressioncxx . . $ QFlags#QFlags(93d577a3e9528307).::CaseInsensitiveOptioncxx . . $ QRegularExpression#CaseInsensitiveOption.); |
| 372 |
if (hexColorPattern.matchcxx . . $ QRegularExpression#match(76cd69b0d626af6c).(colorStr).hasMatchcxx . . $ QRegularExpressionMatch#hasMatch(50ce9a9e25b4a850).()) |
| 373 |
{ |
| 374 |
// Parsing is always ok as already matched by the regexp |
| 375 |
r = colorStr.midRefcxx . . $ QString#midRef(d3067bdbc520bd67).(1, 2).toIntcxx . . $ QStringRef#toInt(d7972accae11ee1f).(nullptr, 16); |
| 376 |
g = colorStr.midRefcxx . . $ QString#midRef(d3067bdbc520bd67).(3, 2).toIntcxx . . $ QStringRef#toInt(d7972accae11ee1f).(nullptr, 16); |
| 377 |
b = colorStr.midRefcxx . . $ QString#midRef(d3067bdbc520bd67).(5, 2).toIntcxx . . $ QStringRef#toInt(d7972accae11ee1f).(nullptr, 16); |
| 378 |
ok = true; |
| 379 |
} |
| 380 |
} |
| 381 |
if (!ok) |
| 382 |
{ |
| 383 |
qWarningcxx . . $ `<external>/10450329605257866924/qlogging.h:166:9`!().nospacecxx . . $ QDebug#nospace(56428bd51055c476).() <<cxx . . $ QDebug#`operator<<`(d8a917b173851aad). "Invalid color value " <<cxx . . $ QDebug#`operator<<`(4cf17434affdd8). colorStr |
| 384 |
<<cxx . . $ QDebug#`operator<<`(d8a917b173851aad). " for " <<cxx . . $ QDebug#`operator<<`(4cf17434affdd8). colorName <<cxx . . $ QDebug#`operator<<`(d8a917b173851aad). ". Fallback to black."; |
| 385 |
r = g = b = 0; |
| 386 |
} |
| 387 |
entry.colorcxx . . $ Konsole/ColorEntry#color. =cxx . . $ QColor#`operator=`(fd1b853fb77c9003). QColorcxx . . $ QColor#QColor(2261ffe5112eab06).(r, g, b); |
| 388 |
|
| 389 |
entry.transparentcxx . . $ Konsole/ColorEntry#transparent. = s->valuecxx . . $ QSettings#value(12a1b1749da49362).(QLatin1Stringcxx . . $ QString#QString(4641beeb24e75d60).("Transparent"),falsecxx . . $ QVariant#QVariant(b45ddcbc8423892c).).toBoolcxx . . $ QVariant#toBool(50ce9a9e25b4a850).(); |
| 390 |
|
| 391 |
// Deprecated key from KDE 4.0 which set 'Bold' to true to force |
| 392 |
// a color to be bold or false to use the current format |
| 393 |
// |
| 394 |
// TODO - Add a new tri-state key which allows for bold, normal or |
| 395 |
// current format |
| 396 |
if (s->containscxx . . $ QSettings#contains(f3b39adf77d9c36c).(QLatin1Stringcxx . . $ QString#QString(4641beeb24e75d60).("Bold"))) |
| 397 |
entry.fontWeightcxx . . $ Konsole/ColorEntry#fontWeight. = s->valuecxx . . $ QSettings#value(12a1b1749da49362).(QLatin1Stringcxx . . $ QString#QString(4641beeb24e75d60).("Bold"),falsecxx . . $ QVariant#QVariant(b45ddcbc8423892c).).toBoolcxx . . $ QVariant#toBool(50ce9a9e25b4a850).() ? ColorEntrycxx . . $ Konsole/ColorEntry#::Boldcxx . . $ Konsole/ColorEntry#Bold. : |
| 398 |
ColorEntrycxx . . $ Konsole/ColorEntry#::UseCurrentFormatcxx . . $ Konsole/ColorEntry#UseCurrentFormat.; |
| 399 |
|
| 400 |
quint16cxx . . $ quint16# hue = s->valuecxx . . $ QSettings#value(12a1b1749da49362).(QLatin1Stringcxx . . $ QString#QString(4641beeb24e75d60).("MaxRandomHue"),0cxx . . $ QVariant#QVariant(d4f767463ce0a6b3).).toIntcxx . . $ QVariant#toInt(5bd9a3493f6a7a21).(); |
| 401 |
quint8cxx . . $ quint8# value = s->valuecxx . . $ QSettings#value(12a1b1749da49362).(QLatin1Stringcxx . . $ QString#QString(4641beeb24e75d60).("MaxRandomValue"),0cxx . . $ QVariant#QVariant(d4f767463ce0a6b3).).toIntcxx . . $ QVariant#toInt(5bd9a3493f6a7a21).(); |
| 402 |
quint8cxx . . $ quint8# saturation = s->valuecxx . . $ QSettings#value(12a1b1749da49362).(QLatin1Stringcxx . . $ QString#QString(4641beeb24e75d60).("MaxRandomSaturation"),0cxx . . $ QVariant#QVariant(d4f767463ce0a6b3).).toIntcxx . . $ QVariant#toInt(5bd9a3493f6a7a21).(); |
| 403 |
|
| 404 |
setColorTableEntrycxx . . $ Konsole/ColorScheme#setColorTableEntry(3c6840e24643ea34).( index , entry ); |
| 405 |
|
| 406 |
if ( hue != 0 || value != 0 || saturation != 0 ) |
| 407 |
setRandomizationRangecxx . . $ Konsole/ColorScheme#setRandomizationRange(1345fdb3466ed04e).( index , hue , saturation , value ); |
| 408 |
|
| 409 |
s->endGroupcxx . . $ QSettings#endGroup(49f6e7a06ebc5aa8).(); |
| 410 |
} |
| •411 |
void ColorSchemecxx . . $ Konsole/ColorScheme#::writeColorEntrycxx . . $ Konsole/ColorScheme#writeColorEntry(40501a4d721c9e5d).(QSettingscxx . . $ QSettings# * s, int index, const ColorEntrycxx . . $ Konsole/ColorEntry#& entry) const |
| 412 |
{ |
| 413 |
s->beginGroupcxx . . $ QSettings#beginGroup(3520e46b33348bf6).(colorNameForIndexcxx . . $ Konsole/ColorScheme#colorNameForIndex(ce915ed341d4a7f0).(index)); |
| 414 |
QStringListcxx . . $ QStringList# colorListcxx . . $ QStringList#QStringList(ced63f7c635d850d).; |
| 415 |
colorList <<cxx . . $ QStringList#`operator<<`(85116071a693d053). QStringcxx . . $ QString#::numbercxx . . $ QString#number(f4fd9db251ca774b).(entry.colorcxx . . $ Konsole/ColorEntry#color..redcxx . . $ QColor#red(ea6fe5115c70a13f).()) <<cxx . . $ QStringList#`operator<<`(85116071a693d053). QStringcxx . . $ QString#::numbercxx . . $ QString#number(f4fd9db251ca774b).(entry.colorcxx . . $ Konsole/ColorEntry#color..greencxx . . $ QColor#green(ea6fe5115c70a13f).()) <<cxx . . $ QStringList#`operator<<`(85116071a693d053). QStringcxx . . $ QString#::numbercxx . . $ QString#number(f4fd9db251ca774b).(entry.colorcxx . . $ Konsole/ColorEntry#color..bluecxx . . $ QColor#blue(ea6fe5115c70a13f).()); |
| 416 |
s->setValuecxx . . $ QSettings#setValue(1c60a90c724e6bfb).("Color"cxx . . $ QString#QString(85c52e162fed56f9)., colorListcxx . . $ QVariant#QVariant(631c0101495f0328).); |
| 417 |
s->setValuecxx . . $ QSettings#setValue(1c60a90c724e6bfb).("Transparency"cxx . . $ QString#QString(85c52e162fed56f9)., (cxx . . $ QVariant#QVariant(b45ddcbc8423892c).bool)entry.transparentcxx . . $ Konsole/ColorEntry#transparent.); |
| 418 |
if (entry.fontWeightcxx . . $ Konsole/ColorEntry#fontWeight. != ColorEntrycxx . . $ Konsole/ColorEntry#::UseCurrentFormatcxx . . $ Konsole/ColorEntry#UseCurrentFormat.) |
| 419 |
{ |
| 420 |
s->setValuecxx . . $ QSettings#setValue(1c60a90c724e6bfb).("Bold"cxx . . $ QString#QString(85c52e162fed56f9)., entrycxx . . $ QVariant#QVariant(b45ddcbc8423892c)..fontWeightcxx . . $ Konsole/ColorEntry#fontWeight. == ColorEntrycxx . . $ Konsole/ColorEntry#::Boldcxx . . $ Konsole/ColorEntry#Bold.); |
| 421 |
} |
| 422 |
s->endGroupcxx . . $ QSettings#endGroup(49f6e7a06ebc5aa8).(); |
| 423 |
} |
| 424 |
#if 0 |
| 425 |
// implemented upstream - user apps |
| 426 |
void ColorScheme::writeColorEntry(KConfig& config , const QString& colorName, const ColorEntry& entry , const RandomizationRange& random) const |
| 427 |
{ |
| 428 |
KConfigGroup configGroup(&config,colorName); |
| 429 |
|
| 430 |
configGroup.writeEntry("Color",entry.color); |
| 431 |
configGroup.writeEntry("Transparency",(bool)entry.transparent); |
| 432 |
if (entry.fontWeight != ColorEntry::UseCurrentFormat) |
| 433 |
{ |
| 434 |
configGroup.writeEntry("Bold",entry.fontWeight == ColorEntry::Bold); |
| 435 |
} |
| 436 |
|
| 437 |
// record randomization if this color has randomization or |
| 438 |
// if one of the keys already exists |
| 439 |
if ( !random.isNull() || configGroup.hasKey("MaxRandomHue") ) |
| 440 |
{ |
| 441 |
configGroup.writeEntry("MaxRandomHue",(int)random.hue); |
| 442 |
configGroup.writeEntry("MaxRandomValue",(int)random.value); |
| 443 |
configGroup.writeEntry("MaxRandomSaturation",(int)random.saturation); |
| 444 |
} |
| 445 |
} |
| 446 |
#endif |
| 447 |
|
| 448 |
// |
| 449 |
// Work In Progress - A color scheme for use on KDE setups for users |
| 450 |
// with visual disabilities which means that they may have trouble |
| 451 |
// reading text with the supplied color schemes. |
| 452 |
// |
| 453 |
// This color scheme uses only the 'safe' colors defined by the |
| 454 |
// KColorScheme class. |
| 455 |
// |
| 456 |
// A complication this introduces is that each color provided by |
| 457 |
// KColorScheme is defined as a 'background' or 'foreground' color. |
| 458 |
// Only foreground colors are allowed to be used to render text and |
| 459 |
// only background colors are allowed to be used for backgrounds. |
| 460 |
// |
| 461 |
// The ColorEntry and TerminalDisplay classes do not currently |
| 462 |
// support this restriction. |
| 463 |
// |
| 464 |
// Requirements: |
| 465 |
// - A color scheme which uses only colors from the KColorScheme class |
| 466 |
// - Ability to restrict which colors the TerminalDisplay widget |
| 467 |
// uses as foreground and background color |
| 468 |
// - Make use of KGlobalSettings::allowDefaultBackgroundImages() as |
| 469 |
// a hint to determine whether this accessible color scheme should |
| 470 |
// be used by default. |
| 471 |
// |
| 472 |
// |
| 473 |
// -- Robert Knight <[email protected]> 21/07/2007 |
| 474 |
// |
| 475 |
AccessibleColorSchemecxx . . $ Konsole/AccessibleColorScheme#::AccessibleColorSchemecxx . . $ Konsole/AccessibleColorScheme#AccessibleColorScheme(49f6e7a06ebc5aa8).() |
| 476 |
: ColorSchemecxx . . $ Konsole/ColorScheme#() |
| 477 |
{ |
| 478 |
#if 0 |
| 479 |
// It's not finished in konsole and it breaks Qt4 compilation as well |
| 480 |
// basic attributes |
| 481 |
setName("accessible"); |
| 482 |
setDescription(QObject::tr("Accessible Color Scheme")); |
| 483 |
|
| 484 |
// setup colors |
| 485 |
const int ColorRoleCount = 8; |
| 486 |
|
| 487 |
const KColorScheme colorScheme(QPalette::Active); |
| 488 |
|
| 489 |
QBrush colors[ColorRoleCount] = |
| 490 |
{ |
| 491 |
colorScheme.foreground( colorScheme.NormalText ), |
| 492 |
colorScheme.background( colorScheme.NormalBackground ), |
| 493 |
|
| 494 |
colorScheme.foreground( colorScheme.InactiveText ), |
| 495 |
colorScheme.foreground( colorScheme.ActiveText ), |
| 496 |
colorScheme.foreground( colorScheme.LinkText ), |
| 497 |
colorScheme.foreground( colorScheme.VisitedText ), |
| 498 |
colorScheme.foreground( colorScheme.NegativeText ), |
| 499 |
colorScheme.foreground( colorScheme.NeutralText ) |
| 500 |
}; |
| 501 |
|
| 502 |
for ( int i = 0 ; i < TABLE_COLORS ; i++ ) |
| 503 |
{ |
| 504 |
ColorEntry entry; |
| 505 |
entry.color = colors[ i % ColorRoleCount ].color(); |
| 506 |
|
| 507 |
setColorTableEntry( i , entry ); |
| 508 |
} |
| 509 |
#endif |
| 510 |
} |
| 511 |
|
| 512 |
ColorSchemeManagercxx . . $ Konsole/ColorSchemeManager#::ColorSchemeManagercxx . . $ Konsole/ColorSchemeManager#ColorSchemeManager(49f6e7a06ebc5aa8).() |
| 513 |
: _haveLoadedAllcxx . . $ Konsole/ColorSchemeManager#_haveLoadedAll.(false) |
| 514 |
{ |
| 515 |
} |
| 516 |
ColorSchemeManagercxx . . $ Konsole/ColorSchemeManager#::~cxx . . $ Konsole/ColorSchemeManager#`~ColorSchemeManager`(ced63f7c635d850d).ColorSchemeManagercxx . . $ Konsole/ColorSchemeManager#() |
| 517 |
{ |
| 518 |
QHashIteratorcxx . . $ QHashIterator#<QStringcxx . . $ QString#,const ColorSchemecxx . . $ Konsole/ColorScheme#*> itercxx . . $ QHashIterator#QHashIterator(b49801d1bb7ffe09).(_colorSchemescxx . . $ Konsole/ColorSchemeManager#_colorSchemes.); |
| 519 |
while (iter.hasNextcxx . . $ QHashIterator#hasNext(50ce9a9e25b4a850).()) |
| 520 |
{ |
| 521 |
iter.nextcxx . . $ QHashIterator#next(502dc262f89e6c2c).(); |
| 522 |
delete iter.valuecxx . . $ QHashIterator#value(bdbd05d619d62250).(); |
| 523 |
} |
| 524 |
} |
| 525 |
void ColorSchemeManagercxx . . $ Konsole/ColorSchemeManager#::loadAllColorSchemescxx . . $ Konsole/ColorSchemeManager#loadAllColorSchemes(49f6e7a06ebc5aa8).() |
| 526 |
{ |
| 527 |
//qDebug() << "loadAllColorSchemes"; |
| 528 |
int failed = 0; |
| 529 |
|
| 530 |
QListcxx . . $ QList#<QStringcxx . . $ QString#> nativeColorSchemes = listColorSchemescxx . . $ Konsole/ColorSchemeManager#listColorSchemes(346f0183abd8f69).(); |
| 531 |
QListIteratorcxx . . $ QListIterator#<QStringcxx . . $ QString#> nativeItercxx . . $ QListIterator#QListIterator(742a15f66a895bc5).(nativeColorSchemes); |
| 532 |
while ( nativeIter.hasNextcxx . . $ QListIterator#hasNext(50ce9a9e25b4a850).() ) |
| 533 |
{ |
| 534 |
if ( !loadColorSchemecxx . . $ Konsole/ColorSchemeManager#loadColorScheme(e1defb592416720d).( nativeIter.nextcxx . . $ QListIterator#next(1306adbac230aeaa).() ) ) |
| 535 |
failed++; |
| 536 |
} |
| 537 |
|
| 538 |
/*if ( failed > 0 ) |
| 539 |
qDebug() << "failed to load " << failed << " color schemes.";*/ |
| 540 |
|
| 541 |
_haveLoadedAllcxx . . $ Konsole/ColorSchemeManager#_haveLoadedAll. = true; |
| 542 |
} |
| 543 |
QListcxx . . $ QList#<const ColorSchemecxx . . $ Konsole/ColorScheme#*> ColorSchemeManagercxx . . $ Konsole/ColorSchemeManager#::allColorSchemescxx . . $ Konsole/ColorSchemeManager#allColorSchemes(de974b58986d672).() |
| 544 |
{ |
| 545 |
if ( !_haveLoadedAllcxx . . $ Konsole/ColorSchemeManager#_haveLoadedAll. ) |
| 546 |
{ |
| 547 |
loadAllColorSchemescxx . . $ Konsole/ColorSchemeManager#loadAllColorSchemes(49f6e7a06ebc5aa8).(); |
| 548 |
} |
| 549 |
|
| 550 |
return _colorSchemescxx . . $ Konsole/ColorSchemeManager#_colorSchemes..valuescxx . . $ QHash#values(16615713d304f37e).(); |
| 551 |
} |
| 552 |
#if 0 |
| 553 |
void ColorSchemeManager::addColorScheme(ColorScheme* scheme) |
| 554 |
{ |
| 555 |
_colorSchemes.insert(scheme->name(),scheme); |
| 556 |
|
| 557 |
// save changes to disk |
| 558 |
QString path = KGlobal::dirs()->saveLocation("data","konsole/") + scheme->name() + ".colorscheme"; |
| 559 |
KConfig config(path , KConfig::NoGlobals); |
| 560 |
|
| 561 |
scheme->write(config); |
| 562 |
} |
| 563 |
#endif |
| 564 |
|
| 565 |
bool ColorSchemeManagercxx . . $ Konsole/ColorSchemeManager#::loadCustomColorSchemecxx . . $ Konsole/ColorSchemeManager#loadCustomColorScheme(e1defb592416720d).(const QStringcxx . . $ QString#& path) |
| 566 |
{ |
| 567 |
if (path.endsWithcxx . . $ QString#endsWith(9b0c247ef39438e0).(QLatin1Stringcxx . . $ QLatin1String#QLatin1String(aac1607cfe1c1740).(".colorscheme"))) |
| 568 |
return loadColorSchemecxx . . $ Konsole/ColorSchemeManager#loadColorScheme(e1defb592416720d).(path); |
| 569 |
|
| 570 |
return false; |
| 571 |
} |
| 572 |
|
| 573 |
void ColorSchemeManagercxx . . $ Konsole/ColorSchemeManager#::addCustomColorSchemeDircxx . . $ Konsole/ColorSchemeManager#addCustomColorSchemeDir(3520e46b33348bf6).(const QStringcxx . . $ QString#& custom_dir) |
| 574 |
{ |
| 575 |
add_custom_color_scheme_dircxx . . $ add_custom_color_scheme_dir(3520e46b33348bf6).(custom_dir); |
| 576 |
} |
| 577 |
|
| 578 |
bool ColorSchemeManagercxx . . $ Konsole/ColorSchemeManager#::loadColorSchemecxx . . $ Konsole/ColorSchemeManager#loadColorScheme(e1defb592416720d).(const QStringcxx . . $ QString#& filePath) |
| 579 |
{ |
| 580 |
if ( !filePath.endsWithcxx . . $ QString#endsWith(9b0c247ef39438e0).(QLatin1Stringcxx . . $ QLatin1String#QLatin1String(aac1607cfe1c1740).(".colorscheme")) || !QFilecxx . . $ QFile#::existscxx . . $ QFile#exists(e1defb592416720d).(filePath) ) |
| 581 |
return false; |
| 582 |
|
| 583 |
QFileInfocxx . . $ QFileInfo# infocxx . . $ QFileInfo#QFileInfo(3520e46b33348bf6).(filePath); |
| 584 |
|
| 585 |
const QStringcxx . . $ QString#& schemeName = info.baseNamecxx . . $ QFileInfo#baseName(6ef7b6c27b00b43d).(); |
| 586 |
|
| •587 |
ColorSchemecxx . . $ Konsole/ColorScheme#* scheme = new ColorSchemecxx . . $ Konsole/ColorScheme#(this); |
| 588 |
scheme->setNamecxx . . $ Konsole/ColorScheme#setName(3520e46b33348bf6).(schemeName); |
| 589 |
scheme->readcxx . . $ Konsole/ColorScheme#read(3520e46b33348bf6).(filePath); |
| 590 |
|
| 591 |
if (scheme->namecxx . . $ Konsole/ColorScheme#name(6ef7b6c27b00b43d).().isEmptycxx . . $ QString#isEmpty(50ce9a9e25b4a850).()) |
| 592 |
{ |
| 593 |
//qDebug() << "Color scheme in" << filePath << "does not have a valid name and was not loaded."; |
| 594 |
delete scheme; |
| 595 |
return false; |
| 596 |
} |
| 597 |
|
| 598 |
if ( !_colorSchemescxx . . $ Konsole/ColorSchemeManager#_colorSchemes..containscxx . . $ QHash#contains(8877ebe272b9620d).(schemeName) ) |
| 599 |
{ |
| 600 |
_colorSchemescxx . . $ Konsole/ColorSchemeManager#_colorSchemes..insertcxx . . $ QHash#insert(d77b19c31d2eb147).(schemeName,scheme); |
| 601 |
} |
| 602 |
else |
| 603 |
{ |
| 604 |
/*qDebug() << "color scheme with name" << schemeName << "has already been" << |
| 605 |
"found, ignoring.";*/ |
| 606 |
|
| 607 |
delete scheme; |
| 608 |
} |
| 609 |
|
| 610 |
return true; |
| 611 |
} |
| 612 |
QListcxx . . $ QList#<QStringcxx . . $ QString#> ColorSchemeManagercxx . . $ Konsole/ColorSchemeManager#::listColorSchemescxx . . $ Konsole/ColorSchemeManager#listColorSchemes(346f0183abd8f69).() |
| 613 |
{ |
| 614 |
QListcxx . . $ QList#<QStringcxx . . $ QString#> retcxx . . $ QList#QList(ced63f7c635d850d).; |
| 615 |
for (const QStringcxx . . $ QString# &scheme_dir : get_color_schemes_dirscxx . . $ get_color_schemes_dirs(8915157311999748).()) |
| 616 |
{ |
| 617 |
const QStringcxx . . $ QString# dnamecxx . . $ QString#QString(132dd6869045752b).(scheme_dir); |
| 618 |
QDircxx . . $ QDir# dircxx . . $ QDir#QDir(3520e46b33348bf6).(dname); |
| 619 |
QStringListcxx . . $ QStringList# filterscxx . . $ QStringList#QStringList(ced63f7c635d850d).; |
| 620 |
filters <<cxx . . $ QStringList#`operator<<`(85116071a693d053). QLatin1Stringcxx . . $ QString#QString(4641beeb24e75d60).("*.colorscheme"); |
| 621 |
dir.setNameFilterscxx . . $ QDir#setNameFilters(631c0101495f0328).(filters); |
| 622 |
const QStringListcxx . . $ QStringList# list = dir.entryListcxx . . $ QDir#entryList(4575c08c50802968).(filters); |
| 623 |
for (const QStringcxx . . $ QString# &i : list) |
| 624 |
ret <<cxx . . $ QList#`operator<<`(309d1580d8f5dc58). dname +cxx . . $ operator+(eab1ea5b6c36e9b2). QLatin1Charcxx . . $ QChar#QChar(a50889c09eec06d9).('/') +cxx . . $ operator+(fab9b4f80031f353). i; |
| 625 |
} |
| 626 |
return retcxx . . $ QList#QList(88d75cd4b19cb2d1).; |
| 627 |
// return KGlobal::dirs()->findAllResources("data", |
| 628 |
// "konsole/*.colorscheme", |
| 629 |
// KStandardDirs::NoDuplicates); |
| 630 |
} |
| 631 |
const ColorSchemecxx . . $ Konsole/ColorScheme# ColorSchemeManagercxx . . $ Konsole/ColorSchemeManager#::_defaultColorSchemecxx . . $ Konsole/ColorSchemeManager#_defaultColorScheme.; |
| 632 |
const ColorSchemecxx . . $ Konsole/ColorScheme#* ColorSchemeManagercxx . . $ Konsole/ColorSchemeManager#::defaultColorSchemecxx . . $ Konsole/ColorSchemeManager#defaultColorScheme(b3d5baf7ec74d27d).() const |
| 633 |
{ |
| 634 |
return &_defaultColorSchemecxx . . $ Konsole/ColorSchemeManager#_defaultColorScheme.; |
| 635 |
} |
| 636 |
bool ColorSchemeManagercxx . . $ Konsole/ColorSchemeManager#::deleteColorSchemecxx . . $ Konsole/ColorSchemeManager#deleteColorScheme(e1defb592416720d).(const QStringcxx . . $ QString#& name) |
| 637 |
{ |
| 638 |
Q_ASSERTcxx . . $ `<external>/15045578679651060896/qglobal.h:859:13`!( _colorSchemes.contains(name) ); |
| 639 |
|
| 640 |
// lookup the path and delete |
| 641 |
QStringcxx . . $ QString# path = findColorSchemePathcxx . . $ Konsole/ColorSchemeManager#findColorSchemePath(5555d9024dcf93fb).(name); |
| 642 |
if ( QFilecxx . . $ QFile#::removecxx . . $ QFile#remove(e1defb592416720d).(path) ) |
| 643 |
{ |
| 644 |
_colorSchemescxx . . $ Konsole/ColorSchemeManager#_colorSchemes..removecxx . . $ QHash#remove(dd8e59d271e40448).(name); |
| 645 |
return true; |
| 646 |
} |
| 647 |
else |
| 648 |
{ |
| 649 |
//qDebug() << "Failed to remove color scheme -" << path; |
| 650 |
return false; |
| 651 |
} |
| 652 |
} |
| 653 |
QStringcxx . . $ QString# ColorSchemeManagercxx . . $ Konsole/ColorSchemeManager#::findColorSchemePathcxx . . $ Konsole/ColorSchemeManager#findColorSchemePath(5555d9024dcf93fb).(const QStringcxx . . $ QString#& name) const |
| 654 |
{ |
| 655 |
// QString path = KStandardDirs::locate("data","konsole/"+name+".colorscheme"); |
| 656 |
const QStringListcxx . . $ QStringList# dirs = get_color_schemes_dirscxx . . $ get_color_schemes_dirs(8915157311999748).(); |
| 657 |
if ( dirs.isEmptycxx . . $ QList#isEmpty(3482b152b9333168).() ) |
| 658 |
return QStringcxx . . $ QString#QString(ced63f7c635d850d).(); |
| 659 |
|
| 660 |
const QStringcxx . . $ QString# dir = dirscxx . . $ QString#QString(132dd6869045752b)..firstcxx . . $ QList#first(ea465e50d690edfe).(); |
| 661 |
QStringcxx . . $ QString# path(dir +cxx . . $ operator+(eab1ea5b6c36e9b2). QLatin1Charcxx . . $ QChar#QChar(a50889c09eec06d9).('/')+cxx . . $ operator+(fab9b4f80031f353). name +cxx . . $ operator+(fab9b4f80031f353). QLatin1Stringcxx . . $ QString#QString(4641beeb24e75d60).(".colorscheme")); |
| 662 |
if ( !path.isEmptycxx . . $ QString#isEmpty(50ce9a9e25b4a850).() ) |
| 663 |
return pathcxx . . $ QString#QString(28715ad661ad3cec).; |
| 664 |
|
| 665 |
//path = KStandardDirs::locate("data","konsole/"+name+".schema"); |
| 666 |
path =cxx . . $ QString#`operator=`(b79fde0b0ce9b948). dir +cxx . . $ operator+(eab1ea5b6c36e9b2). QLatin1Charcxx . . $ QChar#QChar(a50889c09eec06d9).('/')+cxx . . $ operator+(fab9b4f80031f353). name +cxx . . $ operator+(fab9b4f80031f353). QLatin1Stringcxx . . $ QString#QString(4641beeb24e75d60).(".schema"); |
| 667 |
|
| 668 |
return pathcxx . . $ QString#QString(28715ad661ad3cec).; |
| 669 |
} |
| •670 |
const Konsolecxx . . $ Konsole/::ColorSchemecxx . . $ Konsole/ColorScheme#* ColorSchemeManagercxx . . $ Konsole/ColorSchemeManager#::findColorSchemecxx . . $ Konsole/ColorSchemeManager#findColorScheme(c2b30146a6fdc030).(const QStringcxx . . $ QString#& name) |
| 671 |
{ |
| 672 |
if ( name.isEmptycxx . . $ QString#isEmpty(50ce9a9e25b4a850).() ) |
| 673 |
return defaultColorSchemecxx . . $ Konsole/ColorSchemeManager#defaultColorScheme(b3d5baf7ec74d27d).(); |
| 674 |
|
| 675 |
if ( _colorSchemescxx . . $ Konsole/ColorSchemeManager#_colorSchemes..containscxx . . $ QHash#contains(8877ebe272b9620d).(name) ) |
| 676 |
return _colorSchemescxx . . $ Konsole/ColorSchemeManager#_colorSchemes.[cxx . . $ QHash#`operator[]`(bbd415b616967878).name]; |
| 677 |
else |
| 678 |
{ |
| 679 |
// look for this color scheme |
| 680 |
QStringcxx . . $ QString# path = findColorSchemePathcxx . . $ Konsole/ColorSchemeManager#findColorSchemePath(5555d9024dcf93fb).(name); |
| 681 |
if ( !path.isEmptycxx . . $ QString#isEmpty(50ce9a9e25b4a850).() && loadColorSchemecxx . . $ Konsole/ColorSchemeManager#loadColorScheme(e1defb592416720d).(path) ) |
| 682 |
{ |
| 683 |
return findColorSchemecxx . . $ Konsole/ColorSchemeManager#findColorScheme(c2b30146a6fdc030).(name); |
| 684 |
} |
| 685 |
|
| 686 |
//qDebug() << "Could not find color scheme - " << name; |
| 687 |
|
| 688 |
return nullptr; |
| 689 |
} |
| 690 |
} |
| 691 |
Q_GLOBAL_STATICcxx . . $ `<external>/5857545390125231380/qglobalstatic.h:161:9`!(ColorSchemeManager, theColorSchemeManager) |
| 692 |
ColorSchemeManagercxx . . $ Konsole/ColorSchemeManager#* ColorSchemeManagercxx . . $ Konsole/ColorSchemeManager#::instancecxx . . $ Konsole/ColorSchemeManager#instance(604bba33ddb2d782).() |
| 693 |
{ |
| 694 |
return theColorSchemeManagercxx . . $ theColorSchemeManager.; |
| 695 |
} |