QTfrontend/ui/widget/colorwidget.h
author unc0rr
Sun, 27 May 2012 23:42:43 +0400
changeset 7130 fcab1fd02bc6
child 7749 edad8a7bcaea
permissions -rw-r--r--
- Allow switching colors with mouse wheel - Use indices instead of color values - Introduce a model for colors - Some small fixes, .pro can be used to build again - Yay, tested it to work via network (and fixed a bug!) (TODO: pass colors to engine by index)
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
7130
fcab1fd02bc6 - Allow switching colors with mouse wheel
unc0rr
parents:
diff changeset
     1
#ifndef COLORWIDGET_H
fcab1fd02bc6 - Allow switching colors with mouse wheel
unc0rr
parents:
diff changeset
     2
#define COLORWIDGET_H
fcab1fd02bc6 - Allow switching colors with mouse wheel
unc0rr
parents:
diff changeset
     3
fcab1fd02bc6 - Allow switching colors with mouse wheel
unc0rr
parents:
diff changeset
     4
#include <QWidget>
fcab1fd02bc6 - Allow switching colors with mouse wheel
unc0rr
parents:
diff changeset
     5
#include <QModelIndex>
fcab1fd02bc6 - Allow switching colors with mouse wheel
unc0rr
parents:
diff changeset
     6
fcab1fd02bc6 - Allow switching colors with mouse wheel
unc0rr
parents:
diff changeset
     7
namespace Ui {
fcab1fd02bc6 - Allow switching colors with mouse wheel
unc0rr
parents:
diff changeset
     8
class ColorWidget;
fcab1fd02bc6 - Allow switching colors with mouse wheel
unc0rr
parents:
diff changeset
     9
}
fcab1fd02bc6 - Allow switching colors with mouse wheel
unc0rr
parents:
diff changeset
    10
fcab1fd02bc6 - Allow switching colors with mouse wheel
unc0rr
parents:
diff changeset
    11
class QStandardItemModel;
fcab1fd02bc6 - Allow switching colors with mouse wheel
unc0rr
parents:
diff changeset
    12
fcab1fd02bc6 - Allow switching colors with mouse wheel
unc0rr
parents:
diff changeset
    13
class ColorWidget : public QWidget
fcab1fd02bc6 - Allow switching colors with mouse wheel
unc0rr
parents:
diff changeset
    14
{
fcab1fd02bc6 - Allow switching colors with mouse wheel
unc0rr
parents:
diff changeset
    15
    Q_OBJECT
fcab1fd02bc6 - Allow switching colors with mouse wheel
unc0rr
parents:
diff changeset
    16
    
fcab1fd02bc6 - Allow switching colors with mouse wheel
unc0rr
parents:
diff changeset
    17
public:
fcab1fd02bc6 - Allow switching colors with mouse wheel
unc0rr
parents:
diff changeset
    18
    explicit ColorWidget(QStandardItemModel *colorsModel, QWidget *parent = 0);
fcab1fd02bc6 - Allow switching colors with mouse wheel
unc0rr
parents:
diff changeset
    19
    ~ColorWidget();
fcab1fd02bc6 - Allow switching colors with mouse wheel
unc0rr
parents:
diff changeset
    20
fcab1fd02bc6 - Allow switching colors with mouse wheel
unc0rr
parents:
diff changeset
    21
    void setColors(QStandardItemModel * colorsModel);
fcab1fd02bc6 - Allow switching colors with mouse wheel
unc0rr
parents:
diff changeset
    22
    void setColor(int color);
fcab1fd02bc6 - Allow switching colors with mouse wheel
unc0rr
parents:
diff changeset
    23
    int getColor();
fcab1fd02bc6 - Allow switching colors with mouse wheel
unc0rr
parents:
diff changeset
    24
fcab1fd02bc6 - Allow switching colors with mouse wheel
unc0rr
parents:
diff changeset
    25
signals:
fcab1fd02bc6 - Allow switching colors with mouse wheel
unc0rr
parents:
diff changeset
    26
    void colorChanged(int color);
fcab1fd02bc6 - Allow switching colors with mouse wheel
unc0rr
parents:
diff changeset
    27
    
fcab1fd02bc6 - Allow switching colors with mouse wheel
unc0rr
parents:
diff changeset
    28
private:
fcab1fd02bc6 - Allow switching colors with mouse wheel
unc0rr
parents:
diff changeset
    29
    int m_color;
fcab1fd02bc6 - Allow switching colors with mouse wheel
unc0rr
parents:
diff changeset
    30
    QStandardItemModel * m_colorsModel;
fcab1fd02bc6 - Allow switching colors with mouse wheel
unc0rr
parents:
diff changeset
    31
fcab1fd02bc6 - Allow switching colors with mouse wheel
unc0rr
parents:
diff changeset
    32
private slots:
fcab1fd02bc6 - Allow switching colors with mouse wheel
unc0rr
parents:
diff changeset
    33
    void dataChanged(const QModelIndex &topLeft, const QModelIndex &bottomRight);
fcab1fd02bc6 - Allow switching colors with mouse wheel
unc0rr
parents:
diff changeset
    34
fcab1fd02bc6 - Allow switching colors with mouse wheel
unc0rr
parents:
diff changeset
    35
protected:
fcab1fd02bc6 - Allow switching colors with mouse wheel
unc0rr
parents:
diff changeset
    36
    void mousePressEvent(QMouseEvent * event);
fcab1fd02bc6 - Allow switching colors with mouse wheel
unc0rr
parents:
diff changeset
    37
    void wheelEvent(QWheelEvent * event);
fcab1fd02bc6 - Allow switching colors with mouse wheel
unc0rr
parents:
diff changeset
    38
};
fcab1fd02bc6 - Allow switching colors with mouse wheel
unc0rr
parents:
diff changeset
    39
fcab1fd02bc6 - Allow switching colors with mouse wheel
unc0rr
parents:
diff changeset
    40
#endif // COLORWIDGET_H