Grey out edit->undo/redo actions if there's nothing left to undo/redo
This commit is contained in:
@@ -97,6 +97,15 @@ void ProjectJournal::redo()
|
||||
}
|
||||
}
|
||||
|
||||
bool ProjectJournal::canUndo() const
|
||||
{
|
||||
return !m_undoCheckPoints.isEmpty();
|
||||
}
|
||||
|
||||
bool ProjectJournal::canRedo() const
|
||||
{
|
||||
return !m_redoCheckPoints.isEmpty();
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
@@ -288,11 +288,11 @@ void MainWindow::finalize()
|
||||
|
||||
QMenu * edit_menu = new QMenu( this );
|
||||
menuBar()->addMenu( edit_menu )->setText( tr( "&Edit" ) );
|
||||
edit_menu->addAction( embed::getIconPixmap( "edit_undo" ),
|
||||
m_undoAction = edit_menu->addAction( embed::getIconPixmap( "edit_undo" ),
|
||||
tr( "Undo" ),
|
||||
this, SLOT( undo() ),
|
||||
Qt::CTRL + Qt::Key_Z );
|
||||
edit_menu->addAction( embed::getIconPixmap( "edit_redo" ),
|
||||
m_redoAction = edit_menu->addAction( embed::getIconPixmap( "edit_redo" ),
|
||||
tr( "Redo" ),
|
||||
this, SLOT( redo() ),
|
||||
Qt::CTRL + Qt::Key_Y );
|
||||
@@ -300,6 +300,7 @@ void MainWindow::finalize()
|
||||
edit_menu->addAction( embed::getIconPixmap( "setup_general" ),
|
||||
tr( "Settings" ),
|
||||
this, SLOT( showSettingsDialog() ) );
|
||||
connect( edit_menu, SIGNAL(aboutToShow()), this, SLOT(updateUndoRedoButtons()) );
|
||||
|
||||
m_viewMenu = new QMenu( this );
|
||||
menuBar()->addMenu( m_viewMenu )->setText( tr( "&View" ) );
|
||||
@@ -1182,6 +1183,14 @@ void MainWindow::updatePlayPauseIcons()
|
||||
}
|
||||
|
||||
|
||||
void MainWindow::updateUndoRedoButtons()
|
||||
{
|
||||
// when the edit menu is shown, grey out the undo/redo buttons if there's nothing to undo/redo
|
||||
// else, un-grey them
|
||||
m_undoAction->setEnabled(Engine::projectJournal()->canUndo());
|
||||
m_redoAction->setEnabled(Engine::projectJournal()->canRedo());
|
||||
}
|
||||
|
||||
|
||||
|
||||
void MainWindow::undo()
|
||||
|
||||
Reference in New Issue
Block a user