Commit 426c7be8 authored by Andreas Traczyk's avatar Andreas Traczyk

accounts: connect voicemail signals to selected account

Change-Id: I3c3902bb4875a54e3de796565a374315e8f6425a
parent a0b4139c
...@@ -64,27 +64,14 @@ CurrentAccountComboBox::CurrentAccountComboBox(QWidget* parent) ...@@ -64,27 +64,14 @@ CurrentAccountComboBox::CurrentAccountComboBox(QWidget* parent)
}); });
// voicemail received // voicemail received
connect(LRCInstance::getCurrentCallModel(), &lrc::api::NewCallModel::voiceMailNotify, if (LRCInstance::accountModel().getAccountList().size()) {
[this] (const std::string& accountId, int newCount, int oldCount, int urgentCount) { connectVoiceMail();
Q_UNUSED(urgentCount); }
voicemailMap_[accountId] = std::make_pair(newCount, oldCount);
if (LRCInstance::accountModel().getAccountList()[currentIndex()] == accountId) { connect(&LRCInstance::instance(),
if (newCount == 0 && oldCount == 0) { &LRCInstance::accountListChanged,
voicemailButton_.setNeedToShowNotify(false); this, &CurrentAccountComboBox::connectVoiceMail,
voicemailButton_.setEnabled(false); Qt::UniqueConnection);
return;
}
if (newCount == 0) {
voicemailButton_.setNotifyNumber(oldCount);
voicemailButton_.setGreyStyleNotification(true);
} else {
voicemailButton_.setNotifyNumber(newCount);
voicemailButton_.setGreyStyleNotification(false);
}
voicemailButton_.setNeedToShowNotify(true);
voicemailButton_.setEnabled(true);
}
});
connect(&voicemailButton_, &QAbstractButton::clicked, connect(&voicemailButton_, &QAbstractButton::clicked,
[this] { [this] {
...@@ -230,6 +217,32 @@ CurrentAccountComboBox::setupVoicemailButton() ...@@ -230,6 +217,32 @@ CurrentAccountComboBox::setupVoicemailButton()
voicemailSize_ + 2 * voicemailBorder_); voicemailSize_ + 2 * voicemailBorder_);
} }
void
CurrentAccountComboBox::connectVoiceMail()
{
connect(LRCInstance::getCurrentCallModel(), &lrc::api::NewCallModel::voiceMailNotify,
[this](const std::string& accountId, int newCount, int oldCount, int urgentCount) {
Q_UNUSED(urgentCount);
voicemailMap_[accountId] = std::make_pair(newCount, oldCount);
if (LRCInstance::accountModel().getAccountList()[currentIndex()] == accountId) {
if (newCount == 0 && oldCount == 0) {
voicemailButton_.setNeedToShowNotify(false);
voicemailButton_.setEnabled(false);
return;
}
if (newCount == 0) {
voicemailButton_.setNotifyNumber(oldCount);
voicemailButton_.setGreyStyleNotification(true);
} else {
voicemailButton_.setNotifyNumber(newCount);
voicemailButton_.setGreyStyleNotification(false);
}
voicemailButton_.setNeedToShowNotify(true);
voicemailButton_.setEnabled(true);
}
});
}
// import account background account pixmap and scale pixmap to fit in label // import account background account pixmap and scale pixmap to fit in label
void void
CurrentAccountComboBox::importLabelPhoto(int index) CurrentAccountComboBox::importLabelPhoto(int index)
......
...@@ -59,6 +59,7 @@ protected: ...@@ -59,6 +59,7 @@ protected:
void hidePopup(); void hidePopup();
private: private:
void connectVoiceMail();
void importLabelPhoto(int index); void importLabelPhoto(int index);
void setupSettingsButton(); void setupSettingsButton();
void setupVoicemailButton(); void setupVoicemailButton();
......
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