[SCM] ktp-contact-list packaging branch, master, updated. debian/15.12.1-2-1070-g6c56f91
Maximiliano Curia
maxy at moszumanska.debian.org
Sat May 28 00:07:32 UTC 2016
Gitweb-URL: http://git.debian.org/?p=pkg-kde/applications/ktp-contact-list.git;a=commitdiff;h=28323be
The following commit has been merged in the master branch:
commit 28323beaa0ed82797d1de273ac7418c24f7b852e
Author: David Edmundson <kde at davidedmundson.co.uk>
Date: Tue Sep 13 15:24:18 2011 +0100
Seperate the account buttons from MainWidget
Revied-by: Martin Klapetek
REVIEW: 102605
---
CMakeLists.txt | 1 +
account-buttons-panel.cpp | 66 +++++++++++++++++++++++++++++++++++++++++++++++
account-buttons-panel.h | 54 ++++++++++++++++++++++++++++++++++++++
main-widget.cpp | 56 ++++++++++------------------------------
main-widget.h | 3 ---
main-widget.ui | 12 ++++++---
6 files changed, 144 insertions(+), 48 deletions(-)
diff --git a/CMakeLists.txt b/CMakeLists.txt
index c2fa1b2..7c463ff 100644
--- a/CMakeLists.txt
+++ b/CMakeLists.txt
@@ -28,6 +28,7 @@ set (contactlist_SRCS avatar-button.cpp
contact-delegate.cpp
contact-delegate-compact.cpp
account-button.cpp
+ account-buttons-panel.cpp
filter-bar.cpp
main.cpp
main-widget.cpp
diff --git a/account-buttons-panel.cpp b/account-buttons-panel.cpp
new file mode 100644
index 0000000..b499f32
--- /dev/null
+++ b/account-buttons-panel.cpp
@@ -0,0 +1,66 @@
+/*
+ *
+ * Copyright (C) 2011 Martin Klapetek <martin.klapetek at gmail.com>
+ * Copyright (C) 2011 David Edmundson <kde at davidedmundson.co.uk>
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License as published by the Free Software Foundation; either
+ * version 2.1 of the License, or (at your option) any later version.
+ *
+ * This library 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
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this library; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
+ */
+
+#include "account-buttons-panel.h"
+
+#include <TelepathyQt4/AccountManager>
+#include <TelepathyQt4/Account>
+#include <TelepathyQt4/AccountSet>
+
+#include <QHBoxLayout>
+
+#include "account-button.h"
+
+AccountButtonsPanel::AccountButtonsPanel(QWidget *parent) :
+ QWidget(parent),
+ m_layout(new QHBoxLayout(this))
+{
+ m_layout->insertStretch(-1);
+}
+
+void AccountButtonsPanel::setAccountManager(const Tp::AccountManagerPtr &accountManager)
+{
+ m_enabledAccounts = accountManager->enabledAccounts();
+ foreach (const Tp::AccountPtr &account, m_enabledAccounts->accounts()) {
+ onAccountAdded(account);
+ }
+
+ connect(m_enabledAccounts.data(), SIGNAL(accountAdded(Tp::AccountPtr)), SLOT(onAccountAdded(Tp::AccountPtr)));
+ connect(m_enabledAccounts.data(), SIGNAL(accountRemoved(Tp::AccountPtr)), SLOT(onAccountRemoved(Tp::AccountPtr)));
+}
+
+void AccountButtonsPanel::onAccountAdded(const Tp::AccountPtr &account)
+{
+ //add a new button to the layout
+ AccountButton *button = new AccountButton(account, this);
+ button->setObjectName(account->uniqueIdentifier());
+ m_layout->insertWidget(m_layout->count() - 1, button);
+}
+
+void AccountButtonsPanel::onAccountRemoved(const Tp::AccountPtr &account)
+{
+ //try and find relevant account button - and remove it.
+ AccountButton *button = qobject_cast<AccountButton*>(findChild<AccountButton *>(account->uniqueIdentifier()));
+ if (button) {
+ delete button;
+ }
+}
+
+#include "account-buttons-panel.moc"
diff --git a/account-buttons-panel.h b/account-buttons-panel.h
new file mode 100644
index 0000000..0f18d40
--- /dev/null
+++ b/account-buttons-panel.h
@@ -0,0 +1,54 @@
+/*
+ *
+ * Copyright (C) 2011 Martin Klapetek <martin.klapetek at gmail.com>
+ * Copyright (C) 2011 David Edmundson <kde at davidedmundson.co.uk>
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License as published by the Free Software Foundation; either
+ * version 2.1 of the License, or (at your option) any later version.
+ *
+ * This library 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
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this library; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
+ */
+
+#ifndef ACCOUNTBUTTONS_H
+#define ACCOUNTBUTTONS_H
+
+#include <QWidget>
+
+#include <TelepathyQt4/AccountSet>
+
+class QHBoxLayout;
+
+/** This class handles a horizontal list of AccountButton widgets which allow a user to control an account presence.
+ * Only enabled accounts are shown, newly enabled accounts are added/removed as appropriate.
+ */
+
+class AccountButtonsPanel : public QWidget
+{
+ Q_OBJECT
+public:
+ explicit AccountButtonsPanel(QWidget *parent = 0);
+ void setAccountManager(const Tp::AccountManagerPtr &accountManager);
+
+signals:
+
+public slots:
+
+private slots:
+ void onAccountAdded(const Tp::AccountPtr &account);
+ void onAccountRemoved(const Tp::AccountPtr &account);
+
+private:
+ Tp::AccountSetPtr m_enabledAccounts;
+ QHBoxLayout *m_layout;
+};
+
+#endif // ACCOUNTBUTTONS_H
diff --git a/main-widget.cpp b/main-widget.cpp
index 0e2c252..597d8e0 100644
--- a/main-widget.cpp
+++ b/main-widget.cpp
@@ -57,7 +57,7 @@
#include <KToolInvocation>
#include "ui_main-widget.h"
-#include "account-button.h"
+#include "account-buttons-panel.h"
#include "contact-overlays.h"
#include "contact-delegate.h"
#include "contact-delegate-compact.h"
@@ -334,9 +334,10 @@ void MainWidget::onAccountManagerReady(Tp::PendingOperation* op)
connect(m_groupsModel, SIGNAL(operationFinished(Tp::PendingOperation*)),
this, SLOT(onGenericOperationFinished(Tp::PendingOperation*)));
- m_accountButtonsLayout->insertStretch(-1);
+
m_avatarButton->initialize(m_model, m_accountManager);
+ m_accountButtons->setAccountManager(m_accountManager);
QList<Tp::AccountPtr> accounts = m_accountManager->allAccounts();
@@ -413,24 +414,6 @@ void MainWidget::onNewAccountAdded(const Tp::AccountPtr& account)
SIGNAL(connectionStatusChanged(Tp::ConnectionStatus)),
this, SLOT(onAccountConnectionStatusChanged(Tp::ConnectionStatus)));
- connect(account.data(), SIGNAL(stateChanged(bool)),
- this, SLOT(onAccountStateChanged(bool)));
-
- connect(account.data(),
- SIGNAL(removed()),
- this, SLOT(onAccountRemoved()));
-
- AccountButton *bt = new AccountButton(account, this);
- bt->setObjectName(account->uniqueIdentifier());
- bt->hide();
-
- m_accountButtonsLayout->insertWidget(m_accountButtonsLayout->count() - 1, bt);
-
- if(account->isEnabled()) {
- bt->show();
- m_avatarButton->loadAvatar(account);
- }
-
KSharedConfigPtr config = KGlobal::config();
KConfigGroup avatarGroup(config, "Avatar");
if (avatarGroup.readEntry("method", QString()) == QLatin1String("account")) {
@@ -469,27 +452,7 @@ void MainWidget::onContactManagerStateChanged(const Tp::ContactManagerPtr &conta
}
}
-void MainWidget::onAccountStateChanged(bool enabled)
-{
- Tp::AccountPtr account(qobject_cast<Tp::Account*>(sender()));
-
- if(enabled) {
- findChild<AccountButton *>(account->uniqueIdentifier())->show();
- } else {
- findChild<AccountButton *>(account->uniqueIdentifier())->hide();
- showMessageToUser(i18n("Account %1 was disabled.", account->displayName()),
- MainWidget::SystemMessageError);
- }
-}
-
-void MainWidget::onAccountRemoved()
-{
- Tp::AccountPtr account(qobject_cast<Tp::Account*>(sender()));
- delete findChild<AccountButton *>(account->uniqueIdentifier());
- showMessageToUser(i18n("Account %1 was removed.", account->displayName()),
- MainWidget::SystemMessageError);
-}
void MainWidget::onConnectionChanged(const Tp::ConnectionPtr& connection)
{
@@ -1181,9 +1144,18 @@ void MainWidget::onUnblockContactTriggered()
void MainWidget::setCustomPresenceMessage(const QString& message)
{
- for (int i = 0; i < m_accountButtonsLayout->count() - 1; i++) {
- qobject_cast<AccountButton*>(m_accountButtonsLayout->itemAt(i)->widget())->setCustomPresenceMessage(message);
+ //loop through all enabled account setting to the same presence but with a new presence message.
+ foreach(const Tp::AccountPtr account, m_accountManager->allAccounts()) {
+ if (! account->isEnabled()) {
+ continue;
+ }
+
+ Tp::SimplePresence presence;
+ presence.type = account->currentPresence().type();
+ presence.status = account->currentPresence().status();
+ presence.statusMessage = message;
+ account->setRequestedPresence(presence);
}
m_presenceMessageEdit->clearFocus();
diff --git a/main-widget.h b/main-widget.h
index 608e968..6843af5 100644
--- a/main-widget.h
+++ b/main-widget.h
@@ -75,9 +75,6 @@ public Q_SLOTS:
void onAddContactRequest();
void onAddContactRequestFoundContacts(Tp::PendingOperation *operation);
void onNewAccountAdded(const Tp::AccountPtr &account);
- void onAccountStateChanged(bool enabled);
- void onAccountRemoved();
-
void toggleSearchWidget(bool show);
void setCustomPresenceMessage(const QString &message);
void showSettingsKCM();
diff --git a/main-widget.ui b/main-widget.ui
index 7e97288..2682a51 100644
--- a/main-widget.ui
+++ b/main-widget.ui
@@ -29,9 +29,6 @@
<property name="verticalSpacing">
<number>0</number>
</property>
- <item row="2" column="1">
- <layout class="QHBoxLayout" name="m_accountButtonsLayout"/>
- </item>
<item row="1" column="1">
<widget class="KLineEdit" name="m_presenceMessageEdit">
<property name="placeholderText">
@@ -74,6 +71,9 @@
</property>
</widget>
</item>
+ <item row="2" column="1">
+ <widget class="AccountButtonsPanel" name="m_accountButtons" native="true"/>
+ </item>
</layout>
</item>
<item>
@@ -116,6 +116,12 @@
<extends>QToolButton</extends>
<header>avatar-button.h</header>
</customwidget>
+ <customwidget>
+ <class>AccountButtonsPanel</class>
+ <extends>QWidget</extends>
+ <header>account-buttons-panel.h</header>
+ <container>1</container>
+ </customwidget>
</customwidgets>
<resources/>
<connections/>
--
ktp-contact-list packaging
More information about the pkg-kde-commits
mailing list