From 4e3709967930a0cafb34a977cd31ede68e4ff109 Mon Sep 17 00:00:00 2001 From: Edric Milaret Date: Wed, 20 Jan 2016 11:29:32 -0500 Subject: [PATCH] ui: move QColor to dedicated header/namespace Change-Id: I32555bd2b031e87ab743f010dc2a60614b001beb Tuleap: #148 --- RingWinClient.pro | 3 ++- imdelegate.cpp | 6 ++++-- imdelegate.h | 1 - ringthemeutils.h | 29 +++++++++++++++++++++++++++++ smartlistdelegate.cpp | 12 +++++++----- smartlistdelegate.h | 5 ----- 6 files changed, 42 insertions(+), 14 deletions(-) create mode 100644 ringthemeutils.h diff --git a/RingWinClient.pro b/RingWinClient.pro index 7ff80ff..db4bb20 100644 --- a/RingWinClient.pro +++ b/RingWinClient.pro @@ -102,7 +102,8 @@ HEADERS += mainwindow.h \ mainwindowtoolbar.h \ ringcontactlineedit.h \ pixbufmanipulator.h \ - qualitydialog.h + qualitydialog.h \ + ringthemeutils.h FORMS += mainwindow.ui \ callwidget.ui \ diff --git a/imdelegate.cpp b/imdelegate.cpp index e670a9a..a9d885d 100644 --- a/imdelegate.cpp +++ b/imdelegate.cpp @@ -18,10 +18,12 @@ #include "imdelegate.h" +#include + #include "media/text.h" #include "media/textrecording.h" -#include +#include "ringthemeutils.h" ImDelegate::ImDelegate(QObject *parent) : QStyledItemDelegate(parent), showDate_(false), showAuthor_(false) @@ -93,7 +95,7 @@ ImDelegate::paint(QPainter* painter, path.addRoundedRect(bubbleRect, padding_, padding_); if (dir == Qt::AlignRight) { - painter->fillPath(path, blue_); + painter->fillPath(path, RingTheme::blue_); painter->setPen(Qt::white); } else { diff --git a/imdelegate.h b/imdelegate.h index f088dce..1fee78f 100644 --- a/imdelegate.h +++ b/imdelegate.h @@ -43,7 +43,6 @@ private: QRect getBoundingRect(const Qt::AlignmentFlag& dir, const QString& msg, const QStyleOptionViewItem &option) const; const QFont fontMsg_ = QFont("Arial", 10); - const QColor blue_ {"#3AC0D2"}; const QSize iconSize_ {38,38}; constexpr static int padding_ = 5; diff --git a/ringthemeutils.h b/ringthemeutils.h new file mode 100644 index 0000000..4363697 --- /dev/null +++ b/ringthemeutils.h @@ -0,0 +1,29 @@ +/*************************************************************************** + * Copyright (C) 2016 by Savoir-faire Linux * + * Author: Edric Ladent Milaret * + * * + * This program 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. * + * * + * This program 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 this program. If not, see . * + **************************************************************************/ + +#pragma once + +namespace RingTheme { + +static const QColor blue_ {"#3AC0D2"}; +static const QColor lightGrey_ {242, 242, 242}; +static const QColor lightBlack_ {63, 63, 63}; +static const QColor grey_ {192, 192, 192}; +static const QColor red_ {251, 72, 71}; + +} diff --git a/smartlistdelegate.cpp b/smartlistdelegate.cpp index ffa8bee..c53c129 100644 --- a/smartlistdelegate.cpp +++ b/smartlistdelegate.cpp @@ -28,6 +28,8 @@ #include "recentmodel.h" #include "call.h" +#include "ringthemeutils.h" + SmartListDelegate::SmartListDelegate(QObject* parent) : QItemDelegate(parent) { @@ -85,9 +87,9 @@ SmartListDelegate::paint(QPainter* painter QPainterPath path; path.addRoundedRect(bubbleRect, 3, 3); - QPen pen(red_, 5); + QPen pen(RingTheme::red_, 5); painter->setPen(pen); - painter->fillPath(path, red_); + painter->fillPath(path, RingTheme::red_); painter->drawPath(path); painter->setPen(Qt::white); @@ -104,7 +106,7 @@ SmartListDelegate::paint(QPainter* painter emit rowSelected(opt.rect); if (not (opt.state & QStyle::State_Selected)) { - pen.setColor(lightGrey_); + pen.setColor(RingTheme::lightGrey_); painter->setPen(pen); painter->drawLine(rect.left() + 20, rect.bottom(), rect.right() - 20, @@ -117,7 +119,7 @@ SmartListDelegate::paint(QPainter* painter QVariant name = index.data(static_cast(Ring::Role::Name)); if (name.isValid()) { - pen.setColor(lightBlack_); + pen.setColor(RingTheme::lightBlack_); painter->setPen(pen); font.setBold(true); painter->setFont(font); @@ -134,7 +136,7 @@ SmartListDelegate::paint(QPainter* painter } QVariant state = index.data(static_cast(Ring::Role::FormattedState)); - pen.setColor(grey_); + pen.setColor(RingTheme::grey_); painter->setPen(pen); font.setBold(false); painter->setFont(font); diff --git a/smartlistdelegate.h b/smartlistdelegate.h index 354577c..705faef 100644 --- a/smartlistdelegate.h +++ b/smartlistdelegate.h @@ -43,11 +43,6 @@ private: constexpr static int pinSize_ = 12; int rowHighlighted_ = -1; - const QColor lightGrey_ {242, 242, 242}; - const QColor lightBlack_ {63, 63, 63}; - const QColor grey_ {192, 192, 192}; - const QColor red_ {251, 72, 71}; - signals: void rowSelected(const QRect& rect) const; }; -- GitLab