1999-10-09 09:55:16 +00:00
|
|
|
#include "options.h"
|
1999-10-10 03:22:21 +00:00
|
|
|
#include <qpalette.h>
|
1999-11-07 15:48:24 +00:00
|
|
|
#include <qpixmap.h>
|
1999-10-10 03:22:21 +00:00
|
|
|
#include <qapplication.h>
|
|
|
|
#include <kconfig.h>
|
|
|
|
#include <kglobal.h>
|
1999-10-09 09:55:16 +00:00
|
|
|
|
1999-10-11 02:00:06 +00:00
|
|
|
Options::Options()
|
|
|
|
{
|
|
|
|
int i;
|
|
|
|
for(i=0; i < KWINCOLORS*2; ++i)
|
|
|
|
cg[i] = NULL;
|
1999-10-10 03:22:21 +00:00
|
|
|
reload();
|
|
|
|
}
|
|
|
|
|
1999-10-11 02:00:06 +00:00
|
|
|
Options::~Options(){
|
|
|
|
int i;
|
|
|
|
for(i=0; i < KWINCOLORS*2; ++i){
|
|
|
|
if(cg[i]){
|
|
|
|
delete cg[i];
|
|
|
|
cg[i] = NULL;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
1999-10-10 03:22:21 +00:00
|
|
|
const QColor& Options::color(ColorType type, bool active)
|
|
|
|
{
|
|
|
|
return(colors[type + (active ? 0 : KWINCOLORS)]);
|
|
|
|
}
|
|
|
|
|
|
|
|
const QFont& Options::font(bool active)
|
|
|
|
{
|
|
|
|
return(active ? activeFont : inactiveFont);
|
|
|
|
}
|
|
|
|
|
1999-10-11 02:00:06 +00:00
|
|
|
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().
|
1999-11-07 15:48:24 +00:00
|
|
|
base());
|
1999-10-11 02:00:06 +00:00
|
|
|
return(*cg[idx]);
|
|
|
|
}
|
1999-10-10 03:22:21 +00:00
|
|
|
|
|
|
|
void Options::reload()
|
|
|
|
{
|
1999-10-09 09:55:16 +00:00
|
|
|
focusPolicy = ClickToFocus;
|
|
|
|
resizeMode = Opaque;
|
1999-11-01 23:41:44 +00:00
|
|
|
moveMode = Opaque;// Transparent;
|
1999-10-10 03:22:21 +00:00
|
|
|
|
|
|
|
QPalette pal = QApplication::palette();
|
|
|
|
KConfig *config = KGlobal::config();
|
|
|
|
config->setGroup("WM");
|
|
|
|
|
|
|
|
// normal colors
|
|
|
|
colors[Frame] = Qt::lightGray;
|
|
|
|
colors[Frame] = config->readColorEntry("frame", &colors[Frame]);
|
1999-11-07 01:43:06 +00:00
|
|
|
colors[Handle] = QColor( 140, 140, 140 );
|
|
|
|
colors[Handle] = config->readColorEntry("handle", &colors[Handle]);
|
1999-11-07 15:48:24 +00:00
|
|
|
colors[ButtonBg] = colors[Frame];
|
1999-10-11 02:00:06 +00:00
|
|
|
colors[ButtonBg] = config->readColorEntry("buttonBackgroundDown",
|
1999-10-10 03:22:21 +00:00
|
|
|
&colors[Frame]);
|
1999-11-07 15:48:24 +00:00
|
|
|
if(QPixmap::defaultDepth() < 15)
|
|
|
|
colors[ButtonBlend] = colors[ ButtonBg ];
|
|
|
|
else
|
|
|
|
colors[ButtonBlend] = colors[ ButtonBg ].dark(150);
|
1999-10-11 02:00:06 +00:00
|
|
|
colors[ButtonBlend] = config->readColorEntry("buttonBlendDown",
|
1999-11-07 01:43:06 +00:00
|
|
|
&colors[ButtonBlend]);
|
1999-10-10 03:22:21 +00:00
|
|
|
colors[TitleBar] = Qt::darkBlue;
|
|
|
|
colors[TitleBar] = config->readColorEntry("activeBackground",
|
|
|
|
&colors[TitleBar]);
|
1999-11-07 15:48:24 +00:00
|
|
|
if(QPixmap::defaultDepth() < 15)
|
|
|
|
colors[TitleBlend] = colors[ TitleBar ];
|
|
|
|
else
|
|
|
|
colors[TitleBlend] = colors[ TitleBar ].dark(150);
|
1999-10-10 03:22:21 +00:00
|
|
|
colors[TitleBlend] = config->readColorEntry("activeBlend",
|
1999-11-07 01:43:06 +00:00
|
|
|
&colors[TitleBlend]);
|
1999-10-10 03:22:21 +00:00
|
|
|
|
|
|
|
colors[Font] = Qt::white;
|
|
|
|
colors[Font] = config->readColorEntry("activeForeground", &colors[Font]);
|
1999-11-07 15:48:24 +00:00
|
|
|
colors[ButtonFg] = Qt::darkGray;
|
1999-10-11 02:00:06 +00:00
|
|
|
colors[ButtonFg] = config->readColorEntry("buttonForegroundDown",
|
1999-10-10 03:22:21 +00:00
|
|
|
&colors[ButtonFg]);
|
|
|
|
|
|
|
|
// inactive
|
1999-11-07 15:48:24 +00:00
|
|
|
colors[Frame+KWINCOLORS] = config->readColorEntry("inactiveFrame",
|
|
|
|
&colors[Frame]);
|
1999-11-09 13:20:09 +00:00
|
|
|
colors[TitleBar+KWINCOLORS] = colors[Frame];
|
1999-10-10 03:22:21 +00:00
|
|
|
colors[TitleBar+KWINCOLORS] = config->
|
|
|
|
readColorEntry("inactiveBackground", &colors[TitleBar+KWINCOLORS]);
|
1999-11-07 15:48:24 +00:00
|
|
|
|
|
|
|
if(QPixmap::defaultDepth() < 15)
|
|
|
|
colors[TitleBlend+KWINCOLORS] = colors[ TitleBar+KWINCOLORS ];
|
|
|
|
else
|
|
|
|
colors[TitleBlend+KWINCOLORS] = colors[ TitleBar+KWINCOLORS ].dark(150);
|
1999-10-10 03:22:21 +00:00
|
|
|
colors[TitleBlend+KWINCOLORS] =
|
1999-11-07 15:48:24 +00:00
|
|
|
config->readColorEntry("inactiveBlend", &colors[TitleBlend+KWINCOLORS]);
|
|
|
|
|
|
|
|
colors[ButtonBg+KWINCOLORS] = colors[Frame+KWINCOLORS];
|
1999-10-10 03:22:21 +00:00
|
|
|
colors[ButtonBg+KWINCOLORS] =
|
1999-10-11 02:00:06 +00:00
|
|
|
config->readColorEntry("buttonBackground",
|
|
|
|
&colors[ButtonBg]);
|
1999-11-07 15:48:24 +00:00
|
|
|
|
|
|
|
if(QPixmap::defaultDepth() < 15)
|
|
|
|
colors[ButtonBlend+KWINCOLORS] = colors[ ButtonBg+KWINCOLORS ];
|
|
|
|
else
|
|
|
|
colors[ButtonBlend+KWINCOLORS] = colors[ ButtonBg+KWINCOLORS ].dark(150);
|
1999-10-10 03:22:21 +00:00
|
|
|
colors[ButtonBlend+KWINCOLORS] =
|
1999-11-07 15:48:24 +00:00
|
|
|
config->readColorEntry("buttonBlend", &colors[ButtonBlend+KWINCOLORS]);
|
|
|
|
|
1999-10-11 02:00:06 +00:00
|
|
|
colors[ButtonFg+KWINCOLORS] = config->
|
|
|
|
readColorEntry("buttonForeground", &colors[ButtonFg]);
|
|
|
|
|
|
|
|
colors[Handle+KWINCOLORS] =
|
|
|
|
config->readColorEntry("inactiveHandle", &colors[Handle]);
|
1999-10-10 03:22:21 +00:00
|
|
|
|
1999-11-07 15:48:24 +00:00
|
|
|
colors[Font+KWINCOLORS] = Qt::darkGray;
|
1999-10-10 03:22:21 +00:00
|
|
|
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);
|
1999-10-11 02:00:06 +00:00
|
|
|
|
|
|
|
int i;
|
|
|
|
for(i=0; i < KWINCOLORS*2; ++i){
|
|
|
|
if(cg[i]){
|
|
|
|
delete cg[i];
|
|
|
|
cg[i] = NULL;
|
|
|
|
}
|
|
|
|
}
|
1999-10-09 09:55:16 +00:00
|
|
|
}
|