File indexing completed on 2024-05-05 05:40:26

0001 /***************************************************************************
0002  *  Copyright (C) 2015 by Renaud Guezennec                                *
0003  *   https://rolisteam.org/contact                   *
0004  *                                                                         *
0005  *   Rolisteam is free software; you can redistribute it and/or modify     *
0006  *   it under the terms of the GNU General Public License as published by  *
0007  *   the Free Software Foundation; either version 2 of the License, or     *
0008  *   (at your option) any later version.                                   *
0009  *                                                                         *
0010  *   This program is distributed in the hope that it will be useful,       *
0011  *   but WITHOUT ANY WARRANTY; without even the implied warranty of        *
0012  *   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the         *
0013  *   GNU General Public License for more details.                          *
0014  *                                                                         *
0015  *   You should have received a copy of the GNU General Public License     *
0016  *   along with this program; if not, write to the                         *
0017  *   Free Software Foundation, Inc.,                                       *
0018  *   59 Temple Place - Suite 330, Boston, MA  02111-1307, USA.             *
0019  ***************************************************************************/
0020 #include "data/rolisteamtheme.h"
0021 
0022 #include <QStyleFactory>
0023 RolisteamTheme::RolisteamTheme() : m_paletteModel(new PaletteModel()) {}
0024 
0025 RolisteamTheme::RolisteamTheme(QPalette pal, QString name, QString css, QStyle* style, QString bgPath, int pos,
0026                                QColor bgColor, bool isRemovable)
0027     : m_paletteModel(new PaletteModel())
0028     , m_name(name)
0029     , m_css(css)
0030     , m_removable(isRemovable)
0031     , m_bgPath(bgPath)
0032     , m_bgColor(bgColor)
0033     , m_position(pos)
0034 {
0035     setStyle(style);
0036     m_paletteModel->setPalette(pal);
0037 }
0038 
0039 RolisteamTheme::~RolisteamTheme()= default;
0040 
0041 void RolisteamTheme::setPalette(QPalette pal)
0042 {
0043     m_paletteModel->setPalette(pal);
0044 }
0045 
0046 void RolisteamTheme::setName(QString str)
0047 {
0048     m_name= str;
0049 }
0050 
0051 void RolisteamTheme::setCss(QString str)
0052 {
0053     m_css= str;
0054 }
0055 
0056 void RolisteamTheme::setRemovable(bool b)
0057 {
0058     m_removable= b;
0059 }
0060 
0061 QPalette RolisteamTheme::getPalette() const
0062 {
0063     return m_paletteModel->getPalette();
0064 }
0065 const QString& RolisteamTheme::getName() const
0066 {
0067     return m_name;
0068 }
0069 const QString& RolisteamTheme::getCss() const
0070 {
0071     return m_css;
0072 }
0073 bool RolisteamTheme::isRemovable() const
0074 {
0075     return m_removable;
0076 }
0077 QStyle* RolisteamTheme::getStyle() const
0078 {
0079     return QStyleFactory::create(m_styleName);
0080 }
0081 void RolisteamTheme::setStyle(QStyle* style)
0082 {
0083     if(nullptr != style)
0084     {
0085         m_styleName= style->objectName();
0086     }
0087 }
0088 void RolisteamTheme::setBackgroundColor(QColor c)
0089 {
0090     m_bgColor= c;
0091 }
0092 
0093 void RolisteamTheme::setBackgroundImage(QString img)
0094 {
0095     m_bgPath= img;
0096 }
0097 
0098 QString RolisteamTheme::getStyleName() const
0099 {
0100     return m_styleName;
0101 }
0102 
0103 PaletteModel* RolisteamTheme::paletteModel() const
0104 {
0105     return m_paletteModel.get();
0106 }
0107 QString RolisteamTheme::getBackgroundImage() const
0108 {
0109     return m_bgPath;
0110 }
0111 
0112 int RolisteamTheme::getBackgroundPosition() const
0113 {
0114     return m_position;
0115 }
0116 void RolisteamTheme::setBackgroundPosition(int p)
0117 {
0118     m_position= p;
0119 }
0120 QColor RolisteamTheme::getBackgroundColor() const
0121 {
0122     return m_bgColor;
0123 }
0124 void RolisteamTheme::setDiceHighlightColor(QColor c)
0125 {
0126     m_diceHighlightColor= c;
0127 }
0128 QColor RolisteamTheme::getDiceHighlightColor() const
0129 {
0130     return m_diceHighlightColor;
0131 }