diff --git a/misc/style.cpp b/misc/style.cpp index fb8378579..b4d1cc209 100644 --- a/misc/style.cpp +++ b/misc/style.cpp @@ -27,28 +27,29 @@ // helper functions QFont appFont(int pixelSize, int weight) { - auto font = QFont(); + QFont font; font.setPixelSize(pixelSize); font.setWeight(weight); return font; } -QString cssifyWeight(int weight) +QString qssifyWeight(int weight) { QString weightStr = "normal"; if (weight == QFont::Bold) weightStr = "bold"; if (weight == QFont::Light) - weightStr = "lighter"; + weightStr = "light"; return QString("%1").arg(weightStr); } -QString cssifyFont(QFont font) +QString qssifyFont(QFont font) { - return QString("%1px %2") + return QString("%1px %2 \"%3\"") .arg(font.pixelSize()) - .arg(font.weight()); + .arg(qssifyWeight(font.weight())) + .arg(font.family()); } QString Style::getStylesheet(const QString &filename) @@ -112,13 +113,13 @@ QString Style::resolve(QString qss) {"@white", getColor(White).name()}, // fonts - {"@extraBig", cssifyFont(getFont(ExtraBig))}, - {"@big", cssifyFont(getFont(Big))}, - {"@bigBold", cssifyFont(getFont(BigBold))}, - {"@medium", cssifyFont(getFont(Medium))}, - {"@mediumBold", cssifyFont(getFont(MediumBold))}, - {"@small", cssifyFont(getFont(Small))}, - {"@smallLight", cssifyFont(getFont(SmallLight))}, + {"@extraBig", qssifyFont(getFont(ExtraBig))}, + {"@big", qssifyFont(getFont(Big))}, + {"@bigBold", qssifyFont(getFont(BigBold))}, + {"@medium", qssifyFont(getFont(Medium))}, + {"@mediumBold", qssifyFont(getFont(MediumBold))}, + {"@small", qssifyFont(getFont(Small))}, + {"@smallLight", qssifyFont(getFont(SmallLight))}, }; for (const QString& key : dict.keys()) diff --git a/ui/chatArea/innerStyle.css b/ui/chatArea/innerStyle.css index 28bcb32c8..fd0ca03ee 100644 --- a/ui/chatArea/innerStyle.css +++ b/ui/chatArea/innerStyle.css @@ -1,25 +1,31 @@ -div.name_me { - color: #646464; - font-weight: bold; - padding-right: 3px; -} - div.name { - color: #000000; - font-weight: bold; - padding-right: 3px; + color: @black; + font: @big; } div.message { - color: #000000; - padding-right: 3px; - padding-left: 3px; + color: @black; + font: @big; } div.date { - color: #000000; - padding-left: 3px; - white-space: nowrap; + color: @black; + font: @big; +} + +div.name_me { + color: @mediumGrey; + font: @big; +} + +div.message_me { + color: @mediumGrey; + font: @big; +} + +div.date_me { + color: @mediumGrey; + font: @big; } span.quote { @@ -31,9 +37,9 @@ div.green { margin-bottom: 12px; margin-left: 12px; margin-right: 12px; - color: #ffffff; - background-color: #6bc260; - font-size: 10px; + color: @white; + background-color: @green; + font: @small; } div.silver { @@ -41,9 +47,9 @@ div.silver { margin-bottom: 12px; margin-left: 12px; margin-right: 12px; - color: #000000; - background-color: #d1d1d1; - font-size: 10px; + color: @black; + background-color: @lightGrey; + font: @small; } div.red { @@ -51,14 +57,14 @@ div.red { margin-bottom: 12px; margin-left: 12px; margin-right: 12px; - color: #ffffff; - background-color: rgb(200,78,78); - font-size: 10px; + color: @white; + background-color: @red; + font: @small; } div.button { margin-top: 0px; margin-bottom: 0px; margin-left: 0px; - color: #ffffff; + color: @white; } diff --git a/ui/chatroomWidgets/genericChatroomWidget.css b/ui/chatroomWidgets/genericChatroomWidget.css new file mode 100644 index 000000000..4ed573fb0 --- /dev/null +++ b/ui/chatroomWidgets/genericChatroomWidget.css @@ -0,0 +1,38 @@ +GenericChatroomWidget +{ + background-color: @mediumGrey; +} + +GenericChatroomWidget[active="true"] +{ + background-color: @white; +} + +GenericChatroomWidget[active="false"]:hover +{ + background-color: @mediumGreyLight; +} + +GenericChatroomWidget[active="true"] > QLabel#status +{ + font: @medium; + color: @mediumGrey; +} + +GenericChatroomWidget[active="false"] > QLabel#status +{ + font: @medium; + color: @lightGrey; +} + +GenericChatroomWidget[active="true"] > QLabel#name +{ + font: @big; + color: @darkGrey; +} + +GenericChatroomWidget[active="false"] > QLabel#name +{ + font: @big; + color: @white; +} \ No newline at end of file diff --git a/ui/emoticonWidget/emoticonWidget.css b/ui/emoticonWidget/emoticonWidget.css index eb168a07e..093db5122 100644 --- a/ui/emoticonWidget/emoticonWidget.css +++ b/ui/emoticonWidget/emoticonWidget.css @@ -35,6 +35,6 @@ QRadioButton::indicator::checked QMenu { - background-color: #414141; /* sets background of the menu */ + background-color: @mediumGrey; /* sets background of the menu */ border: 0px solid; } diff --git a/ui/msgEdit/msgEdit.css b/ui/msgEdit/msgEdit.css index 2509f57fc..bbc967ccc 100644 --- a/ui/msgEdit/msgEdit.css +++ b/ui/msgEdit/msgEdit.css @@ -1,5 +1,5 @@ QTextEdit { - border-color: #c4c1bd; + border-color: @lightGrey; border-style: solid; border-width: 1px 0 1px 1px; } diff --git a/widget/chatareawidget.cpp b/widget/chatareawidget.cpp index c2e7a90b6..a2c1d6384 100644 --- a/widget/chatareawidget.cpp +++ b/widget/chatareawidget.cpp @@ -36,19 +36,20 @@ ChatAreaWidget::ChatAreaWidget(QWidget *parent) : setAcceptRichText(false); setFrameStyle(QFrame::NoFrame); - chatTextTable = textCursor().insertTable(1,3); - QTextTableFormat tableFormat; + tableFormat.setCellSpacing(15); tableFormat.setBorderStyle(QTextFrameFormat::BorderStyle_None); - tableFormat.setCellSpacing(2); - tableFormat.setWidth(QTextLength(QTextLength::PercentageLength,100)); - chatTextTable->setFormat(tableFormat); - setNameColWidth(100); + tableFormat.setColumnWidthConstraints({QTextLength(QTextLength::VariableLength,0), + QTextLength(QTextLength::PercentageLength,100), + QTextLength(QTextLength::VariableLength,0)}); + + chatTextTable = textCursor().insertTable(1,3,tableFormat); + + nameFormat.setAlignment(Qt::AlignRight); + nameFormat.setNonBreakableLines(true); + dateFormat.setAlignment(Qt::AlignLeft); + dateFormat.setNonBreakableLines(true); -// nameFormat.setAlignment(Qt::AlignRight); -// nameFormat.setNonBreakableLines(true); -// dateFormat.setAlignment(Qt::AlignLeft); -// dateFormat.setNonBreakableLines(true); connect(this, &ChatAreaWidget::anchorClicked, this, &ChatAreaWidget::onAnchorClicked); connect(verticalScrollBar(), SIGNAL(rangeChanged(int,int)), this, SLOT(onSliderRangeChanged())); @@ -112,9 +113,11 @@ void ChatAreaWidget::insertMessage(ChatAction *msgAction) cur.clearSelection(); cur.setKeepPositionOnInsert(true); chatTextTable->appendRows(1); + chatTextTable->cellAt(row,0).firstCursorPosition().setBlockFormat(nameFormat); chatTextTable->cellAt(row,0).firstCursorPosition().insertHtml(msgAction->getName()); chatTextTable->cellAt(row,1).firstCursorPosition().insertHtml(msgAction->getMessage()); - chatTextTable->cellAt(row,2).firstCursorPosition().insertText(msgAction->getDate()); + chatTextTable->cellAt(row,2).firstCursorPosition().setBlockFormat(dateFormat); + chatTextTable->cellAt(row,2).firstCursorPosition().insertHtml(msgAction->getDate()); msgAction->setup(cur, this); diff --git a/widget/form/chatform.cpp b/widget/form/chatform.cpp index efe61f818..f2f2c32d6 100644 --- a/widget/form/chatform.cpp +++ b/widget/form/chatform.cpp @@ -35,7 +35,7 @@ #include "widget/widget.h" #include "widget/maskablepixmapwidget.h" #include "widget/croppinglabel.h" -#include "style.h" +#include "misc/style.h" ChatForm::ChatForm(Friend* chatFriend) : f(chatFriend) diff --git a/widget/form/groupchatform.cpp b/widget/form/groupchatform.cpp index 77e64ea83..412ef46e8 100644 --- a/widget/form/groupchatform.cpp +++ b/widget/form/groupchatform.cpp @@ -21,7 +21,7 @@ #include "widget/croppinglabel.h" #include "widget/maskablepixmapwidget.h" #include "core.h" -#include "style.h" +#include "misc/style.h" #include #include #include diff --git a/widget/friendwidget.cpp b/widget/friendwidget.cpp index 9159d3e7f..a524a7daf 100644 --- a/widget/friendwidget.cpp +++ b/widget/friendwidget.cpp @@ -24,7 +24,7 @@ #include "widget/form/chatform.h" #include "widget/maskablepixmapwidget.h" #include "widget/croppinglabel.h" -#include "style.h" +#include "misc/style.h" #include #include #include diff --git a/widget/genericchatroomwidget.cpp b/widget/genericchatroomwidget.cpp index ab0d13810..cd75964d8 100644 --- a/widget/genericchatroomwidget.cpp +++ b/widget/genericchatroomwidget.cpp @@ -15,7 +15,7 @@ */ #include "genericchatroomwidget.h" -#include "style.h" +#include "misc/style.h" #include "widget/maskablepixmapwidget.h" #include "croppinglabel.h" #include diff --git a/widget/groupwidget.cpp b/widget/groupwidget.cpp index 2d7b1ebe5..aeecb3737 100644 --- a/widget/groupwidget.cpp +++ b/widget/groupwidget.cpp @@ -20,7 +20,7 @@ #include "misc/settings.h" #include "widget/form/groupchatform.h" #include "widget/maskablepixmapwidget.h" -#include "style.h" +#include "misc/style.h" #include #include #include diff --git a/widget/tool/chatactions/chataction.cpp b/widget/tool/chatactions/chataction.cpp index 7758aae33..6978711a6 100644 --- a/widget/tool/chatactions/chataction.cpp +++ b/widget/tool/chatactions/chataction.cpp @@ -41,13 +41,15 @@ QString ChatAction::QImage2base64(const QImage &img) QString ChatAction::getName() { if (isMe) - return QString("
" + toHtmlChars(name) + "
"); + return QString("
%2
").arg("name_me").arg(toHtmlChars(name)); else - return QString("
" + toHtmlChars(name) + "
"); + return QString("
%2
").arg("name").arg(toHtmlChars(name)); } QString ChatAction::getDate() { - QString res = date; - return res; + if (isMe) + return QString("
" + toHtmlChars(date) + "
"); + else + return QString("
" + toHtmlChars(date) + "
"); } diff --git a/widget/tool/chatactions/messageaction.cpp b/widget/tool/chatactions/messageaction.cpp index 9904be470..6445279ea 100644 --- a/widget/tool/chatactions/messageaction.cpp +++ b/widget/tool/chatactions/messageaction.cpp @@ -71,5 +71,8 @@ QString MessageAction::getMessage() } message_ = message_.left(message_.length()-4); - return QString("
" + message_ + "
"); + if (isMe) + return QString("
" + message_ + "
"); + else + return QString("
" + message_ + "
"); }