<commit_before>/*
 * Qumulus UML editor
 * Author: <NAME>
 *
 */

#include "ToolBarItem.h"

#include "ToolBar.h"

QUML_BEGIN_NAMESPACE_GW

ToolBarItem::ToolBarItem(ElementItem elementItem) : mElementItem(elementItem) {
    mLayout = new QHBoxLayout(this);
    mButton = new QPushButton(this);
    mDropdown = new QPushButton(this);

    mButton->setFlat(true);
    mDropdown->setFlat(true);

    mButton->setIconSize({32,32});

    mButton->setMaximumSize({32,32});
    mDropdown->setMaximumSize({9,32});

    mButton->setIcon(mElementItem.icon());
    mButton->setToolTip(mElementItem.text() + " [" + 
            mElementItem.shortcut().toString() + "]");
    mButton->setShortcut(mElementItem.shortcut());
    mDropdown->setIcon(QIcon(":/data/img/toolbar/dropdown.png"));

    mLayout->addWidget(mButton);
    mLayout->addWidget(mDropdown);
    mLayout->setContentsMargins(2,2,2,2);
    mLayout->setSpacing(2);
    setLayout(mLayout);
    mDropdown->hide();

    connect(mButton, &QPushButton::clicked, mElementItem.slot());
}

const QString ToolBarItem::text() const {
    return mElementItem.text();
}

void ToolBarItem::setMenu(ToolBarMenu* menu) {
    mMenu = menu;
    connect(mDropdown, &QPushButton::clicked, [&]{
            mMenu->exec(mButton->mapToGlobal({-2, 34}));
            });
    mDropdown->show();
}

QUML_END_NAMESPACE_GW
<commit_msg>Fix bug introduced by commit eff8eab602117e5220014f871441891fe6569a25.<commit_after>/*
 * Qumulus UML editor
 * Author: <NAME>
 *
 */

#include "ToolBarItem.h"

#include "ToolBar.h"

QUML_BEGIN_NAMESPACE_GW

ToolBarItem::ToolBarItem(ElementItem elementItem) : mElementItem(elementItem) {
    mLayout = new QHBoxLayout(this);
    mButton = new QPushButton(this);
    mDropdown = new QPushButton(this);

    mButton->setFlat(true);
    mDropdown->setFlat(true);

    mButton->setIconSize({32,32});

    mButton->setMaximumSize({32,32});
    mDropdown->setMaximumSize({9,32});

    mButton->setIcon(mElementItem.icon());
    mButton->setToolTip(mElementItem.text() + " [" + 
            mElementItem.shortcut().toString() + "]");
    mButton->setShortcut(mElementItem.shortcut());
    mDropdown->setIcon(QIcon(":/data/img/toolbar/dropdown.png"));

    mLayout->addWidget(mButton);
    mLayout->addWidget(mDropdown);
    mLayout->setContentsMargins(2,2,2,2);
    mLayout->setSpacing(2);
    setLayout(mLayout);
    mDropdown->hide();

    connect(mButton, &QPushButton::clicked, mElementItem.slot());
}

const QString ToolBarItem::text() const {
    return mElementItem.text();
}

void ToolBarItem::setMenu(ToolBarMenu* menu) {
    mDropdown->addActions(menu->actions());
    mMenu = menu;
    connect(mDropdown, &QPushButton::clicked, [&]{
            mMenu->exec(mButton->mapToGlobal({-2, 34}));});
    mDropdown->show();
}

QUML_END_NAMESPACE_GW

{'fraction_non_alphanumeric': 0.16202712348322626, 'fraction_numerical': 0.023911491791577446, 'mean_word_length': 4.339047619047619, 'pattern_counts': {'":': 2, '<': 5, '<?xml version=': 0, '>': 41, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '2751692', 'n_tokens_mistral': 1042, 'n_tokens_neox': 988, 'n_words': 124}