#include "util.h"
QHash<QString, UiStyle::FormatType> UiStyle::_formatCodes;
+QString UiStyle::_timestampFormatString;
UiStyle::UiStyle(QObject *parent) : QObject(parent) {
// register FormatList if that hasn't happened yet
_formatCodes["%DM"] = ModeFlags;
_formatCodes["%DU"] = Url;
+ setTimestampFormatString("[hh:mm:ss]");
+
loadStyleSheet();
}
-UiStyle::~ UiStyle() {
+UiStyle::~UiStyle() {
qDeleteAll(_metricsCache);
}
+void UiStyle::reload() {
+ loadStyleSheet();
+}
+
void UiStyle::loadStyleSheet() {
qDeleteAll(_metricsCache);
_metricsCache.clear();
_formatCache.clear();
- QString styleSheet;
+ UiStyleSettings s;
+ QString styleSheet;
styleSheet += loadStyleSheet("file:///" + Quassel::findDataFilePath("default.qss"));
- styleSheet += loadStyleSheet("file:///" + Quassel::configDirPath() + "custom.qss");
- // styleSheet += loadStyleSheet("file:///" + some custom file name); FIXME
+ styleSheet += loadStyleSheet("file:///" + Quassel::configDirPath() + "settings.qss");
+ if(s.value("UseCustomStyleSheet", false).toBool())
+ styleSheet += loadStyleSheet("file:///" + s.value("CustomStyleSheetPath").toString(), true);
styleSheet += loadStyleSheet("file:///" + Quassel::optionValue("qss"), true);
- if(styleSheet.isEmpty())
- return;
+ if(!styleSheet.isEmpty()) {
+ QssParser parser;
+ parser.processStyleSheet(styleSheet);
+ QApplication::setPalette(parser.palette());
+ _formatCache = parser.formats();
- QssParser parser;
- parser.processStyleSheet(styleSheet);
- QApplication::setPalette(parser.palette());
- _formatCache = parser.formats();
-
- qApp->setStyleSheet(styleSheet); // pass the remaining sections to the application
+ qApp->setStyleSheet(styleSheet); // pass the remaining sections to the application
+ }
emit changed();
}
return ss;
}
+void UiStyle::setTimestampFormatString(const QString &format) {
+ if(_timestampFormatString != format) {
+ _timestampFormatString = format;
+ // FIXME reload
+ }
+}
+
/******** Caching *******/
QTextCharFormat UiStyle::cachedFormat(quint64 key) const {
case Message::DayChange:
return DayChangeMsg;
}
- Q_ASSERT(false); // we need to handle all message types
+ //Q_ASSERT(false); // we need to handle all message types
+ qWarning() << Q_FUNC_INFO << "Unknown message type:" << msgType;
return ErrorMsg;
}
}
QString UiStyle::StyledMessage::decoratedTimestamp() const {
- return QString("[%1]").arg(timestamp().toLocalTime().toString("hh:mm:ss"));
+ return timestamp().toLocalTime().toString(UiStyle::timestampFormatString());
}
QString UiStyle::StyledMessage::plainSender() const {