1 //////////////////////////////////////////////////////////////////////////////
4 // Oxygen window decoration for KDE.
6 // Copyright (c) 2006, 2007 Riccardo Iaconelli <riccardo@kde.org>
8 // Permission is hereby granted, free of charge, to any person obtaining a copy
9 // of this software and associated documentation files (the "Software"), to
10 // deal in the Software without restriction, including without limitation the
11 // rights to use, copy, modify, merge, publish, distribute, sublicense, and/or
12 // sell copies of the Software, and to permit persons to whom the Software is
13 // furnished to do so, subject to the following conditions:
15 // The above copyright notice and this permission notice shall be included in
16 // all copies or substantial portions of the Software.
18 // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
19 // IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
20 // FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
21 // AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
22 // LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
23 // FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS
25 //////////////////////////////////////////////////////////////////////////////
27 #include "oxygenclient.h"
29 #include <kconfiggroup.h>
33 KDE_EXPORT KDecorationFactory
* create_factory()
35 return new Oxygen::OxygenFactory();
42 //////////////////////////////////////////////////////////////////////////////
43 // OxygenFactory Class //
44 //////////////////////////////////////////////////////////////////////////////
46 bool OxygenFactory::initialized_
= false;
47 Qt::Alignment
OxygenFactory::titlealign_
= Qt::AlignLeft
;
49 //////////////////////////////////////////////////////////////////////////////
54 OxygenFactory::OxygenFactory()
60 //////////////////////////////////////////////////////////////////////////////
65 OxygenFactory::~OxygenFactory() { initialized_
= false; }
67 //////////////////////////////////////////////////////////////////////////////
70 // Create the decoration
72 KDecoration
* OxygenFactory::createDecoration(KDecorationBridge
* b
)
74 return (new OxygenClient(b
, this))->decoration();
77 //////////////////////////////////////////////////////////////////////////////
80 // Reset the handler. Returns true if decorations need to be remade, false if
81 // only a repaint is necessary
83 bool OxygenFactory::reset(unsigned long changed
)
85 // read in the configuration
87 bool confchange
= readConfig();
91 (changed
& (SettingDecoration
| SettingButtons
| SettingBorder
))) {
94 resetDecorations(changed
);
99 //////////////////////////////////////////////////////////////////////////////
102 // Read in the configuration file
104 bool OxygenFactory::readConfig()
106 // create a config object
107 KConfig
config("oxygenrc");
108 KConfigGroup group
= config
.group("Windeco");
111 Qt::Alignment oldalign
= titlealign_
;
112 QString value
= group
.readEntry("TitleAlignment", "AlignLeft");
113 if (value
== "AlignLeft") titlealign_
= Qt::AlignLeft
;
114 else if (value
== "AlignHCenter") titlealign_
= Qt::AlignHCenter
;
115 else if (value
== "AlignRight") titlealign_
= Qt::AlignRight
;
117 if (oldalign
== titlealign_
)
123 bool OxygenFactory::supports( Ability ability
) const
127 case AbilityAnnounceButtons
:
128 case AbilityAnnounceColors
:
130 case AbilityButtonMenu
:
131 case AbilityButtonHelp
:
132 case AbilityButtonMinimize
:
133 case AbilityButtonMaximize
:
134 case AbilityButtonClose
:
135 // case AbilityButtonAboveOthers:
136 // case AbilityButtonBelowOthers:
137 case AbilityButtonSpacer
:
139 // no colors supported at this time