-: QObject(parent),
- _channelJoinedIcon(SmallIcon("irc-channel-active")),
- _channelPartedIcon(SmallIcon("irc-channel-inactive")),
- _userOfflineIcon(SmallIcon("im-user-offline")),
- _userOnlineIcon(SmallIcon("im-user")),
- _userAwayIcon(SmallIcon("im-user-away")),
- _categoryOpIcon(SmallIcon("irc-operator")),
- _categoryVoiceIcon(SmallIcon("irc-voice")),
- _opIconLimit(UserCategoryItem::categoryFromModes("o")),
- _voiceIconLimit(UserCategoryItem::categoryFromModes("v"))
-{
- // register FormatList if that hasn't happened yet
- // FIXME I don't think this actually avoids double registration... then again... does it hurt?
- if(QVariant::nameToType("UiStyle::FormatList") == QVariant::Invalid) {
- qRegisterMetaType<FormatList>("UiStyle::FormatList");
- qRegisterMetaTypeStreamOperators<FormatList>("UiStyle::FormatList");
- Q_ASSERT(QVariant::nameToType("UiStyle::FormatList") != QVariant::Invalid);
- }
-
- _uiStylePalette = QVector<QBrush>(NumRoles, QBrush());
-
- // Now initialize the mapping between FormatCodes and FormatTypes...
- _formatCodes["%O"] = Base;
- _formatCodes["%B"] = Bold;
- _formatCodes["%S"] = Italic;
- _formatCodes["%U"] = Underline;
- _formatCodes["%R"] = Reverse;
-
- _formatCodes["%DN"] = Nick;
- _formatCodes["%DH"] = Hostmask;
- _formatCodes["%DC"] = ChannelName;
- _formatCodes["%DM"] = ModeFlags;
- _formatCodes["%DU"] = Url;
-
- setTimestampFormatString("[hh:mm:ss]");
-
- // BufferView / NickView settings
- UiStyleSettings s;
- _showBufferViewIcons = _showNickViewIcons = s.value("ShowItemViewIcons", true).toBool();
- s.notify("ShowItemViewIcons", this, SLOT(showItemViewIconsChanged()));
-
- loadStyleSheet();
-}
-
-UiStyle::~UiStyle() {
- qDeleteAll(_metricsCache);
-}
-
-void UiStyle::reload() {
- loadStyleSheet();
-}
-
-void UiStyle::loadStyleSheet() {
- qDeleteAll(_metricsCache);
- _metricsCache.clear();
- _formatCache.clear();
- _formats.clear();
-
- UiStyleSettings s;
-
- QString styleSheet;
- styleSheet += loadStyleSheet("file:///" + Quassel::findDataFilePath("stylesheets/default.qss"));
- 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()) {
- QssParser parser;
- parser.processStyleSheet(styleSheet);
- QApplication::setPalette(parser.palette());
-
- _uiStylePalette = parser.uiStylePalette();
- _formats = parser.formats();
- _listItemFormats = parser.listItemFormats();
-
- styleSheet = styleSheet.trimmed();
- if(!styleSheet.isEmpty())
- qApp->setStyleSheet(styleSheet); // pass the remaining sections to the application
- }
-
- emit changed();
-}
-
-QString UiStyle::loadStyleSheet(const QString &styleSheet, bool shouldExist) {
- QString ss = styleSheet;
- if(ss.startsWith("file:///")) {
- ss.remove(0, 8);
- if(ss.isEmpty())
- return QString();
-
- QFile file(ss);
- if(file.open(QFile::ReadOnly)) {
- QTextStream stream(&file);
- ss = stream.readAll();
- file.close();
- } else {
- if(shouldExist)
- qWarning() << "Could not open stylesheet file:" << file.fileName();
- return QString();
- }
- }
- return ss;
+ : QObject(parent),
+ _channelJoinedIcon(SmallIcon("irc-channel-active")),
+ _channelPartedIcon(SmallIcon("irc-channel-inactive")),
+ _userOfflineIcon(SmallIcon("im-user-offline")),
+ _userOnlineIcon(SmallIcon("im-user")),
+ _userAwayIcon(SmallIcon("im-user-away")),
+ _categoryOpIcon(SmallIcon("irc-operator")),
+ _categoryVoiceIcon(SmallIcon("irc-voice")),
+ _opIconLimit(UserCategoryItem::categoryFromModes("o")),
+ _voiceIconLimit(UserCategoryItem::categoryFromModes("v"))
+{
+ // register FormatList if that hasn't happened yet
+ // FIXME I don't think this actually avoids double registration... then again... does it hurt?
+ if (QVariant::nameToType("UiStyle::FormatList") == QVariant::Invalid) {
+ qRegisterMetaType<FormatList>("UiStyle::FormatList");
+ qRegisterMetaTypeStreamOperators<FormatList>("UiStyle::FormatList");
+ Q_ASSERT(QVariant::nameToType("UiStyle::FormatList") != QVariant::Invalid);
+ }
+
+ _uiStylePalette = QVector<QBrush>(NumRoles, QBrush());
+
+ // Now initialize the mapping between FormatCodes and FormatTypes...
+ _formatCodes["%O"] = Base;
+ _formatCodes["%B"] = Bold;
+ _formatCodes["%S"] = Italic;
+ _formatCodes["%U"] = Underline;
+ _formatCodes["%R"] = Reverse;
+
+ _formatCodes["%DN"] = Nick;
+ _formatCodes["%DH"] = Hostmask;
+ _formatCodes["%DC"] = ChannelName;
+ _formatCodes["%DM"] = ModeFlags;
+ _formatCodes["%DU"] = Url;
+
+ setTimestampFormatString("[hh:mm:ss]");
+
+ // BufferView / NickView settings
+ UiStyleSettings s;
+ _showBufferViewIcons = _showNickViewIcons = s.value("ShowItemViewIcons", true).toBool();
+ s.notify("ShowItemViewIcons", this, SLOT(showItemViewIconsChanged(QVariant)));
+
+ _allowMircColors = s.value("AllowMircColors", true).toBool();
+ s.notify("AllowMircColors", this, SLOT(allowMircColorsChanged(QVariant)));
+
+ loadStyleSheet();