Commit 21fd911d authored by Friedrich W. H. Kossebau's avatar Friedrich W. H. Kossebau Committed by Laurent Montel
Browse files

Use action texts for buttons of decision/confirmation dialogs

parent 32f9bd92
Pipeline #94438 passed with stage
in 54 minutes and 17 seconds
......@@ -178,7 +178,12 @@ public:
if (buttonRect.contains(mouseEvent->pos())) {
const QString templateName = index.data(Qt::DisplayRole).toString();
if (KMessageBox::questionYesNo(nullptr, i18nc("@label", "Do you really want to delete template '%1'?", templateName)) == KMessageBox::Yes) {
const int answer = KMessageBox::questionYesNo(nullptr,
i18nc("@label", "Do you really want to delete template '%1'?", templateName),
QString(),
KStandardGuiItem::del(),
KStandardGuiItem::cancel());
if (answer == KMessageBox::Yes) {
model->removeRows(index.row(), 1);
return true;
}
......
......@@ -88,7 +88,9 @@ void MergeContactSelectInformationScrollArea::slotMergeContacts()
if (KMessageBox::No
== KMessageBox::warningYesNo(this,
i18n("Some information was not selected. You can lose this information. Do you want to continue merging?"),
i18n("Missing Selected Information"))) {
i18n("Missing Selected Information"),
KStandardGuiItem::cont(),
KStandardGuiItem::cancel())) {
return;
}
}
......
......@@ -93,10 +93,13 @@ void ConfirmBeforeDeletingWidget::slotRemoveRule()
{
auto items = mTreeWidget->selectedItems();
if (!items.isEmpty()) {
if (KMessageBox::questionYesNo(this,
i18np("Do you want to remove this rule?", "Do you want to remove these rules?", items.count()),
i18nc("@title", "Remove Rule"))
== KMessageBox::Yes) {
const int answer = KMessageBox::questionYesNo(this,
i18np("Do you want to remove this rule?", "Do you want to remove these rules?", items.count()),
i18nc("@title", "Remove Rule"),
KStandardGuiItem::remove(),
KStandardGuiItem::cancel());
if (answer == KMessageBox::Yes) {
while (!items.isEmpty()) {
delete items.takeFirst();
}
......
......@@ -66,7 +66,12 @@ QuickTextWidget::~QuickTextWidget()
void QuickTextWidget::save()
{
if (mSnippetWidget->wasChanged()) {
if (KMessageBox::Yes == KMessageBox::warningYesNo(this, i18n("QuickText was changed. Do you want to save it?"), i18n("Save"))) {
const int answer = KMessageBox::warningYesNo(this,
i18n("QuickText was changed. Do you want to save it?"),
i18n("Save"),
KStandardGuiItem::save(),
KStandardGuiItem::discard());
if (answer == KMessageBox::Yes) {
switch (mMode) {
case EditMode::AddSnippet:
saveAddSnippet();
......
......@@ -98,7 +98,9 @@ void AutomaticAddContactsJob::slotFetchAllCollections(KJob *job)
if (nbItemCollection == 0) {
if (KMessageBox::questionYesNo(nullptr,
i18nc("@info", "You must create an address book before adding a contact. Do you want to create an address book?"),
i18nc("@title:window", "No Address Book Available"))
i18nc("@title:window", "No Address Book Available"),
KGuiItem(i18nc("@action:button", "Create Address Book"), QStringLiteral("address-book-new")),
KStandardGuiItem::cancel())
== KMessageBox::Yes) {
QPointer<Akonadi::AgentTypeDialog> dlg = new Akonadi::AgentTypeDialog(nullptr);
dlg->setWindowTitle(i18nc("@title:window", "Add Address Book"));
......
......@@ -33,8 +33,12 @@ bool CheckBeforeSendInterface::exec(const MessageComposer::PluginEditorCheckBefo
{
if (mSendPlainText) {
if (params.isHtmlMail()) {
if (KMessageBox::No
== KMessageBox::questionYesNo(parentWidget(), i18n("Do you want to send the email as HTML?"), i18n("Send email as plain text"))) {
const int answer = KMessageBox::questionYesNo(parentWidget(),
i18n("Do you want to send the email as HTML?"),
i18n("Send email as plain text"),
KGuiItem(i18nc("@action:button", "Send As HTML")),
KStandardGuiItem::cancel());
if (answer == KMessageBox::No) {
return false;
}
}
......
......@@ -96,8 +96,8 @@ bool LanguageToolInterface::checkAgain()
parentWidget(),
i18n("You do not use local instance.\nYour text will send on a external web site (https://languagetool.org/).\nDo you want to continue?"),
i18n("Check Grammar with LanguageTool"),
KStandardGuiItem::yes(),
KStandardGuiItem::no(),
KStandardGuiItem::cont(),
KStandardGuiItem::cancel(),
QStringLiteral("send_data_on_languagetool"))
== KMessageBox::No) {
return false;
......
......@@ -767,67 +767,101 @@ public:
if (!warnStr.isEmpty()) {
QString queryStr;
KGuiItem yesItem;
KGuiItem noItem;
if (path == QLatin1String("accept")) {
if (type == Incidence::TypeTodo) {
queryStr = i18n("Do you still want to accept the task?");
} else {
queryStr = i18n("Do you still want to accept the invitation?");
}
yesItem.setText(i18nc("@action:button", "Accept"));
yesItem.setIconName(QStringLiteral("dialog-ok"));
} else if (path == QLatin1String("accept_conditionally")) {
if (type == Incidence::TypeTodo) {
queryStr = i18n("Do you still want to send conditional acceptance of the invitation?");
} else {
queryStr = i18n("Do you still want to send conditional acceptance of the task?");
}
yesItem.setText(i18nc("@action:button", "Send"));
yesItem.setIconName(QStringLiteral("mail-send"));
} else if (path == QLatin1String("accept_counter")) {
queryStr = i18n("Do you still want to accept the counter proposal?");
yesItem.setText(i18nc("@action:button", "Accept"));
yesItem.setIconName(QStringLiteral("dialog-ok"));
} else if (path == QLatin1String("counter")) {
queryStr = i18n("Do you still want to send a counter proposal?");
yesItem.setText(i18nc("@action:button", "Send"));
yesItem.setIconName(QStringLiteral("mail-send"));
} else if (path == QLatin1String("decline")) {
queryStr = i18n("Do you still want to send a decline response?");
yesItem.setText(i18nc("@action:button", "Send"));
yesItem.setIconName(QStringLiteral("mail-send"));
} else if (path == QLatin1String("decline_counter")) {
queryStr = i18n("Do you still want to decline the counter proposal?");
yesItem.setText(i18nc("@action:button", "Decline"));
} else if (path == QLatin1String("reply")) {
queryStr = i18n("Do you still want to record this response in your calendar?");
yesItem.setText(i18nc("@action:button", "Record"));
} else if (path == QLatin1String("delegate")) {
if (type == Incidence::TypeTodo) {
queryStr = i18n("Do you still want to delegate this task?");
} else {
queryStr = i18n("Do you still want to delegate this invitation?");
}
yesItem.setText(i18nc("@action:button", "Delegate"));
} else if (path == QLatin1String("forward")) {
if (type == Incidence::TypeTodo) {
queryStr = i18n("Do you still want to forward this task?");
} else {
queryStr = i18n("Do you still want to forward this invitation?");
}
yesItem.setText(i18nc("@action:button", "Forward"));
yesItem.setIconName(QStringLiteral("mail-forward"));
} else if (path == QLatin1String("cancel")) {
if (type == Incidence::TypeTodo) {
queryStr = i18n("Do you still want to cancel this task?");
yesItem.setText(i18nc("@action:button", "Cancel Task"));
} else {
queryStr = i18n("Do you still want to cancel this invitation?");
yesItem.setText(i18nc("@action:button", "Cancel Invitation"));
}
yesItem.setIconName(QStringLiteral("dialog-ok"));
noItem.setText(i18nc("@action:button", "Do Not Cancel"));
noItem.setIconName(QStringLiteral("dialog-cancel"));
} else if (path == QLatin1String("check_calendar")) {
queryStr = i18n("Do you still want to check your calendar?");
yesItem.setText(i18nc("@action:button", "Check"));
} else if (path == QLatin1String("record")) {
if (type == Incidence::TypeTodo) {
queryStr = i18n("Do you still want to record this task in your calendar?");
} else {
queryStr = i18n("Do you still want to record this invitation in your calendar?");
}
yesItem.setText(i18nc("@action:button", "Record"));
} else if (path == QLatin1String("cancel")) {
if (type == Incidence::TypeTodo) {
queryStr = i18n("Do you really want to cancel this task?");
yesItem.setText(i18nc("@action:button", "Cancel Task"));
} else {
queryStr = i18n("Do you really want to cancel this invitation?");
yesItem.setText(i18nc("@action:button", "Cancel Invitation"));
}
yesItem.setIconName(QStringLiteral("dialog-ok"));
noItem.setText(i18nc("@action:button", "Do Not Cancel"));
noItem.setIconName(QStringLiteral("dialog-cancel"));
} else if (path.startsWith(QLatin1String("ATTACH:"))) {
return false;
} else {
queryStr = i18n("%1?", path);
yesItem = KStandardGuiItem::yes();
}
if (KMessageBox::warningYesNo(nullptr, i18n("%1\n%2", warnStr, queryStr)) == KMessageBox::No) {
if (noItem.text().isEmpty()) {
noItem = KStandardGuiItem::cancel();
}
const int answer = KMessageBox::warningYesNo(nullptr, i18n("%1\n%2", warnStr, queryStr), QString(), yesItem, noItem);
if (answer == KMessageBox::No) {
return true;
}
}
......
......@@ -99,9 +99,13 @@ void ViewerPluginExternalConfigureWidget::slotRemoveScript()
{
QListWidgetItem *item = mListExternal->currentItem();
if (item) {
auto scriptItem = static_cast<ViewerPluginExternalScriptItem *>(item);
if (KMessageBox::Yes
== KMessageBox::warningYesNo(this, i18n("Do you want to remove this script \"%1\"?", item->text()), i18n("Remove External Script"))) {
const int answer = KMessageBox::warningYesNo(this,
i18n("Do you want to remove this script \"%1\"?", item->text()),
i18n("Remove External Script"),
KStandardGuiItem::remove(),
KStandardGuiItem::cancel());
if (answer == KMessageBox::Yes) {
auto scriptItem = static_cast<ViewerPluginExternalScriptItem *>(item);
mFilesToRemove.append(scriptItem->scriptInfo().fileName());
delete mListExternal->takeItem(mListExternal->currentRow());
}
......
......@@ -191,8 +191,12 @@ void AdBlockSettingWidget::removeRule()
if (select.isEmpty()) {
return;
}
if (KMessageBox::No
== KMessageBox::warningYesNo(this, i18np("Do you want to remove this rule?", "Do you want to remove these rules?", select.count()), i18n("Remove"))) {
const int answer = KMessageBox::warningYesNo(this,
i18np("Do you want to remove this rule?", "Do you want to remove these rules?", select.count()),
i18n("Remove"),
KStandardGuiItem::remove(),
KStandardGuiItem::cancel());
if (answer == KMessageBox::No) {
return;
}
for (QListWidgetItem *item : select) {
......@@ -329,7 +333,12 @@ void AdBlockSettingWidget::slotRemoveSubscription()
{
QListWidgetItem *item = mUi->automaticFiltersListWidget->currentItem();
if (item) {
if (KMessageBox::questionYesNo(this, i18n("Do you want to delete list \"%1\"?", item->text()), i18n("Delete current list")) == KMessageBox::Yes) {
const int answer = KMessageBox::questionYesNo(this,
i18n("Do you want to delete list \"%1\"?", item->text()),
i18n("Delete current list"),
KStandardGuiItem::del(),
KStandardGuiItem::cancel());
if (answer == KMessageBox::Yes) {
auto subItem = dynamic_cast<AdBlockListwidgetItem *>(item);
if (subItem) {
if (AdblockManager::self()->removeSubscription(subItem->subscription())) {
......
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment