Пример #1
0
PopupButton::PopupButton(QWidget* parent)
{
	//	this->setFrameStyle(QFrame::Box);

	QVBoxLayout* layout = new QVBoxLayout(this);
	layout->setMargin(0);
	this->setLayout(layout);

	//	QToolButton* expandButton = new QToolButton(this);
	QToolButton* expandButton = new CXSmallToolButton(this);
	mShowHeaderButton = expandButton;
	this->setFixedSize(expandButton->sizeHint());

	QAction* action = new QAction(QIcon(":icons/open_icon_library/layer-lower-3.png"), "Controls", this);
	QString tip = "Show Controls";
	action->setStatusTip(tip);
	action->setWhatsThis(tip);
	action->setToolTip(tip);
	connect(action, SIGNAL(triggered()), this, SLOT(onTriggered()));
	mAction = action;

	mShowHeaderButton->setDefaultAction(action);
	layout->addWidget(mShowHeaderButton);

	action->setCheckable(true);
}
Пример #2
0
	///
	/// Constructor From Data
	///
	BarcodeMenuItem::BarcodeMenuItem( const BarcodeStyle& bcStyle, QObject* parent )
		: QAction(parent), mBcStyle(bcStyle)
	{
		setText( bcStyle.name() );

		connect( this, SIGNAL(triggered()), this, SLOT(onTriggered()) );
	}
Пример #3
0
RemoveBookmarkAction::RemoveBookmarkAction( const QIcon& icon, const char* name, QObject* parent, QListWidget* bookmarksList, QListWidgetItem* removedItem )
   : QAction( icon, name, parent )
   , m_bookmarksList( bookmarksList )
   , m_removedItem( removedItem )
{
   connect( this, SIGNAL( triggered() ), this, SLOT( onTriggered() ) );
}
Пример #4
0
AddBookmarkAction::AddBookmarkAction( const QIcon& icon, const char* name, QObject* parent, const FilePath& relativePath, ResourcesBrowser& browser )
   : QAction( icon, name, parent )
   , m_relativePath( relativePath )
   , m_browser( browser )
{
   connect( this, SIGNAL( triggered() ), this, SLOT( onTriggered() ) );
}
Пример #5
0
SaveResourceAction::SaveResourceAction( const QIcon& icon, const char* name, QObject* parent, Resource& resource, bool recursive )
   : QAction( icon, name, parent )
   , m_resource( resource )
   , m_recursive( recursive )
{
   connect( this, SIGNAL( triggered() ), this, SLOT( onTriggered() ) );
}
ContextMenuExistingTagAction::ContextMenuExistingTagAction(KoResource* resource, QString tag, QObject* parent)
    : QAction(parent)
    , m_resource(resource)
    , m_tag(tag)
{
    setText(tag);
    connect (this, SIGNAL(triggered()),
             this, SLOT(onTriggered()));
}
Пример #7
0
ManageProjectDirAction::ManageProjectDirAction( const QIcon& icon, const char* name, QObject* parent, Project* project, const FilePath& relativePath, bool add )
   : QAction( icon, name, parent )
   , m_project( project )
   , m_relativePath( relativePath )
   , m_add( add )
{
   connect( this, SIGNAL( triggered() ), this, SLOT( onTriggered() ) );

}
NewTagAction::NewTagAction(KoResource* resource, QMenu* parent)
    :KoLineEditAction (parent)
{
    m_resource = resource;
    setIcon(koIcon("document-new"));
    setPlaceholderText(i18n("New tag"));
    closeParentOnTrigger(true);

    connect (this, SIGNAL(triggered(QString)),
             this, SLOT(onTriggered(QString)));
}
 AnnotationProcessorAction::AnnotationProcessorAction(AnnotationProcessor * factory,
                                                      Spine::DocumentHandle document,
                                                      Spine::AnnotationSet annotations,
                                                      QObject * parent)
     : QAction(parent), factory(factory), document(document), annotations(annotations)
 {
     static QRegExp sep("\\s*\\|\\s*");
     setText(factory->title(document, annotations).section(sep, -1, -1, QString::SectionSkipEmpty));
     setIcon(factory->icon(document, annotations));
     connect(this, SIGNAL(triggered()), this, SLOT(onTriggered()));
 }
KoLineEditAction::KoLineEditAction(QObject* parent)
    : QWidgetAction(parent)
    , m_closeParentOnTrigger(false)
{
    QWidget* pWidget = new QWidget (NULL);
    QHBoxLayout* pLayout = new QHBoxLayout();
    m_label = new QLabel(NULL);
    m_editBox = new KLineEdit(NULL);
    pLayout->addWidget(m_label);
    pLayout->addWidget(m_editBox);
    pWidget->setLayout(pLayout);
    setDefaultWidget(pWidget);

    connect (m_editBox, SIGNAL(returnPressed(QString)),
             this, SLOT(onTriggered(QString)));
}
Пример #11
0
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);
        for (std::size_t j = 0; j < groupingSplit.size(); ++j) {
            shortcutGroup.push_back( QLatin1Char('/') );
            shortcutGroup.push_back(QString::fromUtf8(groupingSplit[j].c_str()));
        }
        {
            // If the plug-in has a shortcut get it

            std::list<QKeySequence> keybinds = getKeybind(shortcutGroup, QString::fromUtf8(internalPlugin->getPluginID().c_str()));
            if (!keybinds.empty()) {
                defaultNodeShortcut = keybinds.front();
            }
        }

        QAction* defaultPresetAction = new QAction(this);
        defaultPresetAction->setShortcut(defaultNodeShortcut);
        defaultPresetAction->setShortcutContext(Qt::WidgetShortcut);
        defaultPresetAction->setText(QString::fromUtf8(pluginLabel.c_str()));
        defaultPresetAction->setIcon( pluginsToolButton->getMenuIcon() );
        QObject::connect( defaultPresetAction, SIGNAL(triggered()), pluginsToolButton, SLOT(onTriggered()) );


        const std::vector<PluginPresetDescriptor>& presets = internalPlugin->getPresetFiles();
        if (presets.empty()) {
            // If the node has no presets, just make an action, otherwise make a menu
            pluginsToolButton->setAction(defaultPresetAction);
        } else {


            Menu* menu = new Menu(this);
            menu->setTitle( pluginsToolButton->getLabel() );
            menu->setIcon(menuIcon);
            pluginsToolButton->setMenu(menu);
            pluginsToolButton->setAction( menu->menuAction() );

            defaultPresetAction->setText(QString::fromUtf8(pluginLabel.c_str()) + tr(" (Default)"));
            menu->addAction(defaultPresetAction);

            for (std::vector<PluginPresetDescriptor>::const_iterator it = presets.begin(); it!=presets.end(); ++it) {

                QKeySequence presetShortcut;
                {
                    // If the preset has a shortcut get it

                    std::string shortcutKey = internalPlugin->getPluginID();
                    shortcutKey += "_preset_";
                    shortcutKey += it->presetLabel.toStdString();

                    std::list<QKeySequence> keybinds = getKeybind(shortcutGroup, QString::fromUtf8(shortcutKey.c_str()));
                    if (!keybinds.empty()) {
                        presetShortcut = keybinds.front();
                    }
                }

                QString presetLabel = QString::fromUtf8(pluginLabel.c_str());
                presetLabel += QLatin1String(" (");
                presetLabel += it->presetLabel;
                presetLabel += QLatin1String(")");

                QAction* presetAction = new QAction(this);
                QPixmap presetPix;
                if (getPresetIcon(it->presetFilePath, it->presetIconFile, TO_DPIX(NATRON_MEDIUM_BUTTON_ICON_SIZE), &presetPix)) {
                    presetAction->setIcon( presetPix );
                }
                presetAction->setShortcut(presetShortcut);
                presetAction->setShortcutContext(Qt::WidgetShortcut);
                presetAction->setText(presetLabel);
                presetAction->setData(it->presetLabel);
                QObject::connect( presetAction, SIGNAL(triggered()), pluginsToolButton, SLOT(onTriggered()) );

                menu->addAction(presetAction);
            }
        }

    } // if (!treeNode->getChildren().empty())

    // If it has a parent, add the new tool button as a child
    if (parentToolButton) {
        parentToolButton->tryAddChild(pluginsToolButton);
    }
    _imp->_toolButtons.push_back(pluginsToolButton);

    return pluginsToolButton;
} // findOrCreateToolButton