@@ -83,7 +83,7 @@ QVariant OutputModel::data(const QModelIndex& index, int role) const
8383 return replicationSourceIndex (index.row ());
8484 case ReplicasModelRole:
8585 return replicasModel (output);
86- case RefreshRatesRole:
86+ case RefreshRatesRole: {
8787 QVariantList ret;
8888 for (auto rate : refreshRates (output)) {
8989 if (output->auto_refresh_rate ()) {
@@ -99,6 +99,11 @@ QVariant OutputModel::data(const QModelIndex& index, int role) const
9999 }
100100 return ret;
101101 }
102+ case AdaptiveSyncToggleSupportRole:
103+ return output->adaptive_sync_toggle_support ();
104+ case AdaptiveSyncRole:
105+ return output->adaptive_sync ();
106+ }
102107 return QVariant ();
103108}
104109
@@ -181,7 +186,7 @@ bool OutputModel::setData(const QModelIndex& index, const QVariant& value, int r
181186 return setReplicationSourceIndex (index.row (), value.toInt () - 1 );
182187 }
183188 break ;
184- case ScaleRole:
189+ case ScaleRole: {
185190 bool ok;
186191 const qreal scale = value.toReal (&ok);
187192 if (ok && !qFuzzyCompare (output.ptr ->scale (), scale)) {
@@ -192,6 +197,12 @@ bool OutputModel::setData(const QModelIndex& index, const QVariant& value, int r
192197 }
193198 break ;
194199 }
200+ case AdaptiveSyncRole:
201+ if (value.canConvert <bool >()) {
202+ return set_adaptive_sync (index.row (), value.value <bool >());
203+ }
204+ break ;
205+ }
195206 return false ;
196207}
197208
@@ -217,6 +228,8 @@ QHash<int, QByteArray> OutputModel::roleNames() const
217228 roles[ReplicationSourceModelRole] = " replicationSourceModel" ;
218229 roles[ReplicationSourceIndexRole] = " replicationSourceIndex" ;
219230 roles[ReplicasModelRole] = " replicasModel" ;
231+ roles[AdaptiveSyncToggleSupportRole] = " adaptiveSyncToggleSupport" ;
232+ roles[AdaptiveSyncRole] = " adaptiveSync" ;
220233 return roles;
221234}
222235
@@ -442,6 +455,20 @@ bool OutputModel::setRotation(int outputIndex, Disman::Output::Rotation rotation
442455 return true ;
443456}
444457
458+ bool OutputModel::set_adaptive_sync (int outputIndex, bool value)
459+ {
460+ Output& output = m_outputs[outputIndex];
461+
462+ if (output.ptr ->adaptive_sync () == value) {
463+ return false ;
464+ }
465+ output.ptr ->set_adaptive_sync (value);
466+
467+ auto index = createIndex (outputIndex, 0 );
468+ Q_EMIT dataChanged (index, index, {AdaptiveSyncRole});
469+ return true ;
470+ }
471+
445472int OutputModel::resolutionIndex (const Disman::OutputPtr& output) const
446473{
447474 const QSize currentResolution = output->auto_mode ()->size ();
0 commit comments