Commit 912242e7 authored by Andreas Traczyk's avatar Andreas Traczyk

conversation view: add call buttons

- add audio/video call buttons to message page header
- clean up button UI
- set messageList maxWidth and center in view
- fix incoming message selection bug

Change-Id: I74fe2a8760eb23198d14007cbfb045222813a667
parent f7e07926
......@@ -22,6 +22,7 @@
#include "callwidget.h"
#include "ui_callwidget.h"
#include <QScrollBar>
#include <QClipboard>
#include <QDesktopServices>
#include <QComboBox>
......@@ -112,6 +113,10 @@ CallWidget::CallWidget(QWidget* parent) :
ui->spinnerLabel->setMovie(miniSpinner_);
ui->spinnerLabel->hide();
ui->listMessageView->verticalScrollBar()->setEnabled(true);
ui->listMessageView->setVerticalScrollMode(QAbstractItemView::ScrollPerPixel);
ui->listMessageView->verticalScrollBar()->setStyleSheet("QScrollBar:vertical { width: 0px; }");
setupOutOfCallIM();
// connections
......@@ -151,10 +156,18 @@ CallWidget::CallWidget(QWidget* parent) :
connect(&LRCInstance::behaviorController(), &BehaviorController::showChatView,
this, &CallWidget::slotShowChatView);
// change call widget current account if combobox index changed
connect(ui->currentAccountComboBox, QOverload<int>::of(&QComboBox::currentIndexChanged),
this, &CallWidget::slotAccountChanged);
connect(ui->sendContactRequestButton, &QPushButton::clicked,
this, &CallWidget::on_sendContactRequestButton_clicked);
connect(ui->btnAudioCall, &QPushButton::clicked,
this, &CallWidget::on_sendContactRequestButton_clicked);
connect(ui->btnVideoCall, &QPushButton::clicked,
this, &CallWidget::on_sendContactRequestButton_clicked);
// set first view to welcome view
ui->stackedWidget->setCurrentWidget(ui->welcomePage);
}
......@@ -717,7 +730,7 @@ CallWidget::showIMOutOfCall(const QModelIndex& nodeIdx)
}
bool shouldShowSendContactRequestBtn = !isContact && isRINGAccount;
ui->sendContactRequestPageButton->setVisible(shouldShowSendContactRequestBtn);
ui->sendContactRequestButton->setVisible(shouldShowSendContactRequestBtn);
showConversationView();
......@@ -803,21 +816,31 @@ CallWidget::on_shareButton_clicked()
}
void
CallWidget::on_sendContactRequestPageButton_clicked()
CallWidget::on_sendContactRequestButton_clicked()
{
LRCInstance::getCurrentConversationModel()->makePermanent(selectedConvUid());
}
void
CallWidget::on_sendCRBackButton_clicked()
CallWidget::on_pendingCRBackButton_clicked()
{
ui->stackedWidget->setCurrentWidget(ui->messagingPage);
ui->stackedWidget->setCurrentWidget(ui->welcomePage);
}
void
CallWidget::on_pendingCRBackButton_clicked()
CallWidget::on_btnAudioCall_clicked()
{
ui->stackedWidget->setCurrentWidget(ui->welcomePage);
auto convUid = LRCInstance::getSelectedConvUid();
LRCInstance::getCurrentConversationModel()->placeAudioOnlyCall(convUid);
ui->callingPhoto->setPixmap(QPixmap::fromImage(imageForConv(convUid)));
}
void
CallWidget::on_btnVideoCall_clicked()
{
auto convUid = LRCInstance::getSelectedConvUid();
LRCInstance::getCurrentConversationModel()->placeCall(convUid);
ui->callingPhoto->setPixmap(QPixmap::fromImage(imageForConv(convUid)));
}
bool
......
......@@ -74,7 +74,7 @@ public slots:
void slotAcceptInviteClicked(const QModelIndex& index);
void slotBlockInviteClicked(const QModelIndex& index);
void slotIgnoreInviteClicked(const QModelIndex& index);
void slotCustomContextMenuRequested(const QPoint & pos);
void slotCustomContextMenuRequested(const QPoint & pos);
void slotAccountChanged(int index);
void slotShowCallView(const std::string & accountId, const lrc::api::conversation::Info & convInfo);
void slotShowIncomingCallView(const std::string & accountId, const lrc::api::conversation::Info & convInfo);
......@@ -90,12 +90,13 @@ private slots:
void on_imMessageEdit_returnPressed();
void on_ringContactLineEdit_textChanged(const QString& text);
void on_imBackButton_clicked();
void on_sendContactRequestPageButton_clicked();
void on_sendCRBackButton_clicked();
void on_sendContactRequestButton_clicked();
void on_smartList_clicked(const QModelIndex &index);
void on_qrButton_toggled(bool checked);
void on_shareButton_clicked();
void on_pendingCRBackButton_clicked();
void on_btnAudioCall_clicked();
void on_btnVideoCall_clicked();
private slots:
void smartListSelectionChanged(const QItemSelection &selected, const QItemSelection &deselected);
......
This diff is collapsed.
......@@ -292,7 +292,7 @@
</property>
<property name="icon">
<iconset resource="ressources.qrc">
<normaloff>:/images/default-avatar-overlay.svg</normaloff>:/images/default-avatar-overlay.svg</iconset>
<normaloff>:/images/default_avatar_overlay.svg</normaloff>:/images/default_avatar_overlay.svg</iconset>
</property>
<property name="iconSize">
<size>
......
......@@ -69,7 +69,7 @@
<string/>
</property>
<property name="pixmap">
<pixmap resource="ressources.qrc">:/images/default-avatar-overlay.svg</pixmap>
<pixmap resource="ressources.qrc">:/images/default_avatar_overlay.svg</pixmap>
</property>
<property name="scaledContents">
<bool>true</bool>
......
......@@ -22,7 +22,6 @@
#include <QApplication>
#include <QPainter>
#include <QPixmap>
#include <QDebug>
// Client
#include "smartlistmodel.h"
......@@ -49,21 +48,13 @@ ConversationItemDelegate::paint(QPainter* painter
if (opt.state & QStyle::State_HasFocus)
opt.state ^= QStyle::State_HasFocus;
// First, we draw the control itself
QStyle* style = opt.widget ? opt.widget->style() : QApplication::style();
style->drawControl(QStyle::CE_ItemViewItem, &opt, painter, opt.widget);
auto isContextMenuOpen = index.data(static_cast<int>(SmartListModel::Role::ContextMenuOpen)).value<bool>();
bool selected = false;
if (option.state & QStyle::State_Selected) {
selected = true;
opt.state ^= QStyle::State_Selected;
} else if (!isContextMenuOpen) {
if (option.state & QStyle::State_MouseOver) {
highlightMap_[index.row()] = true;
} else {
highlightMap_[index.row()] = false;
}
highlightMap_[index.row()] = option.state & QStyle::State_MouseOver;
}
// One does not simply keep the highlighted state drawn when the context
......
<svg xmlns="http://www.w3.org/2000/svg" width="24" height="24" viewBox="0 0 24 24"><path d="M0 0h24v24H0z" fill="none"/><path d="M20 11H7.83l5.59-5.59L12 4l-8 8 8 8 1.41-1.41L7.83 13H20v-2z"/></svg>
\ No newline at end of file
<svg xmlns="http://www.w3.org/2000/svg" width="24" height="24" viewBox="0 0 24 24"><path d="M0 0h24v24H0z" fill="none"/><path d="M6.62 10.79c1.44 2.83 3.76 5.14 6.59 6.59l2.2-2.2c.27-.27.67-.36 1.02-.24 1.12.37 2.33.57 3.57.57.55 0 1 .45 1 1V20c0 .55-.45 1-1 1-9.39 0-17-7.61-17-17 0-.55.45-1 1-1h3.5c.55 0 1 .45 1 1 0 1.25.2 2.45.57 3.57.11.35.03.74-.25 1.02l-2.2 2.2z"/></svg>
\ No newline at end of file
<svg xmlns="http://www.w3.org/2000/svg" width="24" height="24" viewBox="0 0 24 24"><path d="M2.01 21L23 12 2.01 3 2 10l15 2-15 2z"/><path d="M0 0h24v24H0z" fill="none"/></svg>
\ No newline at end of file
<svg xmlns="http://www.w3.org/2000/svg" width="24" height="24" viewBox="0 0 24 24"><path fill="none" d="M0 0h24v24H0V0z"/><path d="M17 10.5V7c0-.55-.45-1-1-1H4c-.55 0-1 .45-1 1v10c0 .55.45 1 1 1h12c.55 0 1-.45 1-1v-3.5l4 4v-11l-4 4zM14 13h-3v3H9v-3H6v-2h3V8h2v3h3v2z"/></svg>
\ No newline at end of file
......@@ -32,7 +32,7 @@
#include "utils.h"
ImDelegate::ImDelegate(QObject *parent)
: QStyledItemDelegate(parent)
: QItemDelegate(parent)
{
}
......@@ -66,14 +66,13 @@ ImDelegate::paint(QPainter* painter,
auto dir = isGenerated ? Qt::AlignHCenter : (isOutgoing ? Qt::AlignRight : Qt::AlignLeft);
QStyleOptionViewItem opt = option;
initStyleOption(&opt, index);
painter->setRenderHint(QPainter::Antialiasing);
opt.font = fontMsg_;
painter->setFont(fontMsg_);
opt.text.clear();
QStyle* style = opt.widget ? opt.widget->style() : QApplication::style();
formatMsg(index, msg);
......@@ -89,15 +88,22 @@ ImDelegate::paint(QPainter* painter,
document.setTextWidth(textRect.width());
if (dir == Qt::AlignLeft) {
opt.decorationSize = iconSize_;
// avatar
opt.decorationSize = QSize(sizeImage_, sizeImage_);
opt.decorationPosition = QStyleOptionViewItem::Left;
opt.decorationAlignment = Qt::AlignTop | Qt::AlignHCenter;
style->drawControl(QStyle::CE_ItemViewItem, &opt, painter, opt.widget);
opt.decorationAlignment = Qt::AlignCenter;
QRect rectAvatar(margin_ + opt.rect.left(),
margin_ + opt.rect.top(),
sizeImage_, sizeImage_);
drawDecoration(painter, opt, rectAvatar,
QPixmap::fromImage(index.data(Qt::DecorationRole).value<QImage>())
.scaled(sizeImage_, sizeImage_, Qt::KeepAspectRatio, Qt::SmoothTransformation));
} else {
opt.decorationSize = QSize();
opt.decorationPosition = QStyleOptionViewItem::Right;
}
// message bubble
QPainterPath path;
path.addRoundedRect(textRect, bubbleRadius_, bubbleRadius_);
......@@ -111,6 +117,7 @@ ImDelegate::paint(QPainter* painter,
painter->save();
// text
painter->translate(textRect.topLeft());
document.drawContents(painter);
painter->restore();
......@@ -123,8 +130,8 @@ QRect ImDelegate::getBoundingRect(const Qt::AlignmentFlag& dir,
QRect textRect;
if (dir == Qt::AlignLeft) {
txtDoc.setTextWidth(option.rect.width() - iconSize_.width() - padding_);
textRect.setRect(option.rect.left() + iconSize_.width() + padding_,
txtDoc.setTextWidth(option.rect.width() - sizeImage_ - padding_);
textRect.setRect(option.rect.left() + sizeImage_ + padding_,
option.rect.top() + padding_,
txtDoc.idealWidth(),
txtDoc.size().height());
......@@ -174,8 +181,8 @@ ImDelegate::sizeHint(const QStyleOptionViewItem& option,
QSize size(boundingRect.width() + 2 * margin_, boundingRect.height());
/* Keep the minimum height needed. */
if(size.height() < iconSize_.height())
size.setHeight(iconSize_.height());
if(size.height() < sizeImage_)
size.setHeight(sizeImage_);
size.setHeight(size.height() + 2 * margin_);
......
......@@ -20,9 +20,9 @@
#include <QPainter>
#include <QTextDocument>
#include <QStyledItemDelegate>
#include <QItemDelegate>
class ImDelegate : public QStyledItemDelegate
class ImDelegate : public QItemDelegate
{
Q_OBJECT
public:
......@@ -38,8 +38,7 @@ private:
const QFont fontMsg_ = QFont("Arial", 10);
const QString defaultStylesheet_ = QString("body { color : black; } i { opacity: 100; font-size : 10px; text-align : right; }");
const QSize iconSize_ {38, 38};
constexpr static int sizeImage_ = 38;
constexpr static int margin_ = 5;
constexpr static int padding_ = 5;
constexpr static int bubbleRadius_ = 12;
......
......@@ -108,7 +108,7 @@
</property>
<property name="icon">
<iconset resource="ressources.qrc">
<normaloff>:/images/icons/ic_clear-24px.svg</normaloff>:/images/icons/ic_clear-24px.svg</iconset>
<normaloff>:/images/icons/ic_clear_24px.svg</normaloff>:/images/icons/ic_clear_24px.svg</iconset>
</property>
<property name="iconSize">
<size>
......@@ -140,7 +140,7 @@
</property>
<property name="icon">
<iconset resource="ressources.qrc">
<normaloff>:/images/icons/ic_block-24px.svg</normaloff>:/images/icons/ic_block-24px.svg</iconset>
<normaloff>:/images/icons/ic_block_24px.svg</normaloff>:/images/icons/ic_block_24px.svg</iconset>
</property>
<property name="iconSize">
<size>
......
......@@ -99,7 +99,7 @@ fallbackAvatar(const QSize size, const QString& canonicalUriStr, const QString&
overlayRect.moveTop(overlayRect.top() + margin * 0.5);
overlayRect.setWidth(overlayRect.width() - margin);
overlayRect.setHeight(overlayRect.height() - margin);
painter.drawPixmap(overlayRect, QPixmap(":/images/default-avatar-overlay.svg"));
painter.drawPixmap(overlayRect, QPixmap(":/images/default_avatar_overlay.svg"));
}
return avatar;
......
......@@ -43,8 +43,12 @@
<file>images/icons/ic_chat_black_24dp_2x.png</file>
<file>images/icons/ic_person_add_black_24dp_2x.png</file>
<file>images/waiting.gif</file>
<file>images/default-avatar-overlay.svg</file>
<file>images/icons/ic_clear-24px.svg</file>
<file>images/icons/ic_block-24px.svg</file>
<file>images/default_avatar_overlay.svg</file>
<file>images/icons/ic_clear_24px.svg</file>
<file>images/icons/ic_block_24px.svg</file>
<file>images/icons/ic_phone_24px.svg</file>
<file>images/icons/ic_video_call_24px.svg</file>
<file>images/icons/ic_arrow_back_24px.svg</file>
<file>images/icons/ic_send_24px.svg</file>
</qresource>
</RCC>
......@@ -10,11 +10,11 @@ QPushButton#refuseButton, QPushButton#cancelButton{
border:solid 1px;
}
QPushButton#searchBtn:hover, QPushButton#acceptButton:hover{
QPushButton#acceptButton:hover{
background-color: #5db761;
}
QPushButton#searchBtn:pressed, QPushButton#acceptButton:pressed{
QPushButton#acceptButton:pressed{
background-color: #449d48;
}
......@@ -43,7 +43,9 @@ QPushButton#buttonConversations:pressed, QPushButton#buttonInvites:pressed {
background-color: rgb(212, 212, 212);
}
QPushButton#btnAcceptInvite, QPushButton#btnIgnoreInvite, QPushButton#btnBlockInvite {
QPushButton#imBackButton, QPushButton#btnAcceptInvite, QPushButton#btnIgnoreInvite,
QPushButton#btnBlockInvite, QPushButton#btnAudioCall, QPushButton#btnVideoCall,
QPushButton#sendContactRequestButton, QPushButton#sendButton, QPushButton#sendIMButton {
background-color: transparent;
border-style: solid;
border-width: 0px;
......@@ -60,6 +62,16 @@ QPushButton#btnAcceptInvite:pressed, QPushButton#btnIgnoreInvite:pressed, QPushB
background-color: rgb(187, 187, 187);
}
QPushButton#imBackButton:hover, QPushButton#btnAudioCall:hover, QPushButton#btnVideoCall:hover,
QPushButton#sendContactRequestButton:hover, QPushButton#sendButton:hover, QPushButton#sendIMButton:hover {
background-color: rgb(237, 237, 237);
}
QPushButton#imBackButton:pressed, QPushButton#btnAudioCall:pressed, QPushButton#btnVideoCall:pressed,
QPushButton#sendContactRequestButton:pressed, QPushButton#sendButton:pressed, QPushButton#sendIMButton:pressed {
background-color: rgb(212, 212, 212);
}
QWidget#callInvitePage, QWidget#outboundCallPage{
background-color : rgb(77, 77, 77);
background-image : url(:/images/background-dark.png);
......@@ -151,14 +163,13 @@ QListView#contactRequestList::item:hover, QListView#BannedList::item:hover {
background-color: rgba(242, 242, 242, 255);
}
QListView#listMessageView::item:hover{
background-color: rgba(255, 255, 255, 255);
}
QListView#listMessageView{
background: rgb(255, 255, 255);
border-top: 1px solid rgb(229, 229, 229);
border-bottom: 1px solid rgb(229, 229, 229);
border-bottom: 2px solid rgb(240, 240, 240);
}
QWidget#messagingHeaderWidget{
border-bottom: 2px solid rgb(240, 240, 240);
}
QLineEdit#messageEdit, QLineEdit#imMessageEdit{
......@@ -217,20 +228,20 @@ QPushButton#hangupButton:pressed{
}
QPushButton#exitSettingsButton, QPushButton#settingsButton, QPushButton#addToContactButton,
QPushButton#imBackButton, QPushButton#sendCRBackButton, QPushButton#copyCMButton, QPushButton#pendingCRBackButton,
QPushButton#sendCRBackButton, QPushButton#copyCMButton, QPushButton#pendingCRBackButton,
QPushButton#videoCfgBtn{
background-color: #414141;
border-radius: 15px;
border:solid 1px;
}
QPushButton#exitSettingsButton:hover, QPushButton#settingsButton:hover, QPushButton#imBackButton:hover,
QPushButton#exitSettingsButton:hover, QPushButton#settingsButton:hover,
QPushButton#sendCRBackButton:hover, QPushButton#copyCMButton:hover, QPushButton#pendingCRBackButton:hover,
QPushButton#videoCfgBtn:hover{
background-color: #515151;
}
QPushButton#exitSettingsButton:pressed, QPushButton#settingsButton:pressed, QPushButton#imBackButton:pressed,
QPushButton#exitSettingsButton:pressed, QPushButton#settingsButton:pressed,
QPushButton#sendCRBackButton:pressed, QPushButton#copyCMButton:pressed, QPushButton#pendingCRBackButton:pressed,
QPushButton#videoCfgBtn:pressed{
background-color: #313131;
......@@ -264,23 +275,6 @@ QPushButton#btnvideo{
border:solid 1px;
}
QPushButton#searchBtn, QPushButton#btnComBarVideo,
QPushButton#sendButton, QPushButton#sendIMButton, QPushButton#sendContactRequestPageButton{
background-color: #3AC0D2;
border-radius: 15px;
border:solid 1px;
}
QPushButton#searchBtn:hover, QPushButton#sendButton:hover,
QPushButton#sendIMButton:hover, QPushButton#btnComBarVideo:hover, QPushButton#sendContactRequestPageButton:hover{
background-color: #4dc6d6;
}
QPushButton#searchBtn:pressed, QPushButton#sendButton:pressed,
QPushButton#sendIMButton:pressed, QPushButton#btnComBarVideo:pressed, QPushButton#sendContactRequestPageButton:pressed{
background-color: #34acbd;
}
QScrollBar:vertical{
background: rgb(242, 242, 242);
width:10px;
......@@ -326,8 +320,7 @@ QPushButton#nextButton, QPushButton#playButton, QPushButton#clearHistoryButton,
QPushButton#checkUpdateButton, QPushButton#photoButton, QPushButton#takePhotoButton, QPushButton#importButton,
QPushButton#existingPushButton, QPushButton#newAccountButton, QPushButton#previousButton, QPushButton#exportButton,
QPushButton#cancelAddButton, QPushButton#exportOnRingButton, QPushButton#addDeviceButton, QPushButton#exportEndedOkButton,
QPushButton#errorPushButton, QPushButton#registerButton, QPushButton#sendContactRequestPageButton,
QPushButton#sendContactRequestButton, QPushButton#acceptCRButton, QPushButton#discardCRButton, QPushButton#deleteCancelBtn,
QPushButton#errorPushButton, QPushButton#registerButton, QPushButton#acceptCRButton, QPushButton#discardCRButton, QPushButton#deleteCancelBtn,
QPushButton#dhtImportBtn, QPushButton#fileImportBtn, QPushButton#changePassBtn, QPushButton#confirmChangeBtn {
background-color: #3AC0D2;
border: 0px;
......@@ -349,8 +342,7 @@ QPushButton#takePhotoButton:hover, QPushButton#importButton:hover,
QPushButton#existingPushButton:hover, QPushButton#newAccountButton:hover, QPushButton#previousButton:hover,
QPushButton#exportButton:hover, QPushButton#cancelAddButton:hover, QPushButton#exportOnRingButton:hover,
QPushButton#addDeviceButton:hover, QPushButton#exportEndedOkButton:hover, QPushButton#errorPushButton:hover,
QPushButton#registerButton:hover, QPushButton#sendContactRequestPageButton:hover,
QPushButton#sendContactRequestButton:hover, QPushButton#acceptCRButton:hover, QPushButton#discardCRButton:hover,
QPushButton#registerButton:hover, QPushButton#acceptCRButton:hover, QPushButton#discardCRButton:hover,
QPushButton#deleteCancelBtn:hover, QPushButton#dhtImportBtn:hover, QPushButton#fileImportBtn:hover,
QPushButton#changePassBtn:hover, QPushButton#confirmChangeBtn:hover{
background-color: #4dc6d6;
......@@ -367,8 +359,7 @@ QPushButton#takePhotoButton:pressed, QPushButton#importButton:pressed,
QPushButton#existingPushButton:pressed, QPushButton#newAccountButton:pressed, QPushButton#previousButton:pressed,
QPushButton#exportButton:pressed, QPushButton#cancelAddButton:pressed, QPushButton#exportOnRingButton:pressed,
QPushButton#addDeviceButton:pressed, QPushButton#exportEndedOkButton:pressed, QPushButton#errorPushButton:pressed,
QPushButton#registerButton:pressed, QPushButton#sendContactRequestPageButton:pressed,
QPushButton#sendContactRequestButton:pressed, QPushButton#acceptCRButton:pressed, QPushButton#discardCRButton:pressed,
QPushButton#registerButton:pressed, QPushButton#acceptCRButton:pressed, QPushButton#discardCRButton:pressed,
QPushButton#deleteCancelBtn:pressed, QPushButton#dhtImportBtn:pressed, QPushButton#fileImportBtn:pressed,
QPushButton#changePassBtn:pressed, QPushButton#confirmChangeBtn:pressed {
background-color: #34acbd;
......@@ -428,7 +419,7 @@ QComboBox::drop-down{
}
QRadioButton::indicator{
width: 12px;
width: 1 ;
height: 12px;
border-radius: 8px;
border-width: 2px;
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment