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
|
||||
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())
|
||||
|
|
|
@ -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;
|
||||
}
|
||||
|
|
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
|
||||
{
|
||||
background-color: #414141; /* sets background of the menu */
|
||||
background-color: @mediumGrey; /* sets background of the menu */
|
||||
border: 0px solid;
|
||||
}
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
QTextEdit {
|
||||
border-color: #c4c1bd;
|
||||
border-color: @lightGrey;
|
||||
border-style: solid;
|
||||
border-width: 1px 0 1px 1px;
|
||||
}
|
||||
|
|
|
@ -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);
|
||||
|
||||
|
|
|
@ -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)
|
||||
|
|
|
@ -21,7 +21,7 @@
|
|||
#include "widget/croppinglabel.h"
|
||||
#include "widget/maskablepixmapwidget.h"
|
||||
#include "core.h"
|
||||
#include "style.h"
|
||||
#include "misc/style.h"
|
||||
#include <QPushButton>
|
||||
#include <QMimeData>
|
||||
#include <QDragEnterEvent>
|
||||
|
|
|
@ -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 <QContextMenuEvent>
|
||||
#include <QMenu>
|
||||
#include <QDrag>
|
||||
|
|
|
@ -15,7 +15,7 @@
|
|||
*/
|
||||
|
||||
#include "genericchatroomwidget.h"
|
||||
#include "style.h"
|
||||
#include "misc/style.h"
|
||||
#include "widget/maskablepixmapwidget.h"
|
||||
#include "croppinglabel.h"
|
||||
#include <QMouseEvent>
|
||||
|
|
|
@ -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 <QPalette>
|
||||
#include <QMenu>
|
||||
#include <QContextMenuEvent>
|
||||
|
|
|
@ -41,13 +41,15 @@ QString ChatAction::QImage2base64(const QImage &img)
|
|||
QString ChatAction::getName()
|
||||
{
|
||||
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
|
||||
return QString("<div class=name>" + toHtmlChars(name) + "</div>");
|
||||
return QString("<div class=%1>%2</div>").arg("name").arg(toHtmlChars(name));
|
||||
}
|
||||
|
||||
QString ChatAction::getDate()
|
||||
{
|
||||
QString res = date;
|
||||
return res;
|
||||
if (isMe)
|
||||
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);
|
||||
|
||||
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