7#include "convertsnippetvariablemenu.h"
8#include <KLocalizedString>
11ConvertSnippetVariableMenu::ConvertSnippetVariableMenu(
bool onlyMenuForCustomizeAttachmentFileName,
QWidget *parentWidget,
QObject *parent)
13 , mParentWidget(parentWidget)
15 initializeMenu(onlyMenuForCustomizeAttachmentFileName);
18ConvertSnippetVariableMenu::~ConvertSnippetVariableMenu() =
default;
20void ConvertSnippetVariableMenu::initializeMenu(
bool onlyMenuForCustomizeAttachmentFileName)
22 QMenu *dateTimeMenuVariable =
nullptr;
23 if (!onlyMenuForCustomizeAttachmentFileName) {
24 mMenu =
new QMenu(mParentWidget);
27 auto toMenuVariable =
new QMenu(
i18n(
"To"), mMenu);
28 toMenuVariable->addAction(
i18n(
"To Field Address"),
this, [
this]() {
29 Q_EMIT insertVariable(MessageComposer::ConvertSnippetVariablesUtil::ToAddr);
31 toMenuVariable->addAction(
i18n(
"To Field Last Name"),
this, [
this]() {
32 Q_EMIT insertVariable(MessageComposer::ConvertSnippetVariablesUtil::ToLname);
34 toMenuVariable->addAction(
i18n(
"To Field First Name"),
this, [
this]() {
35 Q_EMIT insertVariable(MessageComposer::ConvertSnippetVariablesUtil::ToFname);
37 toMenuVariable->addAction(
i18n(
"To Field Name"),
this, [
this]() {
38 Q_EMIT insertVariable(MessageComposer::ConvertSnippetVariablesUtil::ToName);
42 auto fromMenuVariable =
new QMenu(
i18n(
"From"), mMenu);
43 fromMenuVariable->addAction(
i18n(
"From Field Address"),
this, [
this]() {
44 Q_EMIT insertVariable(MessageComposer::ConvertSnippetVariablesUtil::FromAddr);
46 fromMenuVariable->addAction(
i18n(
"From Field Last Name"),
this, [
this]() {
47 Q_EMIT insertVariable(MessageComposer::ConvertSnippetVariablesUtil::FromLname);
49 fromMenuVariable->addAction(
i18n(
"From Field First Name"),
this, [
this]() {
50 Q_EMIT insertVariable(MessageComposer::ConvertSnippetVariablesUtil::FromFname);
52 fromMenuVariable->addAction(
i18n(
"From Field Name"),
this, [
this]() {
53 Q_EMIT insertVariable(MessageComposer::ConvertSnippetVariablesUtil::FromName);
55 mMenu->
addMenu(fromMenuVariable);
57 auto ccMenuVariable =
new QMenu(
i18n(
"CC"), mMenu);
58 ccMenuVariable->addAction(
i18n(
"CC Field Address"),
this, [
this]() {
59 Q_EMIT insertVariable(MessageComposer::ConvertSnippetVariablesUtil::CcAddr);
61 ccMenuVariable->addAction(
i18n(
"CC Field Last Name"),
this, [
this]() {
62 Q_EMIT insertVariable(MessageComposer::ConvertSnippetVariablesUtil::CcLname);
64 ccMenuVariable->addAction(
i18n(
"CC Field First Name"),
this, [
this]() {
65 Q_EMIT insertVariable(MessageComposer::ConvertSnippetVariablesUtil::CcFname);
67 ccMenuVariable->addAction(
i18n(
"CC Field Name"),
this, [
this]() {
68 Q_EMIT insertVariable(MessageComposer::ConvertSnippetVariablesUtil::CcName);
73 auto bccMenuVariable =
new QMenu(
i18n(
"Bcc"), mMenu);
74 bccMenuVariable->addAction(
i18n(
"BCC Field Address"),
this, [
this]() {
75 Q_EMIT insertVariable(MessageComposer::ConvertSnippetVariablesUtil::BccAddr);
77 bccMenuVariable->addAction(
i18n(
"BCC Field Last Name"),
this, [
this]() {
78 Q_EMIT insertVariable(MessageComposer::ConvertSnippetVariablesUtil::BccLname);
80 bccMenuVariable->addAction(
i18n(
"BCC Field First Name"),
this, [
this]() {
81 Q_EMIT insertVariable(MessageComposer::ConvertSnippetVariablesUtil::BccFname);
83 bccMenuVariable->addAction(
i18n(
"BCC Field Name"),
this, [
this]() {
84 Q_EMIT insertVariable(MessageComposer::ConvertSnippetVariablesUtil::BccName);
87 mMenu->
addMenu(bccMenuVariable);
89 auto attachmentMenuVariable =
new QMenu(
i18n(
"Attachment"), mMenu);
90 attachmentMenuVariable->addAction(
i18n(
"Number Of Attachments"),
this, [
this]() {
91 Q_EMIT insertVariable(MessageComposer::ConvertSnippetVariablesUtil::AttachmentCount);
93 attachmentMenuVariable->addAction(
i18n(
"Names"),
this, [
this]() {
94 Q_EMIT insertVariable(MessageComposer::ConvertSnippetVariablesUtil::AttachmentName);
96 attachmentMenuVariable->addAction(
i18n(
"Filenames"),
this, [
this]() {
97 Q_EMIT insertVariable(MessageComposer::ConvertSnippetVariablesUtil::AttachmentFilenames);
99 attachmentMenuVariable->addAction(
i18n(
"Names and Sizes"),
this, [
this]() {
100 Q_EMIT insertVariable(MessageComposer::ConvertSnippetVariablesUtil::AttachmentNamesAndSizes);
102 mMenu->
addMenu(attachmentMenuVariable);
103 dateTimeMenuVariable =
new QMenu(
i18n(
"Date/Time"), mMenu);
104 dateTimeMenuVariable->
addAction(
i18n(
"Day Of Week (%1)", MessageComposer::ConvertSnippetVariablesUtil::dayOfWeek()),
this, [
this]() {
105 Q_EMIT insertVariable(MessageComposer::ConvertSnippetVariablesUtil::Dow);
107 dateTimeMenuVariable->
addAction(
i18n(
"Date (%1)", MessageComposer::ConvertSnippetVariablesUtil::shortDate()),
this, [
this]() {
108 Q_EMIT insertVariable(MessageComposer::ConvertSnippetVariablesUtil::ShortDate);
110 dateTimeMenuVariable->
addAction(
i18n(
"Long Date (%1)", MessageComposer::ConvertSnippetVariablesUtil::longDate()),
this, [
this]() {
111 Q_EMIT insertVariable(MessageComposer::ConvertSnippetVariablesUtil::Date);
113 dateTimeMenuVariable->
addAction(
i18n(
"Custom Date (%1)", MessageComposer::ConvertSnippetVariablesUtil::customDate()),
this, [
this]() {
114 Q_EMIT insertVariable(MessageComposer::ConvertSnippetVariablesUtil::CustomDate);
116 dateTimeMenuVariable->
addAction(
i18n(
"Short Time (%1)", MessageComposer::ConvertSnippetVariablesUtil::shortTime()),
this, [
this]() {
117 Q_EMIT insertVariable(MessageComposer::ConvertSnippetVariablesUtil::Time);
119 dateTimeMenuVariable->
addAction(
i18n(
"Time (%1)", MessageComposer::ConvertSnippetVariablesUtil::longTime()),
this, [
this]() {
120 Q_EMIT insertVariable(MessageComposer::ConvertSnippetVariablesUtil::TimeLong);
122 dateTimeMenuVariable->
addAction(
i18n(
"Year (%1)", MessageComposer::ConvertSnippetVariablesUtil::year()),
this, [
this]() {
123 Q_EMIT insertVariable(MessageComposer::ConvertSnippetVariablesUtil::Year);
126 dateTimeMenuVariable =
new QMenu(
i18n(
"Date/Time"), mParentWidget);
127 mMenu = dateTimeMenuVariable;
130 dateTimeMenuVariable->
addAction(
i18n(
"Last Year (%1)", MessageComposer::ConvertSnippetVariablesUtil::lastYear()),
this, [
this]() {
131 Q_EMIT insertVariable(MessageComposer::ConvertSnippetVariablesUtil::LastYear);
133 dateTimeMenuVariable->
addAction(
i18n(
"Next Year (%1)", MessageComposer::ConvertSnippetVariablesUtil::nextYear()),
this, [
this]() {
134 Q_EMIT insertVariable(MessageComposer::ConvertSnippetVariablesUtil::NextYear);
136 dateTimeMenuVariable->
addAction(
i18n(
"Month Number (%1)", MessageComposer::ConvertSnippetVariablesUtil::monthNumber()),
this, [
this]() {
137 Q_EMIT insertVariable(MessageComposer::ConvertSnippetVariablesUtil::MonthNumber);
139 dateTimeMenuVariable->
addAction(
i18n(
"Day Number (%1)", MessageComposer::ConvertSnippetVariablesUtil::dayNumber()),
this, [
this]() {
140 Q_EMIT insertVariable(MessageComposer::ConvertSnippetVariablesUtil::DayNumber);
142 dateTimeMenuVariable->
addAction(
i18n(
"Day Of Month (%1)", MessageComposer::ConvertSnippetVariablesUtil::dayOfMonth()),
this, [
this]() {
143 Q_EMIT insertVariable(MessageComposer::ConvertSnippetVariablesUtil::DayOfMonth);
145 dateTimeMenuVariable->
addAction(
i18n(
"Week Number (%1)", MessageComposer::ConvertSnippetVariablesUtil::weekNumber()),
this, [
this]() {
146 Q_EMIT insertVariable(MessageComposer::ConvertSnippetVariablesUtil::WeekNumber);
148 dateTimeMenuVariable->
addAction(
i18n(
"Month Name Short (%1)", MessageComposer::ConvertSnippetVariablesUtil::monthNameShort()),
this, [
this]() {
149 Q_EMIT insertVariable(MessageComposer::ConvertSnippetVariablesUtil::MonthNameShort);
151 dateTimeMenuVariable->
addAction(
i18n(
"Month Name Long (%1)", MessageComposer::ConvertSnippetVariablesUtil::monthNameLong()),
this, [
this]() {
152 Q_EMIT insertVariable(MessageComposer::ConvertSnippetVariablesUtil::MonthNameLong);
154 dateTimeMenuVariable->
addAction(
i18n(
"Last Month Name Long (%1)", MessageComposer::ConvertSnippetVariablesUtil::lastMonthNameLong()),
this, [
this]() {
155 Q_EMIT insertVariable(MessageComposer::ConvertSnippetVariablesUtil::LastMonthNameLong);
157 dateTimeMenuVariable->
addAction(
i18n(
"Day Of Week (%1)", MessageComposer::ConvertSnippetVariablesUtil::dayOfWeek()),
this, [
this]() {
158 Q_EMIT insertVariable(MessageComposer::ConvertSnippetVariablesUtil::DayOfWeek);
160 dateTimeMenuVariable->
addAction(
i18n(
"Day Of Week Name Short (%1)", MessageComposer::ConvertSnippetVariablesUtil::dayOfWeekNameShort()),
this, [
this]() {
161 Q_EMIT insertVariable(MessageComposer::ConvertSnippetVariablesUtil::DayOfWeekNameShort);
163 dateTimeMenuVariable->
addAction(
i18n(
"Day Of Week Name Long (%1)", MessageComposer::ConvertSnippetVariablesUtil::dayOfWeekNameLong()),
this, [
this]() {
164 Q_EMIT insertVariable(MessageComposer::ConvertSnippetVariablesUtil::DayOfWeekNameLong);
166 dateTimeMenuVariable->
addAction(
i18n(
"Year Last Month (%1)", MessageComposer::ConvertSnippetVariablesUtil::yearLastMonth()),
this, [
this]() {
167 Q_EMIT insertVariable(MessageComposer::ConvertSnippetVariablesUtil::YearLastMonth);
169 if (!onlyMenuForCustomizeAttachmentFileName) {
170 mMenu->
addMenu(dateTimeMenuVariable);
171 auto miscVariable =
new QMenu(
i18n(
"Misc"), mMenu);
172 miscVariable->addAction(
i18n(
"Subject"),
this, [
this]() {
173 Q_EMIT insertVariable(MessageComposer::ConvertSnippetVariablesUtil::FullSubject);
180QMenu *ConvertSnippetVariableMenu::menu()
const
185#include "moc_convertsnippetvariablemenu.cpp"
QString i18n(const char *text, const TYPE &arg...)
Simple interface that both EncryptJob and SignEncryptJob implement so the composer can extract some e...