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 ""
"Project-Id-Version: 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"
"Last-Translator: FULL NAME <EMAIL@ADDRESS>\n"
"Language-Team: LANGUAGE <LL@li.org>\n"
@ -32,69 +32,93 @@ msgstr ""
msgid "Plugin hit an unreachable point"
msgstr ""
#: unsubscribeplugininterface.cpp:59
#, 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
#: unsubscribeplugininterface.cpp:37 unsubscribeplugininterface.cpp:181
#, kde-format
msgid "Unsubscribe"
msgstr ""
#: unsubscribeplugininterface.cpp:146
#: unsubscribeplugininterface.cpp:38
#, kde-format
msgid ""
"Allows you to unsubscribe from a mailing list, if the sender supports One-"
"Click Unsubscribe"
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
msgid "Request Complete"
msgstr ""
#: unsubscribeplugininterface.cpp:159
#: unsubscribeplugininterface.cpp:196
#, kde-format
msgid "The unsubscribe request was successfully sent."
msgstr ""
#: unsubscribeplugininterface.cpp:164
#: unsubscribeplugininterface.cpp:201
#, kde-format
msgid "Unsubscribe Error"
msgstr ""

View file

@ -137,10 +137,54 @@ void UnsubscribePluginInterface::setMessageItem(const Akonadi::Item &item)
/// @param item The new item.
void UnsubscribePluginInterface::updateAction(const Akonadi::Item &item)
{
qCDebug(UnsubscribePlugin) << "updateAction!?" << mActions.count() << "actions";
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)