Commit fd15867a authored by Ming Rui Zhang's avatar Ming Rui Zhang

popupdialog: change contactpicker to use generalized pop up dialog

- generalized pop up dialog provide overrided constructor that can
  change spike alignment, and spike color

Change-Id: Ida7cd6571101c5768e18654c8bdc3db617fb42e9
parent bd163b07
......@@ -2,6 +2,7 @@
* Copyright (C) 2015-2019 by Savoir-faire Linux *
* Author: Edric Ladent Milaret <edric.ladent-milaret@savoirfairelinux.com>*
* Author: Andreas Traczyk <andreas.traczyk@savoirfairelinux.com> *
* Author: Mingrui Zhang <mingrui.zhang@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 *
......@@ -23,24 +24,19 @@
#include <QMouseEvent>
#include "contactpickeritemdelegate.h"
#include "popupdialog.h"
ContactPicker::ContactPicker(QWidget *parent) :
QDialog(parent),
PopupWidget(parent),
ui(new Ui::ContactPicker),
listModeltype_(SmartListModel::Type::CONFERENCE)
{
ui->setupUi(this);
setWindowFlags(Qt::CustomizeWindowHint);
setWindowFlags(Qt::Popup | Qt::FramelessWindowHint | Qt::NoDropShadowWindowHint);
setAttribute(Qt::WA_NoSystemBackground, true);
setAttribute(Qt::WA_TranslucentBackground, true);
ui->smartList->setItemDelegate(new ContactPickerItemDelegate());
selectableProxyModel_ = new SelectableProxyModel(smartListModel_.get());
ui->smartList->setModel(selectableProxyModel_);
}
ContactPicker::~ContactPicker()
......@@ -92,7 +88,7 @@ ContactPicker::accept()
}
}
QDialog::accept();
widgetContainer_->accept();
}
void
......@@ -104,15 +100,6 @@ ContactPicker::on_ringContactLineEdit_textChanged(const QString &arg1)
selectableProxyModel_->setFilterRegExp(QRegExp(arg1, Qt::CaseInsensitive, QRegExp::FixedString));
}
void
ContactPicker::mousePressEvent(QMouseEvent *event)
{
auto contactPickerWidgetRect = ui->contactPickerWidget->rect();
if (!contactPickerWidgetRect.contains(event->pos())) {
emit willClose(event);
}
}
void
ContactPicker::setTitle(const QString& title)
{
......
......@@ -2,6 +2,7 @@
* Copyright (C) 2015-2019 by Savoir-faire Linux *
* Author: Edric Ladent Milaret <edric.ladent-milaret@savoirfairelinux.com>*
* Author: Andreas Traczyk <andreas.traczyk@savoirfairelinux.com> *
* Author: Mingrui Zhang <mingrui.zhang@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 *
......@@ -22,6 +23,7 @@
#include "smartlistmodel.h"
#include "utils.h"
#include "lrcinstance.h"
#include "widgethelpers.h"
#include <QDialog>
#include <QSortFilterProxyModel>
......@@ -56,7 +58,7 @@ private:
};
class ContactPicker : public QDialog
class ContactPicker : public PopupWidget
{
Q_OBJECT;
......@@ -67,14 +69,10 @@ public:
void setType(const SmartListModel::Type& type);
void setCurrentCalleeDisplayName(const QString& CalleeDisplayName);
protected:
void mousePressEvent(QMouseEvent *event);
signals:
void contactWillJoinConference(const std::string& contactUri);
void callWillJoinConference(const std::string& callId);
void contactWillDoTransfer(const std::string& contactUri);
void willClose(QMouseEvent *event);
protected slots:
void accept();
......
<?xml version="1.0" encoding="UTF-8"?>
<ui version="4.0">
<class>ContactPicker</class>
<widget class="QDialog" name="ContactPicker">
<widget class="QWidget" name="ContactPicker">
<property name="geometry">
<rect>
<x>0</x>
<y>0</y>
<width>256</width>
<height>343</height>
<height>330</height>
</rect>
</property>
<property name="sizePolicy">
......@@ -16,54 +16,92 @@
<verstretch>0</verstretch>
</sizepolicy>
</property>
<property name="windowTitle">
<string/>
<property name="minimumSize">
<size>
<width>0</width>
<height>320</height>
</size>
</property>
<property name="styleSheet">
<string notr="true"/>
<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>
<number>5</number>
</property>
<property name="rightMargin">
<number>0</number>
</property>
<property name="bottomMargin">
<number>0</number>
<number>10</number>
</property>
<property name="spacing">
<number>0</number>
</property>
<item row="0" column="0">
<widget class="QWidget" name="contactPickerWidget" native="true">
<layout class="QGridLayout" name="gridLayout_2">
<layout class="QHBoxLayout" name="horizontalLayout">
<property name="topMargin">
<number>0</number>
</property>
<item>
<widget class="QLabel" name="title">
<property name="font">
<font>
<family>Microsoft Tai Le</family>
<pointsize>10</pointsize>
</font>
</property>
<property name="text">
<string>Add contact to conference</string>
</property>
<property name="alignment">
<set>Qt::AlignCenter</set>
</property>
</widget>
</item>
</layout>
</item>
<item row="1" column="0">
<widget class="QWidget" name="smartListOuterWidget" native="true">
<property name="styleSheet">
<string notr="true"/>
</property>
<layout class="QVBoxLayout" name="smartListOuterWidgetLayout">
<property name="spacing">
<number>0</number>
</property>
<property name="leftMargin">
<number>0</number>
</property>
<property name="topMargin">
<number>5</number>
<number>0</number>
</property>
<property name="rightMargin">
<number>0</number>
</property>
<property name="bottomMargin">
<number>10</number>
</property>
<property name="spacing">
<number>0</number>
</property>
<item row="1" column="0">
<widget class="QWidget" name="smartListOuterWidget" native="true">
<property name="styleSheet">
<string notr="true"/>
<item>
<widget class="QWidget" name="searchBarLayoutWidget" native="true">
<property name="sizePolicy">
<sizepolicy hsizetype="Preferred" vsizetype="Preferred">
<horstretch>0</horstretch>
<verstretch>0</verstretch>
</sizepolicy>
</property>
<layout class="QVBoxLayout" name="smartListOuterWidgetLayout">
<property name="spacing">
<number>0</number>
<property name="maximumSize">
<size>
<width>16777215</width>
<height>60</height>
</size>
</property>
<layout class="QGridLayout" name="gridLayout_4">
<property name="sizeConstraint">
<enum>QLayout::SetDefaultConstraint</enum>
</property>
<property name="leftMargin">
<number>0</number>
......@@ -77,227 +115,161 @@
<property name="bottomMargin">
<number>0</number>
</property>
<item>
<widget class="QWidget" name="searchBarLayoutWidget" native="true">
<property name="sizePolicy">
<sizepolicy hsizetype="Preferred" vsizetype="Preferred">
<horstretch>0</horstretch>
<verstretch>0</verstretch>
</sizepolicy>
<property name="spacing">
<number>0</number>
</property>
<item row="2" column="1">
<spacer name="verticalSpacer_8">
<property name="orientation">
<enum>Qt::Vertical</enum>
</property>
<property name="sizeType">
<enum>QSizePolicy::Fixed</enum>
</property>
<property name="maximumSize">
<property name="sizeHint" stdset="0">
<size>
<width>16777215</width>
<height>60</height>
<width>0</width>
<height>15</height>
</size>
</property>
<layout class="QGridLayout" name="gridLayout_4">
<property name="sizeConstraint">
<enum>QLayout::SetDefaultConstraint</enum>
</property>
<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="2" column="1">
<spacer name="verticalSpacer_8">
<property name="orientation">
<enum>Qt::Vertical</enum>
</property>
<property name="sizeType">
<enum>QSizePolicy::Fixed</enum>
</property>
<property name="sizeHint" stdset="0">
<size>
<width>0</width>
<height>15</height>
</size>
</property>
</spacer>
</item>
<item row="1" column="2">
<spacer name="horizontalSpacer_2">
<property name="orientation">
<enum>Qt::Horizontal</enum>
</property>
<property name="sizeType">
<enum>QSizePolicy::Fixed</enum>
</property>
<property name="sizeHint" stdset="0">
<size>
<width>16</width>
<height>20</height>
</size>
</property>
</spacer>
</item>
<item row="1" column="0">
<spacer name="horizontalSpacer">
<property name="orientation">
<enum>Qt::Horizontal</enum>
</property>
<property name="sizeType">
<enum>QSizePolicy::Fixed</enum>
</property>
<property name="sizeHint" stdset="0">
<size>
<width>16</width>
<height>20</height>
</size>
</property>
</spacer>
</item>
<item row="1" column="1">
<widget class="RingContactLineEdit" name="ringContactLineEdit">
<property name="enabled">
<bool>true</bool>
</property>
<property name="sizePolicy">
<sizepolicy hsizetype="Expanding" vsizetype="Fixed">
<horstretch>0</horstretch>
<verstretch>0</verstretch>
</sizepolicy>
</property>
<property name="minimumSize">
<size>
<width>100</width>
<height>30</height>
</size>
</property>
<property name="baseSize">
<size>
<width>244</width>
<height>30</height>
</size>
</property>
<property name="font">
<font>
<pointsize>9</pointsize>
</font>
</property>
<property name="cursor">
<cursorShape>IBeamCursor</cursorShape>
</property>
<property name="toolTip">
<string>Search contact</string>
</property>
<property name="maxLength">
<number>100</number>
</property>
<property name="alignment">
<set>Qt::AlignLeading|Qt::AlignLeft|Qt::AlignVCenter</set>
</property>
<property name="placeholderText">
<string>Search contacts</string>
</property>
<property name="clearButtonEnabled">
<bool>true</bool>
</property>
</widget>
</item>
<item row="0" column="1">
<spacer name="verticalSpacer_7">
<property name="orientation">
<enum>Qt::Vertical</enum>
</property>
<property name="sizeType">
<enum>QSizePolicy::Fixed</enum>
</property>
<property name="sizeHint" stdset="0">
<size>
<width>0</width>
<height>5</height>
</size>
</property>
</spacer>
</item>
</layout>
</widget>
</spacer>
</item>
<item row="1" column="2">
<spacer name="horizontalSpacer_2">
<property name="orientation">
<enum>Qt::Horizontal</enum>
</property>
<property name="sizeType">
<enum>QSizePolicy::Fixed</enum>
</property>
<property name="sizeHint" stdset="0">
<size>
<width>16</width>
<height>20</height>
</size>
</property>
</spacer>
</item>
<item row="1" column="0">
<spacer name="horizontalSpacer">
<property name="orientation">
<enum>Qt::Horizontal</enum>
</property>
<property name="sizeType">
<enum>QSizePolicy::Fixed</enum>
</property>
<property name="sizeHint" stdset="0">
<size>
<width>16</width>
<height>20</height>
</size>
</property>
</spacer>
</item>
<item>
<widget class="SmartListView" name="smartList">
<item row="1" column="1">
<widget class="RingContactLineEdit" name="ringContactLineEdit">
<property name="enabled">
<bool>true</bool>
</property>
<property name="sizePolicy">
<sizepolicy hsizetype="Expanding" vsizetype="MinimumExpanding">
<sizepolicy hsizetype="Expanding" vsizetype="Fixed">
<horstretch>0</horstretch>
<verstretch>0</verstretch>
</sizepolicy>
</property>
<property name="autoScrollMargin">
<number>16</number>
<property name="minimumSize">
<size>
<width>100</width>
<height>30</height>
</size>
</property>
<property name="indentation">
<number>0</number>
<property name="baseSize">
<size>
<width>244</width>
<height>30</height>
</size>
</property>
<property name="font">
<font>
<pointsize>9</pointsize>
</font>
</property>
<property name="cursor">
<cursorShape>IBeamCursor</cursorShape>
</property>
<property name="toolTip">
<string>Search contact</string>
</property>
<property name="rootIsDecorated">
<bool>false</bool>
<property name="maxLength">
<number>100</number>
</property>
<property name="itemsExpandable">
<bool>false</bool>
<property name="alignment">
<set>Qt::AlignLeading|Qt::AlignLeft|Qt::AlignVCenter</set>
</property>
<property name="expandsOnDoubleClick">
<bool>false</bool>
<property name="placeholderText">
<string>Search contacts</string>
</property>
<property name="clearButtonEnabled">
<bool>true</bool>
</property>
<attribute name="headerVisible">
<bool>false</bool>
</attribute>
<attribute name="headerMinimumSectionSize">
<number>0</number>
</attribute>
<attribute name="headerDefaultSectionSize">
<number>0</number>
</attribute>
</widget>
</item>
<item row="0" column="1">
<spacer name="verticalSpacer_7">
<property name="orientation">
<enum>Qt::Vertical</enum>
</property>
<property name="sizeType">
<enum>QSizePolicy::Fixed</enum>
</property>
<property name="sizeHint" stdset="0">
<size>
<width>0</width>
<height>5</height>
</size>
</property>
</spacer>
</item>
</layout>
</widget>
</item>
<item row="0" column="0">
<layout class="QHBoxLayout" name="horizontalLayout_3">
<property name="topMargin">
<item>
<widget class="SmartListView" name="smartList">
<property name="sizePolicy">
<sizepolicy hsizetype="Expanding" vsizetype="MinimumExpanding">
<horstretch>0</horstretch>
<verstretch>0</verstretch>
</sizepolicy>
</property>
<property name="autoScrollMargin">
<number>16</number>
</property>
<property name="indentation">
<number>0</number>
</property>
<item>
<widget class="QLabel" name="title">
<property name="font">
<font>
<family>Microsoft Tai Le</family>
<pointsize>10</pointsize>
</font>
</property>
<property name="text">
<string>Add contact to conference</string>
</property>
<property name="alignment">
<set>Qt::AlignCenter</set>
</property>
</widget>
</item>
</layout>
<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>
<attribute name="headerMinimumSectionSize">
<number>0</number>
</attribute>
<attribute name="headerDefaultSectionSize">
<number>0</number>
</attribute>
</widget>
</item>
</layout>
</widget>
</item>
<item row="1" column="0">
<widget class="QLabel" name="spikeLabel">
<property name="text">
<string/>
</property>
<property name="pixmap">
<pixmap resource="ressources.qrc">:/images/spike.png</pixmap>
</property>
</widget>
</item>
</layout>
</widget>
<customwidgets>
......@@ -312,12 +284,6 @@
<header>smartlistview.h</header>
</customwidget>
</customwidgets>
<tabstops>
<tabstop>ringContactLineEdit</tabstop>
<tabstop>smartList</tabstop>
</tabstops>
<resources>
<include location="ressources.qrc"/>
</resources>
<resources/>
<connections/>
</ui>
......@@ -83,6 +83,7 @@ HEADERS += ./aboutdialog.h \
./collapsiblepasswordwidget.h \
./notifypushbutton.h \
./widgethelpers.h \
./popupdialog.h
SOURCES += ./aboutdialog.cpp \
./banneditemwidget.cpp \
./conversationsfilterwidget.cpp \
......@@ -148,6 +149,7 @@ SOURCES += ./aboutdialog.cpp \
./collapsiblepasswordwidget.cpp \
./notifypushbutton.cpp \
./widgethelpers.cpp \
./popupdialog.cpp
FORMS += ./aboutdialog.ui \
./advancedsipsettingwidget.ui \
./callwidget.ui \
......@@ -174,5 +176,6 @@ FORMS += ./aboutdialog.ui \
./callaudioonlyavataroverlay.ui \
./accountmigration.ui \
./section.ui \
./collapsiblepasswordwidget.ui
./collapsiblepasswordwidget.ui \
./popupdialog.ui
RESOURCES += ressources.qrc
/**************************************************************************
* Copyright (C) 2015-2019 by Savoir-faire Linux *
* Author: Mingrui Zhang <mingrui.zhang@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/>. *
**************************************************************************/