File indexing completed on 2024-04-21 03:42:03

0001 /*
0002     SPDX-FileCopyrightText: 2007 Pino Toscano <pino@kde.org>
0003 
0004     SPDX-License-Identifier: GPL-2.0-or-later
0005 */
0006 
0007 //project headers
0008 #include "kltheme.h"
0009 
0010 #include <KLocalizedString>
0011 
0012 KLTheme::KLTheme()
0013 {
0014 }
0015 
0016 KLTheme::~KLTheme()
0017 {
0018 }
0019 
0020 /// The 'kids' theme
0021 class KLThemeKid : public KLTheme
0022 {
0023 public:
0024     KLThemeKid()
0025         : KLTheme()
0026     {
0027     }
0028 
0029     QString name() const Q_DECL_OVERRIDE
0030     {
0031         return QStringLiteral("kids");
0032     }
0033 
0034     QString uiName() const Q_DECL_OVERRIDE
0035     {
0036         return i18nc("@item:inlistbox", "Kid");
0037     }
0038 
0039     QString svgFileName() const Q_DECL_OVERRIDE
0040     {
0041         return QStringLiteral("klettres_kids.svg");
0042     }
0043 
0044     QColor letterColor() const Q_DECL_OVERRIDE
0045     {
0046         return QColor(215, 215, 215); 
0047     }
0048 
0049     QColor backgroundInputColor() const Q_DECL_OVERRIDE
0050     {
0051         return QColor(187, 76, 58); 
0052     }
0053 
0054     QColor letterInputColor() const Q_DECL_OVERRIDE
0055     {
0056         return QColor(215, 215, 215); 
0057     }
0058 
0059     QRect wordRect(const QSize& windowsize) const Q_DECL_OVERRIDE
0060     {
0061         return QRect(windowsize.width()*200/800, windowsize.height()*200/600, 250, 160);
0062     }
0063 
0064     QRect inputRect(const QSize& windowsize) const Q_DECL_OVERRIDE
0065     {
0066         return QRect(windowsize.width()*188/800, windowsize.height()*468/600, 25, 90);
0067     }
0068 };
0069 
0070 /// The 'desert' theme
0071 class KLThemeDesert : public KLTheme
0072 {
0073 public:
0074     KLThemeDesert()
0075         : KLTheme()
0076     {
0077     }
0078 
0079     QString name() const Q_DECL_OVERRIDE
0080     {
0081         return QStringLiteral("desert");
0082     }
0083 
0084     QString uiName() const Q_DECL_OVERRIDE
0085     {
0086         return i18nc("@item:inlistbox desert theme for the interface", "Desert");
0087     }
0088 
0089     QString svgFileName() const Q_DECL_OVERRIDE
0090     {
0091         return QStringLiteral("klettres_desert.svg");
0092     }
0093 
0094     QColor letterColor() const Q_DECL_OVERRIDE
0095     {
0096         return QColor(115, 50, 95); 
0097     }
0098 
0099     QColor backgroundInputColor() const Q_DECL_OVERRIDE
0100     {
0101         return QColor(202, 217, 84); 
0102     }
0103 
0104     QColor letterInputColor() const Q_DECL_OVERRIDE
0105     {
0106         return QColor(141, 80, 17); 
0107     }
0108 
0109     QRect wordRect(const QSize& windowsize) const Q_DECL_OVERRIDE
0110     {
0111     return QRect(windowsize.width()*230/800, windowsize.height()*140/600, 250, 160);
0112     }
0113 
0114     QRect inputRect(const QSize& windowsize) const Q_DECL_OVERRIDE
0115     {
0116         return QRect(windowsize.width()*380/800, windowsize.height()*480/600, 250, 160);
0117     }
0118 };
0119 
0120 /// The 'savannah' theme
0121 class KLThemeSavannah : public KLTheme
0122 {
0123 public:
0124     KLThemeSavannah()
0125         : KLTheme()
0126     {
0127     }
0128 
0129     QString name() const Q_DECL_OVERRIDE
0130     {
0131         return QStringLiteral("savannah");
0132     }
0133 
0134     QString uiName() const Q_DECL_OVERRIDE
0135     {
0136         return i18nc("@item:inlistbox", "Savannah");
0137     }
0138 
0139     QString svgFileName() const Q_DECL_OVERRIDE
0140     {
0141         return QStringLiteral("klettres_savannah.svg");
0142     }
0143 
0144     QColor letterColor() const Q_DECL_OVERRIDE
0145     {
0146         return QColor(215, 215, 215); 
0147     }
0148 
0149     QColor backgroundInputColor() const Q_DECL_OVERRIDE
0150     {
0151         return QColor(196, 189, 94); 
0152     }
0153 
0154     QColor letterInputColor() const Q_DECL_OVERRIDE
0155     {
0156         return QColor(141, 80, 17); 
0157     }
0158 
0159     QRect wordRect(const QSize& windowsize) const Q_DECL_OVERRIDE
0160     {
0161         return QRect(windowsize.width()*230/800, windowsize.height()*80/600, 250, 160);
0162     }
0163 
0164     QRect inputRect(const QSize& windowsize) const Q_DECL_OVERRIDE
0165     {
0166         return QRect(windowsize.width()*540/800, windowsize.height()*480/600, 250, 160);
0167     }
0168 };
0169 
0170 ///The 'Aqua' theme
0171 
0172 class KLThemeAqua : public KLTheme
0173 {
0174 public:
0175     KLThemeAqua()
0176         : KLTheme()
0177     {
0178     }
0179 
0180     QString name() const Q_DECL_OVERRIDE
0181     {
0182         return QStringLiteral("aqua");
0183     }
0184 
0185     QString uiName() const Q_DECL_OVERRIDE
0186     {
0187         return i18nc("@item:inlistbox", "Aqua");
0188     }
0189 
0190     QString svgFileName() const Q_DECL_OVERRIDE
0191     {
0192         return QStringLiteral("klettres_aqua.svg");
0193     }
0194 
0195     QColor letterColor() const Q_DECL_OVERRIDE
0196     {
0197         return QColor(215, 215, 215); 
0198     }
0199 
0200     QColor backgroundInputColor() const Q_DECL_OVERRIDE
0201     {
0202         return QColor(0, 0, 100); 
0203     }
0204 
0205     QColor letterInputColor() const Q_DECL_OVERRIDE
0206     {
0207         return QColor(0, 0, 215); 
0208     }
0209 
0210     QRect wordRect(const QSize& windowsize) const Q_DECL_OVERRIDE
0211     {
0212         return QRect(windowsize.width()*150/800, windowsize.height()*180/600, 250, 160);
0213     }
0214 
0215     QRect inputRect(const QSize& windowsize) const Q_DECL_OVERRIDE
0216     {
0217     return QRect(windowsize.width()*600/800, windowsize.height()*480/600, 250, 160);
0218     }
0219 };
0220 
0221 KLThemeFactory* KLThemeFactory::instance()
0222 {
0223     static KLThemeFactory factory;
0224     return &factory;
0225 }
0226 
0227 KLThemeFactory::KLThemeFactory()
0228 {
0229 }
0230 
0231 KLThemeFactory::~KLThemeFactory()
0232 {
0233 }
0234 
0235 KLTheme* KLThemeFactory::buildTheme(int id) const
0236 {
0237     switch (id)
0238     {
0239         case 0:
0240             return new KLThemeKid();
0241         case 1:
0242             return new KLThemeDesert();
0243         case 2:
0244             return new KLThemeSavannah();
0245     case 3:
0246         return new KLThemeAqua();
0247     }
0248     return nullptr;
0249 }
0250 
0251 #define ADD_THEME_NAME( themeclass, list ) \
0252 { \
0253    themeclass x; \
0254    list.append( x.uiName() ); \
0255 }
0256 QStringList KLThemeFactory::themeList() const
0257 {
0258     QStringList ret;
0259     ADD_THEME_NAME( KLThemeKid, ret )
0260     ADD_THEME_NAME( KLThemeDesert, ret )
0261     ADD_THEME_NAME( KLThemeSavannah, ret )
0262     ADD_THEME_NAME( KLThemeAqua, ret)
0263     return ret;
0264 }
0265 
0266 
0267 
0268