void GaduEditAccountWidget::showStatusToEveryoneToggled(bool toggled) { if (toggled) return; int count = 0; const QVector<Contact> &contacts = m_contactManager->contacts(account()); foreach (const Contact &contact, contacts) if (!contact.isAnonymous() && contact.ownerBuddy().isOfflineTo()) count++; if (!count) return; MessageDialog *dialog = MessageDialog::create(m_iconsManager->iconByPath(KaduIcon("dialog-warning")), tr("Status Visibility"), tr("You are going to reveal your status to several buddies which are currently not allowed to see it.\n" "Are you sure to allow them to know you are available?")); dialog->addButton(QMessageBox::Yes, tr("Make my status visible anyway")); dialog->addButton(QMessageBox::No, tr("Stay with private status")); dialog->setDefaultButton(QMessageBox::No); int decision = dialog->exec(); if (decision == QMessageBox::Yes) return; ShowStatusToEveryone->setChecked(false); }
void GaduEditAccountWidget::removeAccount() { MessageDialog *dialog = MessageDialog::create(m_iconsManager->iconByPath(KaduIcon("dialog-warning")), tr("Confrim Account Removal"), tr("Are you sure do you want to remove account %1 (%2)?") .arg(account().accountIdentity().name()) .arg(account().id())); dialog->addButton(QMessageBox::Yes, tr("Remove account")); dialog->addButton(QMessageBox::Cancel, tr("Cancel")); dialog->setDefaultButton(QMessageBox::Cancel); int decision = dialog->exec(); if (decision == QMessageBox::Yes) { m_accountManager->removeAccountAndBuddies(account()); deleteLater(); } }
bool YourAccounts::canChangeWidget() { if (ForceWidgetChange) return true; if (!CurrentWidget) return true; if (StateNotChanged == CurrentWidget->stateNotifier()->state()) return true; if (!IsCurrentWidgetEditAccount) { MessageDialog *dialog = MessageDialog::create(m_iconsManager->iconByPath(KaduIcon("dialog-warning")), tr("Unsaved changes"), tr("You have unsaved changes in current account.<br />Do you want to return to edit or discard changes?")); dialog->addButton(QMessageBox::Yes, tr("Return to edit")); dialog->addButton(QMessageBox::Ignore, tr("Discard changes")); dialog->addButton(QMessageBox::Cancel, tr("Cancel")); QMessageBox::StandardButton result = (QMessageBox::StandardButton) dialog->exec(); switch (result) { case QMessageBox::Yes: return false; case QMessageBox::Ignore: CurrentWidget->cancel(); return true; default: return false; } } if (StateChangedDataValid == CurrentWidget->stateNotifier()->state()) { MessageDialog *dialog = MessageDialog::create(m_iconsManager->iconByPath(KaduIcon("dialog-warning")), tr("Unsaved changes"), tr("You have unsaved changes in current account.<br />Do you want to save them?")); dialog->addButton(QMessageBox::Save, tr("Save changes")); dialog->addButton(QMessageBox::Ignore, tr("Discard")); dialog->addButton(QMessageBox::Cancel, tr("Cancel")); QMessageBox::StandardButton result = (QMessageBox::StandardButton) dialog->exec(); switch (result) { case QMessageBox::Save: CurrentWidget->apply(); return true; case QMessageBox::Ignore: CurrentWidget->cancel(); return true; default: return false; } } if (StateChangedDataInvalid == CurrentWidget->stateNotifier()->state()) { MessageDialog *dialog = MessageDialog::create(m_iconsManager->iconByPath(KaduIcon("dialog-warning")), tr("Invalid changes"), tr("You have invalid changes in current account, which cannot be saved.<br />Do you want to stay in edit or discard changes?")); dialog->addButton(QMessageBox::Yes, tr("Stay in edit")); dialog->addButton(QMessageBox::Ignore, tr("Discard changes")); dialog->addButton(QMessageBox::Cancel, tr("Cancel")); QMessageBox::StandardButton result = (QMessageBox::StandardButton) dialog->exec(); switch (result) { case QMessageBox::Yes: return false; case QMessageBox::Ignore: CurrentWidget->cancel(); return true; default: return false; } } return true; }