本文整理汇总了C++中MessageDialog::addButton方法的典型用法代码示例。如果您正苦于以下问题:C++ MessageDialog::addButton方法的具体用法?C++ MessageDialog::addButton怎么用?C++ MessageDialog::addButton使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类MessageDialog
的用法示例。
在下文中一共展示了MessageDialog::addButton方法的9个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: clearTalkableHistory
void HistoryMessagesTab::clearTalkableHistory()
{
if (!Storage)
return;
Q_ASSERT(TalkableTree->selectionModel());
const QModelIndexList &selectedIndexes = TalkableTree->selectionModel()->selectedIndexes();
QList<Talkable> talkables;
MessageDialog *dialog = MessageDialog::create(
m_iconsManager->iconByPath(KaduIcon("dialog-question")), tr("Kadu"),
tr("Do you really want to delete history?"));
dialog->addButton(QMessageBox::Yes, tr("Delete history"));
dialog->addButton(QMessageBox::No, tr("Cancel"));
if (!dialog->ask())
return;
for (auto const &selectedIndex : selectedIndexes)
{
Talkable talkable = selectedIndex.data(TalkableRole).value<Talkable>();
if (!talkable.isEmpty())
Storage->deleteMessages(talkable);
}
updateData();
displayTalkable(Talkable(), true);
}
示例2: showStatusToEveryoneToggled
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);
}
示例3: clearDescriptionsHistory
void StatusWindow::clearDescriptionsHistory()
{
MessageDialog *dialog = MessageDialog::create(
m_iconsManager->iconByPath(KaduIcon("dialog-warning")), tr("Clear Descriptions History"),
tr("Do you really want to clear the descriptions history?"), this);
dialog->addButton(QMessageBox::Yes, tr("Clear history"));
dialog->addButton(QMessageBox::No, tr("Cancel"));
if (!dialog->ask())
return;
m_descriptionManager->clearDescriptions();
DescriptionSelect->setModel(m_descriptionManager->model());
DescriptionSelect->setCurrentIndex(-1);
DescriptionSelect->setEnabled(false);
ClearDescriptionsHistoryButton->setEnabled(false);
}
示例4: removeAccount
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();
}
}
示例5: askForAddingContacts
bool RosterReplacer::askForAddingContacts(const QMap<Buddy, Contact> &contactsToAdd, const QMap<Buddy, Contact> &contactsToRename)
{
if (contactsToAdd.isEmpty() && contactsToRename.isEmpty())
return true;
QString questionString = tr("Kadu since version 0.10.0 automatically synchronizes Gadu-Gadu contact list with server. "
"Now the first synchronization will be performed.<br/><br/>");
if (!contactsToAdd.isEmpty())
{
QStringList contactsToAddStrings;
for (QMap<Buddy, Contact>::const_iterator i = contactsToAdd.constBegin(); i != contactsToAdd.constEnd(); i++)
contactsToAddStrings.append(i.key().display() + " (" + i.value().id() + ')');
questionString += tr("The following contacts present on the server were not found on your local contact list:<br/>"
"<b>%1</b>.<br/>If you do not agree to add those contacts to your local list, "
"they will be removed from the server.<br/><br/>").arg(contactsToAddStrings.join("</b>, <b>"));
}
if (!contactsToRename.isEmpty())
{
QStringList contactsToRenameStrings;
for (QMap<Buddy, Contact>::const_iterator i = contactsToRename.constBegin(); i != contactsToRename.constEnd(); i++)
contactsToRenameStrings.append(i.value().display(true) + " (" + i.value().id() + ") -> " + i.key().display());
if (contactsToAdd.isEmpty())
questionString += tr("The following contacts from your local list are present on the server under different names:<br/>"
"<b>%1</b>.<br/><br/>").arg(contactsToRenameStrings.join("</b>, <b>"));
else
questionString += tr("Moreover, the following contacts from your local list are present on the server under different names:<br/>"
"<b>%1</b>.<br/><br/>").arg(contactsToRenameStrings.join("</b>, <b>"));
}
questionString += tr("Do you want to apply the above changes to your local contact list? "
"Regardless of your choice, it will be sent to the server after making possible changes.");
MessageDialog *dialog = MessageDialog::create(m_iconsManager->iconByPath(KaduIcon("dialog-question")), tr("Kadu"), questionString);
dialog->addButton(QMessageBox::Yes, tr("Apply changes"));
dialog->addButton(QMessageBox::No, tr("Leave contact list unchanged"));
return dialog->ask();
}
示例6: closeTab
void TabWidget::closeTab(ChatWidget *chatWidget)
{
if (!chatWidget)
return;
if (m_configuration->deprecatedApi()->readBoolEntry("Chat", "ChatCloseTimer"))
{
unsigned int period = m_configuration->deprecatedApi()->readUnsignedNumEntry("Chat",
"ChatCloseTimerPeriod", 2);
if (QDateTime::currentDateTime() < chatWidget->lastReceivedMessageTime().addSecs(period))
{
MessageDialog *dialog = MessageDialog::create(m_iconsManager->iconByPath(KaduIcon("dialog-question")), tr("Kadu"), tr("New message received, close window anyway?"));
dialog->addButton(QMessageBox::Yes, tr("Close window"));
dialog->addButton(QMessageBox::No, tr("Cancel"));
if (!dialog->ask())
return;
}
}
delete chatWidget;
}
示例7: closeEvent
void ChatWindow::closeEvent(QCloseEvent *e)
{
kdebugf();
if (m_configuration->deprecatedApi()->readBoolEntry("Chat", "ChatCloseTimer"))
{
int period = m_configuration->deprecatedApi()->readNumEntry("Chat", "ChatCloseTimerPeriod", 2);
if (QDateTime::currentDateTime() < m_chatWidget->lastReceivedMessageTime().addSecs(period))
{
MessageDialog *dialog = MessageDialog::create(m_iconsManager->iconByPath(KaduIcon("dialog-question")), tr("Kadu"), tr("New message received, close window anyway?"));
dialog->addButton(QMessageBox::Yes, tr("Close window"));
dialog->addButton(QMessageBox::No, tr("Cancel"));
if (!dialog->ask())
{
e->ignore();
return;
}
}
}
QWidget::closeEvent(e);
}
示例8: openInsertImageDialog
void ChatEditBox::openInsertImageDialog()
{
ChatImageService *chatImageService = CurrentChat.chatAccount().protocolHandler()->chatImageService();
if (!chatImageService)
return;
// QTBUG-849
QString selectedFile = QFileDialog::getOpenFileName(this, tr("Insert image"), configuration()->deprecatedApi()->readEntry("Chat", "LastImagePath"),
tr("Images (*.png *.PNG *.jpg *.JPG *.jpeg *.JPEG *.gif *.GIF *.bmp *.BMP);;All Files (*)"));
if (!selectedFile.isEmpty())
{
QFileInfo f(selectedFile);
configuration()->deprecatedApi()->writeEntry("Chat", "LastImagePath", f.absolutePath());
if (!f.isReadable())
{
MessageDialog::show(m_iconsManager->iconByPath(KaduIcon("dialog-warning")), tr("Kadu"), tr("This file is not readable"), QMessageBox::Ok, this);
return;
}
Error imageSizeError = chatImageService->checkImageSize(f.size());
if (!imageSizeError.message().isEmpty())
{
MessageDialog *dialog = MessageDialog::create(m_iconsManager->iconByPath(KaduIcon("dialog-warning")), tr("Kadu"), imageSizeError.message(), this);
dialog->addButton(QMessageBox::Yes, tr("Send anyway"));
dialog->addButton(QMessageBox::No, tr("Cancel"));
switch (imageSizeError.severity())
{
case NoError:
break;
case ErrorLow:
if (dialog->ask())
return;
break;
case ErrorHigh:
MessageDialog::show(m_iconsManager->iconByPath(KaduIcon("dialog-error")), tr("Kadu"), imageSizeError.message(), QMessageBox::Ok, this);
return;
default:
break;
}
}
int tooBigCounter = 0;
int disconnectedCounter = 0;
foreach (const Contact &contact, CurrentChat.contacts())
{
if (contact.currentStatus().isDisconnected())
disconnectedCounter++;
else if (contact.maximumImageSize() == 0 || contact.maximumImageSize() * 1024 < f.size())
tooBigCounter++;
}
QString message;
if (1 == CurrentChat.contacts().count())
{
Contact contact = *CurrentChat.contacts().constBegin();
if (tooBigCounter > 0)
message = tr("This image has %1 KiB and may be too big for %2.")
.arg((f.size() + 1023) / 1024).arg(contact.display(true)) + '\n';
else if (disconnectedCounter > 0)
message = tr("%1 appears to be offline and may not receive images.").arg(contact.display(true)) + '\n';
}
else
{
if (tooBigCounter > 0)
message = tr("This image has %1 KiB and may be too big for %2 of %3 contacts in this conference.")
.arg((f.size() + 1023) / 1024).arg(tooBigCounter).arg(CurrentChat.contacts().count()) + '\n';
if (disconnectedCounter > 0)
message += tr("%1 of %2 contacts appear to be offline and may not receive images.").arg(disconnectedCounter).arg(CurrentChat.contacts().count()) + '\n';
}
if (tooBigCounter > 0 || disconnectedCounter > 0)
message += tr("Do you really want to send this image?");
MessageDialog *dialog = MessageDialog::create(m_iconsManager->iconByPath(KaduIcon("dialog-question")), tr("Kadu"), message, this);
dialog->addButton(QMessageBox::Yes, tr("Send anyway"));
dialog->addButton(QMessageBox::No, tr("Cancel"));
if (!message.isEmpty() && !dialog->ask())
return;
InputBox->insertHtml(QString("<img src='%1' />").arg(selectedFile));
}
示例9: canChangeWidget
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;
}