2009-09-15 07:12:54 +00:00
|
|
|
#ifndef oxygenbutton_h
|
|
|
|
#define oxygenbutton_h
|
2009-08-22 08:24:06 +00:00
|
|
|
|
|
|
|
//////////////////////////////////////////////////////////////////////////////
|
2009-09-15 07:12:54 +00:00
|
|
|
// oxygenbutton.h
|
2009-08-22 08:24:06 +00:00
|
|
|
// -------------------
|
2009-09-09 00:55:55 +00:00
|
|
|
//
|
2009-08-24 15:43:15 +00:00
|
|
|
// Copyright (c) 2006, 2007 Riccardo Iaconelli <riccardo@kde.org>
|
|
|
|
// Copyright (c) 2006, 2007 Casper Boemann <cbr@boemann.dk>
|
|
|
|
// Copyright (c) 2009 Hugo Pereira Da Costa <hugo.pereira@free.fr>
|
|
|
|
//
|
2009-08-22 08:24:06 +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 <kcommondecoration.h>
|
|
|
|
|
2009-09-15 07:12:54 +00:00
|
|
|
#include "oxygen.h"
|
2009-11-17 21:56:04 +00:00
|
|
|
#include "lib/oxygenanimation.h"
|
2009-08-22 08:24:06 +00:00
|
|
|
|
2009-09-15 07:12:54 +00:00
|
|
|
namespace Oxygen
|
2009-08-22 08:24:06 +00:00
|
|
|
{
|
2009-09-15 07:12:54 +00:00
|
|
|
class OxygenClient;
|
2009-09-09 00:55:55 +00:00
|
|
|
|
2009-08-22 08:24:06 +00:00
|
|
|
enum ButtonStatus {
|
|
|
|
Normal,
|
|
|
|
Hovered,
|
2009-09-09 00:55:55 +00:00
|
|
|
Pressed
|
2009-08-22 08:24:06 +00:00
|
|
|
};
|
2009-09-09 00:55:55 +00:00
|
|
|
|
2009-08-22 08:24:06 +00:00
|
|
|
Q_DECLARE_FLAGS(ButtonState, ButtonStatus)
|
2009-09-09 00:55:55 +00:00
|
|
|
|
2009-09-15 07:12:54 +00:00
|
|
|
class OxygenButton : public KCommonDecorationButton
|
2009-08-22 08:24:06 +00:00
|
|
|
{
|
2009-10-14 15:36:38 +00:00
|
|
|
|
|
|
|
Q_OBJECT
|
|
|
|
|
2009-11-17 21:56:04 +00:00
|
|
|
//! declare animation progress property
|
|
|
|
Q_PROPERTY( qreal glowIntensity READ glowIntensity WRITE setGlowIntensity )
|
|
|
|
|
2009-08-22 08:24:06 +00:00
|
|
|
public:
|
2009-09-09 00:55:55 +00:00
|
|
|
|
2009-08-22 08:24:06 +00:00
|
|
|
//! constructor
|
2009-09-15 07:12:54 +00:00
|
|
|
explicit OxygenButton(OxygenClient &parent,
|
2009-08-22 08:24:06 +00:00
|
|
|
const QString &tip=NULL,
|
2009-10-15 16:03:30 +00:00
|
|
|
ButtonType type=ButtonHelp );
|
2009-09-09 00:55:55 +00:00
|
|
|
|
2009-08-22 08:24:06 +00:00
|
|
|
//! destructor
|
2009-09-15 07:12:54 +00:00
|
|
|
~OxygenButton();
|
2009-09-09 00:55:55 +00:00
|
|
|
|
2009-08-22 08:24:06 +00:00
|
|
|
//! destructor
|
|
|
|
QSize sizeHint() const;
|
2009-09-09 00:55:55 +00:00
|
|
|
|
2009-08-22 08:24:06 +00:00
|
|
|
//! button type
|
|
|
|
ButtonType type( void ) const
|
|
|
|
{ return type_; }
|
2009-09-09 00:55:55 +00:00
|
|
|
|
2009-10-14 15:36:38 +00:00
|
|
|
//! set force inactive
|
|
|
|
/*! returns true if value was actually changed */
|
|
|
|
void setForceInactive( const bool& value )
|
|
|
|
{ forceInactive_ = value; }
|
|
|
|
|
2009-11-15 03:24:04 +00:00
|
|
|
//! configuration reset
|
|
|
|
virtual void reset( unsigned long );
|
|
|
|
|
2009-11-17 21:56:04 +00:00
|
|
|
//!@name glow animation
|
|
|
|
//@{
|
|
|
|
|
|
|
|
//! return animation object
|
|
|
|
virtual const Animation::Pointer& glowAnimation() const
|
|
|
|
{ return glowAnimation_; }
|
|
|
|
|
|
|
|
void setGlowIntensity( qreal value )
|
|
|
|
{ glowIntensity_ = value; }
|
|
|
|
|
|
|
|
qreal glowIntensity( void ) const
|
|
|
|
{ return glowIntensity_; }
|
|
|
|
|
|
|
|
//@}
|
|
|
|
|
2009-08-22 08:24:06 +00:00
|
|
|
protected:
|
2009-09-09 00:55:55 +00:00
|
|
|
|
2009-08-22 08:24:06 +00:00
|
|
|
//! press event
|
|
|
|
void mousePressEvent(QMouseEvent* );
|
2009-09-09 00:55:55 +00:00
|
|
|
|
2009-08-22 08:24:06 +00:00
|
|
|
//! release event
|
|
|
|
void mouseReleaseEvent(QMouseEvent* );
|
2009-09-09 00:55:55 +00:00
|
|
|
|
2009-08-22 08:24:06 +00:00
|
|
|
//! enter event
|
|
|
|
void enterEvent( QEvent* );
|
2009-09-09 00:55:55 +00:00
|
|
|
|
2009-08-22 08:24:06 +00:00
|
|
|
//! leave event
|
|
|
|
void leaveEvent(QEvent* );
|
2009-09-09 00:55:55 +00:00
|
|
|
|
2009-08-22 08:24:06 +00:00
|
|
|
//! paint
|
|
|
|
void paintEvent(QPaintEvent* );
|
2009-09-09 00:55:55 +00:00
|
|
|
|
2009-08-22 08:24:06 +00:00
|
|
|
//! draw icon
|
|
|
|
void drawIcon(QPainter*, QPalette&, ButtonType& );
|
2009-09-09 00:55:55 +00:00
|
|
|
|
2009-08-22 08:24:06 +00:00
|
|
|
//! color
|
|
|
|
QColor buttonDetailColor(const QPalette& );
|
2009-09-09 00:55:55 +00:00
|
|
|
|
2009-09-19 21:12:57 +00:00
|
|
|
//! color
|
|
|
|
QColor buttonDetailColor(const QPalette&, bool active );
|
|
|
|
|
2009-11-17 21:56:04 +00:00
|
|
|
//! true if animation is in progress
|
|
|
|
bool isAnimated( void ) const
|
|
|
|
{ return glowAnimation().data()->isRunning(); }
|
2009-09-19 21:12:57 +00:00
|
|
|
|
2009-10-14 15:36:38 +00:00
|
|
|
//! true if button is active
|
|
|
|
bool isActive( void ) const;
|
|
|
|
|
2009-08-22 08:24:06 +00:00
|
|
|
private:
|
2009-09-09 00:55:55 +00:00
|
|
|
|
2009-08-22 08:24:06 +00:00
|
|
|
//! parent client
|
2009-10-11 20:30:38 +00:00
|
|
|
const OxygenClient &client_;
|
2009-09-09 00:55:55 +00:00
|
|
|
|
2009-08-22 08:24:06 +00:00
|
|
|
//! helper
|
2009-09-04 04:22:26 +00:00
|
|
|
OxygenHelper &helper_;
|
2009-09-09 00:55:55 +00:00
|
|
|
|
2009-08-22 08:24:06 +00:00
|
|
|
//! button type
|
|
|
|
ButtonType type_;
|
2009-09-09 00:55:55 +00:00
|
|
|
|
2009-08-22 08:24:06 +00:00
|
|
|
//! button status
|
|
|
|
ButtonState status_;
|
2009-09-09 00:55:55 +00:00
|
|
|
|
2009-10-14 15:36:38 +00:00
|
|
|
//! true if button should be forced inactive
|
|
|
|
bool forceInactive_;
|
|
|
|
|
2009-11-17 21:56:04 +00:00
|
|
|
//! glow animation
|
|
|
|
Animation::Pointer glowAnimation_;
|
|
|
|
|
|
|
|
//! glow intensity
|
|
|
|
qreal glowIntensity_;
|
|
|
|
|
2009-09-16 17:09:33 +00:00
|
|
|
|
2009-08-22 08:24:06 +00:00
|
|
|
};
|
2009-09-09 00:55:55 +00:00
|
|
|
|
2009-09-15 07:12:54 +00:00
|
|
|
} //namespace Oxygen
|
2009-08-22 08:24:06 +00:00
|
|
|
|
|
|
|
#endif
|