00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022
00023
00024
00025
#include "kdecoration_p.h"
00026
00027
#include <kconfig.h>
00028
#include <kglobalsettings.h>
00029
#include <qpalette.h>
00030
#include <qapplication.h>
00031
#include <assert.h>
00032
00033 KDecorationOptionsPrivate::KDecorationOptionsPrivate()
00034 {
00035
for(
int i=0; i < NUM_COLORS*2; ++i)
00036 cg[i] = NULL;
00037 }
00038
00039 KDecorationOptionsPrivate::~KDecorationOptionsPrivate()
00040 {
00041
int i;
00042
for(i=0; i < NUM_COLORS*2; ++i)
00043 {
00044
if(cg[i])
00045 {
00046
delete cg[i];
00047 cg[i] = NULL;
00048 }
00049 }
00050 }
00051
00052
void KDecorationOptionsPrivate::defaultKWinSettings()
00053 {
00054 title_buttons_left =
"MS";
00055 title_buttons_right =
"HIAX";
00056 custom_button_positions =
false;
00057 show_tooltips =
true;
00058 border_size =
BorderNormal;
00059 cached_border_size = BordersCount;
00060 move_resize_maximized_windows =
true;
00061 }
00062
00063
unsigned long KDecorationOptionsPrivate::updateKWinSettings( KConfig* config )
00064 {
00065
unsigned long changed = 0;
00066 QString old_group = config->group();
00067 config->setGroup(
"WM" );
00068
00069
00070 QColor old_colors[NUM_COLORS*2];
00071
for(
int i = 0;
00072 i < NUM_COLORS*2;
00073 ++i )
00074 old_colors[ i ] = colors[ i ];
00075
00076 QPalette pal = QApplication::palette();
00077
00078 colors[
ColorFrame] = pal.active().background();
00079 colors[
ColorFrame] = config->readColorEntry(
"frame", &colors[ColorFrame]);
00080 colors[
ColorHandle] = colors[
ColorFrame];
00081 colors[
ColorHandle] = config->readColorEntry(
"handle", &colors[ColorHandle]);
00082
00083
00084
if(QPixmap::defaultDepth() > 8)
00085 colors[
ColorButtonBg] = colors[
ColorFrame].light(130);
00086
else
00087 colors[
ColorButtonBg] = colors[
ColorFrame];
00088 colors[
ColorButtonBg] = config->readColorEntry(
"activeTitleBtnBg",
00089 &colors[ColorFrame]);
00090 colors[
ColorTitleBar] = pal.active().highlight();
00091 colors[
ColorTitleBar] = config->readColorEntry(
"activeBackground",
00092 &colors[ColorTitleBar]);
00093
if(QPixmap::defaultDepth() > 8)
00094 colors[
ColorTitleBlend] = colors[
ColorTitleBar ].dark(110);
00095
else
00096 colors[
ColorTitleBlend] = colors[
ColorTitleBar ];
00097 colors[
ColorTitleBlend] = config->readColorEntry(
"activeBlend",
00098 &colors[ColorTitleBlend]);
00099
00100 colors[
ColorFont] = pal.active().highlightedText();
00101 colors[
ColorFont] = config->readColorEntry(
"activeForeground", &colors[ColorFont]);
00102
00103
00104 colors[
ColorFrame+NUM_COLORS] = config->readColorEntry(
"inactiveFrame",
00105 &colors[ColorFrame]);
00106 colors[
ColorTitleBar+NUM_COLORS] = colors[
ColorFrame];
00107 colors[
ColorTitleBar+NUM_COLORS] = config->
00108 readColorEntry(
"inactiveBackground", &colors[ColorTitleBar+NUM_COLORS]);
00109
00110
if(QPixmap::defaultDepth() > 8)
00111 colors[
ColorTitleBlend+NUM_COLORS] = colors[
ColorTitleBar+NUM_COLORS ].dark(110);
00112
else
00113 colors[
ColorTitleBlend+NUM_COLORS] = colors[
ColorTitleBar+NUM_COLORS ];
00114 colors[
ColorTitleBlend+NUM_COLORS] =
00115 config->readColorEntry(
"inactiveBlend", &colors[ColorTitleBlend+NUM_COLORS]);
00116
00117
00118
if(QPixmap::defaultDepth() > 8)
00119 colors[
ColorButtonBg+NUM_COLORS] = colors[
ColorFrame+NUM_COLORS].light(130);
00120
else
00121 colors[
ColorButtonBg+NUM_COLORS] = colors[
ColorFrame+NUM_COLORS];
00122 colors[
ColorButtonBg+NUM_COLORS] =
00123 config->readColorEntry(
"inactiveTitleBtnBg",
00124 &colors[ColorButtonBg]);
00125
00126 colors[
ColorHandle+NUM_COLORS] =
00127 config->readColorEntry(
"inactiveHandle", &colors[ColorHandle]);
00128
00129 colors[
ColorFont+NUM_COLORS] = colors[
ColorFrame].dark();
00130 colors[
ColorFont+NUM_COLORS] = config->readColorEntry(
"inactiveForeground",
00131 &colors[ColorFont+NUM_COLORS]);
00132
00133
for(
int i = 0;
00134 i < NUM_COLORS*2;
00135 ++i )
00136
if( old_colors[ i ] != colors[ i ] )
00137 changed |=
SettingColors;
00138
00139
00140 QFont old_activeFont = activeFont;
00141 QFont old_inactiveFont = inactiveFont;
00142 QFont old_activeFontSmall = activeFontSmall;
00143 QFont old_inactiveFontSmall = inactiveFontSmall;
00144
00145 QFont activeFontGuess = KGlobalSettings::generalFont();
00146 activeFontGuess.setBold(
true);
00147 activeFontGuess.setPixelSize(12);
00148
00149 activeFont = config->readFontEntry(
"activeFont", &activeFontGuess);
00150 inactiveFont = config->readFontEntry(
"inactiveFont", &activeFont);
00151
00152 activeFontSmall = activeFont;
00153 activeFontSmall.setPointSize(activeFont.pointSize() - 2);
00154 activeFontSmall = config->readFontEntry(
"activeFontSmall", &activeFontSmall);
00155 inactiveFontSmall = config->readFontEntry(
"inactiveFontSmall", &activeFontSmall);
00156
00157
if( old_activeFont != activeFont
00158 || old_inactiveFont != inactiveFont
00159 || old_activeFontSmall != activeFontSmall
00160 || old_inactiveFontSmall != inactiveFontSmall )
00161 changed |=
SettingFont;
00162
00163 config->setGroup(
"Style" );
00164
00165 QString old_title_buttons_left = title_buttons_left;
00166 QString old_title_buttons_right = title_buttons_right;
00167
bool old_custom_button_positions = custom_button_positions;
00168 custom_button_positions = config->readBoolEntry(
"CustomButtonPositions",
false);
00169
if (custom_button_positions)
00170 {
00171 title_buttons_left = config->readEntry(
"ButtonsOnLeft",
"MS");
00172 title_buttons_right = config->readEntry(
"ButtonsOnRight",
"HIAX");
00173 }
00174
else
00175 {
00176 title_buttons_left =
"MS";
00177 title_buttons_right =
"HIAX";
00178 }
00179
if( old_custom_button_positions != custom_button_positions
00180 || ( custom_button_positions &&
00181 ( old_title_buttons_left != title_buttons_left
00182 || old_title_buttons_right != title_buttons_right )))
00183 changed |=
SettingButtons;
00184
00185
00186
bool old_show_tooltips = show_tooltips;
00187 show_tooltips = config->readBoolEntry(
"ShowToolTips",
true);
00188
if( old_show_tooltips != show_tooltips )
00189 changed |=
SettingTooltips;
00190
00191
00192
00193
BorderSize old_border_size = border_size;
00194
int border_size_num = config->readNumEntry(
"BorderSize", BorderNormal );
00195
if( border_size_num >= 0 && border_size_num < BordersCount )
00196 border_size = static_cast< BorderSize >( border_size_num );
00197
else
00198 border_size =
BorderNormal;
00199
if( old_border_size != border_size )
00200 changed |=
SettingBorder;
00201 cached_border_size = BordersCount;
00202
00203 config->setGroup(
"Windows" );
00204
bool old_move_resize_maximized_windows = move_resize_maximized_windows;
00205 move_resize_maximized_windows = config->readBoolEntry(
"MoveResizeMaximizedWindows",
true );
00206
if( old_move_resize_maximized_windows != move_resize_maximized_windows )
00207 changed |=
SettingBorder;
00208
00209
00210
int i;
00211
for(i=0; i < NUM_COLORS*2; ++i)
00212 {
00213
if(cg[i])
00214 {
00215
delete cg[i];
00216 cg[i] = NULL;
00217 }
00218 }
00219
00220 config->setGroup( old_group );
00221
00222
return changed;
00223 }
00224
00225
KDecorationDefines::BorderSize KDecorationOptionsPrivate::findPreferredBorderSize( BorderSize size,
00226 QValueList< BorderSize > sizes )
const
00227
{
00228
for( QValueList< BorderSize >::ConstIterator it = sizes.begin();
00229 it != sizes.end();
00230 ++it )
00231
if( size <= *it )
00232
return *it;
00233
return sizes.last();
00234 }