本文整理汇总了C++中QAction::setShortcutContext方法的典型用法代码示例。如果您正苦于以下问题:C++ QAction::setShortcutContext方法的具体用法?C++ QAction::setShortcutContext怎么用?C++ QAction::setShortcutContext使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类QAction
的用法示例。
在下文中一共展示了QAction::setShortcutContext方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: QTextEdit
LuaEditor::LuaEditor(QWidget* pa) : QTextEdit(pa), parent(pa)
{
highlighter = new Highlighter(document());
QStringList names = QFontDatabase().families();
QStringList prefs;
prefs << "DejaVu Sans Mono" << "Bitstream Vera Sans Mono" << "Terminus"
<< "Fixed";
foreach (QString p, prefs)
if (names.contains(p, Qt::CaseInsensitive))
{
logInfo(QString("LuaEditor::LuaEditor : found font %1").arg(p));
setFontFamily(p);
break;
}
QAction* a = new QAction(tr("Open a file"), this);
a->setShortcut(tr("Ctrl+1"));
a->setShortcutContext(Qt::WidgetShortcut);
addAction(a);
connect(a, SIGNAL(triggered()), this, SLOT(load()));
a = new QAction(tr("Save file"), this);
a->setShortcut(tr("Ctrl+2"));
a->setShortcutContext(Qt::WidgetShortcut);
addAction(a);
connect(a, SIGNAL(triggered()), this, SLOT(save()));
a = new QAction(tr("Save to file"), this);
a->setShortcut(tr("Ctrl+3"));
a->setShortcutContext(Qt::WidgetShortcut);
addAction(a);
connect(a, SIGNAL(triggered()), this, SLOT(saveAs()));
}
示例2: initializeActions
void SCgMainWindow::initializeActions()
{
QUndoStack* undoStack = mScene->undoStack();
QAction* actionRedo = undoStack->createRedoAction(mScene);
actionRedo->setShortcut(QKeySequence::Redo);
// actionRedo->setShortcutContext(Qt::WidgetShortcut);
QAction* actionUndo = undoStack->createUndoAction(mScene);
actionUndo->setShortcut(QKeySequence::Undo);
// actionUndo->setShortcutContext(Qt::WidgetShortcut);
QAction* actionDelete = new QAction("Delete", mScene);
actionDelete->setShortcut(QKeySequence::Delete);
connect(actionDelete, SIGNAL(triggered()), mInputHandler, SLOT(deleteSelected()));
actionDelete->setShortcutContext(Qt::WidgetShortcut);
QAction* actionDeleteJustContour = new QAction("Delete just contour", mScene);
actionDeleteJustContour->setShortcut( QKeySequence(tr("Backspace")) );
connect(actionDeleteJustContour, SIGNAL(triggered()), mInputHandler, SLOT(deleteJustContour()));
actionDeleteJustContour->setShortcutContext(Qt::WidgetShortcut);
mView->addAction(actionDeleteJustContour);
mView->addAction(actionDelete);
mView->addAction(actionRedo);
mView->addAction(actionUndo);
}
示例3: QWidget
Editor::Editor(QWidget *parent)
: QWidget(parent)
, _view(NULL)
, _buttonBar(NULL)
, _xmlPreview(NULL)
, _assembly(NULL)
, _viewController(NULL)
, _editorController(NULL)
, _buttonBarController(NULL)
{
qRegisterMetaType<ItemMove>("ItemMove");
qRegisterMetaType<ItemsMove>("ItemsMove");
// Widgets
_view = new GraphicsView;
_buttonBar = new ButtonBar;
_buttonBar->setEnabled(false);
_xmlPreview = new QTextEdit;
_xmlPreview->setReadOnly(true);
QVBoxLayout* vLyt = new QVBoxLayout(this);
vLyt->setMargin(0);
vLyt->setSpacing(1);
vLyt->addWidget(_view, 4);
vLyt->addWidget(_buttonBar);
vLyt->addWidget(_xmlPreview, 1);
// Controllers
_viewController = new ViewController(_view, this);
_buttonBarController = new ButtonBarController(_buttonBar, this);
connect(_viewController, SIGNAL(selectionChanged(int)),
_buttonBarController, SLOT(onSelectionChanged(int)));
_editorController = new EditorController(this);
connect(_viewController, SIGNAL(elementsMoved(ItemsMove)),
_editorController, SLOT(onElementsMoved(ItemsMove)));
connect(_buttonBarController, SIGNAL(actionTriggered(int,Action)),
_editorController, SLOT(onAction(int,Action)));
connect(_buttonBarController, SIGNAL(actionValueTriggered(int,Action,qreal)),
_editorController, SLOT(onActionValue(int,Action,qreal)));
connect(_buttonBarController, SIGNAL(nameChanged(QString)),
_editorController, SLOT(onNameEdited(QString)));
QAction* redoAction = _editorController->undoStack()->createRedoAction(this);
redoAction->setShortcut(QKeySequence::Redo);
redoAction->setShortcutContext(Qt::WidgetWithChildrenShortcut);
this->addAction(redoAction);
QAction* undoAction = _editorController->undoStack()->createUndoAction(this);
undoAction->setShortcut(QKeySequence::Undo);
undoAction->setShortcutContext(Qt::WidgetWithChildrenShortcut);
this->addAction(undoAction);
}
示例4: manual
UserManual::UserManual(QWidget *parent) : QMainWindow(parent),
ui(new Ui::UserManual)
{
ui->setupUi(this);
QShortcut *closeKey = new QShortcut(QKeySequence(Qt::CTRL + Qt::Key_W), this);
connect(closeKey, SIGNAL(activated()), this, SLOT(close()));
QShortcut *quitKey = new QShortcut(QKeySequence(Qt::CTRL + Qt::Key_Q), this);
connect(quitKey, SIGNAL(activated()), parent, SLOT(close()));
QAction *actionShowSearch = new QAction(this);
actionShowSearch->setShortcut(Qt::CTRL + Qt::Key_F);
actionShowSearch->setShortcutContext(Qt::WindowShortcut);
addAction(actionShowSearch);
QAction *actionHideSearch = new QAction(this);
actionHideSearch->setShortcut(Qt::Key_Escape);
actionHideSearch->setShortcutContext(Qt::WindowShortcut);
addAction(actionHideSearch);
setWindowTitle(tr("User Manual"));
ui->webView->page()->setLinkDelegationPolicy(QWebPage::DelegateExternalLinks);
QString searchPath = getSubsurfaceDataPath("Documentation");
if (searchPath.size()) {
// look for localized versions of the manual first
QString lang = uiLanguage(NULL);
QString prefix = searchPath.append("/user-manual");
QFile manual(prefix + "_" + lang + ".html");
if (!manual.exists())
manual.setFileName(prefix + "_" + lang.left(2) + ".html");
if (!manual.exists())
manual.setFileName(prefix + ".html");
if (!manual.exists()) {
ui->webView->setHtml(tr("Cannot find the Subsurface manual"));
} else {
QString urlString = QString("file:///") + manual.fileName();
QUrl url(urlString, QUrl::TolerantMode);
ui->webView->setUrl(url);
}
} else {
ui->webView->setHtml(tr("Cannot find the Subsurface manual"));
}
ui->searchPanel->setParent(this);
ui->searchPanel->hide();
connect(actionShowSearch, SIGNAL(triggered(bool)), this, SLOT(showSearchPanel()));
connect(actionHideSearch, SIGNAL(triggered(bool)), this, SLOT(hideSearchPanel()));
connect(ui->webView, SIGNAL(linkClicked(QUrl)), this, SLOT(linkClickedSlot(QUrl)));
connect(ui->searchEdit, SIGNAL(textChanged(QString)), this, SLOT(searchTextChanged(QString)));
connect(ui->findNext, SIGNAL(clicked()), this, SLOT(searchNext()));
connect(ui->findPrev, SIGNAL(clicked()), this, SLOT(searchPrev()));
}
示例5: QWidget
URLListWidget::URLListWidget(URLListController *_ctrl)
: QWidget(), ctrl(_ctrl), connectToDbDialog(new SharedConnectionsDialog(this)), waitingForDbToConnect(false)
{
setupUi(this);
popup = new OptionsPopup(this);
reset();
QIcon fileIcon = QIcon(QString(":U2Designer/images/add_file.png"));
QIcon dirIcon = QIcon(QString(":U2Designer/images/add_directory.png"));
QIcon dbIcon = QIcon(QString(":U2Designer/images/database_add.png"));
QIcon deleteIcon = QIcon(QString(":U2Designer/images/exit.png"));
QIcon upIcon = QIcon(QString(":U2Designer/images/up.png"));
QIcon downIcon = QIcon(QString(":U2Designer/images/down.png"));
addFileButton->setIcon(fileIcon);
addDirButton->setIcon(dirIcon);
addFromDbButton->setIcon(dbIcon);
deleteButton->setIcon(deleteIcon);
upButton->setIcon(upIcon);
downButton->setIcon(downIcon);
connect(addFileButton, SIGNAL(clicked()), SLOT(sl_addFileButton()));
connect(addDirButton, SIGNAL(clicked()), SLOT(sl_addDirButton()));
connect(addFromDbButton, SIGNAL(clicked()), SLOT(sl_addFromDbButton()));
connect(downButton, SIGNAL(clicked()), SLOT(sl_downButton()));
connect(upButton, SIGNAL(clicked()), SLOT(sl_upButton()));
connect(deleteButton, SIGNAL(clicked()), SLOT(sl_deleteButton()));
connect(connectToDbDialog.data(), SIGNAL(si_connectionCompleted()), SLOT(sl_sharedDbConnected()));
connect(itemsArea, SIGNAL(itemSelectionChanged()), SLOT(sl_itemChecked()));
if (!readingFromDbIsSupported()) {
addFromDbButton->hide();
}
QAction *deleteAction = new QAction(itemsArea);
deleteAction->setShortcut(QKeySequence::Delete);
deleteAction->setShortcutContext(Qt::WidgetShortcut);
connect(deleteAction, SIGNAL(triggered()), SLOT(sl_deleteButton()));
itemsArea->addAction(deleteAction);
QAction *selectAction = new QAction(itemsArea);
selectAction->setShortcut(QKeySequence::SelectAll);
selectAction->setShortcutContext(Qt::WidgetShortcut);
connect(selectAction, SIGNAL(triggered()), SLOT(sl_selectAll()));
itemsArea->addAction(selectAction);
itemsArea->installEventFilter(this);
}
示例6: setupMainMenu
void RepoWindow::setupMainMenu()
{
QMenu * m = ui->menuBar->addMenu("Repository");
QAction * a = m->addAction("Open ...", this, SLOT(openRepository()));
a->setShortcut(QKeySequence(Qt::CTRL + Qt::Key_O));
a->setShortcutContext(Qt::ApplicationShortcut);
}
示例7: scanWorlds
void MainWindow::scanWorlds() {
ui->menuOpen_World->clear();
bool enabled = false;
int key = 0;
for (const QString &worldDir : settings->getWorlds()) {
QDir dir(worldDir);
QDirIterator it(dir);
QList<QAction *> actions;
while (it.hasNext()) {
it.next();
if (it.fileName().endsWith(".wld")) {
QString name = worldName(it.filePath());
if (!name.isNull()) {
QAction *w = new QAction(this);
w->setText(name);
w->setData(it.filePath());
if (key < 9) {
w->setShortcut(QKeySequence(Qt::CTRL + Qt::Key_1 + key++));
w->setShortcutContext(Qt::ApplicationShortcut);
}
connect(w, SIGNAL(triggered()),
this, SLOT(openWorld()));
actions.append(w);
}
}
}
if (!actions.isEmpty()) {
ui->menuOpen_World->addSection(worldDir);
ui->menuOpen_World->addActions(actions);
enabled = true;
}
}
ui->menuOpen_World->setDisabled(!enabled);
}
示例8: QTreeView
DiveListView::DiveListView(QWidget *parent) : QTreeView(parent), mouseClickSelection(false),
currentHeaderClicked(-1), searchBox(new QLineEdit(this))
{
setUniformRowHeights(true);
setItemDelegateForColumn(TreeItemDT::RATING, new StarWidgetsDelegate());
QSortFilterProxyModel *model = new QSortFilterProxyModel(this);
model->setSortRole(TreeItemDT::SORT_ROLE);
model->setFilterKeyColumn(-1); // filter all columns
setModel(model);
connect(model, SIGNAL(layoutChanged()), this, SLOT(fixMessyQtModelBehaviour()));
setSortingEnabled(false);
setContextMenuPolicy(Qt::DefaultContextMenu);
header()->setContextMenuPolicy(Qt::ActionsContextMenu);
QAction *showSearchBox = new QAction(tr("Show Search Box"), this);
showSearchBox->setShortcut( Qt::CTRL + Qt::Key_F);
showSearchBox->setShortcutContext(Qt::ApplicationShortcut);
addAction(showSearchBox);
searchBox->installEventFilter(this);
searchBox->hide();
connect(showSearchBox, SIGNAL(triggered(bool)), this, SLOT(showSearchEdit()));
connect(searchBox, SIGNAL(textChanged(QString)), model, SLOT(setFilterFixedString(QString)));
selectedTrips.clear();
}
示例9: toQAction
QAction* ActionResource::toQAction() const {
Log log( Log::LT_TRACE, Log::MOD_MAIN, "QAction* ActionResource::toQAction() const" );
if( !( m_Type == AT_ITEM || m_Type == AT_SEPARATOR ) ) {
return NULL;
};
log.write( Log::LT_TRACE, "Produce item %s", getText() );
QAction* act = new QAction( getText(), NULL );
act->setAutoRepeat( getAutoRepeat() );
act->setCheckable( getCheckable() );
act->setChecked( getChecked() );
act->setData( getData() );
act->setFont( getFont() );
act->setIcon( getIcon() );
act->setIconVisibleInMenu( getIconVisibleInMenu() );
act->setMenuRole( getMenuRole() );
act->setSeparator( m_Type == AT_SEPARATOR );
act->setShortcut( getShortcut() );
act->setShortcutContext( getShortcutContext() );
act->setStatusTip( getStatusTip() );
act->setToolTip( getTooltip() );
act->setVisible( getVisible() );
act->setWhatsThis( getWhatsThis() );
return act;
};
示例10:
QAction *KeySequence::widget(QWidget *widget, Qt::ShortcutContext context,
const QObject *receiver, const char *member)
{
QAction *act = KeySequence::action(widget, receiver, member);
act->setShortcutContext(context);
return act;
}
示例11: QDesignerObjectInspector
// ------------ ObjectInspector
ObjectInspector::ObjectInspector(QDesignerFormEditorInterface *core, QWidget *parent) :
QDesignerObjectInspector(parent),
m_impl(new ObjectInspectorPrivate(core))
{
QVBoxLayout *vbox = new QVBoxLayout(this);
vbox->setMargin(0);
QTreeView *treeView = m_impl->treeView();
vbox->addWidget(treeView);
connect(treeView, SIGNAL(customContextMenuRequested(QPoint)),
this, SLOT(slotPopupContextMenu(QPoint)));
connect(treeView->selectionModel(), SIGNAL(selectionChanged(QItemSelection,QItemSelection)),
this, SLOT(slotSelectionChanged(QItemSelection,QItemSelection)));
connect(treeView->header(), SIGNAL(sectionDoubleClicked(int)), this, SLOT(slotHeaderDoubleClicked(int)));
setAcceptDrops(true);
ItemViewFindWidget *findWidget = m_impl->findWidget();
vbox->addWidget(findWidget);
findWidget->setItemView(treeView);
QAction *findAction = new QAction(
ItemViewFindWidget::findIconSet(),
tr("&Find in Text..."),
this);
findAction->setShortcut(QKeySequence::Find);
findAction->setShortcutContext(Qt::WidgetWithChildrenShortcut);
addAction(findAction);
connect(findAction, SIGNAL(triggered(bool)), findWidget, SLOT(activate()));
}
示例12: file
FormEditorMainWidget::FormEditorMainWidget(FormEditorMainView *mainView)
: QWidget(),
m_formEditorMainView(mainView),
m_stackedWidget(new QStackedWidget(this))
{
QFile file(":/qmldesigner/formeditorstylesheet.css");
file.open(QFile::ReadOnly);
QString styleSheet = QLatin1String(file.readAll());
setStyleSheet(styleSheet);
QVBoxLayout *fillLayout = new QVBoxLayout(this);
fillLayout->setMargin(0);
fillLayout->setSpacing(0);
setLayout(fillLayout);
QActionGroup *toolActionGroup = new QActionGroup(this);
QAction *transformToolAction = toolActionGroup->addAction("Transform Tool (Press Key Q)");
transformToolAction->setShortcut(Qt::Key_Q);
transformToolAction->setShortcutContext(Qt::WidgetWithChildrenShortcut);
transformToolAction->setCheckable(true);
transformToolAction->setChecked(true);
transformToolAction->setIcon(QPixmap(":/icon/tool/transform.png"));
connect(transformToolAction, SIGNAL(triggered(bool)), SLOT(changeTransformTool(bool)));
QAction *anchorToolAction = toolActionGroup->addAction("Anchor Tool (Press Key W)");
anchorToolAction->setShortcut(Qt::Key_W);
anchorToolAction->setShortcutContext(Qt::WidgetWithChildrenShortcut);
anchorToolAction->setCheckable(true);
anchorToolAction->setIcon(QPixmap(":/icon/tool/anchor.png"));
connect(anchorToolAction, SIGNAL(triggered(bool)), SLOT(changeAnchorTool(bool)));
addActions(toolActionGroup->actions());
m_componentAction = new ComponentAction(toolActionGroup);
addAction(m_componentAction.data());
m_zoomAction = new ZoomAction(toolActionGroup);
addAction(m_zoomAction.data());
ToolBox *toolBox = new ToolBox(this);
toolBox->setActions(actions());
fillLayout->addWidget(toolBox);
fillLayout->addWidget(m_stackedWidget.data());
}
示例13: registerAction
void ActionsManager::registerAction(const QLatin1String &name, const QString &text, const QIcon &icon)
{
QAction *action = new QAction(icon, text, m_instance);
action->setObjectName(name);
action->setShortcutContext(Qt::ApplicationShortcut);
m_applicationActions[name] = action;
}
示例14: QAction
QAction *RemoveTaskHandler::createAction(QObject *parent) const
{
QAction *removeAction = new QAction(tr("Remove", "Name of the action triggering the removetaskhandler"), parent);
removeAction->setToolTip(tr("Remove task from the task list."));
removeAction->setShortcut(QKeySequence(QKeySequence::Delete));
removeAction->setShortcutContext(Qt::WidgetWithChildrenShortcut);
return removeAction;
}
示例15: initialize
void MainWindow::initialize(TraceModelPtr& model)
{
model = restoreModel(model);//? trying to take settings from QSettings, but this is sooo bad
initCanvas(model);
// Restore window geometry
QRect r = restoreGeometry();
if (r.isValid())
{
setGeometry(r);
}
else
{
r = QApplication::desktop()->screenGeometry();
resize(r.width(), r.height());
}
initToolbar();
initSidebar();
xinitialize(sidebarContents, canvas);
toolbar->addActions(modeActions->actions());
Q_ASSERT(browser);
browser->addToolbarActions(toolbar);
QAction* resetView = new QAction(this);
resetView->setShortcut(Qt::Key_Escape);
resetView->setShortcutContext(Qt::WindowShortcut);
addAction(resetView);
connect(resetView, SIGNAL(triggered(bool)), this,
SLOT(resetView()));
toolbar->addSeparator();
// Restore time unit and format
QSettings settings;
QString time_unit = settings.value("time_unit", Time::unit_name(0)).toString();
for(int i = 0; i < Time::units().size(); ++i)
{
if (Time::unit_name(i) == time_unit)
{
Time::setUnit(i);
break;
}
}
if (settings.value("time_format", "separated") == "separated")
{
Time::setFormat(Time::Advanced);
}
// Adding freestanding tools
foreach (QAction * action, freestandingTools)
{
toolbar->addAction(action);
}