1#include "deviceconfigparser.h"
6DeviceConfigParser::DeviceConfigParser(QObject *parent): QObject(parent)
11QString DeviceConfigParser::name() const
16void DeviceConfigParser::setName(const QString &name)
25Qt::ScreenOrientation DeviceConfigParser::primaryOrientation() const
27 return stringToOrientation(readOrientationFromConfig("PrimaryOrientation"), Qt::PrimaryOrientation);
30Qt::ScreenOrientations DeviceConfigParser::supportedOrientations() const
32 QStringList values = readOrientationsFromConfig("SupportedOrientations");
33 if (values.isEmpty()) {
34 return Qt::PortraitOrientation
35 | Qt::InvertedPortraitOrientation
36 | Qt::LandscapeOrientation
37 | Qt::InvertedLandscapeOrientation;
40 Qt::ScreenOrientations ret = Qt::PrimaryOrientation;
41 Q_FOREACH(const QString &orientationString, values) {
42 ret |= stringToOrientation(orientationString, Qt::PrimaryOrientation);
47Qt::ScreenOrientation DeviceConfigParser::landscapeOrientation() const
49 return stringToOrientation(readOrientationFromConfig("LandscapeOrientation"), Qt::LandscapeOrientation);
52Qt::ScreenOrientation DeviceConfigParser::invertedLandscapeOrientation() const
54 return stringToOrientation(readOrientationFromConfig("InvertedLandscapeOrientation"), Qt::InvertedLandscapeOrientation);
57Qt::ScreenOrientation DeviceConfigParser::portraitOrientation() const
59 return stringToOrientation(readOrientationFromConfig("PortraitOrientation"), Qt::PortraitOrientation);
62Qt::ScreenOrientation DeviceConfigParser::invertedPortraitOrientation() const
64 return stringToOrientation(readOrientationFromConfig("InvertedPortraitOrientation"), Qt::InvertedPortraitOrientation);
67QStringList DeviceConfigParser::readOrientationsFromConfig(const QString &key) const
69 QFileInfo fi("./devices.conf");
72 path = "./devices.conf";
74 path = "/etc/unity8/devices.conf";
76 QSettings config(path, QSettings::IniFormat);
77 config.beginGroup(m_name);
79 if (config.contains(key)) {
80 return config.value(key).toStringList();
85QString DeviceConfigParser::readOrientationFromConfig(const QString &key) const
87 QStringList ret = readOrientationsFromConfig(key);
88 return ret.count() > 0 ? ret.first() : QString();
91Qt::ScreenOrientation DeviceConfigParser::stringToOrientation(const QString &orientationString, Qt::ScreenOrientation defaultValue) const
93 if (orientationString == "Landscape") {
94 return Qt::LandscapeOrientation;
96 if (orientationString == "InvertedLandscape") {
97 return Qt::InvertedLandscapeOrientation;
99 if (orientationString == "Portrait") {
100 return Qt::PortraitOrientation;
102 if (orientationString == "InvertedPortrait") {
103 return Qt::InvertedPortraitOrientation;
keysesc to close
- j k
- move down, up
- enter
- open
- esc
- back, or up a level
- 1 2 3 4
- readme, files, commits, refs
- /
- filter
- y
- copy the clone command
- c
- compare the chosen commit with another (or shift-click both)
- ?
- show or hide this list