本文整理汇总了C++中QAction::setAccel方法的典型用法代码示例。如果您正苦于以下问题:C++ QAction::setAccel方法的具体用法?C++ QAction::setAccel怎么用?C++ QAction::setAccel使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类QAction
的用法示例。
在下文中一共展示了QAction::setAccel方法的5个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1:
/** maps an action to a shortcut */
PyObject *map(PyObject *, PyObject *args)
{
char *action, *shortcut;
QPtrList<QAction> *actions = Shortcuts::actions();
QAction *a;
if(!PyArg_ParseTuple(args, "ss", &action, &shortcut)){
PyErr_SetString(PyExc_TypeError, "two strings required");
return NULL;
}
for(a = actions->first(); a; a = actions->next())
if(a->name() == QString(action)){
a->setAccel(QKeySequence(shortcut));
break;
}
if(!a)
qWarning("no command %s found", action);
Py_INCREF(Py_None);
return Py_None;
}
示例2: setAccelerator
void PopupMenuEditor::setAccelerator( int key, Qt::ButtonState state, int index )
{
// FIXME: make this a command
int idx = ( index == -1 ? currentIndex : index );
if ( key == Qt::Key_Shift ||
key == Qt::Key_Control ||
key == Qt::Key_Alt ||
key == Qt::Key_Meta ||
key == Qt::Key_unknown )
return; // ignore these keys when they are pressed
PopupMenuEditorItem * i = 0;
if ( idx >= (int)itemList.count() )
i = createItem();
else
i = itemList.at( idx );
int shift = ( state & Qt::ShiftButton ? Qt::SHIFT : 0 );
int ctrl = ( state & Qt::ControlButton ? Qt::CTRL : 0 );
int alt = ( state & Qt::AltButton ? Qt::ALT : 0 );
int meta = ( state & Qt::MetaButton ? Qt::META : 0 );
QAction * a = i->action();
QKeySequence ks = a->accel();
int keys[4] = { ks[0], ks[1], ks[2], ks[3] };
int n = 0;
while ( n < 4 && ks[n++] );
n--;
if ( n < 4 )
keys[n] = key | shift | ctrl | alt | meta;
a->setAccel( QKeySequence( keys[0], keys[1], keys[2], keys[3] ) );
MetaDataBase::setPropertyChanged( a, "accel", TRUE );
resizeToContents();
}
示例3: icon
MainMenubar::MainMenubar (QMainWindow *mw) : QMenuBar (mw, "mainMenubar")
{
actions.setAutoDelete(FALSE);
RcFile rcfile;
QPixmap icon(finished);
QAction *action = new QAction(this, "actionExit");
action->setMenuText(tr("E&xit"));
action->setIconSet(icon);
action->setAccel(Qt::CTRL+Qt::Key_Q);
action->setStatusTip(tr("Quit Qtstalker (Ctrl+Q)"));
action->setToolTip(tr("Quit Qtstalker (Ctrl+Q)"));
connect(action, SIGNAL(activated()), this, SIGNAL(signalExit()));
actions.replace(Exit, action);
icon = configure;
action = new QAction(this, "actionOptions");
action->setMenuText(tr("Edit &Preferences"));
action->setIconSet(icon);
action->setStatusTip(tr("Modify user preferences (Ctrl+0)"));
action->setToolTip(tr("Modify user preferences (Ctrl+0)"));
connect(action, SIGNAL(activated()), mw, SLOT(slotOptions()));
actions.replace(Options, action);
icon = nav;
bool b;
rcfile.loadData(RcFile::ShowSidePanel, b);
action = new QAction(this, "actionPanel");
action->setMenuText(tr("Side &Panel"));
action->setIconSet(icon);
action->setStatusTip(tr("Toggle side-panel view (Ctrl+1)"));
action->setToolTip(tr("Toggle side-panel view (Ctrl+1)"));
action->setToggleAction(TRUE);
action->setOn(b);
connect(action, SIGNAL(toggled(bool)), mw, SLOT(slotHideNav(bool)));
actions.replace(SidePanel, action);
icon = gridicon;
rcfile.loadData(RcFile::Grid, b);
action = new QAction(this, "actionGrid");
action->setMenuText(tr("Chart &Grid"));
action->setIconSet(icon);
action->setStatusTip(tr("Toggle chart grid (Ctrl+2)"));
action->setToolTip(tr("Toggle chart grid (Ctrl+2)"));
action->setToggleAction(TRUE);
action->setOn(b);
connect(action, SIGNAL(toggled(bool)), this, SIGNAL(signalGrid(bool)));
actions.replace(Grid, action);
icon = scaletoscreen;
rcfile.loadData(RcFile::ScaleToScreen, b);
action = new QAction(this, "actionScale");
action->setMenuText(tr("&Scale To Screen"));
action->setIconSet(icon);
action->setStatusTip(tr("Scale chart to current screen data (Ctrl+3)"));
action->setToolTip(tr("Scale chart to current screen data (Ctrl+3)"));
action->setToggleAction(TRUE);
action->setOn(b);
connect(action, SIGNAL(toggled(bool)), this, SIGNAL(signalScale(bool)));
actions.replace(ScaleToScreen, action);
icon = crosshair;
rcfile.loadData(RcFile::Crosshairs, b);
action = new QAction(this, "actionCrosshairs");
action->setMenuText(tr("Toggle &Crosshairs"));
action->setIconSet(icon);
action->setStatusTip(tr("Toggle crosshairs (Ctrl+4)"));
action->setToolTip(tr("Toggle crosshairs (Ctrl+4)"));
action->setToggleAction(TRUE);
action->setOn(b);
connect(action, SIGNAL(toggled(bool)), this, SIGNAL(signalCrosshairs(bool)));
actions.replace(Crosshairs, action);
icon = co;
rcfile.loadData(RcFile::DrawMode, b);
action = new QAction(this, "actionDraw");
action->setMenuText(tr("Toggle &Draw Mode"));
action->setIconSet(icon);
action->setStatusTip(tr("Toggle drawing mode (Ctrl+5)"));
action->setToolTip(tr("Toggle drawing mode (Ctrl+5)"));
action->setToggleAction(TRUE);
action->setOn(b);
connect(action, SIGNAL(toggled(bool)), this, SIGNAL(signalDraw(bool)));
actions.replace(DrawMode, action);
icon = papertrade;
rcfile.loadData(RcFile::PaperTradeMode, b);
action = new QAction(this, "actionPaperTrade");
action->setMenuText(tr("Toggle &Trade Mode"));
action->setIconSet(icon);
action->setStatusTip(tr("Toggle paper-trade mode"));
action->setToolTip(tr("Toggle paper-trade mode"));
action->setToggleAction(TRUE);
action->setOn(b);
connect(action, SIGNAL(toggled(bool)), this, SIGNAL(signalPaperTrade(bool)));
actions.replace(PaperTrade, action);
icon = indicator;
action = new QAction(this, "actionNewIndicator");
//.........这里部分代码省略.........
示例4: emplacement
/**************************************************************
* This is the main method which update the GUI
* according to the plugin's data
* @param pluginID the id of the plugin
* @param type the type of the plugin
* @param infos plugin informations
*
*************************************************************/
void
MainWindow::updateGUIWithPluginData(const QString & pluginID,
PluginType type,
std::vector<MenuAddOn *> & infos)
{
std::cout << "Dans updateGUIWithPluginData "<< std::endl
<< "taille d infos transmis " << infos.size() << std::endl;
const int nbArgs = infos.size();
//TODO : use Iterator instead of direct access
for(int i=0; i<nbArgs; i++)
{
//First we retrieve the MenuAddOn
MenuAddOn* infoMenu = infos[i];
QString emplacement(infoMenu->emplacement->c_str());
qDebug("emplacement = %s ", emplacement.latin1());
// We split the string to learn where the plugin wants
// to be connected with the GUI components
QStringList decomposition = QStringList::split(INPUT_COMPONENT_SEPARATOR, emplacement);
QString component = decomposition[0];
qDebug("Compoment = %s ", component.latin1());
//Which component ?
//TODO: To IMPROVE the test
if (component == "Menu")
{
QPopupMenu* aMenu;
for(int j=1; j<decomposition.size()-1; j++)
{
aMenu = _menus.find(decomposition[j]);
//Do we already have built this menu
if(!aMenu)
{
QPopupMenu * aMenu = new QPopupMenu( this );
_menus.insert(decomposition[j], aMenu);
if (j == 1)
{
menuBar()->insertItem( decomposition[j], _menus[decomposition[j]]);
}
else
{
QPopupMenu* previousMenu = _menus.find(decomposition[j-1]);
previousMenu->insertItem( decomposition[j], aMenu);
}
}
}
QAction* aAction = new QAction(this);
aAction->setText ( decomposition[decomposition.size() -1] );
aAction->setMenuText( decomposition[decomposition.size() -1] );
if( infoMenu->texte != NULL )
{
aAction->setAccel( QKeySequence( QString(infoMenu->texte->c_str()) ) );
}
if( infoMenu->image != NULL )
{
aAction->setIconSet( QIconSet(
QPixmap
(
QString(IMAGES_DIR).append(infoMenu->image->c_str())
) ) );
aAction->addTo( _toolBar);
}
QSignalMapper* _signalMapper = new QSignalMapper(this);
_signalMapper->setMapping(aAction, pluginID);
connect( aAction, SIGNAL(activated() ),
_signalMapper, SLOT(map()) );
switch(infoMenu->typeAppel)
{
case LOAD_CALL:
{
connect( _signalMapper, SIGNAL(mapped(const QString &) ),
_pluginManager, SLOT(executeLoad(const QString &)) );
break;
}
//.........这里部分代码省略.........
示例5: accept
void PreferencesDialog::accept() {
cancelSetAccelKey();
if( !isRevealingSequenceSelectionValid() ) {
tab->showPage( quizPage );
QMessageBox::warning( this, QObject::tr( "Warning" ), tr( "RevealingOrderMandatory" ) );
return;
}
if( !isStudyLanguageSelectionValid() ) {
tab->showPage( languagePage );
QMessageBox::warning( this, QObject::tr( "Warning" ), tr( "StudyLanguagesMandatory" ) );
return;
}
if( quizAlgoOriginalRadioButton->isChecked() )
prefs->setQuizAlgorithm( Preferences::ORIGINAL );
else if( quizAlgoSuperMemo2RadioButton->isChecked() )
prefs->setQuizAlgorithm( Preferences::SUPERMEMO2 );
prefs->setQuizCharacterImageLocation( quizCharacterImageLocationField->text() );
prefs->setQuizCharacterImagesAnimated( quizCharacterImageTypeCheckbox->isOn() );
prefs->setQuizLength( quizLengthSlider->value() );
prefs->clearRevealingSequences();
for( SequenceListItem* item = (SequenceListItem*)sequencesView->firstChild(); item; item = (SequenceListItem*)item->nextSibling() )
prefs->addRevealingSequence( item->getSequence() );
prefs->setLabelsFontFamily( labelsFontFamilyComboBox->text( labelsFontFamilyComboBox->currentItem() ) );
int fontSizeNameListLength = sizeof( fontSizeNameList ) / sizeof( QString );
int labelsFontSizeModifier = labelsFontSizeComboBox->currentItem() - ( fontSizeNameListLength - 1 ) / 2;
prefs->setLabelsFontSizeModifier( labelsFontSizeModifier );
prefs->setFontFamily( fontFamilyComboBox->text( fontFamilyComboBox->currentItem() ) );
int fontSizeModifier = fontSizeComboBox->currentItem() - ( fontSizeNameListLength - 1 ) / 2;
prefs->setFontSizeModifier( fontSizeModifier );
prefs->clearFontOverrideFamilies();
prefs->clearFontOverrideSizes();
int fontOverrideCount = fontOverrideLabels.count();
for( int i = 0; i < fontOverrideCount; i++ ) {
const QString& language = Util::getLanguageCode( fontOverrideLabels.at( i )->text() );
if( fontOverrideFamilyComboBoxes.at( i )->currentItem() > 0 )
prefs->setFontOverrideFamily( language, fontOverrideFamilyComboBoxes.at( i )->currentText() );
if( fontOverrideSizeComboBoxes.at( i )->currentItem() > 0 ) {
int fontSizeModifier = ( fontOverrideSizeComboBoxes.at( i )->currentItem() - 1 ) - ( fontSizeNameListLength - 1 ) / 2;
prefs->setFontOverrideSize( language, fontSizeModifier );
}
}
bool firstLanguageExists = false;
bool testLanguageExists = false;
prefs->clearStudyLanguages();
for( QCheckListItem* item = (QCheckListItem*)studyLanguagesListView->firstChild(); item; item = (QCheckListItem*)item->nextSibling() ) {
if( item->isOn() ) {
QString langCode( Util::getLanguageCode( item->text() ) );
prefs->addStudyLanguage( langCode );
if( !firstLanguageExists )
firstLanguageExists = ( prefs->getFirstLanguage() == langCode );
if( !testLanguageExists )
testLanguageExists = (prefs->getTestLanguage() == langCode );
}
}
if( !firstLanguageExists )
prefs->setFirstLanguage( QString::null );
if( !testLanguageExists )
prefs->setTestLanguage( QString::null );
prefs->setDigraphEnabled( digraphCheckBox->isOn() );
prefs->setQuizButtonsHidden( hideQuizButtonCheckBox->isOn() );
prefs->setAltInTermListShown( showAltTextInTermListCheckBox->isOn() );
if( keyboardAccelModified ) {
for( KeyActionListViewItem* item = (KeyActionListViewItem*)keyboardAccelListView->firstChild(); item ;
item = (KeyActionListViewItem*)item->nextSibling() ) {
QAction *action = item->getAction();
action->setAccel( item->getKey() );
prefs->setAccelerator( item->getActionIndex(), item->getKey() );
}
}
QDialog::accept();
}