当前位置: 首页>>代码示例>>C++>>正文


C++ ToolButton::getLabel方法代码示例

本文整理汇总了C++中ToolButton::getLabel方法的典型用法代码示例。如果您正苦于以下问题:C++ ToolButton::getLabel方法的具体用法?C++ ToolButton::getLabel怎么用?C++ ToolButton::getLabel使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在ToolButton的用法示例。


在下文中一共展示了ToolButton::getLabel方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。

示例1: pix

ToolButton*
Gui::findOrCreateToolButton(const PluginGroupNodePtr & treeNode)
{

    // Do not create an action for non user creatable plug-ins
    bool isUserCreatable = true;
    PluginPtr internalPlugin = treeNode->getPlugin();
    if (internalPlugin && treeNode->getChildren().empty() && !internalPlugin->getIsUserCreatable()) {
        isUserCreatable = false;
    }
    if (!isUserCreatable) {
        return 0;
    }

    // Check for existing toolbuttons
    for (std::size_t i = 0; i < _imp->_toolButtons.size(); ++i) {
        if (_imp->_toolButtons[i]->getPluginToolButton() == treeNode) {
            return _imp->_toolButtons[i];
        }
    }

    // Check for parent toolbutton
    ToolButton* parentToolButton = NULL;
    if ( treeNode->getParent() ) {
        assert(treeNode->getParent() != treeNode);
        if (treeNode->getParent() != treeNode) {
            parentToolButton = findOrCreateToolButton( treeNode->getParent() );
        }
    }

    QString resourcesPath;
    if (internalPlugin) {
        resourcesPath = QString::fromUtf8(internalPlugin->getProperty<std::string>(kNatronPluginPropResourcesPath).c_str());
    }
    QString iconFilePath = resourcesPath;
    StrUtils::ensureLastPathSeparator(iconFilePath);
    iconFilePath += treeNode->getTreeNodeIconFilePath();

    QIcon toolButtonIcon, menuIcon;
    // Create tool icon
    if ( !iconFilePath.isEmpty() && QFile::exists(iconFilePath) ) {
        QPixmap pix(iconFilePath);
        int menuSize = TO_DPIX(NATRON_MEDIUM_BUTTON_ICON_SIZE);
        int toolButtonSize = !treeNode->getParent() ? TO_DPIX(NATRON_TOOL_BUTTON_ICON_SIZE) : TO_DPIX(NATRON_MEDIUM_BUTTON_ICON_SIZE);
        QPixmap menuPix = pix, toolbuttonPix = pix;
        if ( (std::max( menuPix.width(), menuPix.height() ) != menuSize) && !menuPix.isNull() ) {
            menuPix = menuPix.scaled(menuSize, menuSize, Qt::KeepAspectRatio, Qt::SmoothTransformation);
        }
        if ( (std::max( toolbuttonPix.width(), toolbuttonPix.height() ) != toolButtonSize) && !toolbuttonPix.isNull() ) {
            toolbuttonPix = toolbuttonPix.scaled(toolButtonSize, toolButtonSize, Qt::KeepAspectRatio, Qt::SmoothTransformation);
        }
        menuIcon.addPixmap(menuPix);
        toolButtonIcon.addPixmap(toolbuttonPix);
    } else {
        // Set default icon only if it has no parent, otherwise leave action without an icon
        if ( !treeNode->getParent() ) {
            QPixmap toolbuttonPix, menuPix;
            getPixmapForGrouping( &toolbuttonPix, TO_DPIX(NATRON_TOOL_BUTTON_ICON_SIZE), treeNode->getTreeNodeName() );
            toolButtonIcon.addPixmap(toolbuttonPix);
            getPixmapForGrouping( &menuPix, TO_DPIX(NATRON_TOOL_BUTTON_ICON_SIZE), treeNode->getTreeNodeName() );
            menuIcon.addPixmap(menuPix);
        }
    }

    // If the tool-button has no children, this is a leaf, we must create an action
    // At this point any plug-in MUST be in a toolbutton, so it must have a parent.
    assert(!treeNode->getChildren().empty() || treeNode->getParent());

    int majorVersion = internalPlugin ? internalPlugin->getProperty<unsigned int>(kNatronPluginPropVersion, 0) : 1;
    int minorVersion = internalPlugin ? internalPlugin->getProperty<unsigned int>(kNatronPluginPropVersion, 1) : 0;

    ToolButton* pluginsToolButton = new ToolButton(getApp(),
                                                   treeNode,
                                                   treeNode->getTreeNodeID(),
                                                   majorVersion,
                                                   minorVersion,
                                                   treeNode->getTreeNodeName(),
                                                   toolButtonIcon,
                                                   menuIcon);

    if (!treeNode->getChildren().empty()) {
        // For grouping items, create the menu
        Menu* menu = new Menu(this);
        menu->setTitle( pluginsToolButton->getLabel() );
        menu->setIcon(menuIcon);
        pluginsToolButton->setMenu(menu);
        pluginsToolButton->setAction( menu->menuAction() );
    } else {
        // This is a leaf (plug-in)
        assert(internalPlugin);
        assert(parentToolButton);

        // If this is the highest major version for this plug-in use normal label, otherwise also append the major version
        bool isHighestMajorVersionForPlugin = internalPlugin->getIsHighestMajorVersion();

        std::string pluginLabel = !isHighestMajorVersionForPlugin ? internalPlugin->getLabelVersionMajorEncoded() : internalPlugin->getLabelWithoutSuffix();

        QKeySequence defaultNodeShortcut;
        QString shortcutGroup = QString::fromUtf8(kShortcutGroupNodes);
        std::vector<std::string> groupingSplit = internalPlugin->getPropertyN<std::string>(kNatronPluginPropGrouping);
//.........这里部分代码省略.........
开发者ID:azerupi,项目名称:Natron,代码行数:101,代码来源:Gui20.cpp


注:本文中的ToolButton::getLabel方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。