source: calamares/trunk/fuentes/src/modules/plasmalnf/ThemeInfo.h

Last change on this file was 7538, checked in by kbut, 14 months ago

sync with github

File size: 2.6 KB
Line 
1/* === This file is part of Calamares - <https://github.com/calamares> ===
2 *
3 *   Copyright 2017, Adriaan de Groot <groot@kde.org>
4 *
5 *   Calamares is free software: you can redistribute it and/or modify
6 *   it under the terms of the GNU General Public License as published by
7 *   the Free Software Foundation, either version 3 of the License, or
8 *   (at your option) any later version.
9 *
10 *   Calamares is distributed in the hope that it will be useful,
11 *   but WITHOUT ANY WARRANTY; without even the implied warranty of
12 *   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13 *   GNU General Public License for more details.
14 *
15 *   You should have received a copy of the GNU General Public License
16 *   along with Calamares. If not, see <http://www.gnu.org/licenses/>.
17 */
18
19#ifndef PLASMALNF_THEMEINFO_H
20#define PLASMALNF_THEMEINFO_H
21
22#include <QList>
23#include <QString>
24
25class KPluginMetaData;
26class ThemeWidget;
27
28/** @brief describes a single plasma LnF theme.
29 *
30 * A theme description has an id, which is really the name of the desktop
31 * file (e.g. org.kde.breeze.desktop), a name which is human-readable and
32 * translated, and an optional image Page, which points to a local screenshot
33 * of that theme.
34 */
35struct ThemeInfo
36{
37    QString id;
38    QString name;
39    QString description;
40    QString imagePath;
41    ThemeWidget* widget;
42
43    ThemeInfo()
44        : widget( nullptr )
45    {}
46
47    explicit ThemeInfo( const QString& _id )
48        : id( _id )
49        , widget( nullptr )
50    {
51    }
52
53    explicit ThemeInfo( const QString& _id, const QString& image )
54        : id( _id )
55        , imagePath( image )
56        , widget( nullptr )
57    {}
58
59    // Defined in PlasmaLnfPage.cpp
60    explicit ThemeInfo( const KPluginMetaData& );
61
62    bool isValid() const { return !id.isEmpty(); }
63} ;
64
65class ThemeInfoList : public QList< ThemeInfo >
66{
67public:
68    /** @brief Looks for a given @p id in the list of themes, returns nullptr if not found. */
69    ThemeInfo* findById( const QString& id )
70    {
71        for ( ThemeInfo& i : *this )
72        {
73            if ( i.id == id )
74                return &i;
75        }
76        return nullptr;
77    }
78
79    /** @brief Looks for a given @p id in the list of themes, returns nullptr if not found. */
80    const ThemeInfo* findById( const QString& id ) const
81    {
82        for ( const ThemeInfo& i : *this )
83        {
84            if ( i.id == id )
85                return &i;
86        }
87        return nullptr;
88    }
89
90    /** @brief Checks if a given @p id is in the list of themes. */
91    bool contains( const QString& id ) const
92    {
93        return findById( id ) != nullptr;
94    }
95} ;
96
97#endif
Note: See TracBrowser for help on using the repository browser.