本文整理汇总了C++中QUndoGroup::createRedoAction方法的典型用法代码示例。如果您正苦于以下问题:C++ QUndoGroup::createRedoAction方法的具体用法?C++ QUndoGroup::createRedoAction怎么用?C++ QUndoGroup::createRedoAction使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类QUndoGroup
的用法示例。
在下文中一共展示了QUndoGroup::createRedoAction方法的6个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: commandTextFormat
void tst_QUndoGroup::commandTextFormat()
{
QString binDir = QLibraryInfo::location(QLibraryInfo::BinariesPath);
if (QProcess::execute(binDir + "/lrelease -version") != 0)
QSKIP("lrelease is missing or broken");
const QString tsFile = QFINDTESTDATA("testdata/qundogroup.ts");
QVERIFY(!tsFile.isEmpty());
QVERIFY(!QProcess::execute(binDir + "/lrelease " + tsFile));
QTranslator translator;
const QString qmFile = QFINDTESTDATA("testdata/qundogroup.qm");
QVERIFY(!qmFile.isEmpty());
QVERIFY(translator.load(qmFile));
qApp->installTranslator(&translator);
QUndoGroup group;
QAction *undo_action = group.createUndoAction(0);
QAction *redo_action = group.createRedoAction(0);
QCOMPARE(undo_action->text(), QString("Undo-default-text"));
QCOMPARE(redo_action->text(), QString("Redo-default-text"));
QUndoStack stack(&group);
stack.setActive();
QString str;
stack.push(new AppendCommand(&str, "foo"));
QCOMPARE(undo_action->text(), QString("undo-prefix append undo-suffix"));
QCOMPARE(redo_action->text(), QString("Redo-default-text"));
stack.push(new InsertCommand(&str, 0, "bar"));
stack.undo();
QCOMPARE(undo_action->text(), QString("undo-prefix append undo-suffix"));
QCOMPARE(redo_action->text(), QString("redo-prefix insert redo-suffix"));
stack.undo();
QCOMPARE(undo_action->text(), QString("Undo-default-text"));
QCOMPARE(redo_action->text(), QString("redo-prefix append redo-suffix"));
qApp->removeTranslator(&translator);
}
示例2: checkSignals
void tst_QUndoGroup::checkSignals()
{
QUndoGroup group;
QAction *undo_action = group.createUndoAction(0, QString("foo"));
QAction *redo_action = group.createRedoAction(0, QString("bar"));
QSignalSpy indexChangedSpy(&group, SIGNAL(indexChanged(int)));
QSignalSpy cleanChangedSpy(&group, SIGNAL(cleanChanged(bool)));
QSignalSpy canUndoChangedSpy(&group, SIGNAL(canUndoChanged(bool)));
QSignalSpy undoTextChangedSpy(&group, SIGNAL(undoTextChanged(QString)));
QSignalSpy canRedoChangedSpy(&group, SIGNAL(canRedoChanged(bool)));
QSignalSpy redoTextChangedSpy(&group, SIGNAL(redoTextChanged(QString)));
QString str;
CHECK_STATE(0, // activeStack
true, // clean
false, // canUndo
"", // undoText
false, // canRedo
"", // redoText
false, // cleanChanged
false, // indexChanged
false, // undoChanged
false) // redoChanged
group.undo();
CHECK_STATE(0, // activeStack
true, // clean
false, // canUndo
"", // undoText
false, // canRedo
"", // redoText
false, // cleanChanged
false, // indexChanged
false, // undoChanged
false) // redoChanged
group.redo();
CHECK_STATE(0, // activeStack
true, // clean
false, // canUndo
"", // undoText
false, // canRedo
"", // redoText
false, // cleanChanged
false, // indexChanged
false, // undoChanged
false) // redoChanged
QUndoStack *stack1 = new QUndoStack(&group);
CHECK_STATE(0, // activeStack
true, // clean
false, // canUndo
"", // undoText
false, // canRedo
"", // redoText
false, // cleanChanged
false, // indexChanged
false, // undoChanged
false) // redoChanged
stack1->push(new AppendCommand(&str, "foo"));
CHECK_STATE(0, // activeStack
true, // clean
false, // canUndo
"", // undoText
false, // canRedo
"", // redoText
false, // cleanChanged
false, // indexChanged
false, // undoChanged
false) // redoChanged
stack1->setActive();
CHECK_STATE(stack1, // activeStack
false, // clean
true, // canUndo
"append", // undoText
false, // canRedo
"", // redoText
true, // cleanChanged
true, // indexChanged
true, // undoChanged
true) // redoChanged
stack1->push(new InsertCommand(&str, 0, "bar"));
CHECK_STATE(stack1, // activeStack
false, // clean
true, // canUndo
"insert", // undoText
false, // canRedo
"", // redoText
false, // cleanChanged
true, // indexChanged
true, // undoChanged
true) // redoChanged
stack1->undo();
CHECK_STATE(stack1, // activeStack
false, // clean
//.........这里部分代码省略.........
示例3: newIcon
MainToolBar::MainToolBar(QWidget *parent)
: QToolBar(parent)
, mCommandButton(new CommandButton(this))
{
setObjectName(QLatin1String("MainToolBar"));
setWindowTitle(tr("Main Toolbar"));
setToolButtonStyle(Qt::ToolButtonFollowStyle);
QIcon newIcon(QLatin1String(":images/24x24/document-new.png"));
QIcon openIcon(QLatin1String(":images/24x24/document-open.png"));
QIcon saveIcon(QLatin1String(":images/24x24/document-save.png"));
QIcon undoIcon(QLatin1String(":images/24x24/edit-undo.png"));
QIcon redoIcon(QLatin1String(":images/24x24/edit-redo.png"));
newIcon.addFile(QLatin1String(":images/16x16/document-new.png"));
openIcon.addFile(QLatin1String(":images/16x16/document-open.png"));
saveIcon.addFile(QLatin1String(":images/16x16/document-save.png"));
redoIcon.addFile(QLatin1String(":images/16x16/edit-redo.png"));
undoIcon.addFile(QLatin1String(":images/16x16/edit-undo.png"));
mNewButton = new QToolButton(this);
mOpenAction = new QAction(this);
mSaveAction = new QAction(this);
QMenu *newMenu = new QMenu(this);
newMenu->addAction(ActionManager::action("NewMap"));
newMenu->addAction(ActionManager::action("NewTileset"));
mNewButton->setMenu(newMenu);
mNewButton->setPopupMode(QToolButton::InstantPopup);
QUndoGroup *undoGroup = DocumentManager::instance()->undoGroup();
mUndoAction = undoGroup->createUndoAction(this, tr("Undo"));
mRedoAction = undoGroup->createRedoAction(this, tr("Redo"));
mNewButton->setIcon(newIcon);
mOpenAction->setIcon(openIcon);
mSaveAction->setIcon(saveIcon);
mUndoAction->setIcon(undoIcon);
mRedoAction->setIcon(redoIcon);
Utils::setThemeIcon(mNewButton, "document-new");
Utils::setThemeIcon(mOpenAction, "document-open");
Utils::setThemeIcon(mSaveAction, "document-save");
Utils::setThemeIcon(mRedoAction, "edit-redo");
Utils::setThemeIcon(mUndoAction, "edit-undo");
mRedoAction->setPriority(QAction::LowPriority);
addWidget(mNewButton);
addAction(mOpenAction);
addAction(mSaveAction);
addSeparator();
addAction(mUndoAction);
addAction(mRedoAction);
addSeparator();
addWidget(mCommandButton);
DocumentManager *documentManager = DocumentManager::instance();
connect(mOpenAction, &QAction::triggered, documentManager, &DocumentManager::openFileDialog);
connect(mSaveAction, &QAction::triggered, documentManager, &DocumentManager::saveFile);
connect(documentManager, &DocumentManager::currentDocumentChanged,
this, &MainToolBar::currentDocumentChanged);
connect(this, &MainToolBar::orientationChanged,
this, &MainToolBar::onOrientationChanged);
retranslateUi();
}
示例4: redoIcon
MainWindow::MainWindow(QWidget *parent, Qt::WFlags flags)
: QMainWindow(parent, flags)
, mUi(new Ui::MainWindow)
, mMapDocument(0)
, mActionHandler(new MapDocumentActionHandler(this))
, mLayerDock(new LayerDock(this))
, mTilesetDock(new TilesetDock(this))
, mZoomLabel(new QLabel)
, mStatusInfoLabel(new QLabel)
, mClipboardManager(new ClipboardManager(this))
, mDocumentManager(DocumentManager::instance())
{
mUi->setupUi(this);
setCentralWidget(mDocumentManager->widget());
PluginManager::instance()->loadPlugins();
#ifdef Q_WS_MAC
MacSupport::addFullscreen(this);
#endif
Preferences *preferences = Preferences::instance();
QIcon redoIcon(QLatin1String(":images/16x16/edit-redo.png"));
QIcon undoIcon(QLatin1String(":images/16x16/edit-undo.png"));
QIcon tiledIcon(QLatin1String(":images/tiled-icon-16.png"));
tiledIcon.addFile(QLatin1String(":images/tiled-icon-32.png"));
setWindowIcon(tiledIcon);
// Add larger icon versions for actions used in the tool bar
QIcon newIcon = mUi->actionNew->icon();
QIcon openIcon = mUi->actionOpen->icon();
QIcon saveIcon = mUi->actionSave->icon();
newIcon.addFile(QLatin1String(":images/24x24/document-new.png"));
openIcon.addFile(QLatin1String(":images/24x24/document-open.png"));
saveIcon.addFile(QLatin1String(":images/24x24/document-save.png"));
redoIcon.addFile(QLatin1String(":images/24x24/edit-redo.png"));
undoIcon.addFile(QLatin1String(":images/24x24/edit-undo.png"));
mUi->actionNew->setIcon(newIcon);
mUi->actionOpen->setIcon(openIcon);
mUi->actionSave->setIcon(saveIcon);
QUndoGroup *undoGroup = mDocumentManager->undoGroup();
QAction *undoAction = undoGroup->createUndoAction(this, tr("Undo"));
QAction *redoAction = undoGroup->createRedoAction(this, tr("Redo"));
mUi->mainToolBar->setToolButtonStyle(Qt::ToolButtonFollowStyle);
mUi->actionNew->setPriority(QAction::LowPriority);
redoAction->setPriority(QAction::LowPriority);
redoAction->setIcon(redoIcon);
undoAction->setIcon(undoIcon);
redoAction->setIconText(tr("Redo"));
undoAction->setIconText(tr("Undo"));
connect(undoGroup, SIGNAL(cleanChanged(bool)), SLOT(updateWindowTitle()));
UndoDock *undoDock = new UndoDock(undoGroup, this);
addDockWidget(Qt::RightDockWidgetArea, mLayerDock);
addDockWidget(Qt::RightDockWidgetArea, undoDock);
tabifyDockWidget(undoDock, mLayerDock);
addDockWidget(Qt::RightDockWidgetArea, mTilesetDock);
statusBar()->addPermanentWidget(mZoomLabel);
mUi->actionNew->setShortcuts(QKeySequence::New);
mUi->actionOpen->setShortcuts(QKeySequence::Open);
mUi->actionSave->setShortcuts(QKeySequence::Save);
mUi->actionSaveAs->setShortcuts(QKeySequence::SaveAs);
mUi->actionClose->setShortcuts(QKeySequence::Close);
mUi->actionQuit->setShortcuts(QKeySequence::Quit);
mUi->actionCut->setShortcuts(QKeySequence::Cut);
mUi->actionCopy->setShortcuts(QKeySequence::Copy);
mUi->actionPaste->setShortcuts(QKeySequence::Paste);
mUi->actionDelete->setShortcuts(QKeySequence::Delete);
undoAction->setShortcuts(QKeySequence::Undo);
redoAction->setShortcuts(QKeySequence::Redo);
mUi->actionShowGrid->setChecked(preferences->showGrid());
mUi->actionSnapToGrid->setChecked(preferences->snapToGrid());
mUi->actionHighlightCurrentLayer->setChecked(preferences->highlightCurrentLayer());
// Make sure Ctrl+= also works for zooming in
QList<QKeySequence> keys = QKeySequence::keyBindings(QKeySequence::ZoomIn);
keys += QKeySequence(tr("Ctrl+="));
keys += QKeySequence(tr("+"));
mUi->actionZoomIn->setShortcuts(keys);
keys = QKeySequence::keyBindings(QKeySequence::ZoomOut);
keys += QKeySequence(tr("-"));
mUi->actionZoomOut->setShortcuts(keys);
mUi->menuEdit->insertAction(mUi->actionCut, undoAction);
mUi->menuEdit->insertAction(mUi->actionCut, redoAction);
mUi->menuEdit->insertSeparator(mUi->actionCut);
mUi->menuEdit->insertAction(mUi->actionPreferences,
mActionHandler->actionSelectAll());
mUi->menuEdit->insertAction(mUi->actionPreferences,
mActionHandler->actionSelectNone());
mUi->menuEdit->insertSeparator(mUi->actionPreferences);
mUi->mainToolBar->addAction(undoAction);
mUi->mainToolBar->addAction(redoAction);
//.........这里部分代码省略.........
示例5: redoIcon
MainWindow::MainWindow(QWidget *parent, Qt::WindowFlags flags)
: QMainWindow(parent, flags)
, mUi(new Ui::MainWindow)
, mMapDocument(0)
, mActionHandler(new MapDocumentActionHandler(this))
, mMapsDock(new MapsDock(this))
, mTilesetDock(new TilesetDock(this))
, mMiniMapDock(new MiniMapDock(this))
, mZoomable(0)
, mZoomComboBox(new QComboBox)
, mStatusInfoLabel(new QLabel)
, mValidationErrorWidget(new QWidget)
, mValidationErrorLabel(new QLabel)
, mDocumentManager(DocumentManager::instance())
, mQuickStampManager(new QuickStampManager(this))
, mToolManager(new ToolManager(this))
, mKodableMapValidator(new KodableMapValidator(this))
{
mUi->setupUi(this);
setCentralWidget(mDocumentManager->widget());
#ifdef Q_OS_MAC
MacSupport::addFullscreen(this);
#endif
Preferences *preferences = Preferences::instance();
QIcon redoIcon(QLatin1String(":images/16x16/edit-redo.png"));
QIcon undoIcon(QLatin1String(":images/16x16/edit-undo.png"));
QIcon windowIcon(QLatin1String(":images/kodable-editor-icon.png"));
setWindowIcon(windowIcon);
// Add larger icon versions for actions used in the tool bar
QIcon newIcon = mUi->actionNew->icon();
QIcon openIcon = mUi->actionOpen->icon();
QIcon saveIcon = mUi->actionSave->icon();
newIcon.addFile(QLatin1String(":images/24x24/document-new.png"));
openIcon.addFile(QLatin1String(":images/24x24/document-open.png"));
saveIcon.addFile(QLatin1String(":images/24x24/document-save.png"));
redoIcon.addFile(QLatin1String(":images/24x24/edit-redo.png"));
undoIcon.addFile(QLatin1String(":images/24x24/edit-undo.png"));
mUi->actionNew->setIcon(newIcon);
mUi->actionOpen->setIcon(openIcon);
mUi->actionSave->setIcon(saveIcon);
QUndoGroup *undoGroup = mDocumentManager->undoGroup();
QAction *undoAction = undoGroup->createUndoAction(this, tr("Undo"));
QAction *redoAction = undoGroup->createRedoAction(this, tr("Redo"));
mUi->mainToolBar->setToolButtonStyle(Qt::ToolButtonFollowStyle);
mUi->actionNew->setPriority(QAction::LowPriority);
redoAction->setPriority(QAction::LowPriority);
redoAction->setIcon(redoIcon);
undoAction->setIcon(undoIcon);
redoAction->setIconText(tr("Redo"));
undoAction->setIconText(tr("Undo"));
connect(undoGroup, SIGNAL(cleanChanged(bool)), SLOT(updateWindowTitle()));
UndoDock *undoDock = new UndoDock(undoGroup, this);
PropertiesDock *propertiesDock = new PropertiesDock(this);
addDockWidget(Qt::LeftDockWidgetArea, undoDock);
addDockWidget(Qt::LeftDockWidgetArea, mMapsDock);
addDockWidget(Qt::RightDockWidgetArea, mMiniMapDock);
addDockWidget(Qt::RightDockWidgetArea, mTilesetDock);
addDockWidget(Qt::RightDockWidgetArea, propertiesDock);
tabifyDockWidget(undoDock, mMapsDock);
// These dock widgets may not be immediately useful to many people, so
// they are hidden by default.
undoDock->setVisible(false);
mMapsDock->setVisible(false);
mMiniMapDock->setVisible(false);
QHBoxLayout *errorBoxLayout = new QHBoxLayout;
QLabel *iconLabel = new QLabel;
iconLabel->setPixmap(QPixmap(QLatin1String(":images/16x16/dialog-warning.png")));
errorBoxLayout->addWidget(iconLabel);
errorBoxLayout->addWidget(mValidationErrorLabel);
mValidationErrorWidget->setLayout(errorBoxLayout);
mValidationErrorWidget->setVisible(false);
statusBar()->addPermanentWidget(mValidationErrorWidget);
statusBar()->addPermanentWidget(mZoomComboBox);
mUi->actionNew->setShortcuts(QKeySequence::New);
mUi->actionOpen->setShortcuts(QKeySequence::Open);
mUi->actionSave->setShortcuts(QKeySequence::Save);
mUi->actionSaveAs->setShortcuts(QKeySequence::SaveAs);
mUi->actionClose->setShortcuts(QKeySequence::Close);
mUi->actionQuit->setShortcuts(QKeySequence::Quit);
mUi->actionCut->setShortcuts(QKeySequence::Cut);
mUi->actionCopy->setShortcuts(QKeySequence::Copy);
mUi->actionPaste->setShortcuts(QKeySequence::Paste);
mUi->actionDelete->setShortcuts(QKeySequence::Delete);
undoAction->setShortcuts(QKeySequence::Undo);
redoAction->setShortcuts(QKeySequence::Redo);
mUi->actionShowGrid->setChecked(preferences->showGrid());
//.........这里部分代码省略.........
示例6: nutateThread
NaMainWindow::NaMainWindow()
: nutateThread(NULL)
{
ui.setupUi(this);
//QMetaObject::connectSlotsByName(this); This is apparently already called by setupUi, so calling it again creates repeat trigger events
annotationSession=0;
// Wire up MIP viewer
// Status bar message
connect(ui.naLargeMIPWidget, SIGNAL(statusMessage(const QString&)),
statusBar(), SLOT(showMessage(const QString&)));
connect(ui.gammaWidget_MIP, SIGNAL(gammaBrightnessChanged(double)),
ui.naLargeMIPWidget, SLOT(setGammaBrightness(double)));
// Wire up Z-stack / HDR viewer
ui.HDR_checkBox->setChecked(true);
ui.naZStackWidget->setHDRCheckState(true);
ui.gammaWidget_Zstack->hide();
connect(ui.HDR_checkBox, SIGNAL(stateChanged(int)),
ui.naZStackWidget, SLOT(setHDRCheckState(int)));
connect(ui.naZStackWidget, SIGNAL(changedHDRCheckState(bool)),
ui.gammaWidget_Zstack, SLOT(setVisible(bool)));
connect(ui.gammaWidget_Zstack, SIGNAL(gammaBrightnessChanged(double)),
ui.naZStackWidget, SLOT(setGammaBrightness(double)));
connect(ui.HDRRed_pushButton, SIGNAL(clicked()),
ui.naZStackWidget, SLOT(setRedChannel()));
connect(ui.HDRGreen_pushButton, SIGNAL(clicked()),
ui.naZStackWidget, SLOT(setGreenChannel()));
connect(ui.HDRBlue_pushButton, SIGNAL(clicked()),
ui.naZStackWidget, SLOT(setBlueChannel()));
connect(ui.ZSlice_horizontalScrollBar, SIGNAL(valueChanged(int)),
ui.naZStackWidget, SLOT(setCurrentZSlice(int)));
connect(ui.naZStackWidget, SIGNAL(curZsliceChanged(int)),
ui.ZSlice_horizontalScrollBar, SLOT(setValue(int)));
connect(ui.BoxSize_spinBox, SIGNAL(valueChanged(int)),
ui.naZStackWidget, SLOT(updateROIsize(int)));
connect(ui.naZStackWidget, SIGNAL(boxSizeChanged(int)),
ui.BoxSize_spinBox, SLOT(setValue(int)));
// 3D viewer
connect(ui.rotationResetButton, SIGNAL(clicked()),
ui.v3dr_glwidget, SLOT(resetRotation()));
connect(ui.nutateButton, SIGNAL(toggled(bool)),
this, SLOT(setNutate(bool)));
// 3D rotation
connect(&(ui.v3dr_glwidget->cameraModel), SIGNAL(rotationChanged(const Rotation3D&)),
this, SLOT(on3DViewerRotationChanged(const Rotation3D&)));
connect(ui.rotXWidget, SIGNAL(angleChanged(int)),
this, SLOT(update3DViewerXYZBodyRotation()));
connect(ui.rotYWidget, SIGNAL(angleChanged(int)),
this, SLOT(update3DViewerXYZBodyRotation()));
connect(ui.rotZWidget, SIGNAL(angleChanged(int)),
this, SLOT(update3DViewerXYZBodyRotation()));
// 3D gamma correction
connect(ui.gammaWidget_3D, SIGNAL(gammaBrightnessChanged(double)),
ui.v3dr_glwidget, SLOT(setGammaBrightness(double)));
connect(ui.gammaWidget_3D, SIGNAL(gammaBrightnessChanged(double)),
this, SLOT(updateThumbnailGamma(double)));
connect(ui.colorResetButton, SIGNAL(clicked()),
ui.gammaWidget_3D, SLOT(reset()));
// Whether to use common zoom and focus in MIP, ZStack and 3D viewers
connect(ui.actionLink_viewers, SIGNAL(toggled(bool)),
this, SLOT(unifyCameras(bool)));
unifyCameras(true); // Start with cameras linked
// Crosshair
connect(ui.actionShow_Crosshair, SIGNAL(toggled(bool)),
ui.naLargeMIPWidget, SLOT(showCrosshair(bool)));
connect(ui.actionShow_Crosshair, SIGNAL(toggled(bool)),
ui.v3dr_glwidget, SLOT(showCrosshair(bool)));
// Create "Undo" menu options
// TODO - figure out which of these variables to expose once we have a QUndoCommand to work with.
QUndoGroup * undoGroup = new QUndoGroup(this);
QAction * undoAction = undoGroup->createUndoAction(this);
QAction * redoAction = undoGroup->createRedoAction(this);
ui.menuEdit->insertAction(ui.menuEdit->actions().at(0), redoAction);
ui.menuEdit->insertAction(redoAction, undoAction);
}