本文整理汇总了C++中setCurrentAction函数的典型用法代码示例。如果您正苦于以下问题:C++ setCurrentAction函数的具体用法?C++ setCurrentAction怎么用?C++ setCurrentAction使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了setCurrentAction函数的16个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的C++代码示例。
示例1: setCurrentAction
void QG_GraphicView::mousePressEvent(QMouseEvent* e) {
// pan zoom with middle mouse button
#if QT_VERSION < 0x040700
if (e->button()==Qt::MidButton /*|| (e->state()==Qt::LeftButton|Qt::AltButton)*/) {
#else
if (e->button()==Qt::MiddleButton /*|| (e->state()==Qt::LeftButton|Qt::AltButton)*/) {
#endif
setCurrentAction(new RS_ActionZoomPan(*container, *this));
}
RS_GraphicView::mousePressEvent(e);
QWidget::mousePressEvent(e);
}
void QG_GraphicView::mouseDoubleClickEvent(QMouseEvent* e) {
// zoom auto with double click middle mouse button
#if QT_VERSION < 0x040700
if (e->button()==Qt::MidButton) {
#else
if (e->button()==Qt::MiddleButton) {
#endif
setCurrentAction(new RS_ActionZoomAuto(*container, *this));
e->accept();
}
}
void QG_GraphicView::mouseReleaseEvent(QMouseEvent* e) {
RS_DEBUG->print("QG_GraphicView::mouseReleaseEvent");
RS_GraphicView::mouseReleaseEvent(e);
//QWidget::mouseReleaseEvent(e);
if (!e->isAccepted()) {
if (QG_DIALOGFACTORY!=NULL && QG_DIALOGFACTORY->getCadToolBar()!=NULL) {
RS_DEBUG->print("QG_GraphicView::mouseReleaseEvent: "
"fwd to cadtoolbar");
QG_DIALOGFACTORY->getCadToolBar()->mouseReleaseEvent(e);
}
}
RS_DEBUG->print("QG_GraphicView::mouseReleaseEvent: OK");
}
void QG_GraphicView::mouseMoveEvent(QMouseEvent* e) {
//RS_DEBUG->print("QG_GraphicView::mouseMoveEvent begin");
//QMouseEvent rsm = QG_Qt2Rs::mouseEvent(e);
RS_GraphicView::mouseMoveEvent(e);
QWidget::mouseMoveEvent(e);
#ifdef Q_OS_WIN32
// make sure that we can still use hotkeys and the mouse wheel
if (parent()!=NULL) {
((QWidget*)parent())->setFocus();
}
#endif
//RS_DEBUG->print("QG_GraphicView::mouseMoveEvent end");
}
开发者ID:ASF-inhambane,项目名称:LibreCAD,代码行数:59,代码来源:qg_graphicview.cpp
示例2: toGraph
/**
* mouse wheel event. zooms in/out or scrolls when
* shift or ctrl is pressed.
*/
void QG_GraphicView::wheelEvent(QWheelEvent *e) {
//RS_DEBUG->print("wheel: %d", e->delta());
//printf("state: %d\n", e->state());
//printf("ctrl: %d\n", Qt::ControlButton);
if (container==NULL) {
return;
}
RS_Vector mouse = toGraph(RS_Vector(e->x(), e->y()));
bool scroll = false;
RS2::Direction direction = RS2::Up;
// scroll up / down:
if (e->modifiers()==Qt::ControlModifier) {
scroll = true;
if (e->delta()>0) {
direction = RS2::Up;
} else {
direction = RS2::Down;
}
}
// scroll left / right:
else if (e->modifiers()==Qt::ShiftModifier) {
scroll = true;
if (e->delta()>0) {
direction = RS2::Right;
} else {
direction = RS2::Left;
}
}
if (scroll) {
setCurrentAction(new RS_ActionZoomScroll(direction,
*container, *this));
}
// zoom in / out:
else if (e->modifiers()==0) {
if (e->delta()>0) {
setCurrentAction(new RS_ActionZoomIn(*container, *this,
RS2::In, RS2::Both,
mouse));
} else {
setCurrentAction(new RS_ActionZoomIn(*container, *this,
RS2::Out, RS2::Both,
mouse));
}
}
redraw();
e->accept();
}
开发者ID:CrazyHeex,项目名称:sodacad,代码行数:61,代码来源:qg_graphicview.cpp
示例3: setCurrentAction
void QG_ActionHandler::slotLockRelativeZero(bool on) {
if (lockRelativeZero!=NULL) {
lockRelativeZero->setOn(on);
}
if (on) {
setCurrentAction(RS2::ActionLockRelativeZero);
} else {
setCurrentAction(RS2::ActionUnlockRelativeZero);
}
#if QT_VERSION>=0x030000
if (cadToolBarSnap!=NULL) {
cadToolBarSnap->setLockRelativeZero(on);
}
#endif
}
开发者ID:Akaur,项目名称:qdraw,代码行数:15,代码来源:qg_actionhandler.cpp
示例4: connect
/*!
\internal
\brief Establishes all connections.
*/
void Ui::MainWindow::establishConnections()
{
Ui::CommonBar *commonBar = qobject_cast<Ui::CommonBar *>(actionManager->toolBar(Core::ID::COMMON_BAR));
connect(commonBar, SIGNAL(antialiasingChanged(bool)), this, SIGNAL(antialiasingChanged(bool)));
connect(newAction, SIGNAL(triggered()), this, SLOT(showProjectCreateDialog()));
connect(openAction, SIGNAL(triggered()), this, SLOT(showOpenDialog()));
//connect(actionManager->action(Core::ID::Action::NEW), SIGNAL(triggered()), this, SLOT(showPreferencesDialog()));
connect(aboutAction, SIGNAL(triggered()), this, SLOT(showAboutDialog()));
// tool box actions
connect(lineToolAction, SIGNAL(triggered()), mapper, SLOT(map()));
mapper->setMapping(lineToolAction, Core::ID::ACTION_DRAW_LINE);
connect(textToolAction, SIGNAL(triggered()), mapper, SLOT(map()));
mapper->setMapping(textToolAction, Core::ID::ACTION_DRAW_TEXT);
connect(curveToolAction, SIGNAL(triggered()), mapper, SLOT(map()));
mapper->setMapping(curveToolAction, Core::ID::ACTION_DRAW_CURVE);
connect(ellipseToolAction, SIGNAL(triggered()), mapper, SLOT(map()));
mapper->setMapping(ellipseToolAction, Core::ID::ACTION_DRAW_ELLIPSE);
connect(polygonToolAction, SIGNAL(triggered()), mapper, SLOT(map()));
mapper->setMapping(polygonToolAction, Core::ID::ACTION_DRAW_POLYGON);
connect(rectangleToolAction, SIGNAL(triggered()), mapper, SLOT(map()));
mapper->setMapping(rectangleToolAction, Core::ID::ACTION_DRAW_RECT);
connect(roundRectangleToolAction, SIGNAL(triggered()), mapper, SLOT(map()));
mapper->setMapping(roundRectangleToolAction, Core::ID::ACTION_DRAW_ROUND_RECT);
connect(mapper, SIGNAL(mapped(QString)), appCtx, SLOT(setCurrentAction(QString)));
connect(mapper, SIGNAL(mapped(QString)), commonBar, SLOT(resetCommonBar(QString)));
connect(ci, SIGNAL(foregroundColorChanged(QColor)), appCtx, SLOT(setPenColor(const QColor &)));
}
开发者ID:jaisurya,项目名称:picworks,代码行数:34,代码来源:mainwindow.cpp
示例5: mapFromGlobal
bool QG_GraphicView::event(QEvent *event) {
#if QT_VERSION >= 0x050200
if (event->type() == QEvent::NativeGesture) {
QNativeGestureEvent *nge = static_cast<QNativeGestureEvent *>(event);
if (nge->gestureType() == Qt::ZoomNativeGesture) {
double v = nge->value();
RS2::ZoomDirection direction;
double factor;
if (v < 0) {
direction = RS2::Out;
factor = 1-v;
} else {
direction = RS2::In;
factor = 1+v;
}
// It seems the NativeGestureEvent::pos() incorrectly reports global coordinates
QPoint g = mapFromGlobal(nge->globalPos());
RS_Vector mouse = toGraph(RS_Vector(g.x(), g.y()));
setCurrentAction(new RS_ActionZoomIn(*container, *this, direction,
RS2::Both, mouse, factor));
}
return true;
}
#endif
return QWidget::event(event);
}
开发者ID:ASF-inhambane,项目名称:LibreCAD,代码行数:30,代码来源:qg_graphicview.cpp
示例6: qSort
void KoZoomAction::regenerateItems(const qreal zoom, bool asCurrent)
{
// where we'll store sorted new zoom values
QList<qreal> zoomLevels;
zoomLevels << 33;
zoomLevels << 50;
zoomLevels << 75;
zoomLevels << 100;
zoomLevels << 125;
zoomLevels << 150;
zoomLevels << 200;
zoomLevels << 250;
zoomLevels << 350;
zoomLevels << 400;
zoomLevels << 450;
zoomLevels << 500;
if( !zoomLevels.contains( zoom*100 ) )
zoomLevels << zoom*100;
qSort(zoomLevels.begin(), zoomLevels.end());
// update items with new sorted zoom values
QStringList values;
if(d->zoomModes & KoZoomMode::ZOOM_WIDTH)
{
values << KoZoomMode::toString(KoZoomMode::ZOOM_WIDTH);
}
if(d->zoomModes & KoZoomMode::ZOOM_PAGE)
{
values << KoZoomMode::toString(KoZoomMode::ZOOM_PAGE);
}
foreach(qreal value, zoomLevels) {
if(value>10.0)
values << i18n("%1%", KGlobal::locale()->formatNumber(value, 0));
else
values << i18n("%1%", KGlobal::locale()->formatNumber(value, 1));
}
setItems( values );
if(d->input)
d->input->setZoomLevels(values);
if(asCurrent)
{
QString valueString;
if(zoom*100>10.0)
valueString = i18n("%1%", KGlobal::locale()->formatNumber(zoom*100, 0));
else
valueString = i18n("%1%", KGlobal::locale()->formatNumber(zoom*100, 1));
setCurrentAction(valueString);
if(d->input)
d->input->setCurrentZoomLevel(valueString);
}
}
开发者ID:KDE,项目名称:calligra-history,代码行数:59,代码来源:KoZoomAction.cpp
示例7: setCurrentAction
void QG_GraphicView::mousePressEvent(QMouseEvent* event)
{
// pan zoom with middle mouse button
if (event->button()==Qt::MiddleButton)
{
setCurrentAction(new RS_ActionZoomPan(*container, *this));
}
eventHandler->mousePressEvent(event);
}
开发者ID:LibreCAD,项目名称:LibreCAD,代码行数:9,代码来源:qg_graphicview.cpp
示例8: format
void FontSizeAction::setFontSize( qreal size )
{
if ( size == fontSize() ) {
const QString test = format(size);
Q_FOREACH(QAction* action, actions()) {
if (action->text() == test) {
setCurrentAction(action);
return;
}
}
}
if ( size < 1 ) {
kWarning() << "FontSizeAction: Size " << size << " is out of range";
return;
}
QAction* a = action( format(size) );
if ( !a ) {
// Insert at the correct position in the list (to keep sorting)
QList<qreal> lst;
// Convert to list of qreals
QStringListIterator itemsIt( items() );
QStringList debug_lst = items();
while ( itemsIt.hasNext() ) {
lst.append( itemsIt.next().toDouble() );
}
//add the new size
lst.append( size );
//remove actions
clear();
// Sort the list
qSort( lst );
Q_FOREACH( qreal it, lst ) {
KAction* const action = addAction( format(it) );
if (it == size) {
setCurrentAction(action);
}
}
开发者ID:abhishekmurthy,项目名称:Calligra,代码行数:42,代码来源:FontSizeAction.cpp
示例9: disableRestrictions
void QG_ActionHandler::slotRestrictVertical() {
disableRestrictions();
if (restrictVertical!=NULL) {
restrictVertical->setOn(true);
}
#if QT_VERSION>=0x030000
if (cadToolBarSnap!=NULL) {
cadToolBarSnap->setSnapRestriction(RS2::RestrictVertical);
}
#endif
setCurrentAction(RS2::ActionRestrictVertical);
}
开发者ID:Akaur,项目名称:qdraw,代码行数:12,代码来源:qg_actionhandler.cpp
示例10: disableSnaps
void QG_ActionHandler::slotSnapIntersection() {
disableSnaps();
if (snapIntersection!=NULL) {
snapIntersection->setOn(true);
}
#if QT_VERSION>=0x030000
if (cadToolBarSnap!=NULL) {
cadToolBarSnap->setSnapMode(RS2::SnapIntersection);
}
#endif
setCurrentAction(RS2::ActionSnapIntersection);
}
开发者ID:Akaur,项目名称:qdraw,代码行数:12,代码来源:qg_actionhandler.cpp
示例11: framework
void QueryFinishWizardPage::initializePage()
{
m_result->clear();
ui.progressBar->setValue(0);
Framework* fw = framework();
setCurrentAction(tr("Collecting information..."));
quint32 storeId = field("store").value<quint32>();
const QString queryStr = field("query").toString();
setCurrentAction(tr("Looking for store..."));
const DataStore* dataStore = fw->dataStoreById(storeId);
if(dataStore == NULL) return;
setCurrentAction(tr("Store found..."));
setCurrentAction(tr("Parsing query..."));
CGSQL_NS::RootNode *root = CGSQL_NS::QueryParser::parse(queryStr.toStdString());
if (root == NULL)
{
setCurrentAction("Error while parting query.");
return;
}
pgn::GameCollection loadedGames;
setCurrentAction(tr("Retrieving games from %1...").arg(dataStore->name().toLower()));
bool loadResult = dataStore->load(root, loadedGames);
if(!loadResult)
{
setCurrentAction(tr("Can not load games from %1...").arg(dataStore->name().toLower()));
return;
}
setCurrentAction(tr("Loaded %1 games. Looking for concepts in its...").arg(loadedGames.size()));
QProgressDialog* progressDialog = new QProgressDialog("Searching for concepts", "Cancel", 0, loadedGames.size());
progressDialog->setWindowModality(Qt::WindowModal);
progressDialog->setValue(0);
int progress = 0;
for(pgn::GameCollection::iterator it = loadedGames.begin();
it != loadedGames.end();
++it)
{
progressDialog->show();
m_result->data().addGame(&(*it));
if(root->body()->accept(&(m_result->data())))
m_result->games().insert(*it);
progressDialog->setValue(progress);
++progress;
}
progressDialog->setValue(100);
progressDialog->setAutoClose(true);
progressDialog->reset();
progressDialog->show();
progressDialog->deleteLater();
ui.progressBar->setValue(100);
}
开发者ID:edwardoid,项目名称:DarkKnight,代码行数:50,代码来源:QueryFinishWizardPage.cpp
示例12: switch
void QG_GraphicView::mouseDoubleClickEvent(QMouseEvent* e)
{
switch(e->button())
{
default:
break;
case Qt::MiddleButton:
setCurrentAction(new RS_ActionZoomAuto(*container, *this));
break;
case Qt::LeftButton:
if (menus.contains("Double-Click"))
{
killAllActions();
menus["Double-Click"]->popup(mapToGlobal(e->pos()));
}
break;
}
e->accept();
}
开发者ID:LibreCAD,项目名称:LibreCAD,代码行数:19,代码来源:qg_graphicview.cpp
示例13: switch
void QG_GraphicView::keyPressEvent(QKeyEvent* e) {
//if (e->key()==Qt::Key_Control) {
// setCtrlPressed(true);
//}
if (container==NULL) {
return;
}
bool scroll = false;
RS2::Direction direction = RS2::Up;
switch (e->key()) {
case Qt::Key_Left:
scroll = true;
direction = RS2::Right;
break;
case Qt::Key_Right:
scroll = true;
direction = RS2::Left;
break;
case Qt::Key_Up:
scroll = true;
direction = RS2::Up;
break;
case Qt::Key_Down:
scroll = true;
direction = RS2::Down;
break;
default:
scroll = false;
break;
}
if (scroll) {
setCurrentAction(new RS_ActionZoomScroll(direction,
*container, *this));
}
RS_GraphicView::keyPressEvent(e);
}
开发者ID:ASF-inhambane,项目名称:LibreCAD,代码行数:42,代码来源:qg_graphicview.cpp
示例14: e
/**
* Launches the given command if possible.
*
* @return true: the command was recognized.
* false: the command is not known and was probably intended for a
* running action.
*/
bool QG_ActionHandler::command(const QString& cmd) {
RS_DEBUG->print("QG_ActionHandler::command: %s", cmd.latin1());
QString c = cmd.lower();
if (c=="\n") {
RS_GraphicView* gv = mainWindow->getGraphicView();
if (gv!=NULL) {
gv->back();
}
RS_DEBUG->print("QG_ActionHandler::command: back");
return true;
}
// pass command on to running action:
RS_CommandEvent e(cmd);
RS_GraphicView* gv = mainWindow->getGraphicView();
if (gv!=NULL) {
RS_DEBUG->print("QG_ActionHandler::command: trigger command event in "
" graphic view");
gv->commandEvent(&e);
}
// if the current action can't deal with the command,
// it might be intended to launch a new command
if (!e.isAccepted()) {
RS_DEBUG->print("QG_ActionHandler::command: convert cmd to action type");
// command for new action:
RS2::ActionType type = RS_COMMANDS->cmdToAction(cmd);
if (type!=RS2::ActionNone) {
RS_DEBUG->print("QG_ActionHandler::command: setting current action");
setCurrentAction(type);
RS_DEBUG->print("QG_ActionHandler::command: current action set");
return true;
}
}
RS_DEBUG->print("QG_ActionHandler::command: current action not set");
return false;
}
开发者ID:Akaur,项目名称:qdraw,代码行数:47,代码来源:qg_actionhandler.cpp
示例15: toGraph
/**
* mouse wheel event. zooms in/out or scrolls when
* shift or ctrl is pressed.
*/
void QG_GraphicView::wheelEvent(QWheelEvent *e) {
//RS_DEBUG->print("wheel: %d", e->delta());
//printf("state: %d\n", e->state());
//printf("ctrl: %d\n", Qt::ControlButton);
if (container==NULL) {
return;
}
RS_Vector mouse = toGraph(RS_Vector(e->x(), e->y()));
#if QT_VERSION >= 0x050200
QPoint numPixels = e->pixelDelta();
// high-resolution scrolling triggers Pan instead of Zoom logic
isSmoothScrolling |= !numPixels.isNull();
if (isSmoothScrolling) {
if (e->phase() == Qt::ScrollEnd) isSmoothScrolling = false;
if (!numPixels.isNull()) {
if (e->modifiers()==Qt::ControlModifier) {
// Hold ctrl to zoom. 1 % per pixel
double v = -numPixels.y() / 100.;
RS2::ZoomDirection direction;
double factor;
if (v < 0) {
direction = RS2::Out; factor = 1-v;
} else {
direction = RS2::In; factor = 1+v;
}
setCurrentAction(new RS_ActionZoomIn(*container, *this, direction,
RS2::Both, mouse, factor));
} else {
// otherwise, scroll
setCurrentAction(new RS_ActionZoomScroll(numPixels.x(), numPixels.y(),
*container, *this));
}
redraw();
}
e->accept();
return;
}
#endif
if (e->delta() == 0) {
// A zero delta event occurs when smooth scrolling is ended. Ignore this
e->accept();
return;
}
bool scroll = false;
RS2::Direction direction = RS2::Up;
// scroll up / down:
if (e->modifiers()==Qt::ControlModifier) {
scroll = true;
switch(e->orientation()){
case Qt::Horizontal:
direction=(e->delta()>0)?RS2::Left:RS2::Right;
break;
default:
case Qt::Vertical:
direction=(e->delta()>0)?RS2::Up:RS2::Down;
}
}
// scroll left / right:
else if (e->modifiers()==Qt::ShiftModifier) {
scroll = true;
switch(e->orientation()){
case Qt::Horizontal:
direction=(e->delta()>0)?RS2::Up:RS2::Down;
break;
default:
case Qt::Vertical:
direction=(e->delta()>0)?RS2::Left:RS2::Right;
}
}
if (scroll) {
setCurrentAction(new RS_ActionZoomScroll(direction,
*container, *this));
}
// zoom in / out:
else if (e->modifiers()==0) {
if (e->delta()>0) {
setCurrentAction(new RS_ActionZoomIn(*container, *this,
RS2::In, RS2::Both,
mouse));
} else {
setCurrentAction(new RS_ActionZoomIn(*container, *this,
//.........这里部分代码省略.........
开发者ID:ASF-inhambane,项目名称:LibreCAD,代码行数:101,代码来源:qg_graphicview.cpp
示例16: toGraph
/**
* mouse wheel event. zooms in/out or scrolls when
* shift or ctrl is pressed.
*/
void QG_GraphicView::wheelEvent(QWheelEvent *e) {
//RS_DEBUG->print("wheel: %d", e->delta());
//printf("state: %d\n", e->state());
//printf("ctrl: %d\n", Qt::ControlButton);
if (container==NULL) {
return;
}
RS_Vector mouse = toGraph(e->x(), e->y());
if (device == "Trackpad")
{
QPoint numPixels = e->pixelDelta();
// high-resolution scrolling triggers Pan instead of Zoom logic
isSmoothScrolling |= !numPixels.isNull();
if (isSmoothScrolling)
{
if (e->phase() == Qt::ScrollEnd) isSmoothScrolling = false;
}
else // Trackpads that without high-resolution scrolling
// e.g. libinput-XWayland trackpads
{
numPixels = e->angleDelta() / 4;
}
if (!numPixels.isNull())
{
if (e->modifiers()==Qt::ControlModifier)
{
RS_SETTINGS->beginGroup("/Defaults");
bool invZoom = (RS_SETTINGS->readNumEntry("/InvertZoomDirection", 0) == 1);
RS_SETTINGS->endGroup();
// Hold ctrl to zoom. 1 % per pixel
double v = (invZoom) ? (numPixels.y() / 100.) : (-numPixels.y() / 100.);
RS2::ZoomDirection direction;
double factor;
if (v < 0) {
direction = RS2::Out; factor = 1-v;
} else {
direction = RS2::In; factor = 1+v;
}
setCurrentAction(new RS_ActionZoomIn(*container, *this, direction,
RS2::Both, &mouse, factor));
}
else
{
RS_SETTINGS->beginGroup("/Defaults");
bool inv_h = (RS_SETTINGS->readNumEntry("/WheelScrollInvertH", 0) == 1);
bool inv_v = (RS_SETTINGS->readNumEntry("/WheelScrollInvertV", 0) == 1);
RS_SETTINGS->endGroup();
int hDelta = (inv_h) ? -numPixels.x() : numPixels.x();
int vDelta = (inv_v) ? -numPixels.y() : numPixels.y();
// scroll by scrollbars: issue #479 (it has its own issues)
if (scrollbars)
{
hScrollBar->setValue(hScrollBar->value() - hDelta);
vScrollBar->setValue(vScrollBar->value() - vDelta);
}
else
{
setCurrentAction(new RS_ActionZoomScroll(hDelta, vDelta,
*container, *this));
}
}
redraw();
}
e->accept();
return;
}
if (e->delta() == 0) {
// A zero delta event occurs when smooth scrolling is ended. Ignore this
e->accept();
return;
}
bool scroll = false;
RS2::Direction direction = RS2::Up;
// scroll up / down:
if (e->modifiers()==Qt::ControlModifier) {
scroll = true;
switch(e->orientation()){
case Qt::Horizontal:
direction=(e->delta()>0)?RS2::Left:RS2::Right;
break;
default:
//.........这里部分代码省略.........
开发者ID:LibreCAD,项目名称:LibreCAD,代码行数:101,代码来源:qg_graphicview.cpp
注:本文中的setCurrentAction函数示例由纯净天空整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论