#include "deadlinetype.h" #include "config.h" #include #include 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); }