blob: b14a572888fecce2a3187fac7454bbab3efd6da3 (
plain) (
blame)
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
|
#include "deadlinetype.h"
#include "config.h"
#include <QSettings>
#include <QDebug>
static const QString FILE_SHUTDOWN("shutdown");
static const QString FILE_IDLE_KILL("idle-kill");
static const QString FILE_NO_TIMEOUT("no-timeout");
static const QString CONFIG_LOCKED_SUFFIX("-locked");
static const QString CONFIG_MESSAGES_PATH(CONFIG_DIR + "/messages.ini");
static QSettings MESSAGES(CONFIG_MESSAGES_PATH, QSettings::IniFormat);
const DeadlineType *DeadlineType::Unknown = new DeadlineType("");
const DeadlineType *DeadlineType::Shutdown = new DeadlineType(FILE_SHUTDOWN);
const DeadlineType *DeadlineType::IdleKill = new DeadlineType(FILE_IDLE_KILL);
const DeadlineType *DeadlineType::NoTimeout = new DeadlineType(FILE_NO_TIMEOUT);
DeadlineType::DeadlineType(const QString &name)
{
if (name.isEmpty())
return;
MESSAGES.setIniCodec("UTF-8");
QString nameLocked = name + CONFIG_LOCKED_SUFFIX;
_headerLine[0] = MESSAGES.value(name).toString();
_bodyText[0] = Config::loadFileToString(CONFIG_DIR + "/text-" + name);
if (_headerLine[0].isEmpty()) {
_headerLine[0] = CONFIG_MESSAGES_PATH + " missing key " + name;
}
if (_bodyText[0].isEmpty()) {
_bodyText[0] = CONFIG_DIR + "/text-" + name + " missing";
}
_headerLine[1] = MESSAGES.value(nameLocked).toString();
qDebug() << "From" << nameLocked << "got:" << _headerLine[1];
_bodyText[1] = Config::loadFileToString(CONFIG_DIR + "/text-" + nameLocked);
if (_headerLine[1].isEmpty()) {
_headerLine[1] = _headerLine[0];
}
if (_bodyText[1].isEmpty()) {
_bodyText[1] = _bodyText[0];
}
qDebug() << name;
qDebug() << " locked headline:" << headerLine(true);
qDebug() << "unlocked headline:" << headerLine(false);
}
|