[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:06:00 UTC 2016
Gitweb-URL: http://git.debian.org/?p=pkg-kde/applications/ktp-contact-list.git;a=commitdiff;h=3c16a2d
The following commit has been merged in the master branch:
commit 3c16a2d67d2289ac8f608a95bb8e8611218e99da
Author: Martin Klapetek <martin.klapetek at gmail.com>
Date: Thu Apr 21 23:12:25 2011 +0200
Fix a crash when there is no account set and user tries to set avatar. Now it warns the user with KMessageBox and asks to open Accounts KCM
BUG: 271445
Reviewed by: David Edmundson
---
main-widget.cpp | 80 ++++++++++++++++++++++++++++++++++++++-------------------
1 file changed, 54 insertions(+), 26 deletions(-)
diff --git a/main-widget.cpp b/main-widget.cpp
index 305a453..db4f4cd 100644
--- a/main-widget.cpp
+++ b/main-widget.cpp
@@ -733,7 +733,7 @@ void MainWidget::showSettingsKCM()
dialog->addModule("kcm_telepathy_accounts");
dialog->setAttribute(Qt::WA_DeleteOnClose);
- dialog->show();
+ dialog->exec();
}
void MainWidget::loadAvatar(const Tp::AccountPtr &account)
@@ -806,44 +806,72 @@ void MainWidget::selectAvatarFromAccount(const QString &accountUID)
void MainWidget::loadAvatarFromFile()
{
- FetchAvatarJob *job = new FetchAvatarJob(KFileDialog::getImageOpenUrl(KUrl(), this,
- i18n("Please choose your avatar")),
- this);
+ 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) {
+ showSettingsKCM();
+ loadAvatarFromFile();
+ } else {
+ return;
+ }
+ } else {
+ FetchAvatarJob *job = new FetchAvatarJob(KFileDialog::getImageOpenUrl(KUrl(), this,
+ i18n("Please choose your avatar")),
+ this);
- connect(job, SIGNAL(result(KJob*)), this, SLOT(onAvatarFetched(KJob*)));
+ connect(job, SIGNAL(result(KJob*)),
+ this, SLOT(onAvatarFetched(KJob*)));
- job->start();
+ job->start();
+ }
}
void MainWidget::onAvatarFetched(KJob *job)
{
if (job->error()) {
- KMessageBox::error(this, job->errorText());
+ KMessageBox::error(this, job->errorString());
return;
}
- FetchAvatarJob *fetchJob = qobject_cast< FetchAvatarJob* >(job);
+ //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"));
- Q_ASSERT(fetchJob);
+ if (returnCode == KMessageBox::Yes) {
+ showSettingsKCM();
+ } else {
+ return;
+ }
+ } else {
- foreach (const Tp::AccountPtr account, m_accountManager->allAccounts()) {
- Tp::PendingOperation *op = account->setAvatar(fetchJob->avatar());
+ FetchAvatarJob *fetchJob = qobject_cast< FetchAvatarJob* >(job);
- //connect for eventual error displaying
- connect(op, SIGNAL(finished(Tp::PendingOperation*)),
- this, SLOT(slotGenericOperationFinished(Tp::PendingOperation*)));
- }
+ Q_ASSERT(fetchJob);
- //add the selected avatar to the avatar button
- QIcon icon;
- icon.addPixmap(QPixmap::fromImage(QImage::fromData(fetchJob->avatar().avatarData)).scaled(48, 48));
- m_userAccountIconButton->setIcon(icon);
+ foreach (const Tp::AccountPtr account, m_accountManager->allAccounts()) {
+ Tp::PendingOperation *op = account->setAvatar(fetchJob->avatar());
- //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();
+ //connect for eventual error displaying
+ connect(op, SIGNAL(finished(Tp::PendingOperation*)),
+ this, SLOT(slotGenericOperationFinished(Tp::PendingOperation*)));
+ }
+
+ //add the selected avatar to the avatar button
+ QIcon icon;
+ icon.addPixmap(QPixmap::fromImage(QImage::fromData(fetchJob->avatar().avatarData)).scaled(48, 48));
+ m_userAccountIconButton->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();
+ }
}
--
ktp-contact-list packaging
More information about the pkg-kde-commits
mailing list