2012-05-25 23:02:10 +02:00
|
|
|
/* This file is part of Clementine.
|
|
|
|
Copyright 2012, David Sansome <me@davidsansome.com>
|
|
|
|
|
|
|
|
Clementine is free software: you can redistribute it and/or modify
|
|
|
|
it under the terms of the GNU General Public License as published by
|
|
|
|
the Free Software Foundation, either version 3 of the License, or
|
|
|
|
(at your option) any later version.
|
|
|
|
|
|
|
|
Clementine is distributed in the hope that it will be useful,
|
|
|
|
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
|
|
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
|
|
GNU General Public License for more details.
|
|
|
|
|
|
|
|
You should have received a copy of the GNU General Public License
|
|
|
|
along with Clementine. If not, see <http://www.gnu.org/licenses/>.
|
|
|
|
*/
|
|
|
|
|
|
|
|
#ifndef MOODBARPROXYSTYLE_H
|
|
|
|
#define MOODBARPROXYSTYLE_H
|
|
|
|
|
2012-05-26 00:56:55 +02:00
|
|
|
#include "moodbarrenderer.h"
|
|
|
|
|
2012-05-25 23:02:10 +02:00
|
|
|
#include <QProxyStyle>
|
|
|
|
|
2012-05-28 00:44:49 +02:00
|
|
|
class Application;
|
|
|
|
|
2012-05-28 13:50:07 +02:00
|
|
|
class QActionGroup;
|
|
|
|
class QMenu;
|
2012-05-25 23:02:10 +02:00
|
|
|
class QSlider;
|
|
|
|
class QStyleOptionSlider;
|
|
|
|
class QTimeLine;
|
|
|
|
|
|
|
|
class MoodbarProxyStyle : public QProxyStyle {
|
|
|
|
Q_OBJECT
|
|
|
|
|
|
|
|
public:
|
2012-05-28 00:44:49 +02:00
|
|
|
MoodbarProxyStyle(Application* app, QSlider* slider);
|
2012-05-25 23:02:10 +02:00
|
|
|
|
|
|
|
// QProxyStyle
|
|
|
|
void drawComplexControl(ComplexControl control, const QStyleOptionComplex* option,
|
|
|
|
QPainter* painter, const QWidget* widget) const;
|
2012-05-26 00:34:56 +02:00
|
|
|
QRect subControlRect(ComplexControl cc, const QStyleOptionComplex* opt,
|
|
|
|
SubControl sc, const QWidget* widget) const;
|
2012-05-25 23:02:10 +02:00
|
|
|
|
|
|
|
// QObject
|
|
|
|
bool eventFilter(QObject* object, QEvent* event);
|
|
|
|
|
|
|
|
public slots:
|
|
|
|
// An empty byte array means there's no moodbar, so just show a normal slider.
|
|
|
|
void SetMoodbarData(const QByteArray& data);
|
|
|
|
|
|
|
|
// If the moodbar is disabled then a normal slider will always be shown.
|
|
|
|
void SetMoodbarEnabled(bool enabled);
|
|
|
|
|
|
|
|
private:
|
2012-05-26 00:34:56 +02:00
|
|
|
static const int kMarginSize;
|
|
|
|
static const int kBorderSize;
|
|
|
|
static const int kArrowWidth;
|
|
|
|
static const int kArrowHeight;
|
2012-05-25 23:02:10 +02:00
|
|
|
|
|
|
|
enum State {
|
|
|
|
MoodbarOn,
|
|
|
|
MoodbarOff,
|
|
|
|
FadingToOn,
|
|
|
|
FadingToOff
|
|
|
|
};
|
|
|
|
|
|
|
|
private:
|
|
|
|
void NextState();
|
|
|
|
|
|
|
|
void Render(ComplexControl control, const QStyleOptionSlider* option,
|
|
|
|
QPainter* painter, const QWidget* widget);
|
|
|
|
void EnsureMoodbarRendered();
|
2012-05-26 00:34:56 +02:00
|
|
|
void DrawArrow(const QStyleOptionSlider* option, QPainter* painter) const;
|
2012-05-28 13:50:07 +02:00
|
|
|
void ShowContextMenu(const QPoint& pos);
|
2012-05-25 23:02:10 +02:00
|
|
|
|
2012-05-27 17:46:16 +02:00
|
|
|
static QPixmap MoodbarPixmap(const ColorVector& colors,
|
2012-05-26 00:56:55 +02:00
|
|
|
const QSize& size, const QPalette& palette);
|
2012-05-25 23:02:10 +02:00
|
|
|
|
|
|
|
private slots:
|
2012-05-28 00:44:49 +02:00
|
|
|
void ReloadSettings();
|
2012-05-25 23:02:10 +02:00
|
|
|
void FaderValueChanged(qreal value);
|
2012-05-28 13:50:07 +02:00
|
|
|
void ChangeStyle(QAction* action);
|
2012-05-25 23:02:10 +02:00
|
|
|
|
|
|
|
private:
|
2012-05-28 13:50:07 +02:00
|
|
|
Application* app_;
|
2012-05-25 23:02:10 +02:00
|
|
|
QSlider* slider_;
|
|
|
|
|
|
|
|
bool enabled_;
|
|
|
|
QByteArray data_;
|
2012-05-26 00:56:55 +02:00
|
|
|
MoodbarRenderer::MoodbarStyle moodbar_style_;
|
2012-05-25 23:02:10 +02:00
|
|
|
|
|
|
|
State state_;
|
|
|
|
QTimeLine* fade_timeline_;
|
|
|
|
|
|
|
|
QPixmap fade_source_;
|
|
|
|
QPixmap fade_target_;
|
|
|
|
|
|
|
|
bool moodbar_colors_dirty_;
|
|
|
|
bool moodbar_pixmap_dirty_;
|
2012-05-27 17:46:16 +02:00
|
|
|
ColorVector moodbar_colors_;
|
2012-05-25 23:02:10 +02:00
|
|
|
QPixmap moodbar_pixmap_;
|
2012-05-28 13:50:07 +02:00
|
|
|
|
|
|
|
QMenu* context_menu_;
|
|
|
|
QAction* show_moodbar_action_;
|
|
|
|
QActionGroup* style_action_group_;
|
2012-05-25 23:02:10 +02:00
|
|
|
};
|
|
|
|
|
|
|
|
#endif // MOODBARPROXYSTYLE_H
|