本文整理汇总了C++中QAction::isSeparator方法的典型用法代码示例。如果您正苦于以下问题:C++ QAction::isSeparator方法的具体用法?C++ QAction::isSeparator怎么用?C++ QAction::isSeparator使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类QAction
的用法示例。
在下文中一共展示了QAction::isSeparator方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: dropEvent
void MenuBar::dropEvent(QDropEvent *event)
{
const MimeDataObject *mimeData = qobject_cast<const MimeDataObject *>(event->mimeData());
QAction *aAction = qobject_cast<QAction *>(mimeData->object());
if (aAction && isEdited()) {
if (activeAction())
if (activeAction()->menu())
activeAction()->menu()->close();
if (aAction->menu())
if (aAction->objectName() == "actionNewMenu") {
Menu *menu = new Menu(aAction->text());
menu->setEdited(true);
aAction = menu->menuAction();
}
QAction *eAction = this->actionAt(event->pos());
QRect rect = actionGeometry(eAction);
eAction = this->actionAt(QPoint(event->pos().x()+rect.width()/2,
event->pos().y()));
if (eAction) {
if (aAction->isSeparator())
insertSeparator(eAction);
else
insertAction(eAction,aAction);
} else {
if (aAction->isSeparator())
addSeparator();
else
addAction(aAction);
}
event->acceptProposedAction();
}
}
示例2: manageMenuBar
void AcceleratorManagerPrivate::manageMenuBar(QMenuBar *mbar, Item *item)
{
QAction *maction;
QString s;
for (int i=0; i<mbar->actions().count(); ++i)
{
maction = mbar->actions()[i];
if (!maction)
continue;
// nothing to do for separators
if (maction->isSeparator())
continue;
s = maction->text();
if (!s.isEmpty())
{
Item *it = new Item;
item->addChild(it);
it->m_content =
AccelString(s,
// menu titles are important, so raise the weight
AccelManagerAlgorithm::MENU_TITLE_WEIGHT);
it->m_widget = mbar;
it->m_index = i;
}
// have a look at the popup as well, if present
if (maction->menu())
PopupAccelManager::manage(maction->menu());
}
}
示例3: indexBasedInsertion
void tst_QMenu::indexBasedInsertion()
{
// test the compat'ed index based insertion
QFETCH(int, indexForInsertion);
QFETCH(int, expectedIndex);
{
QMenu menu;
menu.addAction("Regular Item");
menu.insertItem("New Item", -1 /*id*/, indexForInsertion);
QAction *act = menu.actions().value(expectedIndex);
QVERIFY(act);
QCOMPARE(act->text(), QString("New Item"));
}
{
QMenu menu;
menu.addAction("Regular Item");
menu.insertSeparator(indexForInsertion);
QAction *act = menu.actions().value(expectedIndex);
QVERIFY(act);
QVERIFY(act->isSeparator());
}
}
示例4: showLineEdit
void QDesignerMenuBar::showLineEdit()
{
QAction *action = 0;
if (m_currentIndex >= 0 && m_currentIndex < realActionCount())
action = safeActionAt(m_currentIndex);
else
action = m_addMenu;
if (action->isSeparator())
return;
// hideMenu();
m_lastFocusWidget = qApp->focusWidget();
// open edit field for item name
const QString text = action != m_addMenu ? action->text() : QString();
m_editor->setText(text);
m_editor->selectAll();
m_editor->setGeometry(actionGeometry(action));
m_editor->show();
qApp->setActiveWindow(m_editor);
m_editor->setFocus();
m_editor->grabKeyboard();
}
示例5: populateList
void ToolbarEditor::populateList(QListWidget * w, QList<QAction *> actions_list, bool add_separators) {
w->clear();
QAction * action;
for (int n = 0; n < actions_list.count(); n++) {
action = static_cast<QAction*> (actions_list[n]);
if (action) {
if (!action->objectName().isEmpty()) {
QListWidgetItem * i = new QListWidgetItem;
QString text = fixname(action->text(), action->objectName());
i->setText(text + " ("+ action->objectName() +")");
QIcon icon = action->icon();
if (icon.isNull()) {
icon = Images::icon("empty_icon");
}
i->setIcon(icon);
i->setData(Qt::UserRole, action->objectName());
w->addItem(i);
}
else
if ((action->isSeparator()) && (add_separators)) {
QListWidgetItem * i = new QListWidgetItem;
//i->setText(tr("(separator)"));
i->setText("---------");
i->setData(Qt::UserRole, "separator");
i->setIcon(Images::icon("empty_icon"));
w->addItem(i);
}
}
}
}
示例6: menu
QAccessibleInterface *QAccessibleMenu::childAt(int x, int y) const
{
QAction *act = menu()->actionAt(menu()->mapFromGlobal(QPoint(x,y)));
if(act && act->isSeparator())
act = 0;
return act ? getOrCreateMenu(menu(), act) : 0;
}
示例7: isSeparator
bool QActionProto::isSeparator() const
{
QAction *item = qscriptvalue_cast<QAction*>(thisObject());
if (item)
return item->isSeparator();
return false;
}
示例8: setup
void MenuManager::setup(MenuItem* menuItems) const
{
if (!menuItems)
return; // empty menu bar
QMenuBar* menuBar = getMainWindow()->menuBar();
//menuBar->setUpdatesEnabled(false);
QList<MenuItem*> items = menuItems->getItems();
QList<QAction*> actions = menuBar->actions();
for (QList<MenuItem*>::ConstIterator it = items.begin(); it != items.end(); ++it)
{
// search for the menu action
QAction* action = findAction(actions, QString::fromAscii((*it)->command().c_str()));
if (!action) {
// There must be not more than one separator in the menu bar, so
// we can safely remove it if available and append it at the end
if ((*it)->command() == "Separator") {
action = menuBar->addSeparator();
action->setObjectName(QLatin1String("Separator"));
}
else {
// create a new menu
std::string menuName = (*it)->command();
QMenu* menu = menuBar->addMenu(
QApplication::translate("Workbench", menuName.c_str(),
0, QApplication::UnicodeUTF8));
action = menu->menuAction();
menu->setObjectName(QString::fromAscii(menuName.c_str()));
action->setObjectName(QString::fromAscii(menuName.c_str()));
}
// set the menu user data
action->setData(QString::fromAscii((*it)->command().c_str()));
}
else {
// put the menu at the end
menuBar->removeAction(action);
menuBar->addAction(action);
action->setVisible(true);
int index = actions.indexOf(action);
actions.removeAt(index);
}
// flll up the menu
if (!action->isSeparator())
setup(*it, action->menu());
}
// hide all menus which we don't need for the moment
for (QList<QAction*>::Iterator it = actions.begin(); it != actions.end(); ++it) {
(*it)->setVisible(false);
}
// enable update again
//menuBar->setUpdatesEnabled(true);
}
示例9: objectNameList
static QStringList objectNameList(QDesignerFormWindowInterface *form)
{
typedef QList<QAction*> ActionList;
typedef QList<QButtonGroup *> ButtonGroupList;
QStringList result;
QWidget *mainContainer = form->mainContainer();
if (!mainContainer)
return result;
// Add main container container pages (QStatusBar, QWizardPages) etc.
// to the list. Pages of containers on the form are not added, however.
if (const QDesignerContainerExtension *c = qt_extension<QDesignerContainerExtension *>(form->core()->extensionManager(), mainContainer)) {
const int count = c->count();
for (int i = 0 ; i < count; i++)
addWidgetToObjectList(c->widget(i), result);
}
const QDesignerFormWindowCursorInterface *cursor = form->cursor();
const int widgetCount = cursor->widgetCount();
for (int i = 0; i < widgetCount; ++i)
addWidgetToObjectList(cursor->widget(i), result);
const QDesignerMetaDataBaseInterface *mdb = form->core()->metaDataBase();
// Add managed actions and actions with managed menus
const ActionList actions = mainContainer->findChildren<QAction*>();
if (!actions.empty()) {
const ActionList::const_iterator cend = actions.constEnd();
for (ActionList::const_iterator it = actions.constBegin(); it != cend; ++it) {
QAction *a = *it;
if (!a->isSeparator()) {
if (QMenu *menu = a->menu()) {
if (mdb->item(menu))
result.push_back(menu->objectName());
} else {
if (mdb->item(a))
result.push_back(a->objectName());
}
}
}
}
// Add managed buttons groups
const ButtonGroupList buttonGroups = mainContainer->findChildren<QButtonGroup *>();
if (!buttonGroups.empty()) {
const ButtonGroupList::const_iterator cend = buttonGroups.constEnd();
for (ButtonGroupList::const_iterator it = buttonGroups.constBegin(); it != cend; ++it)
if (mdb->item(*it))
result.append((*it)->objectName());
}
result.sort();
return result;
}
示例10: updateWindow
void MacMenu::updateWindow(MainWindow *win)
{
QListIterator<QAction*> i(_windows->actions());
i.toBack();
while(i.hasPrevious()) {
QAction *a = i.previous();
if(a->isSeparator())
break;
if(a->property("mainwin").value<MainWindow*>() == win) {
a->setText(menuWinTitle(win->windowTitle()));
break;
}
}
}
示例11: mouseReleaseEvent
void PopupMenu::mouseReleaseEvent(QMouseEvent *e)
{
DEBUG_PRST_ROUTES(stderr, "PopupMenu::mouseReleaseEvent this:%p\n", this);
if(_contextMenu && _contextMenu->isVisible())
return;
// Removed by Tim. Why not stay-open scrollable menus?
// if(MusEGlobal::config.scrollableSubMenus)
// {
// QMenu::mouseReleaseEvent(e);
// return;
// }
QAction* action = actionAt(e->pos());
if (!(action && action == activeAction() && !action->isSeparator() && action->isEnabled()))
action=NULL;
#ifdef POPUP_MENU_DISABLE_STAY_OPEN
if (action && action->menu() != NULL && action->isCheckable())
action->activate(QAction::Trigger);
QMenu::mouseReleaseEvent(e);
if (action && action->menu() != NULL && action->isCheckable())
close();
return;
#else
// Check for Ctrl to stay open.
const bool stay_open = _stayOpen && (MusEGlobal::config.popupsDefaultStayOpen || (e->modifiers() & Qt::ControlModifier));
// Stay open? Or does the action have a submenu, but also a checkbox of its own?
if(action && (stay_open || (action->isEnabled() && action->menu() && action->isCheckable())))
{
DEBUG_PRST_ROUTES(stderr, "PopupMenu::mouseReleaseEvent: stay open\n");
action->trigger(); // Trigger the action.
e->accept();
if(!stay_open)
closeUp();
return; // We handled it.
}
// Otherwise let ancestor QMenu handle it...
e->ignore();
QMenu::mouseReleaseEvent(e);
#endif // POPUP_MENU_DISABLE_STAY_OPEN
}
示例12: updateWinMenu
void MacMenu::updateWinMenu()
{
const MainWindow *top = qobject_cast<MainWindow*>(qApp->activeWindow());
QListIterator<QAction*> i(_windows->actions());
i.toBack();
while(i.hasPrevious()) {
QAction *a = i.previous();
if(a->isSeparator())
break;
// TODO show bullet if window has unsaved changes and diamond
// if minimized.
a->setChecked(a->property("mainwin").value<MainWindow*>() == top);
}
}
示例13: handleContextMenuEvent
bool ToolBarEventFilter::handleContextMenuEvent(QContextMenuEvent * event )
{
event->accept();
const QPoint globalPos = event->globalPos();
const int index = actionIndexAt(m_toolBar, m_toolBar->mapFromGlobal(globalPos), m_toolBar->orientation());
const ActionList actions = m_toolBar->actions();
QAction *action = index != -1 ?actions.at(index) : 0;
QVariant itemData;
QMenu menu(0);
// Insert before
if (action && index != 0 && !action->isSeparator()) {
QAction *newSeperatorAct = menu.addAction(tr("Insert Separator before '%1'").arg(action->objectName()));
qVariantSetValue(itemData, action);
newSeperatorAct->setData(itemData);
connect(newSeperatorAct, SIGNAL(triggered()), this, SLOT(slotInsertSeparator()));
}
// Append separator
if (actions.empty() || !actions.back()->isSeparator()) {
QAction *newSeperatorAct = menu.addAction(tr("Append Separator"));
qVariantSetValue(itemData, static_cast<QAction*>(0));
newSeperatorAct->setData(itemData);
connect(newSeperatorAct, SIGNAL(triggered()), this, SLOT(slotInsertSeparator()));
}
// Remove
if (!menu.actions().empty())
menu.addSeparator();
// Remove
if (action) {
QAction *a = menu.addAction(tr("Remove action '%1'").arg(action->objectName()));
qVariantSetValue(itemData, action);
a->setData(itemData);
connect(a, SIGNAL(triggered()), this, SLOT(slotRemoveSelectedAction()));
}
QAction *remove_toolbar = menu.addAction(tr("Remove Toolbar '%1'").arg(m_toolBar->objectName()));
connect(remove_toolbar, SIGNAL(triggered()), this, SLOT(slotRemoveToolBar()));
menu.exec(globalPos);
return true;
}
示例14: removeWindow
void MacMenu::removeWindow(MainWindow *win)
{
QListIterator<QAction*> i(_windows->actions());
i.toBack();
QAction *delthis = nullptr;
while(i.hasPrevious()) {
QAction *a = i.previous();
if(a->isSeparator())
break;
if(a->property("mainwin").value<MainWindow*>() == win) {
delthis = a;
break;
}
}
Q_ASSERT(delthis);
delete delthis;
}
示例15: contextMenuActions
ActionList ToolBarEventFilter::contextMenuActions(const QPoint &globalPos)
{
ActionList rc;
const int index = actionIndexAt(m_toolBar, m_toolBar->mapFromGlobal(globalPos), m_toolBar->orientation());
const ActionList actions = m_toolBar->actions();
QAction *action = index != -1 ?actions.at(index) : 0;
QVariant itemData;
// Insert before
if (action && index != 0 && !action->isSeparator()) {
QAction *newSeperatorAct = new QAction(tr("Insert Separator before '%1'").arg(action->objectName()), 0);
itemData.setValue(action);
newSeperatorAct->setData(itemData);
connect(newSeperatorAct, SIGNAL(triggered()), this, SLOT(slotInsertSeparator()));
rc.push_back(newSeperatorAct);
}
// Append separator
if (actions.empty() || !actions.back()->isSeparator()) {
QAction *newSeperatorAct = new QAction(tr("Append Separator"), 0);
itemData.setValue(static_cast<QAction*>(0));
newSeperatorAct->setData(itemData);
connect(newSeperatorAct, SIGNAL(triggered()), this, SLOT(slotInsertSeparator()));
rc.push_back(newSeperatorAct);
}
// Promotion
if (!m_promotionTaskMenu)
m_promotionTaskMenu = new PromotionTaskMenu(m_toolBar, PromotionTaskMenu::ModeSingleWidget, this);
m_promotionTaskMenu->addActions(formWindow(), PromotionTaskMenu::LeadingSeparator|PromotionTaskMenu::TrailingSeparator, rc);
// Remove
if (action) {
QAction *a = new QAction(tr("Remove action '%1'").arg(action->objectName()), 0);
itemData.setValue(action);
a->setData(itemData);
connect(a, SIGNAL(triggered()), this, SLOT(slotRemoveSelectedAction()));
rc.push_back(a);
}
QAction *remove_toolbar = new QAction(tr("Remove Toolbar '%1'").arg(m_toolBar->objectName()), 0);
connect(remove_toolbar, SIGNAL(triggered()), this, SLOT(slotRemoveToolBar()));
rc.push_back(remove_toolbar);
return rc;
}