本文整理汇总了C++中QAction::shortcuts方法的典型用法代码示例。如果您正苦于以下问题:C++ QAction::shortcuts方法的具体用法?C++ QAction::shortcuts怎么用?C++ QAction::shortcuts使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类QAction
的用法示例。
在下文中一共展示了QAction::shortcuts方法的11个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: setupShortcuts
void PropertiesDialog::setupShortcuts()
{
QMap<QString, QAction*> actions = QTerminalApp::Instance()->getWindowList()[0]->leaseActions();
QList< QString > shortcutKeys = actions.keys();
int shortcutCount = shortcutKeys.count();
shortcutsWidget->setRowCount( shortcutCount );
for( int x=0; x < shortcutCount; x++ )
{
QString keyValue = shortcutKeys.at(x);
QAction *keyAction = actions[keyValue];
QStringList sequenceStrings;
foreach (const QKeySequence &shortcut, keyAction->shortcuts())
sequenceStrings.append(shortcut.toString());
QTableWidgetItem *itemName = new QTableWidgetItem( tr(keyValue.toStdString().c_str()) );
QTableWidgetItem *itemShortcut = new QTableWidgetItem( sequenceStrings.join('|') );
itemName->setFlags( Qt::ItemIsSelectable | Qt::ItemIsEnabled );
shortcutsWidget->setItem(x, 0, itemName);
shortcutsWidget->setItem(x, 1, itemShortcut);
}
shortcutsWidget->resizeColumnsToContents();
/*
connect(shortcutsWidget, SIGNAL(currentChanged(int, int)),
this, SLOT(recordAction(int, int)));
connect(shortcutsWidget, SIGNAL(valueChanged(int, int)),
this, SLOT(validateAction(int, int)));
*/
}
示例2: loadFromConfig
void ActionsEditor::loadFromConfig(QObject *o, QSettings *set) {
qDebug("ActionsEditor::loadFromConfig");
set->beginGroup("actions");
QAction *action;
QString accelText;
QList<QAction *> actions = o->findChildren<QAction *>();
for (int n=0; n < actions.count(); n++) {
action = static_cast<QAction*> (actions[n]);
if (!action->objectName().isEmpty() && !action->inherits("QWidgetAction")) {
#if USE_MULTIPLE_SHORTCUTS
QString current = shortcutsToString(action->shortcuts());
accelText = set->value(action->objectName(), current).toString();
action->setShortcuts( stringToShortcuts( accelText ) );
#else
accelText = set->value(action->objectName(), action->shortcut().toString()).toString();
action->setShortcut(QKeySequence(accelText));
#endif
}
}
set->endGroup();
}
示例3: setupShortcuts
void PropertiesDialog::setupShortcuts()
{
QMap<QString, QAction*> actions = QTerminalApp::Instance()->getWindowList()[0]->leaseActions();
QList< QString > shortcutKeys = actions.keys();
int shortcutCount = shortcutKeys.count();
shortcutsWidget->setRowCount( shortcutCount );
for( int x=0; x < shortcutCount; x++ )
{
QString keyValue = shortcutKeys.at(x);
QAction *keyAction = actions[keyValue];
QStringList sequenceStrings;
const auto shortcuts = keyAction->shortcuts();
for (const QKeySequence &shortcut : shortcuts)
sequenceStrings.append(shortcut.toString());
QTableWidgetItem *itemName = new QTableWidgetItem( tr(keyValue.toStdString().c_str()) );
QTableWidgetItem *itemShortcut = new QTableWidgetItem( sequenceStrings.join(QLatin1Char('|')) );
itemName->setFlags( itemName->flags() & ~Qt::ItemIsEditable & ~Qt::ItemIsSelectable );
shortcutsWidget->setItem(x, 0, itemName);
shortcutsWidget->setItem(x, 1, itemShortcut);
}
shortcutsWidget->resizeColumnsToContents();
// No shortcut validation is needed with QKeySequenceEdit.
}
示例4:
QList<QKeySequence> QActionProto::shortcuts() const
{
QAction *item = qscriptvalue_cast<QAction*>(thisObject());
if (item)
return item->shortcuts();
return QList<QKeySequence>();
}
示例5: keysToString
QString Shortcut::keysToString() const
{
QAction* a = action();
QList<QKeySequence> kl = a->shortcuts();
QString s;
for (int i = 0; i < kl.size(); ++i) {
if (i)
s += "; ";
s += kl[i].toString(QKeySequence::NativeText);
}
return s;
}
示例6: data
QVariant ActionModel::data(const QModelIndex &index, int role) const
{
if (!index.isValid())
return QVariant();
QMutexLocker lock(Probe::objectLock());
QAction *action = m_actions.at(index.row());
if (!Probe::instance()->isValidObject(action))
return QVariant();
const int column = index.column();
if (role == Qt::DisplayRole) {
switch (column) {
case AddressColumn:
return Util::addressToString(action);
case NameColumn:
return action->text();
case CheckablePropColumn:
return action->isCheckable();
case CheckedPropColumn:
return VariantHandler::displayString(action->isChecked());
case PriorityPropColumn:
return Util::enumToString(action->priority(), 0, action);
case ShortcutsPropColumn:
return toString(action->shortcuts());
default:
return QVariant();
}
} else if (role == Qt::DecorationRole) {
if (column == NameColumn) {
return action->icon();
} else if (column == ShortcutsPropColumn && m_duplicateFinder->hasAmbiguousShortcut(action)) {
QIcon icon = QIcon::fromTheme(QStringLiteral("dialog-warning"));
if (!icon.isNull()) {
return icon;
} else {
return QColor(Qt::red);
}
}
} else if (role == Qt::ToolTipRole) {
if (column == ShortcutsPropColumn && m_duplicateFinder->hasAmbiguousShortcut(action)) {
return tr("Warning: Ambiguous shortcut detected.");
}
} else if (role == ObjectModel::ObjectRole) {
return QVariant::fromValue<QObject*>(action);
}
return QVariant();
}
示例7: shortcuts
int Action::shortcuts(lua_State * L) // const : QList<QKeySequence>
{
QAction* obj = QtObject<QAction>::check( L, 1);
QList<QKeySequence> r = obj->shortcuts();
//lua_newtable( L );
//int t = lua_gettop( L );
int j = r.size();
for( int i = 0; i < r.size(); ++i )
{
//Util::push( L, i + 1 );
QKeySequence* res = QtValue<QKeySequence>::create( L );
*res = r[i];
//lua_rawset( L, t );
}
return j;
}
示例8: getAction
QAction* getAction(Shortcut* s)
{
if (s == 0)
return 0;
if (s->action == 0) {
QAction* a = new QAction(s->xml, 0); // mscore);
s->action = a;
a->setData(s->xml);
if(!s->key.isEmpty())
a->setShortcut(s->key);
else
a->setShortcuts(s->standardKey);
a->setShortcutContext(s->context);
if (!s->help.isEmpty()) {
a->setToolTip(s->help);
a->setWhatsThis(s->help);
}
else {
a->setToolTip(s->descr);
a->setWhatsThis(s->descr);
}
if (s->standardKey != QKeySequence::UnknownKey) {
QList<QKeySequence> kl = a->shortcuts();
if (!kl.isEmpty()) {
QString s(a->toolTip());
s += " (";
for (int i = 0; i < kl.size(); ++i) {
if (i)
s += ",";
s += kl[i].toString(QKeySequence::NativeText);
}
s += ")";
a->setToolTip(s);
}
}
else if (!s->key.isEmpty()) {
a->setToolTip(a->toolTip() +
" (" + s->key.toString(QKeySequence::NativeText) + ")" );
}
if (!s->text.isEmpty())
a->setText(s->text);
if (s->icon != -1)
a->setIcon(*icons[s->icon]);
}
return s->action;
}
示例9: setupActions
void lemon::setupActions()
{
KStandardAction::quit(this, SLOT(salir()), actionCollection());
//KStandardAction::quit(qApp, SLOT(quit()), actionCollection());
KStandardAction::preferences(this, SLOT(optionsPreferences()), actionCollection());
//Our actions
QAction* loginAction = actionCollection()->addAction( "login" );
loginAction->setText(i18n("Login"));
loginAction->setIcon(KIcon("preferences-web-browser-identification")); //identity office-address-book
loginAction->setShortcut(Qt::CTRL+Qt::Key_L);
connect(loginAction, SIGNAL(triggered(bool)),m_view, SLOT(login()));
QAction *corteCajaAction = actionCollection()->addAction("balance");
corteCajaAction->setText(i18nc("Account balance", "Balance"));
corteCajaAction->setIcon(KIcon("lemon-balance"));
corteCajaAction->setShortcut(Qt::CTRL+Qt::Key_B);
connect(corteCajaAction, SIGNAL(triggered(bool)), m_view, SLOT(corteDeCaja()));
QAction* enterCodeAction = actionCollection()->addAction( "enterCode" );
enterCodeAction->setText(i18n("Enter Code"));
enterCodeAction->setIcon(KIcon("lemon-tag"));
enterCodeAction->setShortcut(Qt::Key_F2);
connect(enterCodeAction, SIGNAL(triggered(bool)),m_view, SLOT(showEnterCodeWidget()));
QAction* searchItemAction = actionCollection()->addAction( "searchItem" );
searchItemAction->setText(i18n("Search Item"));
searchItemAction->setIcon(KIcon("edit-find"));
searchItemAction->setShortcut(Qt::Key_F3);
connect(searchItemAction, SIGNAL(triggered(bool)),m_view, SLOT(showSearchItemWidget()));
QAction* delSelectedItemAction = actionCollection()->addAction( "deleteSelectedItem" );
delSelectedItemAction->setText(i18n("Delete Selected Item"));
delSelectedItemAction->setIcon(KIcon("lemon-boxcancel"));
delSelectedItemAction->setShortcut(QKeySequence::ZoomOut); //Qt::Key_Delete Qt::Key_Control+Qt::Key_Delete QKeySequence::Cut QKeySequence::ZoomOut
connect(delSelectedItemAction, SIGNAL(triggered(bool)),m_view, SLOT(deleteSelectedItem()));
// ERROR: I dont know why, in my computer, instead of CTRL-Delete, the key assigned is Shift-(
// The same for other non-working shortcuts.
// Some problem related to different keyboard layout :
qDebug()<<"shortcut:"<<delSelectedItemAction->shortcuts();
QAction* finishTransactionAction = actionCollection()->addAction( "finishTransaction" );
finishTransactionAction->setText(i18n("Finish transaction"));
finishTransactionAction->setIcon(KIcon("lemon-transaction-accept"));
finishTransactionAction->setShortcut(Qt::Key_F12);
connect(finishTransactionAction, SIGNAL(triggered(bool)),m_view, SLOT(finishCurrentTransaction()));
QAction* cancelTransactionAction = actionCollection()->addAction( "cancelTransaction" );
cancelTransactionAction->setText(i18n("Cancel transaction"));
cancelTransactionAction->setIcon(KIcon("lemon-transaction-cancel"));
cancelTransactionAction->setShortcut(Qt::Key_F10);
connect(cancelTransactionAction, SIGNAL(triggered(bool)),m_view, SLOT(preCancelCurrentTransaction()));
QAction* cancelSellAction = actionCollection()->addAction("cancelTicket");
cancelSellAction->setText(i18n("Cancel a ticket"));
cancelSellAction->setIcon(KIcon("lemon-ticket-cancel") );
cancelSellAction->setShortcut(Qt::Key_F11);
connect(cancelSellAction, SIGNAL(triggered(bool)),m_view, SLOT(askForIdToCancel()));
//NOTE: This action is for setting how much money is on the drawer...
QAction* startOperationAction = actionCollection()->addAction( "startOperation" );
startOperationAction->setText(i18n("Start Operation"));
startOperationAction->setIcon(KIcon("window-new"));
startOperationAction->setShortcut(QKeySequence::New); // New Qt::Key_Control+Qt::Key_N
connect(startOperationAction, SIGNAL(triggered(bool)),m_view, SLOT(_slotDoStartOperation()));
QAction *payFocusAction = actionCollection()->addAction("payFocus");
payFocusAction->setText(i18n("Pay focus"));
payFocusAction->setIcon(KIcon("lemon-payfocus"));
payFocusAction->setShortcut(Qt::Key_F4); //Qt::Key_Alt + Qt::Key_End
connect(payFocusAction, SIGNAL(triggered(bool)),m_view, SLOT(focusPayInput()));
QAction *showProdGridAction = actionCollection()->addAction("showProductsGrid");
showProdGridAction->setCheckable(true);
showProdGridAction->setText(i18n("Show/Hide Products Grid"));
showProdGridAction->setIcon(KIcon("view-split-top-bottom"));
showProdGridAction->setShortcut(QKeySequence::Print);
connect(showProdGridAction, SIGNAL(toggled(bool)), m_view, SLOT(showProductsGrid(bool)));
qDebug()<<"Show Grid shortcut:"<<showProdGridAction->shortcuts();
QAction *showPriceCheckerAction = actionCollection()->addAction("showPriceChecker");
showPriceCheckerAction->setText(i18n("Show Price Checker"));
showPriceCheckerAction->setIcon(KIcon("lemon-price-checker"));
showPriceCheckerAction->setShortcut(Qt::Key_F9);
connect(showPriceCheckerAction, SIGNAL(triggered(bool)), m_view, SLOT(showPriceChecker()));
QAction *reprintTicketAction = actionCollection()->addAction("reprintTicket");
reprintTicketAction->setText(i18n("Reprint ticket"));
reprintTicketAction->setIcon(KIcon("lemon-print-ticket"));
reprintTicketAction->setShortcut(Qt::Key_F5);
connect(reprintTicketAction, SIGNAL(triggered(bool)), m_view, SLOT(showReprintTicket()));
QAction *cashOutAction = actionCollection()->addAction("cashOut");
cashOutAction->setText(i18n("Cash Out"));
cashOutAction->setIcon(KIcon("lemon-cashout"));
cashOutAction->setShortcut(Qt::Key_F7); //F7
connect(cashOutAction, SIGNAL(triggered(bool)), m_view, SLOT(cashOut()));
QAction *cashAvailableAction = actionCollection()->addAction("cashAvailable");
//.........这里部分代码省略.........
示例10: setupActions
void lemon::setupActions()
{
KStandardAction::quit(this, SLOT(salir()), actionCollection());
//KStandardAction::quit(qApp, SLOT(quit()), actionCollection());
KStandardAction::preferences(this, SLOT(optionsPreferences()), actionCollection());
//Our actions
QAction* loginAction = actionCollection()->addAction( "login" );
loginAction->setText(i18n("Login"));
loginAction->setIcon(KIcon("office-address-book")); //identity
loginAction->setShortcut(Qt::CTRL+Qt::Key_L);
connect(loginAction, SIGNAL(triggered(bool)),m_view, SLOT(login()));
QAction *corteCajaAction = actionCollection()->addAction("balance");
corteCajaAction->setText(i18nc("Account balance", "Balance"));
corteCajaAction->setIcon(KIcon("lemon-balance"));
corteCajaAction->setShortcut(Qt::CTRL+Qt::Key_B);
connect(corteCajaAction, SIGNAL(triggered(bool)), m_view, SLOT(doCorteDeCaja()));
QAction* enterCodeAction = actionCollection()->addAction( "enterCode" );
enterCodeAction->setText(i18n("Enter Code"));
enterCodeAction->setIcon(KIcon("lemon-tag"));
enterCodeAction->setShortcut(Qt::Key_F2);
connect(enterCodeAction, SIGNAL(triggered(bool)),m_view, SLOT(showEnterCodeWidget()));
QAction* searchItemAction = actionCollection()->addAction( "searchItem" );
searchItemAction->setText(i18n("Search Item"));
searchItemAction->setIcon(KIcon("edit-find"));
searchItemAction->setShortcut(Qt::Key_F3);
connect(searchItemAction, SIGNAL(triggered(bool)),m_view, SLOT(showSearchItemWidget()));
QAction* delSelectedItemAction = actionCollection()->addAction( "deleteSelectedItem" );
delSelectedItemAction->setText(i18n("Delete Selected Item"));
delSelectedItemAction->setIcon(KIcon("lemon-boxcancel"));
delSelectedItemAction->setShortcut(QKeySequence::ZoomOut); //Qt::Key_Delete Qt::Key_Control+Qt::Key_Delete QKeySequence::Cut QKeySequence::ZoomOut
connect(delSelectedItemAction, SIGNAL(triggered(bool)),m_view, SLOT(deleteSelectedItem()));
// ERROR: I dont know why, in my computer, instead of CTRL-Delete, the key assigned is Shift-(
// The same for other non-working shortcuts.
// Some problem related to different keyboard layout :
qDebug()<<"shortcut:"<<delSelectedItemAction->shortcuts();
QAction* finishTransactionAction = actionCollection()->addAction( "finishTransaction" );
finishTransactionAction->setText(i18n("Finish transaction"));
finishTransactionAction->setIcon(KIcon("lemon-transaction-accept"));
finishTransactionAction->setShortcut(Qt::Key_F12);
connect(finishTransactionAction, SIGNAL(triggered(bool)),m_view, SLOT(finishCurrentTransaction()));
QAction* cancelTransactionAction = actionCollection()->addAction( "cancelTransaction" );
cancelTransactionAction->setText(i18n("Cancel transaction"));
cancelTransactionAction->setIcon(KIcon("lemon-transaction-cancel"));
cancelTransactionAction->setShortcut(Qt::Key_F10);
connect(cancelTransactionAction, SIGNAL(triggered(bool)),m_view, SLOT(preCancelCurrentTransaction()));
QAction* cancelSellAction = actionCollection()->addAction("cancelTicket");
cancelSellAction->setText(i18n("Cancel a ticket"));
cancelSellAction->setIcon(KIcon("lemon-ticket-cancel") );
cancelSellAction->setShortcut(Qt::Key_F11);
connect(cancelSellAction, SIGNAL(triggered(bool)),m_view, SLOT(askForIdToCancel()));
//NOTE: This action is for setting how much money is on the drawer...
QAction* startOperationAction = actionCollection()->addAction( "startOperation" );
startOperationAction->setText(i18n("Start Operation"));
startOperationAction->setIcon(KIcon("window-new"));
startOperationAction->setShortcut(QKeySequence::New); // New Qt::Key_Control+Qt::Key_N
connect(startOperationAction, SIGNAL(triggered(bool)),m_view, SLOT(_slotDoStartOperation()));
QAction *payFocusAction = actionCollection()->addAction("payFocus");
payFocusAction->setText(i18n("Pay focus"));
payFocusAction->setIcon(KIcon("lemon-payfocus"));
payFocusAction->setShortcut(Qt::Key_F4); //Qt::Key_Alt + Qt::Key_End
connect(payFocusAction, SIGNAL(triggered(bool)),m_view, SLOT(focusPayInput()));
QAction *showProdGridAction = actionCollection()->addAction("showProductsGrid");
showProdGridAction->setCheckable(true);
showProdGridAction->setText(i18n("Show/Hide Products Grid"));
showProdGridAction->setIcon(KIcon("view-split-top-bottom"));
showProdGridAction->setShortcut(QKeySequence::Print);
connect(showProdGridAction, SIGNAL(toggled(bool)), m_view, SLOT(showProductsGrid(bool)));
qDebug()<<"Show Grid shortcut:"<<showProdGridAction->shortcuts();
QAction *showPriceCheckerAction = actionCollection()->addAction("showPriceChecker");
showPriceCheckerAction->setText(i18n("Show Price Checker"));
showPriceCheckerAction->setIcon(KIcon("lemon-price-checker"));
showPriceCheckerAction->setShortcut(Qt::Key_F9);
connect(showPriceCheckerAction, SIGNAL(triggered(bool)), m_view, SLOT(showPriceChecker()));
QAction *reprintTicketAction = actionCollection()->addAction("reprintTicket");
reprintTicketAction->setText(i18n("Reprint ticket"));
reprintTicketAction->setIcon(KIcon("lemon-print-ticket"));
reprintTicketAction->setShortcut(Qt::Key_F5);
connect(reprintTicketAction, SIGNAL(triggered(bool)), m_view, SLOT(showReprintTicket()));
QAction *cashOutAction = actionCollection()->addAction("cashOut");
cashOutAction->setText(i18n("Cash Out"));
cashOutAction->setIcon(KIcon("lemon-cashout"));
cashOutAction->setShortcut(Qt::Key_F7); //F7
connect(cashOutAction, SIGNAL(triggered(bool)), m_view, SLOT(cashOut()));
QAction *cashAvailableAction = actionCollection()->addAction("cashAvailable");
//.........这里部分代码省略.........
示例11: updateView
void ActionsEditor::updateView() {
actionsTable->setRowCount( actionsList.count() );
QAction *action;
QString accelText;
#if !USE_SHORTCUTGETTER
dont_validate = true;
#endif
//actionsTable->setSortingEnabled(false);
for (int n=0; n < actionsList.count(); n++) {
action = static_cast<QAction*> (actionsList[n]);
#if USE_MULTIPLE_SHORTCUTS
accelText = shortcutsToString( action->shortcuts() );
#else
accelText = action->shortcut().toString();
#endif
// Conflict column
QTableWidgetItem * i_conf = new QTableWidgetItem();
// Name column
QTableWidgetItem * i_name = new QTableWidgetItem(action->objectName());
// Desc column
QTableWidgetItem * i_desc = new QTableWidgetItem(action->text().replace("&",""));
i_desc->setIcon( action->icon() );
// Shortcut column
QTableWidgetItem * i_shortcut = new QTableWidgetItem(accelText);
// Set flags
#if !USE_SHORTCUTGETTER
i_conf->setFlags(Qt::ItemIsEnabled);
i_name->setFlags(Qt::ItemIsEnabled);
i_desc->setFlags(Qt::ItemIsEnabled);
#else
i_conf->setFlags(Qt::ItemIsEnabled | Qt::ItemIsSelectable);
i_name->setFlags(Qt::ItemIsEnabled | Qt::ItemIsSelectable);
i_desc->setFlags(Qt::ItemIsEnabled | Qt::ItemIsSelectable);
i_shortcut->setFlags(Qt::ItemIsEnabled | Qt::ItemIsSelectable);
#endif
// Add items to table
actionsTable->setItem(n, COL_CONFLICTS, i_conf );
actionsTable->setItem(n, COL_NAME, i_name );
actionsTable->setItem(n, COL_DESC, i_desc );
actionsTable->setItem(n, COL_SHORTCUT, i_shortcut );
}
hasConflicts(); // Check for conflicts
actionsTable->resizeColumnsToContents();
actionsTable->setCurrentCell(0, COL_SHORTCUT);
#if !USE_SHORTCUTGETTER
dont_validate = false;
#endif
//actionsTable->setSortingEnabled(true);
}