diff --git a/res.qrc b/res.qrc index f413e0209..0b6abfff5 100644 --- a/res.qrc +++ b/res.qrc @@ -124,5 +124,6 @@ ui/micButton/micButtonPressed.png ui/micButton/micButton.css ui/volButton/volButton.css + ui/fileButton/fileButtonDisabled.png diff --git a/ui/fileButton/fileButton.css b/ui/fileButton/fileButton.css index 59b110ced..fd06c6f0e 100644 --- a/ui/fileButton/fileButton.css +++ b/ui/fileButton/fileButton.css @@ -17,6 +17,11 @@ QPushButton:pressed background-image: url(":/ui/fileButton/fileButtonPressed.png"); } +QPushButton[enabled="false"] +{ + background-image: url(":/ui/fileButton/fileButtonDisabled.png"); +} + QPushButton:focus { outline: none; } diff --git a/ui/fileButton/fileButtonDisabled.png b/ui/fileButton/fileButtonDisabled.png new file mode 100644 index 000000000..ed024e2df Binary files /dev/null and b/ui/fileButton/fileButtonDisabled.png differ diff --git a/widget/form/chatform.cpp b/widget/form/chatform.cpp index 6a7d0e114..2c57fc597 100644 --- a/widget/form/chatform.cpp +++ b/widget/form/chatform.cpp @@ -52,7 +52,6 @@ ChatForm::ChatForm(Friend* chatFriend) connect(msgEdit, &ChatTextEdit::enterPressed, this, &ChatForm::onSendTriggered); connect(chatArea->verticalScrollBar(), &QScrollBar::rangeChanged, this, &ChatForm::onSliderRangeChanged); connect(chatArea, &QScrollArea::customContextMenuRequested, this, &ChatForm::onChatContextMenuRequested); - connect(emoteButton, &QPushButton::clicked, this, &ChatForm::onEmoteButtonClicked); connect(micButton, SIGNAL(clicked()), this, SLOT(onMicMuteToggle())); } @@ -530,33 +529,6 @@ void ChatForm::onCancelCallTriggered() emit cancelCall(callId, f->friendId); } -void ChatForm::onEmoteButtonClicked() -{ - // don't show the smiley selection widget if there are no smileys available - if (SmileyPack::getInstance().getEmoticons().empty()) - return; - - EmoticonsWidget widget; - connect(&widget, &EmoticonsWidget::insertEmoticon, this, &ChatForm::onEmoteInsertRequested); - - QWidget* sender = qobject_cast(QObject::sender()); - if (sender) - { - QPoint pos = -QPoint(widget.sizeHint().width() / 2, widget.sizeHint().height()) - QPoint(0, 10); - widget.exec(sender->mapToGlobal(pos)); - } -} - -void ChatForm::onEmoteInsertRequested(QString str) -{ - // insert the emoticon - QWidget* sender = qobject_cast(QObject::sender()); - if (sender) - msgEdit->insertPlainText(str); - - msgEdit->setFocus(); // refocus so that we can continue typing -} - void ChatForm::onMicMuteToggle() { if (audioInputFlag == true) diff --git a/widget/form/chatform.h b/widget/form/chatform.h index c2c530863..395940663 100644 --- a/widget/form/chatform.h +++ b/widget/form/chatform.h @@ -81,8 +81,6 @@ private slots: void onAnswerCallTriggered(); void onHangupCallTriggered(); void onCancelCallTriggered(); - void onEmoteButtonClicked(); - void onEmoteInsertRequested(QString str); private: Friend* f; diff --git a/widget/form/genericchatform.cpp b/widget/form/genericchatform.cpp index f28173e72..56ae97558 100644 --- a/widget/form/genericchatform.cpp +++ b/widget/form/genericchatform.cpp @@ -19,6 +19,8 @@ #include #include #include +#include "smileypack.h" +#include "widget/emoticonswidget.h" #include "style.h" GenericChatForm::GenericChatForm(QObject *parent) : @@ -134,8 +136,6 @@ GenericChatForm::GenericChatForm(QObject *parent) : headTextLayout->addStretch(); headTextLayout->addWidget(nameLabel); -// headTextLayout->addWidget(statusMessage); -// headTextLayout->addStretch(); chatArea->setWidget(chatAreaWidget); @@ -145,17 +145,7 @@ GenericChatForm::GenericChatForm(QObject *parent) : fileButton->setAttribute(Qt::WA_LayoutUsesWidgetRect); emoteButton->setAttribute(Qt::WA_LayoutUsesWidgetRect); - // connect(Widget::getInstance()->getCore(), &Core::fileSendStarted, this, &ChatForm::startFileSend); - // connect(Widget::getInstance()->getCore(), &Core::videoFrameReceived, netcam, &NetCamView::updateDisplay); - // connect(sendButton, &QPushButton::clicked, this, &ChatForm::onSendTriggered); - // connect(fileButton, &QPushButton::clicked, this, &ChatForm::onAttachClicked); - // connect(callButton, &QPushButton::clicked, this, &ChatForm::onCallTriggered); - // connect(videoButton, &QPushButton::clicked, this, &ChatForm::onVideoCallTriggered); - // connect(msgEdit, &ChatTextEdit::enterPressed, this, &ChatForm::onSendTriggered); - // connect(chatArea->verticalScrollBar(), &QScrollBar::rangeChanged, this, &ChatForm::onSliderRangeChanged); - // connect(chatArea, &QScrollArea::customContextMenuRequested, this, &ChatForm::onChatContextMenuRequested); - // connect(emoteButton, &QPushButton::clicked, this, &ChatForm::onEmoteButtonClicked); - // connect(micButton, SIGNAL(clicked()), this, SLOT(onMicMuteToggle())); + connect(emoteButton, SIGNAL(clicked()), this, SLOT(onEmoteButtonClicked())); } void GenericChatForm::setName(const QString &newName) @@ -230,3 +220,30 @@ GenericChatForm::~GenericChatForm() delete mainWidget; delete headWidget; } + +void GenericChatForm::onEmoteButtonClicked() +{ + // don't show the smiley selection widget if there are no smileys available + if (SmileyPack::getInstance().getEmoticons().empty()) + return; + + EmoticonsWidget widget; + connect(&widget, SIGNAL(insertEmoticon(QString)), this, SLOT(onEmoteInsertRequested(QString))); + + QWidget* sender = qobject_cast(QObject::sender()); + if (sender) + { + QPoint pos = -QPoint(widget.sizeHint().width() / 2, widget.sizeHint().height()) - QPoint(0, 10); + widget.exec(sender->mapToGlobal(pos)); + } +} + +void GenericChatForm::onEmoteInsertRequested(QString str) +{ + // insert the emoticon + QWidget* sender = qobject_cast(QObject::sender()); + if (sender) + msgEdit->insertPlainText(str); + + msgEdit->setFocus(); // refocus so that we can continue typing +} diff --git a/widget/form/genericchatform.h b/widget/form/genericchatform.h index b223bb395..2b2d9c62e 100644 --- a/widget/form/genericchatform.h +++ b/widget/form/genericchatform.h @@ -54,6 +54,8 @@ protected slots: void onChatContextMenuRequested(QPoint pos); void onSliderRangeChanged(); void onSaveLogClicked(); + void onEmoteButtonClicked(); + void onEmoteInsertRequested(QString str); protected: QLabel *nameLabel, *avatarLabel;