Changeset View
Changeset View
Standalone View
Standalone View
kcm/output_model.cpp
Show First 20 Lines • Show All 43 Lines • ▼ Show 20 Line(s) | 41 | { | |||
---|---|---|---|---|---|
44 | } | 44 | } | ||
45 | 45 | | |||
46 | const KScreen::OutputPtr &output = m_outputs[index.row()].ptr; | 46 | const KScreen::OutputPtr &output = m_outputs[index.row()].ptr; | ||
47 | switch (role) { | 47 | switch (role) { | ||
48 | case Qt::DisplayRole: | 48 | case Qt::DisplayRole: | ||
49 | return Utils::outputName(output); | 49 | return Utils::outputName(output); | ||
50 | case EnabledRole: | 50 | case EnabledRole: | ||
51 | return output->isEnabled(); | 51 | return output->isEnabled(); | ||
52 | case InternalRole: | ||||
53 | return output->type() == KScreen::Output::Type::Panel; | ||||
52 | case PrimaryRole: | 54 | case PrimaryRole: | ||
53 | return output->isPrimary(); | 55 | return output->isPrimary(); | ||
54 | case SizeRole: | 56 | case SizeRole: | ||
55 | return output->geometry().size(); | 57 | return output->geometry().size(); | ||
56 | case PositionRole: | 58 | case PositionRole: | ||
57 | return m_outputs[index.row()].pos; | 59 | return m_outputs[index.row()].pos; | ||
58 | case NormalizedPositionRole: | 60 | case NormalizedPositionRole: | ||
59 | return output->geometry().topLeft(); | 61 | return output->geometry().topLeft(); | ||
62 | case AutoRotateRole: | ||||
63 | return m_config->autoRotate(output); | ||||
64 | case AutoRotateOnlyInTabletModeRole: | ||||
65 | return m_config->autoRotateOnlyInTabletMode(output); | ||||
60 | case RotationRole: | 66 | case RotationRole: | ||
61 | return output->rotation(); | 67 | return output->rotation(); | ||
62 | case ScaleRole: | 68 | case ScaleRole: | ||
63 | return output->scale(); | 69 | return output->scale(); | ||
64 | case ResolutionIndexRole: | 70 | case ResolutionIndexRole: | ||
65 | return resolutionIndex(output); | 71 | return resolutionIndex(output); | ||
66 | case ResolutionsRole: | 72 | case ResolutionsRole: | ||
67 | return resolutionsStrings(output); | 73 | return resolutionsStrings(output); | ||
▲ Show 20 Lines • Show All 60 Lines • ▼ Show 20 Line(s) | 133 | if (value.canConvert<int>()) { | |||
128 | return setResolution(index.row(), value.toInt()); | 134 | return setResolution(index.row(), value.toInt()); | ||
129 | } | 135 | } | ||
130 | break; | 136 | break; | ||
131 | case RefreshRateIndexRole: | 137 | case RefreshRateIndexRole: | ||
132 | if (value.canConvert<int>()) { | 138 | if (value.canConvert<int>()) { | ||
133 | return setRefreshRate(index.row(), value.toInt()); | 139 | return setRefreshRate(index.row(), value.toInt()); | ||
134 | } | 140 | } | ||
135 | break; | 141 | break; | ||
142 | case AutoRotateRole: | ||||
143 | if (value.canConvert<bool>()) { | ||||
144 | return setAutoRotate(index.row(), value.value<bool>()); | ||||
145 | } | ||||
146 | break; | ||||
147 | case AutoRotateOnlyInTabletModeRole: | ||||
148 | if (value.canConvert<bool>()) { | ||||
149 | return setAutoRotateOnlyInTabletMode(index.row(), value.value<bool>()); | ||||
150 | } | ||||
151 | break; | ||||
136 | case RotationRole: | 152 | case RotationRole: | ||
137 | if (value.canConvert<KScreen::Output::Rotation>()) { | 153 | if (value.canConvert<KScreen::Output::Rotation>()) { | ||
138 | return setRotation(index.row(), | 154 | return setRotation(index.row(), | ||
139 | value.value<KScreen::Output::Rotation>()); | 155 | value.value<KScreen::Output::Rotation>()); | ||
140 | } | 156 | } | ||
141 | break; | 157 | break; | ||
142 | case ReplicationSourceIndexRole: | 158 | case ReplicationSourceIndexRole: | ||
143 | if (value.canConvert<int>()) { | 159 | if (value.canConvert<int>()) { | ||
Show All 12 Lines | 163 | case ScaleRole: | |||
156 | break; | 172 | break; | ||
157 | } | 173 | } | ||
158 | return false; | 174 | return false; | ||
159 | } | 175 | } | ||
160 | 176 | | |||
161 | QHash<int, QByteArray> OutputModel::roleNames() const { | 177 | QHash<int, QByteArray> OutputModel::roleNames() const { | ||
162 | QHash<int, QByteArray> roles = QAbstractItemModel::roleNames(); | 178 | QHash<int, QByteArray> roles = QAbstractItemModel::roleNames(); | ||
163 | roles[EnabledRole] = "enabled"; | 179 | roles[EnabledRole] = "enabled"; | ||
180 | roles[InternalRole] = "internal"; | ||||
164 | roles[PrimaryRole] = "primary"; | 181 | roles[PrimaryRole] = "primary"; | ||
165 | roles[SizeRole] = "size"; | 182 | roles[SizeRole] = "size"; | ||
166 | roles[PositionRole] = "position"; | 183 | roles[PositionRole] = "position"; | ||
167 | roles[NormalizedPositionRole] = "normalizedPosition"; | 184 | roles[NormalizedPositionRole] = "normalizedPosition"; | ||
185 | roles[AutoRotateRole] = "autoRotate"; | ||||
186 | roles[AutoRotateOnlyInTabletModeRole] = "autoRotateOnlyInTabletMode"; | ||||
168 | roles[RotationRole] = "rotation"; | 187 | roles[RotationRole] = "rotation"; | ||
169 | roles[ScaleRole] = "scale"; | 188 | roles[ScaleRole] = "scale"; | ||
170 | roles[ResolutionIndexRole] = "resolutionIndex"; | 189 | roles[ResolutionIndexRole] = "resolutionIndex"; | ||
171 | roles[ResolutionsRole] = "resolutions"; | 190 | roles[ResolutionsRole] = "resolutions"; | ||
172 | roles[RefreshRateIndexRole] = "refreshRateIndex"; | 191 | roles[RefreshRateIndexRole] = "refreshRateIndex"; | ||
173 | roles[RefreshRatesRole] = "refreshRates"; | 192 | roles[RefreshRatesRole] = "refreshRates"; | ||
174 | roles[ReplicationSourceModelRole] = "replicationSourceModel"; | 193 | roles[ReplicationSourceModelRole] = "replicationSourceModel"; | ||
175 | roles[ReplicationSourceIndexRole] = "replicationSourceIndex"; | 194 | roles[ReplicationSourceIndexRole] = "replicationSourceIndex"; | ||
▲ Show 20 Lines • Show All 184 Lines • ▼ Show 20 Line(s) | 377 | if (refreshRateCompare(oldMode->refreshRate(), (*modeIt)->refreshRate())) { | |||
360 | return false; | 379 | return false; | ||
361 | } | 380 | } | ||
362 | output.ptr->setCurrentModeId((*modeIt)->id()); | 381 | output.ptr->setCurrentModeId((*modeIt)->id()); | ||
363 | QModelIndex index = createIndex(outputIndex, 0); | 382 | QModelIndex index = createIndex(outputIndex, 0); | ||
364 | Q_EMIT dataChanged(index, index, {RefreshRateIndexRole}); | 383 | Q_EMIT dataChanged(index, index, {RefreshRateIndexRole}); | ||
365 | return true; | 384 | return true; | ||
366 | } | 385 | } | ||
367 | 386 | | |||
387 | bool OutputModel::setAutoRotate(int outputIndex, bool value) | ||||
388 | { | ||||
389 | Output &output = m_outputs[outputIndex]; | ||||
390 | | ||||
391 | if (m_config->autoRotate(output.ptr) == value) { | ||||
392 | return false; | ||||
393 | } | ||||
394 | m_config->setAutoRotate(output.ptr, value); | ||||
395 | | ||||
396 | QModelIndex index = createIndex(outputIndex, 0); | ||||
397 | Q_EMIT dataChanged(index, index, {AutoRotateRole}); | ||||
398 | return true; | ||||
399 | } | ||||
400 | | ||||
401 | bool OutputModel::setAutoRotateOnlyInTabletMode(int outputIndex, bool value) | ||||
402 | { | ||||
403 | Output &output = m_outputs[outputIndex]; | ||||
404 | | ||||
405 | if (m_config->autoRotateOnlyInTabletMode(output.ptr) == value) { | ||||
406 | return false; | ||||
407 | } | ||||
408 | m_config->setAutoRotateOnlyInTabletMode(output.ptr, value); | ||||
409 | | ||||
410 | QModelIndex index = createIndex(outputIndex, 0); | ||||
411 | Q_EMIT dataChanged(index, index, {AutoRotateOnlyInTabletModeRole}); | ||||
412 | return true; | ||||
413 | } | ||||
414 | | ||||
368 | bool OutputModel::setRotation(int outputIndex, KScreen::Output::Rotation rotation) | 415 | bool OutputModel::setRotation(int outputIndex, KScreen::Output::Rotation rotation) | ||
369 | { | 416 | { | ||
370 | const Output &output = m_outputs[outputIndex]; | 417 | const Output &output = m_outputs[outputIndex]; | ||
371 | 418 | | |||
372 | if (rotation != KScreen::Output::None | 419 | if (rotation != KScreen::Output::None | ||
373 | && rotation != KScreen::Output::Left | 420 | && rotation != KScreen::Output::Left | ||
374 | && rotation != KScreen::Output::Inverted | 421 | && rotation != KScreen::Output::Inverted | ||
375 | && rotation != KScreen::Output::Right) { | 422 | && rotation != KScreen::Output::Right) { | ||
▲ Show 20 Lines • Show All 526 Lines • Show Last 20 Lines |