From 3aca8e3981c385d1d9e6968ff774df7937f7cbbf Mon Sep 17 00:00:00 2001
From: Edric Milaret <edric.ladent-milaret@savoirfairelinux.com>
Date: Fri, 12 Jun 2015 10:01:40 -0400
Subject: [PATCH] im: move im ui to the right of video

Refs #75424

Change-Id: Ib97e3e0b3adbe5e15a2c77df50c4e5505ef512b4
---
 callwidget.cpp             |   4 +-
 callwidget.ui              | 221 ++++++++++++++++++++-----------------
 instantmessagingwidget.cpp |   8 +-
 videooverlay.cpp           |   5 +-
 videooverlay.h             |   3 +
 videoview.cpp              |   4 +
 videoview.h                |   2 +
 7 files changed, 136 insertions(+), 111 deletions(-)

diff --git a/callwidget.cpp b/callwidget.cpp
index 738b5fb..988c5da 100644
--- a/callwidget.cpp
+++ b/callwidget.cpp
@@ -48,6 +48,9 @@ CallWidget::CallWidget(QWidget *parent) :
     setActualCall(nullptr);
     videoRenderer_ = nullptr;
 
+    connect(ui->videoWidget, SIGNAL(setChatVisibility(bool)),
+            ui->instantMessagingWidget, SLOT(setVisible(bool)));
+
     try {
         callModel_ = CallModel::instance();
 
@@ -306,7 +309,6 @@ void
 CallWidget::setActualCall(Call* value)
 {
     actualCall_ = value;
-    ui->instantMessagingWidget->setVisible(actualCall_ != nullptr);
     ui->instantMessagingWidget->setMediaText(actualCall_);
 }
 
diff --git a/callwidget.ui b/callwidget.ui
index 15ff4a9..d561530 100644
--- a/callwidget.ui
+++ b/callwidget.ui
@@ -20,6 +20,98 @@
    <string>Form</string>
   </property>
   <layout class="QGridLayout" name="gridLayout">
+   <item row="0" column="1">
+    <widget class="QWidget" name="CallSubGroup" native="true">
+     <layout class="QVBoxLayout" name="verticalLayout">
+      <property name="sizeConstraint">
+       <enum>QLayout::SetMaximumSize</enum>
+      </property>
+      <item>
+       <widget class="QFrame" name="videoFrame">
+        <property name="sizePolicy">
+         <sizepolicy hsizetype="Preferred" vsizetype="Preferred">
+          <horstretch>0</horstretch>
+          <verstretch>0</verstretch>
+         </sizepolicy>
+        </property>
+        <property name="minimumSize">
+         <size>
+          <width>0</width>
+          <height>325</height>
+         </size>
+        </property>
+        <property name="frameShape">
+         <enum>QFrame::StyledPanel</enum>
+        </property>
+        <property name="frameShadow">
+         <enum>QFrame::Raised</enum>
+        </property>
+        <layout class="QVBoxLayout" name="verticalLayout_7">
+         <item>
+          <widget class="VideoView" name="videoWidget" native="true"/>
+         </item>
+         <item>
+          <widget class="QWidget" name="callInvite" native="true">
+           <layout class="QVBoxLayout" name="verticalLayout_4">
+            <item>
+             <layout class="QVBoxLayout" name="verticalLayout_3">
+              <item alignment="Qt::AlignHCenter">
+               <widget class="QLabel" name="callLabel">
+                <property name="text">
+                 <string>Call</string>
+                </property>
+               </widget>
+              </item>
+             </layout>
+            </item>
+            <item>
+             <layout class="QHBoxLayout" name="horizontalLayout">
+              <item>
+               <widget class="QPushButton" name="acceptButton">
+                <property name="text">
+                 <string>Accept</string>
+                </property>
+                <property name="icon">
+                 <iconset resource="ressources.qrc">
+                  <normaloff>:/images/phone.png</normaloff>:/images/phone.png</iconset>
+                </property>
+               </widget>
+              </item>
+              <item>
+               <widget class="QPushButton" name="refuseButton">
+                <property name="text">
+                 <string>Refuse</string>
+                </property>
+                <property name="icon">
+                 <iconset resource="ressources.qrc">
+                  <normaloff>:/images/phone-hangup.png</normaloff>:/images/phone-hangup.png</iconset>
+                </property>
+               </widget>
+              </item>
+             </layout>
+            </item>
+           </layout>
+          </widget>
+         </item>
+        </layout>
+       </widget>
+      </item>
+      <item alignment="Qt::AlignHCenter">
+       <widget class="QLabel" name="callStateLabel">
+        <property name="sizePolicy">
+         <sizepolicy hsizetype="Preferred" vsizetype="Fixed">
+          <horstretch>0</horstretch>
+          <verstretch>0</verstretch>
+         </sizepolicy>
+        </property>
+        <property name="text">
+         <string>Call State :</string>
+        </property>
+       </widget>
+      </item>
+     </layout>
+    </widget>
+   </item>
    <item row="0" column="0">
     <layout class="QVBoxLayout" name="verticalLayout_2">
      <property name="spacing">
@@ -191,107 +283,28 @@
      </item>
     </layout>
    </item>
-   <item row="0" column="1">
-    <widget class="QWidget" name="CallSubGroup" native="true">
-     <layout class="QVBoxLayout" name="verticalLayout">
-      <property name="sizeConstraint">
-       <enum>QLayout::SetMaximumSize</enum>
-      </property>
-      <item>
-       <widget class="QFrame" name="videoFrame">
-        <property name="sizePolicy">
-         <sizepolicy hsizetype="Preferred" vsizetype="Preferred">
-          <horstretch>0</horstretch>
-          <verstretch>0</verstretch>
-         </sizepolicy>
-        </property>
-        <property name="minimumSize">
-         <size>
-          <width>0</width>
-          <height>325</height>
-         </size>
-        </property>
-        <property name="frameShape">
-         <enum>QFrame::StyledPanel</enum>
-        </property>
-        <property name="frameShadow">
-         <enum>QFrame::Raised</enum>
-        </property>
-        <layout class="QVBoxLayout" name="verticalLayout_7">
-         <item>
-          <widget class="VideoView" name="videoWidget" native="true"/>
-         </item>
-         <item>
-          <widget class="QWidget" name="callInvite" native="true">
-           <layout class="QVBoxLayout" name="verticalLayout_4">
-            <item>
-             <layout class="QVBoxLayout" name="verticalLayout_3">
-              <item alignment="Qt::AlignHCenter">
-               <widget class="QLabel" name="callLabel">
-                <property name="text">
-                 <string>Call</string>
-                </property>
-               </widget>
-              </item>
-             </layout>
-            </item>
-            <item>
-             <layout class="QHBoxLayout" name="horizontalLayout">
-              <item>
-               <widget class="QPushButton" name="acceptButton">
-                <property name="text">
-                 <string>Accept</string>
-                </property>
-                <property name="icon">
-                 <iconset>
-                  <normaloff>:/images/phone.png</normaloff>:/images/phone.png</iconset>
-                </property>
-               </widget>
-              </item>
-              <item>
-               <widget class="QPushButton" name="refuseButton">
-                <property name="text">
-                 <string>Refuse</string>
-                </property>
-                <property name="icon">
-                 <iconset>
-                  <normaloff>:/images/phone-hangup.png</normaloff>:/images/phone-hangup.png</iconset>
-                </property>
-               </widget>
-              </item>
-             </layout>
-            </item>
-           </layout>
-          </widget>
-         </item>
-        </layout>
-       </widget>
-      </item>
-      <item alignment="Qt::AlignHCenter">
-       <widget class="QLabel" name="callStateLabel">
-        <property name="sizePolicy">
-         <sizepolicy hsizetype="Preferred" vsizetype="Fixed">
-          <horstretch>0</horstretch>
-          <verstretch>0</verstretch>
-         </sizepolicy>
-        </property>
-        <property name="text">
-         <string>Call State :</string>
-        </property>
-       </widget>
-      </item>
-      <item>
-       <widget class="InstantMessagingWidget" name="instantMessagingWidget" native="true">
-        <property name="sizePolicy">
-         <sizepolicy hsizetype="Expanding" vsizetype="Fixed">
-          <horstretch>0</horstretch>
-          <verstretch>0</verstretch>
-         </sizepolicy>
-        </property>
-       </widget>
-      </item>
-     </layout>
-    </widget>
+   <item row="0" column="2">
+    <layout class="QVBoxLayout" name="verticalLayout_8">
+     <property name="leftMargin">
+      <number>0</number>
+     </property>
+     <item>
+      <widget class="InstantMessagingWidget" name="instantMessagingWidget" native="true">
+       <property name="sizePolicy">
+        <sizepolicy hsizetype="Fixed" vsizetype="Expanding">
+         <horstretch>0</horstretch>
+         <verstretch>0</verstretch>
+        </sizepolicy>
+       </property>
+       <property name="minimumSize">
+        <size>
+         <width>0</width>
+         <height>0</height>
+        </size>
+       </property>
+      </widget>
+     </item>
+    </layout>
    </item>
    <item row="1" column="1">
     <layout class="QHBoxLayout" name="horizontalLayout_5" stretch="1,0,0">
@@ -320,7 +333,7 @@
        </property>
       </widget>
      </item>
-     <item alignment="Qt::AlignRight">
+     <item>
       <widget class="QLabel" name="label_2">
        <property name="text">
         <string>State:</string>
@@ -352,6 +365,8 @@
    <container>1</container>
   </customwidget>
  </customwidgets>
- <resources/>
+ <resources>
+  <include location="ressources.qrc"/>
+ </resources>
  <connections/>
 </ui>
diff --git a/instantmessagingwidget.cpp b/instantmessagingwidget.cpp
index fc6c3f6..014b5f2 100644
--- a/instantmessagingwidget.cpp
+++ b/instantmessagingwidget.cpp
@@ -34,8 +34,7 @@ InstantMessagingWidget::InstantMessagingWidget(QWidget *parent) :
 {
     ui->setupUi(this);
 
-    ui->messageInput->hide();
-    ui->messageOutput->hide();
+    this->hide();
 
     imDelegate_ = new ImDelegate();
     ui->messageOutput->setItemDelegate(imDelegate_);
@@ -79,12 +78,9 @@ InstantMessagingWidget::setMediaText(Call *call)
             textMedia->send(ui->messageInput->text());
             ui->messageInput->clear();
         });
-        ui->messageInput->show();
     } else {
         ui->messageOutput->disconnect();
         ui->messageInput->disconnect();
-        ui->messageOutput->hide();
-        ui->messageInput->hide();
     }
 }
 
@@ -104,7 +100,7 @@ InstantMessagingWidget::mediaAdd(Media::Media *media)
             connect(ui->messageOutput->model(),
                     SIGNAL(rowsInserted(const QModelIndex&, int, int)),
                     ui->messageOutput, SLOT(scrollToBottom()));
-            ui->messageOutput->show();
+            this->show();
         }
         break;
     case Media::Media::Type::FILE:
diff --git a/videooverlay.cpp b/videooverlay.cpp
index a1f90ab..c50f82b 100644
--- a/videooverlay.cpp
+++ b/videooverlay.cpp
@@ -27,6 +27,8 @@ VideoOverlay::VideoOverlay(QWidget *parent) :
 {
     ui->setupUi(this);
 
+    ui->chatButton->setCheckable(true);
+
     actionModel_ = CallModel::instance()->userActionModel();
     setAttribute(Qt::WA_NoSystemBackground);
 }
@@ -59,11 +61,12 @@ void
 VideoOverlay::on_hangupButton_clicked()
 {
     actionModel_->execute(UserActionModel::Action::HANGUP);
+    ui->chatButton->setChecked(false);
 }
 
 void
 VideoOverlay::on_chatButton_toggled(bool checked)
 {
-    //TODO : Link this to im class once it's merged
+    emit setChatVisibility(checked);
 }
 
diff --git a/videooverlay.h b/videooverlay.h
index 31dc6fb..e31d0f9 100644
--- a/videooverlay.h
+++ b/videooverlay.h
@@ -48,6 +48,9 @@ private slots:
 private:
     Ui::VideoOverlay *ui;
     UserActionModel* actionModel_;
+
+signals:
+    void setChatVisibility(bool visible);
 };
 
 #endif // VIDEOOVERLAY_H
diff --git a/videoview.cpp b/videoview.cpp
index 88644ec..d61635e 100644
--- a/videoview.cpp
+++ b/videoview.cpp
@@ -62,6 +62,9 @@ VideoView::VideoView(QWidget *parent) :
     this->setContextMenuPolicy(Qt::CustomContextMenu);
     connect(this, SIGNAL(customContextMenuRequested(const QPoint&)),
         this, SLOT(showContextMenu(const QPoint&)));
+    connect(overlay_, &VideoOverlay::setChatVisibility, [=](bool visible) {
+        emit this->setChatVisibility(visible);
+    });
 }
 
 VideoView::~VideoView()
@@ -103,6 +106,7 @@ VideoView::callStateChanged(Call* call, Call::State previousState)
         overlay_->setName(call->formattedName());
     }
     else {
+        emit setChatVisibility(false);
         ui->videoWidget->hide();
         if (isFullScreen())
             toggleFullScreen();
diff --git a/videoview.h b/videoview.h
index 5d855d9..6a91b8c 100644
--- a/videoview.h
+++ b/videoview.h
@@ -61,6 +61,8 @@ private:
     QSize oldSize_;
 private:
     void toggleFullScreen();
+signals:
+    void setChatVisibility(bool visible);
 };
 
 #endif // VIDEOVIEW_H
-- 
GitLab