1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128
|
/*
* Copyright (C) 2024 Carl Schwan <carl@carlschwan.eu>
*
* Licensed under the GNU Lesser General Public License Version 2.1
*
* This library is free software: you can redistribute it and/or modify
* it under the terms of the GNU Lesser General Public License as published by
* the Free Software Foundation, either version 2.1 of the license, or
* (at your option) any later version.
*
* This library 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 Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public License
* along with this library. If not, see <http://www.gnu.org/licenses/>.
*/
#include "branding.h"
#include "appstream.h"
#include "chelpers.h"
using namespace AppStream;
class AppStream::BrandingData : public QSharedData
{
public:
BrandingData()
{
brandingp = as_branding_new();
}
BrandingData(AsBranding *branding)
: brandingp(branding)
{
g_object_ref(brandingp);
}
~BrandingData()
{
g_object_unref(brandingp);
}
bool operator==(const BrandingData &rd) const
{
return rd.brandingp == brandingp;
}
AsBranding *brandingp;
};
Branding::Branding()
: d(new BrandingData)
{
}
Branding::Branding(_AsBranding *brandingp)
: d(new BrandingData(brandingp))
{
}
Branding::Branding(const Branding &branding) = default;
Branding::~Branding() = default;
Branding &Branding::operator=(const Branding &branding) = default;
bool Branding::operator==(const Branding &other) const
{
if (this->d == other.d) {
return true;
}
if (this->d && other.d) {
return *(this->d) == *other.d;
}
return false;
}
_AsBranding *Branding::cPtr() const
{
return d->brandingp;
}
QString Branding::colorKindToString(Branding::ColorKind colorKind)
{
return valueWrap(as_color_kind_to_string(static_cast<AsColorKind>(colorKind)));
}
Branding::ColorKind Branding::colorKindfromString(const QString &string)
{
return static_cast<Branding::ColorKind>(as_color_kind_from_string(qPrintable(string)));
}
QString Branding::colorSchemeToString(ColorSchemeKind colorScheme)
{
return valueWrap(as_color_scheme_kind_to_string(static_cast<AsColorSchemeKind>(colorScheme)));
}
Branding::ColorSchemeKind Branding::colorSchemefromString(const QString &string)
{
return static_cast<Branding::ColorSchemeKind>(
as_color_scheme_kind_from_string(qPrintable(string)));
}
void Branding::setColor(Branding::ColorKind kind,
Branding::ColorSchemeKind scheme,
const QString &color)
{
as_branding_set_color(d->brandingp,
static_cast<AsColorKind>(kind),
static_cast<AsColorSchemeKind>(scheme),
qPrintable(color));
}
void Branding::removeColor(Branding::ColorKind kind, Branding::ColorSchemeKind scheme)
{
as_branding_remove_color(d->brandingp,
static_cast<AsColorKind>(kind),
static_cast<AsColorSchemeKind>(scheme));
}
QString Branding::color(Branding::ColorKind kind, Branding::ColorSchemeKind scheme)
{
return valueWrap(as_branding_get_color(d->brandingp,
static_cast<AsColorKind>(kind),
static_cast<AsColorSchemeKind>(scheme)));
}
|