Ejemplo n.º 1
0
static int DoAction(lua_State *L) {
	const char* name = lua_tostring(L, -1);
	ActionManager* actionManager = App::getActionManager();
	actionManager->Do(name);
	lua_pop(L, 1);
	return 0;
}
Ejemplo n.º 2
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);
}
Ejemplo n.º 3
0
void ModeManager::objectAdded(QObject *obj)
{
    IMode *mode = Aggregation::query<IMode>(obj);
    if (!mode)
        return;

    m_mainWindow->addContextObject(mode);

    // Count the number of modes with a higher priority
    int index = 0;
    foreach (const IMode *m, m_modes)
        if (m->priority() > mode->priority())
            ++index;

    m_modes.insert(index, mode);
    m_modeStack->insertTab(index, mode->widget(), mode->icon(), mode->name());

    // Register mode shortcut
    ActionManager *am = m_mainWindow->actionManager();
    const QString shortcutId = QLatin1String("GCS.Mode.") + mode->uniqueModeName();
    QShortcut *shortcut = new QShortcut(m_mainWindow);
    shortcut->setWhatsThis(tr("Switch to %1 mode").arg(mode->name()));
    Command *cmd = am->registerShortcut(shortcut, shortcutId, QList<int>() << Constants::C_GLOBAL_ID);

    m_modeShortcuts.insert(index, cmd);
    connect(cmd, SIGNAL(keySequenceChanged()), this, SLOT(updateModeToolTip()));

    setDefaultKeyshortcuts();

    m_signalMapper->setMapping(shortcut, mode->uniqueModeName());
    connect(shortcut, SIGNAL(activated()), m_signalMapper, SLOT(map()));
}
Ejemplo n.º 4
0
static int RegisterAction(lua_State *L) {
	const char* name = lua_tostring(L, -2);
	const char* code = lua_tostring(L, -1);
	ActionManager* actionManager = App::getActionManager();
	actionManager->Register(name, code);
	lua_pop(L, 2);
	return 0;
}
Ejemplo n.º 5
0
BOOL MenuManager::HandleGeneralCommands(MenuCommandsEnum cmd)
{
	TRACEST(_T("MenuManager::HandleGeneralCommands"), cmd);
	PrgAPI* pAPI = PRGAPI();
	ActionManager* pAM = pAPI->GetActionManager();
	switch (cmd)
	{
	case MENU_Exit:
		AfxGetMainWnd()->PostMessage(WM_QUIT);
		break;
	case MENU_ShowMainWindow:
		pAM->ShowMainWindow();
		break;
	case MENU_ShowMiniPlayer:
		pAPI->GetMiniPlayerDlg(TRUE)->ShowWindow(TRUE);
		break;
	case MENU_HideMiniPlayer:
		{
			CMiniPlayerDlg* pMPDlg = pAPI->GetMiniPlayerDlg(FALSE);
			if (pMPDlg)
				pMPDlg->ShowWindow(SW_HIDE);
		}
		break;
	//case MENU_ToggleMiniPlayer:
	//	pAPI->GetActionManager()->ShowMiniPlayer(!pAPI->GetActionManager()->IsMiniPlayerVisible());
	//	break;
	case MENU_ShowAboutDlg:
		pAM->ShowAboutDlg(AfxGetMainWnd());
		break;
	case MENU_ShowHistoryDlg:
		pAM->ShowHistoryDlg(AfxGetMainWnd());
		break;
	case MENU_ShowGamesDlg:
		pAM->ShowGamesDlg(AfxGetMainWnd());
		break;
	case MENU_ShowAdvancedSearch:
		pAPI->GetAdvancedSearchDlg()->ShowWindow(SW_SHOW);
		break;
	case MENU_ShowOptionsDlg:
		pAM->ShowOptionsDlg(AfxGetMainWnd());
		break;
	case MENU_ShowCollectionsDlg:
		pAM->ShowCollectionsDlg(AfxGetMainWnd());
		break;
	case MENU_UpdateLocalCollections:
		pAPI->GetCollectionManager()->RefreshLocalCollections(TRUE, FALSE, TRUE);
		break;
	case MENU_ShowSkinsDialog:
		pAM->ShowSkinsDlg(AfxGetMainWnd());
		break;
	case MENU_ShowLanguagesDialog:
		pAM->ShowLanguagesDlg(AfxGetMainWnd());
		break;
	default:
		return FALSE;
	}
	return TRUE;

}
Ejemplo n.º 6
0
void Pipe::addPipe(float dt)
{
    SpriteFrameCache *pFrameCache = SpriteFrameCache::getInstance();
    auto pipe_up = Sprite::createWithSpriteFrame(pFrameCache->getSpriteFrameByName("pipe_up.png"));
    pipe_up->setPosition(Point(pipe_up->getContentSize().width/2,pipe_up->getContentSize().height/2));
    auto body_up=PhysicsBody::create();
    auto body_shape_up=PhysicsShapeBox::create(pipe_up->getContentSize());
    body_up->addShape(body_shape_up);
    body_up->setDynamic(false);
    body_up->setGravityEnable(false);
    body_up->setCategoryBitmask(1);
    body_up->setCollisionBitmask(-1);
    body_up->setContactTestBitmask(-1);
    pipe_up->setPhysicsBody(body_up);
    
    //向下管道初始化,这边的THROUGH_HEIGHT是两根管道之间的空隙
    auto pipe_down = Sprite::createWithSpriteFrame(pFrameCache->getSpriteFrameByName("pipe_down.png"));
    pipe_down->setPosition(Point(pipe_down->getContentSize().width/2,pipe_down->getContentSize().height/2+pipe_up->getContentSize().height+THROUGH_HEIGHT));
    auto body_down=PhysicsBody::create();
    auto body_shape_down=PhysicsShapeBox::create(pipe_down->getContentSize());
    body_down->addShape(body_shape_down);
    body_down->setDynamic(false);
    body_down->setGravityEnable(false);
    body_down->setCategoryBitmask(1);
    body_down->setCollisionBitmask(-1);
    body_down->setContactTestBitmask(-1);
    pipe_down->setPhysicsBody(body_down);
    
    //这边的node相当于一个容器把这两个管道封装在一个节点中并设置target
    auto node=Node::create();
    node->addChild(pipe_up,0,PIPE_UP);
    node->addChild(pipe_down,0,PIPE_DOWN);
    node->setAnchorPoint(Point::ANCHOR_BOTTOM_LEFT);
    
    //关于管道Y坐标的设置(就是管道上下长度不一样的处理),大家还是看图例,说不清楚
    //管道是从右边移动到左边,所以PIPE_X的值肯定比游戏的width要大这里设定是300
    int range=rand()%PIPE_RANGE;
    node->setPosition(Point(PIPE_X, PIPE_Y + range));
    
    ActionManager *pActionManager = Director::getInstance()->getActionManager();
    MoveBy *pMoveBy = MoveBy::create(3.2f, Point(-400, 0));
    CallFuncN *pMoveOverCallback = CallFuncN::create(CC_CALLBACK_1(Pipe::moveOverHandle, this));
    ActionInterval *pSeq = Sequence::create(pMoveBy, pMoveOverCallback, nullptr);
    pActionManager->addAction(pSeq, node, false);
    
    this->addChild(node);
    pPipeVector.pushBack(node);
    if (isStart) {
        scheduleUpdate();
        isStart = false;
    }
}
Ejemplo n.º 7
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;
}
Ejemplo n.º 8
0
BOOL CQuizRunningDlg::DisplayNextQuestion()
{
	TRACEST(_T("CQuizRunningDlg::DisplayNextQuestion"));
	PrgAPI* pAPI = PRGAPI();
	ActionManager* pAM = pAPI->GetActionManager();
	TracksFilter tf;
	tf.Duration.match = NUMM_Over;
	tf.Duration.val = 30;
	FullTrackRecordCollection col;
	if (!pAM->GetRandomTrackCollection(col, tf, 4))
		return FALSE;
	UINT trackLength = 0;
	TCHAR trackPath[MAX_PATH];
	m_correctAnswer = INT((rand() * 4) / RAND_MAX);
	FullTrackRecordSP rec;
	for (int i = 0; i < 4; i++)
	{
		TCHAR txt[1000];
		_sntprintf(txt, 1000, _T("%d. %s - %s"), i + 1, col[i]->artist.name.c_str(),col[i]->track.name.c_str());
		m_pButtons[i + BT_Answer1]->SetWindowText(txt);
		if (m_correctAnswer == i)
		{
			_tcsncpy(trackPath, col[i]->track.location.c_str(), MAX_PATH);
			trackLength = col[i]->track.duration;
		}
		m_pButtons[i + BT_Answer1]->ShowWindow(TRUE);
	}

	m_subTitle.SetWindowText(PRGAPI()->GetString(IDS_RECOGNISESONG));
	if (!m_pPlayer->Play(trackPath))
	{
		TRACE(_T("@1CQuizRunningDlg::DisplayNextQuestion. Cannot play the file '%s'\r\n"), trackPath);
		return FALSE;
	}
	m_pPlayer->Pause();
	trackLength = INT(m_pPlayer->GetMediaLength());
	if (trackLength < 20)
	{
		TRACE(_T("@1CQuizRunningDlg::DisplayNextQuestion. trackLength is %d '%s'\r\n"), trackLength, trackPath);
		return FALSE;
	}
	m_subTitle.SetColor(CLabelEx::COL_Text, RGB(200,200,200));
	UINT startSec = (trackLength - 40) * rand() / RAND_MAX + 20;//Select 20sec in the track after the first 20 sec
	m_pPlayer->SetVolume(95);
	m_pPlayer->SetMediaPos((DOUBLE) startSec);


	return TRUE;
}
Ejemplo n.º 9
0
	//--------------------------------------------------------------------------------------------------------------------------------------
	void EditCamera::OnActionInput( ActionManager& am )
	{
		//if( am.isTouch() && am.isMove() )
		//{
		//	if( am.isTowPoint() )
		//	{
		//		float d = am.DistanceTowPoint() - am.LastDistanceTowPoint();
		//		this->ZoomInOut( d );
		//		//DEBUGLOG("Camera zoom\n",1);
		//	}
		//	else
		//	{
		//		float xd = -( am.TouchPoint().m_x - am.LastTouchPoint().m_x ) / 2.0;//TouchPoint是(-1,1)区间的
		//		float yd = -( am.TouchPoint().m_y - am.LastTouchPoint().m_y ) / 2.0;
		//		this->Rotate(xd,yd);
		//		//DEBUGLOG("Camera Rotate\n",1);
		//	}
		//}
		{
			vector3f move;
			bool isMove = false;
			float movedis = m_MoveSpeed * Engine::Instance().GetTimeSpan() / 1000.0f;
			if( am.isAction( ActionManager::ACTION_MOVEFORWARD ) )
			{
				isMove = true;
				move += vector3f( 0, 0, -movedis );
			}
			if( am.isAction( ActionManager::ACTION_MOVEBACK ) )
			{
				isMove = true;
				move += vector3f( 0, 0, movedis );
			}
			if( am.isAction( ActionManager::ACTION_MOVELRIGHT ) )
			{
				isMove = true;
				move += vector3f( movedis, 0, 0 );
			}
			if( am.isAction( ActionManager::ACTION_MOVELEFT ) )
			{
				isMove = true;
				move += vector3f( -movedis, 0, 0 );
			}
			if( isMove )
			{
				this->Move( move );
			}
		}
	}
Ejemplo n.º 10
0
void ModeManager::objectAdded(QObject *obj)
{
    IMode *mode = Aggregation::query<IMode>(obj);
    if (!mode)
        return;

    d->m_mainWindow->addContextObject(mode);

    // Count the number of modes with a higher priority
    int index = 0;
    foreach (const IMode *m, d->m_modes)
        if (m->priority() > mode->priority())
            ++index;

    d->m_modes.insert(index, mode);
    d->m_modeStack->insertTab(index, mode->widget(), mode->icon(), mode->displayName());
    d->m_modeStack->setTabEnabled(index, mode->isEnabled());

    // Register mode shortcut
    ActionManager *am = d->m_mainWindow->actionManager();
    const QString shortcutId = QLatin1String("QtCreator.Mode.") + mode->id();
    QShortcut *shortcut = new QShortcut(d->m_mainWindow);
    shortcut->setWhatsThis(tr("Switch to <b>%1</b> mode").arg(mode->displayName()));
    Command *cmd = am->registerShortcut(shortcut, shortcutId, Context(Constants::C_GLOBAL));

    d->m_modeShortcuts.insert(index, cmd);
    connect(cmd, SIGNAL(keySequenceChanged()), this, SLOT(updateModeToolTip()));
    for (int i = 0; i < d->m_modeShortcuts.size(); ++i) {
        Command *currentCmd = d->m_modeShortcuts.at(i);
        // we need this hack with currentlyHasDefaultSequence
        // because we call setDefaultShortcut multiple times on the same cmd
        // and still expect the current shortcut to change with it
        bool currentlyHasDefaultSequence = (currentCmd->keySequence()
                                            == currentCmd->defaultKeySequence());
#ifdef Q_WS_MAC
        currentCmd->setDefaultKeySequence(QKeySequence(QString("Meta+%1").arg(i+1)));
#else
        currentCmd->setDefaultKeySequence(QKeySequence(QString("Ctrl+%1").arg(i+1)));
#endif
        if (currentlyHasDefaultSequence)
            currentCmd->setKeySequence(currentCmd->defaultKeySequence());
    }

    d->m_signalMapper->setMapping(shortcut, mode->id());
    connect(shortcut, SIGNAL(activated()), d->m_signalMapper, SLOT(map()));
    connect(mode, SIGNAL(enabledStateChanged(bool)),
            this, SLOT(enabledStateChanged()));
}
Ejemplo n.º 11
0
void CHistTracksListCtrl::ExecuteTracks(BOOL enqueue)
{
	FullTrackRecordCollection col;
	POSITION pos = GetFirstSelectedItemPosition();
	while (pos)
		GetFullTrackRecordCollectionByItemID(col, GetNextSelectedItem(pos), 1);
	if (!col.empty())
	{
		ActionManager* am = PRGAPI()->GetActionManager();
		MediaPlayer* mp = PRGAPI()->GetMediaPlayer();
		if (enqueue)
			am->Enqueue(mp, col);
		else
			am->Play(mp, col);
	}

}
Ejemplo n.º 12
0
void TreeView::setupToolbar()
{
	ActionManager *ac = Controller::create()->getActionManager();
	toolbar = new QToolBar();

	addRowAction = ac->getGlobalAction(Actions::ADD_NODE);
	toolbar->addAction(addRowAction);
	connect(addRowAction, SIGNAL(triggered()), this, SLOT(addRow()));

	addChildAction = ac->getGlobalAction(Actions::ADD_SUBNODE);
	toolbar->addAction(addChildAction);
	connect(addChildAction, SIGNAL(triggered()), this, SLOT(addChild()));

	removeAction = ac->getGlobalAction(Actions::REMOVE_NODE);
	toolbar->addAction(removeAction);
	connect(removeAction, SIGNAL(triggered()), questionFrame, SLOT(show()));

	toolbar->addSeparator();

	propertyAction = ac->getGlobalAction(Actions::SHOW_NODE_PROPERTIES);
	toolbar->addAction(propertyAction);
	connect(propertyAction, SIGNAL(triggered()), Controller::create()->getNodePropertyWidget(), SLOT(show()));

	welcomeAction = ac->getGlobalAction(Actions::SHOW_WELCOMEVIEW);
	toolbar->addAction(welcomeAction);
	connect(welcomeAction, SIGNAL(triggered(bool)), this, SLOT(showWelcomeView()));
}
Ejemplo n.º 13
0
void NavigationWidget::objectAdded(QObject * obj)
{
    INavigationWidgetFactory *factory = Aggregation::query<INavigationWidgetFactory>(obj);
    if (!factory)
        return;

    ICore *core = ICore::instance();
    ActionManager *am = core->actionManager();
    QList<int> navicontext = QList<int>() << core->uniqueIDManager()->
        uniqueIdentifier(Core::Constants::C_NAVIGATION_PANE);

    QString displayName = factory->displayName();
    QShortcut *shortcut = new QShortcut(this);
    shortcut->setWhatsThis(tr("Activate %1 Pane").arg(displayName));
    Core::Command *cmd = am->registerShortcut(shortcut,
        QLatin1String("QtCreator.Sidebar.") + displayName, navicontext);
    cmd->setDefaultKeySequence(factory->activationSequence());
    connect(shortcut, SIGNAL(activated()), this, SLOT(activateSubWidget()));

    m_shortcutMap.insert(shortcut, displayName);
    m_commandMap.insert(displayName, cmd);
}
Ejemplo n.º 14
0
	//--------------------------------------------------------------------------------------------------------------------------------------
	void TrackballCamera::OnActionInput( ActionManager& am )
	{
		if( am.isTouch() && am.isMove() )
		{
			if( am.isTowPoint() )
			{
				float d = am.DistanceTowPoint() - am.LastDistanceTowPoint();
				this->ZoomInOut( d );
				//DEBUGLOG("Camera zoom\n",1);
			}
			else
			{
				float xd = -( am.TouchPoint().m_x - am.LastTouchPoint().m_x ) / 2.0;//TouchPoint是(-1,1)区间的
				float yd = -( am.TouchPoint().m_y - am.LastTouchPoint().m_y ) / 2.0;
				this->Rotate(xd,yd);
				//DEBUGLOG("Camera Rotate\n",1);
			}
		}
	}
Ejemplo n.º 15
0
void VcsManager::registerActions()
{
    ActionManager *manager = ActionManager::instance();

    ActionContainer* mVcs = manager->createMenu("VCS");

    manager->actionContainer(Constants::MENU_BAR)->addMenu(mVcs, Constants::M_VCS);

    QAction* commitChanges = new QAction("Commit changes...");
    manager->registerAction(commitChanges);

    QAction* updateProject = new QAction("Update project...");
    manager->registerAction(updateProject);


    QAction* createPatch = new QAction("Create Patch...");
    manager->registerAction(updateProject);

    QAction* applyPatch = new QAction("Apply Patch...");
    manager->registerAction(applyPatch);


}
Ejemplo n.º 16
0
QmlProfilerTool::QmlProfilerTool(QObject *parent)
    : IAnalyzerTool(parent), d(new QmlProfilerToolPrivate(this))
{
    setObjectName("QmlProfilerTool");

    d->m_profilerState = 0;
    d->m_viewContainer = 0;
    d->m_runConfiguration = 0;

    qmlRegisterType<QmlProfilerCanvas>("Monitor", 1, 0, "Canvas2D");
    qmlRegisterType<Context2D>();
    qmlRegisterType<CanvasGradient>();
    qmlRegisterType<TimelineRenderer>("Monitor", 1, 0,"TimelineRenderer");

    d->m_profilerState = new QmlProfilerStateManager(this);
    connect(d->m_profilerState, SIGNAL(stateChanged()), this, SLOT(profilerStateChanged()));
    connect(d->m_profilerState, SIGNAL(clientRecordingChanged()), this, SLOT(clientRecordingChanged()));
    connect(d->m_profilerState, SIGNAL(serverRecordingChanged()), this, SLOT(serverRecordingChanged()));

    d->m_profilerConnections = new QmlProfilerClientManager(this);
    d->m_profilerConnections->registerProfilerStateManager(d->m_profilerState);

    d->m_profilerDataModel = new QmlProfilerDataModel(this);
    connect(d->m_profilerDataModel, SIGNAL(stateChanged()), this, SLOT(profilerDataModelStateChanged()));
    connect(d->m_profilerDataModel, SIGNAL(error(QString)), this, SLOT(showErrorDialog(QString)));
    connect(d->m_profilerConnections, SIGNAL(addRangedEvent(int,qint64,qint64,QStringList,QmlJsDebugClient::QmlEventLocation)), d->m_profilerDataModel, SLOT(addRangedEvent(int,qint64,qint64,QStringList,QmlJsDebugClient::QmlEventLocation)));
    connect(d->m_profilerConnections, SIGNAL(addV8Event(int,QString,QString,int,double,double)), d->m_profilerDataModel, SLOT(addV8Event(int,QString,QString,int,double,double)));
    connect(d->m_profilerConnections, SIGNAL(addFrameEvent(qint64,int,int)), d->m_profilerDataModel, SLOT(addFrameEvent(qint64,int,int)));
    connect(d->m_profilerConnections, SIGNAL(traceStarted(qint64)), d->m_profilerDataModel, SLOT(setTraceStartTime(qint64)));
    connect(d->m_profilerConnections, SIGNAL(traceFinished(qint64)), d->m_profilerDataModel, SLOT(setTraceEndTime(qint64)));
    connect(d->m_profilerConnections, SIGNAL(dataReadyForProcessing()), d->m_profilerDataModel, SLOT(complete()));


    d->m_detailsRewriter = new QmlProfilerDetailsRewriter(this);
    connect(d->m_profilerDataModel, SIGNAL(requestDetailsForLocation(int,QmlJsDebugClient::QmlEventLocation)),
            d->m_detailsRewriter, SLOT(requestDetailsForLocation(int,QmlJsDebugClient::QmlEventLocation)));
    connect(d->m_detailsRewriter, SIGNAL(rewriteDetailsString(int,QmlJsDebugClient::QmlEventLocation,QString)),
            d->m_profilerDataModel, SLOT(rewriteDetailsString(int,QmlJsDebugClient::QmlEventLocation,QString)));
    connect(d->m_detailsRewriter, SIGNAL(eventDetailsChanged()), d->m_profilerDataModel, SLOT(finishedRewritingDetails()));
    connect(d->m_profilerDataModel, SIGNAL(reloadDocumentsForDetails()), d->m_detailsRewriter, SLOT(reloadDocuments()));

    Command *command = 0;
    const Context globalContext(C_GLOBAL);
    ActionManager *am = ICore::actionManager();

    ActionContainer *menu = am->actionContainer(M_DEBUG_ANALYZER);
    ActionContainer *options = am->createMenu(M_DEBUG_ANALYZER_QML_OPTIONS);
    options->menu()->setTitle(tr("QML Profiler Options"));
    menu->addMenu(options, G_ANALYZER_OPTIONS);
    options->menu()->setEnabled(true);

    QAction *act = d->m_loadQmlTrace = new QAction(tr("Load QML Trace"), options);
    command = am->registerAction(act, "Analyzer.Menu.StartAnalyzer.QMLProfilerOptions.LoadQMLTrace", globalContext);
    connect(act, SIGNAL(triggered()), this, SLOT(showLoadDialog()));
    options->addAction(command);

    act = d->m_saveQmlTrace = new QAction(tr("Save QML Trace"), options);
    d->m_saveQmlTrace->setEnabled(false);
    command = am->registerAction(act, "Analyzer.Menu.StartAnalyzer.QMLProfilerOptions.SaveQMLTrace", globalContext);
    connect(act, SIGNAL(triggered()), this, SLOT(showSaveDialog()));
    options->addAction(command);

    d->m_recordingTimer.setInterval(100);
    connect(&d->m_recordingTimer, SIGNAL(timeout()), this, SLOT(updateTimeDisplay()));
}
Ejemplo n.º 17
0
void OutputPaneManager::init()
{
    ActionManager *am = Core::ICore::instance()->actionManager();
    ActionContainer *mwindow = am->actionContainer(Constants::M_WINDOW);
    const Context globalcontext(Core::Constants::C_GLOBAL);

    // Window->Output Panes
    ActionContainer *mpanes = am->createMenu(Constants::M_WINDOW_PANES);
    mwindow->addMenu(mpanes, Constants::G_WINDOW_PANES);
    mpanes->menu()->setTitle(tr("Output &Panes"));
    mpanes->appendGroup("Coreplugin.OutputPane.ActionsGroup");
    mpanes->appendGroup("Coreplugin.OutputPane.PanesGroup");

    Core::Command *cmd;

    cmd = am->registerAction(m_clearAction, "Coreplugin.OutputPane.clear", globalcontext);
    m_clearButton->setDefaultAction(cmd->action());
    mpanes->addAction(cmd, "Coreplugin.OutputPane.ActionsGroup");

    cmd = am->registerAction(m_prevAction, "Coreplugin.OutputPane.previtem", globalcontext);
    cmd->setDefaultKeySequence(QKeySequence("Shift+F6"));
    m_prevToolButton->setDefaultAction(cmd->action());
    mpanes->addAction(cmd, "Coreplugin.OutputPane.ActionsGroup");

    cmd = am->registerAction(m_nextAction, "Coreplugin.OutputPane.nextitem", globalcontext);
    m_nextToolButton->setDefaultAction(cmd->action());
    cmd->setDefaultKeySequence(QKeySequence("F6"));
    mpanes->addAction(cmd, "Coreplugin.OutputPane.ActionsGroup");

    cmd = am->registerAction(m_minMaxAction, "Coreplugin.OutputPane.minmax", globalcontext);
#ifdef Q_WS_MAC
    cmd->setDefaultKeySequence(QKeySequence("Ctrl+9"));
#else
    cmd->setDefaultKeySequence(QKeySequence("Alt+9"));
#endif
    cmd->setAttribute(Command::CA_UpdateText);
    cmd->setAttribute(Command::CA_UpdateIcon);
    mpanes->addAction(cmd, "Coreplugin.OutputPane.ActionsGroup");
    connect(m_minMaxAction, SIGNAL(triggered()), this, SLOT(slotMinMax()));
    m_minMaxButton->setDefaultAction(cmd->action());

    QAction *sep = new QAction(this);
    sep->setSeparator(true);
    cmd = am->registerAction(sep, "Coreplugin.OutputPane.Sep", globalcontext);
    mpanes->addAction(cmd, "Coreplugin.OutputPane.ActionsGroup");

    QList<IOutputPane*> panes = ExtensionSystem::PluginManager::instance()
        ->getObjects<IOutputPane>();
    QMultiMap<int, IOutputPane*> sorted;
    foreach (IOutputPane* outPane, panes)
        sorted.insertMulti(outPane->priorityInStatusBar(), outPane);

    QMultiMap<int, IOutputPane*>::const_iterator it, begin;
    begin = sorted.constBegin();
    it = sorted.constEnd();
    int shortcutNumber = 1;
    while (it != begin) {
        --it;
        IOutputPane* outPane = it.value();
        const int idx = m_outputWidgetPane->addWidget(outPane->outputWidget(this));

        m_pageMap.insert(idx, outPane);
        connect(outPane, SIGNAL(showPage(bool,bool)), this, SLOT(showPage(bool,bool)));
        connect(outPane, SIGNAL(hidePage()), this, SLOT(slotHide()));
        connect(outPane, SIGNAL(togglePage(bool)), this, SLOT(togglePage(bool)));
        connect(outPane, SIGNAL(navigateStateUpdate()), this, SLOT(updateNavigateState()));

        QWidget *toolButtonsContainer = new QWidget(m_opToolBarWidgets);
        QHBoxLayout *toolButtonsLayout = new QHBoxLayout;
        toolButtonsLayout->setMargin(0);
        toolButtonsLayout->setSpacing(0);
        foreach (QWidget *toolButton, outPane->toolBarWidgets())
            toolButtonsLayout->addWidget(toolButton);
        toolButtonsLayout->addStretch(5);
        toolButtonsContainer->setLayout(toolButtonsLayout);

        m_opToolBarWidgets->addWidget(toolButtonsContainer);

        QString actionId = QString("QtCreator.Pane.%1").arg(outPane->displayName().simplified());
        actionId.remove(QLatin1Char(' '));
        QAction *action = new QAction(outPane->displayName(), this);

        Command *cmd = am->registerAction(action, Id(actionId), Context(Constants::C_GLOBAL));

        mpanes->addAction(cmd, "Coreplugin.OutputPane.PanesGroup");
        m_actions.insert(cmd->action(), idx);

        if (outPane->priorityInStatusBar() != -1) {
            cmd->setDefaultKeySequence(QKeySequence(paneShortCut(shortcutNumber)));
            QToolButton *button = new OutputPaneToggleButton(shortcutNumber, outPane->displayName(),
                                                             cmd->action());
            ++shortcutNumber;
            m_buttonsWidget->layout()->addWidget(button);
            connect(button, SIGNAL(clicked()), this, SLOT(buttonTriggered()));
            m_buttons.insert(idx, button);
        }

        // Now add the entry to the combobox, since the first item we add sets the currentIndex, thus we need to be set up for that
        m_widgetComboBox->addItem(outPane->displayName(), idx);

        connect(cmd->action(), SIGNAL(triggered()), this, SLOT(shortcutTriggered()));
    }

    changePage();
}
/*!
  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()));

}
Ejemplo n.º 19
0
BOOL MenuManager::HandlePlayerCommands(MediaPlayer& player, MenuCommandsEnum cmd, INT playlistPos)
{
	TRACEST(_T("MenuManager::HandlePlayerCommands"));
	PrgAPI* pAPI = PRGAPI();
	ActionManager* pAM = pAPI->GetActionManager();
	switch (cmd)
	{
		//=== Play Control =========================================
	case MENU_PlayControl:
		player.Start();
		break;
	case MENU_PauseControl:
		if (player.GetPlayState() == PS_Paused)
			player.Start();
		else
			player.Pause();
		break;
	case MENU_StopControl:
		player.Stop();
		break;
	case MENU_NextControl:
		player.Next();
		break;
	case MENU_PrevControl:
		player.Previous();
		break;
		//=== Playlist Serialization =========================================
	case MENU_LoadList:
		pAM->InsertPlayList(&player, -1);
		break;
	case MENU_SaveList:
		pAM->SavePlayList(&player);
		break;
	case MENU_InsertList:
		pAM->InsertPlayList(&player, playlistPos);
		break;
	default:
		//=== PlayModes =========================================
		if (cmd>= MENU_PlayModesHolder && cmd < MENU_PlayModesHolder + MPNM_Last)
			player.SetNextMode(MediaPlayerNextMode(cmd - MENU_PlayModesHolder), -1);
		else if (cmd >= MENU_AutoContinueModeHolder && cmd < MENU_AutoContinueModeHolder + RTM_Last)
		{
			player.SetNextMode(player.GetNextMode(NULL), cmd - MENU_AutoContinueModeHolder);
		}
		//=== Rating =========================================
		else if (cmd>= MENU_RatingHolder && cmd <= MENU_RatingHolder + 5)
		{
			int idx = playlistPos;
			if (idx >= 0)
			{
				SQLManager* pSM = PRGAPI()->GetSQLManager();
				MediaPlayListItem mpli;
				if (player.GetPlayListItem(mpli, idx))
				{
					FullTrackRecordSP rec;
					if (pSM->GetFullTrackRecordByLocation(rec, mpli.url))
					{
						FullTrackRecordCollection col;
						col.push_back(rec);
						ActionManager* pAM = PRGAPI()->GetActionManager();
						pAM->SetTrackRating(col, Stars2Rating((FLOAT)(cmd - MENU_RatingHolder)));
					}
				}
			}
		}

		else
			return FALSE;
	}
	return TRUE;
}