2007-06-15 20:48:52 +00:00
|
|
|
//////////////////////////////////////////////////////////////////////////////
|
|
|
|
// oxygenbutton.h
|
|
|
|
// -------------------
|
|
|
|
// Oxygen window decoration for KDE.
|
|
|
|
// -------------------
|
2007-11-02 15:30:53 +00:00
|
|
|
// Copyright (c) 2006, 2007 Riccardo Iaconelli <riccardo@kde.org>
|
2007-06-15 20:48:52 +00:00
|
|
|
//
|
|
|
|
// Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
|
|
// of this software and associated documentation files (the "Software"), to
|
|
|
|
// deal in the Software without restriction, including without limitation the
|
|
|
|
// rights to use, copy, modify, merge, publish, distribute, sublicense, and/or
|
|
|
|
// sell copies of the Software, and to permit persons to whom the Software is
|
|
|
|
// furnished to do so, subject to the following conditions:
|
|
|
|
//
|
|
|
|
// The above copyright notice and this permission notice shall be included in
|
|
|
|
// all copies or substantial portions of the Software.
|
|
|
|
//
|
|
|
|
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
|
|
// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
|
|
// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
|
|
// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
|
|
// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
|
|
|
|
// FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS
|
|
|
|
// IN THE SOFTWARE.
|
|
|
|
//////////////////////////////////////////////////////////////////////////////
|
|
|
|
|
|
|
|
#include "oxygenclient.h"
|
|
|
|
#include "oxygen.h"
|
2007-10-05 22:21:25 +00:00
|
|
|
#include <kconfiggroup.h>
|
|
|
|
|
2007-06-15 20:48:52 +00:00
|
|
|
extern "C"
|
|
|
|
{
|
|
|
|
KDE_EXPORT KDecorationFactory* create_factory()
|
|
|
|
{
|
|
|
|
return new Oxygen::OxygenFactory();
|
|
|
|
}
|
|
|
|
}
|
|
|
|
namespace Oxygen
|
|
|
|
{
|
|
|
|
|
|
|
|
|
|
|
|
//////////////////////////////////////////////////////////////////////////////
|
|
|
|
// OxygenFactory Class //
|
|
|
|
//////////////////////////////////////////////////////////////////////////////
|
|
|
|
|
|
|
|
bool OxygenFactory::initialized_ = false;
|
2007-09-26 19:35:55 +00:00
|
|
|
Qt::Alignment OxygenFactory::titlealign_ = Qt::AlignLeft;
|
2007-06-15 20:48:52 +00:00
|
|
|
|
|
|
|
//////////////////////////////////////////////////////////////////////////////
|
|
|
|
// OxygenFactory()
|
|
|
|
// ----------------
|
|
|
|
// Constructor
|
|
|
|
|
|
|
|
OxygenFactory::OxygenFactory()
|
|
|
|
{
|
|
|
|
readConfig();
|
|
|
|
initialized_ = true;
|
|
|
|
}
|
|
|
|
|
|
|
|
//////////////////////////////////////////////////////////////////////////////
|
|
|
|
// ~OxygenFactory()
|
|
|
|
// -----------------
|
|
|
|
// Destructor
|
|
|
|
|
|
|
|
OxygenFactory::~OxygenFactory() { initialized_ = false; }
|
|
|
|
|
|
|
|
//////////////////////////////////////////////////////////////////////////////
|
|
|
|
// createDecoration()
|
|
|
|
// -----------------
|
|
|
|
// Create the decoration
|
|
|
|
|
|
|
|
KDecoration* OxygenFactory::createDecoration(KDecorationBridge* b)
|
|
|
|
{
|
2007-11-29 14:11:02 +00:00
|
|
|
return (new OxygenClient(b, this))->decoration();
|
2007-06-15 20:48:52 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
//////////////////////////////////////////////////////////////////////////////
|
|
|
|
// reset()
|
|
|
|
// -------
|
|
|
|
// Reset the handler. Returns true if decorations need to be remade, false if
|
|
|
|
// only a repaint is necessary
|
|
|
|
|
|
|
|
bool OxygenFactory::reset(unsigned long changed)
|
|
|
|
{
|
|
|
|
// read in the configuration
|
|
|
|
initialized_ = false;
|
|
|
|
bool confchange = readConfig();
|
|
|
|
initialized_ = true;
|
|
|
|
|
|
|
|
if (confchange ||
|
|
|
|
(changed & (SettingDecoration | SettingButtons | SettingBorder))) {
|
|
|
|
return true;
|
|
|
|
} else {
|
|
|
|
resetDecorations(changed);
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
//////////////////////////////////////////////////////////////////////////////
|
|
|
|
// readConfig()
|
|
|
|
// ------------
|
|
|
|
// Read in the configuration file
|
|
|
|
|
|
|
|
bool OxygenFactory::readConfig()
|
|
|
|
{
|
|
|
|
// create a config object
|
|
|
|
KConfig config("kwinexamplerc");
|
2007-06-16 10:59:08 +00:00
|
|
|
KConfigGroup group = config.group("General");
|
2007-06-15 20:48:52 +00:00
|
|
|
|
|
|
|
// grab settings
|
|
|
|
Qt::Alignment oldalign = titlealign_;
|
2007-09-26 19:35:55 +00:00
|
|
|
QString value = group.readEntry("TitleAlignment", "AlignLeft");
|
2007-06-15 20:48:52 +00:00
|
|
|
if (value == "AlignLeft") titlealign_ = Qt::AlignLeft;
|
|
|
|
else if (value == "AlignHCenter") titlealign_ = Qt::AlignHCenter;
|
|
|
|
else if (value == "AlignRight") titlealign_ = Qt::AlignRight;
|
|
|
|
|
|
|
|
if (oldalign == titlealign_)
|
|
|
|
return false;
|
|
|
|
else
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
|
2007-11-02 16:28:27 +00:00
|
|
|
bool OxygenFactory::supports( Ability ability ) const
|
|
|
|
{
|
|
|
|
switch( ability ) {
|
2007-11-29 17:14:26 +00:00
|
|
|
// announce
|
2007-11-02 16:28:27 +00:00
|
|
|
case AbilityAnnounceButtons:
|
2007-11-29 17:14:26 +00:00
|
|
|
case AbilityAnnounceColors:
|
|
|
|
// buttons
|
2007-11-02 16:28:27 +00:00
|
|
|
case AbilityButtonMenu:
|
|
|
|
case AbilityButtonHelp:
|
|
|
|
case AbilityButtonMinimize:
|
|
|
|
case AbilityButtonMaximize:
|
|
|
|
case AbilityButtonClose:
|
|
|
|
return true;
|
2007-11-29 17:14:26 +00:00
|
|
|
// no colors supported at this time
|
2007-11-02 16:28:27 +00:00
|
|
|
default:
|
|
|
|
return false;
|
|
|
|
};
|
|
|
|
}
|
2007-06-15 20:48:52 +00:00
|
|
|
|
|
|
|
} //namespace Oxygen
|