1
0
mirror of https://github.com/qTox/qTox.git synced 2024-03-22 14:00:36 +08:00

refactor: Move buttons style in ChatForm css

This commit is contained in:
Diadlo 2017-11-16 01:17:39 +03:00
parent bf1c789fc1
commit e3bb4e735f
No known key found for this signature in database
GPG Key ID: 5AF9F2E29107C727
9 changed files with 180 additions and 39 deletions

15
res.qrc
View File

@ -51,26 +51,25 @@
<file>ui/chatArea/scrollBarDownArrow.svg</file>
<file>ui/chatArea/scrollBarLeftArrow.svg</file>
<file>ui/chatArea/scrollBarRightArrow.svg</file>
<file>ui/chatForm/buttons.css</file>
<file>ui/chatForm/callButton.svg</file>
<file>ui/chatForm/micButton.svg</file>
<file>ui/chatForm/videoButton.svg</file>
<file>ui/chatForm/volButton.svg</file>
<file>ui/emoteButton/emoteButton.css</file>
<file>ui/emoteButton/emoteButton.svg</file>
<file>ui/chatForm/emoteButton.svg</file>
<file>ui/chatForm/fileButton.svg</file>
<file>ui/chatForm/screenshotButton.svg</file>
<file>ui/chatForm/sendButton.svg</file>
<file>ui/emoticonWidget/dot_page.svg</file>
<file>ui/emoticonWidget/dot_page_current.svg</file>
<file>ui/emoticonWidget/dot_page_hover.svg</file>
<file>ui/emoticonWidget/emoticonWidget.css</file>
<file>ui/fileButton/fileButton.css</file>
<file>ui/fileButton/fileButton.svg</file>
<file>ui/screenshotButton/screenshotButton.css</file>
<file>ui/screenshotButton/screenshotButton.svg</file>
<file>ui/fileTransferWidget/fileTransferWidget.css</file>
<file>ui/friendList/friendList.css</file>
<file>ui/msgEdit/msgEdit.css</file>
<file>ui/sendButton/sendButton.css</file>
<file>ui/sendButton/sendButton.svg</file>
<file>ui/settings/mainContent.css</file>
<file>ui/settings/mainHead.css</file>
<file>ui/statusButton/statusButton.css</file>

View File

@ -78,15 +78,14 @@ const QString MIC_TOOL_TIP[] = {
ChatFormHeader::tr("Mute microphone"),
};
template <class T, class Fun>
T* createButton(ChatFormHeader* self, const QSize& size, const QString& name, Fun onClickSlot)
template <class Fun>
QPushButton* createButton(ChatFormHeader* self, const QString& name, Fun onClickSlot)
{
T* btn = new T();
btn->setFixedSize(size);
QPushButton* btn = new QPushButton();
btn->setAttribute(Qt::WA_LayoutUsesWidgetRect);
btn->setObjectName(name);
btn->setStyleSheet(Style::getStylesheet(STYLE_PATH));
QObject::connect(btn, &QAbstractButton::clicked, self, onClickSlot);
QObject::connect(btn, &QPushButton::clicked, self, onClickSlot);
return btn;
}
@ -131,10 +130,10 @@ ChatFormHeader::ChatFormHeader(QWidget* parent)
headTextLayout->addWidget(nameLabel);
headTextLayout->addStretch();
micButton = createButton<QToolButton>(this, TOOL_BUTTONS_SIZE, "micButton", &ChatFormHeader::micMuteToggle);
volButton = createButton<QToolButton>(this, TOOL_BUTTONS_SIZE, "volButton", &ChatFormHeader::volMuteToggle);
callButton = createButton<QPushButton>(this, CALL_BUTTONS_SIZE, "callButton", &ChatFormHeader::callTriggered);
videoButton = createButton<QPushButton>(this, CALL_BUTTONS_SIZE, "videoButton", &ChatFormHeader::videoCallTriggered);
micButton = createButton(this, "micButton", &ChatFormHeader::micMuteToggle);
volButton = createButton(this, "volButton", &ChatFormHeader::volMuteToggle);
callButton = createButton(this, "callButton", &ChatFormHeader::callTriggered);
videoButton = createButton(this, "videoButton", &ChatFormHeader::videoCallTriggered);
QVBoxLayout* micButtonsLayout = new QVBoxLayout();
micButtonsLayout->setSpacing(MIC_BUTTONS_LAYOUT_SPACING);

View File

@ -99,8 +99,8 @@ private:
QPushButton* callButton;
QPushButton* videoButton;
QToolButton* volButton;
QToolButton* micButton;
QPushButton* volButton;
QPushButton* micButton;
CallButtonState callState;
CallButtonState videoState;

View File

@ -104,6 +104,27 @@ QString GenericChatForm::resolveToxPk(const ToxPk& pk)
return pk.toString();
}
namespace
{
const QString STYLE_PATH = QStringLiteral(":/ui/chatForm/buttons.css");
}
namespace
{
QPushButton* createButton(const QString& name)
{
QPushButton* btn = new QPushButton();
// Fix for incorrect layouts on OS X as per
// https://bugreports.qt-project.org/browse/QTBUG-14591
btn->setAttribute(Qt::WA_LayoutUsesWidgetRect);
btn->setObjectName(name);
btn->setProperty("state", "green");
btn->setStyleSheet(Style::getStylesheet(STYLE_PATH));
return btn;
}
}
GenericChatForm::GenericChatForm(QWidget* parent)
: QWidget(parent, Qt::Window)
, audioInputFlag(false)
@ -121,12 +142,11 @@ GenericChatForm::GenericChatForm(QWidget* parent)
msgEdit = new ChatTextEdit();
sendButton = new QPushButton();
emoteButton = new QPushButton();
sendButton = createButton("sendButton");
emoteButton = createButton("emoteButton");
// Setting the sizes in the CSS doesn't work (glitch with high DPIs)
fileButton = new QPushButton();
screenshotButton = new QPushButton;
fileButton = createButton("fileButton");
screenshotButton = createButton("screenshotButton");
// TODO: Make updateCallButtons (see ChatForm) abstract
// and call here to set tooltips.
@ -143,11 +163,6 @@ GenericChatForm::GenericChatForm(QWidget* parent)
msgEdit->setFixedHeight(MESSAGE_EDIT_HEIGHT);
msgEdit->setFrameStyle(QFrame::NoFrame);
SET_STYLESHEET(sendButton);
SET_STYLESHEET(fileButton);
SET_STYLESHEET(screenshotButton);
SET_STYLESHEET(emoteButton);
bodySplitter = new QSplitter(Qt::Vertical, this);
connect(bodySplitter, &QSplitter::splitterMoved, this, &GenericChatForm::onSplitterMoved);
QWidget* contentWidget = new QWidget(this);
@ -175,13 +190,6 @@ GenericChatForm::GenericChatForm(QWidget* parent)
contentLayout->addWidget(chatWidget);
contentLayout->addLayout(mainFootLayout);
// Fix for incorrect layouts on OS X as per
// https://bugreports.qt-project.org/browse/QTBUG-14591
sendButton->setAttribute(Qt::WA_LayoutUsesWidgetRect);
fileButton->setAttribute(Qt::WA_LayoutUsesWidgetRect);
screenshotButton->setAttribute(Qt::WA_LayoutUsesWidgetRect);
emoteButton->setAttribute(Qt::WA_LayoutUsesWidgetRect);
menu.addActions(chatWidget->actions());
menu.addSeparator();
saveChatAction =

View File

@ -1,29 +1,79 @@
/* Message edit */
QAbstractButton#emoteButton
{
background-image: url(":/ui/chatForm/emoteButton.svg");
border-top-right-radius: 5px;
width: 24px;
height: 24px;
}
QAbstractButton#fileButton
{
background-image: url(":/ui/chatForm/fileButton.svg");
border-bottom-right-radius: 5px;
width: 24px;
height: 24px;
}
QAbstractButton#screenshotButton
{
background-image: url(":/ui/chatForm/screenshotButton.svg");
border-top-left-radius: 5px;
width: 24px;
height: 24px;
}
QAbstractButton#sendButton
{
background-image: url(":/ui/chatForm/sendButton.svg");
border-radius: 5px;
width: 50px;
height: 50px;
}
/* Header */
QAbstractButton#volButton
{
image: url(":/ui/chatForm/volButton.svg");
border-image: url(":/ui/chatForm/volButton.svg");
border-radius: 5px;
width: 22px;
height: 18px;
}
QAbstractButton#micButton
{
image: url(":/ui/chatForm/micButton.svg");
border-image: url(":/ui/chatForm/micButton.svg");
border-radius: 5px;
width: 22px;
height: 18px;
}
QAbstractButton#videoButton
{
background-image: url(":/ui/chatForm/videoButton.svg");
border-radius: 5px;
width: 50px;
height: 40px;
}
QAbstractButton#callButton
{
background-image: url(":/ui/chatForm/callButton.svg");
border-radius: 5px;
width: 50px;
height: 40px;
}
/* Common */
QAbstractButton
{
background-repeat: none;
background-position: center;
border: none;
border-radius: 5px;
}
QAbstractButton:disabled

View File

@ -0,0 +1,28 @@
<?xml version="1.0" encoding="UTF-8" standalone="no"?>
<!-- Created with Inkscape (http://www.inkscape.org/) -->
<svg
xmlns:dc="http://purl.org/dc/elements/1.1/"
xmlns:cc="http://creativecommons.org/ns#"
xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#"
xmlns:svg="http://www.w3.org/2000/svg"
xmlns="http://www.w3.org/2000/svg"
version="1.1"
width="17"
height="17"
viewBox="0 0 17 17"
id="Layer_1"
xml:space="preserve"><metadata
id="metadata15"><rdf:RDF><cc:Work
rdf:about=""><dc:format>image/svg+xml</dc:format><dc:type
rdf:resource="http://purl.org/dc/dcmitype/StillImage" /><dc:title></dc:title></cc:Work></rdf:RDF></metadata><defs
id="defs13" /><g
transform="matrix(1.6827488,0,0,1.654661,0,0.02245763)"
id="g3"><path
d="M 3.4,1.5 C 3.4,2.3 2.7,3 1.9,3 1.1,3 0.4,2.3 0.4,1.5 0.4,0.7 1.1,0 1.9,0 2.7,0 3.4,0.7 3.4,1.5 z m 6,0 C 9.4,2.3 8.7,3 7.9,3 7.1,3 6.4,2.3 6.4,1.5 6.4,0.7 7.1,0 7.9,0 8.7,0 9.4,0.7 9.4,1.5 z"
id="path5"
style="fill:#ffffff" /><g
id="g7"><path
d="M 0.7,6.6 C 0.7,6.6 0.8,6.7 1,6.9 1.2,7.1 1.5,7.4 1.8,7.7 2.2,8 2.7,8.2 3.2,8.4 3.5,8.5 3.8,8.5 4.1,8.6 4.3,8.7 4.7,8.7 5,8.7 5.4,8.7 5.7,8.7 6,8.6 6.3,8.6 6.6,8.5 6.9,8.4 7.4,8.2 7.9,8 8.3,7.7 9.1,7.1 9.4,6.5 9.4,6.6 l 0.7,0.2 c 0,0 0,0.2 -0.2,0.5 C 9.6,7.7 9.4,8.2 9,8.6 8.8,8.9 8.5,9.1 8.3,9.3 8,9.5 7.6,9.7 7.3,9.8 6.9,9.9 6.6,10.1 6.2,10.1 5.8,10.2 5.4,10.2 5.1,10.2 4.6,10.2 4.3,10.2 3.9,10.1 3.4,10.1 3,10 2.7,9.8 2.3,9.7 2,9.5 1.7,9.3 1.4,9.1 1.2,8.9 1,8.6 0.2,7.7 0,6.9 0,6.9 L 0.7,6.6 z"
id="path9"
style="fill:#ffffff" /></g></g></svg>

After

Width:  |  Height:  |  Size: 1.6 KiB

View File

@ -0,0 +1,27 @@
<?xml version="1.0" encoding="UTF-8" standalone="no"?>
<!-- Created with Inkscape (http://www.inkscape.org/) -->
<svg
xmlns:dc="http://purl.org/dc/elements/1.1/"
xmlns:cc="http://creativecommons.org/ns#"
xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#"
xmlns:svg="http://www.w3.org/2000/svg"
xmlns="http://www.w3.org/2000/svg"
version="1.1"
width="16"
height="16"
viewBox="0 0 16 16"
id="Layer_1"
xml:space="preserve"><metadata
id="metadata13"><rdf:RDF><cc:Work
rdf:about=""><dc:format>image/svg+xml</dc:format><dc:type
rdf:resource="http://purl.org/dc/dcmitype/StillImage" /><dc:title></dc:title></cc:Work></rdf:RDF></metadata><defs
id="defs11" /><g
transform="matrix(1.1649174,0,0,1.1610052,0,0.08477933)"
id="g3"><path
d="M 13.629,2.874 C 13.567,2.619 13.48,2.38 13.373,2.158 13.185,1.77 12.935,1.439 12.655,1.166 12.445,0.96 12.217,0.784 11.983,0.639 11.63,0.418 11.263,0.262 10.905,0.158 10.726,0.105 10.55,0.067 10.377,0.04 10.204,0.014 10.036,0 9.872,0 9.446,0 9.068,0.061 8.744,0.156 8.501,0.228 8.29,0.317 8.107,0.413 7.835,0.558 7.632,0.713 7.49,0.84 7.396,0.926 7.33,0.996 7.291,1.043 L 1.279,6.974 1.278,6.977 C 1.12,7.134 0.962,7.315 0.812,7.523 0.587,7.834 0.383,8.206 0.235,8.636 0.089,9.066 0,9.556 0,10.099 c 0.001,0.216 0.028,0.432 0.079,0.645 0.088,0.371 0.246,0.734 0.461,1.075 0.161,0.256 0.354,0.5 0.578,0.724 0.336,0.336 0.743,0.626 1.211,0.834 0.233,0.104 0.482,0.187 0.743,0.244 0.262,0.057 0.536,0.088 0.82,0.088 0.27,0 0.529,-0.042 0.774,-0.108 0.214,-0.06 0.418,-0.138 0.609,-0.229 0.338,-0.16 0.642,-0.357 0.914,-0.562 0.406,-0.306 0.738,-0.629 0.976,-0.878 0.235,-0.25 0.374,-0.426 0.384,-0.439 l -1.109,-0.871 0,0 0.51,0.399 -0.51,-0.4 0.453,0.356 -0.452,-0.356 H 6.44 l 0,0 v 10e-4 l 0,0 C 6.438,10.626 6.347,10.738 6.194,10.904 6.078,11.03 5.925,11.185 5.747,11.345 5.614,11.466 5.467,11.59 5.31,11.703 5.077,11.878 4.825,12.031 4.58,12.136 4.457,12.19 4.337,12.23 4.221,12.257 c -0.115,0.027 -0.225,0.04 -0.328,0.04 -0.185,0 -0.36,-0.021 -0.527,-0.058 C 3.073,12.176 2.805,12.057 2.563,11.903 2.382,11.788 2.217,11.65 2.073,11.5 1.856,11.273 1.686,11.019 1.574,10.77 1.518,10.645 1.476,10.524 1.45,10.41 1.424,10.296 1.41,10.19 1.41,10.099 1.41,9.839 1.438,9.606 1.485,9.394 1.557,9.077 1.671,8.806 1.81,8.571 1.948,8.337 2.112,8.138 2.276,7.974 L 8.341,1.988 8.364,1.958 C 8.373,1.948 8.406,1.91 8.468,1.858 8.564,1.778 8.72,1.667 8.948,1.576 9.063,1.53 9.195,1.489 9.348,1.459 9.501,1.429 9.674,1.411 9.872,1.411 c 0.1,0 0.219,0.01 0.348,0.032 0.226,0.038 0.48,0.116 0.727,0.232 0.186,0.089 0.366,0.198 0.53,0.329 0.124,0.097 0.238,0.207 0.34,0.327 0.152,0.182 0.277,0.388 0.366,0.629 0.09,0.241 0.143,0.518 0.144,0.848 0,0.151 -0.02,0.297 -0.053,0.436 -0.053,0.21 -0.139,0.407 -0.248,0.59 C 11.917,5.017 11.785,5.182 11.65,5.32 L 11.649,5.322 8.609,8.496 C 8.604,8.5 8.586,8.519 8.553,8.542 8.501,8.579 8.418,8.63 8.306,8.671 8.194,8.712 8.052,8.744 7.869,8.744 7.818,8.744 7.771,8.738 7.728,8.728 7.653,8.711 7.588,8.681 7.526,8.638 7.48,8.608 7.437,8.567 7.396,8.52 7.336,8.449 7.284,8.359 7.248,8.257 7.213,8.155 7.192,8.043 7.192,7.926 7.192,7.815 7.213,7.71 7.247,7.612 7.271,7.537 7.305,7.467 7.341,7.405 7.396,7.31 7.455,7.231 7.498,7.183 7.52,7.156 7.537,7.14 7.546,7.13 7.55,7.127 7.553,7.125 7.554,7.123 L 7.562,7.115 9.917,4.789 8.925,3.786 6.593,6.09 C 6.568,6.114 6.521,6.16 6.463,6.224 6.348,6.352 6.185,6.558 6.043,6.842 5.973,6.983 5.907,7.146 5.86,7.328 5.813,7.51 5.781,7.711 5.781,7.926 c 0.001,0.281 0.05,0.557 0.143,0.814 0.069,0.193 0.164,0.376 0.282,0.545 0.09,0.126 0.193,0.243 0.31,0.349 0.176,0.158 0.38,0.289 0.609,0.381 0.229,0.091 0.482,0.141 0.744,0.141 0.273,0 0.521,-0.04 0.735,-0.1 C 8.765,10.011 8.908,9.953 9.031,9.894 9.217,9.803 9.359,9.704 9.46,9.623 9.55,9.553 9.606,9.495 9.634,9.467 l 3.03,-3.166 c 0.268,-0.277 0.53,-0.623 0.732,-1.041 0.101,-0.209 0.186,-0.436 0.245,-0.679 0.061,-0.242 0.095,-0.503 0.095,-0.772 0,-0.33 -0.037,-0.642 -0.107,-0.935 z M 8.362,1.96 l 0,0 0,0 0,0 z"
id="path5"
style="fill:#ffffff" /><polygon
points="12.664,6.301 12.666,6.299 12.664,6.301 "
id="polygon7"
style="fill:#ffffff" /></g></svg>

After

Width:  |  Height:  |  Size: 4.1 KiB

View File

@ -0,0 +1,8 @@
<svg width="16" height="16" xmlns="http://www.w3.org/2000/svg">
<metadata id="metadata13">image/svg+xml</metadata>
<g>
<title>Layer 1</title>
<rect ry="1" rx="1" id="svg_6" height="8" width="14" y="3" x="1" stroke-linecap="null" stroke-linejoin="null" stroke-width="2" stroke="#ffffff" fill="none"/>
<path id="svg_8" d="m4.50183,15.49984l3.4986,-4.12208l3.49866,4.12208l-6.99725,0z" stroke-linecap="null" stroke-linejoin="null" stroke="#ffffff" fill="#ffffff"/>
</g>
</svg>

After

Width:  |  Height:  |  Size: 482 B

View File

@ -0,0 +1,22 @@
<?xml version="1.0" encoding="UTF-8" standalone="no"?>
<!-- Created with Inkscape (http://www.inkscape.org/) -->
<svg
xmlns:dc="http://purl.org/dc/elements/1.1/"
xmlns:cc="http://creativecommons.org/ns#"
xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#"
xmlns:svg="http://www.w3.org/2000/svg"
xmlns="http://www.w3.org/2000/svg"
version="1.1"
width="27"
height="32"
viewBox="0 0 26.999999 31.999999"
id="Layer_1"
xml:space="preserve"><metadata
id="metadata9"><rdf:RDF><cc:Work
rdf:about=""><dc:format>image/svg+xml</dc:format><dc:type
rdf:resource="http://purl.org/dc/dcmitype/StillImage" /><dc:title></dc:title></cc:Work></rdf:RDF></metadata><defs
id="defs7" /><path
d="M 5.0774179,2.9032355 C 2.9746346,4.3950939 1.3168041,6.548619 0.57798838,9.0267615 -0.36459081,12.040868 -0.16637195,15.423795 1.2627444,18.256944 c 1.4623839,2.960234 4.1778437,5.214598 7.2744936,6.326585 2.585162,0.998716 5.460029,1.140995 8.151924,0.504193 -0.321586,2.479524 -1.397235,4.780853 -2.664173,6.912277 3.971308,-2.573456 7.23984,-6.100043 9.904013,-9.983019 1.96001,-2.927081 3.262987,-6.41361 3.099422,-9.971968 C 26.884265,8.9176349 25.349801,5.9408249 23.075136,3.812164 20.611955,1.5122157 17.268571,0.20269558 13.900236,0.11428916 10.752299,-0.00174427 7.6029757,1.0411752 5.0774179,2.9032355 z"
id="path3"
style="fill:#ffffff" /></svg>

After

Width:  |  Height:  |  Size: 1.4 KiB