Commit 35828719 authored by Ronan Abhamon's avatar Ronan Abhamon

feat(ui/modules/Linphone/Chat/Message): supports copy of messages

parent 545f39cf
......@@ -105,6 +105,7 @@ set(SOURCES
src/components/camera/MSFunctions.cpp
src/components/chat/ChatModel.cpp
src/components/chat/ChatProxyModel.cpp
src/components/clipboard/Clipboard.cpp
src/components/codecs/AbstractCodecsModel.cpp
src/components/codecs/AudioCodecsModel.cpp
src/components/codecs/VideoCodecsModel.cpp
......@@ -149,6 +150,7 @@ set(HEADERS
src/components/camera/MSFunctions.hpp
src/components/chat/ChatModel.hpp
src/components/chat/ChatProxyModel.hpp
src/components/clipboard/Clipboard.cpp
src/components/codecs/AbstractCodecsModel.hpp
src/components/codecs/AudioCodecsModel.hpp
src/components/codecs/VideoCodecsModel.hpp
......
......@@ -822,6 +822,20 @@ your friend&apos;s SIP address or username.</translation>
<translation>Select you active account</translation>
</message>
</context>
<context>
<name>Message</name>
<message>
<source>menuCopy</source>
<translation>Copy</translation>
</message>
</context>
<context>
<name>MessageMenu</name>
<message>
<source>copy</source>
<translation type="unfinished"></translation>
</message>
</context>
<context>
<name>OutgoingMessage</name>
<message>
......
......@@ -821,6 +821,20 @@ un chat ou ajouter un contact.</translation>
<translation>Sélectionner votre compte principal</translation>
</message>
</context>
<context>
<name>Message</name>
<message>
<source>menuCopy</source>
<translation>Copier</translation>
</message>
</context>
<context>
<name>MessageMenu</name>
<message>
<source>copy</source>
<translation type="unfinished"></translation>
</message>
</context>
<context>
<name>OutgoingMessage</name>
<message>
......
......@@ -243,6 +243,8 @@
<file>ui/modules/Common/Menus/DropDownDynamicMenu.qml</file>
<file>ui/modules/Common/Menus/DropDownStaticMenuEntry.qml</file>
<file>ui/modules/Common/Menus/DropDownStaticMenu.qml</file>
<file>ui/modules/Common/Menus/MenuItem.qml</file>
<file>ui/modules/Common/Menus/Menu.qml</file>
<file>ui/modules/Common/Misc/Borders.qml</file>
<file>ui/modules/Common/Misc/Collapse.qml</file>
<file>ui/modules/Common/Misc/ForceScrollBar.qml</file>
......@@ -281,6 +283,8 @@
<file>ui/modules/Common/Styles/Indicators/VuMeterStyle.qml</file>
<file>ui/modules/Common/Styles/Menus/ApplicationMenuStyle.qml</file>
<file>ui/modules/Common/Styles/Menus/DropDownStaticMenuStyle.qml</file>
<file>ui/modules/Common/Styles/Menus/MenuItemStyle.qml</file>
<file>ui/modules/Common/Styles/Menus/MenuStyle.qml</file>
<file>ui/modules/Common/Styles/Misc/CollapseStyle.qml</file>
<file>ui/modules/Common/Styles/Misc/ForceScrollBarStyle.qml</file>
<file>ui/modules/Common/Styles/Misc/PanedStyle.qml</file>
......@@ -310,6 +314,7 @@
<file>ui/modules/Linphone/Chat/FileMessage.qml</file>
<file>ui/modules/Linphone/Chat/IncomingMessage.qml</file>
<file>ui/modules/Linphone/Chat/Message.js</file>
<file>ui/modules/Linphone/Chat/MessageMenu.qml</file>
<file>ui/modules/Linphone/Chat/Message.qml</file>
<file>ui/modules/Linphone/Chat/OutgoingMessage.qml</file>
<file>ui/modules/Linphone/Codecs/CodecAttribute.qml</file>
......
......@@ -23,7 +23,6 @@
#ifndef UTILS_H_
#define UTILS_H_
#include <QObject>
#include <QString>
// =============================================================================
......
......@@ -151,8 +151,9 @@ void App::initContentApp () {
);
}
// Init core.
// Init core and clipboard.
CoreManager::init(this, mParser.value("config"));
Clipboard::init(this);
// Init engine content.
mEngine = new QQmlApplicationEngine();
......@@ -373,6 +374,7 @@ void App::registerSharedTypes () {
qInfo() << QStringLiteral("Registering shared types...");
registerSharedSingletonType(App, "App", App::getInstance);
registerSharedSingletonType(Clipboard, "Clipboard", Clipboard::getInstance);
registerSharedSingletonType(CoreManager, "CoreManager", CoreManager::getInstance);
registerSharedSingletonType(SettingsModel, "SettingsModel", CoreManager::getInstance()->getSettingsModel);
registerSharedSingletonType(AccountSettingsModel, "AccountSettingsModel", CoreManager::getInstance()->getAccountSettingsModel);
......
/*
* Clipboard.cpp
* Copyright (C) 2017 Belledonne Communications, Grenoble, France
*
* 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 2
* 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, write to the Free Software
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
*
* Created on: May 30, 2017
* Author: Ronan Abhamon
*/
#include "Clipboard.hpp"
// =============================================================================
/*
* Clipboard.hpp
* Copyright (C) 2017 Belledonne Communications, Grenoble, France
*
* 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 2
* 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, write to the Free Software
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
*
* Created on: May 30, 2017
* Author: Ronan Abhamon
*/
#ifndef CLIPBOARD_H_
#define CLIPBOARD_H_
#include <QObject>
// =============================================================================
class Clipboard : public QObject {
Q_OBJECT;
Q_PRO
};
#endif // ifndef CLIPBOARD_H_
......@@ -80,7 +80,7 @@ inline void ensureFilePathExists (const QString &path) {
}
inline string getReadableDirPath (const QString &dirname) {
return Utils::appStringToCoreString(QDir::toNativeSeparators(dirname));
return ::Utils::appStringToCoreString(QDir::toNativeSeparators(dirname));
}
inline string getWritableDirPath (const QString &dirname) {
......@@ -89,7 +89,7 @@ inline string getWritableDirPath (const QString &dirname) {
}
inline string getReadableFilePath (const QString &filename) {
return Utils::appStringToCoreString(QDir::toNativeSeparators(filename));
return ::Utils::appStringToCoreString(QDir::toNativeSeparators(filename));
}
inline string getWritableFilePath (const QString &filename) {
......
......@@ -33,7 +33,7 @@ AvatarProvider::AvatarProvider () : QQuickImageProvider(
QQmlImageProviderBase::Image,
QQmlImageProviderBase::ForceAsynchronousImageLoading
) {
mAvatarsPath = Utils::coreStringToAppString(Paths::getAvatarsDirPath());
mAvatarsPath = ::Utils::coreStringToAppString(Paths::getAvatarsDirPath());
}
QImage AvatarProvider::requestImage (const QString &id, QSize *, const QSize &) {
......
......@@ -33,7 +33,7 @@ ThumbnailProvider::ThumbnailProvider () : QQuickImageProvider(
QQmlImageProviderBase::Image,
QQmlImageProviderBase::ForceAsynchronousImageLoading
) {
mThumbnailsPath = Utils::coreStringToAppString(Paths::getThumbnailsDirPath());
mThumbnailsPath = ::Utils::coreStringToAppString(Paths::getThumbnailsDirPath());
}
QImage ThumbnailProvider::requestImage (const QString &id, QSize *, const QSize &) {
......
......@@ -30,6 +30,7 @@
#include "camera/Camera.hpp"
#include "camera/CameraPreview.hpp"
#include "chat/ChatProxyModel.hpp"
#include "clipboard/Clipboard.hpp"
#include "codecs/AudioCodecsModel.hpp"
#include "codecs/VideoCodecsModel.hpp"
#include "conference/ConferenceAddModel.hpp"
......
......@@ -606,7 +606,7 @@ void CallModel::updateStats (const shared_ptr<const linphone::CallStats> &callSt
statsList << createStat(tr("callStatsJitterBuffer"), QString("%1 ms").arg(callStats->getJitterBufferSizeMs()));
break;
case linphone::StreamTypeVideo: {
QString sentVideoDefinitionName = Utils::coreStringToAppString(params->getSentVideoDefinition()->getName());
QString sentVideoDefinitionName = ::Utils::coreStringToAppString(params->getSentVideoDefinition()->getName());
QString sentVideoDefinition = QString("%1x%2")
.arg(params->getSentVideoDefinition()->getWidth())
.arg(params->getSentVideoDefinition()->getHeight());
......@@ -615,7 +615,7 @@ void CallModel::updateStats (const shared_ptr<const linphone::CallStats> &callSt
? sentVideoDefinition
: QString("%1 (%2)").arg(sentVideoDefinition).arg(sentVideoDefinitionName));
QString receivedVideoDefinitionName = Utils::coreStringToAppString(params->getReceivedVideoDefinition()->getName());
QString receivedVideoDefinitionName = ::Utils::coreStringToAppString(params->getReceivedVideoDefinition()->getName());
QString receivedVideoDefinition = QString("%1x%2")
.arg(params->getReceivedVideoDefinition()->getWidth())
.arg(params->getReceivedVideoDefinition()->getHeight());
......
/*
* Clipboard.cpp
* Copyright (C) 2017 Belledonne Communications, Grenoble, France
*
* 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 2
* 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, write to the Free Software
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
*
* Created on: May 30, 2017
* Author: Ronan Abhamon
*/
#include <QClipboard>
#include <QGuiApplication>
#include "Clipboard.hpp"
// =============================================================================
Clipboard *Clipboard::mInstance = nullptr;
Clipboard::Clipboard (QObject *parent) : QObject(parent) {
connect(QGuiApplication::clipboard(), &QClipboard::dataChanged, this, &Clipboard::textChanged);
}
// -----------------------------------------------------------------------------
void Clipboard::init (QObject *parent) {
if (!mInstance)
mInstance = new Clipboard(parent);
}
QString Clipboard::getText () const {
return QGuiApplication::clipboard()->text(QClipboard::Clipboard);
}
void Clipboard::setText (const QString &text) {
QGuiApplication::clipboard()->setText(text, QClipboard::Clipboard);
}
/*
* Clipboard.hpp
* Copyright (C) 2017 Belledonne Communications, Grenoble, France
*
* 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 2
* 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, write to the Free Software
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
*
* Created on: May 30, 2017
* Author: Ronan Abhamon
*/
#ifndef CLIPBOARD_H_
#define CLIPBOARD_H_
#include <QObject>
// =============================================================================
class Clipboard : public QObject {
Q_OBJECT;
Q_PROPERTY(QString text READ getText WRITE setText NOTIFY textChanged);
public:
~Clipboard () = default;
static void init (QObject *parent);
static Clipboard *getInstance () {
Q_ASSERT(mInstance != nullptr);
return mInstance;
}
signals:
void textChanged ();
private:
Clipboard (QObject *parent);
QString getText () const;
void setText (const QString &text);
static Clipboard *mInstance;
};
#endif // ifndef CLIPBOARD_H_
import QtQuick 2.7
import QtQuick.Controls 2.1 as Controls
import Common 1.0
import Common.Styles 1.0
// =============================================================================
Controls.Menu {
id: menu
background: Rectangle {
implicitWidth: MenuStyle.width
color: MenuStyle.color
layer {
enabled: true
effect: PopupShadow {}
}
}
}
import QtQuick 2.7
import QtQuick.Controls 2.1
import Common.Styles 1.0
// =============================================================================
MenuItem {
id: button
background: Rectangle {
color: button.down
? MenuItemStyle.background.color.pressed
: (
button.hovered
? MenuItemStyle.background.color.hovered
: MenuItemStyle.background.color.normal
)
implicitHeight: MenuItemStyle.background.height
}
contentItem: Text {
color: MenuItemStyle.text.color
elide: Text.ElideRight
font.bold: true
font.pointSize: MenuItemStyle.text.fontSize
text: button.text
leftPadding: MenuItemStyle.leftPadding
rightPadding: MenuItemStyle.rightPadding
verticalAlignment: Text.AlignVCenter
}
hoverEnabled: true
}
pragma Singleton
import QtQuick 2.7
import Common 1.0
// =============================================================================
QtObject {
property int leftPadding: 5
property int rightPadding: 5
property QtObject background: QtObject {
property int height: 30
property QtObject color: QtObject {
property color hovered: Colors.y
property color normal: Colors.k
property color pressed: Colors.y
}
}
property QtObject text: QtObject {
property color color: Colors.j
property int fontSize: 10
}
}
pragma Singleton
import QtQuick 2.7
import Common 1.0
// =============================================================================
QtObject {
property color color: Colors.k
property int width: 130
}
......@@ -42,6 +42,8 @@ singleton VuMeterStyle 1.0 Indicators/VuMeterStyle.qml
singleton ApplicationMenuStyle 1.0 Menus/ApplicationMenuStyle.qml
singleton DropDownStaticMenuStyle 1.0 Menus/DropDownStaticMenuStyle.qml
singleton MenuItemStyle 1.0 Menus/MenuItemStyle.qml
singleton MenuStyle 1.0 Menus/MenuStyle.qml
singleton CollapseStyle 1.0 Misc/CollapseStyle.qml
singleton ForceScrollBarStyle 1.0 Misc/ForceScrollBarStyle.qml
......
......@@ -65,6 +65,8 @@ ApplicationMenu 1.0 Menus/ApplicationMenu.qml
DropDownDynamicMenu 1.0 Menus/DropDownDynamicMenu.qml
DropDownStaticMenu 1.0 Menus/DropDownStaticMenu.qml
DropDownStaticMenuEntry 1.0 Menus/DropDownStaticMenuEntry.qml
Menu 1.0 Menus/Menu.qml
MenuItem 1.0 Menus/MenuItem.qml
Borders 1.0 Misc/Borders.qml
Collapse 1.0 Misc/Collapse.qml
......
import QtQuick 2.7
import Common 1.0
import Linphone 1.0
import Linphone.Styles 1.0
import Utils 1.0
......@@ -66,15 +67,24 @@ Item {
onActiveFocusChanged: deselect()
Menu {
id: messageMenu
MenuItem {
text: qsTr('menuCopy')
onTriggered: Clipboard.text = $chatEntry.content
}
}
// Handle hovered link.
MouseArea {
id: mouseArea
anchors.fill: parent
acceptedButtons: Qt.NoButton
acceptedButtons: Qt.RightButton
cursorShape: parent.hoveredLink
? Qt.PointingHandCursor
: Qt.IBeamCursor
onClicked: mouse.button === Qt.RightButton && messageMenu.open()
}
}
......
import QtQuick 2.7
import QtQuick.Controls 2.1
// =============================================================================
Menu {
MenuItem {
text: qsTr('copy')
}
}
......@@ -9,13 +9,13 @@ import App.Styles 1.0
// =============================================================================
DialogPlus {
id: callTransfer
id: callTransfer
// ---------------------------------------------------------------------------
// ---------------------------------------------------------------------------
property var call
property var call
// ---------------------------------------------------------------------------
// ---------------------------------------------------------------------------
buttons: [
TextButtonA {
......@@ -31,7 +31,7 @@ DialogPlus {
height: CallTransferStyle.height
width: CallTransferStyle.width
onCallChanged: !call && exit(0)
onCallChanged: !call && exit(0)
// ---------------------------------------------------------------------------
......@@ -87,7 +87,7 @@ DialogPlus {
icon: 'transfer',
handler: function (entry) {
callTransfer.call.transferTo(entry.sipAddress)
exit(1)
exit(1)
}
}]
......
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