From 90d2181239761f8950b95768d3b037843e9e8b50 Mon Sep 17 00:00:00 2001 From: Teus Benschop Date: Fri, 6 Oct 2017 12:24:31 +0200 Subject: New upstream version 2.11.0 --- src/frontend/display/btcolorwidget.cpp | 44 +++++++++++++--------------------- 1 file changed, 16 insertions(+), 28 deletions(-) (limited to 'src/frontend/display/btcolorwidget.cpp') diff --git a/src/frontend/display/btcolorwidget.cpp b/src/frontend/display/btcolorwidget.cpp index 579e461..908037b 100644 --- a/src/frontend/display/btcolorwidget.cpp +++ b/src/frontend/display/btcolorwidget.cpp @@ -2,58 +2,46 @@ * * This file is part of BibleTime's source code, http://www.bibletime.info/. * -* Copyright 1999-2014 by the BibleTime developers. +* Copyright 1999-2016 by the BibleTime developers. * The BibleTime source code is licensed under the GNU General Public License version 2.0. * **********/ #include "frontend/display/btcolorwidget.h" -#include #include #include #include -BtColorWidget::BtColorWidget(QWidget* parent) - : QFrame(parent) { +BtColorWidget::BtColorWidget(QWidget * parent) + : QFrame(parent) +{ setFrameShadow(QFrame::Sunken); setFrameShape(QFrame::StyledPanel); setSizePolicy(QSizePolicy::Fixed, QSizePolicy::Fixed); setAutoFillBackground(true); + setBackgroundRole(QPalette::Window); } -BtColorWidget::~BtColorWidget() { -} - -QSize BtColorWidget::sizeHint() const { - return QSize(35, 18); -} +QSize BtColorWidget::sizeHint() const { return QSize(35, 18); } -void BtColorWidget::setColor(const QColor& color) { - QPalette p = palette(); +void BtColorWidget::setColor(QColor const & color) { + QPalette p(palette()); p.setColor(QPalette::Normal, QPalette::Window, color); setPalette(p); - - if (color.isValid()) - m_color = color; - else - m_color = QColor(0, 0, 0); update(); } -void BtColorWidget::mouseReleaseEvent(QMouseEvent* event) { +void BtColorWidget::mouseReleaseEvent(QMouseEvent * event) { if (event->button() == Qt::LeftButton) { event->accept(); - showColorDialog(); - return; - } -} - -void BtColorWidget::showColorDialog() { - QColor color = QColorDialog::getColor(m_color, this); - if (color.isValid()) { - m_color = color; - emit changed(m_color); + QColor const color(QColorDialog::getColor( + palette().color(QPalette::Normal, QPalette::Window), + this)); + if (color.isValid()) { + setColor(color); + emit changed(color); + } } } -- cgit v1.2.3