Changeset View
Changeset View
Standalone View
Standalone View
src/accountinfo.cpp
Show First 20 Lines • Show All 242 Lines • ▼ Show 20 Line(s) | 206 | { | |||
---|---|---|---|---|---|
243 | } | 243 | } | ||
244 | 244 | | |||
245 | if (m_infoToSave.contains(AccountModel::Password)) { | 245 | if (m_infoToSave.contains(AccountModel::Password)) { | ||
246 | infoToSave[AccountModel::Password] = m_infoToSave[AccountModel::Password]; | 246 | infoToSave[AccountModel::Password] = m_infoToSave[AccountModel::Password]; | ||
247 | } | 247 | } | ||
248 | 248 | | |||
249 | 249 | | |||
250 | m_infoToSave = infoToSave; | 250 | m_infoToSave = infoToSave; | ||
251 | Q_EMIT changed(!m_infoToSave.isEmpty()); | 251 | emit changed(!m_infoToSave.isEmpty()); | ||
252 | } | 252 | } | ||
253 | 253 | | |||
254 | QString AccountInfo::cleanName(QString name) const | 254 | QString AccountInfo::cleanName(QString name) const | ||
255 | { | 255 | { | ||
256 | return name; | 256 | return name; | ||
257 | } | 257 | } | ||
258 | 258 | | |||
259 | bool AccountInfo::validateName(const QString& name) const | 259 | bool AccountInfo::validateName(const QString& name) const | ||
▲ Show 20 Lines • Show All 135 Lines • ▼ Show 20 Line(s) | 394 | { | |||
395 | QScopedPointer<AvatarGallery> gallery(new AvatarGallery()); | 395 | QScopedPointer<AvatarGallery> gallery(new AvatarGallery()); | ||
396 | if (gallery->exec() != QDialog::Accepted) { | 396 | if (gallery->exec() != QDialog::Accepted) { | ||
397 | return; | 397 | return; | ||
398 | } | 398 | } | ||
399 | 399 | | |||
400 | QString path = gallery->url().toLocalFile(); | 400 | QString path = gallery->url().toLocalFile(); | ||
401 | m_info->face->setIcon(QIcon(path)); | 401 | m_info->face->setIcon(QIcon(path)); | ||
402 | m_infoToSave.insert(AccountModel::Face, path); | 402 | m_infoToSave.insert(AccountModel::Face, path); | ||
403 | Q_EMIT changed(true); | 403 | emit changed(true); | ||
404 | } | 404 | } | ||
405 | 405 | | |||
406 | QStringList AccountInfo::imageFormats() const | 406 | QStringList AccountInfo::imageFormats() const | ||
407 | { | 407 | { | ||
408 | QStringList result; | 408 | QStringList result; | ||
409 | const QList<QByteArray> supportedMimes = QImageReader::supportedMimeTypes(); | 409 | const QList<QByteArray> supportedMimes = QImageReader::supportedMimeTypes(); | ||
410 | for (const QByteArray &b: supportedMimes) { | 410 | for (const QByteArray &b: supportedMimes) { | ||
411 | if (! b.isEmpty()) | 411 | if (! b.isEmpty()) | ||
Show All 23 Lines | |||||
435 | 435 | | |||
436 | void AccountInfo::avatarCreated(KJob* job) | 436 | void AccountInfo::avatarCreated(KJob* job) | ||
437 | { | 437 | { | ||
438 | if (! job->error()) { | 438 | if (! job->error()) { | ||
439 | qCDebug(USER_MANAGER_LOG) << "Avatar created"; | 439 | qCDebug(USER_MANAGER_LOG) << "Avatar created"; | ||
440 | CreateAvatarJob *aJob = qobject_cast<CreateAvatarJob*>(job); | 440 | CreateAvatarJob *aJob = qobject_cast<CreateAvatarJob*>(job); | ||
441 | m_info->face->setIcon(QIcon(aJob->avatarPath())); | 441 | m_info->face->setIcon(QIcon(aJob->avatarPath())); | ||
442 | m_infoToSave.insert(AccountModel::Face, aJob->avatarPath()); | 442 | m_infoToSave.insert(AccountModel::Face, aJob->avatarPath()); | ||
443 | Q_EMIT changed(true); | 443 | emit changed(true); | ||
444 | } | 444 | } | ||
445 | } | 445 | } | ||
446 | 446 | | |||
447 | void AccountInfo::avatarModelChanged(KJob* job) | 447 | void AccountInfo::avatarModelChanged(KJob* job) | ||
448 | { | 448 | { | ||
449 | KIO::CopyJob* cJob = qobject_cast<KIO::CopyJob*>(job); | 449 | KIO::CopyJob* cJob = qobject_cast<KIO::CopyJob*>(job); | ||
450 | m_model->setData(m_index, QVariant(cJob->destUrl().path()), AccountModel::Face); | 450 | m_model->setData(m_index, QVariant(cJob->destUrl().path()), AccountModel::Face); | ||
451 | m_info->face->setIcon(QIcon(m_model->data(m_index, AccountModel::Face).value<QPixmap>())); | 451 | m_info->face->setIcon(QIcon(m_model->data(m_index, AccountModel::Face).value<QPixmap>())); | ||
452 | // If there is a leftover temp file, remove it | 452 | // If there is a leftover temp file, remove it | ||
453 | if (cJob->srcUrls().constFirst().path().startsWith(QLatin1String("/tmp/"))) { | 453 | if (cJob->srcUrls().constFirst().path().startsWith(QLatin1String("/tmp/"))) { | ||
454 | QFile::remove(cJob->srcUrls().constFirst().path()); | 454 | QFile::remove(cJob->srcUrls().constFirst().path()); | ||
455 | } | 455 | } | ||
456 | } | 456 | } | ||
457 | 457 | | |||
458 | void AccountInfo::clearAvatar() | 458 | void AccountInfo::clearAvatar() | ||
459 | { | 459 | { | ||
460 | m_info->face->setIcon(QIcon::fromTheme(QStringLiteral("user-identity")).pixmap(48, 48)); | 460 | m_info->face->setIcon(QIcon::fromTheme(QStringLiteral("user-identity")).pixmap(48, 48)); | ||
461 | m_infoToSave.insert(AccountModel::Face, QString()); | 461 | m_infoToSave.insert(AccountModel::Face, QString()); | ||
462 | Q_EMIT changed(true); | 462 | emit changed(true); | ||
463 | } | 463 | } | ||
464 | 464 | | |||
465 | void AccountInfo::changePassword() | 465 | void AccountInfo::changePassword() | ||
466 | { | 466 | { | ||
467 | QScopedPointer<PasswordDialog> dialog(new PasswordDialog(this)); | 467 | QScopedPointer<PasswordDialog> dialog(new PasswordDialog(this)); | ||
468 | dialog->setUsername(m_model->data(m_index, AccountModel::Username).toByteArray()); | 468 | dialog->setUsername(m_model->data(m_index, AccountModel::Username).toByteArray()); | ||
469 | dialog->setModal(true); | 469 | dialog->setModal(true); | ||
470 | if (!dialog->exec()) { | 470 | if (!dialog->exec()) { | ||
471 | return; | 471 | return; | ||
472 | } | 472 | } | ||
473 | 473 | | |||
474 | m_infoToSave[AccountModel::Password] = dialog->password(); | 474 | m_infoToSave[AccountModel::Password] = dialog->password(); | ||
475 | Q_EMIT changed(true); | 475 | emit changed(true); | ||
476 | } | 476 | } |