Diffstat (limited to 'noncore/graphics/drawpad/colorpanel.cpp') (more/less context) (show whitespace changes)
-rw-r--r-- | noncore/graphics/drawpad/colorpanel.cpp | 18 |
1 files changed, 2 insertions, 16 deletions
diff --git a/noncore/graphics/drawpad/colorpanel.cpp b/noncore/graphics/drawpad/colorpanel.cpp index 1db0d7b..9327012 100644 --- a/noncore/graphics/drawpad/colorpanel.cpp +++ b/noncore/graphics/drawpad/colorpanel.cpp @@ -9,67 +9,52 @@ * the Free Software Foundation; either version 2 of the License, or * * (at your option) any later version. * * * ***************************************************************************/ #include "colorpanel.h" #include <qlayout.h> #include <qpainter.h> ColorPanelButton::ColorPanelButton(const QColor& color, QWidget* parent, const char* name) : QFrame(parent, name) { m_color = color; setFixedSize(16, 16); - setActive(false); + setFrameStyle(NoFrame); } ColorPanelButton::~ColorPanelButton() { } -void ColorPanelButton::setActive(bool active) -{ - m_active = active; - - if (m_active) { - setFrameStyle(Panel | Sunken); - } else { - setFrameStyle(NoFrame); - } -} - void ColorPanelButton::enterEvent(QEvent* e) { Q_UNUSED(e) - if (!m_active) { setFrameStyle(Panel | Sunken); } -} void ColorPanelButton::leaveEvent(QEvent* e) { Q_UNUSED(e) - if (!m_active) { setFrameStyle(NoFrame); } -} void ColorPanelButton::paintEvent(QPaintEvent* e) { QFrame::paintEvent(e); QPainter painter; painter.begin(this); painter.fillRect(2, 2, 12, 12, m_color); painter.setPen(Qt::black); painter.drawRect(2, 2, 12, 12); painter.end(); } void ColorPanelButton::mouseReleaseEvent(QMouseEvent* e) { Q_UNUSED(e) @@ -112,23 +97,24 @@ ColorPanel::ColorPanel(QWidget* parent, const char* name) addColor(QColor(0, 128, 128), 4, 0); addColor(QColor(0, 64, 128), 4, 1); addColor(QColor(0, 0, 128), 4, 2); addColor(QColor(64, 0, 128), 4, 3); addColor(QColor(128, 0, 128), 4, 4); addColor(QColor(128, 0, 64), 4, 5); } ColorPanel::~ColorPanel() { } void ColorPanel::addColor(const QColor& color, int row, int col) { ColorPanelButton* panelButton = new ColorPanelButton(color, this); connect(panelButton, SIGNAL(selected(const QColor&)), this, SLOT(buttonSelected(const QColor&))); + m_pGridLayout->addWidget(panelButton, row, col); } void ColorPanel::buttonSelected(const QColor& color) { emit colorSelected(color); } |