Make a branch to make krunner Good Enough For Aaron™.
[kdebase/uwolfer.git] / workspace / kwin / clients / oxygen / oxygen.cpp
blobc030f764403e31ada562a32d4a3f120672d3e3b3
1 //////////////////////////////////////////////////////////////////////////////
2 // oxygenbutton.h
3 // -------------------
4 // Oxygen window decoration for KDE.
5 // -------------------
6 // Copyright (c) 2006, 2007 Riccardo Iaconelli <riccardo@kde.org>
7 //
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
24 // IN THE SOFTWARE.
25 //////////////////////////////////////////////////////////////////////////////
27 #include "oxygenclient.h"
28 #include "oxygen.h"
29 #include <kconfiggroup.h>
31 extern "C"
33 KDE_EXPORT KDecorationFactory* create_factory()
35 return new Oxygen::OxygenFactory();
38 namespace Oxygen
42 //////////////////////////////////////////////////////////////////////////////
43 // OxygenFactory Class //
44 //////////////////////////////////////////////////////////////////////////////
46 bool OxygenFactory::initialized_ = false;
47 Qt::Alignment OxygenFactory::titlealign_ = Qt::AlignLeft;
49 //////////////////////////////////////////////////////////////////////////////
50 // OxygenFactory()
51 // ----------------
52 // Constructor
54 OxygenFactory::OxygenFactory()
56 readConfig();
57 initialized_ = true;
60 //////////////////////////////////////////////////////////////////////////////
61 // ~OxygenFactory()
62 // -----------------
63 // Destructor
65 OxygenFactory::~OxygenFactory() { initialized_ = false; }
67 //////////////////////////////////////////////////////////////////////////////
68 // createDecoration()
69 // -----------------
70 // Create the decoration
72 KDecoration* OxygenFactory::createDecoration(KDecorationBridge* b)
74 return (new OxygenClient(b, this))->decoration();
77 //////////////////////////////////////////////////////////////////////////////
78 // reset()
79 // -------
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
86 initialized_ = false;
87 bool confchange = readConfig();
88 initialized_ = true;
90 if (confchange ||
91 (changed & (SettingDecoration | SettingButtons | SettingBorder))) {
92 return true;
93 } else {
94 resetDecorations(changed);
95 return false;
99 //////////////////////////////////////////////////////////////////////////////
100 // readConfig()
101 // ------------
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");
110 // grab settings
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_)
118 return false;
119 else
120 return true;
123 bool OxygenFactory::supports( Ability ability ) const
125 switch( ability ) {
126 // announce
127 case AbilityAnnounceButtons:
128 case AbilityAnnounceColors:
129 // buttons
130 case AbilityButtonMenu:
131 case AbilityButtonHelp:
132 case AbilityButtonMinimize:
133 case AbilityButtonMaximize:
134 case AbilityButtonClose:
135 // case AbilityButtonAboveOthers:
136 // case AbilityButtonBelowOthers:
137 case AbilityButtonSpacer:
138 return true;
139 // no colors supported at this time
140 default:
141 return false;
145 } //namespace Oxygen