kwin/options.cpp
Cristian Tibirna 52d957df8e CT: cascading placement. I feel it as a bit of an overkill for what it does
compared to smart placement. Whatever. Some people want it

    smart placement made smarter (just a bit) and faster (just a bit)

Qt is a marvel. kwin is even better than kwm. KDE is amazing :-) You know
	who I am now, even if I don't sign.

svn path=/trunk/kdebase/kwin/; revision=34452
1999-11-20 06:27:07 +00:00

154 lines
5.1 KiB
C++

#include "options.h"
#include <qpalette.h>
#include <qpixmap.h>
#include <qapplication.h>
#include <kconfig.h>
#include <kglobal.h>
Options::Options()
{
int i;
for(i=0; i < KWINCOLORS*2; ++i)
cg[i] = NULL;
reload();
//CT fix them for now. Will be read from rc
placement = Smart;
animate_shade = true;
anim_steps = 100;
}
Options::~Options(){
int i;
for(i=0; i < KWINCOLORS*2; ++i){
if(cg[i]){
delete cg[i];
cg[i] = NULL;
}
}
}
const QColor& Options::color(ColorType type, bool active)
{
return(colors[type + (active ? 0 : KWINCOLORS)]);
}
const QFont& Options::font(bool active)
{
return(active ? activeFont : inactiveFont);
}
const QColorGroup& Options::colorGroup(ColorType type, bool active)
{
int idx = type + (active ? 0 : KWINCOLORS);
if(cg[idx])
return(*cg[idx]);
cg[idx] = new QColorGroup(Qt::black, colors[idx], colors[idx].light(150),
colors[idx].dark(), colors[idx].dark(120),
Qt::black, QApplication::palette().normal().
base());
return(*cg[idx]);
}
void Options::reload()
{
focusPolicy = ClickToFocus;
resizeMode = Opaque;
moveMode = Opaque;// Transparent;
QPalette pal = QApplication::palette();
KConfig *config = KGlobal::config();
config->setGroup("WM");
// normal colors
colors[Frame] = Qt::lightGray;
colors[Frame] = config->readColorEntry("frame", &colors[Frame]);
colors[Handle] = QColor( 140, 140, 140 );
colors[Handle] = config->readColorEntry("handle", &colors[Handle]);
colors[ButtonBg] = colors[Frame];
colors[ButtonBg] = config->readColorEntry("activeTitleBtnBg",
&colors[Frame]);
if(QPixmap::defaultDepth() < 15)
colors[ButtonBlend] = colors[ ButtonBg ];
else
colors[ButtonBlend] = colors[ ButtonBg ].dark(150);
colors[ButtonBlend] = config->readColorEntry("activeTitleBtnBlend",
&colors[ButtonBlend]);
colors[TitleBar] = Qt::darkBlue;
colors[TitleBar] = config->readColorEntry("activeBackground",
&colors[TitleBar]);
if(QPixmap::defaultDepth() < 15)
colors[TitleBlend] = colors[ TitleBar ];
else
colors[TitleBlend] = colors[ TitleBar ].dark(150);
colors[TitleBlend] = config->readColorEntry("activeBlend",
&colors[TitleBlend]);
colors[Font] = Qt::white;
colors[Font] = config->readColorEntry("activeForeground", &colors[Font]);
colors[ButtonFg] = Qt::darkGray;
colors[ButtonFg] = config->readColorEntry("activeTitleBtnFg",
&colors[ButtonFg]);
// inactive
colors[Frame+KWINCOLORS] = config->readColorEntry("inactiveFrame",
&colors[Frame]);
colors[TitleBar+KWINCOLORS] = colors[Frame].dark();
colors[TitleBar+KWINCOLORS] = config->
readColorEntry("inactiveBackground", &colors[TitleBar+KWINCOLORS]);
if(QPixmap::defaultDepth() < 15)
colors[TitleBlend+KWINCOLORS] = colors[ TitleBar+KWINCOLORS ];
else
colors[TitleBlend+KWINCOLORS] = colors[ TitleBar+KWINCOLORS ].dark(150);
colors[TitleBlend+KWINCOLORS] =
config->readColorEntry("inactiveBlend", &colors[TitleBlend+KWINCOLORS]);
colors[ButtonBg+KWINCOLORS] = colors[Frame+KWINCOLORS];
colors[ButtonBg+KWINCOLORS] =
config->readColorEntry("inactiveTitleBtnBg",
&colors[ButtonBg]);
if(QPixmap::defaultDepth() < 15)
colors[ButtonBlend+KWINCOLORS] = colors[ ButtonBg+KWINCOLORS ];
else
colors[ButtonBlend+KWINCOLORS] = colors[ ButtonBg+KWINCOLORS ].dark(150);
colors[ButtonBlend+KWINCOLORS] =
config->readColorEntry("inactiveTitleBtnBlend",
&colors[ButtonBlend+KWINCOLORS]);
colors[ButtonFg+KWINCOLORS] = config->
readColorEntry("inactiveTitleBtnFg", &colors[ButtonFg]);
colors[Handle+KWINCOLORS] = colors[Frame];
config->readColorEntry("inactiveHandle", &colors[Handle]);
colors[Font+KWINCOLORS] = Qt::darkGray;
colors[Font+KWINCOLORS] = config->readColorEntry("inactiveForeground",
&colors[Font+KWINCOLORS]);
activeFont = QFont("Helvetica", 12, QFont::Bold);
activeFont = config->readFontEntry("activeFont", &activeFont);
inactiveFont = config->readFontEntry("inactiveFont", &activeFont);
int i;
for(i=0; i < KWINCOLORS*2; ++i){
if(cg[i]){
delete cg[i];
cg[i] = NULL;
}
}
//CT well, what this costs us?
config->setGroup("Actions");
QString val;
val = config->readEntry("Placement","Smart");
if (val == "Smart") placement = Smart;
else if (val == "Random") placement = Random;
else if (val == "Cascade") placement = Cascade;
animate_shade = config->readBoolEntry("AnimateShade", true);
anim_steps = config->readNumEntry("AnimSteps", 100);
}