theme.cc 2.64 KB
Newer Older
1 2
/*******************************************************************
*
Frederik Schwarzer's avatar
Frederik Schwarzer committed
3
* Copyright 2007  Aron Boström <c02ab@efd.lth.se>
4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21
*
* Bovo 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 2, or (at your option)
* any later version.
*
* Bovo 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 Bovo; see the file COPYING.  If not, write to
* the Free Software Foundation, 51 Franklin Street, Fifth Floor,
* Boston, MA 02110-1301, USA.
*
********************************************************************/

22

23 24
#include "theme.h"

25 26
#include "settings.h"

27 28 29 30
#include <kconfig.h>
#include <kconfiggroup.h>
#include <kdesktopfile.h>

31
#include <QStandardPaths>
32

33 34
namespace gui {

35 36 37
Theme::Theme() {
}

38
Theme::Theme(const QString& path, const int id)
39
  : m_id(id), m_path(path) {
40
    QString themePath = QStringLiteral("themes/%1/").arg(m_path);
41
            themePath = QStandardPaths::locate(QStandardPaths::AppDataLocation, themePath, QStandardPaths::LocateDirectory);
42
    QString themerc = themePath + QLatin1String("themerc");
43 44 45 46 47 48 49 50 51 52 53
    KDesktopFile themeConfig(themerc);
    m_name = themeConfig.readName();
    m_comment = themeConfig.readComment();

    KConfig config(themerc);
    KConfigGroup configGroup(&config, "Config");
    m_backgroundColor = configGroup.readEntry("BackgroundColor", "white");
    m_fill = configGroup.readEntry("Fill", 0.75);
    m_gridColor = configGroup.readEntry("GridColor", "black");

    QString gridTypeStr = configGroup.readEntry("GridType", "svg");
54
    if (gridTypeStr == QLatin1String("svg")) {
55
        m_gridType = SvgGrid;
56
    } else if (gridTypeStr == QLatin1String("gomoku")) {
57
        m_gridType = GomokuGrid;
58
    } else if (gridTypeStr == QLatin1String("squares")) {
59 60
        m_gridType = SquaresGrid;
    }
61

62
    m_svg = themePath + configGroup.readEntry("Svg", "theme.svg");
63 64
}

65 66
QColor Theme::backgroundColor() const {
    return m_backgroundColor;
67 68 69 70 71 72
}

QString Theme::comment() const {
    return m_comment;
}

73 74 75 76 77 78 79 80 81 82 83 84
qreal Theme::fill() const {
    return m_fill;
}

QColor Theme::gridColor() const {
    return m_gridColor;
}

GridType Theme::gridType() const {
    return m_gridType;
}

85 86
int Theme::id() const {
    return m_id;
87 88 89 90 91 92 93 94 95 96
}

QString Theme::name() const {
    return m_name;
}

QString Theme::path() const {
    return m_path;
}

97 98 99 100 101 102
QString Theme::svg() const {
    return m_svg;
}



103
} /* namespace gui */