mirror of
https://gitlab.linphone.org/BC/public/linphone-desktop.git
synced 2026-01-25 07:38:11 +00:00
feat(ManageAccounts.qml): display unread message count
This commit is contained in:
parent
9d6aa8a9b3
commit
5c806c75e2
8 changed files with 95 additions and 45 deletions
|
|
@ -91,6 +91,11 @@ CoreManager::CoreManager (QObject *parent, const QString &configPath) :
|
|||
{
|
||||
MessageCountNotifier *messageCountNotifier = new MessageCountNotifier(mInstance);
|
||||
messageCountNotifier->updateUnreadMessageCount();
|
||||
QObject::connect(
|
||||
messageCountNotifier, &MessageCountNotifier::unreadMessageCountChanged,
|
||||
mInstance, &CoreManager::unreadMessageCountChanged
|
||||
);
|
||||
mInstance->mMessageCountNotifier = messageCountNotifier;
|
||||
}
|
||||
|
||||
mInstance->migrate();
|
||||
|
|
@ -301,6 +306,12 @@ QString CoreManager::getVersion () const {
|
|||
|
||||
// -----------------------------------------------------------------------------
|
||||
|
||||
int CoreManager::getUnreadMessageCount () const {
|
||||
return mMessageCountNotifier ? mMessageCountNotifier->getUnreadMessageCount() : 0;
|
||||
}
|
||||
|
||||
// -----------------------------------------------------------------------------
|
||||
|
||||
void CoreManager::iterate () {
|
||||
mInstance->lockVideoRender();
|
||||
mCore->iterate();
|
||||
|
|
|
|||
|
|
@ -35,6 +35,7 @@ class CallsListModel;
|
|||
class ChatModel;
|
||||
class ContactsListModel;
|
||||
class CoreHandlers;
|
||||
class MessageCountNotifier;
|
||||
class SettingsModel;
|
||||
class SipAddressesModel;
|
||||
class VcardModel;
|
||||
|
|
@ -44,6 +45,7 @@ class CoreManager : public QObject {
|
|||
|
||||
Q_PROPERTY(QString version READ getVersion CONSTANT);
|
||||
Q_PROPERTY(QString downloadUrl READ getDownloadUrl CONSTANT);
|
||||
Q_PROPERTY(int unreadMessageCount READ getUnreadMessageCount NOTIFY unreadMessageCountChanged);
|
||||
|
||||
public:
|
||||
bool started () const {
|
||||
|
|
@ -135,6 +137,8 @@ signals:
|
|||
|
||||
void logsUploaded (const QString &url);
|
||||
|
||||
void unreadMessageCountChanged (int count);
|
||||
|
||||
private:
|
||||
CoreManager (QObject *parent, const QString &configPath);
|
||||
|
||||
|
|
@ -147,6 +151,8 @@ private:
|
|||
|
||||
QString getVersion () const;
|
||||
|
||||
int getUnreadMessageCount () const;
|
||||
|
||||
void iterate ();
|
||||
|
||||
void handleLogsUploadStateChanged (linphone::Core::LogCollectionUploadState state, const std::string &info);
|
||||
|
|
@ -164,6 +170,8 @@ private:
|
|||
SettingsModel *mSettingsModel = nullptr;
|
||||
AccountSettingsModel *mAccountSettingsModel = nullptr;
|
||||
|
||||
MessageCountNotifier *mMessageCountNotifier = nullptr;
|
||||
|
||||
QHash<QPair<QString, QString>, std::weak_ptr<ChatModel>> mChatModels;
|
||||
|
||||
QTimer *mCbsTimer = nullptr;
|
||||
|
|
|
|||
|
|
@ -59,6 +59,7 @@ void AbstractMessageCountNotifier::internalNotifyUnreadMessageCount () {
|
|||
int n = mUnreadMessageCount > 99 ? 99 : mUnreadMessageCount;
|
||||
|
||||
notifyUnreadMessageCount(CoreManager::getInstance()->getSettingsModel()->getChatEnabled() ? n : 0);
|
||||
unreadMessageCountChanged(mUnreadMessageCount);
|
||||
}
|
||||
|
||||
// -----------------------------------------------------------------------------
|
||||
|
|
|
|||
|
|
@ -43,6 +43,13 @@ public:
|
|||
|
||||
void updateUnreadMessageCount ();
|
||||
|
||||
int getUnreadMessageCount () const {
|
||||
return mUnreadMessageCount;
|
||||
}
|
||||
|
||||
signals:
|
||||
void unreadMessageCountChanged (int count);
|
||||
|
||||
protected:
|
||||
virtual void notifyUnreadMessageCount (int n) = 0;
|
||||
|
||||
|
|
|
|||
|
|
@ -54,10 +54,12 @@ static inline AccountSettingsModel::RegistrationState mapLinphoneRegistrationSta
|
|||
// -----------------------------------------------------------------------------
|
||||
|
||||
AccountSettingsModel::AccountSettingsModel (QObject *parent) : QObject(parent) {
|
||||
CoreManager *coreManager = CoreManager::getInstance();
|
||||
QObject::connect(
|
||||
CoreManager::getInstance()->getHandlers().get(), &CoreHandlers::registrationStateChanged,
|
||||
coreManager->getHandlers().get(), &CoreHandlers::registrationStateChanged,
|
||||
this, &AccountSettingsModel::handleRegistrationStateChanged
|
||||
);
|
||||
QObject::connect(coreManager, &CoreManager::unreadMessageCountChanged, this, [this]() { emit accountSettingsUpdated(); });
|
||||
}
|
||||
|
||||
// -----------------------------------------------------------------------------
|
||||
|
|
|
|||
|
|
@ -16,58 +16,75 @@ Item {
|
|||
|
||||
// ---------------------------------------------------------------------------
|
||||
|
||||
Column {
|
||||
RowLayout {
|
||||
anchors.fill: parent
|
||||
|
||||
RowLayout {
|
||||
height: parent.height / 2
|
||||
spacing: AccountStatusStyle.horizontalSpacing
|
||||
width: parent.width
|
||||
Column {
|
||||
Layout.fillWidth: true
|
||||
Layout.fillHeight: true
|
||||
|
||||
Item {
|
||||
Layout.alignment: Qt.AlignBottom
|
||||
Layout.bottomMargin: AccountStatusStyle.presenceLevel.bottomMargin
|
||||
Layout.preferredHeight: AccountStatusStyle.presenceLevel.size
|
||||
Layout.preferredWidth: AccountStatusStyle.presenceLevel.size
|
||||
RowLayout {
|
||||
height: parent.height / 2
|
||||
spacing: AccountStatusStyle.horizontalSpacing
|
||||
width: parent.width
|
||||
|
||||
PresenceLevel {
|
||||
anchors.fill: parent
|
||||
level: SettingsModel.rlsUriEnabled ? OwnPresenceModel.presenceLevel : Presence.Green
|
||||
visible: AccountSettingsModel.registrationState === AccountSettingsModel.RegistrationStateRegistered
|
||||
Item {
|
||||
Layout.alignment: Qt.AlignBottom
|
||||
Layout.bottomMargin: AccountStatusStyle.presenceLevel.bottomMargin
|
||||
Layout.preferredHeight: AccountStatusStyle.presenceLevel.size
|
||||
Layout.preferredWidth: AccountStatusStyle.presenceLevel.size
|
||||
|
||||
PresenceLevel {
|
||||
anchors.fill: parent
|
||||
level: SettingsModel.rlsUriEnabled ? OwnPresenceModel.presenceLevel : Presence.Green
|
||||
visible: AccountSettingsModel.registrationState === AccountSettingsModel.RegistrationStateRegistered
|
||||
}
|
||||
|
||||
BusyIndicator {
|
||||
anchors.fill: parent
|
||||
running: AccountSettingsModel.registrationState === AccountSettingsModel.RegistrationStateInProgress
|
||||
}
|
||||
|
||||
Icon {
|
||||
iconSize: parent.width
|
||||
icon: 'generic_error'
|
||||
visible: AccountSettingsModel.registrationState === AccountSettingsModel.RegistrationStateNotRegistered
|
||||
}
|
||||
}
|
||||
|
||||
BusyIndicator {
|
||||
anchors.fill: parent
|
||||
running: AccountSettingsModel.registrationState === AccountSettingsModel.RegistrationStateInProgress
|
||||
}
|
||||
|
||||
Icon {
|
||||
iconSize: parent.width
|
||||
icon: 'generic_error'
|
||||
visible: AccountSettingsModel.registrationState === AccountSettingsModel.RegistrationStateNotRegistered
|
||||
Text {
|
||||
Layout.fillHeight: true
|
||||
Layout.fillWidth: true
|
||||
color: AccountStatusStyle.username.color
|
||||
elide: Text.ElideRight
|
||||
font.bold: true
|
||||
font.pointSize: AccountStatusStyle.username.pointSize
|
||||
text: AccountSettingsModel.username
|
||||
verticalAlignment: Text.AlignBottom
|
||||
}
|
||||
}
|
||||
|
||||
Text {
|
||||
Layout.fillHeight: true
|
||||
Layout.fillWidth: true
|
||||
color: AccountStatusStyle.username.color
|
||||
color: AccountStatusStyle.sipAddress.color
|
||||
elide: Text.ElideRight
|
||||
font.bold: true
|
||||
font.pointSize: AccountStatusStyle.username.pointSize
|
||||
text: AccountSettingsModel.username
|
||||
verticalAlignment: Text.AlignBottom
|
||||
font.pointSize: AccountStatusStyle.sipAddress.pointSize
|
||||
height: parent.height / 2
|
||||
text: AccountSettingsModel.sipAddress
|
||||
verticalAlignment: Text.AlignTop
|
||||
width: parent.width
|
||||
}
|
||||
}
|
||||
|
||||
Text {
|
||||
color: AccountStatusStyle.sipAddress.color
|
||||
elide: Text.ElideRight
|
||||
font.pointSize: AccountStatusStyle.sipAddress.pointSize
|
||||
height: parent.height / 2
|
||||
text: AccountSettingsModel.sipAddress
|
||||
verticalAlignment: Text.AlignTop
|
||||
width: parent.width
|
||||
Item {
|
||||
Layout.preferredWidth: MessageCounterStyle.iconSize.message
|
||||
Layout.preferredHeight: MessageCounterStyle.iconSize.message
|
||||
|
||||
MessageCounter {
|
||||
id: messageCounter
|
||||
|
||||
anchors.fill: parent
|
||||
count: CoreManager.unreadMessageCount
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -67,10 +67,11 @@ DialogPlus {
|
|||
property string textRole: 'sipAddress' // Used by delegate.
|
||||
|
||||
anchors.fill: parent
|
||||
currentIndex: Utils.findIndex(AccountSettingsModel.accounts, function (account) {
|
||||
model: AccountSettingsModel.accounts
|
||||
|
||||
onModelChanged: currentIndex = Utils.findIndex(AccountSettingsModel.accounts, function (account) {
|
||||
return account.sipAddress === AccountSettingsModel.sipAddress
|
||||
})
|
||||
model: AccountSettingsModel.accounts
|
||||
|
||||
delegate: CommonItemDelegate {
|
||||
id: item
|
||||
|
|
@ -80,7 +81,10 @@ DialogPlus {
|
|||
itemIcon: Logic.getItemIcon(flattenedModel)
|
||||
width: parent.width
|
||||
|
||||
onClicked: AccountSettingsModel.setDefaultProxyConfig(flattenedModel.proxyConfig)
|
||||
onClicked: {
|
||||
container.currentIndex = index
|
||||
AccountSettingsModel.setDefaultProxyConfig(flattenedModel.proxyConfig)
|
||||
}
|
||||
|
||||
MessageCounter {
|
||||
anchors.fill: parent
|
||||
|
|
|
|||
|
|
@ -4,11 +4,11 @@ import QtQml 2.2
|
|||
// =============================================================================
|
||||
|
||||
QtObject {
|
||||
property int height: 303
|
||||
property int heightWithoutPresence: 234
|
||||
property int height: 353
|
||||
property int heightWithoutPresence: 284
|
||||
property int width: 450
|
||||
|
||||
property QtObject accountSelector: QtObject {
|
||||
property int height: 126
|
||||
property int height: 176
|
||||
}
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue