Convert ColorWidget from QWidget to QFrame and make use of The Box Model(tm) in stylesheet
--- a/QTfrontend/ui/widget/colorwidget.cpp Sat Oct 13 00:07:46 2012 +0400
+++ b/QTfrontend/ui/widget/colorwidget.cpp Sat Oct 13 00:35:20 2012 +0400
@@ -1,17 +1,17 @@
#include <QStandardItemModel>
#include <QMouseEvent>
#include <QWheelEvent>
+#include <QColor>
#include "colorwidget.h"
#include "hwconsts.h"
ColorWidget::ColorWidget(QStandardItemModel *colorsModel, QWidget *parent) :
- QWidget(parent)
+ QFrame(parent)
{
m_colorsModel = colorsModel;
setColor(0);
- setStyleSheet("");
setAutoFillBackground(true);
connect(m_colorsModel, SIGNAL(dataChanged(QModelIndex,QModelIndex)), this, SLOT(dataChanged(QModelIndex,QModelIndex)));
@@ -30,9 +30,12 @@
QStandardItem * item = m_colorsModel->item(m_color);
+ setStyleSheet(QString("border: 2px solid orange; border-radius: 8px; background: %1").arg(item->data().value<QColor>().name()));
+ /*
QPalette p = palette();
p.setColor(QPalette::Window, item->data().value<QColor>());
setPalette(p);
+ */
emit colorChanged(m_color);
}
--- a/QTfrontend/ui/widget/colorwidget.h Sat Oct 13 00:07:46 2012 +0400
+++ b/QTfrontend/ui/widget/colorwidget.h Sat Oct 13 00:35:20 2012 +0400
@@ -1,7 +1,7 @@
#ifndef COLORWIDGET_H
#define COLORWIDGET_H
-#include <QWidget>
+#include <QFrame>
#include <QModelIndex>
namespace Ui {
@@ -10,7 +10,7 @@
class QStandardItemModel;
-class ColorWidget : public QWidget
+class ColorWidget : public QFrame
{
Q_OBJECT