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


C++ Manager::addAction方法代码示例

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


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

示例1: QWidget

TextFindReplacePanel::TextFindReplacePanel( QWidget * parent ):
    QWidget(parent),
    mMode((Mode) 0), // a hack so that first setMode() works
    mEditor(0),
    mSearchPosition(-1)
{
    mFindField = new QLineEdit;
    mReplaceField = new QLineEdit;

    mNextBtn = new QToolButton();
    mNextBtn->setIcon( style()->standardIcon( QStyle::SP_ArrowForward ) );
    mNextBtn->setToolTip( tr("Find Next") );

    mPrevBtn = new QToolButton();
    mPrevBtn->setIcon( style()->standardIcon( QStyle::SP_ArrowBack ) );
    mPrevBtn->setToolTip( tr("Find Previous") );

    mReplaceBtn = new QToolButton();
    mReplaceBtn->setText(tr("Replace"));
    mReplaceAllBtn = new QToolButton();
    mReplaceAllBtn->setText(tr("Replace All"));

    mOptionsBtn = new QToolButton();
    mOptionsBtn->setText(tr("Options"));
    mOptionsBtn->setIcon( QIcon::fromTheme("preferences-other") );
    mOptionsBtn->setPopupMode(QToolButton::InstantPopup);

    QMenu *optMenu = new QMenu(this);
    mMatchCaseAction = optMenu->addAction(tr("Match Case"));
    mMatchCaseAction->setCheckable(true);
    mRegExpAction = optMenu->addAction(tr("Regular Expression"));
    mRegExpAction->setCheckable(true);
    mWholeWordAction = optMenu->addAction(tr("Whole Words"));
    mWholeWordAction->setCheckable(true);
    mOptionsBtn->setMenu(optMenu);

    mFindLabel = new QLabel(tr("Find:"));
    mFindLabel->setAlignment(Qt::AlignRight | Qt::AlignVCenter);
    mReplaceLabel = new QLabel(tr("Replace:"));
    mReplaceLabel->setAlignment(Qt::AlignRight | Qt::AlignVCenter);

    mGrid = new QGridLayout();
    mGrid->setContentsMargins(0,0,0,0);
    mGrid->setSpacing(2);

    QHBoxLayout *findBtnLayout = new QHBoxLayout();
    findBtnLayout->setContentsMargins(0,0,0,0);
    findBtnLayout->setSpacing(1);
    findBtnLayout->addWidget(mPrevBtn);
    findBtnLayout->addWidget(mNextBtn);
    findBtnLayout->addStretch(0);
    findBtnLayout->addWidget(mOptionsBtn);

    mGrid->addWidget(mFindLabel, 0, 0);
    mGrid->addWidget(mFindField, 0, 1);
    mGrid->addLayout(findBtnLayout, 0, 2);

    QHBoxLayout *replaceBtnLayout = new QHBoxLayout();
    replaceBtnLayout->setContentsMargins(0,0,0,0);
    replaceBtnLayout->setSpacing(1);
    replaceBtnLayout->addWidget(mReplaceBtn);
    replaceBtnLayout->addWidget(mReplaceAllBtn);
    replaceBtnLayout->addStretch(0);

    mGrid->addWidget(mReplaceLabel, 1, 0);
    mGrid->addWidget(mReplaceField, 1, 1);
    mGrid->addLayout(replaceBtnLayout, 1, 2);

    mGrid->setColumnStretch(1,1);

    setLayout(mGrid);

    setMode(Find);

    setFocusProxy(mFindField);
    QWidget::setTabOrder(mFindField, mReplaceField);
    mFindField->installEventFilter(this);

    connect(mNextBtn, SIGNAL(clicked()), this, SLOT(findNext()));
    connect(mPrevBtn, SIGNAL(clicked()), this, SLOT(findPrevious()));
    connect(mReplaceBtn, SIGNAL(clicked()), this, SLOT(replace()));
    connect(mReplaceAllBtn, SIGNAL(clicked()), this, SLOT(replaceAll()));
    connect(mFindField, SIGNAL(returnPressed()), this, SLOT(onFindFieldReturn()));
    connect(mFindField, SIGNAL(textChanged(QString)), this, SLOT(onFindFieldTextChanged()));
    connect(mReplaceField, SIGNAL(returnPressed()), this, SLOT(replace()));
    // Update search results when options change:
    connect(optMenu, SIGNAL(triggered(QAction*)), this, SLOT(findAll()));

    Settings::Manager *settings = Main::settings();
    QAction *action;

    action = mActions[FindNext] = new QAction(tr("Find Next"), this);
    action->setShortcut(tr("Ctrl+G", "Find Next"));
    connect( action, SIGNAL(triggered()), this, SLOT(findNext()) );
    settings->addAction( action, "editor-find-next", tr("Text Editor") );

    action = mActions[FindPrevious] = new QAction(tr("Find Previous"), this);
    action->setShortcut(tr("Ctrl+Shift+G", "Find Previous"));
    connect( action, SIGNAL(triggered()), this, SLOT(findPrevious()) );
    settings->addAction( action, "editor-find-previous", tr("Text Editor") );
//.........这里部分代码省略.........
开发者ID:8c6794b6,项目名称:supercollider,代码行数:101,代码来源:find_replace_tool.cpp


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