本文整理汇总了C++中MessageDialog::ask方法的典型用法代码示例。如果您正苦于以下问题:C++ MessageDialog::ask方法的具体用法?C++ MessageDialog::ask怎么用?C++ MessageDialog::ask使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类MessageDialog
的用法示例。
在下文中一共展示了MessageDialog::ask方法的6个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的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: 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);
}
示例3: 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();
}
示例4: 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;
}
示例5: 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);
}
示例6: 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));
}