X-Git-Url: https://git.quassel-irc.org/?p=quassel.git;a=blobdiff_plain;f=src%2Fuisupport%2Fqssparser.h;h=c0f9e5e99eea2a8edf01d700279207ba1180a4ed;hp=1dc9e744b617ab53fa810f702110e0fc0c13fcfe;hb=cc6e7c08709c4e761e2fd9c2e322751015497003;hpb=7bd2084db21a5203fe6119d3eb8857aa11c80aa7 diff --git a/src/uisupport/qssparser.h b/src/uisupport/qssparser.h index 1dc9e744..c0f9e5e9 100644 --- a/src/uisupport/qssparser.h +++ b/src/uisupport/qssparser.h @@ -1,65 +1,77 @@ /*************************************************************************** -* Copyright (C) 2005-09 by the Quassel Project * -* devel@quassel-irc.org * -* * -* This program is free software; you can redistribute it and/or modify * -* it under the terms of the GNU General Public License as published by * -* the Free Software Foundation; either version 2 of the License, or * -* (at your option) version 3. * -* * -* This program is distributed in the hope that it will be useful, * -* but WITHOUT ANY WARRANTY; without even the implied warranty of * -* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * -* GNU General Public License for more details. * -* * -* You should have received a copy of the GNU General Public License * -* along with this program; if not, write to the * -* Free Software Foundation, Inc., * -* 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. * -***************************************************************************/ - -#ifndef QSSPARSER_H_ -#define QSSPARSER_H_ + * Copyright (C) 2005-2019 by the Quassel Project * + * devel@quassel-irc.org * + * * + * This program is free software; you can redistribute it and/or modify * + * it under the terms of the GNU General Public License as published by * + * the Free Software Foundation; either version 2 of the License, or * + * (at your option) version 3. * + * * + * This program is distributed in the hope that it will be useful, * + * but WITHOUT ANY WARRANTY; without even the implied warranty of * + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * + * GNU General Public License for more details. * + * * + * You should have received a copy of the GNU General Public License * + * along with this program; if not, write to the * + * Free Software Foundation, Inc., * + * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. * + ***************************************************************************/ + +#pragma once + +#include #include "uistyle.h" -class QssParser { - Q_DECLARE_TR_FUNCTIONS(QssParser) +class QssParser +{ + Q_DECLARE_TR_FUNCTIONS(QssParser) - public: +public: QssParser(); - void loadStyleSheet(const QString &sheet); + void processStyleSheet(QString& sheet); inline QPalette palette() const { return _palette; } + inline QVector uiStylePalette() const { return _uiStylePalette; } inline const QHash& formats() const { return _formats; } + inline const QHash& listItemFormats() const { return _listItemFormats; } - protected: - typedef QList ColorTuple; +protected: + using ColorTuple = QList; - void parseChatLineData(const QString &decl, const QString &contents); - void parsePaletteData(const QString &decl, const QString &contents); + void parseChatLineBlock(const QString& decl, const QString& contents); + void parsePaletteBlock(const QString& decl, const QString& contents); + void parseListItemBlock(const QString& decl, const QString& contents); - quint64 parseFormatType(const QString &decl); + std::pair parseFormatType(const QString& decl); + UiStyle::ItemFormatType parseItemFormatType(const QString& decl); - QTextCharFormat parseFormat(const QString &qss); - bool parsePalette(QPalette &, const QString &qss); + QTextCharFormat parseFormat(const QString& qss); - // Parse basic data types - QBrush parseBrushValue(const QString &str); - QColor parseColorValue(const QString &str); - QFont parseFontValue(const QString &str); + // Parse boolean properties + bool parseBoolean(const QString& str, bool* ok = nullptr) const; - // Parse subelements - ColorTuple parseColorTuple(const QString &str); - QGradientStops parseGradientStops(const QString &str); + // Parse color/brush-related properties + QBrush parseBrush(const QString& str, bool* ok = nullptr); + QColor parseColor(const QString& str); + ColorTuple parseColorTuple(const QString& str); + QGradientStops parseGradientStops(const QString& str); + + // Parse font-related properties + void parseFont(const QString& str, QTextCharFormat* format); + void parseFontStyle(const QString& str, QTextCharFormat* format); + void parseFontWeight(const QString& str, QTextCharFormat* format); + void parseFontSize(const QString& str, QTextCharFormat* format); + void parseFontFamily(const QString& str, QTextCharFormat* format); QHash _paletteColorRoles; + QHash _uiStyleColorRoles; - private: +private: QPalette _palette; + QVector _uiStylePalette; QHash _formats; - int _maxSenderHash; + QHash _listItemFormats; }; - -#endif