Esempio n. 1
0
CMakeEditorFactory::CMakeEditorFactory(CMakeManager *manager)
    : m_mimeTypes(QStringList() << QLatin1String(CMakeProjectManager::Constants::CMAKEMIMETYPE)),
      m_manager(manager)
{
    using namespace Core;
    using namespace TextEditor;

    m_actionHandler =
            new TextEditorActionHandler(Constants::C_CMAKEEDITOR,
            TextEditorActionHandler::UnCommentSelection
            | TextEditorActionHandler::JumpToFileUnderCursor);

    ActionManager *am = ICore::actionManager();
    ActionContainer *contextMenu = am->createMenu(Constants::M_CONTEXT);
    Command *cmd;
    Context cmakeEditorContext = Context(Constants::C_CMAKEEDITOR);

    cmd = am->command(TextEditor::Constants::JUMP_TO_FILE_UNDER_CURSOR);
    contextMenu->addAction(cmd);

    QAction *separator = new QAction(this);
    separator->setSeparator(true);
    contextMenu->addAction(am->registerAction(separator,
                  Id(Constants::SEPARATOR), cmakeEditorContext));

    cmd = am->command(TextEditor::Constants::UN_COMMENT_SELECTION);
    contextMenu->addAction(cmd);
}
Esempio n. 2
0
QList <QAction *> QmlProfilerTool::profilerContextMenuActions()
{
    QList <QAction *> commonActions;
    ActionManager *manager = ActionManager::instance();
    if (manager) {
        Command *command = manager->command(Constants::QmlProfilerLoadActionId);
        if (command)
            commonActions << command->action();
        command = manager->command(Constants::QmlProfilerSaveActionId);
        if (command)
            commonActions << command->action();
    }
    return commonActions;
}
/*!
  Mimic the look of the text editor toolbar as defined in e.g. EditorView::EditorView
  */
EditorToolBar::EditorToolBar(QWidget *parent) :
        Utils::StyledBar(parent),
        m_editorList(new QComboBox(this)),
        m_closeButton(new QToolButton),
        m_lockButton(new QToolButton),

        m_goBackAction(new QAction(QIcon(QLatin1String(":/help/images/previous.png")), EditorManager::tr("Go Back"), parent)),
        m_goForwardAction(new QAction(QIcon(QLatin1String(":/help/images/next.png")), EditorManager::tr("Go Forward"), parent)),

        m_activeToolBar(0),
        m_toolBarPlaceholder(new QWidget),
        m_defaultToolBar(new QWidget(this)),
        m_isStandalone(false)
{
    QHBoxLayout *toolBarLayout = new QHBoxLayout(this);
    toolBarLayout->setMargin(0);
    toolBarLayout->setSpacing(0);
    toolBarLayout->addWidget(m_defaultToolBar);
    m_toolBarPlaceholder->setLayout(toolBarLayout);
    m_toolBarPlaceholder->setSizePolicy(QSizePolicy::MinimumExpanding, QSizePolicy::MinimumExpanding);

    m_defaultToolBar->setSizePolicy(QSizePolicy::MinimumExpanding, QSizePolicy::MinimumExpanding);
    m_activeToolBar = m_defaultToolBar;

    m_editorsListModel = EditorManager::instance()->openedEditorsModel();
    connect(m_goBackAction, SIGNAL(triggered()), this, SIGNAL(goBackClicked()));
    connect(m_goForwardAction, SIGNAL(triggered()), this, SIGNAL(goForwardClicked()));

    m_editorList->setSizePolicy(QSizePolicy::Fixed, QSizePolicy::Fixed);
    m_editorList->setMinimumContentsLength(20);
    m_editorList->setModel(m_editorsListModel);
    m_editorList->setMaxVisibleItems(40);
    m_editorList->setContextMenuPolicy(Qt::CustomContextMenu);

    m_lockButton->setAutoRaise(true);
    m_lockButton->setProperty("type", QLatin1String("dockbutton"));
    m_lockButton->setVisible(false);

    m_closeButton->setAutoRaise(true);
    m_closeButton->setIcon(QIcon(":/core/images/closebutton.png"));
    m_closeButton->setProperty("type", QLatin1String("dockbutton"));
    m_closeButton->setEnabled(false);

    m_toolBarPlaceholder->setSizePolicy(QSizePolicy::MinimumExpanding, QSizePolicy::MinimumExpanding);

    m_backButton = new QToolButton(this);
    m_backButton->setDefaultAction(m_goBackAction);

    m_forwardButton= new QToolButton(this);
    m_forwardButton->setDefaultAction(m_goForwardAction);

    QHBoxLayout *toplayout = new QHBoxLayout(this);
    toplayout->setSpacing(0);
    toplayout->setMargin(0);
    toplayout->addWidget(m_backButton);
    toplayout->addWidget(m_forwardButton);
    toplayout->addWidget(m_editorList);
    toplayout->addWidget(m_toolBarPlaceholder, 1); // Custom toolbar stretches
    toplayout->addWidget(m_lockButton);
    toplayout->addWidget(m_closeButton);

    setLayout(toplayout);

    // this signal is disconnected for standalone toolbars and replaced with
    // a private slot connection
    connect(m_editorList, SIGNAL(activated(int)), this, SIGNAL(listSelectionActivated(int)));

    connect(m_editorList, SIGNAL(customContextMenuRequested(QPoint)), this, SLOT(listContextMenu(QPoint)));
    connect(m_lockButton, SIGNAL(clicked()), this, SLOT(makeEditorWritable()));
    connect(m_closeButton, SIGNAL(clicked()), this, SLOT(closeView()), Qt::QueuedConnection);

    ActionManager *am = ICore::instance()->actionManager();
    connect(am->command(Constants::CLOSE), SIGNAL(keySequenceChanged()),
            this, SLOT(updateActionShortcuts()));
    connect(am->command(Constants::GO_BACK), SIGNAL(keySequenceChanged()),
            this, SLOT(updateActionShortcuts()));
    connect(am->command(Constants::GO_FORWARD), SIGNAL(keySequenceChanged()),
            this, SLOT(updateActionShortcuts()));

}