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

currentaccountcombox: add voicemail notification functionality

Change-Id: Ic49960677691f6e5a60a941ef3c81121e03e6886
parent 6578a311
......@@ -1122,6 +1122,7 @@ CallWidget::connectConversationModel()
updateSmartList();
updateConversationForNewContact(convUid);
ui->conversationsFilterWidget->update();
ui->currentAccountComboBox->canPlaceAudioOnlyCall(convUid);
}
);
conversationRemovedConnection_ = QObject::connect(
......
This diff is collapsed.
......@@ -16,11 +16,16 @@
* You should have received a copy of the GNU General Public License *
* along with this program. If not, see <http://www.gnu.org/licenses/>. *
**************************************************************************/
#pragma once
#include <QComboBox>
#include <QLabel>
#include "accountlistmodel.h"
#include "accountitemdelegate.h"
#include "notifypushbutton.h"
#include <QComboBox>
#include <QLabel>
#include <QPushButton>
namespace Ui {
class CurrentAccountComboBox;
......@@ -37,10 +42,12 @@ public:
void accountListUpdate();
void setCurrentIndex(int index);
void updateComboBoxDisplay();
void canPlaceAudioOnlyCall(const std::string& convUid) { emit placeAudioOnlyCall(convUid); }
signals:
void settingsButtonClicked();
void newAccountClicked();
void placeAudioOnlyCall(const std::string& convUid);
protected:
void paintEvent(QPaintEvent* e);
......@@ -54,6 +61,7 @@ protected:
private:
void importLabelPhoto(int index);
void setupSettingsButton();
void setupVoicemailButton();
AccountItemDelegate* accountItemDelegate_;
std::unique_ptr<AccountListModel> accountListModel_;
......@@ -68,4 +76,11 @@ private:
QPoint gearPoint_;
QLabel gearLabel_;
QPoint voicemailPoint_;
NotifyPushButton voicemailButton_;
const int voicemailBorder_ = 4;
const int voicemailSize_ = 24;
std::map<std::string,std::pair<int,int>> voicemailMap_;
};
......@@ -78,7 +78,8 @@ HEADERS += ./aboutdialog.h \
./previewwidget.h \
./rendermanager.h \
./distantwidget.h \
./videowidgetbase.h
./videowidgetbase.h \
./notifypushbutton.h
SOURCES += ./aboutdialog.cpp \
./banneditemwidget.cpp \
./conversationsfilterwidget.cpp \
......@@ -138,7 +139,8 @@ SOURCES += ./aboutdialog.cpp \
./previewwidget.cpp \
./rendermanager.cpp \
./distantwidget.cpp \
./videowidgetbase.cpp
./videowidgetbase.cpp \
./notifypushbutton.cpp
FORMS += ./aboutdialog.ui \
./advancedsipsettingwidget.ui \
./callwidget.ui \
......
/**************************************************************************
* Copyright (C) 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/>. *
**************************************************************************/
#include "notifypushbutton.h"
#include "lrcinstance.h"
#include <QPainter>
#include <QPainterPath>
NotifyPushButton::NotifyPushButton(QWidget* parent,
// count
int newCount,
int notifyLimit,
// geo
int circleRadiusDivideRatio,
int circleRadiusMakeup,
int notifyCirclePresenceMakeup,
int notifyTextCorrectionY,
int notifyTextCorrectionX,
int notifyTextCorrectionXOverLimit,
// font size
int notifyNumberFontSize,
int notifyNumberFontSizeDeductionOverLimit) :
QPushButton(parent),
newCount_(newCount),
notifyLimit_(notifyLimit),
circleRadiusDivideRatio_(circleRadiusDivideRatio),
circleRadiusMakeup_(circleRadiusMakeup),
notifyCirclePresenceMakeup_(notifyCirclePresenceMakeup),
notifyTextCorrectionY_(notifyTextCorrectionY),
notifyTextCorrectionX_(notifyTextCorrectionX),
notifyTextCorrectionXOverLimit_(notifyTextCorrectionXOverLimit),
notifyNumberFontSize_(notifyNumberFontSize),
notifyNumberFontSizeDeductionOverLimit_(notifyNumberFontSizeDeductionOverLimit)
{
}
NotifyPushButton::~NotifyPushButton()
{
}
void
NotifyPushButton::paintEvent(QPaintEvent* e)
{
if (!needToNotify_) {
setEnabled(false);
return;
}
QPushButton::paintEvent(e);
// set up
bool isOverNotifyLimit = (newCount_ > notifyLimit_) ? true : false;
QPainter painter(this);
painter.setRenderHint(QPainter::Antialiasing, true);
QFont font;
font.setPixelSize(isOverNotifyLimit ? notifyNumberFontSize_ - notifyNumberFontSizeDeductionOverLimit_ : notifyNumberFontSize_);
font.setWeight(QFont::Bold);
QPainterPath notifyCircle;
QPointF presenceCenter(height() - notifyCirclePresenceMakeup_, height() - notifyCirclePresenceMakeup_);
qreal circleRadius = height() / circleRadiusDivideRatio_ + circleRadiusMakeup_;
// draw circle
notifyCircle.addEllipse(presenceCenter, circleRadius, circleRadius);
painter.fillPath(notifyCircle, greyStyleNotification_ ? QBrush(QColor("grey")) : QBrush(QColor("red")));
// draw notify count
presenceCenter.setY(height() - notifyTextCorrectionY_);
presenceCenter.setX(isOverNotifyLimit ?
height() - notifyTextCorrectionX_ - notifyTextCorrectionXOverLimit_:
height() - notifyTextCorrectionX_);
painter.setPen(QPen(QColor("white")));
painter.setOpacity(1);
painter.setFont(font);
QString notifyCount = (isOverNotifyLimit) ? (QString::number(notifyLimit_) + "+") : QString::number(newCount_);
painter.drawText(presenceCenter, notifyCount);
}
/**************************************************************************
* Copyright (C) 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/>. *
**************************************************************************/
#pragma once
#include "utils.h"
#include <QColor>
#include <QImage>
#include <QPaintEvent>
#include <QPushButton>
class NotifyPushButton : public QPushButton {
Q_OBJECT
public:
// note that height should always be equal to the width for this button
explicit NotifyPushButton(QWidget* parent = nullptr,
// count
int newCount = 0,
int notifyLimit = 9,
// geo
int circleRadiusDivideRatio = 5,
int circleRadiusMakeup = 0 ,
int notifyCirclePresenceMakeup = 8,
int notifyTextCorrectionY = 5,
int notifyTextCorrectionX = 11,
int notifyTextCorrectionXOverLimit = 2,
// font size
int notifyNumberFontSize = 10,
int notifyNumberFontSizeDeductionOverLimit = 2);
~NotifyPushButton();
// count
void setNotifyNumber(int num) { newCount_ = num; }
int getNotifyNumber() { return newCount_; }
void setNotifyLimit(int limit) { notifyLimit_ = limit; }
void setNeedToShowNotify(bool need) { needToNotify_ = need; }
void setGreyStyleNotification(bool grey) { greyStyleNotification_ = grey; }
protected:
void paintEvent(QPaintEvent* e);
private:
// count
int newCount_;
int notifyLimit_;
// geo
int circleRadiusDivideRatio_;
int circleRadiusMakeup_;
int notifyCirclePresenceMakeup_;
int notifyTextCorrectionY_;
int notifyTextCorrectionX_;
int notifyTextCorrectionXOverLimit_;
// font size
int notifyNumberFontSize_;
int notifyNumberFontSizeDeductionOverLimit_;
bool needToNotify_ { true };
bool greyStyleNotification_ { false };
};
......@@ -88,5 +88,6 @@
<file>images/icons/icon-keypad-24.png</file>
<file>images/icons/ic_play_white_24dp.png</file>
<file>images/icons/icon-keypad-24-2x.png</file>
<file>images/icons/ic_voicemail_black_24dp_2x_.png</file>
</qresource>
</RCC>
\ No newline at end of file
......@@ -351,6 +351,7 @@ del /s /q $(OutDir)\Jami.exp</Command>
<ClCompile Include="aboutdialog.cpp" />
<ClCompile Include="distantwidget.cpp" />
<ClCompile Include="levelmeter.cpp" />
<ClCompile Include="notifypushbutton.cpp" />
<ClCompile Include="overlaybutton.cpp" />
<ClCompile Include="previewwidget.cpp" />
<ClCompile Include="rendermanager.cpp" />
......@@ -644,6 +645,10 @@ del /s /q $(OutDir)\Jami.exp</Command>
<IncludePath Condition="'$(Configuration)|$(Platform)'=='ReleaseCompile|x64'">.\GeneratedFiles\$(ConfigurationName);.\GeneratedFiles;.;$(ProjectDir)..\ring-daemon\contrib\msvc\include;$(ProjectDir)..\daemon\contrib\msvc\include;$(ProjectDir)..\ring-lrc\src;$(ProjectDir)..\lrc\src;$(ProjectDir)winsparkle\include;$(ProjectDir)qrencode-win32\qrencode-win32;$(QTDIR)\include;$(QTDIR)\include\QtSvg;$(QTDIR)\include\QtWidgets;$(QTDIR)\include\QtWinExtras;$(QTDIR)\include\QtGui;$(QTDIR)\include\QtANGLE;$(QTDIR)\include\QtXml;$(QTDIR)\include\QtNetwork;$(QTDIR)\include\QtWebEngineWidgets;$(QTDIR)\include\QtWebChannel;$(QTDIR)\include\QtCore;$(QTDIR)\mkspecs\win32-msvc;.\release</IncludePath>
<IncludePath Condition="'$(Configuration)|$(Platform)'=='Beta|x64'">.\GeneratedFiles\$(ConfigurationName);.\GeneratedFiles;.;$(ProjectDir)..\ring-daemon\contrib\msvc\include;$(ProjectDir)..\daemon\contrib\msvc\include;$(ProjectDir)..\ring-lrc\src;$(ProjectDir)..\lrc\src;$(ProjectDir)qrencode-win32\qrencode-win32;$(QTDIR)\include;$(QTDIR)\include\QtSvg;$(QTDIR)\include\QtWidgets;$(QTDIR)\include\QtWinExtras;$(QTDIR)\include\QtGui;$(QTDIR)\include\QtANGLE;$(QTDIR)\include\QtXml;$(QTDIR)\include\QtNetwork;$(QTDIR)\include\QtWebEngineWidgets;$(QTDIR)\include\QtWebChannel;$(QTDIR)\include\QtCore;$(QTDIR)\mkspecs\win32-msvc;.\release</IncludePath>
</QtMoc>
<QtMoc Include="notifypushbutton.h">
<IncludePath Condition="'$(Configuration)|$(Platform)'=='Release|x64'">.\GeneratedFiles\$(ConfigurationName);.\GeneratedFiles;.;$(ProjectDir)..\ring-daemon\contrib\msvc\include;$(ProjectDir)..\daemon\contrib\msvc\include;$(ProjectDir)..\ring-lrc\src;$(ProjectDir)..\lrc\src;$(ProjectDir)qrencode-win32\qrencode-win32;$(QTDIR)\include;$(QTDIR)\include\QtSvg;$(QTDIR)\include\QtWidgets;$(QTDIR)\include\QtWinExtras;$(QTDIR)\include\QtGui;$(QTDIR)\include\QtANGLE;$(QTDIR)\include\QtXml;$(QTDIR)\include\QtNetwork;$(QTDIR)\include\QtWebEngineWidgets;$(QTDIR)\include\QtWebChannel;$(QTDIR)\include\QtCore;$(QTDIR)\mkspecs\win32-msvc;.\release</IncludePath>
<IncludePath Condition="'$(Configuration)|$(Platform)'=='ReleaseCompile|x64'">.\GeneratedFiles\$(ConfigurationName);.\GeneratedFiles;.;$(ProjectDir)..\ring-daemon\contrib\msvc\include;$(ProjectDir)..\daemon\contrib\msvc\include;$(ProjectDir)..\ring-lrc\src;$(ProjectDir)..\lrc\src;$(ProjectDir)winsparkle\include;$(ProjectDir)qrencode-win32\qrencode-win32;$(QTDIR)\include;$(QTDIR)\include\QtSvg;$(QTDIR)\include\QtWidgets;$(QTDIR)\include\QtWinExtras;$(QTDIR)\include\QtGui;$(QTDIR)\include\QtANGLE;$(QTDIR)\include\QtXml;$(QTDIR)\include\QtNetwork;$(QTDIR)\include\QtWebEngineWidgets;$(QTDIR)\include\QtWebChannel;$(QTDIR)\include\QtCore;$(QTDIR)\mkspecs\win32-msvc;.\release</IncludePath>
</QtMoc>
<ClInclude Include="pixbufmanipulator.h" />
<QtMoc Include="ringbutton.h">
</QtMoc>
......
......@@ -243,6 +243,9 @@
<ClCompile Include="distantwidget.cpp">
<Filter>Source Files</Filter>
</ClCompile>
<ClCompile Include="notifypushbutton.cpp">
<Filter>Source Files</Filter>
</ClCompile>
</ItemGroup>
<ItemGroup>
<QtMoc Include="aboutdialog.h">
......@@ -428,6 +431,9 @@
<QtMoc Include="distantwidget.h">
<Filter>Header Files</Filter>
</QtMoc>
<QtMoc Include="notifypushbutton.h">
<Filter>Header Files</Filter>
</QtMoc>
</ItemGroup>
<ItemGroup>
<CustomBuild Include="debug\moc_predefs.h.cbt">
......
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