|
Packit Bot |
052d53 |
/*************************************************************************
|
|
Packit Bot |
052d53 |
* Copyright (C) 2014 by Hugo Pereira Da Costa <hugo.pereira@free.fr> *
|
|
Packit Bot |
052d53 |
* *
|
|
Packit Bot |
052d53 |
* This program is free software; you can redistribute it and/or modify *
|
|
Packit Bot |
052d53 |
* it under the terms of the GNU General Public License as published by *
|
|
Packit Bot |
052d53 |
* the Free Software Foundation; either version 2 of the License, or *
|
|
Packit Bot |
052d53 |
* (at your option) any later version. *
|
|
Packit Bot |
052d53 |
* *
|
|
Packit Bot |
052d53 |
* This program is distributed in the hope that it will be useful, *
|
|
Packit Bot |
052d53 |
* but WITHOUT ANY WARRANTY; without even the implied warranty of *
|
|
Packit Bot |
052d53 |
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the *
|
|
Packit Bot |
052d53 |
* GNU General Public License for more details. *
|
|
Packit Bot |
052d53 |
* *
|
|
Packit Bot |
052d53 |
* You should have received a copy of the GNU General Public License *
|
|
Packit Bot |
052d53 |
* along with this program; if not, write to the *
|
|
Packit Bot |
052d53 |
* Free Software Foundation, Inc., *
|
|
Packit Bot |
052d53 |
* 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA . *
|
|
Packit Bot |
052d53 |
*************************************************************************/
|
|
Packit Bot |
052d53 |
|
|
Packit Bot |
052d53 |
#ifndef ADWAITA_SPINBOX_ENGINE_H
|
|
Packit Bot |
052d53 |
#define ADWAITA_SPINBOX_ENGINE_H
|
|
Packit Bot |
052d53 |
|
|
Packit Bot |
052d53 |
#include "adwaitabaseengine.h"
|
|
Packit Bot |
052d53 |
#include "adwaitadatamap.h"
|
|
Packit Bot |
052d53 |
#include "adwaitaspinboxdata.h"
|
|
Packit Bot |
052d53 |
#include "adwaitaqt_export.h"
|
|
Packit Bot |
052d53 |
|
|
Packit Bot |
052d53 |
namespace Adwaita
|
|
Packit Bot |
052d53 |
{
|
|
Packit Bot |
052d53 |
//* handle spinbox arrows hover effect
|
|
Packit Bot |
052d53 |
class ADWAITAQT_EXPORT SpinBoxEngine : public BaseEngine
|
|
Packit Bot |
052d53 |
{
|
|
Packit Bot |
052d53 |
Q_OBJECT
|
|
Packit Bot |
052d53 |
public:
|
|
Packit Bot |
052d53 |
//* constructor
|
|
Packit Bot |
052d53 |
explicit SpinBoxEngine(QObject *parent)
|
|
Packit Bot |
052d53 |
: BaseEngine(parent)
|
|
Packit Bot |
052d53 |
{
|
|
Packit Bot |
052d53 |
}
|
|
Packit Bot |
052d53 |
|
|
Packit Bot |
052d53 |
//* destructor
|
|
Packit Bot |
052d53 |
virtual ~SpinBoxEngine()
|
|
Packit Bot |
052d53 |
{
|
|
Packit Bot |
052d53 |
}
|
|
Packit Bot |
052d53 |
|
|
Packit Bot |
052d53 |
//* register widget
|
|
Packit Bot |
052d53 |
virtual bool registerWidget(QWidget *);
|
|
Packit Bot |
052d53 |
|
|
Packit Bot |
052d53 |
//* state
|
|
Packit Bot |
052d53 |
virtual bool updateState(const QObject *object, QStyle::SubControl subControl, bool value, bool pressed)
|
|
Packit Bot |
052d53 |
{
|
|
Packit Bot |
052d53 |
if (DataMap<SpinBoxData>::Value data = _data.find(object)) {
|
|
Packit Bot |
052d53 |
return data.data()->updateState(subControl, value, pressed);
|
|
Packit Bot |
052d53 |
} else {
|
|
Packit Bot |
052d53 |
return false;
|
|
Packit Bot |
052d53 |
}
|
|
Packit Bot |
052d53 |
}
|
|
Packit Bot |
052d53 |
|
|
Packit Bot |
052d53 |
//* true if widget is animated
|
|
Packit Bot |
052d53 |
virtual bool isAnimated(const QObject *object, QStyle::SubControl subControl)
|
|
Packit Bot |
052d53 |
{
|
|
Packit Bot |
052d53 |
if (DataMap<SpinBoxData>::Value data = _data.find(object)) {
|
|
Packit Bot |
052d53 |
return data.data()->isAnimated(subControl);
|
|
Packit Bot |
052d53 |
} else {
|
|
Packit Bot |
052d53 |
return false;
|
|
Packit Bot |
052d53 |
}
|
|
Packit Bot |
052d53 |
}
|
|
Packit Bot |
052d53 |
|
|
Packit Bot |
052d53 |
//* animation opacity
|
|
Packit Bot |
052d53 |
virtual qreal opacity(const QObject *object, QStyle::SubControl subControl)
|
|
Packit Bot |
052d53 |
{
|
|
Packit Bot |
052d53 |
if (DataMap<SpinBoxData>::Value data = _data.find(object)) {
|
|
Packit Bot |
052d53 |
return data.data()->opacity(subControl);
|
|
Packit Bot |
052d53 |
} else {
|
|
Packit Bot |
052d53 |
return AnimationData::OpacityInvalid;
|
|
Packit Bot |
052d53 |
}
|
|
Packit Bot |
052d53 |
}
|
|
Packit Bot |
052d53 |
|
|
Packit Bot |
052d53 |
//* animation opacity
|
|
Packit Bot |
052d53 |
virtual qreal pressed(const QObject *object, QStyle::SubControl subControl)
|
|
Packit Bot |
052d53 |
{
|
|
Packit Bot |
052d53 |
if (DataMap<SpinBoxData>::Value data = _data.find(object)) {
|
|
Packit Bot |
052d53 |
return data.data()->pressed(subControl);
|
|
Packit Bot |
052d53 |
} else {
|
|
Packit Bot |
052d53 |
return AnimationData::OpacityInvalid;
|
|
Packit Bot |
052d53 |
}
|
|
Packit Bot |
052d53 |
}
|
|
Packit Bot |
052d53 |
|
|
Packit Bot |
052d53 |
//* enability
|
|
Packit Bot |
052d53 |
virtual void setEnabled(bool value)
|
|
Packit Bot |
052d53 |
{
|
|
Packit Bot |
052d53 |
BaseEngine::setEnabled(value);
|
|
Packit Bot |
052d53 |
_data.setEnabled(value);
|
|
Packit Bot |
052d53 |
}
|
|
Packit Bot |
052d53 |
|
|
Packit Bot |
052d53 |
//* duration
|
|
Packit Bot |
052d53 |
virtual void setDuration(int value)
|
|
Packit Bot |
052d53 |
{
|
|
Packit Bot |
052d53 |
BaseEngine::setDuration(value);
|
|
Packit Bot |
052d53 |
_data.setDuration(value);
|
|
Packit Bot |
052d53 |
}
|
|
Packit Bot |
052d53 |
|
|
Packit Bot |
052d53 |
public Q_SLOTS:
|
|
Packit Bot |
052d53 |
|
|
Packit Bot |
052d53 |
//* remove widget from map
|
|
Packit Bot |
052d53 |
virtual bool unregisterWidget(QObject *object)
|
|
Packit Bot |
052d53 |
{
|
|
Packit Bot |
052d53 |
return _data.unregisterWidget(object);
|
|
Packit Bot |
052d53 |
}
|
|
Packit Bot |
052d53 |
|
|
Packit Bot |
052d53 |
private:
|
|
Packit Bot |
052d53 |
//* data map
|
|
Packit Bot |
052d53 |
DataMap<SpinBoxData> _data;
|
|
Packit Bot |
052d53 |
};
|
|
Packit Bot |
052d53 |
|
|
Packit Bot |
052d53 |
} // namespace Adwaita
|
|
Packit Bot |
052d53 |
|
|
Packit Bot |
052d53 |
#endif // ADWAITA_SPINBOX_ENGINE_H
|