[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:08:28 UTC 2016
Gitweb-URL: http://git.debian.org/?p=pkg-kde/applications/ktp-contact-list.git;a=commitdiff;h=10a417b
The following commit has been merged in the master branch:
commit 10a417bf609de9ff61b9919a3b01a3b65255cddd
Author: David Edmundson <kde at davidedmundson.co.uk>
Date: Tue Dec 27 15:08:06 2011 +0000
Remove avatar code
---
CMakeLists.txt | 2 -
avatar-button.cpp | 229 ---------------------------------------------------
avatar-button.h | 64 --------------
fetch-avatar-job.cpp | 113 -------------------------
fetch-avatar-job.h | 51 ------------
main-widget.cpp | 7 --
main-widget.ui | 36 +-------
7 files changed, 3 insertions(+), 499 deletions(-)
diff --git a/CMakeLists.txt b/CMakeLists.txt
index a333f37..e57d389 100644
--- a/CMakeLists.txt
+++ b/CMakeLists.txt
@@ -26,7 +26,6 @@ include_directories (${KDE4_INCLUDES}
set (ktp_contactlist_SRCS
contact-list-widget.cpp
context-menu.cpp
- avatar-button.cpp
abstract-contact-delegate.cpp
contact-list-application.cpp
contact-view-hover-button.cpp
@@ -39,7 +38,6 @@ set (ktp_contactlist_SRCS
filter-bar.cpp
main.cpp
main-widget.cpp
- fetch-avatar-job.cpp
global-presence-chooser.cpp
dialogs/add-contact-dialog.cpp
dialogs/join-chat-room-dialog.cpp
diff --git a/avatar-button.cpp b/avatar-button.cpp
deleted file mode 100644
index 12ef76e..0000000
--- a/avatar-button.cpp
+++ /dev/null
@@ -1,229 +0,0 @@
-/*
- * Button representing user's Avatar
- *
- * Copyright (C) 2011 Martin Klapetek <martin.klapetek at gmail.com>
- *
- * 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 "avatar-button.h"
-
-#include <QWidgetAction>
-
-#include <KDebug>
-#include <KFileDialog>
-#include <KMessageBox>
-#include <KMenu>
-#include <KLocalizedString>
-#include <KSharedConfig>
-
-#include <KTp/Models/accounts-model.h>
-#include <KTp/Models/accounts-model-item.h>
-
-#include "fetch-avatar-job.h"
-
-AvatarButton::AvatarButton(QWidget *parent)
- : QToolButton(parent),
- //m_accountManager(0),
- m_accountsModel(0)
-{
-// m_accountManager = am;
-// m_accountsModel = model;
- m_avatarButtonMenu = new KMenu(this);
-
- QToolButton *loadFromFileButton = new QToolButton(this);
- loadFromFileButton->setIcon(KIcon("document-open-folder"));
- loadFromFileButton->setIconSize(QSize(48, 48));
- loadFromFileButton->setText(i18n("Load from file..."));
- loadFromFileButton->setToolButtonStyle(Qt::ToolButtonTextBesideIcon);
-
- QWidgetAction *loadFromFileAction = new QWidgetAction(this);
- loadFromFileAction->setDefaultWidget(loadFromFileButton);
-
- connect(loadFromFileButton, SIGNAL(clicked(bool)),
- this, SLOT(loadAvatarFromFile()));
-
- m_avatarButtonMenu->addAction(loadFromFileAction);
-
- setMenu(m_avatarButtonMenu);
-}
-
-AvatarButton::~AvatarButton()
-{
-
-}
-
-void AvatarButton::initialize(AccountsModel* model, const Tp::AccountManagerPtr& manager)
-{
- m_accountsModel = model;
- m_accountManager = manager;
-}
-
-void AvatarButton::loadAvatar(const Tp::AccountPtr &account)
-{
- if (!account->avatar().avatarData.isEmpty()) {
- QIcon icon;
- Tp::Avatar avatar = account->avatar();
- icon.addPixmap(QPixmap::fromImage(QImage::fromData(avatar.avatarData)).scaled(48, 48));
-
- QToolButton *avatarMenuItem = new QToolButton(this);
- avatarMenuItem->setIcon(icon);
- avatarMenuItem->setIconSize(QSize(48, 48));
- avatarMenuItem->setText(i18nc("String in menu saying Use avatar from account X",
- "Use from %1", account->displayName()));
- avatarMenuItem->setToolButtonStyle(Qt::ToolButtonTextBesideIcon);
-
- QWidgetAction *avatarAction = new QWidgetAction(m_avatarButtonMenu);
- avatarAction->setDefaultWidget(avatarMenuItem);
- avatarAction->setData(account->uniqueIdentifier());
-
- //this connect is chained to the avatarAction, because avatarAction holds the account id
- //which is then extracted and used
- connect(avatarMenuItem, SIGNAL(clicked(bool)),
- avatarAction, SIGNAL(triggered(bool)));
-
- connect(avatarAction, SIGNAL(triggered(bool)),
- this, SLOT(selectAvatarFromAccount()));
-
- m_avatarButtonMenu->addAction(avatarAction);
- }
-}
-
-void AvatarButton::selectAvatarFromAccount()
-{
- selectAvatarFromAccount(qobject_cast<QWidgetAction*>(sender())->data().toString());
-}
-
-void AvatarButton::selectAvatarFromAccount(const QString &accountUID)
-{
- if (accountUID.isEmpty()) {
- kDebug() << "Supplied accountUID is empty, aborting...";
- return;
- }
-
- if (m_accountsModel->accountItemForId(accountUID) == 0) {
- kDebug() << "Chosen account ID does not exist, aborting..";
-
- //no point of keeping the config if the previously set account ID does not exist
- KSharedConfigPtr config = KGlobal::config();
- KConfigGroup avatarGroup(config, "Avatar");
- avatarGroup.deleteGroup();
- avatarGroup.config()->sync();
-
- return;
- }
-
- Tp::Avatar avatar = qobject_cast<AccountsModelItem*>(m_accountsModel->accountItemForId(accountUID))->data(AccountsModel::AvatarRole).value<Tp::Avatar>();
-
- foreach (const Tp::AccountPtr &account, m_accountManager->allAccounts()) {
- //don't set the avatar for the account from where it was taken
- if (account->uniqueIdentifier() == accountUID) {
- continue;
- }
-
- account->setAvatar(avatar);
- }
-
- //add the selected avatar as the icon of avatar button
- QIcon icon;
- icon.addPixmap(QPixmap::fromImage(QImage::fromData(avatar.avatarData)).scaled(48, 48));
- setIcon(icon);
-
- m_avatarButtonMenu->close();
-
- //save the selected account into config
- KSharedConfigPtr config = KGlobal::config();
- KConfigGroup avatarGroup(config, "Avatar");
- avatarGroup.writeEntry("method", "account");
- avatarGroup.writeEntry("source", accountUID);
- avatarGroup.config()->sync();
-}
-
-void AvatarButton::loadAvatarFromFile()
-{
- if (m_accountManager->allAccounts().isEmpty()) {
- int returnCode = KMessageBox::warningYesNo(this,
- i18nc("Dialog text", "You have no accounts set. Would you like to set one now?"),
- i18nc("Dialog caption", "No accounts set"));
-
- if (returnCode == KMessageBox::Yes) {
- emit openKCMSettings();
- loadAvatarFromFile();
- } else {
- return;
- }
- } else {
- KUrl fileUrl = KFileDialog::getImageOpenUrl(KUrl(), this,
- i18n("Please choose your avatar"));
-
- if (!fileUrl.isEmpty()) {
- FetchAvatarJob *job = new FetchAvatarJob(fileUrl, this);
-
- connect(job, SIGNAL(result(KJob*)),
- this, SLOT(onAvatarFetched(KJob*)));
-
- job->start();
- } else {
- return;
- }
- }
-}
-
-void AvatarButton::onAvatarFetched(KJob *job)
-{
- if (job->error()) {
- KMessageBox::error(this, job->errorString());
- return;
- }
-
- //this should never be true, but better one "if" than a crash
- if (m_accountManager->allAccounts().isEmpty()) {
- int returnCode = KMessageBox::warningYesNo(this,
- i18nc("Dialog text", "You have no accounts set. Would you like to set one now?"),
- i18nc("Dialog caption", "No accounts set"));
-
- if (returnCode == KMessageBox::Yes) {
- emit openKCMSettings();
- } else {
- return;
- }
- } else {
-
- FetchAvatarJob *fetchJob = qobject_cast< FetchAvatarJob* >(job);
-
- Q_ASSERT(fetchJob);
-
- foreach (const Tp::AccountPtr &account, m_accountManager->allAccounts()) {
- Tp::PendingOperation *op = account->setAvatar(fetchJob->avatar());
-
- //connect for eventual error displaying
- connect(op, SIGNAL(finished(Tp::PendingOperation*)),
- this, SIGNAL(operationFinished(Tp::PendingOperation*)));
- }
-
- //add the selected avatar to the avatar button
- QIcon icon;
- icon.addPixmap(QPixmap::fromImage(QImage::fromData(fetchJob->avatar().avatarData)).scaled(48, 48));
- setIcon(icon);
-
- //since all the accounts will have the same avatar,
- //we take simply the first in AM and use this in config
- KSharedConfigPtr config = KGlobal::config();
- KConfigGroup avatarGroup(config, "Avatar");
- avatarGroup.writeEntry("method", "account");
- avatarGroup.writeEntry("source", m_accountManager->allAccounts().first()->uniqueIdentifier());
- avatarGroup.config()->sync();
- }
-}
diff --git a/avatar-button.h b/avatar-button.h
deleted file mode 100644
index b49d5eb..0000000
--- a/avatar-button.h
+++ /dev/null
@@ -1,64 +0,0 @@
-/*
- * Button representing user's Avatar
- *
- * Copyright (C) 2011 Martin Klapetek <martin.klapetek at gmail.com>
- *
- * 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 AVATAR_BUTTON_H
-#define AVATAR_BUTTON_H
-
-#include <QtGui/QToolButton>
-#include <TelepathyQt/Account>
-
-namespace Tp {
-class PendingOperation;
-}
-
-class AccountsModel;
-class KJob;
-class KMenu;
-
-class AvatarButton : public QToolButton
-{
- Q_OBJECT
-
-public:
- AvatarButton(QWidget* parent = 0);
- ~AvatarButton();
- void initialize(AccountsModel *model, const Tp::AccountManagerPtr &manager);
-
-Q_SIGNALS:
- void openKCMSettings();
- void operationFinished(Tp::PendingOperation*);
-
-public Q_SLOTS:
- void loadAvatar(const Tp::AccountPtr &account);
- void selectAvatarFromAccount(const QString &accountUID);
-
-private Q_SLOTS:
- void selectAvatarFromAccount();
- void loadAvatarFromFile();
-
- void onAvatarFetched(KJob*);
-
-private:
- KMenu *m_avatarButtonMenu;
- Tp::AccountManagerPtr m_accountManager;
- AccountsModel *m_accountsModel;
-};
-
-#endif //AVATAR_BUTTON_H
diff --git a/fetch-avatar-job.cpp b/fetch-avatar-job.cpp
deleted file mode 100644
index 06a35ea..0000000
--- a/fetch-avatar-job.cpp
+++ /dev/null
@@ -1,113 +0,0 @@
-/*
- * This file is part of telepathy-contactslist-prototype
- *
- * Copyright (C) 2011 Collabora Ltd. <info at collabora.co.uk>
- * @Author Dario Freddi <dario.freddi at collabora.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 "fetch-avatar-job.h"
-
-#include <KUrl>
-#include <KLocalizedString>
-
-#include <KIO/Job>
-
-class FetchAvatarJob::Private
-{
-public:
- Private(FetchAvatarJob *q) : q(q) {}
- ~Private() {}
-
- void _k_onMimeTypeDetected(KIO::Job *job, const QString &mimetype);
- void _k_onDataFromJob(KIO::Job *job, const QByteArray &data);
- void _k_onJobFinished(KJob *job);
-
- Tp::Avatar avatar;
- KUrl url;
-
- FetchAvatarJob *q;
-};
-
-FetchAvatarJob::FetchAvatarJob(const KUrl& url, QObject* parent)
- : KJob(parent)
- , d(new Private(this))
-{
- d->url = url;
-}
-
-FetchAvatarJob::~FetchAvatarJob()
-{
- delete d;
-}
-
-Tp::Avatar FetchAvatarJob::avatar() const
-{
- return d->avatar;
-}
-
-void FetchAvatarJob::start()
-{
- if (d->url.isEmpty() || !d->url.isValid()) {
- setError(1);
- emitResult();
- return;
- }
-
- KIO::TransferJob *job = KIO::get(d->url);
-
- connect(job, SIGNAL(mimetype(KIO::Job*,QString)),
- this, SLOT(_k_onMimeTypeDetected(KIO::Job*,QString)));
- connect(job, SIGNAL(data(KIO::Job*,QByteArray)),
- this, SLOT(_k_onDataFromJob(KIO::Job*,QByteArray)));
- connect(job, SIGNAL(result(KJob*)),
- this, SLOT(_k_onJobFinished(KJob*)));
-}
-
-void FetchAvatarJob::Private::_k_onMimeTypeDetected(KIO::Job *job, const QString &mimetype)
-{
- if (!mimetype.contains("image/")) {
- q->setErrorText(i18n("The file you have selected does not seem to be an image.
"
- "Please select an image file."));
- q->setError(1);
- q->emitResult();
-
- disconnect(job, SIGNAL(result(KJob*)),
- q, SLOT(_k_onJobFinished(KJob*)));
- disconnect(job, SIGNAL(data(KIO::Job*,QByteArray)),
- q, SLOT(_k_onDataFromJob(KIO::Job*,QByteArray)));
-
- job->kill();
-
- return;
- }
-
- avatar.MIMEType = mimetype;
-}
-
-void FetchAvatarJob::Private::_k_onDataFromJob(KIO::Job *job, const QByteArray &data)
-{
- Q_UNUSED(job)
- avatar.avatarData.append(data);
-}
-
-void FetchAvatarJob::Private::_k_onJobFinished(KJob *job)
-{
- q->setError(job->error());
- q->emitResult();
-}
-
-#include "fetch-avatar-job.moc"
diff --git a/fetch-avatar-job.h b/fetch-avatar-job.h
deleted file mode 100644
index f9841e2..0000000
--- a/fetch-avatar-job.h
+++ /dev/null
@@ -1,51 +0,0 @@
-/*
- * This file is part of telepathy-contactslist-prototype
- *
- * Copyright (C) 2011 Collabora Ltd. <info at collabora.co.uk>
- * @Author Dario Freddi <dario.freddi at collabora.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 FETCH_AVATAR_JOB_H
-#define FETCH_AVATAR_JOB_H
-
-#include <KJob>
-
-#include <TelepathyQt/Types>
-
-class KUrl;
-class FetchAvatarJob : public KJob
-{
- Q_OBJECT
-
-public:
- explicit FetchAvatarJob(const KUrl &url, QObject *parent = 0);
- virtual ~FetchAvatarJob();
-
- void start();
-
- Tp::Avatar avatar() const;
-
-private:
- class Private;
- Private * const d;
-
- Q_PRIVATE_SLOT(d, void _k_onMimeTypeDetected(KIO::Job*,QString))
- Q_PRIVATE_SLOT(d, void _k_onDataFromJob(KIO::Job*,QByteArray))
- Q_PRIVATE_SLOT(d, void _k_onJobFinished(KJob*))
-};
-
-#endif // FETCH_AVATAR_JOB_H
diff --git a/main-widget.cpp b/main-widget.cpp
index 7ad1240..dbcd233 100644
--- a/main-widget.cpp
+++ b/main-widget.cpp
@@ -53,7 +53,6 @@
#include "ui_main-widget.h"
#include "account-buttons-panel.h"
-#include "fetch-avatar-job.h"
#include "contact-list-application.h"
#include "dialogs/add-contact-dialog.h"
#include "dialogs/join-chat-room-dialog.h"
@@ -85,8 +84,6 @@ MainWidget::MainWidget(QWidget *parent)
user.loginName() : user.property(KUser::FullName).toString()
);
- m_avatarButton->setPopupMode(QToolButton::InstantPopup);
-
m_toolBar->setToolButtonStyle(Qt::ToolButtonIconOnly);
m_addContactAction = new KAction(KIcon("list-add-user"), i18n("Add new contacts..."), this);
@@ -183,9 +180,6 @@ MainWidget::MainWidget(QWidget *parent)
connect(m_searchContactAction, SIGNAL(triggered(bool)),
this, SLOT(toggleSearchWidget(bool)));
- connect(m_avatarButton, SIGNAL(operationFinished(Tp::PendingOperation*)),
- this, SLOT(onGenericOperationFinished(Tp::PendingOperation*)));
-
connect(m_contactsListView, SIGNAL(accountManagerReady(Tp::PendingOperation*)),
this, SLOT(onAccountManagerReady(Tp::PendingOperation*)));
@@ -229,7 +223,6 @@ void MainWidget::onAccountManagerReady(Tp::PendingOperation* op)
connect(m_contactsListView, SIGNAL(genericOperationFinished(Tp::PendingOperation*)),
this, SLOT(onGenericOperationFinished(Tp::PendingOperation*)));
- m_avatarButton->initialize(m_contactsListView->accountsModel(), m_contactsListView->accountManager());
m_accountButtons->setAccountManager(m_contactsListView->accountManager());
m_presenceChooser->setAccountManager(m_contactsListView->accountManager());
diff --git a/main-widget.ui b/main-widget.ui
index 98e1fe4..d01dfc9 100644
--- a/main-widget.ui
+++ b/main-widget.ui
@@ -29,42 +29,17 @@
<property name="verticalSpacing">
<number>0</number>
</property>
- <item row="0" column="1">
+ <item row="0" column="0">
<widget class="QLabel" name="m_userAccountNameLabel">
<property name="text">
<string notr="true">TextLabel</string>
</property>
</widget>
</item>
- <item row="0" column="0" rowspan="3">
- <widget class="AvatarButton" name="m_avatarButton">
- <property name="minimumSize">
- <size>
- <width>64</width>
- <height>64</height>
- </size>
- </property>
- <property name="maximumSize">
- <size>
- <width>64</width>
- <height>64</height>
- </size>
- </property>
- <property name="text">
- <string/>
- </property>
- <property name="iconSize">
- <size>
- <width>64</width>
- <height>64</height>
- </size>
- </property>
- </widget>
- </item>
- <item row="2" column="1">
+ <item row="2" column="0">
<widget class="AccountButtonsPanel" name="m_accountButtons" native="true"/>
</item>
- <item row="1" column="1">
+ <item row="1" column="0">
<widget class="GlobalPresenceChooser" name="m_presenceChooser">
<property name="sizePolicy">
<sizepolicy hsizetype="Ignored" vsizetype="Fixed">
@@ -111,11 +86,6 @@
<container>1</container>
</customwidget>
<customwidget>
- <class>AvatarButton</class>
- <extends>QToolButton</extends>
- <header>avatar-button.h</header>
- </customwidget>
- <customwidget>
<class>AccountButtonsPanel</class>
<extends>QWidget</extends>
<header>account-buttons-panel.h</header>
--
ktp-contact-list packaging
More information about the pkg-kde-commits
mailing list