From ec2b99363141d3cad003b8533b5462a313ade3c1 Mon Sep 17 00:00:00 2001 From: Manuel Nickschas Date: Mon, 8 Jun 2009 09:46:15 +0200 Subject: [PATCH 1/1] Kill old non-stylesheet code from UiStyle Remove stuff that has been commented out for a while now and/or is no longer used within the new styleengine. This also disables most of the colorsettingspage for now. Consider this dialog dysfunctional, as it will be rewritten completely or probably even obsoleted soon. --- src/qtui/qtuistyle.cpp | 110 +- src/qtui/qtuistyle.h | 3 - .../settingspages/appearancesettingspage.cpp | 10 +- .../settingspages/appearancesettingspage.ui | 12 + src/qtui/settingspages/colorsettingspage.cpp | 52 +- src/qtui/settingspages/colorsettingspage.ui | 1772 +++++++++-------- src/uisupport/qssparser.h | 18 - src/uisupport/uistyle.cpp | 89 +- src/uisupport/uistyle.h | 93 +- 9 files changed, 952 insertions(+), 1207 deletions(-) diff --git a/src/qtui/qtuistyle.cpp b/src/qtui/qtuistyle.cpp index a3f5ea30..5ea72c19 100644 --- a/src/qtui/qtuistyle.cpp +++ b/src/qtui/qtuistyle.cpp @@ -21,109 +21,8 @@ #include "qtuistyle.h" #include "qtuisettings.h" -QtUiStyle::QtUiStyle() : UiStyle("QtUiStyle") { - // We need to just set our internal formats; everything else is done by the base class... +QtUiStyle::QtUiStyle() : UiStyle() { - // Internal message formats - QTextCharFormat plainMsg; - plainMsg.setForeground(QBrush("black")); - setFormat(PlainMsg, plainMsg, Settings::Default); - - QTextCharFormat notice; - notice.setForeground(QBrush("navy")); - setFormat(NoticeMsg, notice, Settings::Default); - - QTextCharFormat server; - server.setForeground(QBrush("navy")); - setFormat(ServerMsg, server, Settings::Default); - - QTextCharFormat error; - error.setForeground(QBrush("red")); - setFormat(ErrorMsg, error, Settings::Default); - - QTextCharFormat join; - join.setForeground(QBrush("green")); - setFormat(JoinMsg, join, Settings::Default); - - QTextCharFormat part; - part.setForeground(QBrush("indianred")); - setFormat(PartMsg, part, Settings::Default); - - QTextCharFormat quit; - quit.setForeground(QBrush("indianred")); - setFormat(QuitMsg, quit, Settings::Default); - - QTextCharFormat kick; - kick.setForeground(QBrush("indianred")); - setFormat(KickMsg, kick, Settings::Default); - - QTextCharFormat nren; - nren.setForeground(QBrush("magenta")); - setFormat(RenameMsg, nren, Settings::Default); - - QTextCharFormat mode; - mode.setForeground(QBrush("steelblue")); - setFormat(ModeMsg, mode, Settings::Default); - - QTextCharFormat action; - action.setFontItalic(true); - action.setForeground(QBrush("darkmagenta")); - setFormat(ActionMsg, action, Settings::Default); - - // Internal message element formats - QTextCharFormat ts; - ts.setForeground(QBrush("grey")); - setFormat(Timestamp, ts, Settings::Default); - - // Set the default sender color - QTextCharFormat sender; - sender.setAnchor(true); - sender.setForeground(QBrush("navy")); - setFormat(Sender, sender, Settings::Default); - - /* - * Fillup the list of colors used for sender auto coloring In this case - * These are Oxygen palette colors - */ - addSenderAutoColor(SenderCol01, "#989a95"); - addSenderAutoColor(SenderCol02, "#ef8440"); - addSenderAutoColor(SenderCol03, "#ffbf00"); - addSenderAutoColor(SenderCol04, "#49b13b"); - addSenderAutoColor(SenderCol05, "#00a778"); - addSenderAutoColor(SenderCol06, "#008b90"); - addSenderAutoColor(SenderCol07, "#0069ba"); - addSenderAutoColor(SenderCol08, "#563696"); - addSenderAutoColor(SenderCol09, "#ad3597"); - addSenderAutoColor(SenderCol10, "#e70083"); - addSenderAutoColor(SenderCol11, "#e70f00"); - addSenderAutoColor(SenderCol12, "#866127"); - - QTextCharFormat nick; - nick.setAnchor(true); - nick.setFontWeight(QFont::Bold); - setFormat(Nick, nick, Settings::Default); - - QTextCharFormat hostmask; - hostmask.setFontItalic(true); - setFormat(Hostmask, hostmask, Settings::Default); - - QTextCharFormat channel; - channel.setAnchor(true); - channel.setFontWeight(QFont::Bold); - setFormat(ChannelName, channel, Settings::Default); - - QTextCharFormat flags; - flags.setFontWeight(QFont::Bold); - setFormat(ModeFlags, flags, Settings::Default); - - QTextCharFormat url; - url.setFontUnderline(true); - url.setAnchor(true); - setFormat(Url, url, Settings::Default); - - QtUiStyleSettings s; - _highlightColor = s.highlightColor(); - if(!_highlightColor.isValid()) _highlightColor = QColor("lightcoral"); } QtUiStyle::~QtUiStyle() {} @@ -133,10 +32,3 @@ void QtUiStyle::setHighlightColor(const QColor &col) { QtUiStyleSettings s; s.setHighlightColor(col); } - -void QtUiStyle::addSenderAutoColor(FormatType type, const QString name) { - QTextCharFormat autoColor; - autoColor.setAnchor(true); - autoColor.setForeground(QBrush(QColor(name))); - setFormat(type, autoColor, Settings::Default); -} diff --git a/src/qtui/qtuistyle.h b/src/qtui/qtuistyle.h index 805ce4f4..270e2480 100644 --- a/src/qtui/qtuistyle.h +++ b/src/qtui/qtuistyle.h @@ -34,9 +34,6 @@ public: virtual inline QColor highlightColor() const { return _highlightColor; } virtual void setHighlightColor(const QColor &); -protected: - void inline addSenderAutoColor( FormatType type, const QString name ); - private: QColor _highlightColor; }; diff --git a/src/qtui/settingspages/appearancesettingspage.cpp b/src/qtui/settingspages/appearancesettingspage.cpp index 29b9335e..3346eeb3 100644 --- a/src/qtui/settingspages/appearancesettingspage.cpp +++ b/src/qtui/settingspages/appearancesettingspage.cpp @@ -144,8 +144,8 @@ void AppearanceSettingsPage::loadFonts(Settings::Mode mode) { bufferViewFont = s.value("BufferView", QFont()).value(); setFont(ui.demoBufferView, bufferViewFont); - QTextCharFormat chatFormat = QtUi::style()->format(UiStyle::None, mode); - setFont(ui.demoChatView, chatFormat.font()); + //QTextCharFormat chatFormat = QtUi::style()->cachedFormat(UiStyle::None, 0); // FIXME + //setFont(ui.demoChatView, chatFormat.font()); _fontsChanged = false; } @@ -183,9 +183,9 @@ void AppearanceSettingsPage::save() { else fontSettings.setValue("BufferView", ""); - QTextCharFormat chatFormat = QtUi::style()->format(UiStyle::None); - chatFormat.setFont(ui.demoChatView->font()); - QtUi::style()->setFormat(UiStyle::None, chatFormat, Settings::Custom); + //QTextCharFormat chatFormat = QtUi::style()->format(UiStyle::None); + //chatFormat.setFont(ui.demoChatView->font()); + //QtUi::style()->setFormat(UiStyle::None, chatFormat, Settings::Custom); _fontsChanged = false; diff --git a/src/qtui/settingspages/appearancesettingspage.ui b/src/qtui/settingspages/appearancesettingspage.ui index a988b837..87f871d4 100644 --- a/src/qtui/settingspages/appearancesettingspage.ui +++ b/src/qtui/settingspages/appearancesettingspage.ui @@ -58,12 +58,18 @@ + + true + Fonts + + false + Set font for the main chat window and the chat monitor @@ -74,6 +80,9 @@ + + false + 0 @@ -99,6 +108,9 @@ + + false + 0 diff --git a/src/qtui/settingspages/colorsettingspage.cpp b/src/qtui/settingspages/colorsettingspage.cpp index bf44ce70..2eb20c02 100644 --- a/src/qtui/settingspages/colorsettingspage.cpp +++ b/src/qtui/settingspages/colorsettingspage.cpp @@ -93,7 +93,7 @@ void ColorSettingsPage::defaultBufferview() { ui.otherActivityUseBG->setChecked(false); } -void ColorSettingsPage::defaultServerActivity() { +void ColorSettingsPage::defaultServerActivity() { /* ui.errorMessageFG->setColor(QtUi::style()->format(UiStyle::ErrorMsg, Settings::Default).foreground().color()); ui.errorMessageBG->setColor(QColor("white")); ui.errorMessageBG->setEnabled(false); @@ -110,10 +110,10 @@ void ColorSettingsPage::defaultServerActivity() { ui.serverMessageBG->setColor(QColor("white")); ui.serverMessageBG->setEnabled(false); ui.serverMessageUseBG->setChecked(false); - ui.highlightColor->setColor(QColor("lightcoral")); + ui.highlightColor->setColor(QColor("lightcoral")); */ } -void ColorSettingsPage::defaultUserActivity() { +void ColorSettingsPage::defaultUserActivity() { /* ui.actionMessageFG->setColor(QtUi::style()->format(UiStyle::ActionMsg, Settings::Default).foreground().color()); ui.actionMessageBG->setColor(QColor("white")); ui.actionMessageBG->setEnabled(false); @@ -141,10 +141,10 @@ void ColorSettingsPage::defaultUserActivity() { ui.renameMessageFG->setColor(QtUi::style()->format(UiStyle::RenameMsg, Settings::Default).foreground().color()); ui.renameMessageBG->setColor(QColor("white")); ui.renameMessageBG->setEnabled(false); - ui.renameMessageUseBG->setChecked(false); + ui.renameMessageUseBG->setChecked(false); */ } -void ColorSettingsPage::defaultMessage() { +void ColorSettingsPage::defaultMessage() { /* ui.timestampFG->setColor(QtUi::style()->format(UiStyle::Timestamp, Settings::Default).foreground().color()); ui.timestampBG->setColor(QColor("white")); ui.timestampBG->setEnabled(false); @@ -154,7 +154,7 @@ void ColorSettingsPage::defaultMessage() { ui.senderBG->setEnabled(false); ui.senderUseBG->setChecked(false); ui.senderAutoColor->setChecked(false); - ui.newMsgMarkerFG->setColor(Qt::red); + ui.newMsgMarkerFG->setColor(Qt::red); */ /* ui.nickFG->setColor(QColor("black")); @@ -180,7 +180,7 @@ void ColorSettingsPage::defaultMessage() { */ } -void ColorSettingsPage::defaultMircColorCodes() { +void ColorSettingsPage::defaultMircColorCodes() { /* ui.color0->setColor(QtUi::style()->format(UiStyle::FgCol00, Settings::Default).foreground().color()); ui.color1->setColor(QtUi::style()->format(UiStyle::FgCol01, Settings::Default).foreground().color()); ui.color2->setColor(QtUi::style()->format(UiStyle::FgCol02, Settings::Default).foreground().color()); @@ -196,7 +196,7 @@ void ColorSettingsPage::defaultMircColorCodes() { ui.color12->setColor(QtUi::style()->format(UiStyle::FgCol12, Settings::Default).foreground().color()); ui.color13->setColor(QtUi::style()->format(UiStyle::FgCol13, Settings::Default).foreground().color()); ui.color14->setColor(QtUi::style()->format(UiStyle::FgCol14, Settings::Default).foreground().color()); - ui.color15->setColor(QtUi::style()->format(UiStyle::FgCol15, Settings::Default).foreground().color()); + ui.color15->setColor(QtUi::style()->format(UiStyle::FgCol15, Settings::Default).foreground().color()); */ } void ColorSettingsPage::defaultNickview() { @@ -246,7 +246,7 @@ void ColorSettingsPage::load() { ui.otherActivityBG->setColor(settings["OtherActivityBG"].value()); settings["OtherActivityUseBG"] = s.value("otherActivityUseBG"); ui.otherActivityUseBG->setChecked(settings["OtherActivityUseBG"].toBool()); - +/* ui.actionMessageFG->setColor(QtUi::style()->format(UiStyle::ActionMsg).foreground().color()); ui.errorMessageFG->setColor(QtUi::style()->format(UiStyle::ErrorMsg).foreground().color()); ui.joinMessageFG->setColor(QtUi::style()->format(UiStyle::JoinMsg).foreground().color()); @@ -270,7 +270,7 @@ void ColorSettingsPage::load() { ui.quitMessageBG->setColor(QtUi::style()->format(UiStyle::QuitMsg).background().color()); ui.renameMessageBG->setColor(QtUi::style()->format(UiStyle::RenameMsg).background().color()); ui.serverMessageBG->setColor(QtUi::style()->format(UiStyle::ServerMsg).background().color()); - +*/ // FIXME set to false if appropriate settings["ActionMessageUseBG"] = s.value("actionMessageUseBG", QVariant(false)); if(settings["ActionMessageUseBG"].toBool()) { @@ -327,7 +327,7 @@ void ColorSettingsPage::load() { ui.serverMessageUseBG->setChecked(true); ui.serverMessageBG->setEnabled(true); } - +/* ui.timestampFG->setColor(QtUi::style()->format(UiStyle::Timestamp).foreground().color()); ui.timestampBG->setColor(QtUi::style()->format(UiStyle::Timestamp).background().color()); ui.senderFG->setColor(QtUi::style()->format(UiStyle::Sender).foreground().color()); @@ -337,6 +337,7 @@ void ColorSettingsPage::load() { ui.senderFG->setEnabled(!settings["SenderAutoColor"].toBool()); ui.senderAutoColor->setChecked(settings["SenderAutoColor"].toBool()); +*/ settings["NewMsgMarkerFG"] = s.value("newMsgMarkerFG", QColor(Qt::red)); ui.newMsgMarkerFG->setColor(settings["NewMsgMarkerFG"].value()); @@ -350,7 +351,7 @@ void ColorSettingsPage::load() { ui.senderUseBG->setChecked(true); ui.senderBG ->setEnabled(true); } - +/* ui.nickFG->setColor(QtUi::style()->format(UiStyle::Nick).foreground().color()); ui.nickBG->setColor(QtUi::style()->format(UiStyle::Nick).background().color()); ui.hostmaskFG->setColor(QtUi::style()->format(UiStyle::Hostmask).foreground().color()); @@ -361,9 +362,9 @@ void ColorSettingsPage::load() { ui.modeFlagsBG->setColor(QtUi::style()->format(UiStyle::ModeFlags).background().color()); ui.urlFG->setColor(QtUi::style()->format(UiStyle::Url).foreground().color()); ui.urlBG->setColor(QtUi::style()->format(UiStyle::Url).background().color()); - +*/ ui.highlightColor->setColor(QtUi::style()->highlightColor()); - +/* ui.color0->setColor(QtUi::style()->format(UiStyle::FgCol00).foreground().color()); ui.color1->setColor(QtUi::style()->format(UiStyle::FgCol01).foreground().color()); ui.color2->setColor(QtUi::style()->format(UiStyle::FgCol02).foreground().color()); @@ -380,7 +381,7 @@ void ColorSettingsPage::load() { ui.color13->setColor(QtUi::style()->format(UiStyle::FgCol13).foreground().color()); ui.color14->setColor(QtUi::style()->format(UiStyle::FgCol14).foreground().color()); ui.color15->setColor(QtUi::style()->format(UiStyle::FgCol15).foreground().color()); - +*/ settings["OnlineStatusFG"] = s.value("onlineStatusFG", QVariant(QColor(Qt::black))); ui.onlineStatusFG->setColor(settings["OnlineStatusFG"].value()); settings["OnlineStatusBG"] = s.value("onlineStatusBG", QVariant(QColor(Qt::white))); @@ -450,7 +451,7 @@ void ColorSettingsPage::save() { saveColor(UiStyle::Sender, ui.senderFG->color(), ui.senderBG->color(), ui.senderUseBG->isChecked()); s.setValue("senderUseBG", ui.senderUseBG->isChecked()); s.setValue("SenderAutoColor", ui.senderAutoColor->isChecked()); - QtUi::style()->setSenderAutoColor(ui.senderAutoColor->isChecked()); + //QtUi::style()->setSenderAutoColor(ui.senderAutoColor->isChecked()); s.setValue("newMsgMarkerFG", ui.newMsgMarkerFG->color()); /* @@ -494,20 +495,20 @@ void ColorSettingsPage::save() { setChangedState(false); } -void ColorSettingsPage::saveColor(UiStyle::FormatType formatType, const QColor &foreground, const QColor &background, bool enableBG) { +void ColorSettingsPage::saveColor(UiStyle::FormatType /*formatType*/, const QColor &/*foreground*/, const QColor &/*background*/, bool /*enableBG*/) { /* QTextCharFormat format = QtUi::style()->format(formatType); format.setForeground(QBrush(foreground)); if(enableBG) format.setBackground(QBrush(background)); else format.clearBackground(); - QtUi::style()->setFormat(formatType, format, Settings::Custom); + QtUi::style()->setFormat(formatType, format, Settings::Custom); */ } -void ColorSettingsPage::saveMircColor(int num, const QColor &col) { +void ColorSettingsPage::saveMircColor(int /*num*/, const QColor &/*col*/) { /* QTextCharFormat fgf, bgf; fgf.setForeground(QBrush(col)); QtUi::style()->setFormat((UiStyle::FormatType)(UiStyle::FgCol00 | num<<24), fgf, Settings::Custom); - bgf.setBackground(QBrush(col)); QtUi::style()->setFormat((UiStyle::FormatType)(UiStyle::BgCol00 | num<<28), bgf, Settings::Custom); + bgf.setBackground(QBrush(col)); QtUi::style()->setFormat((UiStyle::FormatType)(UiStyle::BgCol00 | num<<28), bgf, Settings::Custom); */ } void ColorSettingsPage::widgetHasChanged() { @@ -535,7 +536,7 @@ bool ColorSettingsPage::testHasChanged() { if(settings["OtherActivityFG"].value() != ui.otherActivityFG->color()) return true; if(settings["OtherActivityBG"].value() != ui.otherActivityBG->color()) return true; if(settings["OtherActivityUseBG"].toBool() != ui.otherActivityUseBG->isChecked()) return true; - +/* if(QtUi::style()->format(UiStyle::ErrorMsg).foreground().color() != ui.errorMessageFG->color()) return true; if(QtUi::style()->format(UiStyle::ErrorMsg).background().color() != ui.errorMessageBG->color()) return true; if(settings["ErrorMessageUseBG"].toBool() != ui.errorMessageUseBG->isChecked()) return true; @@ -572,9 +573,9 @@ bool ColorSettingsPage::testHasChanged() { if(QtUi::style()->format(UiStyle::RenameMsg).foreground().color() != ui.renameMessageFG->color()) return true; if(QtUi::style()->format(UiStyle::RenameMsg).background().color() != ui.renameMessageBG->color()) return true; if(settings["RenameMessageUseBG"].toBool() != ui.renameMessageUseBG->isChecked()) return true; - +*/ if(QtUi::style()->highlightColor() != ui.highlightColor->color()) return true; - +/* if(QtUi::style()->format(UiStyle::Timestamp).foreground().color() != ui.timestampFG->color()) return true; if(QtUi::style()->format(UiStyle::Timestamp).background().color() != ui.timestampBG->color()) return true; if(settings["TimestampUseBG"].toBool() != ui.timestampUseBG->isChecked()) return true; @@ -582,6 +583,7 @@ bool ColorSettingsPage::testHasChanged() { if(QtUi::style()->format(UiStyle::Sender).background().color() != ui.senderBG->color()) return true; if(settings["SenderUseBG"].toBool() != ui.senderUseBG->isChecked()) return true; if(settings["SenderAutoColor"].toBool() != ui.senderAutoColor->isChecked()) return true; +*/ if(settings["NewMsgMarkerFG"].value() != ui.newMsgMarkerFG->color()) return true; /* @@ -601,7 +603,7 @@ bool ColorSettingsPage::testHasChanged() { if(QtUi::style()->format(UiStyle::Url).background().color() != ui.urlBG->color()) return true; if(settings["urlUseBG"].toBool() != ui.urlUseBG->isChecked()) return true; */ - +/* if(QtUi::style()->format(UiStyle::FgCol00).foreground().color() != ui.color0->color()) return true; if(QtUi::style()->format(UiStyle::FgCol01).foreground().color() != ui.color1->color()) return true; if(QtUi::style()->format(UiStyle::FgCol02).foreground().color() != ui.color2->color()) return true; @@ -618,7 +620,7 @@ bool ColorSettingsPage::testHasChanged() { if(QtUi::style()->format(UiStyle::FgCol13).foreground().color() != ui.color13->color()) return true; if(QtUi::style()->format(UiStyle::FgCol14).foreground().color() != ui.color14->color()) return true; if(QtUi::style()->format(UiStyle::FgCol15).foreground().color() != ui.color15->color()) return true; - +*/ if(settings["OnlineStatusFG"].value() != ui.onlineStatusFG->color()) return true; if(settings["OnlineStatusBG"].value() != ui.onlineStatusBG->color()) return true; if(settings["OnlineStatusUseBG"].toBool() != ui.onlineStatusUseBG->isChecked()) return true; diff --git a/src/qtui/settingspages/colorsettingspage.ui b/src/qtui/settingspages/colorsettingspage.ui index 6d0fee98..bf7fe08f 100644 --- a/src/qtui/settingspages/colorsettingspage.ui +++ b/src/qtui/settingspages/colorsettingspage.ui @@ -1,7 +1,8 @@ - + + ColorSettingsPage - - + + 0 0 @@ -9,298 +10,301 @@ 442 - - + + 0 0 - + Form - + - - + + + true + + 0 - - + + Bufferview - - - - + + + + Activities: - - - - + + + + Foreground - + Qt::AlignCenter - - - + + + BG - + Qt::AlignCenter - + true - - - + + + Use BG - + Qt::AlignCenter - + true - - - + + + Default: - - - + + + - - - + + + false - - + + 0 0 - + - + true - - - - + + + + 0 0 - + - + true - - - + + + Inactive: - - - + + + - - - + + + false - + - + true - - - - + + + + 0 0 - + Qt::LeftToRight - + - + true - - - + + + Highlight: - - - + + + - - - + + + false - + - + true - - - - + + + + 0 0 - + - + true - - - + + + New Message: - - - + + + - - - + + + false - + - + true - - - - + + + + 0 0 - + - + true - - - + + + Other Activity: - - - + + + - - - + + + false - + - + true - - - - + + + + 0 0 - + - + true - + - + Qt::Vertical - + 20 40 @@ -311,16 +315,16 @@ - - - + + + Preview: - + - + - + 1 @@ -329,12 +333,12 @@ - + - + Qt::Vertical - + 318 171 @@ -344,33 +348,203 @@ - - + + + Nickview + + + + + + Nick status: + + + + + + Foreground + + + Qt::AlignCenter + + + + + + + BG + + + Qt::AlignCenter + + + true + + + + + + + Use BG + + + Qt::AlignCenter + + + true + + + + + + + Online: + + + + + + + + + + + + + + false + + + + + + true + + + + + + + + 0 + 0 + + + + Qt::LeftToRight + + + + + + true + + + + + + + Away: + + + + + + + + + + + + + + false + + + + + + true + + + + + + + + 0 + 0 + + + + + + + true + + + + + + + Qt::Vertical + + + + 20 + 40 + + + + + + + + + + + Qt::Vertical + + + + 261 + 151 + + + + + + + + Chatview - + - - - + + + false + + + 0 0 - + 0 - - + + Server Activity - - + + - + Qt::Vertical - + 20 40 @@ -378,611 +552,611 @@ - - - + + + Foreground - + Qt::AlignCenter - - - + + + Background - + Qt::AlignCenter - - - + + + Use BG - + Qt::AlignCenter - + true - - - + + + Error Message: - - - + + + - - - + + + false - + - + true - - - - + + + + 0 0 - + Qt::LeftToRight - + - + true - - - + + + Notice Message: - - - + + + - - - + + + false - + - + true - - - - + + + + 0 0 - + Qt::LeftToRight - + - + true - - - + + + Plain Message: - - - + + + - - - + + + false - + - + true - - - - + + + + 0 0 - + Qt::LeftToRight - + - + true - - - + + + Server Message: - - - + + + - - - + + + false - + - + true - - - - + + + + 0 0 - + Qt::LeftToRight - + - + true - - - + + + Highlight Message: - - - - true + + + + false - + - - + + User Activity - - - - + + + + Foreground - + Qt::AlignCenter - - - + + + Background - + Qt::AlignCenter - + true - - - + + + Use BG - + Qt::AlignCenter - + true - - - + + + Action Message: - - - + + + - - - + + + false - + - + true - - - - + + + + 0 0 - + Qt::LeftToRight - + - + true - - - + + + Join Message: - - - + + + - - - + + + false - + - + true - - - - + + + + 0 0 - + Qt::LeftToRight - + - + true - - - + + + Kick Message: - - - + + + - - - + + + false - + - + true - - - - + + + + 0 0 - + Qt::LeftToRight - + - + true - - - + + + Mode Message: - - - + + + - - - + + + false - + - + true - - - - + + + + 0 0 - + Qt::LeftToRight - + - + true - - - + + + Part Message: - - - + + + - - - + + + false - + - + true - - - - + + + + 0 0 - + Qt::LeftToRight - + - + true - - - + + + Quit Message: - - - + + + - - - + + + false - + - + true - - - - + + + + 0 0 - + Qt::LeftToRight - + - + true - - - + + + Rename Message: - - - + + + - - - + + + false - + - + true - - - - + + + + 0 0 - + Qt::LeftToRight - + - + true - - - + + + Qt::Vertical - + 20 40 @@ -992,436 +1166,436 @@ - - + + Message - - - - + + + + Foreground - + Qt::AlignCenter - - - + + + Background - + Qt::AlignCenter - + true - - - + + + Use BG - + Qt::AlignCenter - + true - - - + + + Timestamp: - - - + + + - - - + + + false - + - + true - - - - + + + + 0 0 - + Qt::LeftToRight - + - + true - - - + + + Sender: - - - + + + Nick: - + true - - - + + + - + true - - - + + + false - + - + true - - - - + + + + 0 0 - + Qt::LeftToRight - + - + true - - - + + + Hostmask: - + true - - - + + + - + true - - - + + + false - + - + true - - - - + + + + 0 0 - + Qt::LeftToRight - + - + true - - - + + + Channelname: - + true - - - + + + - + true - - - + + + false - + - + true - - - - + + + + 0 0 - + Qt::LeftToRight - + - + true - - - + + + Mode flags: - + true - - - + + + - + true - - - + + + false - + - + true - - - - + + + + 0 0 - + Qt::LeftToRight - + - + true - - - + + + Url: - + true - - - + + + - + true - - - + + + false - + - + true - - - - + + + + 0 0 - + Qt::LeftToRight - + - + true - - - + + + New Message Marker: - - - + + + - - - + + + Enable - - - + + + Sender auto coloring: - - - + + + false - + - + true - - - + + + - + false - - - - + + + + 0 0 - + Qt::LeftToRight - + - + true - - - + + + Qt::Vertical - + 20 40 @@ -1434,11 +1608,11 @@ - - + + Qt::Vertical - + 20 40 @@ -1448,243 +1622,246 @@ - - + + Mirc Color Codes - + - - - + + + false + + + 0 0 - + Color Codes - - - - + + + + Color 0: - - - + + + - - - + + + - - - + + + Color 1: - - - + + + - - - + + + - - - + + + Color 2: - - - + + + - - - + + + - - - + + + Color 3: - - - + + + - - - + + + - - - + + + Color 4: - - - + + + - - - + + + - - - + + + Color 5: - - - + + + - - - + + + - - - + + + Color 6: - - - + + + - - - + + + - - - + + + Color 7: - - - + + + - - - + + + - - - + + + Color 8: - - - + + + Color 14: - - - + + + Color 15: - - - + + + Color 13: - - - + + + Color 12: - - - + + + Color 11: - - - + + + Color 10: - - - + + + Color 9: @@ -1694,10 +1871,10 @@ - + Qt::Vertical - + 140 291 @@ -1707,173 +1884,6 @@ - - - Nickview - - - - - - Nick status: - - - - - - Foreground - - - Qt::AlignCenter - - - - - - - BG - - - Qt::AlignCenter - - - true - - - - - - - Use BG - - - Qt::AlignCenter - - - true - - - - - - - Online: - - - - - - - - - - - - - - false - - - - - - true - - - - - - - - 0 - 0 - - - - Qt::LeftToRight - - - - - - true - - - - - - - Away: - - - - - - - - - - - - - - false - - - - - - true - - - - - - - - 0 - 0 - - - - - - - true - - - - - - - Qt::Vertical - - - - 20 - 40 - - - - - - - - - - - Qt::Vertical - - - - 261 - 151 - - - - - - @@ -1893,11 +1903,11 @@ inactiveActivityBG setEnabled(bool) - + 249 111 - + 197 111 @@ -1909,11 +1919,11 @@ noActivityBG setEnabled(bool) - + 249 147 - + 197 147 @@ -1925,11 +1935,11 @@ highlightActivityBG setEnabled(bool) - + 249 183 - + 197 183 @@ -1941,11 +1951,11 @@ newMessageActivityBG setEnabled(bool) - + 249 219 - + 197 219 @@ -1957,11 +1967,11 @@ otherActivityBG setEnabled(bool) - + 249 255 - + 197 255 @@ -1973,11 +1983,11 @@ onlineStatusBG setEnabled(bool) - + 202 111 - + 150 111 @@ -1989,11 +1999,11 @@ awayStatusBG setEnabled(bool) - + 202 147 - + 150 147 @@ -2005,11 +2015,11 @@ errorMessageBG setEnabled(bool) - + 374 119 - + 280 119 @@ -2021,11 +2031,11 @@ noticeMessageBG setEnabled(bool) - + 374 155 - + 280 155 @@ -2037,11 +2047,11 @@ plainMessageBG setEnabled(bool) - + 374 191 - + 280 191 @@ -2053,11 +2063,11 @@ serverMessageBG setEnabled(bool) - + 374 227 - + 280 227 @@ -2069,11 +2079,11 @@ actionMessageBG setEnabled(bool) - + 376 121 - + 285 121 @@ -2085,11 +2095,11 @@ joinMessageBG setEnabled(bool) - + 376 157 - + 285 157 @@ -2101,11 +2111,11 @@ kickMessageBG setEnabled(bool) - + 376 193 - + 285 193 @@ -2117,11 +2127,11 @@ modeMessageBG setEnabled(bool) - + 376 229 - + 285 229 @@ -2133,11 +2143,11 @@ partMessageBG setEnabled(bool) - + 376 265 - + 285 265 @@ -2149,11 +2159,11 @@ quitMessageBG setEnabled(bool) - + 376 301 - + 285 301 @@ -2165,11 +2175,11 @@ renameMessageBG setEnabled(bool) - + 376 337 - + 285 337 @@ -2181,11 +2191,11 @@ timestampBG setEnabled(bool) - + 372 121 - + 273 121 @@ -2197,11 +2207,11 @@ nickBG setEnabled(bool) - + 372 193 - + 273 193 @@ -2213,11 +2223,11 @@ hostmaskBG setEnabled(bool) - + 372 229 - + 273 229 @@ -2229,11 +2239,11 @@ channelnameBG setEnabled(bool) - + 372 265 - + 273 265 @@ -2245,11 +2255,11 @@ modeFlagsBG setEnabled(bool) - + 372 301 - + 273 301 @@ -2261,11 +2271,11 @@ urlBG setEnabled(bool) - + 372 337 - + 273 337 @@ -2277,11 +2287,11 @@ senderBG setEnabled(bool) - + 463 143 - + 376 143 @@ -2293,11 +2303,11 @@ senderFG setDisabled(bool) - + 232 173 - + 232 143 diff --git a/src/uisupport/qssparser.h b/src/uisupport/qssparser.h index c5f86eec..0db59b51 100644 --- a/src/uisupport/qssparser.h +++ b/src/uisupport/qssparser.h @@ -27,27 +27,11 @@ class QssParser { Q_DECLARE_TR_FUNCTIONS(QssParser) public: - enum Column { - Any, - Timestamp, - Sender, - Contents - }; - - struct ChatLineFormat { - QVector senderColors; - QVector mircColors; - QHash formats; - - }; - QssParser(); void loadStyleSheet(const QString &sheet); inline QPalette palette() const { return _palette; } - ChatLineFormat basicFormat() const; - QHash specialFormats() const; protected: typedef QList ColorTuple; @@ -73,8 +57,6 @@ class QssParser { private: QPalette _palette; - ChatLineFormat _basicFormat; - QHash _specialFormats; int _maxSenderHash; }; diff --git a/src/uisupport/uistyle.cpp b/src/uisupport/uistyle.cpp index e0dbce9c..e1684f2e 100644 --- a/src/uisupport/uistyle.cpp +++ b/src/uisupport/uistyle.cpp @@ -25,7 +25,7 @@ #include "uisettings.h" #include "util.h" -UiStyle::UiStyle(const QString &settingsKey) : _settingsKey(settingsKey) { +UiStyle::UiStyle() { // 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) { @@ -34,24 +34,6 @@ UiStyle::UiStyle(const QString &settingsKey) : _settingsKey(settingsKey) { Q_ASSERT(QVariant::nameToType("UiStyle::FormatList") != QVariant::Invalid); } - _defaultFont = QFont("Monospace", QApplication::font().pointSize()); - - // Default format - _defaultPlainFormat.setForeground(QBrush("#000000")); - _defaultPlainFormat.setFont(_defaultFont); - _defaultPlainFormat.font().setFixedPitch(true); - _defaultPlainFormat.font().setStyleHint(QFont::TypeWriter); - setFormat(None, _defaultPlainFormat, Settings::Default); - - // Load saved custom formats - UiStyleSettings s(_settingsKey); - foreach(FormatType type, s.availableFormats()) { - _customFormats[type] = s.customFormat(type); - } - - // Check for the sender auto coloring option - _senderAutoColor = s.value("Colors/SenderAutoColor", false).toBool(); - // Now initialize the mapping between FormatCodes and FormatTypes... _formatCodes["%O"] = None; _formatCodes["%B"] = Bold; @@ -79,33 +61,6 @@ UiStyle::UiStyle(const QString &settingsKey) : _settingsKey(settingsKey) { _formatCodes["%DM"] = ModeFlags; _formatCodes["%DU"] = Url; - // Initialize color codes according to mIRC "standard" - QStringList colors; - //colors << "white" << "black" << "navy" << "green" << "red" << "maroon" << "purple" << "orange"; - //colors << "yellow" << "lime" << "teal" << "aqua" << "royalblue" << "fuchsia" << "grey" << "silver"; - colors << "#ffffff" << "#000000" << "#000080" << "#008000" << "#ff0000" << "#800000" << "#800080" << "#ffa500"; - colors << "#ffff00" << "#00ff00" << "#008080" << "#00ffff" << "#4169E1" << "#ff00ff" << "#808080" << "#c0c0c0"; - - // Set color formats - for(int i = 0; i < 16; i++) { - QString idx = QString("%1").arg(i, (int)2, (int)10, (QChar)'0'); - _formatCodes[QString("%Dcf%1").arg(idx)] = (FormatType)(FgCol00 | i<<24); - _formatCodes[QString("%Dcb%1").arg(idx)] = (FormatType)(BgCol00 | i<<28); - QTextCharFormat fgf, bgf; - fgf.setForeground(QBrush(QColor(colors[i]))); setFormat((FormatType)(FgCol00 | i<<24), fgf, Settings::Default); - bgf.setBackground(QBrush(QColor(colors[i]))); setFormat((FormatType)(BgCol00 | i<<28), bgf, Settings::Default); - } - - // Set a few more standard formats - QTextCharFormat bold; bold.setFontWeight(QFont::Bold); - setFormat(Bold, bold, Settings::Default); - - QTextCharFormat italic; italic.setFontItalic(true); - setFormat(Italic, italic, Settings::Default); - - QTextCharFormat underline; underline.setFontUnderline(true); - setFormat(Underline, underline, Settings::Default); -*/ loadStyleSheet(); } @@ -113,42 +68,6 @@ UiStyle::~ UiStyle() { qDeleteAll(_metricsCache); } -void UiStyle::setFormat(FormatType ftype, QTextCharFormat fmt, Settings::Mode mode) { - if(mode == Settings::Default) { - _defaultFormats[ftype] = fmt; - } else { - UiStyleSettings s(_settingsKey); - if(fmt != _defaultFormats[ftype]) { - _customFormats[ftype] = fmt; - s.setCustomFormat(ftype, fmt); - } else { - _customFormats.remove(ftype); - s.removeCustomFormat(ftype); - } - } - // TODO: invalidate only affected cached formats... if that's possible with less overhead than just rebuilding them - qDeleteAll(_metricsCache); - _metricsCache.clear(); - _formatCache.clear(); -} - -void UiStyle::setSenderAutoColor( bool state ) { - _senderAutoColor = state; - UiStyleSettings s(_settingsKey); - s.setValue("Colors/SenderAutoColor", QVariant(state)); -} - -QTextCharFormat UiStyle::format(FormatType ftype, Settings::Mode mode) const { - // Check for enabled sender auto coloring - if ( (ftype & 0x00000fff) == Sender && !_senderAutoColor ) { - // Just use the default sender style if auto coloring is disabled FIXME - ftype = Sender; - } - - if(mode == Settings::Custom && _customFormats.contains(ftype)) return _customFormats.value(ftype); - else return _defaultFormats.value(ftype, QTextCharFormat()); -} - QTextCharFormat UiStyle::cachedFormat(quint64 key) const { return _formatCache.value(key, QTextCharFormat()); } @@ -178,7 +97,7 @@ void UiStyle::mergeSubElementFormat(QTextCharFormat& fmt, quint32 ftype, quint32 // NOTE: This function is intimately tied to the values in FormatType. Don't change this // until you _really_ know what you do! -QTextCharFormat UiStyle::mergedFormat(quint32 ftype, quint32 label) { +QTextCharFormat UiStyle::format(quint32 ftype, quint32 label) { if(ftype == Invalid) return QTextCharFormat(); @@ -227,7 +146,7 @@ QFontMetricsF *UiStyle::fontMetrics(quint32 ftype, quint32 label) { if(_metricsCache.contains(key)) return _metricsCache.value(key); - return (_metricsCache[key] = new QFontMetricsF(mergedFormat(ftype, label).font())); + return (_metricsCache[key] = new QFontMetricsF(format(ftype, label).font())); } UiStyle::FormatType UiStyle::formatType(const QString & code) const { @@ -244,7 +163,7 @@ QList UiStyle::toTextLayoutList(const FormatList &form QTextLayout::FormatRange range; int i = 0; for(i = 0; i < formatList.count(); i++) { - range.format = mergedFormat(formatList.at(i).second); + range.format = format(formatList.at(i).second); range.start = formatList.at(i).first; if(i > 0) formatRanges.last().length = range.start - formatRanges.last().start; formatRanges.append(range); diff --git a/src/uisupport/uistyle.h b/src/uisupport/uistyle.h index ae0ad293..60123e29 100644 --- a/src/uisupport/uistyle.h +++ b/src/uisupport/uistyle.h @@ -36,7 +36,7 @@ class UiStyle { Q_DECLARE_TR_FUNCTIONS(UiStyle) public: - UiStyle(const QString &settingsKey); + UiStyle(); virtual ~UiStyle(); typedef QList > FormatList; @@ -80,72 +80,16 @@ public: ModeFlags = 0x00002000, // URL is special, we want that to take precedence over the rest... - Url = 0x00080000, + Url = 0x00080000 // mIRC Colors - we assume those to be present only in plain contents - FgCol00 = 0x00400000, - FgCol01 = 0x01400000, - FgCol02 = 0x02400000, - FgCol03 = 0x03400000, - FgCol04 = 0x04400000, - FgCol05 = 0x05400000, - FgCol06 = 0x06400000, - FgCol07 = 0x07400000, - FgCol08 = 0x08400000, - FgCol09 = 0x09400000, - FgCol10 = 0x0a400000, - FgCol11 = 0x0b400000, - FgCol12 = 0x0c400000, - FgCol13 = 0x0d400000, - FgCol14 = 0x0e400000, - FgCol15 = 0x0f400000, - - BgCol00 = 0x00800000, - BgCol01 = 0x10800000, - BgCol02 = 0x20800000, - BgCol03 = 0x30800000, - BgCol04 = 0x40800000, - BgCol05 = 0x50800000, - BgCol06 = 0x60800000, - BgCol07 = 0x70800000, - BgCol08 = 0x80800000, - BgCol09 = 0x90800000, - BgCol10 = 0xa0800000, - BgCol11 = 0xb0800000, - BgCol12 = 0xc0800000, - BgCol13 = 0xd0800000, - BgCol14 = 0xe0800000, - BgCol15 = 0xf0800000, - - // Colors used for sender auto coloring - // (starting at 01 because 00 is the default Sender format) - SenderCol01 = 0x01000200, - SenderCol02 = 0x02000200, - SenderCol03 = 0x03000200, - SenderCol04 = 0x04000200, - SenderCol05 = 0x05000200, - SenderCol06 = 0x06000200, - SenderCol07 = 0x07000200, - SenderCol08 = 0x08000200, - SenderCol09 = 0x09000200, - SenderCol10 = 0x0a000200, - SenderCol11 = 0x0b000200, - SenderCol12 = 0x0c000200, - SenderCol13 = 0x0d000200, - SenderCol14 = 0x0e000200, - SenderCol15 = 0x0f000200, - SenderCol16 = 0x10000200, - SenderCol17 = 0x11000200, - SenderCol18 = 0x12000200, - SenderCol19 = 0x13000200, - SenderCol20 = 0x14000200, - SenderCol21 = 0x15000200, - - SenderColSelf = 0xff000200 + // foreground: 0x0.400000 + // background: 0x.0800000 }; enum MessageLabel { - Highlight = 0x00000001 + OwnMsg = 0x00000001, + Highlight = 0x00000002 }; struct StyledString { @@ -154,25 +98,13 @@ public: }; class StyledMessage; - class QssParser; StyledString styleString(const QString &); QString mircToInternal(const QString &) const; - void setFormat(FormatType, QTextCharFormat, Settings::Mode mode/* = Settings::Custom*/); // FIXME go away - void setSenderAutoColor(bool state); // FIXME go away - QTextCharFormat format(FormatType, Settings::Mode mode = Settings::Custom) const; // FIXME go away - - QTextCharFormat cachedFormat(quint64 key) const; - QTextCharFormat cachedFormat(quint32 formatType, quint32 messageLabel = 0) const; - void setCachedFormat(const QTextCharFormat &format, quint32 formatType, quint32 messageLabel = 0); - - QTextCharFormat mergedFormat(quint32 formatType, quint32 messageLabel = 0); + QTextCharFormat format(quint32 formatType, quint32 messageLabel = 0); QFontMetricsF *fontMetrics(quint32 formatType, quint32 messageLabel = 0); - FormatType formatType(const QString &code) const; - QString formatCode(FormatType) const; - inline QFont defaultFont() const { return _defaultFont; } QList toTextLayoutList(const FormatList &, int textLength); @@ -184,20 +116,19 @@ protected: //int formatSetIndex(const QString &hostmask) const; //int formatSetIndexForSelf() const; + QTextCharFormat cachedFormat(quint64 key) const; + QTextCharFormat cachedFormat(quint32 formatType, quint32 messageLabel = 0) const; + void setCachedFormat(const QTextCharFormat &format, quint32 formatType, quint32 messageLabel = 0); void mergeSubElementFormat(QTextCharFormat &format, quint32 formatType, quint32 messageLabel = 0); - bool _senderAutoColor; + FormatType formatType(const QString &code) const; + QString formatCode(FormatType) const; private: QFont _defaultFont; - QTextCharFormat _defaultPlainFormat; - QHash _defaultFormats; - QHash _customFormats; QHash _formatCache; QHash _metricsCache; QHash _formatCodes; - - QString _settingsKey; }; class UiStyle::StyledMessage : public Message { -- 2.20.1