Changeset View
Changeset View
Standalone View
Standalone View
common/control.cpp
- This file was moved from kded/control.cpp.
Show All 9 Lines | |||||
10 | but WITHOUT ANY WARRANTY; without even the implied warranty of | 10 | but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
11 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | 11 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | ||
12 | GNU General Public License for more details. | 12 | GNU General Public License for more details. | ||
13 | 13 | | |||
14 | You should have received a copy of the GNU General Public License | 14 | You should have received a copy of the GNU General Public License | ||
15 | along with this program. If not, see <http://www.gnu.org/licenses/>. | 15 | along with this program. If not, see <http://www.gnu.org/licenses/>. | ||
16 | *********************************************************************/ | 16 | *********************************************************************/ | ||
17 | #include "control.h" | 17 | #include "control.h" | ||
18 | #include "config.h" | 18 | #include "globals.h" | ||
19 | 19 | | |||
20 | #include "kscreen_daemon_debug.h" | | |||
21 | #include "generator.h" | | |||
22 | | ||||
23 | #include <QStringList> | | |||
24 | #include <QFile> | 20 | #include <QFile> | ||
25 | #include <QStringBuilder> | | |||
26 | #include <QJsonDocument> | 21 | #include <QJsonDocument> | ||
27 | #include <QDir> | 22 | #include <QDir> | ||
28 | #include <QLoggingCategory> | | |||
29 | | ||||
30 | #include <kscreen/output.h> | | |||
31 | #include <kscreen/edid.h> | | |||
32 | 23 | | |||
33 | QString Control::s_dirName = QStringLiteral("control/"); | 24 | QString Control::s_dirName = QStringLiteral("control/"); | ||
34 | 25 | | |||
35 | QString Control::dirPath() | 26 | QString Control::dirPath() | ||
36 | { | 27 | { | ||
37 | return Config::dirPath() % s_dirName; | 28 | return Globals::dirPath() % s_dirName; | ||
38 | } | 29 | } | ||
39 | 30 | | |||
40 | QString Control::outputFilePath(const QString &hash) | 31 | QString Control::outputFilePath(const QString &hash) | ||
41 | { | 32 | { | ||
42 | const QString dir = dirPath() % QStringLiteral("outputs/"); | 33 | const QString dir = dirPath() % QStringLiteral("outputs/"); | ||
43 | if (!QDir().mkpath(dir)) { | 34 | if (!QDir().mkpath(dir)) { | ||
44 | return QString(); | 35 | return QString(); | ||
45 | } | 36 | } | ||
Show All 23 Lines | 50 | { | |||
69 | return OutputRetention::Undefined; | 60 | return OutputRetention::Undefined; | ||
70 | } | 61 | } | ||
71 | 62 | | |||
72 | QMap<QString, Control::OutputRetention> Control::readInOutputRetentionValues(const QString &configId) | 63 | QMap<QString, Control::OutputRetention> Control::readInOutputRetentionValues(const QString &configId) | ||
73 | { | 64 | { | ||
74 | // qDebug() << "Looking for control file:" << configId; | 65 | // qDebug() << "Looking for control file:" << configId; | ||
75 | QFile file(configFilePath(configId)); | 66 | QFile file(configFilePath(configId)); | ||
76 | if (!file.open(QIODevice::ReadOnly)) { | 67 | if (!file.open(QIODevice::ReadOnly)) { | ||
77 | qCDebug(KSCREEN_KDED) << "Failed to open file" << file.fileName(); | 68 | // TODO: have a logging category | ||
69 | // qCDebug(KSCREEN_COMMON) << "Failed to open file" << file.fileName(); | ||||
78 | return QMap<QString, Control::OutputRetention>(); | 70 | return QMap<QString, Control::OutputRetention>(); | ||
79 | } | 71 | } | ||
80 | 72 | | |||
81 | QJsonDocument parser; | 73 | QJsonDocument parser; | ||
82 | const QVariantMap controlInfo = parser.fromJson(file.readAll()).toVariant().toMap(); | 74 | const QVariantMap controlInfo = parser.fromJson(file.readAll()).toVariant().toMap(); | ||
83 | const QVariantList outputsInfo = controlInfo[QStringLiteral("outputs")].toList(); | 75 | const QVariantList outputsInfo = controlInfo[QStringLiteral("outputs")].toList(); | ||
84 | QMap<QString, Control::OutputRetention> retentions; | 76 | QMap<QString, Control::OutputRetention> retentions; | ||
85 | 77 | | |||
Show All 22 Lines |