~saviq/qtubuntu/leaner-qtubuntu

« back to all changes in this revision

Viewing changes to src/shared/ubuntutheme.h

  • Committer: Bileto Bot
  • Author(s): Lukáš Tinkl
  • Date: 2017-04-04 00:46:48 UTC
  • mfrom: (384.3.4 ubuntuIconsFonts)
  • Revision ID: ci-train-bot@canonical.com-20170404004648-65yt1ad9dyybbkr2
Use the correct font (Ubuntu family) and icon theme (suru) (LP: #1676878)

Approved by: Daniel d'Andrada, Unity8 CI Bot

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
/*
 
2
 * Copyright (C) 2016-2017 Canonical, Ltd.
 
3
 *
 
4
 * This program is free software: you can redistribute it and/or modify it under
 
5
 * the terms of the GNU Lesser General Public License version 3, as published by
 
6
 * the Free Software Foundation.
 
7
 *
 
8
 * This program is distributed in the hope that it will be useful, but WITHOUT
 
9
 * ANY WARRANTY; without even the implied warranties of MERCHANTABILITY,
 
10
 * SATISFACTORY QUALITY, or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
 
11
 * Lesser General Public License for more details.
 
12
 *
 
13
 * You should have received a copy of the GNU Lesser General Public License
 
14
 * along with this program.  If not, see <http://www.gnu.org/licenses/>.
 
15
 */
 
16
 
 
17
#include <QVariant>
 
18
#include <QtPlatformSupport/private/qgenericunixthemes_p.h>
 
19
 
 
20
class UbuntuTheme : public QGenericUnixTheme
 
21
{
 
22
public:
 
23
    UbuntuTheme()
 
24
      : mSystemFont(QStringLiteral("Ubuntu Regular"), 10),
 
25
        mFixedFont(QStringLiteral("Ubuntu Mono Regular"), 13)
 
26
    {
 
27
        mSystemFont.setStyleHint(QFont::System);
 
28
        mFixedFont.setStyleHint(QFont::TypeWriter);
 
29
    }
 
30
    ~UbuntuTheme() = default;
 
31
 
 
32
    QVariant themeHint(ThemeHint hint) const override
 
33
    {
 
34
        switch (hint) {
 
35
        case QPlatformTheme::SystemIconThemeName: {
 
36
            QByteArray iconTheme = qgetenv("QTUBUNTU_ICON_THEME");
 
37
            if (iconTheme.isEmpty()) {
 
38
                return QStringLiteral("suru");
 
39
            } else {
 
40
                return iconTheme;
 
41
            }
 
42
        }
 
43
        default:
 
44
            break;
 
45
        }
 
46
        return QGenericUnixTheme::themeHint(hint);
 
47
    }
 
48
 
 
49
    const QFont *font(Font type) const override
 
50
    {
 
51
        switch (type) {
 
52
        case QPlatformTheme::SystemFont:
 
53
            return &mSystemFont;
 
54
        case QPlatformTheme::FixedFont:
 
55
            return &mFixedFont;
 
56
        default:
 
57
            return nullptr;
 
58
        }
 
59
    }
 
60
 
 
61
private:
 
62
    QFont mSystemFont, mFixedFont;
 
63
};