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); | ||||
60 | case RotationRole: | 64 | case RotationRole: | ||
61 | return output->rotation(); | 65 | return output->rotation(); | ||
62 | case ScaleRole: | 66 | case ScaleRole: | ||
63 | return output->scale(); | 67 | return output->scale(); | ||
64 | case ResolutionIndexRole: | 68 | case ResolutionIndexRole: | ||
65 | return resolutionIndex(output); | 69 | return resolutionIndex(output); | ||
66 | case ResolutionsRole: | 70 | case ResolutionsRole: | ||
67 | return resolutionsStrings(output); | 71 | return resolutionsStrings(output); | ||
▲ Show 20 Lines • Show All 60 Lines • ▼ Show 20 Line(s) | 131 | if (value.canConvert<int>()) { | |||
128 | return setResolution(index.row(), value.toInt()); | 132 | return setResolution(index.row(), value.toInt()); | ||
129 | } | 133 | } | ||
130 | break; | 134 | break; | ||
131 | case RefreshRateIndexRole: | 135 | case RefreshRateIndexRole: | ||
132 | if (value.canConvert<int>()) { | 136 | if (value.canConvert<int>()) { | ||
133 | return setRefreshRate(index.row(), value.toInt()); | 137 | return setRefreshRate(index.row(), value.toInt()); | ||
134 | } | 138 | } | ||
135 | break; | 139 | break; | ||
140 | case AutoRotateRole: | ||||
141 | if (value.canConvert<bool>()) { | ||||
142 | return setAutoRotate(index.row(), value.value<bool>()); | ||||
143 | } | ||||
144 | break; | ||||
136 | case RotationRole: | 145 | case RotationRole: | ||
137 | if (value.canConvert<KScreen::Output::Rotation>()) { | 146 | if (value.canConvert<KScreen::Output::Rotation>()) { | ||
138 | return setRotation(index.row(), | 147 | return setRotation(index.row(), | ||
139 | value.value<KScreen::Output::Rotation>()); | 148 | value.value<KScreen::Output::Rotation>()); | ||
140 | } | 149 | } | ||
141 | break; | 150 | break; | ||
142 | case ReplicationSourceIndexRole: | 151 | case ReplicationSourceIndexRole: | ||
143 | if (value.canConvert<int>()) { | 152 | if (value.canConvert<int>()) { | ||
Show All 12 Lines | 156 | case ScaleRole: | |||
156 | break; | 165 | break; | ||
157 | } | 166 | } | ||
158 | return false; | 167 | return false; | ||
159 | } | 168 | } | ||
160 | 169 | | |||
161 | QHash<int, QByteArray> OutputModel::roleNames() const { | 170 | QHash<int, QByteArray> OutputModel::roleNames() const { | ||
162 | QHash<int, QByteArray> roles = QAbstractItemModel::roleNames(); | 171 | QHash<int, QByteArray> roles = QAbstractItemModel::roleNames(); | ||
163 | roles[EnabledRole] = "enabled"; | 172 | roles[EnabledRole] = "enabled"; | ||
173 | roles[InternalRole] = "internal"; | ||||
164 | roles[PrimaryRole] = "primary"; | 174 | roles[PrimaryRole] = "primary"; | ||
165 | roles[SizeRole] = "size"; | 175 | roles[SizeRole] = "size"; | ||
166 | roles[PositionRole] = "position"; | 176 | roles[PositionRole] = "position"; | ||
167 | roles[NormalizedPositionRole] = "normalizedPosition"; | 177 | roles[NormalizedPositionRole] = "normalizedPosition"; | ||
178 | roles[AutoRotateRole] = "autoRotate"; | ||||
168 | roles[RotationRole] = "rotation"; | 179 | roles[RotationRole] = "rotation"; | ||
169 | roles[ScaleRole] = "scale"; | 180 | roles[ScaleRole] = "scale"; | ||
170 | roles[ResolutionIndexRole] = "resolutionIndex"; | 181 | roles[ResolutionIndexRole] = "resolutionIndex"; | ||
171 | roles[ResolutionsRole] = "resolutions"; | 182 | roles[ResolutionsRole] = "resolutions"; | ||
172 | roles[RefreshRateIndexRole] = "refreshRateIndex"; | 183 | roles[RefreshRateIndexRole] = "refreshRateIndex"; | ||
173 | roles[RefreshRatesRole] = "refreshRates"; | 184 | roles[RefreshRatesRole] = "refreshRates"; | ||
174 | roles[ReplicationSourceModelRole] = "replicationSourceModel"; | 185 | roles[ReplicationSourceModelRole] = "replicationSourceModel"; | ||
175 | roles[ReplicationSourceIndexRole] = "replicationSourceIndex"; | 186 | roles[ReplicationSourceIndexRole] = "replicationSourceIndex"; | ||
▲ Show 20 Lines • Show All 184 Lines • ▼ Show 20 Line(s) | 369 | if (refreshRateCompare(oldMode->refreshRate(), (*modeIt)->refreshRate())) { | |||
360 | return false; | 371 | return false; | ||
361 | } | 372 | } | ||
362 | output.ptr->setCurrentModeId((*modeIt)->id()); | 373 | output.ptr->setCurrentModeId((*modeIt)->id()); | ||
363 | QModelIndex index = createIndex(outputIndex, 0); | 374 | QModelIndex index = createIndex(outputIndex, 0); | ||
364 | Q_EMIT dataChanged(index, index, {RefreshRateIndexRole}); | 375 | Q_EMIT dataChanged(index, index, {RefreshRateIndexRole}); | ||
365 | return true; | 376 | return true; | ||
366 | } | 377 | } | ||
367 | 378 | | |||
379 | bool OutputModel::setAutoRotate(int outputIndex, bool value) | ||||
380 | { | ||||
381 | Output &output = m_outputs[outputIndex]; | ||||
382 | | ||||
383 | if (m_config->autoRotate(output.ptr) == value) { | ||||
384 | return false; | ||||
385 | } | ||||
386 | m_config->setAutoRotate(output.ptr, value); | ||||
387 | | ||||
388 | QModelIndex index = createIndex(outputIndex, 0); | ||||
389 | Q_EMIT dataChanged(index, index, {AutoRotateRole}); | ||||
390 | return true; | ||||
391 | } | ||||
392 | | ||||
368 | bool OutputModel::setRotation(int outputIndex, KScreen::Output::Rotation rotation) | 393 | bool OutputModel::setRotation(int outputIndex, KScreen::Output::Rotation rotation) | ||
369 | { | 394 | { | ||
370 | const Output &output = m_outputs[outputIndex]; | 395 | const Output &output = m_outputs[outputIndex]; | ||
371 | 396 | | |||
372 | if (rotation != KScreen::Output::None | 397 | if (rotation != KScreen::Output::None | ||
373 | && rotation != KScreen::Output::Left | 398 | && rotation != KScreen::Output::Left | ||
374 | && rotation != KScreen::Output::Inverted | 399 | && rotation != KScreen::Output::Inverted | ||
375 | && rotation != KScreen::Output::Right) { | 400 | && rotation != KScreen::Output::Right) { | ||
▲ Show 20 Lines • Show All 526 Lines • Show Last 20 Lines |