diff --git a/RingWinClient.pro b/RingWinClient.pro index 3cc68ad030fc65c25cdb59ba7bcef8aabc2041ce..29c76e839e72096fb63ece5e37fd35342d861e5c 100644 --- a/RingWinClient.pro +++ b/RingWinClient.pro @@ -42,7 +42,9 @@ SOURCES += main.cpp\ historydelegate.cpp \ contactdelegate.cpp \ selectareadialog.cpp \ - accountserializationadapter.cpp + accountserializationadapter.cpp \ + instantmessagingwidget.cpp + HEADERS += mainwindow.h \ callwidget.h \ @@ -60,7 +62,8 @@ HEADERS += mainwindow.h \ historydelegate.h \ contactdelegate.h \ selectareadialog.h \ - accountserializationadapter.h + accountserializationadapter.h \ + instantmessagingwidget.h FORMS += mainwindow.ui \ callwidget.ui \ @@ -70,7 +73,8 @@ FORMS += mainwindow.ui \ accountdetails.ui \ aboutdialog.ui \ pivotviewwidget.ui \ - wizarddialog.ui + wizarddialog.ui \ + instantmessagingwidget.ui win32: LIBS += -lole32 -luuid -lshlwapi diff --git a/callwidget.cpp b/callwidget.cpp index 434b5803b0000cf5a1d3d82b08d4e1db752bf8d7..8d294265e792a9897fc086f7f9a41e4f5d3f27d4 100644 --- a/callwidget.cpp +++ b/callwidget.cpp @@ -227,53 +227,6 @@ CallWidget::callStateChanged(Call* call, Call::State previousState) ui->callStateLabel->setText("Call State : " + call->toHumanStateName()); } -void -CallWidget::setMediaText(Call *call) -{ - if (call != nullptr) { - connect(call, SIGNAL(mediaAdded(Media::Media*)), - this, SLOT(mediaAdd(Media::Media*))); - Media::Text *textMedia = call->addOutgoingMedia<Media::Text>(); - connect(ui->messageInput, &QLineEdit::returnPressed, [=]() - { - textMedia->send(ui->messageInput->text()); - ui->messageInput->clear(); - }); - ui->messageInput->show(); - } else { - ui->messageOutput->disconnect(); - ui->messageInput->disconnect(); - ui->messageOutput->hide(); - ui->messageInput->hide(); - } -} - -void -CallWidget::mediaAdd(Media::Media *media) -{ - switch(media->type()) { - case Media::Media::Type::AUDIO: - break; - case Media::Media::Type::VIDEO: - break; - case Media::Media::Type::TEXT: - if (media->direction() == Media::Text::Direction::IN) { - ui->messageOutput->setModel( - static_cast<Media::Text*>(media)->recording()-> - instantMessagingModel()); - connect(ui->messageOutput->model(), - SIGNAL(rowsInserted(const QModelIndex&, int, int)), - ui->messageOutput, SLOT(scrollToBottom())); - ui->messageOutput->show(); - } - break; - case Media::Media::Type::FILE: - break; - default: - break; - } -} - void CallWidget::on_callList_activated(const QModelIndex &index) { @@ -370,10 +323,10 @@ CallWidget::setActualCall(Call* value) actualCall_ = value; ui->holdButton->setEnabled(actualCall_ != nullptr); ui->hangupButton->setEnabled(actualCall_ != nullptr); - ui->messageInput->setEnabled(actualCall_ != nullptr); - ui->messageOutput->setEnabled(actualCall_ != nullptr); - setMediaText(actualCall_); + ui->instantMessagingWidget->setVisible(actualCall_ != nullptr); + ui->instantMessagingWidget->setMediaText(actualCall_); } + void CallWidget::on_sortComboBox_currentIndexChanged(int index) { diff --git a/callwidget.h b/callwidget.h index 27f4c0710fb60eddb96eed90cc482df50b3467b6..588209b32f3b83bcb32e51fb9d93a429b5e90c7e 100644 --- a/callwidget.h +++ b/callwidget.h @@ -25,11 +25,11 @@ #include <QMenu> #include "navwidget.h" +#include "instantmessagingwidget.h" #include "callmodel.h" #include "video/renderer.h" #include "video/previewmanager.h" - #include "categorizedhistorymodel.h" namespace Ui { @@ -67,7 +67,6 @@ private slots: void addedCall(Call *call, Call *parent); void callStateChanged(Call *call, Call::State previousState); void findRingAccount(QModelIndex idx1, QModelIndex idx2, QVector<int> vec); - void mediaAdd(Media::Media* media); private: Ui::CallWidget *ui; @@ -80,7 +79,6 @@ private: private: void findRingAccount(); void setActualCall(Call *value); - void setMediaText(Call* call); }; #endif // CALLWIDGET_H diff --git a/callwidget.ui b/callwidget.ui index 383fa353413bd532ee3907bd7e8bc4394ad0f776..f322d6fb8740508ec2fa7b8dfd1a4c43439499c1 100644 --- a/callwidget.ui +++ b/callwidget.ui @@ -217,7 +217,7 @@ <string>Hold/Unhold</string> </property> <property name="icon"> - <iconset resource="ressources.qrc"> + <iconset> <normaloff>:/images/phone-paused.png</normaloff>:/images/phone-paused.png</iconset> </property> </widget> @@ -237,7 +237,7 @@ <string>Hangup</string> </property> <property name="icon"> - <iconset resource="ressources.qrc"> + <iconset> <normaloff>:/images/phone-hangup.png</normaloff>:/images/phone-hangup.png</iconset> </property> </widget> @@ -296,7 +296,7 @@ <string>Accept</string> </property> <property name="icon"> - <iconset resource="ressources.qrc"> + <iconset> <normaloff>:/images/phone.png</normaloff>:/images/phone.png</iconset> </property> </widget> @@ -307,7 +307,7 @@ <string>Refuse</string> </property> <property name="icon"> - <iconset resource="ressources.qrc"> + <iconset> <normaloff>:/images/phone-hangup.png</normaloff>:/images/phone-hangup.png</iconset> </property> </widget> @@ -348,7 +348,7 @@ <string/> </property> <property name="icon"> - <iconset resource="ressources.qrc"> + <iconset> <normaloff>:/images/speaker-off.png</normaloff>:/images/speaker-off.png</iconset> </property> <property name="iconSize"> @@ -372,7 +372,7 @@ <string/> </property> <property name="icon"> - <iconset resource="ressources.qrc"> + <iconset> <normaloff>:/images/microphone-off.png</normaloff>:/images/microphone-off.png</iconset> </property> <property name="iconSize"> @@ -398,32 +398,13 @@ </widget> </item> <item> - <widget class="QListView" name="messageOutput"> + <widget class="InstantMessagingWidget" name="instantMessagingWidget" native="true"> <property name="sizePolicy"> <sizepolicy hsizetype="Expanding" vsizetype="Fixed"> <horstretch>0</horstretch> <verstretch>0</verstretch> </sizepolicy> </property> - <property name="flow"> - <enum>QListView::TopToBottom</enum> - </property> - <property name="isWrapping" stdset="0"> - <bool>false</bool> - </property> - <property name="wordWrap"> - <bool>true</bool> - </property> - </widget> - </item> - <item> - <widget class="QLineEdit" name="messageInput"> - <property name="placeholderText"> - <string>Send text message...</string> - </property> - <property name="clearButtonEnabled"> - <bool>true</bool> - </property> </widget> </item> </layout> @@ -438,9 +419,13 @@ <header>videowidget.h</header> <container>1</container> </customwidget> + <customwidget> + <class>InstantMessagingWidget</class> + <extends>QWidget</extends> + <header>instantmessagingwidget.h</header> + <container>1</container> + </customwidget> </customwidgets> - <resources> - <include location="ressources.qrc"/> - </resources> + <resources/> <connections/> </ui> diff --git a/instantmessagingwidget.cpp b/instantmessagingwidget.cpp new file mode 100644 index 0000000000000000000000000000000000000000..11b435a05634a49cc456c652e100e0689912c43e --- /dev/null +++ b/instantmessagingwidget.cpp @@ -0,0 +1,115 @@ +/*************************************************************************** + * Copyright (C) 2015 by Savoir-Faire Linux * + * Author: Edric Ladent Milaret <edric.ladent-milaret@savoirfairelinux.com>* + * * + * This program is free software; you can redistribute it and/or modify * + * it under the terms of the GNU General Public License as published by * + * the Free Software Foundation; either version 3 of the License, or * + * (at your option) any later version. * + * * + * This program is distributed in the hope that it will be useful, * + * but WITHOUT ANY WARRANTY; without even the implied warranty of * + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * + * GNU General Public License for more details. * + * * + * You should have received a copy of the GNU General Public License * + * along with this program. If not, see <http://www.gnu.org/licenses/>. * + **************************************************************************/ + +#include "instantmessagingwidget.h" +#include "ui_instantmessagingwidget.h" + +#include <QApplication> +#include <QClipboard> +#include <QMenu> + +#include "media/text.h" +#include "media/textrecording.h" + +InstantMessagingWidget::InstantMessagingWidget(QWidget *parent) : + QWidget(parent), + ui(new Ui::InstantMessagingWidget) +{ + ui->setupUi(this); + + ui->messageInput->hide(); + ui->messageOutput->hide(); + + ui->messageOutput->setContextMenuPolicy(Qt::ActionsContextMenu); + auto copyAction = new QAction("Copy", this); + ui->messageOutput->addAction(copyAction); + connect(copyAction, &QAction::triggered, [=]() { + copyToClipboard(); + }); +} + +InstantMessagingWidget::~InstantMessagingWidget() +{ + delete ui; +} + +void +InstantMessagingWidget::setMediaText(Call *call) +{ + if (call != nullptr) { + connect(call, SIGNAL(mediaAdded(Media::Media*)), + this, SLOT(mediaAdd(Media::Media*))); + Media::Text *textMedia = call->addOutgoingMedia<Media::Text>(); + connect(ui->messageInput, &QLineEdit::returnPressed, [=]() + { + textMedia->send(ui->messageInput->text()); + ui->messageInput->clear(); + }); + ui->messageInput->show(); + } else { + ui->messageOutput->disconnect(); + ui->messageInput->disconnect(); + ui->messageOutput->hide(); + ui->messageInput->hide(); + } +} + +void +InstantMessagingWidget::mediaAdd(Media::Media *media) +{ + switch(media->type()) { + case Media::Media::Type::AUDIO: + break; + case Media::Media::Type::VIDEO: + break; + case Media::Media::Type::TEXT: + if (media->direction() == Media::Text::Direction::IN) { + ui->messageOutput->setModel( + static_cast<Media::Text*>(media)->recording()-> + instantMessagingModel()); + connect(ui->messageOutput->model(), + SIGNAL(rowsInserted(const QModelIndex&, int, int)), + ui->messageOutput, SLOT(scrollToBottom())); + ui->messageOutput->show(); + } + break; + case Media::Media::Type::FILE: + break; + default: + break; + } +} + +void +InstantMessagingWidget::keyPressEvent(QKeyEvent *event) +{ + if (event->matches(QKeySequence::Copy)) { + copyToClipboard(); + } +} + +void +InstantMessagingWidget::copyToClipboard() +{ + auto idx = ui->messageOutput->currentIndex(); + if (idx.isValid()) { + auto text = ui->messageOutput->model()->data(idx); + + QApplication::clipboard()->setText(text.value<QString>()); + } +} diff --git a/instantmessagingwidget.h b/instantmessagingwidget.h new file mode 100644 index 0000000000000000000000000000000000000000..f659f13d41f346fac5832feff2769dde2c4f3254 --- /dev/null +++ b/instantmessagingwidget.h @@ -0,0 +1,52 @@ +/*************************************************************************** + * Copyright (C) 2015 by Savoir-Faire Linux * + * Author: Edric Ladent Milaret <edric.ladent-milaret@savoirfairelinux.com>* + * * + * This program is free software; you can redistribute it and/or modify * + * it under the terms of the GNU General Public License as published by * + * the Free Software Foundation; either version 3 of the License, or * + * (at your option) any later version. * + * * + * This program is distributed in the hope that it will be useful, * + * but WITHOUT ANY WARRANTY; without even the implied warranty of * + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * + * GNU General Public License for more details. * + * * + * You should have received a copy of the GNU General Public License * + * along with this program. If not, see <http://www.gnu.org/licenses/>. * + **************************************************************************/ + +#ifndef INSTANTMESSAGINGWIDGET_H +#define INSTANTMESSAGINGWIDGET_H + +#include <QWidget> +#include <QKeyEvent> + +#include "call.h" +#include "media/media.h" + +namespace Ui { +class InstantMessagingWidget; +} + +class InstantMessagingWidget : public QWidget +{ + Q_OBJECT + +public: + explicit InstantMessagingWidget(QWidget *parent = 0); + ~InstantMessagingWidget(); + void setMediaText(Call* call); + +protected: + virtual void keyPressEvent(QKeyEvent *event); + +private slots: + void mediaAdd(Media::Media *media); + +private: + Ui::InstantMessagingWidget *ui; + void copyToClipboard(); +}; + +#endif // INSTANTMESSAGINGWIDGET_H diff --git a/instantmessagingwidget.ui b/instantmessagingwidget.ui new file mode 100644 index 0000000000000000000000000000000000000000..c37fc05efce1a161569acddcf83d4dae4cfaa13e --- /dev/null +++ b/instantmessagingwidget.ui @@ -0,0 +1,44 @@ +<?xml version="1.0" encoding="UTF-8"?> +<ui version="4.0"> + <class>InstantMessagingWidget</class> + <widget class="QWidget" name="InstantMessagingWidget"> + <property name="geometry"> + <rect> + <x>0</x> + <y>0</y> + <width>400</width> + <height>300</height> + </rect> + </property> + <property name="sizePolicy"> + <sizepolicy hsizetype="Expanding" vsizetype="Fixed"> + <horstretch>0</horstretch> + <verstretch>0</verstretch> + </sizepolicy> + </property> + <property name="windowTitle"> + <string>Form</string> + </property> + <layout class="QVBoxLayout" name="verticalLayout"> + <item> + <widget class="QListView" name="messageOutput"> + <property name="wordWrap"> + <bool>true</bool> + </property> + </widget> + </item> + <item> + <widget class="QLineEdit" name="messageInput"> + <property name="placeholderText"> + <string>Send text message...</string> + </property> + <property name="clearButtonEnabled"> + <bool>true</bool> + </property> + </widget> + </item> + </layout> + </widget> + <resources/> + <connections/> +</ui>