Show what kind of unsubscribe will happen

This commit is contained in:
snow flurry 2024-06-16 18:25:19 -07:00
parent 0765a9801b
commit f0d634d9f5
2 changed files with 116 additions and 48 deletions

View file

@ -8,7 +8,7 @@ msgid ""
msgstr "" msgstr ""
"Project-Id-Version: kmail_unsubscribe\n" "Project-Id-Version: kmail_unsubscribe\n"
"Report-Msgid-Bugs-To: https://git.2ki.xyz/snow/kmail_unsubscribe\n" "Report-Msgid-Bugs-To: https://git.2ki.xyz/snow/kmail_unsubscribe\n"
"POT-Creation-Date: 2024-06-13 00:32-0700\n" "POT-Creation-Date: 2024-06-16 18:24-0700\n"
"PO-Revision-Date: YEAR-MO-DA HO:MI+ZONE\n" "PO-Revision-Date: YEAR-MO-DA HO:MI+ZONE\n"
"Last-Translator: FULL NAME <EMAIL@ADDRESS>\n" "Last-Translator: FULL NAME <EMAIL@ADDRESS>\n"
"Language-Team: LANGUAGE <LL@li.org>\n" "Language-Team: LANGUAGE <LL@li.org>\n"
@ -32,69 +32,93 @@ msgstr ""
msgid "Plugin hit an unreachable point" msgid "Plugin hit an unreachable point"
msgstr "" msgstr ""
#: unsubscribeplugininterface.cpp:59 #: unsubscribeplugininterface.cpp:37 unsubscribeplugininterface.cpp:181
#, kde-format
msgid "Network not available"
msgstr ""
#: unsubscribeplugininterface.cpp:60
#, kde-format
msgid "Please go back online to unsubscribe from this list."
msgstr ""
#: unsubscribeplugininterface.cpp:72
#, kde-format
msgid "Can't Unsubscribe"
msgstr ""
#: unsubscribeplugininterface.cpp:73
#, kde-format
msgid "This email doesn't advertise a way to unsubscribe."
msgstr ""
#: unsubscribeplugininterface.cpp:93
#, kde-format
msgid "The digital signature of this email couldn't be validated."
msgstr ""
#: unsubscribeplugininterface.cpp:94
#, kde-format
msgid "Do you still want to unsubscribe?"
msgstr ""
#: unsubscribeplugininterface.cpp:104
#, kde-format
msgid "This mailing list supports One-Click Unsubscribe."
msgstr ""
#: unsubscribeplugininterface.cpp:105
#, kde-format
msgid "Do you want to unsubscribe?"
msgstr ""
#: unsubscribeplugininterface.cpp:145
#, kde-format #, kde-format
msgid "Unsubscribe" msgid "Unsubscribe"
msgstr "" msgstr ""
#: unsubscribeplugininterface.cpp:146 #: unsubscribeplugininterface.cpp:38
#, kde-format #, kde-format
msgid "" msgid ""
"Allows you to unsubscribe from a mailing list, if the sender supports One-" "Allows you to unsubscribe from a mailing list, if the sender supports One-"
"Click Unsubscribe" "Click Unsubscribe"
msgstr "" msgstr ""
#: unsubscribeplugininterface.cpp:158 #: unsubscribeplugininterface.cpp:74
#, kde-format
msgid "Network not available"
msgstr ""
#: unsubscribeplugininterface.cpp:75
#, kde-format
msgid "Please go back online to unsubscribe from this list."
msgstr ""
#: unsubscribeplugininterface.cpp:87
#, kde-format
msgid "Can't Unsubscribe"
msgstr ""
#: unsubscribeplugininterface.cpp:88
#, kde-format
msgid "This email doesn't advertise a way to unsubscribe."
msgstr ""
#: unsubscribeplugininterface.cpp:108
#, kde-format
msgid "The digital signature of this email couldn't be validated."
msgstr ""
#: unsubscribeplugininterface.cpp:109
#, kde-format
msgid "Do you still want to unsubscribe?"
msgstr ""
#: unsubscribeplugininterface.cpp:119
#, kde-format
msgid "This mailing list supports One-Click Unsubscribe."
msgstr ""
#: unsubscribeplugininterface.cpp:120
#, kde-format
msgid "Do you want to unsubscribe?"
msgstr ""
#: unsubscribeplugininterface.cpp:152
#, kde-format
msgctxt "unsubscribe via the web"
msgid "Web"
msgstr ""
#: unsubscribeplugininterface.cpp:156
#, kde-format
msgctxt "unsubscribe via email"
msgid "Email"
msgstr ""
#: unsubscribeplugininterface.cpp:167
#, kde-format
msgctxt "using RFC 8058 unsubscribe"
msgid "One-Click"
msgstr ""
#: unsubscribeplugininterface.cpp:185
#, kde-format
msgctxt "unsubscribe via %1"
msgid "Unsubscribe (%1)"
msgstr ""
#: unsubscribeplugininterface.cpp:195
#, kde-format #, kde-format
msgid "Request Complete" msgid "Request Complete"
msgstr "" msgstr ""
#: unsubscribeplugininterface.cpp:159 #: unsubscribeplugininterface.cpp:196
#, kde-format #, kde-format
msgid "The unsubscribe request was successfully sent." msgid "The unsubscribe request was successfully sent."
msgstr "" msgstr ""
#: unsubscribeplugininterface.cpp:164 #: unsubscribeplugininterface.cpp:201
#, kde-format #, kde-format
msgid "Unsubscribe Error" msgid "Unsubscribe Error"
msgstr "" msgstr ""

View file

@ -137,10 +137,54 @@ void UnsubscribePluginInterface::setMessageItem(const Akonadi::Item &item)
/// @param item The new item. /// @param item The new item.
void UnsubscribePluginInterface::updateAction(const Akonadi::Item &item) void UnsubscribePluginInterface::updateAction(const Akonadi::Item &item)
{ {
qCDebug(UnsubscribePlugin) << "updateAction!?" << mActions.count() << "actions";
mUnsub.setMessageItem(item); mUnsub.setMessageItem(item);
auto status = mUnsub.unsubscribeStatus();
QAction *action = mActions.first();
QString caption;
mActions.first()->setDisabled(mUnsub.unsubscribeStatus() == UnsubscribeManager::None); switch (mUnsub.unsubscribeStatus())
{
case UnsubscribeManager::NoOneClick:
{
QString scheme = mUnsub.getUrl().scheme();
if (scheme.startsWith("http"))
{
caption = i18nc("unsubscribe via the web", "Web");
}
else if (scheme.startsWith("mailto"))
{
caption = i18nc("unsubscribe via email", "Email");
}
else
{
// Unknown, just set to
caption = scheme;
}
}
break;
case UnsubscribeManager::ValidOneClick:
case UnsubscribeManager::InvalidOneClick:
caption = i18nc("using RFC 8058 unsubscribe", "One-Click");
break;
case UnsubscribeManager::None:
default:
// Do nothing
break;
}
// Assuming we have an action, set the action up
if (action)
{
action->setDisabled(status == UnsubscribeManager::None);
if (caption.isEmpty())
{
action->setIconText(i18n("Unsubscribe"));
}
else
{
action->setIconText(i18nc("unsubscribe via %1", "Unsubscribe (%1)", caption));
}
}
} }
void UnsubscribePluginInterface::getOneClickResult(bool isSuccess, const QString &resultString) void UnsubscribePluginInterface::getOneClickResult(bool isSuccess, const QString &resultString)