From 2913326fb21d47032d331bbfe688af6702ca79c0 Mon Sep 17 00:00:00 2001 From: krepa098 Date: Thu, 9 Oct 2014 21:20:06 +0200 Subject: [PATCH] fix #416, cleanup --- res.qrc | 1 + src/widget/form/chatform.cpp | 13 +++++-------- src/widget/form/genericchatform.cpp | 14 +++++--------- src/widget/form/groupchatform.cpp | 20 ++++---------------- ui/chatArea/chatHead.css | 14 ++++++++++++++ 5 files changed, 29 insertions(+), 33 deletions(-) create mode 100644 ui/chatArea/chatHead.css diff --git a/res.qrc b/res.qrc index 375312b1d..29ca53664 100644 --- a/res.qrc +++ b/res.qrc @@ -140,5 +140,6 @@ ui/settings/mainContent.css ui/settings/mainHead.css translations/pirate.qm + ui/chatArea/chatHead.css diff --git a/src/widget/form/chatform.cpp b/src/widget/form/chatform.cpp index 94420ae5e..a717019b3 100644 --- a/src/widget/form/chatform.cpp +++ b/src/widget/form/chatform.cpp @@ -39,15 +39,16 @@ ChatForm::ChatForm(Friend* chatFriend) : f(chatFriend) + , audioInputFlag(false) + , callId(0) { nameLabel->setText(f->getName()); avatar->setPixmap(QPixmap(":/img/contact_dark.png"), Qt::transparent); statusMessageLabel = new CroppingLabel(); + statusMessageLabel->setObjectName("statusLabel"); statusMessageLabel->setFont(Style::getFont(Style::Medium)); - QPalette pal; pal.setColor(QPalette::WindowText, Style::getColor(Style::MediumGrey)); - statusMessageLabel->setPalette(pal); netcam = new NetCamView(); @@ -466,15 +467,11 @@ void ChatForm::onMicMuteToggle() { emit micMuteToggle(callId); if (micButton->objectName() == "red") - { micButton->setObjectName("green"); - micButton->style()->polish(micButton); - } else - { micButton->setObjectName("red"); - micButton->style()->polish(micButton); - } + + Style::repolish(micButton); } } diff --git a/src/widget/form/genericchatform.cpp b/src/widget/form/genericchatform.cpp index a42a956dd..bdb764777 100644 --- a/src/widget/form/genericchatform.cpp +++ b/src/widget/form/genericchatform.cpp @@ -37,9 +37,7 @@ GenericChatForm::GenericChatForm(QWidget *parent) : headWidget = new QWidget(); nameLabel = new CroppingLabel(); - nameLabel->setFont(Style::getFont(Style::MediumBold)); - QPalette pal; pal.setColor(QPalette::WindowText, Style::getColor(Style::DarkGrey)); - nameLabel->setPalette(pal); + nameLabel->setObjectName("nameLabel"); avatar = new MaskablePixmapWidget(this, QSize(40,40), ":/img/avatar_mask.png"); QHBoxLayout *headLayout = new QHBoxLayout(), *mainFootLayout = new QHBoxLayout(); @@ -48,8 +46,6 @@ GenericChatForm::GenericChatForm(QWidget *parent) : QVBoxLayout *footButtonsSmall = new QVBoxLayout(), *volMicLayout = new QVBoxLayout(); chatWidget = new ChatAreaWidget(); - chatWidget->document()->setDefaultStyleSheet(Style::getStylesheet(":ui/chatArea/innerStyle.css")); - chatWidget->setStyleSheet(Style::getStylesheet(":/ui/chatArea/chatArea.css")); msgEdit = new ChatTextEdit(); @@ -62,10 +58,6 @@ GenericChatForm::GenericChatForm(QWidget *parent) : volButton = new QPushButton(); micButton = new QPushButton(); - QFont bold; - bold.setBold(true); - nameLabel->setFont(bold); - footButtonsSmall->setSpacing(2); msgEdit->setStyleSheet(Style::getStylesheet(":/ui/msgEdit/msgEdit.css")); @@ -125,6 +117,10 @@ GenericChatForm::GenericChatForm(QWidget *parent) : connect(emoteButton, SIGNAL(clicked()), this, SLOT(onEmoteButtonClicked())); connect(chatWidget, SIGNAL(customContextMenuRequested(QPoint)), this, SLOT(onChatContextMenuRequested(QPoint))); + + chatWidget->document()->setDefaultStyleSheet(Style::getStylesheet(":ui/chatArea/innerStyle.css")); + chatWidget->setStyleSheet(Style::getStylesheet(":/ui/chatArea/chatArea.css")); + headWidget->setStyleSheet(Style::getStylesheet(":/ui/chatArea/chatHead.css")); } int GenericChatForm::getNumberOfMessages() diff --git a/src/widget/form/groupchatform.cpp b/src/widget/form/groupchatform.cpp index 822304f58..0c5b4c9e1 100644 --- a/src/widget/form/groupchatform.cpp +++ b/src/widget/form/groupchatform.cpp @@ -31,6 +31,7 @@ GroupChatForm::GroupChatForm(Group* chatGroup) { nusersLabel = new QLabel(); namesList = new QLabel(); + namesList->setObjectName("peersLabel"); fileButton->setEnabled(false); callButton->setVisible(false); @@ -38,24 +39,15 @@ GroupChatForm::GroupChatForm(Group* chatGroup) volButton->setVisible(false); micButton->setVisible(false); - QFont small; - small.setPixelSize(10); - nameLabel->setText(group->widget->getName()); nusersLabel->setFont(Style::getFont(Style::Medium)); nusersLabel->setText(GroupChatForm::tr("%1 users in chat","Number of users in chat").arg(group->peers.size())); - QPalette pal; pal.setColor(QPalette::WindowText, Style::getColor(Style::MediumGrey)); - nusersLabel->setPalette(pal); + nusersLabel->setObjectName("statusLabel"); avatar->setPixmap(QPixmap(":/img/group_dark.png"), Qt::transparent); - QString names; - for (QString& s : group->peers) - names.append(s+", "); - names.chop(2); - namesList->setText(names); - namesList->setFont(small); + namesList->setText(QStringList(group->peers.values()).join(", ")); msgEdit->setObjectName("group"); @@ -83,11 +75,7 @@ void GroupChatForm::onSendTriggered() void GroupChatForm::onUserListChanged() { nusersLabel->setText(tr("%1 users in chat").arg(group->nPeers)); - QString names; - for (QString& s : group->peers) - names.append(s+", "); - names.chop(2); - namesList->setText(names); + namesList->setText(QStringList(group->peers.values()).join(", ")); } void GroupChatForm::dragEnterEvent(QDragEnterEvent *ev) diff --git a/ui/chatArea/chatHead.css b/ui/chatArea/chatHead.css new file mode 100644 index 000000000..1747dc900 --- /dev/null +++ b/ui/chatArea/chatHead.css @@ -0,0 +1,14 @@ +#nameLabel { + color: @black; + font: @mediumBold; +} + +#statusLabel { + color: @mediumGrey; + font: @medium; +} + +#peersLabel { + color: @mediumGrey; + font: @medium; +}