mirror of
https://github.com/qTox/qTox.git
synced 2024-03-22 14:00:36 +08:00
more styling
This commit is contained in:
parent
04f56cc9ec
commit
5e328d2404
|
@ -27,28 +27,29 @@
|
||||||
// helper functions
|
// helper functions
|
||||||
QFont appFont(int pixelSize, int weight)
|
QFont appFont(int pixelSize, int weight)
|
||||||
{
|
{
|
||||||
auto font = QFont();
|
QFont font;
|
||||||
font.setPixelSize(pixelSize);
|
font.setPixelSize(pixelSize);
|
||||||
font.setWeight(weight);
|
font.setWeight(weight);
|
||||||
return font;
|
return font;
|
||||||
}
|
}
|
||||||
|
|
||||||
QString cssifyWeight(int weight)
|
QString qssifyWeight(int weight)
|
||||||
{
|
{
|
||||||
QString weightStr = "normal";
|
QString weightStr = "normal";
|
||||||
if (weight == QFont::Bold)
|
if (weight == QFont::Bold)
|
||||||
weightStr = "bold";
|
weightStr = "bold";
|
||||||
if (weight == QFont::Light)
|
if (weight == QFont::Light)
|
||||||
weightStr = "lighter";
|
weightStr = "light";
|
||||||
|
|
||||||
return QString("%1").arg(weightStr);
|
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.pixelSize())
|
||||||
.arg(font.weight());
|
.arg(qssifyWeight(font.weight()))
|
||||||
|
.arg(font.family());
|
||||||
}
|
}
|
||||||
|
|
||||||
QString Style::getStylesheet(const QString &filename)
|
QString Style::getStylesheet(const QString &filename)
|
||||||
|
@ -112,13 +113,13 @@ QString Style::resolve(QString qss)
|
||||||
{"@white", getColor(White).name()},
|
{"@white", getColor(White).name()},
|
||||||
|
|
||||||
// fonts
|
// fonts
|
||||||
{"@extraBig", cssifyFont(getFont(ExtraBig))},
|
{"@extraBig", qssifyFont(getFont(ExtraBig))},
|
||||||
{"@big", cssifyFont(getFont(Big))},
|
{"@big", qssifyFont(getFont(Big))},
|
||||||
{"@bigBold", cssifyFont(getFont(BigBold))},
|
{"@bigBold", qssifyFont(getFont(BigBold))},
|
||||||
{"@medium", cssifyFont(getFont(Medium))},
|
{"@medium", qssifyFont(getFont(Medium))},
|
||||||
{"@mediumBold", cssifyFont(getFont(MediumBold))},
|
{"@mediumBold", qssifyFont(getFont(MediumBold))},
|
||||||
{"@small", cssifyFont(getFont(Small))},
|
{"@small", qssifyFont(getFont(Small))},
|
||||||
{"@smallLight", cssifyFont(getFont(SmallLight))},
|
{"@smallLight", qssifyFont(getFont(SmallLight))},
|
||||||
};
|
};
|
||||||
|
|
||||||
for (const QString& key : dict.keys())
|
for (const QString& key : dict.keys())
|
||||||
|
|
|
@ -1,25 +1,31 @@
|
||||||
div.name_me {
|
|
||||||
color: #646464;
|
|
||||||
font-weight: bold;
|
|
||||||
padding-right: 3px;
|
|
||||||
}
|
|
||||||
|
|
||||||
div.name {
|
div.name {
|
||||||
color: #000000;
|
color: @black;
|
||||||
font-weight: bold;
|
font: @big;
|
||||||
padding-right: 3px;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
div.message {
|
div.message {
|
||||||
color: #000000;
|
color: @black;
|
||||||
padding-right: 3px;
|
font: @big;
|
||||||
padding-left: 3px;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
div.date {
|
div.date {
|
||||||
color: #000000;
|
color: @black;
|
||||||
padding-left: 3px;
|
font: @big;
|
||||||
white-space: nowrap;
|
}
|
||||||
|
|
||||||
|
div.name_me {
|
||||||
|
color: @mediumGrey;
|
||||||
|
font: @big;
|
||||||
|
}
|
||||||
|
|
||||||
|
div.message_me {
|
||||||
|
color: @mediumGrey;
|
||||||
|
font: @big;
|
||||||
|
}
|
||||||
|
|
||||||
|
div.date_me {
|
||||||
|
color: @mediumGrey;
|
||||||
|
font: @big;
|
||||||
}
|
}
|
||||||
|
|
||||||
span.quote {
|
span.quote {
|
||||||
|
@ -31,9 +37,9 @@ div.green {
|
||||||
margin-bottom: 12px;
|
margin-bottom: 12px;
|
||||||
margin-left: 12px;
|
margin-left: 12px;
|
||||||
margin-right: 12px;
|
margin-right: 12px;
|
||||||
color: #ffffff;
|
color: @white;
|
||||||
background-color: #6bc260;
|
background-color: @green;
|
||||||
font-size: 10px;
|
font: @small;
|
||||||
}
|
}
|
||||||
|
|
||||||
div.silver {
|
div.silver {
|
||||||
|
@ -41,9 +47,9 @@ div.silver {
|
||||||
margin-bottom: 12px;
|
margin-bottom: 12px;
|
||||||
margin-left: 12px;
|
margin-left: 12px;
|
||||||
margin-right: 12px;
|
margin-right: 12px;
|
||||||
color: #000000;
|
color: @black;
|
||||||
background-color: #d1d1d1;
|
background-color: @lightGrey;
|
||||||
font-size: 10px;
|
font: @small;
|
||||||
}
|
}
|
||||||
|
|
||||||
div.red {
|
div.red {
|
||||||
|
@ -51,14 +57,14 @@ div.red {
|
||||||
margin-bottom: 12px;
|
margin-bottom: 12px;
|
||||||
margin-left: 12px;
|
margin-left: 12px;
|
||||||
margin-right: 12px;
|
margin-right: 12px;
|
||||||
color: #ffffff;
|
color: @white;
|
||||||
background-color: rgb(200,78,78);
|
background-color: @red;
|
||||||
font-size: 10px;
|
font: @small;
|
||||||
}
|
}
|
||||||
|
|
||||||
div.button {
|
div.button {
|
||||||
margin-top: 0px;
|
margin-top: 0px;
|
||||||
margin-bottom: 0px;
|
margin-bottom: 0px;
|
||||||
margin-left: 0px;
|
margin-left: 0px;
|
||||||
color: #ffffff;
|
color: @white;
|
||||||
}
|
}
|
||||||
|
|
38
ui/chatroomWidgets/genericChatroomWidget.css
Normal file
38
ui/chatroomWidgets/genericChatroomWidget.css
Normal file
|
@ -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;
|
||||||
|
}
|
|
@ -35,6 +35,6 @@ QRadioButton::indicator::checked
|
||||||
|
|
||||||
QMenu
|
QMenu
|
||||||
{
|
{
|
||||||
background-color: #414141; /* sets background of the menu */
|
background-color: @mediumGrey; /* sets background of the menu */
|
||||||
border: 0px solid;
|
border: 0px solid;
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,5 +1,5 @@
|
||||||
QTextEdit {
|
QTextEdit {
|
||||||
border-color: #c4c1bd;
|
border-color: @lightGrey;
|
||||||
border-style: solid;
|
border-style: solid;
|
||||||
border-width: 1px 0 1px 1px;
|
border-width: 1px 0 1px 1px;
|
||||||
}
|
}
|
||||||
|
|
|
@ -36,19 +36,20 @@ ChatAreaWidget::ChatAreaWidget(QWidget *parent) :
|
||||||
setAcceptRichText(false);
|
setAcceptRichText(false);
|
||||||
setFrameStyle(QFrame::NoFrame);
|
setFrameStyle(QFrame::NoFrame);
|
||||||
|
|
||||||
chatTextTable = textCursor().insertTable(1,3);
|
|
||||||
|
|
||||||
QTextTableFormat tableFormat;
|
QTextTableFormat tableFormat;
|
||||||
|
tableFormat.setCellSpacing(15);
|
||||||
tableFormat.setBorderStyle(QTextFrameFormat::BorderStyle_None);
|
tableFormat.setBorderStyle(QTextFrameFormat::BorderStyle_None);
|
||||||
tableFormat.setCellSpacing(2);
|
tableFormat.setColumnWidthConstraints({QTextLength(QTextLength::VariableLength,0),
|
||||||
tableFormat.setWidth(QTextLength(QTextLength::PercentageLength,100));
|
QTextLength(QTextLength::PercentageLength,100),
|
||||||
chatTextTable->setFormat(tableFormat);
|
QTextLength(QTextLength::VariableLength,0)});
|
||||||
setNameColWidth(100);
|
|
||||||
|
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(this, &ChatAreaWidget::anchorClicked, this, &ChatAreaWidget::onAnchorClicked);
|
||||||
connect(verticalScrollBar(), SIGNAL(rangeChanged(int,int)), this, SLOT(onSliderRangeChanged()));
|
connect(verticalScrollBar(), SIGNAL(rangeChanged(int,int)), this, SLOT(onSliderRangeChanged()));
|
||||||
|
@ -112,9 +113,11 @@ void ChatAreaWidget::insertMessage(ChatAction *msgAction)
|
||||||
cur.clearSelection();
|
cur.clearSelection();
|
||||||
cur.setKeepPositionOnInsert(true);
|
cur.setKeepPositionOnInsert(true);
|
||||||
chatTextTable->appendRows(1);
|
chatTextTable->appendRows(1);
|
||||||
|
chatTextTable->cellAt(row,0).firstCursorPosition().setBlockFormat(nameFormat);
|
||||||
chatTextTable->cellAt(row,0).firstCursorPosition().insertHtml(msgAction->getName());
|
chatTextTable->cellAt(row,0).firstCursorPosition().insertHtml(msgAction->getName());
|
||||||
chatTextTable->cellAt(row,1).firstCursorPosition().insertHtml(msgAction->getMessage());
|
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);
|
msgAction->setup(cur, this);
|
||||||
|
|
||||||
|
|
|
@ -35,7 +35,7 @@
|
||||||
#include "widget/widget.h"
|
#include "widget/widget.h"
|
||||||
#include "widget/maskablepixmapwidget.h"
|
#include "widget/maskablepixmapwidget.h"
|
||||||
#include "widget/croppinglabel.h"
|
#include "widget/croppinglabel.h"
|
||||||
#include "style.h"
|
#include "misc/style.h"
|
||||||
|
|
||||||
ChatForm::ChatForm(Friend* chatFriend)
|
ChatForm::ChatForm(Friend* chatFriend)
|
||||||
: f(chatFriend)
|
: f(chatFriend)
|
||||||
|
|
|
@ -21,7 +21,7 @@
|
||||||
#include "widget/croppinglabel.h"
|
#include "widget/croppinglabel.h"
|
||||||
#include "widget/maskablepixmapwidget.h"
|
#include "widget/maskablepixmapwidget.h"
|
||||||
#include "core.h"
|
#include "core.h"
|
||||||
#include "style.h"
|
#include "misc/style.h"
|
||||||
#include <QPushButton>
|
#include <QPushButton>
|
||||||
#include <QMimeData>
|
#include <QMimeData>
|
||||||
#include <QDragEnterEvent>
|
#include <QDragEnterEvent>
|
||||||
|
|
|
@ -24,7 +24,7 @@
|
||||||
#include "widget/form/chatform.h"
|
#include "widget/form/chatform.h"
|
||||||
#include "widget/maskablepixmapwidget.h"
|
#include "widget/maskablepixmapwidget.h"
|
||||||
#include "widget/croppinglabel.h"
|
#include "widget/croppinglabel.h"
|
||||||
#include "style.h"
|
#include "misc/style.h"
|
||||||
#include <QContextMenuEvent>
|
#include <QContextMenuEvent>
|
||||||
#include <QMenu>
|
#include <QMenu>
|
||||||
#include <QDrag>
|
#include <QDrag>
|
||||||
|
|
|
@ -15,7 +15,7 @@
|
||||||
*/
|
*/
|
||||||
|
|
||||||
#include "genericchatroomwidget.h"
|
#include "genericchatroomwidget.h"
|
||||||
#include "style.h"
|
#include "misc/style.h"
|
||||||
#include "widget/maskablepixmapwidget.h"
|
#include "widget/maskablepixmapwidget.h"
|
||||||
#include "croppinglabel.h"
|
#include "croppinglabel.h"
|
||||||
#include <QMouseEvent>
|
#include <QMouseEvent>
|
||||||
|
|
|
@ -20,7 +20,7 @@
|
||||||
#include "misc/settings.h"
|
#include "misc/settings.h"
|
||||||
#include "widget/form/groupchatform.h"
|
#include "widget/form/groupchatform.h"
|
||||||
#include "widget/maskablepixmapwidget.h"
|
#include "widget/maskablepixmapwidget.h"
|
||||||
#include "style.h"
|
#include "misc/style.h"
|
||||||
#include <QPalette>
|
#include <QPalette>
|
||||||
#include <QMenu>
|
#include <QMenu>
|
||||||
#include <QContextMenuEvent>
|
#include <QContextMenuEvent>
|
||||||
|
|
|
@ -41,13 +41,15 @@ QString ChatAction::QImage2base64(const QImage &img)
|
||||||
QString ChatAction::getName()
|
QString ChatAction::getName()
|
||||||
{
|
{
|
||||||
if (isMe)
|
if (isMe)
|
||||||
return QString("<div class=name_me>" + toHtmlChars(name) + "</div>");
|
return QString("<div class=%1>%2</div>").arg("name_me").arg(toHtmlChars(name));
|
||||||
else
|
else
|
||||||
return QString("<div class=name>" + toHtmlChars(name) + "</div>");
|
return QString("<div class=%1>%2</div>").arg("name").arg(toHtmlChars(name));
|
||||||
}
|
}
|
||||||
|
|
||||||
QString ChatAction::getDate()
|
QString ChatAction::getDate()
|
||||||
{
|
{
|
||||||
QString res = date;
|
if (isMe)
|
||||||
return res;
|
return QString("<div class=date_me>" + toHtmlChars(date) + "</div>");
|
||||||
|
else
|
||||||
|
return QString("<div class=date>" + toHtmlChars(date) + "</div>");
|
||||||
}
|
}
|
||||||
|
|
|
@ -71,5 +71,8 @@ QString MessageAction::getMessage()
|
||||||
}
|
}
|
||||||
message_ = message_.left(message_.length()-4);
|
message_ = message_.left(message_.length()-4);
|
||||||
|
|
||||||
return QString("<div class=message>" + message_ + "</div>");
|
if (isMe)
|
||||||
|
return QString("<div class=message_me>" + message_ + "</div>");
|
||||||
|
else
|
||||||
|
return QString("<div class=message>" + message_ + "</div>");
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue
Block a user