ScreenToolsController.cc 1.91 KB
Newer Older
1 2
/****************************************************************************
 *
3
 * (c) 2009-2020 QGROUNDCONTROL PROJECT <http://www.qgroundcontrol.org>
4 5 6 7 8
 *
 * QGroundControl is licensed according to the terms in the file
 * COPYING.md in the root of the source code directory.
 *
 ****************************************************************************/
Don Gagne's avatar
Don Gagne committed
9 10 11


/// @file
12
/// @author Gus Grubba <gus@auterion.com>
Don Gagne's avatar
Don Gagne committed
13 14

#include "ScreenToolsController.h"
15
#include <QFontDatabase>
dogmaphobic's avatar
dogmaphobic committed
16
#include <QScreen>
17 18 19
#include <QFontMetrics>

#include "SettingsManager.h"
20

21 22 23
#if defined(__ios__)
#include <sys/utsname.h>
#endif
Don Gagne's avatar
Don Gagne committed
24 25 26

ScreenToolsController::ScreenToolsController()
{
27

Don Gagne's avatar
Don Gagne committed
28
}
29

30 31 32 33 34 35
bool
ScreenToolsController::hasTouch() const
{
    return QTouchDevice::devices().count() > 0 || isMobile();
}

36
QString
37
ScreenToolsController::iOSDevice() const
38 39 40 41 42 43 44 45 46
{
#if defined(__ios__)
    struct utsname systemInfo;
    uname(&systemInfo);
    return QString(systemInfo.machine);
#else
    return QString();
#endif
}
47 48 49 50 51 52

QString
ScreenToolsController::fixedFontFamily() const
{
    return QFontDatabase::systemFont(QFontDatabase::FixedFont).family();
}
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

QString
ScreenToolsController::normalFontFamily() const
{
    //-- See App.SettinsGroup.json for index
    int langID = qgcApp()->toolbox()->settingsManager()->appSettings()->language()->rawValue().toInt();
    if(langID == 6 /*Korean*/) {
        return QString("fonts/NanumGothic-Regular");
    } else {
        return QString("opensans");
    }
}

QString
ScreenToolsController::boldFontFamily() const
{
    //-- See App.SettinsGroup.json for index
    int langID = qgcApp()->toolbox()->settingsManager()->appSettings()->language()->rawValue().toInt();
    if(langID == 6 /*Korean*/) {
        return QString("NanumGothic-Bold");
    } else {
        return QString("opensans-demibold");
    }
}

double ScreenToolsController::defaultFontDescent(int pointSize) const
{
    return QFontMetrics(QFont(normalFontFamily(), pointSize)).descent();
}