void MonitorSettingDialog::onMonitorModeChanged() { const bool intersect = m_primary && m_model->monitorsIsIntersect(); if (intersect) updateModeList(m_model->monitorsSameModeList()); else updateModeList(m_monitor->modeList()); if (!intersect) { m_resolutionsModel->setSelectedIndex(m_resolutionsModel->index(m_monitor->modeList().indexOf(m_monitor->currentMode()))); } else { const ResolutionList list = m_model->monitorsSameModeList(); const Resolution mode = m_model->monitorList().first()->currentMode(); for (auto it = list.cbegin(); it != list.cend(); ++it) { if (it->id() == mode.id()) { m_resolutionsModel->setSelectedIndex(m_resolutionsModel->index(it - list.cbegin())); break; } } } }