forked from qt-creator/qt-creator
Switch less often to edit mode
This change * Removes IMode::type, ModeManager::activateModeType, and IEditor::preferredModeType, and adds IEditor::isDesignModePreferred instead * Adapts the mode switching code in EditorManager to handle multiple windows, for example switching to edit mode should only happen if the editor/view is in the main window. Otherwise the editor window should be raised and focused * Renames EditorManager::NoActivate --> DoNotChangeCurrentEditor * Reverts the EditorManager::ModeSwitch logic to switch mode or make the current editor visible by default, introducing DoNotMakeVisible flag instead * Fixes a few instances where EditorManager::ModeSwitch should have been used One non-trivial problem left: If you open a .ui file and switch to an external editor window, edit mode is activated, because the current editor no longer is a .ui file, which means that the design mode gets deactivated. Change-Id: I76c5c2391eb4090143b778fb103acff3a5a1ff41 Reviewed-by: David Schulz <david.schulz@digia.com>
This commit is contained in:
@@ -150,21 +150,6 @@ IMode *ModeManager::mode(Id id)
|
||||
return 0;
|
||||
}
|
||||
|
||||
void ModeManager::activateModeType(Id type)
|
||||
{
|
||||
if (currentMode() && currentMode()->type() == type)
|
||||
return;
|
||||
int index = -1;
|
||||
for (int i = 0; i < d->m_modes.count(); ++i) {
|
||||
if (d->m_modes.at(i)->type() == type) {
|
||||
index = i;
|
||||
break;
|
||||
}
|
||||
}
|
||||
if (index != -1)
|
||||
d->m_modeStack->setCurrentIndex(index);
|
||||
}
|
||||
|
||||
void ModeManager::slotActivateMode(int id)
|
||||
{
|
||||
m_instance->activateMode(Id::fromUniqueIdentifier(id));
|
||||
@@ -333,10 +318,10 @@ void ModeManager::setFocusToCurrentMode()
|
||||
QWidget *widget = mode->widget();
|
||||
if (widget) {
|
||||
QWidget *focusWidget = widget->focusWidget();
|
||||
if (focusWidget)
|
||||
focusWidget->setFocus();
|
||||
else
|
||||
widget->setFocus();
|
||||
if (!focusWidget)
|
||||
focusWidget = widget;
|
||||
focusWidget->setFocus();
|
||||
ICore::raiseWindow(focusWidget);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user