本文整理汇总了C++中QAction::isEnabled方法的典型用法代码示例。如果您正苦于以下问题:C++ QAction::isEnabled方法的具体用法?C++ QAction::isEnabled怎么用?C++ QAction::isEnabled使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类QAction
的用法示例。
在下文中一共展示了QAction::isEnabled方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: showTabBarWhenOneTab
// public bool showTabBarWhenOneTab() const
void tst_TabBar::showTabBarWhenOneTab()
{
QFETCH(bool, showTabBarWhenOneTab);
SubTabBar bar;
bar.show();
bar.setShowTabBarWhenOneTab(showTabBarWhenOneTab);
QAction *action = bar.viewTabBarAction();
QVERIFY(action);
QCOMPARE(action->text(), (showTabBarWhenOneTab ? QString("Hide Tab Bar") : QString("Show Tab Bar")));
QCOMPARE(bar.showTabBarWhenOneTab(), showTabBarWhenOneTab);
bar.addTab("one");
QCOMPARE(bar.count(), 1);
QCOMPARE(bar.isVisible(), showTabBarWhenOneTab);
bar.addTab("two");
QCOMPARE(bar.count(), 2);
QCOMPARE(bar.isVisible(), true);
QCOMPARE(action->text(), QString("Hide Tab Bar"));
QCOMPARE(action->isEnabled(), false);
bar.removeTab(0);
QCOMPARE(bar.count(), 1);
QCOMPARE(bar.isVisible(), showTabBarWhenOneTab);
QCOMPARE(action->isEnabled(), true);
QCOMPARE(action->text(), (showTabBarWhenOneTab ? QString("Hide Tab Bar") : QString("Show Tab Bar")));
}
示例2: actionChanged
void HelpViewer::actionChanged()
{
QAction *a = qobject_cast<QAction *>(sender());
if (a == pageAction(QWebPage::Back))
emit backwardAvailable(a->isEnabled());
else if (a == pageAction(QWebPage::Forward))
emit forwardAvailable(a->isEnabled());
}
示例3: testAddEntry
void TestGui::testAddEntry()
{
EntryView* entryView = m_dbWidget->findChild<EntryView*>("entryView");
QAction* entryNewAction = m_mainWindow->findChild<QAction*>("actionEntryNew");
QVERIFY(entryNewAction->isEnabled());
QToolBar* toolBar = m_mainWindow->findChild<QToolBar*>("toolBar");
QWidget* entryNewWidget = toolBar->widgetForAction(entryNewAction);
QVERIFY(entryNewWidget->isVisible());
QVERIFY(entryNewWidget->isEnabled());
QTest::mouseClick(entryNewWidget, Qt::LeftButton);
QCOMPARE(m_dbWidget->currentMode(), DatabaseWidget::EditMode);
EditEntryWidget* editEntryWidget = m_dbWidget->findChild<EditEntryWidget*>("editEntryWidget");
QLineEdit* titleEdit = editEntryWidget->findChild<QLineEdit*>("titleEdit");
QTest::keyClicks(titleEdit, "test");
QDialogButtonBox* editEntryWidgetButtonBox = editEntryWidget->findChild<QDialogButtonBox*>("buttonBox");
QTest::mouseClick(editEntryWidgetButtonBox->button(QDialogButtonBox::Ok), Qt::LeftButton);
QCOMPARE(m_dbWidget->currentMode(), DatabaseWidget::ViewMode);
QModelIndex item = entryView->model()->index(1, 1);
Entry* entry = entryView->entryFromIndex(item);
QCOMPARE(entry->title(), QString("test"));
QCOMPARE(entry->historyItems().size(), 0);
// wait for modified timer
QTRY_COMPARE(m_tabWidget->tabText(m_tabWidget->currentIndex()), QString("%1*").arg(m_orgDbFileName));
QAction* entryEditAction = m_mainWindow->findChild<QAction*>("actionEntryEdit");
QVERIFY(entryEditAction->isEnabled());
QWidget* entryEditWidget = toolBar->widgetForAction(entryEditAction);
QVERIFY(entryEditWidget->isVisible());
QVERIFY(entryEditWidget->isEnabled());
QTest::mouseClick(entryEditWidget, Qt::LeftButton);
QCOMPARE(m_dbWidget->currentMode(), DatabaseWidget::EditMode);
QTest::keyClicks(titleEdit, "something");
QTest::mouseClick(editEntryWidgetButtonBox->button(QDialogButtonBox::Ok), Qt::LeftButton);
QCOMPARE(entry->title(), QString("testsomething"));
QCOMPARE(entry->historyItems().size(), 1);
QTest::mouseClick(entryNewWidget, Qt::LeftButton);
QTest::keyClicks(titleEdit, "something 2");
QTest::mouseClick(editEntryWidgetButtonBox->button(QDialogButtonBox::Ok), Qt::LeftButton);
QTest::mouseClick(entryNewWidget, Qt::LeftButton);
QTest::keyClicks(titleEdit, "something 3");
QTest::mouseClick(editEntryWidgetButtonBox->button(QDialogButtonBox::Ok), Qt::LeftButton);
QTRY_COMPARE(entryView->model()->rowCount(), 4);
}
示例4: testSearch
void TestGui::testSearch()
{
QAction* searchAction = m_mainWindow->findChild<QAction*>("actionSearch");
QVERIFY(searchAction->isEnabled());
QToolBar* toolBar = m_mainWindow->findChild<QToolBar*>("toolBar");
QWidget* searchActionWidget = toolBar->widgetForAction(searchAction);
QVERIFY(searchActionWidget->isVisible());
QVERIFY(searchActionWidget->isEnabled());
QTest::mouseClick(searchActionWidget, Qt::LeftButton);
EntryView* entryView = m_dbWidget->findChild<EntryView*>("entryView");
QLineEdit* searchEdit = m_dbWidget->findChild<QLineEdit*>("searchEdit");
QToolButton* clearSearch = m_dbWidget->findChild<QToolButton*>("clearButton");
QTest::keyClicks(searchEdit, "ZZZ");
QTRY_COMPARE(entryView->model()->rowCount(), 0);
QTest::mouseClick(clearSearch, Qt::LeftButton);
QTest::keyClicks(searchEdit, "some");
QTRY_COMPARE(entryView->model()->rowCount(), 2);
QModelIndex item = entryView->model()->index(0, 1);
QRect itemRect = entryView->visualRect(item);
QTest::mouseClick(entryView->viewport(), Qt::LeftButton, Qt::NoModifier, itemRect.center());
QAction* entryEditAction = m_mainWindow->findChild<QAction*>("actionEntryEdit");
QVERIFY(entryEditAction->isEnabled());
QWidget* entryEditWidget = toolBar->widgetForAction(entryEditAction);
QVERIFY(entryEditWidget->isVisible());
QVERIFY(entryEditWidget->isEnabled());
QTest::mouseClick(entryEditWidget, Qt::LeftButton);
QCOMPARE(m_dbWidget->currentMode(), DatabaseWidget::EditMode);
EditEntryWidget* editEntryWidget = m_dbWidget->findChild<EditEntryWidget*>("editEntryWidget");
QDialogButtonBox* editEntryWidgetButtonBox = editEntryWidget->findChild<QDialogButtonBox*>("buttonBox");
QTest::mouseClick(editEntryWidgetButtonBox->button(QDialogButtonBox::Ok), Qt::LeftButton);
QCOMPARE(m_dbWidget->currentMode(), DatabaseWidget::ViewMode);
QModelIndex item2 = entryView->model()->index(1, 0);
QRect itemRect2 = entryView->visualRect(item2);
QTest::mouseClick(entryView->viewport(), Qt::LeftButton, Qt::NoModifier, itemRect2.center());
QAction* entryDeleteAction = m_mainWindow->findChild<QAction*>("actionEntryDelete");
QWidget* entryDeleteWidget = toolBar->widgetForAction(entryDeleteAction);
QVERIFY(entryDeleteWidget->isVisible());
QVERIFY(entryDeleteWidget->isEnabled());
QTest::mouseClick(entryDeleteWidget, Qt::LeftButton);
QWidget* closeSearchButton = m_dbWidget->findChild<QToolButton*>("closeSearchButton");
QTest::mouseClick(closeSearchButton, Qt::LeftButton);
QCOMPARE(entryView->model()->rowCount(), 1);
}
示例5: documentChanged
void HelpWindowWidget::documentChanged()
{
// A new help document has been selected, resulting in the previous or next
// help document becoming either available or not
QAction *action = qobject_cast<QAction *>(sender());
if (action == pageAction(QWebPage::Back))
emit backEnabled(action->isEnabled());
else if (action == pageAction(QWebPage::Forward))
emit forwardEnabled(action->isEnabled());
}
示例6: activeContextStateChanged
void KviConnectAction::activeContextStateChanged()
{
KviPointerList<QAction> * bl = actionList();
if(!bl)return;
bool bIconVisibleInMenu = KVI_OPTION_BOOL(KviOption_boolShowIconsInPopupMenus);
QPixmap * p;
QString txt;
KviIrcContext * c = g_pMainWindow->activeContext();
if(c)
{
switch(c->state())
{
case KviIrcContext::Idle:
p = g_pIconManager->getBigIcon(KVI_BIGICON_DISCONNECTED);
txt = m_szConnectString;
break;
case KviIrcContext::PendingReconnection:
case KviIrcContext::Connecting:
case KviIrcContext::LoggingIn:
p = g_pIconManager->getBigIcon(KVI_BIGICON_CONNECTING);
txt = m_szAbortConnectionString;
break;
case KviIrcContext::Connected:
p = g_pIconManager->getBigIcon(KVI_BIGICON_CONNECTED);
txt = m_szDisconnectString;
break;
default:
p = 0;
break;
}
} else {
p = 0;
}
if(p)
{
for(QAction * b = bl->first();b;b =bl->next())
{
if(!b->isEnabled())b->setEnabled(true);
b->setIcon(QIcon(*p));
b->setText(txt);
b->setIconVisibleInMenu(bIconVisibleInMenu);
}
} else {
for(QAction * b = bl->first();b;b = bl->next())
{
if(b->isEnabled())b->setEnabled(false);
b->setIconVisibleInMenu(bIconVisibleInMenu);
}
}
}
示例7: updateActions
void MainWindow::updateActions()
{
QAction *undoAction = m_windowsManager->getAction(UndoAction);
if (undoAction)
{
m_actionsManager->getAction(QLatin1String("Undo"))->setEnabled(undoAction->isEnabled());
m_actionsManager->getAction(QLatin1String("Undo"))->setText(undoAction->text());
}
else
{
m_actionsManager->getAction(QLatin1String("Undo"))->setEnabled(false);
m_actionsManager->getAction(QLatin1String("Undo"))->setText(tr("Undo"));
}
QAction *redoAction = m_windowsManager->getAction(RedoAction);
if (redoAction)
{
m_actionsManager->getAction(QLatin1String("Redo"))->setEnabled(redoAction->isEnabled());
m_actionsManager->getAction(QLatin1String("Redo"))->setText(redoAction->text());
}
else
{
m_actionsManager->getAction(QLatin1String("Redo"))->setEnabled(false);
m_actionsManager->getAction(QLatin1String("Redo"))->setText(tr("Redo"));
}
updateAction(m_windowsManager->getAction(CutAction), m_actionsManager->getAction(QLatin1String("Cut")));
updateAction(m_windowsManager->getAction(CopyAction), m_actionsManager->getAction(QLatin1String("Copy")));
updateAction(m_windowsManager->getAction(PasteAction), m_actionsManager->getAction(QLatin1String("Paste")));
updateAction(m_windowsManager->getAction(DeleteAction), m_actionsManager->getAction(QLatin1String("Delete")));
updateAction(m_windowsManager->getAction(SelectAllAction), m_actionsManager->getAction(QLatin1String("SelectAll")));
updateAction(m_windowsManager->getAction(FindAction), m_actionsManager->getAction(QLatin1String("Find")));
updateAction(m_windowsManager->getAction(FindNextAction), m_actionsManager->getAction(QLatin1String("FindNext")));
updateAction(m_windowsManager->getAction(FindPreviousAction), m_actionsManager->getAction(QLatin1String("FindPrevious")));
updateAction(m_windowsManager->getAction(ReloadAction), m_actionsManager->getAction(QLatin1String("Reload")));
updateAction(m_windowsManager->getAction(StopAction), m_actionsManager->getAction(QLatin1String("Stop")));
updateAction(m_windowsManager->getAction(ViewSourceAction), m_actionsManager->getAction(QLatin1String("ViewSource")));
updateAction(m_windowsManager->getAction(InspectPageAction), m_actionsManager->getAction(QLatin1String("InspectPage")));
updateAction(m_windowsManager->getAction(GoBackAction), m_actionsManager->getAction(QLatin1String("GoBack")));
updateAction(m_windowsManager->getAction(RewindAction), m_actionsManager->getAction(QLatin1String("Rewind")));
updateAction(m_windowsManager->getAction(GoForwardAction), m_actionsManager->getAction(QLatin1String("GoForward")));
updateAction(m_windowsManager->getAction(FastForwardAction), m_actionsManager->getAction(QLatin1String("FastForward")));
const bool canZoom = m_windowsManager->canZoom();
m_actionsManager->getAction(QLatin1String("ZoomOut"))->setEnabled(canZoom);
m_actionsManager->getAction(QLatin1String("ZoomIn"))->setEnabled(canZoom);
m_actionsManager->getAction(QLatin1String("ZoomOriginal"))->setEnabled(canZoom);
}
示例8: updateActions
void MainWindow::updateActions()
{
QAction *undoAction = m_windowsManager->getAction(UndoAction);
if (undoAction)
{
m_ui->actionUndo->setEnabled(undoAction->isEnabled());
m_ui->actionUndo->setText(undoAction->text());
}
else
{
m_ui->actionUndo->setEnabled(false);
m_ui->actionUndo->setText(tr("Undo"));
}
QAction *redoAction = m_windowsManager->getAction(RedoAction);
if (redoAction)
{
m_ui->actionRedo->setEnabled(redoAction->isEnabled());
m_ui->actionRedo->setText(redoAction->text());
}
else
{
m_ui->actionRedo->setEnabled(false);
m_ui->actionRedo->setText(tr("Redo"));
}
updateAction(m_windowsManager->getAction(CutAction), m_ui->actionCut);
updateAction(m_windowsManager->getAction(CopyAction), m_ui->actionCopy);
updateAction(m_windowsManager->getAction(PasteAction), m_ui->actionPaste);
updateAction(m_windowsManager->getAction(DeleteAction), m_ui->actionDelete);
updateAction(m_windowsManager->getAction(SelectAllAction), m_ui->actionSelectAll);
updateAction(m_windowsManager->getAction(FindAction), m_ui->actionFind);
updateAction(m_windowsManager->getAction(FindNextAction), m_ui->actionFindNext);
updateAction(m_windowsManager->getAction(FindPreviousAction), m_ui->actionFindPrevious);
updateAction(m_windowsManager->getAction(ReloadAction), m_ui->actionReload);
updateAction(m_windowsManager->getAction(StopAction), m_ui->actionStop);
updateAction(m_windowsManager->getAction(ViewSourceAction), m_ui->actionViewSource);
updateAction(m_windowsManager->getAction(InspectPageAction), m_ui->actionInspectPage);
updateAction(m_windowsManager->getAction(GoBackAction), m_ui->actionGoBack);
updateAction(m_windowsManager->getAction(RewindAction), m_ui->actionRewind);
updateAction(m_windowsManager->getAction(GoForwardAction), m_ui->actionGoForward);
updateAction(m_windowsManager->getAction(FastForwardAction), m_ui->actionFastForward);
const bool canZoom = m_windowsManager->canZoom();
m_ui->actionZoomOut->setEnabled(canZoom);
m_ui->actionZoomIn->setEnabled(canZoom);
m_ui->actionZoomOriginal->setEnabled(canZoom);
}
示例9: 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
}
示例10: contextMenuEvent
void InventoryTreeView::contextMenuEvent(QContextMenuEvent *event)
{
// Do mousePressEvent so that the right item gets selected before we show the menu
// (right-click doesn't do this automatically).
QMouseEvent mouseEvent(QEvent::MouseButtonPress, event->pos(), event->globalPos(),
Qt::LeftButton, Qt::LeftButton, Qt::NoModifier);
mousePressEvent(&mouseEvent);
QModelIndex index = selectionModel()->currentIndex();
if (!index.isValid())
return;
QMenu *menu = new QMenu(this);
QListIterator<QAction *> it(actions());
while(it.hasNext())
{
QAction *action = it.next();
if (action->isEnabled())
{
// This is kind of hack, but we might have case that base language is not english.
InventoryAction* act = qobject_cast<InventoryAction* >(action);
QString text = QApplication::translate("Inventory::InventoryWindow", act->GetText().toStdString().c_str());
action->setText(text);
menu->addAction(action);
}
}
if (menu->actions().size() > 1) // separator "action" is always enabled, hence the 1
menu->popup(event->globalPos());
}
示例11: triggerAction
void TestGui::triggerAction(const QString& name)
{
QAction* action = m_mainWindow->findChild<QAction*>(name);
QVERIFY(action);
QVERIFY(action->isEnabled());
action->trigger();
}
示例12:
QMap<QAction*, QtilitiesCategory> Qtilities::CoreGui::ActionProvider::actionMap(IActionProvider::ActionFilterFlags action_filter, const QtilitiesCategory& category_filter) const {
// Loop through all actions and inspect them:
QMap<QAction*, QtilitiesCategory> filtered_map;
for (int i = 0; i < d->actions.count(); i++) {
QAction* action = d->actions.keys().at(i);
bool add_action = true;
// Check the category:
if (d->actions.values().at(i) != category_filter && !category_filter.isEmpty())
add_action = false;
// Check for IActionProvider::FilterDisabled
if (action_filter & IActionProvider::FilterDisabled && add_action) {
if (!action->isEnabled())
add_action = false;
}
// Check for IActionProvider::FilterHidden
if (action_filter & IActionProvider::FilterHidden && add_action) {
if (!action->isVisible())
add_action = false;
}
if (add_action)
filtered_map[d->actions.keys().at(i)] = d->actions.values().at(i);
}
return filtered_map;
}
示例13: isEnabled
bool QActionProto::isEnabled() const
{
QAction *item = qscriptvalue_cast<QAction*>(thisObject());
if (item)
return item->isEnabled();
return false;
}
示例14: mouseReleaseEvent
void Menu::mouseReleaseEvent(QMouseEvent *event)
{
if (m_role == BookmarksMenuRole && (event->button() == Qt::LeftButton || event->button() == Qt::MiddleButton))
{
QAction *action = actionAt(event->pos());
if (action && action->isEnabled() && action->data().type() == QVariant::ModelIndex)
{
QWidget *menu = this;
while (menu)
{
menu->close();
menu = menu->parentWidget();
if (!menu || !menu->inherits(QLatin1String("QMenu").data()))
{
break;
}
}
MainWindow *mainWindow = MainWindow::findMainWindow(parent());
if (mainWindow)
{
mainWindow->getWindowsManager()->open(dynamic_cast<BookmarksItem*>(BookmarksManager::getModel()->itemFromIndex(action->data().toModelIndex())), WindowsManager::calculateOpenHints(event->modifiers(), event->button()));
return;
}
}
}
QMenu::mouseReleaseEvent(event);
}
示例15: mousePressEvent
void WidgetMenuBarMapEditor::mousePressEvent(QMouseEvent *event) {
QAction *action = this->actionAt(event->pos());
if (m_selection) {
if (action != nullptr && action->isEnabled()) {
updateSelection(action);
emit selectionChanged();
}
}
else {
if (action != nullptr && action->text() != "|" && action->isEnabled())
updateRight(action);
}
QMenuBar::mousePressEvent(event);
}