Commit 43c0823d authored by Andreas Traczyk's avatar Andreas Traczyk Committed by Isa

message/call views: ui overhaul

This patch:
- implements QWebEngineView as the view for interactions
- reorganizes the main widget's layout in order to share views
  between in-call and out-of-call messaging views
- fixes behavioral bugs and crashes
- cannot be built with the mingw compiler due to lack of support for
  QWebEngine, and must be built natively with msvc and includes some
  build script modifications
- should be thought of as a new client

Change-Id: I59d8c68dc8384e85fb006f30d8313482c00d6c85
parent 5971937b
......@@ -53,11 +53,9 @@ SOURCES += main.cpp\
windowscontactbackend.cpp \
selectareadialog.cpp \
accountserializationadapter.cpp \
instantmessagingwidget.cpp \
accountstatedelegate.cpp \
videoview.cpp \
videooverlay.cpp \
imdelegate.cpp \
contactpicker.cpp \
globalsystemtray.cpp \
conversationitemdelegate.cpp \
......@@ -79,11 +77,14 @@ SOURCES += main.cpp\
smartlistview.cpp \
accountitemdelegate.cpp \
accountlistmodel.cpp \
messagemodel.cpp \
invitebuttonswidget.cpp \
wizardwidget.cpp \
currentaccountcombobox.cpp \
conversationfilterbutton.cpp
conversationfilterbutton.cpp \
messagewebpage.cpp \
messagewebview.cpp \
webchathelpers.cpp \
animationhelpers.cpp
HEADERS += mainwindow.h \
callwidget.h \
......@@ -97,11 +98,9 @@ HEADERS += mainwindow.h \
windowscontactbackend.h \
selectareadialog.h \
accountserializationadapter.h \
instantmessagingwidget.h \
accountstatedelegate.h \
videoview.h \
videooverlay.h \
imdelegate.h \
contactpicker.h \
settingskey.h \
globalsystemtray.h \
......@@ -126,11 +125,14 @@ HEADERS += mainwindow.h \
smartlistview.h \
accountitemdelegate.h \
accountlistmodel.h \
messagemodel.h \
invitebuttonswidget.h \
wizardwidget.h \
currentaccountcombobox.h \
conversationfilterbutton.h
conversationfilterbutton.h \
messagewebpage.h \
messagewebview.h \
webchathelpers.h \
animationhelpers.h
contains(DEFINES, URI_PROTOCOL) {
......@@ -144,7 +146,6 @@ FORMS += mainwindow.ui \
accountdetails.ui \
aboutdialog.ui \
wizarddialog.ui \
instantmessagingwidget.ui \
videoview.ui \
videooverlay.ui \
contactpicker.ui \
......@@ -158,7 +159,8 @@ FORMS += mainwindow.ui \
bannedcontactswidget.ui \
photoboothwidget.ui \
invitebuttonswidget.ui \
wizardwidget.ui
wizardwidget.ui \
animatedoverlay.ui
win32: LIBS += -lole32 -luuid -lshlwapi -lgdi32
LIBS += -lqrencode
......@@ -273,7 +275,9 @@ win32 {
QTRUNTIME.files = $$RUNTIMEDIR/Qt5Core.dll $$RUNTIMEDIR/Qt5Widgets.dll \
$$RUNTIMEDIR/Qt5Gui.dll $$RUNTIMEDIR/Qt5Svg.dll \
$$RUNTIMEDIR/Qt5Xml.dll $$RUNTIMEDIR/Qt5WinExtras.dll \
$$RUNTIMEDIR/Qt5Network.dll $$RUNTIMEDIR/Qt5Sql.dll
$$RUNTIMEDIR/Qt5Network.dll $$RUNTIMEDIR/Qt5Sql.dll \
$$RUNTIMEDIR/Qt5WebEngineWidgets.dll $$RUNTIMEDIR/Qt5WebChannel.dll
QTRUNTIME.path = $$OUT_PWD/release
QTDEPSRUNTIME.files = $$RUNTIMEDIR/zlib1.dll \
......
......@@ -19,6 +19,8 @@
#include "aboutdialog.h"
#include "ui_aboutdialog.h"
#include "version.h"
AboutDialog::AboutDialog(QWidget *parent) :
QDialog(parent),
ui(new Ui::AboutDialog)
......@@ -27,7 +29,7 @@ AboutDialog::AboutDialog(QWidget *parent) :
this->setFixedSize(this->width(),this->height());
ui->creditsWidget->hide();
ui->gitVersionLabel->setText(QString("%1: %2").arg(tr("version"), NIGHTLY_VERSION));
ui->gitVersionLabel->setText(QString("%1: %2").arg(tr("version"), QString(VERSION_STRING)));
ui->creditsBrowser->setHtml("<!DOCTYPE HTML PUBLIC \"-//W3C//DTD HTML 4.0//EN\" \"http://www.w3.org/TR/REC-html40/strict.dtd\">"
"<html><head><meta name=\"qrichtext\" content=\"1\" /><style type=\"text/css\">"
......
<?xml version="1.0" encoding="UTF-8"?>
<ui version="4.0">
<class>AnimatedOverlay</class>
<widget class="QWidget" name="AnimatedOverlay">
<property name="geometry">
<rect>
<x>0</x>
<y>0</y>
<width>400</width>
<height>300</height>
</rect>
</property>
<property name="windowTitle">
<string>Form</string>
</property>
<layout class="QGridLayout" name="gridLayout">
<property name="leftMargin">
<number>0</number>
</property>
<property name="topMargin">
<number>0</number>
</property>
<property name="rightMargin">
<number>0</number>
</property>
<property name="bottomMargin">
<number>0</number>
</property>
<property name="spacing">
<number>0</number>
</property>
<item row="0" column="0">
<widget class="QLabel" name="backgroundLabel">
<property name="styleSheet">
<string notr="true"/>
</property>
<property name="text">
<string/>
</property>
</widget>
</item>
</layout>
</widget>
<resources/>
<connections/>
</ui>
/***************************************************************************
* Copyright (C) 2018 by Savoir-faire Linux *
* Author: Andreas Traczyk <andreas.traczyk@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 "animationhelpers.h"
#include "ui_animatedoverlay.h"
#include <QTimer>
#include <QtMath>
OpacityAnimation::OpacityAnimation(QWidget* target, QObject* parent)
: QObject(parent),
target_(target),
timer_(nullptr),
frameTime_((1.0 / 24.0) * 1000),
startValue_(0.0),
endValue_(1.0),
t_(0),
value_(0),
duration_(1000)
{
timer_ = new QTimer(this);
connect(timer_, SIGNAL(timeout()), this, SLOT(updateAnimation()));
effect_ = new QGraphicsOpacityEffect(this);
effect_->setOpacity(startValue_);
target_->setGraphicsEffect(effect_);
target_->setAutoFillBackground(true);
}
OpacityAnimation::~OpacityAnimation()
{
}
void
OpacityAnimation::setFPS(const int& fps)
{
frameTime_ = (1.0 / static_cast<double>(fps)) * 1000;
}
void
OpacityAnimation::setFrameTime(const int& milliseconds)
{
frameTime_ = milliseconds;
}
void
OpacityAnimation::setDuration(const int& milliseconds)
{
duration_ = milliseconds;
}
void
OpacityAnimation::setStartValue(const double& value)
{
startValue_ = value;
effect_->setOpacity(startValue_);
}
void
OpacityAnimation::setEndValue(const double& value)
{
endValue_ = value;
}
void
OpacityAnimation::start()
{
timer_->start(frameTime_);
}
void
OpacityAnimation::stop()
{
timer_->stop();
}
void
OpacityAnimation::updateAnimation()
{
double d = (startValue_ + endValue_) * 0.5;
double a = abs(startValue_ - endValue_) * 0.5;
t_ += frameTime_;
value_ = a * sin(2 * M_PI * t_ * duration_ * .000001) + d;
effect_->setOpacity(value_);
target_->update();
}
AnimatedOverlay::AnimatedOverlay(QColor color, QWidget* parent) :
QWidget(parent),
ui(new Ui::AnimatedOverlay)
{
ui->setupUi(this);
ui->backgroundLabel->setAutoFillBackground(true);
auto values = QString("%1,%2,%3,255")
.arg(color.red())
.arg(color.green())
.arg(color.blue());
ui->backgroundLabel->setStyleSheet("background-color: rgba(" + values + ");");
oa_ = new OpacityAnimation(this, this);
oa_->setFPS(16);
oa_->setDuration(1000);
oa_->setStartValue(0.0);
oa_->setEndValue(0.25);
oa_->start();
}
AnimatedOverlay::~AnimatedOverlay()
{
disconnect(this);
delete ui;
}
/***************************************************************************
* Copyright (C) 2015-2017 by Savoir-faire Linux *
* Author: Edric Ladent Milaret <edric.ladent-milaret@savoirfairelinux.com>*
* Copyright (C) 2018 by Savoir-faire Linux *
* Author: Andreas Traczyk <andreas.traczyk@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 *
......@@ -19,49 +19,56 @@
#pragma once
#include <QWidget>
#include <QKeyEvent>
#include <QSettings>
#include <QPropertyAnimation>
#include <QGraphicsOpacityEffect>
#include <QMovie>
#include "call.h"
#include "media/media.h"
#include "imdelegate.h"
#include "messagemodel.h"
namespace Ui {
class InstantMessagingWidget;
}
class InstantMessagingWidget final : public QWidget
class OpacityAnimation : public QObject
{
Q_OBJECT
public:
explicit InstantMessagingWidget(QWidget *parent = 0);
~InstantMessagingWidget();
void setupCallMessaging(const std::string& callId,
MessageModel *messageModel);
explicit OpacityAnimation(QWidget* target, QObject* parent = nullptr);
~OpacityAnimation();
protected:
virtual void keyPressEvent(QKeyEvent *event) override;
virtual void showEvent(QShowEvent * event) override;
void setFPS(const int& fps);
void setFrameTime(const int& milliseconds);
void setDuration(const int& milliseconds);
void setStartValue(const double& value);
void setEndValue(const double& value);
//UI SLOTS
private slots:
void on_sendButton_clicked();
void start();
void stop();
private slots:
void onIncomingMessage(const std::string& convUid, uint64_t interactionId, const lrc::api::interaction::Info& interaction);
void updateAnimation();
private:
Ui::InstantMessagingWidget *ui;
ImDelegate* imDelegate_;
std::unique_ptr<MessageModel> messageModel_;
QSettings settings_;
QMetaObject::Connection newInteractionConnection_;
QGraphicsOpacityEffect* effect_;
double value_;
void copyToClipboard();
void updateConversationView(const std::string& convUid);
QWidget* target_;
QTimer* timer_;
int frameTime_;
double t_;
int duration_;
double startValue_;
double endValue_;
};
namespace Ui {
class AnimatedOverlay;
}
class AnimatedOverlay : public QWidget
{
Q_OBJECT
public:
explicit AnimatedOverlay(QColor color, QWidget* parent = 0);
~AnimatedOverlay();
private:
Ui::AnimatedOverlay* ui;
OpacityAnimation* oa_;
};
\ No newline at end of file
:: Ring - native Windows client project build script
@echo off
setlocal EnableDelayedExpansion
setlocal
if "%1" == "/?" goto Usage
if "%~1" == "" goto Usage
set doCompile=N
set doBuild=N
set SRC=%~dp0
set SCRIPTNAME=%~nx0
if "%1"=="compile" (
set doCompile=Y
) else if "%1"=="build" (
set doBuild=Y
) else (
goto Usage
)
set arch=N
shift
:ParseArgs
if "%1" == "" goto FinishedArgs
if /I "%1"=="x86" (
set arch=x86
) else if /I "%1"=="x64" (
set arch=x64
) else (
goto Usage
)
shift
goto ParseArgs
set MSBUILD_ARGS=/nologo /p:useenv=true /p:Configuration=Release-Lib /p:Platform=x64 /verbosity:normal /maxcpucount:%NUMBER_OF_PROCESSORS%
:FinishedArgs
if "%arch%"=="x86" (
set MSBUILD_ARGS=/nologo /p:useenv=true /p:Platform=Win32 /maxcpucount:%NUMBER_OF_PROCESSORS%
) else if "%arch%"=="x64" (
set MSBUILD_ARGS=/nologo /p:useenv=true /p:Platform=x64 /maxcpucount:%NUMBER_OF_PROCESSORS%
)
@setlocal
......@@ -33,13 +69,49 @@ if %PROCESSOR_ARCHITECTURE%==x86 (
)
set path=%path:"=%
call "%VSLATESTDIR%"\\VC\\Auxiliary\\Build\\vcvarsall.bat %Comp_x64%
if "%arch%"=="x86" (
call "%VSLATESTDIR%"\\VC\\Auxiliary\\Build\\vcvarsall.bat %Comp_x86%
) else if "%arch%"=="x64" (
call "%VSLATESTDIR%"\\VC\\Auxiliary\\Build\\vcvarsall.bat %Comp_x64%
)
if "%arch%" neq "N" (
if "%doCompile%" neq "N" (
goto compileClient
) else if "%doBuild%" neq "N" (
goto buildClient
)
goto :eof
)
goto Usage
git clone --depth=1 https://github.com/BlueDragon747/qrencode-win32.git
:compileClient
msbuild ring-client-windows.vcxproj /verbosity:normal /p:Configuration=ReleaseCompile %MSBUILD_ARGS%
goto cleanup
msbuild qrencode-win32/qrencode-win32/vc8/qrcodelib/qrcodelib.vcxproj %MSBUILD_ARGS%
:buildClient
msbuild ring-client-windows.vcxproj /verbosity:normal /p:Configuration=Release %MSBUILD_ARGS%
goto cleanup
@endlocal
:Usage
echo:
echo The correct usage is:
echo:
echo %0 [action] [architecture]
echo:
echo where
echo:
echo [action] is: compile ^| build
echo [architecture] is: x86 ^| x64
echo:
echo For example:
echo %0 compile x86 - compile only x86 (for CI)
echo %0 build x64 - build x64 client
echo:
goto :eof
:cleanup
endlocal
@endlocal
exit /B %ERRORLEVEL%
\ No newline at end of file
This diff is collapsed.
......@@ -30,7 +30,6 @@
#include <QMovie>
#include "navwidget.h"
#include "instantmessagingwidget.h"
#include "smartlistmodel.h"
// old LRC
......@@ -51,7 +50,6 @@
#include "api/newcallmodel.h"
class ConversationItemDelegate;
class ImDelegate;
class QPropertyAnimation;
namespace Ui {
......@@ -87,8 +85,6 @@ private slots:
void on_refuseButton_clicked();
void on_cancelButton_clicked();
void on_smartList_doubleClicked(const QModelIndex& index);
void on_sendIMButton_clicked();
void on_imMessageEdit_returnPressed();
void on_ringContactLineEdit_textChanged(const QString& text);
void on_imBackButton_clicked();
void on_sendContactRequestButton_clicked();
......@@ -101,15 +97,12 @@ private slots:
private slots:
void smartListSelectionChanged(const QItemSelection &selected, const QItemSelection &deselected);
void contactReqListCurrentChanged(const QModelIndex &currentIdx, const QModelIndex &previousIdx);
void slotAccountMessageReceived(const QMap<QString,QString> message,ContactMethod* cm, media::Media::Direction dir);
void onIncomingMessage(const std::string & convUid, uint64_t interactionId, const lrc::api::interaction::Info & interaction);
private:
void placeCall();
void conversationsButtonClicked();
void invitationsButtonClicked();
void setupOutOfCallIM();
void setupSmartListContextMenu(const QPoint &pos);
void setupQRCode(QString ringID);
void backToWelcomePage();
......@@ -136,14 +129,6 @@ private:
const std::string& selectedConvUid();
QMenu* menu_;
ConversationItemDelegate* conversationItemDelegate_;
ImDelegate* imDelegate_;
QMetaObject::Connection imConnection_;
QMetaObject::Connection imVisibleConnection_;
QMetaObject::Connection callChangedConnection_;
QMetaObject::Connection imClickedConnection_;
QMetaObject::Connection crListSelectionConnection_;
Ui::CallWidget* ui;
QMovie* miniSpinner_;
......@@ -154,9 +139,13 @@ private:
Video::Renderer* videoRenderer_;
std::string lastConvUid_ {};
lrc::api::profile::Type currentTypeFilter_{};
std::unique_ptr<SmartListModel> smartListModel_;
std::unique_ptr<MessageModel> messageModel_;
QMetaObject::Connection imConnection_;
QMetaObject::Connection imVisibleConnection_;
QMetaObject::Connection callChangedConnection_;
QMetaObject::Connection imClickedConnection_;
QMetaObject::Connection crListSelectionConnection_;
QMetaObject::Connection modelSortedConnection_;
QMetaObject::Connection modelUpdatedConnection_;
QMetaObject::Connection filterChangedConnection_;
......@@ -167,4 +156,5 @@ private:
QMetaObject::Connection conversationClearedConnection;
QMetaObject::Connection selectedCallChanged_;
QMetaObject::Connection smartlistSelectionConnection_;
QMetaObject::Connection interactionRemovedConnection_;
};
This source diff could not be displayed because it is too large. You can view the blob instead.
......@@ -27,11 +27,12 @@
#include "smartlistmodel.h"
#include "ringthemeutils.h"
#include "utils.h"
#include "lrcinstance.h"
#include <ciso646>
ConversationItemDelegate::ConversationItemDelegate(QObject* parent) :
QItemDelegate(parent)
ConversationItemDelegate::ConversationItemDelegate(QObject* parent)
: QItemDelegate(parent)
{
}
......@@ -42,7 +43,7 @@ ConversationItemDelegate::paint(QPainter* painter
) const
{
QStyleOptionViewItem opt(option);
painter->setRenderHint(QPainter::Antialiasing);
painter->setRenderHint(QPainter::Antialiasing, true);
// Not having focus removes dotted lines around the item
if (opt.state & QStyle::State_HasFocus)
......@@ -139,8 +140,10 @@ ConversationItemDelegate::paint(QPainter* painter
QSize
ConversationItemDelegate::sizeHint(const QStyleOptionViewItem& option,
const QModelIndex& index) const
const QModelIndex& index) const
{
Q_UNUSED(option);
Q_UNUSED(index);
return QSize(0, cellHeight_);
}
......@@ -150,6 +153,7 @@ ConversationItemDelegate::paintRingConversationItem(QPainter* painter,
const QRect& rect,
const QModelIndex& index) const
{
Q_UNUSED(option);
QFont font(painter->font());
font.setPointSize(fontSize_);
QPen pen(painter->pen());
......@@ -221,18 +225,37 @@ ConversationItemDelegate::paintRingConversationItem(QPainter* painter,
// bottom-right: last interaction snippet
QString interactionStr = index.data(static_cast<int>(SmartListModel::Role::LastInteraction)).value<QString>();
if (!interactionStr.isNull()) {
// remove phone glyphs
interactionStr.replace(QChar(0xd83d), "");
interactionStr.replace(QChar(0xdd7d), "");
interactionStr.replace(QChar(0xdcde), "");
font.setItalic(false);
font.setBold(false);
pen.setColor(RingTheme::grey_);
painter->setPen(pen);
painter->setFont(font);
painter->save();
interactionStr = interactionStr.simplified();
auto type = Utils::toEnum<lrc::api::interaction::Type>(index
.data(static_cast<int>(SmartListModel::Role::LastInteractionType))
.value<int>());
if (type == lrc::api::interaction::Type::CALL ||
type == lrc::api::interaction::Type::CONTACT) {
font.setItalic(false);
font.setBold(false);
pen.setColor(RingTheme::grey_.darker(140));
painter->setPen(pen);
painter->setFont(font);
// strip emojis if it's a call/contact type message
VectorUInt emojiless;
for (auto unicode : interactionStr.toUcs4()) {
if (!(unicode >= 0x1F000 && unicode <= 0x1FFFF)) {
emojiless.push_back(unicode);
}
}
interactionStr = QString::fromUcs4(&emojiless.at(0), emojiless.size());
} else {
QFont emojiMsgFont(QStringLiteral("Segoe UI Emoji"));
emojiMsgFont.setItalic(false);
emojiMsgFont.setBold(false);
emojiMsgFont.setPointSize(fontSize_);
painter->setOpacity(0.7);
painter->setFont(emojiMsgFont);
}
interactionStr = fontMetrics.elidedText(interactionStr, Qt::ElideRight, rectInfo2.width());
painter->drawText(rectInfo2, Qt::AlignVCenter | Qt::AlignRight, interactionStr);
painter->restore();
}
}
......@@ -268,7 +291,7 @@ ConversationItemDelegate::paintRingInviteConversationItem(QPainter* painter,
QFontMetrics fontMetrics(font);
// The name is displayed at the avatar's right
QString nameStr = index.data(static_cast<int>(SmartListModel::Role::DisplayName)).value<QString>();;
QString nameStr = index.data(static_cast<int>(SmartListModel::Role::DisplayName)).value<QString>();
if (!nameStr.isNull()) {
font.setItalic(false);
font.setBold(true);
......@@ -293,6 +316,11 @@ ConversationItemDelegate::paintRingInviteConversationItem(QPainter* painter,
}
void
ConversationItemDelegate::paintSIPConversationItem(QPainter * painter, const QStyleOptionViewItem & option, const QModelIndex & index) const
ConversationItemDelegate::paintSIPConversationItem(QPainter* painter,
const QStyleOptionViewItem& option,
const QModelIndex& index) const
{
Q_UNUSED(painter);
Q_UNUSED(option);
Q_UNUSED(index);
}
......@@ -18,9 +18,32 @@
#include "conversationsfilterwidget.h"
#include <QPainter>
#include <QDebug>
#include "ringthemeutils.h"
#include "lrcinstance.h"
#include <QPainter>
ConversationsFilterWidget::ConversationsFilterWidget(QWidget *parent)
: QWidget(parent)
{
}
void ConversationsFilterWidget::resizeEvent(QResizeEvent * event)
{
using namespace lrc::api::profile;
updateNotifier(Type::RING);
updateNotifier(Type::PENDING);
}
void
ConversationsFilterWidget::updateNotifier(lrc::api::profile::Type typeFilter)
{
using namespace lrc::api::profile;
handleNotifierOverlay((typeFilter == Type::RING) ? "btnConversations" : "btnInvites",
(typeFilter == Type::RING) ? unreadMessagesNotifier_ : pendingInvitesNotifier_,
typeFilter);
}
static inline const QRect
getNotifierRect(const QRect& buttonRect)
......@@ -32,8 +55,8 @@ getNotifierRect(const QRect& buttonRect)
void
ConversationsFilterWidget::handleNotifierOverlay(const QString& buttonName,
SmartlistSelectorButtonNotifier*& notifier,
lrc::api::profile::Type filter)
SmartlistSelectorButtonNotifier*& notifier,
lrc::api::profile::Type filter)
{
auto button = this->findChild<QPushButton*>(buttonName);
if (!button) {
......@@ -49,18 +72,4 @@ ConversationsFilterWidget::handleNotifierOverlay(const QString& buttonName,
notifier->setGeometry(getNotifierRect(button->frameGeometry()));
notifier->show();
}
}
ConversationsFilterWidget::ConversationsFilterWidget(QWidget *parent)
: QWidget(parent)
{
}