summaryrefslogtreecommitdiffstats
path: root/malloryclient/malloryhandler.cpp
blob: d63618dc3f4fdb2733d8335604883575fc2edeac (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
//
// C++ Implementation: malloryhandler
//
// Description:
//
//
// Author: Remi Villatel <maxilys@tele2.fr>, (C) 2005
//
// Copyright: See COPYING file that comes with this distribution
//
//

#include "malloryhandler.h"
#include "malloryclient.h"
#include "pixmaps.h"
#include "embeddata.h"

bool MalloryHandler::m_initialized = false;
int MalloryHandler::m_titleSize = 22;
int MalloryHandler::m_buttonSize = 18;
int MalloryHandler::m_borderSize = 5;
int MalloryHandler::m_buttonSpacing = 2;
bool MalloryHandler::m_lessRounded = false;
int MalloryHandler::m_buttonStyle = 0;
bool MalloryHandler::m_resizeHandle = true;
bool MalloryHandler::m_superSize = true;
bool MalloryHandler::m_titleShadow = true;
int MalloryHandler::m_titleShadowSize = 2;

MalloryHandler::MalloryHandler()
{
	reset(0);
}

MalloryHandler::~MalloryHandler()
{
	Pixmaps::deletePixmaps();
	qCleanupImages_KWinMallory();
	m_initialized = false;
}

bool MalloryHandler::reset(unsigned long) // unsigned long changed
{
	readConfig();

	Pixmaps::deletePixmaps();
	Pixmaps::createPixmaps();
	qInitImages_KWinMallory();

	m_initialized = true;
	return true;
}

KDecoration* MalloryHandler::createDecoration(KDecorationBridge *bridge)
{
	return new MalloryClient(bridge, this);
}

void MalloryHandler::readConfig()
{
	TDEConfig config("twinmalloryrc");
	config.setGroup("General");

	m_titleShadow = config.readBoolEntry("TitleShadow", true);
	m_lessRounded = config.readBoolEntry("LessRounded", false);
	m_resizeHandle = config.readBoolEntry("ResizeHandle", true);
	m_superSize = config.readBoolEntry("SuperSize", true);

	m_borderSize = config.readNumEntry("BorderSize", 5);
	if (m_borderSize < 5) m_borderSize = 5;
	if (m_borderSize > 10) m_borderSize = 10;

	m_titleSize = config.readNumEntry("TitleSize", 22);
	if (m_titleSize < 22) m_titleSize = 22;
	if (m_titleSize > 44) m_titleSize = 44;

	m_buttonSize = config.readNumEntry("ButtonSize", 18);
	if (m_buttonSize < 18) m_buttonSize = 18;
	if (m_buttonSize > (m_titleSize-4)) m_buttonSize = (m_titleSize-4);

	m_buttonStyle = config.readNumEntry("ButtonStyle", 0);
	if (m_buttonStyle < 0) m_buttonStyle = 0;
	if (m_buttonStyle > 1) m_buttonStyle = 1;

	m_titleShadowSize = config.readNumEntry("TitleShadowSize", 1);
	if (m_titleShadowSize < 1) m_titleShadowSize = 1;
	if (m_titleShadowSize > 3) m_titleShadowSize = 3;

	// MXLS: Keep this for another time.  ;-)
	/*m_buttonSpacing = config.readNumEntry("ButtonSpacing", 2);
	if (m_buttonSpacing < 0) m_buttonSpacing = 0;
	if (m_buttonSpacing > 5) m_buttonSpacing = 5;*/
}

#include "malloryhandler.moc"