mirror of
https://gitlab.linphone.org/BC/public/linphone-desktop.git
synced 2026-01-17 11:28:07 +00:00
Fixed MWI icon if no count is provided in the NOTIFY (only yes/no)
This commit is contained in:
parent
b6284ea1e6
commit
78f5656482
7 changed files with 34 additions and 5 deletions
|
|
@ -97,6 +97,7 @@ AccountCore::AccountCore(const std::shared_ptr<linphone::Account> &account) : QO
|
|||
}
|
||||
|
||||
INIT_CORE_MEMBER(VoicemailCount, mAccountModel)
|
||||
INIT_CORE_MEMBER(ShowMwi, mAccountModel)
|
||||
}
|
||||
|
||||
AccountCore::~AccountCore() {
|
||||
|
|
@ -268,6 +269,7 @@ void AccountCore::setSelf(QSharedPointer<AccountCore> me) {
|
|||
|
||||
DEFINE_CORE_GET_CONNECT(mAccountModelConnection, AccountCore, AccountModel, mAccountModel, int, voicemailCount,
|
||||
VoicemailCount)
|
||||
DEFINE_CORE_GET_CONNECT(mAccountModelConnection, AccountCore, AccountModel, mAccountModel, int, showMwi, ShowMwi)
|
||||
}
|
||||
|
||||
const std::shared_ptr<AccountModel> &AccountCore::getModel() const {
|
||||
|
|
|
|||
|
|
@ -72,6 +72,7 @@ class AccountCore : public QObject, public AbstractObject {
|
|||
lSetAudioVideoConferenceFactoryAddress NOTIFY audioVideoConferenceFactoryAddressChanged)
|
||||
Q_PROPERTY(QString limeServerUrl READ getLimeServerUrl WRITE lSetLimeServerUrl NOTIFY limeServerUrlChanged)
|
||||
DECLARE_CORE_GET(int, voicemailCount, VoicemailCount)
|
||||
DECLARE_CORE_GET(bool, showMwi, ShowMwi)
|
||||
|
||||
public:
|
||||
static QSharedPointer<AccountCore> create(const std::shared_ptr<linphone::Account> &account);
|
||||
|
|
|
|||
|
|
@ -67,8 +67,10 @@ void AccountModel::onMessageWaitingIndicationChanged(
|
|||
auto userData = getUserData(account);
|
||||
if (!userData) userData = std::make_shared<AccountUserData>();
|
||||
userData->voicemailCount = summary->getNbNew();
|
||||
userData->showMwi = mwi->hasMessageWaiting();
|
||||
setUserData(account, userData);
|
||||
emit voicemailCountChanged(summary->getNbNew());
|
||||
emit showMwiChanged(mwi->hasMessageWaiting());
|
||||
}
|
||||
}
|
||||
|
||||
|
|
@ -311,6 +313,12 @@ int AccountModel::getVoicemailCount() {
|
|||
else return 0;
|
||||
}
|
||||
|
||||
bool AccountModel::getShowMwi() {
|
||||
auto userData = getUserData(mMonitor);
|
||||
if (userData) return userData->showMwi;
|
||||
else return false;
|
||||
}
|
||||
|
||||
// UserData (see hpp for explanations)
|
||||
|
||||
static QMap<const std::shared_ptr<linphone::Account>, std::shared_ptr<AccountUserData>> userDataMap;
|
||||
|
|
|
|||
|
|
@ -67,6 +67,7 @@ public:
|
|||
void setLimeServerUrl(QString value);
|
||||
QString dialPlanAsString(const std::shared_ptr<linphone::DialPlan> &dialPlan);
|
||||
int getVoicemailCount();
|
||||
bool getShowMwi();
|
||||
|
||||
signals:
|
||||
void registrationStateChanged(const std::shared_ptr<linphone::Account> &account,
|
||||
|
|
@ -94,6 +95,7 @@ signals:
|
|||
void limeServerUrlChanged(QString value);
|
||||
void removed();
|
||||
void voicemailCountChanged(int count);
|
||||
void showMwiChanged(bool show);
|
||||
|
||||
private:
|
||||
/**Linphone **/
|
||||
|
|
@ -118,6 +120,7 @@ private:
|
|||
|
||||
struct AccountUserData {
|
||||
int voicemailCount;
|
||||
bool showMwi;
|
||||
// ..
|
||||
};
|
||||
|
||||
|
|
|
|||
|
|
@ -148,6 +148,7 @@ Control.Control{
|
|||
Layout.rightMargin: 20 * DefaultStyle.dp
|
||||
Layout.preferredWidth: 27 * DefaultStyle.dp
|
||||
Layout.preferredHeight: 28 * DefaultStyle.dp
|
||||
visible: mainItem.account.core.showMwi
|
||||
voicemailCount: mainItem.account.core.voicemailCount >= 100 ? '99+' : mainItem.account.core.voicemailCount
|
||||
onClicked: {
|
||||
if (mainItem.account.core.mwiServerAddress.length > 0)
|
||||
|
|
|
|||
|
|
@ -9,7 +9,6 @@ import SettingsCpp
|
|||
Rectangle{
|
||||
id: mainItem
|
||||
property int voicemailCount: 0
|
||||
visible: voicemailCount > 0
|
||||
width: 27 * DefaultStyle.dp
|
||||
height: 28 * DefaultStyle.dp
|
||||
signal clicked()
|
||||
|
|
|
|||
|
|
@ -398,14 +398,29 @@ Item {
|
|||
Layout.preferredWidth: 27 * DefaultStyle.dp
|
||||
Layout.preferredHeight: 28 * DefaultStyle.dp
|
||||
|
||||
function cumulatedVoicemailCount() {
|
||||
Repeater {
|
||||
model: accountProxy
|
||||
Connections {
|
||||
target: modelData.core
|
||||
onMwiChanged: updateCumulatedMwi()
|
||||
}
|
||||
}
|
||||
|
||||
function updateCumulatedMwi() {
|
||||
var count = 0
|
||||
for (var i=0 ; i < accountProxy.count ; i++ )
|
||||
var show = false
|
||||
for (var i=0 ; i < accountProxy.count ; i++ ) {
|
||||
count += accountProxy.getAt(i).core.voicemailCount
|
||||
return count
|
||||
show |= accountProxy.getAt(i).core.showMwi
|
||||
}
|
||||
voicemail.visible = show
|
||||
voicemail.voicemailCount = count
|
||||
}
|
||||
|
||||
Component.onCompleted: {
|
||||
updateCumulatedMwi()
|
||||
}
|
||||
|
||||
voicemailCount: cumulatedVoicemailCount()
|
||||
onClicked: {
|
||||
if (accountProxy.count > 1) {
|
||||
avatarButton.popup.open()
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue