Commit 0dcfea32 authored by Laurent Montel's avatar Laurent Montel 😁
Browse files

Fix generate menu

parent 31da9893
cmake_minimum_required(VERSION 3.5)
set(PIM_VERSION "5.13.45")
set(PIM_VERSION "5.13.46")
if (POLICY CMP0053)
cmake_policy(SET CMP0053 NEW)
......
......@@ -31,5 +31,4 @@ void ConvertSnippetVariableMenuTest::shouldHaveDefaultValues()
{
MessageComposer::ConvertSnippetVariableMenu w(nullptr);
QVERIFY(w.menu());
QVERIFY(!w.onlyMenuForCustomizeAttachmentFileName());
}
......@@ -28,19 +28,27 @@ ConvertSnippetVariableMenu::ConvertSnippetVariableMenu(QWidget *parentWidget, QO
: QObject(parent)
, mParentWidget(parentWidget)
{
initializeMenu();
initializeMenu(false);
}
ConvertSnippetVariableMenu::ConvertSnippetVariableMenu(bool onlyMenuForCustomizeAttachmentFileName, QWidget *parentWidget, QObject *parent)
: QObject(parent)
, mParentWidget(parentWidget)
{
initializeMenu(onlyMenuForCustomizeAttachmentFileName);
}
ConvertSnippetVariableMenu::~ConvertSnippetVariableMenu()
{
}
void ConvertSnippetVariableMenu::initializeMenu()
void ConvertSnippetVariableMenu::initializeMenu(bool onlyMenuForCustomizeAttachmentFileName)
{
mMenu = new QMenu(mParentWidget);
mMenu->setFocusPolicy(Qt::NoFocus);
if (!mOnlyMenuForCustomizeAttachmentFileName) {
if (!onlyMenuForCustomizeAttachmentFileName) {
QMenu *toMenuVariable = new QMenu(i18n("To"), mMenu);
toMenuVariable->addAction(i18n("To Field Address"), this, [this]() {
Q_EMIT insertVariable(MessageComposer::ConvertSnippetVariablesUtil::ToAddr);
......@@ -164,16 +172,6 @@ void ConvertSnippetVariableMenu::initializeMenu()
mMenu->addMenu(miscVariable);
}
bool ConvertSnippetVariableMenu::onlyMenuForCustomizeAttachmentFileName() const
{
return mOnlyMenuForCustomizeAttachmentFileName;
}
void ConvertSnippetVariableMenu::setOnlyMenuForCustomizeAttachmentFileName(bool onlyMenuForCustomizeAttachmentFileName)
{
mOnlyMenuForCustomizeAttachmentFileName = onlyMenuForCustomizeAttachmentFileName;
}
QMenu *ConvertSnippetVariableMenu::menu() const
{
return mMenu;
......
......@@ -34,17 +34,14 @@ class MESSAGECOMPOSER_EXPORT ConvertSnippetVariableMenu : public QObject
Q_OBJECT
public:
explicit ConvertSnippetVariableMenu(QWidget *parentWidget, QObject *parent = nullptr);
explicit ConvertSnippetVariableMenu(bool onlyMenuForCustomizeAttachmentFileName, QWidget *parentWidget, QObject *parent = nullptr);
~ConvertSnippetVariableMenu();
QMenu *menu() const;
Q_REQUIRED_RESULT bool onlyMenuForCustomizeAttachmentFileName() const;
void setOnlyMenuForCustomizeAttachmentFileName(bool onlyMenuForCustomizeAttachmentFileName);
Q_SIGNALS:
void insertVariable(MessageComposer::ConvertSnippetVariablesUtil::VariableType type);
private:
void initializeMenu();
bool mOnlyMenuForCustomizeAttachmentFileName = false;
void initializeMenu(bool onlyMenuForCustomizeAttachmentFileName);
QWidget *mParentWidget = nullptr;
QMenu *mMenu = nullptr;
};
......
Markdown is supported
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