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


C++ QAction::deleteLater方法代码示例

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


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

示例1: updateBookmarks

void MainWindow::updateBookmarks(int folder)
{
	if (m_ui->menuBookmarks->actions().count() == 3)
	{
		return;
	}

	for (int i = (m_ui->menuBookmarks->actions().count() - 1); i > 2; --i)
	{
		QAction *action = m_ui->menuBookmarks->actions().at(i);

		if (folder == 0)
		{
			action->deleteLater();

			m_ui->menuBookmarks->removeAction(action);
		}
		else if (m_ui->menuBookmarks->actions().at(i)->menu())
		{
			action->menu()->deleteLater();
			action->setMenu(new QMenu());

			connect(action->menu(), SIGNAL(aboutToShow()), this, SLOT(menuBookmarksAboutToShow()));
		}
	}
}
开发者ID:mboevink,项目名称:otter,代码行数:26,代码来源:MainWindow.cpp

示例2: onAboutToShow

void WindowMenu::onAboutToShow()
{
   QWidget* win = QApplication::activeWindow();
   pMinimize_->setEnabled(win);
   pZoom_->setEnabled(win && win->maximumSize() != win->minimumSize());
   pBringAllToFront_->setEnabled(win);


   for (int i = windows_.size() - 1; i >= 0; i--)
   {
      QAction* pAction = windows_[i];
      removeAction(pAction);
      windows_.removeAt(i);
      pAction->deleteLater();
   }

   QWidgetList topLevels = QApplication::topLevelWidgets();
   for (int i = 0; i < topLevels.size(); i++)
   {
      QWidget* pWindow = topLevels.at(i);
      if (!pWindow->isVisible())
         continue;

      QAction* pAction = new QAction(pWindow->windowTitle(), pWindow);
      pAction->setData(QVariant::fromValue(pWindow));
      pAction->setCheckable(true);
      if (pWindow->isActiveWindow())
         pAction->setChecked(true);
      insertAction(pWindowPlaceholder_, pAction);
      connect(pAction, SIGNAL(triggered()),
              this, SLOT(showWindow()));

      windows_.append(pAction);
   }
}
开发者ID:Sophrinix,项目名称:rstudio,代码行数:35,代码来源:DesktopMenuCallback.cpp

示例3: updateMenu

void Favorites::updateMenu()
{
    // Remove all except the first 2 items
    while (_menu->actions().count() > FIRST_MENU_ENTRY)
    {
        QAction * a = _menu->actions()[FIRST_MENU_ENTRY];
        _menu->removeAction( a );
        a->deleteLater();
    }

    populateMenu();
    markCurrent();
}
开发者ID:AlexRu,项目名称:rosa-media-player,代码行数:13,代码来源:favorites.cpp

示例4: handleUnclose

	void Core::handleUnclose ()
	{
		QAction *action = qobject_cast<QAction*> (sender ());
		UncloseData ud = action->data ().value<UncloseData> ();
		BrowserWidget *bw = NewURL (ud.URL_);

		QDataStream str (ud.History_);
		str >> *bw->GetView ()->page ()->history ();

		bw->SetOnLoadScrollPoint (ud.SPoint_);

		Unclosers_.removeAll (action);

		action->deleteLater ();
	}
开发者ID:Zereal,项目名称:leechcraft,代码行数:15,代码来源:core.cpp

示例5: deleteMenuItems

void BaseWindow::deleteMenuItems(QMenu *menu)
{
    QList<QAction*> mActions = menu->actions();

    for (int i = 0; i < mActions.size(); i++)
    {
        QAction *act = mActions.at(i);

        menu->removeAction(act); // Remove the action!

        QMenu *men = 0;
        men = act->menu();
        if (men != 0)
        {
            this->deleteMenuItems(men); // Recursion
            men->deleteLater();
        }

        act->deleteLater();
    }

    // Note at this point mActions has dangling pointers...
}
开发者ID:Reanmachine,项目名称:RKnock,代码行数:23,代码来源:basewindow.cpp

示例6: resetFileHistory

void BOpenSaveEditorModulePrivate::resetFileHistory(const QStringList &list)
{
    if (mnuFileHistory.isNull())
        return;
    QList<QAction *> acts = mnuFileHistory->actions();
    while (acts.size() > list.size()) {
        QAction *act = acts.takeLast();
        mnuFileHistory->removeAction(act);
        act->deleteLater();
    }
    while (acts.size() < list.size()) {
        QAction *act = new QAction(mnuFileHistory);
        acts << act;
        mnuFileHistory->addAction(act);
    }
    for (int i = 0; i < list.size(); ++i) {
        QAction *act = acts.at(i);
        act->setProperty("beqt/file_name", list.at(i));
        act->setText(QFileInfo( list.at(i) ).fileName());
        connect(act, SIGNAL(triggered()), this, SLOT(fileTriggered()), Qt::UniqueConnection);
        connect(act, SIGNAL(hovered()), this, SLOT(resetFileHistoryMenuToolTip()));
    }
    mnuFileHistory->setEnabled(!mnuFileHistory->isEmpty());
}
开发者ID:ololoepepe,项目名称:BeQt,代码行数:24,代码来源:bopensaveeditormodule.cpp

示例7: contextMenu

void ItemPhysEnv::contextMenu(QGraphicsSceneMouseEvent *mouseEvent)
{
    m_scene->m_contextMenuIsOpened = true; //bug protector

    //Remove selection from non-bgo items
    if(!this->isSelected())
    {
        m_scene->clearSelection();
        this->setSelected(true);
    }

    this->setSelected(true);
    QMenu ItemMenu;

    /*************Layers*******************/
    QMenu *LayerName = ItemMenu.addMenu(tr("Layer: ") + QString("[%1]").arg(m_data.layer).replace("&", "&&&"));
    QAction *setLayer;
    QList<QAction *> layerItems;
    QAction *newLayer = LayerName->addAction(tr("Add to new layer..."));
    LayerName->addSeparator();

    for(LevelLayer &layer : m_scene->m_data->layers)
    {
        //Skip system layers
        if((layer.name == "Destroyed Blocks") || (layer.name == "Spawned NPCs")) continue;

        setLayer = LayerName->addAction(layer.name.replace("&", "&&&") + ((layer.hidden) ? "" + tr("[hidden]") : ""));
        setLayer->setData(layer.name);
        setLayer->setCheckable(true);
        setLayer->setEnabled(true);
        setLayer->setChecked(layer.name == m_data.layer);
        layerItems.push_back(setLayer);
    }
    ItemMenu.addSeparator();
    /*************Layers*end***************/

    QMenu *WaterType =     ItemMenu.addMenu(tr("Environment type"));
    WaterType->deleteLater();

#define CONTEXT_MENU_ITEM_CHK(name, enable, visible, label, checked_condition)\
    name = WaterType->addAction(label);\
    name->setCheckable(true);\
    name->setEnabled(enable);\
    name->setVisible(visible);\
    name->setChecked(checked_condition); typeID++;

    QAction *envTypes[16];
    int typeID = 0;
    bool enable_new_types = !m_scene->m_data->meta.smbx64strict
            && (m_scene->m_configs->editor.supported_features.level_phys_ez_new_types == EditorSetup::FeaturesSupport::F_ENABLED);
    bool show_new_types = (m_scene->m_configs->editor.supported_features.level_phys_ez_new_types != EditorSetup::FeaturesSupport::F_HIDDEN);

    CONTEXT_MENU_ITEM_CHK(envTypes[typeID], true, true,                       tr("Water"),        m_data.env_type == LevelPhysEnv::ENV_WATER);
    CONTEXT_MENU_ITEM_CHK(envTypes[typeID], true, true,                       tr("Quicksand"),    m_data.env_type == LevelPhysEnv::ENV_QUICKSAND);
    CONTEXT_MENU_ITEM_CHK(envTypes[typeID], enable_new_types, show_new_types, tr("Custom liquid"), m_data.env_type == LevelPhysEnv::ENV_CUSTOM_LIQUID);
    CONTEXT_MENU_ITEM_CHK(envTypes[typeID], enable_new_types, show_new_types, tr("Gravity Field"), m_data.env_type == LevelPhysEnv::ENV_GRAVITATIONAL_FIELD);
    CONTEXT_MENU_ITEM_CHK(envTypes[typeID], enable_new_types, show_new_types, tr("Touch Event (Once)"), m_data.env_type == LevelPhysEnv::ENV_TOUCH_EVENT_ONCE_PLAYER);
    CONTEXT_MENU_ITEM_CHK(envTypes[typeID], enable_new_types, show_new_types, tr("Touch Event (Every frame)"), m_data.env_type == LevelPhysEnv::ENV_TOUCH_EVENT_PLAYER);
    CONTEXT_MENU_ITEM_CHK(envTypes[typeID], enable_new_types, show_new_types, tr("NPC/Player Touch Event (Once)"), m_data.env_type == LevelPhysEnv::ENV_TOUCH_EVENT_ONCE_NPC);
    CONTEXT_MENU_ITEM_CHK(envTypes[typeID], enable_new_types, show_new_types, tr("NPC/Player Touch Event (Every frame)"), m_data.env_type == LevelPhysEnv::ENV_TOUCH_EVENT_NPC);
    CONTEXT_MENU_ITEM_CHK(envTypes[typeID], enable_new_types, show_new_types, tr("Mouse click Event"), m_data.env_type == LevelPhysEnv::ENV_CLICK_EVENT);
    CONTEXT_MENU_ITEM_CHK(envTypes[typeID], enable_new_types, show_new_types, tr("Collision script"), m_data.env_type == LevelPhysEnv::ENV_COLLISION_SCRIPT);
    CONTEXT_MENU_ITEM_CHK(envTypes[typeID], enable_new_types, show_new_types, tr("Mouse click Script"), m_data.env_type == LevelPhysEnv::ENV_CLICK_SCRIPT);
    CONTEXT_MENU_ITEM_CHK(envTypes[typeID], enable_new_types, show_new_types, tr("Collision Event"), m_data.env_type == LevelPhysEnv::ENV_COLLISION_EVENT);
    CONTEXT_MENU_ITEM_CHK(envTypes[typeID], enable_new_types, show_new_types, tr("Air chamber"), m_data.env_type == LevelPhysEnv::ENV_AIR);
    CONTEXT_MENU_ITEM_CHK(envTypes[typeID], enable_new_types, show_new_types, tr("NPC Touch Event (Once)"), m_data.env_type == LevelPhysEnv::ENV_TOUCH_EVENT_ONCE_NPC1);
    CONTEXT_MENU_ITEM_CHK(envTypes[typeID], enable_new_types, show_new_types, tr("NPC Touch Event (Every frame)"), m_data.env_type == LevelPhysEnv::ENV_TOUCH_EVENT_NPC1);
    CONTEXT_MENU_ITEM_CHK(envTypes[typeID], enable_new_types, show_new_types, tr("NPC Hurting Field"), m_data.env_type == LevelPhysEnv::ENV_NPC_HURTING_FIELD);

#undef CONTEXT_MENU_ITEM_CHK

    ItemMenu.addSeparator();

    QMenu *copyPreferences =    ItemMenu.addMenu(tr("Copy preferences"));
    QAction *copyPosXYWH =      copyPreferences->addAction(tr("Position: X, Y, Width, Height"));
    QAction *copyPosLTRB =      copyPreferences->addAction(tr("Position: Left, Top, Right, Bottom"));
    ItemMenu.addSeparator();

    QAction *resize =           ItemMenu.addAction(tr("Resize"));
    resize->deleteLater();

    ItemMenu.addSeparator();
    QAction *copyWater =        ItemMenu.addAction(tr("Copy"));
    QAction *cutWater =         ItemMenu.addAction(tr("Cut"));
    ItemMenu.addSeparator();
    QAction *remove =           ItemMenu.addAction(tr("Remove"));

    /*****************Waiting for answer************************/
    QAction *selected = ItemMenu.exec(mouseEvent->screenPos());
    /***********************************************************/

    if(!selected)
        return;


    if(selected == cutWater)
        m_scene->m_mw->on_actionCut_triggered();
    else if(selected == copyWater)
        m_scene->m_mw->on_actionCopy_triggered();
    else if(selected == copyPosXYWH)
//.........这里部分代码省略.........
开发者ID:Wohlhabend-Networks,项目名称:PGE-Project,代码行数:101,代码来源:item_water.cpp

示例8: getAction


//.........这里部分代码省略.........
			break;
		case FullScreenAction:
			ActionsManager::setupLocalAction(actionObject, QLatin1String("FullScreen"), true);

			actionObject->setEnabled(false);

			break;
		case ZoomInAction:
			ActionsManager::setupLocalAction(actionObject, QLatin1String("ZoomIn"));

			break;
		case ZoomOutAction:
			ActionsManager::setupLocalAction(actionObject, QLatin1String("ZoomOut"), true);

			break;
		case ZoomOriginalAction:
			ActionsManager::setupLocalAction(actionObject, QLatin1String("ZoomOriginal"), true);

			break;
		case SearchAction:
			ActionsManager::setupLocalAction(actionObject, QLatin1String("Search"), true);

			break;
		case SearchMenuAction:
			ActionsManager::setupLocalAction(actionObject, QLatin1String("SearchMenu"), true);

			actionObject->setMenu(new QMenu(this));

			connect(actionObject->menu(), SIGNAL(aboutToShow()), this, SLOT(searchMenuAboutToShow()));
			connect(actionObject->menu(), SIGNAL(triggered(QAction*)), this, SLOT(search(QAction*)));

			break;
		case OpenSelectionAsLinkAction:
			ActionsManager::setupLocalAction(actionObject, QLatin1String("OpenSelectionAsLink"), true);

			break;
		case ClearAllAction:
			ActionsManager::setupLocalAction(actionObject, QLatin1String("ClearAll"), true);

			break;
		case SpellCheckAction:
			ActionsManager::setupLocalAction(actionObject, QLatin1String("SpellCheck"), true);

			actionObject->setEnabled(false);

			break;
		case ImagePropertiesAction:
			ActionsManager::setupLocalAction(actionObject, QLatin1String("ImageProperties"), true);

			break;
		case CreateSearchAction:
			ActionsManager::setupLocalAction(actionObject, QLatin1String("CreateSearch"), true);

			break;
		case ReloadOrStopAction:
			ActionsManager::setupLocalAction(actionObject, QLatin1String("Reload"));

			actionObject->setEnabled(true);
			actionObject->setShortcut(QKeySequence());

			break;
		case InspectPageAction:
			ActionsManager::setupLocalAction(actionObject, QLatin1String("InspectPage"));

			actionObject->setEnabled(true);
			actionObject->setShortcut(QKeySequence());

			break;
		case FindAction:
			ActionsManager::setupLocalAction(actionObject, QLatin1String("Find"), true);

			actionObject->setEnabled(true);

			break;
		case FindNextAction:
			ActionsManager::setupLocalAction(actionObject, QLatin1String("FindNext"), true);

			actionObject->setEnabled(true);

			break;
		case FindPreviousAction:
			ActionsManager::setupLocalAction(actionObject, QLatin1String("FindPrevious"), true);

			actionObject->setEnabled(true);

			break;
		default:
			actionObject->deleteLater();
			actionObject = NULL;

			break;
	}

	if (actionObject)
	{
		m_actions[action] = actionObject;
	}

	return actionObject;
}
开发者ID:Kermit,项目名称:otter,代码行数:101,代码来源:QtWebKitWebWidget.cpp

示例9: contextMenu

void ItemDoor::contextMenu(QGraphicsSceneMouseEvent *mouseEvent)
{
    m_scene->m_contextMenuIsOpened = true; //bug protector

    //Remove selection from non-bgo items
    if(!this->isSelected())
    {
        m_scene->clearSelection();
        this->setSelected(true);
    }

    this->setSelected(1);
    QMenu ItemMenu;

    QAction *openLvl = ItemMenu.addAction(tr("Open target level: %1").arg(m_data.lname).replace("&", "&&&"));
    openLvl->setVisible((!m_data.lname.isEmpty()) && (QFile(m_scene->m_data->meta.path + "/" + m_data.lname).exists()));
    openLvl->deleteLater();

    /*************Layers*******************/
    QMenu *LayerName =     ItemMenu.addMenu(tr("Layer: ") + QString("[%1]").arg(m_data.layer).replace("&", "&&&"));
    QAction *setLayer;
    QList<QAction *> layerItems;

    QAction *newLayer =    LayerName->addAction(tr("Add to new layer..."));
    LayerName->addSeparator()->deleteLater();;
    for(LevelLayer &layer : m_scene->m_data->layers)
    {
        //Skip system layers
        if((layer.name == "Destroyed Blocks") || (layer.name == "Spawned NPCs")) continue;

        setLayer = LayerName->addAction(layer.name.replace("&", "&&&") + ((layer.hidden) ? "" + tr("[hidden]") : ""));
        setLayer->setData(layer.name);
        setLayer->setCheckable(true);
        setLayer->setEnabled(true);
        setLayer->setChecked(layer.name == m_data.layer);
        layerItems.push_back(setLayer);
    }
    ItemMenu.addSeparator();
    /*************Layers*end***************/

    QAction *jumpTo = NULL;
    if(this->data(ITEM_TYPE).toString() == "Door_enter")
    {
        jumpTo =                ItemMenu.addAction(tr("Jump to exit"));
        jumpTo->setVisible((m_data.isSetIn) && (m_data.isSetOut));
    }
    else if(this->data(ITEM_TYPE).toString() == "Door_exit")
    {
        jumpTo =                ItemMenu.addAction(tr("Jump to entrance"));
        jumpTo->setVisible((m_data.isSetIn) && (m_data.isSetOut));
    }
    ItemMenu.addSeparator();
    QAction *NoTransport =     ItemMenu.addAction(tr("No Vehicles"));
    NoTransport->setCheckable(true);
    NoTransport->setChecked(m_data.novehicles);

    QAction *AllowNPC =        ItemMenu.addAction(tr("Allow NPC"));
    AllowNPC->setCheckable(true);
    AllowNPC->setChecked(m_data.allownpc);

    QAction *Locked =          ItemMenu.addAction(tr("Locked"));
    Locked->setCheckable(true);
    Locked->setChecked(m_data.locked);
    QAction *BombNeed =        ItemMenu.addAction(tr("Need a bomb"));
    BombNeed->setCheckable(true);
    BombNeed->setChecked(m_data.need_a_bomb);
    QAction *SpecialStReq =    ItemMenu.addAction(tr("Required special state"));
    SpecialStReq->setCheckable(true);
    SpecialStReq->setChecked(m_data.special_state_required);

    /*************Copy Preferences*******************/
    ItemMenu.addSeparator();
    QMenu *copyPreferences =   ItemMenu.addMenu(tr("Copy preferences"));
    QAction *copyPosXY =        copyPreferences->addAction(tr("Position: X, Y"));
    QAction *copyPosXYWH =      copyPreferences->addAction(tr("Position: X, Y, Width, Height"));
    QAction *copyPosLTRB =      copyPreferences->addAction(tr("Position: Left, Top, Right, Bottom"));
    /*************Copy Preferences*end***************/

    ItemMenu.addSeparator();
    QAction *remove =           ItemMenu.addAction(tr("Remove"));

    ItemMenu.addSeparator();
    QAction *props =            ItemMenu.addAction(tr("Properties..."));

    /*****************Waiting for answer************************/
    QAction *selected = ItemMenu.exec(mouseEvent->screenPos());
    /***********************************************************/

    if(!selected)
        return;

    if(selected == openLvl)
        m_scene->m_mw->OpenFile(m_scene->m_data->meta.path + "/" + m_data.lname);
    else if(selected == jumpTo)
    {
        //scene->doCopy = true ;
        if(this->data(ITEM_TYPE).toString() == "Door_enter")
        {
            if(m_data.isSetOut)
                m_scene->m_mw->activeLvlEditWin()->goTo(m_data.ox, m_data.oy, true, QPoint(0, 0), true);
//.........这里部分代码省略.........
开发者ID:jpmac26,项目名称:PGE-Project,代码行数:101,代码来源:item_door.cpp

示例10: mouseReleaseEvent

void ItemTile::mouseReleaseEvent(QGraphicsSceneMouseEvent *mouseEvent)
{
    int multimouse=0;
    bool callContext=false;
    if(((mouseMid)||(mouseRight))&&( mouseLeft^(mouseEvent->buttons() & Qt::LeftButton) ))
        multimouse++;
    if( (((mouseLeft)||(mouseRight)))&&( mouseMid^(mouseEvent->buttons() & Qt::MiddleButton) ))
        multimouse++;
    if((((mouseLeft)||(mouseMid)))&&( mouseRight^(mouseEvent->buttons() & Qt::RightButton) ))
        multimouse++;
    if(multimouse>0)
    {
        mouseEvent->accept(); return;
    }

    if( mouseLeft^(mouseEvent->buttons() & Qt::LeftButton) )
        mouseLeft=false;

    if( mouseMid^(mouseEvent->buttons() & Qt::MiddleButton) )
        mouseMid=false;

    if( mouseRight^(mouseEvent->buttons() & Qt::RightButton) )
    {
        if(!scene->IsMoved) callContext=true;
        mouseRight=false;
    }

    QGraphicsItem::mouseReleaseEvent(mouseEvent);


    /////////////////////////CONTEXT MENU:///////////////////////////////
    if((callContext)&&(!scene->contextMenuOpened))
    {
        if((!scene->lock_tile)&&(!scene->DrawMode)&&(!isLocked))
        {
            scene->contextMenuOpened = true; //bug protector
            //Remove selection from non-bgo items
            if(!this->isSelected())
            {
                scene->clearSelection();
                this->setSelected(true);
            }

            this->setSelected(1);
            ItemMenu->clear();

            QAction *copyTile = ItemMenu->addAction(tr("Copy"));
            copyTile->deleteLater();
            QAction *cutTile = ItemMenu->addAction(tr("Cut"));
            cutTile->deleteLater();
            ItemMenu->addSeparator()->deleteLater();
            QAction *remove = ItemMenu->addAction(tr("Remove"));
            remove->deleteLater();

    QAction *selected = ItemMenu->exec(mouseEvent->screenPos());

            if(!selected)
            {
                #ifdef _DEBUG_
                WriteToLog(QtDebugMsg, "Context Menu <- NULL");
                #endif
                return;
            }

            if(selected==cutTile)
            {
                MainWinConnect::pMainWin->on_actionCut_triggered();
            }
            else
            if(selected==copyTile)
            {
                MainWinConnect::pMainWin->on_actionCopy_triggered();
            }
            else
            if(selected==remove)
            {
               scene->removeSelectedWldItems();
            }
        }

    }
}
开发者ID:hacheipe399,项目名称:PlatGEnWohl,代码行数:82,代码来源:item_tile.cpp

示例11: contextMenuEvent

void TabBarWidget::contextMenuEvent(QContextMenuEvent *event)
{
	m_clickedTab = tabAt(event->pos());

	hidePreview();

	QMenu menu(this);
	menu.addAction(ActionsManager::getAction(ActionsManager::NewTabAction, this));
	menu.addAction(ActionsManager::getAction(ActionsManager::NewTabPrivateAction, this));

	if (m_clickedTab >= 0)
	{
		const bool isPinned = getTabProperty(m_clickedTab, QLatin1String("isPinned"), false).toBool();
		Action *cloneTabAction = new Action(ActionsManager::CloneTabAction, &menu);
		cloneTabAction->setEnabled(getTabProperty(m_clickedTab, QLatin1String("canClone"), false).toBool());

		Action *pinTabAction = new Action(ActionsManager::PinTabAction, &menu);
		pinTabAction->setOverrideText(isPinned ? QT_TRANSLATE_NOOP("actions", "Unpin Tab") : QT_TRANSLATE_NOOP("actions", "Pin Tab"));

		Action *detachTabAction = new Action(ActionsManager::DetachTabAction, &menu);
		detachTabAction->setEnabled(count() > 1);

		menu.addAction(cloneTabAction);
		menu.addAction(pinTabAction);
		menu.addSeparator();
		menu.addAction(detachTabAction);
		menu.addSeparator();

		if (isPinned)
		{
			Action *closeTabAction = new Action(ActionsManager::CloseTabAction, &menu);
			closeTabAction->setEnabled(false);

			menu.addAction(closeTabAction);
		}
		else
		{
			menu.addAction(ActionsManager::getAction(ActionsManager::CloseTabAction, this));
		}

		const int amount = (count() - getPinnedTabsAmount());
		Action *closeOtherTabsAction = new Action(ActionsManager::CloseOtherTabsAction, &menu);
		closeOtherTabsAction->setEnabled(amount > 0 && !(amount == 1 && !isPinned));

		menu.addAction(closeOtherTabsAction);
		menu.addAction(ActionsManager::getAction(ActionsManager::ClosePrivateTabsAction, this));

		connect(cloneTabAction, SIGNAL(triggered()), this, SLOT(cloneTab()));
		connect(pinTabAction, SIGNAL(triggered()), this, SLOT(pinTab()));
		connect(detachTabAction, SIGNAL(triggered()), this, SLOT(detachTab()));
		connect(closeOtherTabsAction, SIGNAL(triggered()), this, SLOT(closeOtherTabs()));
	}

	menu.addSeparator();

	QMenu *arrangeMenu = menu.addMenu(tr("Arrange"));
	arrangeMenu->addAction(ActionsManager::getAction(ActionsManager::RestoreTabAction, this));
	arrangeMenu->addSeparator();
	arrangeMenu->addAction(ActionsManager::getAction(ActionsManager::RestoreAllAction, this));
	arrangeMenu->addAction(ActionsManager::getAction(ActionsManager::MaximizeAllAction, this));
	arrangeMenu->addAction(ActionsManager::getAction(ActionsManager::MinimizeAllAction, this));
	arrangeMenu->addSeparator();
	arrangeMenu->addAction(ActionsManager::getAction(ActionsManager::CascadeAllAction, this));
	arrangeMenu->addAction(ActionsManager::getAction(ActionsManager::TileAllAction, this));

	QAction *cycleAction = new QAction(tr("Switch tabs using the mouse wheel"), this);
	cycleAction->setCheckable(true);
	cycleAction->setChecked(!SettingsManager::getValue(QLatin1String("TabBar/RequireModifierToSwitchTabOnScroll")).toBool());

	connect(cycleAction, SIGNAL(toggled(bool)), this, SLOT(setCycle(bool)));

	ToolBarWidget *toolBar = qobject_cast<ToolBarWidget*>(parentWidget());

	if (toolBar)
	{
		QList<QAction*> actions;
		actions.append(cycleAction);

		menu.addMenu(ToolBarWidget::createCustomizationMenu(ToolBarsManager::TabBar, actions, &menu));
	}
	else
	{
		QMenu *customizationMenu = menu.addMenu(tr("Customize"));
		customizationMenu->addAction(cycleAction);
		customizationMenu->addSeparator();
		customizationMenu->addAction(ActionsManager::getAction(ActionsManager::LockToolBarsAction, this));
	}

	menu.exec(event->globalPos());

	cycleAction->deleteLater();

	m_clickedTab = -1;

	if (underMouse())
	{
		m_previewTimer = startTimer(250);
	}
}
开发者ID:aurhat,项目名称:otter-browser,代码行数:99,代码来源:TabBarWidget.cpp


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