From fd0d7c0a4c645e85b6abba3d015fa987f6f44c13 Mon Sep 17 00:00:00 2001
From: Andreas Traczyk <andreas.traczyk@savoirfairelinux.com>
Date: Tue, 30 Oct 2018 17:14:06 -0400
Subject: [PATCH] fix regression introduced by 37ccc1c

Change-Id: I392b63a202673aa41b473e2a7073f7bdfc025211
---
 callwidget.cpp             |  11 ++--
 callwidget.ui              | 107 +++++++++++++---------------------
 currentaccountcombobox.cpp | 115 ++++++++++++++++++-------------------
 3 files changed, 103 insertions(+), 130 deletions(-)

diff --git a/callwidget.cpp b/callwidget.cpp
index 582aa4e..71b29a7 100644
--- a/callwidget.cpp
+++ b/callwidget.cpp
@@ -170,8 +170,11 @@ CallWidget::CallWidget(QWidget* parent) :
             this, &CallWidget::on_sendContactRequestButton_clicked);
 
     // connect conversation filter buttons to act as radio buttons
-    connect(ui->buttonInvites, &ConversationFilterButton::clicked, ui->buttonConversations, &ConversationFilterButton::setUnselected);
-    connect(ui->buttonConversations, &ConversationFilterButton::clicked, ui->buttonInvites, &ConversationFilterButton::setUnselected);
+    connect(ui->buttonInvites, &ConversationFilterButton::clicked,
+            ui->buttonConversations, &ConversationFilterButton::setUnselected);
+
+    connect(ui->buttonConversations, &ConversationFilterButton::clicked,
+            ui->buttonInvites, &ConversationFilterButton::setUnselected);
 
     connect(ui->currentAccountComboBox, QOverload<int>::of(&CurrentAccountComboBox::currentIndexChanged),
         [this] {
@@ -610,8 +613,8 @@ void CallWidget::slotShowIncomingCallView(const std::string& accountId,
     }
 
     ui->videoWidget->pushRenderer(convInfo.callId);
-    // TODO:(new lrc) in call chat
-    //ui->instantMessagingWidget->setMediaText(actualCall_);
+
+    ui->instantMessagingWidget->setupCallMessaging(convInfo.callId, messageModel_.get());
 
     disconnect(selectedCallChanged_);
     selectedCallChanged_ = connect(
diff --git a/callwidget.ui b/callwidget.ui
index 376c4fc..6b8f98b 100644
--- a/callwidget.ui
+++ b/callwidget.ui
@@ -93,13 +93,16 @@
           <number>0</number>
          </property>
          <item row="0" column="0">
-          <layout class="QVBoxLayout" name="verticalLayout_2" stretch="0,0">
+          <layout class="QVBoxLayout" name="verticalLayout_2" stretch="0,0,0">
            <property name="spacing">
             <number>0</number>
            </property>
            <property name="sizeConstraint">
             <enum>QLayout::SetDefaultConstraint</enum>
            </property>
+           <property name="topMargin">
+            <number>4</number>
+           </property>
            <item>
             <widget class="CurrentAccountComboBox" name="currentAccountComboBox" native="true">
              <property name="sizePolicy">
@@ -240,7 +243,7 @@
            </item>
            <item>
             <widget class="QWidget" name="smartListWidget" native="true">
-             <layout class="QVBoxLayout" name="verticalLayout_5" stretch="0,0,0">
+             <layout class="QVBoxLayout" name="verticalLayout_5" stretch="0,0">
               <property name="spacing">
                <number>0</number>
               </property>
@@ -256,22 +259,6 @@
               <property name="bottomMargin">
                <number>1</number>
               </property>
-              <item>
-               <widget class="QWidget" name="missingButtonsDummyWidget" native="true">
-                <property name="sizePolicy">
-                 <sizepolicy hsizetype="Preferred" vsizetype="Fixed">
-                  <horstretch>0</horstretch>
-                  <verstretch>0</verstretch>
-                 </sizepolicy>
-                </property>
-                <property name="minimumSize">
-                 <size>
-                  <width>0</width>
-                  <height>10</height>
-                 </size>
-                </property>
-               </widget>
-              </item>
               <item>
                <widget class="ConversationsFilterWidget" name="conversationsFilterWidget" native="true">
                 <layout class="QHBoxLayout" name="conversationFilterLayout">
@@ -288,14 +275,14 @@
                   <number>10</number>
                  </property>
                  <property name="bottomMargin">
-                  <number>10</number>
+                  <number>0</number>
                  </property>
                  <item>
-                  <widget class="ConversationFilterButton" name="buttonConversations">
+                  <widget class="ConversationFilterButton" name="buttonConversations" native="true">
                    <property name="toolTip">
                     <string>Show conversations</string>
                    </property>
-                   <property name="text">
+                   <property name="text" stdset="0">
                     <string>Conversations</string>
                    </property>
                   </widget>
@@ -314,59 +301,40 @@
                </widget>
               </item>
               <item>
-               <widget class="SmartListView" name="smartList">
-                <property name="autoScrollMargin">
-                 <number>16</number>
-                </property>
-                <property name="indentation">
+               <layout class="QVBoxLayout" name="verticalLayout_13">
+                <property name="spacing">
                  <number>0</number>
                 </property>
-                <property name="rootIsDecorated">
-                 <bool>false</bool>
-                </property>
-                <property name="itemsExpandable">
-                 <bool>false</bool>
-                </property>
-                <property name="expandsOnDoubleClick">
-                 <bool>false</bool>
+                <property name="topMargin">
+                 <number>10</number>
                 </property>
-                <attribute name="headerVisible">
-                 <bool>false</bool>
-                </attribute>
-               </widget>
+                <item>
+                 <widget class="SmartListView" name="smartList">
+                  <property name="autoScrollMargin">
+                   <number>16</number>
+                  </property>
+                  <property name="indentation">
+                   <number>0</number>
+                  </property>
+                  <property name="rootIsDecorated">
+                   <bool>false</bool>
+                  </property>
+                  <property name="itemsExpandable">
+                   <bool>false</bool>
+                  </property>
+                  <property name="expandsOnDoubleClick">
+                   <bool>false</bool>
+                  </property>
+                  <attribute name="headerVisible">
+                   <bool>false</bool>
+                  </attribute>
+                 </widget>
+                </item>
+               </layout>
               </item>
              </layout>
             </widget>
            </item>
-           <item>
-            <layout class="QVBoxLayout" name="verticalLayout_13">
-             <property name="topMargin">
-              <number>6</number>
-             </property>
-             <item>
-              <widget class="SmartListView" name="smartList">
-               <property name="autoScrollMargin">
-                <number>16</number>
-               </property>
-               <property name="indentation">
-                <number>0</number>
-               </property>
-               <property name="rootIsDecorated">
-                <bool>false</bool>
-               </property>
-               <property name="itemsExpandable">
-                <bool>false</bool>
-               </property>
-               <property name="expandsOnDoubleClick">
-                <bool>false</bool>
-               </property>
-               <attribute name="headerVisible">
-                <bool>false</bool>
-               </attribute>
-              </widget>
-             </item>
-            </layout>
-           </item>
           </layout>
          </item>
         </layout>
@@ -2074,6 +2042,11 @@
    <extends>QWidget</extends>
    <header>currentaccountcombobox.h</header>
   </customwidget>
+  <customwidget>
+   <class>ConversationFilterButton</class>
+   <extends>QWidget</extends>
+   <header>conversationfilterbutton.h</header>
+  </customwidget>
  </customwidgets>
  <resources>
   <include location="ressources.qrc"/>
diff --git a/currentaccountcombobox.cpp b/currentaccountcombobox.cpp
index abcd1c7..e17323b 100644
--- a/currentaccountcombobox.cpp
+++ b/currentaccountcombobox.cpp
@@ -31,7 +31,6 @@
 
 #undef REGISTERED
 
-
 CurrentAccountComboBox::CurrentAccountComboBox(QWidget* parent)
 {
     Q_UNUSED(parent);
@@ -75,9 +74,10 @@ CurrentAccountComboBox::paintEvent(QPaintEvent* e)
 {
     Q_UNUSED(e);
 
-    gearPoint_.setX(this->width() - gearSize_ - 2 * gearBorder_);
-    gearPoint_.setY(this->height() / 2 - gearLabel_.height() / 2 - gearBorder_);
-    gearLabel_.setGeometry(gearPoint_.x() - 3, gearPoint_.y(), gearSize_ + 2 * gearBorder_, gearSize_ + 2 * gearBorder_);
+    gearPoint_.setX(this->width() - gearSize_ - 4 * gearBorder_);
+    gearPoint_.setY(this->height() / 2 - gearLabel_.height() / 2 - 2 * gearBorder_);
+    gearLabel_.setGeometry(gearPoint_.x() - 3, gearPoint_.y(),
+                           gearSize_ + 2 * gearBorder_, gearSize_ + 2 * gearBorder_);
     gearLabel_.setMargin(gearBorder_);
 
     QPoint p(12, 2);
@@ -123,11 +123,13 @@ CurrentAccountComboBox::paintEvent(QPaintEvent* e)
     // write primary and secondary account identifiers to combobox label
     QString primaryAccountID = QString::fromStdString(Utils::bestNameForAccount(LRCInstance::getCurrentAccountInfo()));
     painter.setPen(Qt::black);
-    primaryAccountID = fontMetricPrimary.elidedText(primaryAccountID, Qt::ElideRight, comboBoxRect.width() - elidConst - gearSize_*!popupPresent);
+    primaryAccountID = fontMetricPrimary.elidedText(primaryAccountID, Qt::ElideRight,
+                                                    comboBoxRect.width() - elidConst - (popupPresent ? 0 : 2 * gearSize_));
     painter.drawText(comboBoxRect, Qt::AlignLeft, primaryAccountID);
 
     QString secondaryAccountID = QString::fromStdString(Utils::secondBestNameForAccount(LRCInstance::getCurrentAccountInfo()));
-    secondaryAccountID = fontMetricSecondary.elidedText(secondaryAccountID, Qt::ElideRight, comboBoxRect.width() - elidConst - 2 - gearSize_ *!popupPresent); // [screen awareness]
+    secondaryAccountID = fontMetricSecondary.elidedText(secondaryAccountID, Qt::ElideRight,
+                                                        comboBoxRect.width() - elidConst - 2 - (popupPresent ? 0 : 2 * gearSize_)); // [screen awareness]
 
     if (secondaryAccountID.length()) { // if secondary accound id exists
         painter.setFont(fontSecondary);
@@ -135,12 +137,8 @@ CurrentAccountComboBox::paintEvent(QPaintEvent* e)
         painter.drawText(comboBoxRect, (Qt::AlignBottom | Qt::AlignLeft), secondaryAccountID);
     }
 
-    if (LRCInstance::accountModel().getAccountList().size() <= 1) {
-        this->setDisabled(true);
-    }
-    else {
-        this->setEnabled(true);
-    }
+    this->setEnabled(LRCInstance::accountModel().getAccountList().size() > 1);
+
     gearLabel_.setPixmap(gearPixmap_);
 }
 
@@ -166,51 +164,50 @@ CurrentAccountComboBox::accountListUpdate()
     this->setModel(accountListModel_.get());
 }
 
-// if gearLabel is clicked
-void
-CurrentAccountComboBox::mousePressEvent(QMouseEvent* mouseEvent)
-{
-    if (!gearLabel_.frameGeometry().contains(mouseEvent->localPos().toPoint())) {
-        QComboBox::mousePressEvent(mouseEvent);
-    }
-    else {
-        emit settingsButtonClicked();
-    }
-}
-
-// if gear label is hovered over
-void
-CurrentAccountComboBox::mouseMoveEvent(QMouseEvent* mouseEvent)
-{
-    if (gearLabel_.frameGeometry().contains(mouseEvent->x(), mouseEvent->y())) {
-        QComboBox::mouseMoveEvent(mouseEvent);
-        gearLabel_.setStyleSheet("background: rgb(237, 237, 237); border-width: 0px; border-radius: 8px;");
-        return;
-    }
-
-    gearLabel_.setStyleSheet("background: transparent;");
-}
-
-void
-CurrentAccountComboBox::showPopup()
-{
-    gearPixmap_.load("");
-    popupPresent = true;
-    QComboBox::showPopup();
-}
-
-void
-CurrentAccountComboBox::hidePopup()
-{
-    gearPixmap_.load(":/images/icons/round-settings-24px.svg");
-    popupPresent = false;
-    QComboBox::hidePopup();
-
-}
-
-void
-CurrentAccountComboBox::leaveEvent(QEvent* event)
-{
-    gearLabel_.setStyleSheet("background: transparent;");
-    QComboBox::leaveEvent(event);
+// if gearLabel is clicked
+void
+CurrentAccountComboBox::mousePressEvent(QMouseEvent* mouseEvent)
+{
+    if (!gearLabel_.frameGeometry().contains(mouseEvent->localPos().toPoint())) {
+        QComboBox::mousePressEvent(mouseEvent);
+    } else {
+        emit settingsButtonClicked();
+    }
+}
+
+// if gear label is hovered over
+void
+CurrentAccountComboBox::mouseMoveEvent(QMouseEvent* mouseEvent)
+{
+    if (gearLabel_.frameGeometry().contains(mouseEvent->x(), mouseEvent->y())) {
+        QComboBox::mouseMoveEvent(mouseEvent);
+        gearLabel_.setStyleSheet("background: rgb(237, 237, 237); border-width: 0px; border-radius: 8px;");
+        return;
+    }
+
+    gearLabel_.setStyleSheet("background: transparent;");
+}
+
+void
+CurrentAccountComboBox::showPopup()
+{
+    gearPixmap_.load("");
+    popupPresent = true;
+    QComboBox::showPopup();
+}
+
+void
+CurrentAccountComboBox::hidePopup()
+{
+    gearPixmap_.load(":/images/icons/round-settings-24px.svg");
+    popupPresent = false;
+    QComboBox::hidePopup();
+
+}
+
+void
+CurrentAccountComboBox::leaveEvent(QEvent* event)
+{
+    gearLabel_.setStyleSheet("background: transparent;");
+    QComboBox::leaveEvent(event);
 }
\ No newline at end of file
-- 
GitLab