void QgsConfigureShortcutsDialog::setCurrentActionShortcut( QKeySequence s ) { QAction* action = currentAction(); if ( !action ) return; // first check whether this action is not taken already QAction* otherAction = QgsShortcutsManager::instance()->actionForShortcut( s ); if ( otherAction != NULL ) { QString otherActionText = otherAction->text(); otherActionText.remove( '&' ); // remove the accelerator int res = QMessageBox::question( this, tr( "Shortcut conflict" ), tr( "This shortcut is already assigned to action %1. Reassign?" ).arg( otherActionText ), QMessageBox::Yes | QMessageBox::No ); if ( res != QMessageBox::Yes ) return; // reset action of the conflicting other action! QgsShortcutsManager::instance()->setActionShortcut( otherAction, QString() ); QList<QTreeWidgetItem*> items = treeActions->findItems( otherActionText, Qt::MatchExactly ); if ( items.count() > 0 ) // there should be exactly one items[0]->setText( 1, QString() ); } // update manager QgsShortcutsManager::instance()->setActionShortcut( action, s.toString() ); // update gui treeActions->currentItem()->setText( 1, s.toString() ); actionChanged( treeActions->currentItem(), NULL ); }
void ActionListView::focusInEvent(QFocusEvent *event) { QListView::focusInEvent(event); // Make property editor display current action if (QAction *a = currentAction()) emit currentChanged(a); }
void MainWindow::setCurrentWindow(Window *window) { Window *previousWindow(m_currentWindow); m_currentWindow = window; for (int i = 0; i < m_standardActions.count(); ++i) { if (m_standardActions[i] && Action::isLocal(m_standardActions[i]->getIdentifier())) { const int identifier(m_standardActions[i]->getIdentifier()); Action *previousAction((previousWindow && previousWindow->getContentsWidget()) ? previousWindow->getContentsWidget()->getAction(identifier) : nullptr); Action *currentAction(window ? window->getContentsWidget()->getAction(identifier) : nullptr); if (previousAction) { disconnect(previousAction, SIGNAL(changed()), m_standardActions[i], SLOT(setup())); } m_standardActions[i]->blockSignals(true); m_standardActions[i]->setup(currentAction); m_standardActions[i]->blockSignals(false); if (currentAction) { connect(currentAction, SIGNAL(changed()), m_standardActions[i], SLOT(setup())); } } } }
void QgsConfigureShortcutsDialog::resetShortcut() { QAction* action = currentAction(); if ( !action ) return; // set default shortcut QString shortcut = QgsShortcutsManager::instance()->actionDefaultShortcut( action ); setCurrentActionShortcut( shortcut ); }
void QgsConfigureShortcutsDialog::actionChanged( QTreeWidgetItem *current, QTreeWidgetItem *previous ) { Q_UNUSED( current ); Q_UNUSED( previous ); // cancel previous shortcut setting (if any) setGettingShortcut( false ); QAction* action = currentAction(); if ( !action ) return; // show which one is the default action QString shortcut = QgsShortcutsManager::instance()->actionDefaultShortcut( action ); if ( shortcut.isEmpty() ) shortcut = tr( "None" ); btnResetShortcut->setText( tr( "Set default (%1)" ).arg( shortcut ) ); // if there's no shortcut, disable set none btnSetNoShortcut->setEnabled( !action->shortcut().isEmpty() ); // if the shortcut is default, disable set default btnResetShortcut->setEnabled( action->shortcut() != QKeySequence( shortcut ) ); }
void AMActionRunner3::onCurrentActionStateChanged(int state, int previousState) { emit currentActionStateChanged(state, previousState); if(state == AMAction3::Starting){ AMListAction3* listAction = qobject_cast<AMListAction3*>(currentAction_); if(listAction){ int parentLogId = -1; AMListAction3* parentAction = qobject_cast<AMListAction3*>(listAction->parentAction()); if(parentAction) parentLogId = parentAction->logActionId(); if(!AMActionLog3::logUncompletedAction(currentAction_, loggingDatabase_, parentLogId)) { AMErrorMon::report(AMErrorReport(this, AMErrorReport::Alert, -200, "There was a problem logging the uncompleted action to your database. Please report this problem to the Acquaman developers.")); } } if (isScanAction()) emit scanActionCreated((AMScanAction *)currentAction()); } if ( (state == AMAction3::Running) && (previousState != AMAction3::Resuming) ){ if (isScanAction()) emit scanActionStarted((AMScanAction *)currentAction()); } if(state == AMAction3::Failed) { // What should we do? int failureResponse = currentAction_->failureResponseInActionRunner(); if(failureResponse == AMAction3::PromptUserResponse) failureResponse = internalAskUserWhatToDoAboutFailedAction(currentAction_); if(failureResponse == AMAction3::AttemptAnotherCopyResponse) { // make a fresh copy of this action and put it at the front of the queue to run again. insertActionInQueue(currentAction_->createCopy(), 0); } // other failure response is to MoveOn, which we'll do anyway. } if(state == AMAction3::Cancelled) { // Usability guess for now: If the user intervened to cancel, they probably want to make some changes to something. Let's pause the workflow for now to let them do that, rather than automatically go on to the next. setQueuePaused(true); } // for all three final states, this is how we wrap things up for the current action: if(state == AMAction3::Failed || state == AMAction3::Cancelled || state == AMAction3::Succeeded) { // log it, unless it's a list action that wants to take care of logging its sub-actions itself. AMListAction3* listAction = qobject_cast<AMListAction3*>(currentAction_); int parentLogId = -1; AMListAction3* parentAction = qobject_cast<AMListAction3*>(currentAction_->parentAction()); if(parentAction) parentLogId = parentAction->logActionId(); if(!(listAction && listAction->shouldLogSubActionsSeparately())) { if(!AMActionLog3::logCompletedAction(currentAction_, loggingDatabase_, parentLogId)) { AMErrorMon::report(AMErrorReport(this, AMErrorReport::Alert, -200, "There was a problem logging the completed action to your database. Please report this problem to the Acquaman developers.")); } } else if(listAction){ if(!AMActionLog3::updateCompletedAction(currentAction_, loggingDatabase_)) { AMErrorMon::report(AMErrorReport(this, AMErrorReport::Alert, -200, "There was a problem updating the log of the completed action to your database. Please report this problem to the Acquaman developers.")); } } if (isScanAction()) emit scanActionFinished((AMScanAction *)currentAction()); // move onto the next, if there is one, and disconnect and delete the old one. internalDoNextAction(); } }