Changeset View
Changeset View
Standalone View
Standalone View
backends/kwayland/waylandoutput.cpp
Show First 20 Lines • Show All 54 Lines • ▼ Show 20 Line(s) | |||||
55 | 55 | | |||
56 | KWayland::Client::OutputDevice::Transform WaylandOutput::toKWaylandTransform(const KScreen::Output::Rotation rotation) const | 56 | KWayland::Client::OutputDevice::Transform WaylandOutput::toKWaylandTransform(const KScreen::Output::Rotation rotation) const | ||
57 | { | 57 | { | ||
58 | return m_rotationMap.key(rotation); | 58 | return m_rotationMap.key(rotation); | ||
59 | } | 59 | } | ||
60 | 60 | | |||
61 | QString WaylandOutput::toKScreenModeId(int kwaylandmodeid) const | 61 | QString WaylandOutput::toKScreenModeId(int kwaylandmodeid) const | ||
62 | { | 62 | { | ||
63 | if (!m_modeIdMap.values().contains(kwaylandmodeid)) { | 63 | auto it = std::find(m_modeIdMap.constBegin(), m_modeIdMap.constEnd(), kwaylandmodeid); | ||
64 | if (it == m_modeIdMap.constEnd()) { | ||||
broulik: I think we typically use `const...()` instead of `c...()` but since this method is `const`… | |||||
Isn't it better to follow STL style? cbegin is also popular in KDE projects: https://lxr.kde.org/search?_filestring=&_string=cbegin volkov: Isn't it better to follow STL style?
cbegin is also popular in KDE projects: https://lxr.kde. | |||||
64 | qCWarning(KSCREEN_WAYLAND) << "Invalid kwayland mode id:" << kwaylandmodeid << m_modeIdMap; | 65 | qCWarning(KSCREEN_WAYLAND) << "Invalid kwayland mode id:" << kwaylandmodeid << m_modeIdMap; | ||
66 | return QStringLiteral("invalid_mode_id"); | ||||
65 | } | 67 | } | ||
66 | return m_modeIdMap.key(kwaylandmodeid, QStringLiteral("invalid_mode_id")); | 68 | return it.key(); | ||
67 | } | 69 | } | ||
68 | 70 | | |||
69 | int WaylandOutput::toKWaylandModeId(const QString &kscreenmodeid) const | 71 | int WaylandOutput::toKWaylandModeId(const QString &kscreenmodeid) const | ||
70 | { | 72 | { | ||
71 | if (!m_modeIdMap.contains(kscreenmodeid)) { | 73 | if (!m_modeIdMap.contains(kscreenmodeid)) { | ||
72 | qCWarning(KSCREEN_WAYLAND) << "Invalid kscreen mode id:" << kscreenmodeid << m_modeIdMap; | 74 | qCWarning(KSCREEN_WAYLAND) << "Invalid kscreen mode id:" << kscreenmodeid << m_modeIdMap; | ||
73 | } | 75 | } | ||
74 | return m_modeIdMap.value(kscreenmodeid, -1); | 76 | return m_modeIdMap.value(kscreenmodeid, -1); | ||
▲ Show 20 Lines • Show All 63 Lines • ▼ Show 20 Line(s) | 125 | { | |||
138 | Q_FOREACH (const KWayland::Client::OutputDevice::Mode &m, m_output->modes()) { | 140 | Q_FOREACH (const KWayland::Client::OutputDevice::Mode &m, m_output->modes()) { | ||
139 | KScreen::ModePtr mode(new KScreen::Mode()); | 141 | KScreen::ModePtr mode(new KScreen::Mode()); | ||
140 | const QString modename = modeName(m); | 142 | const QString modename = modeName(m); | ||
141 | QString modeid = QString::number(m.id); | 143 | QString modeid = QString::number(m.id); | ||
142 | if (modeid.isEmpty()) { | 144 | if (modeid.isEmpty()) { | ||
143 | qCDebug(KSCREEN_WAYLAND) << "Could not create mode id from" << m.id << ", using" << modename << "instead."; | 145 | qCDebug(KSCREEN_WAYLAND) << "Could not create mode id from" << m.id << ", using" << modename << "instead."; | ||
144 | modeid = modename; | 146 | modeid = modename; | ||
145 | } | 147 | } | ||
146 | if (m_modeIdMap.keys().contains(modeid)) { | 148 | if (m_modeIdMap.contains(modeid)) { | ||
147 | qCWarning(KSCREEN_WAYLAND) << "Mode id already in use:" << modeid; | 149 | qCWarning(KSCREEN_WAYLAND) << "Mode id already in use:" << modeid; | ||
148 | } | 150 | } | ||
149 | 151 | | |||
150 | mode->setId(modeid); | 152 | mode->setId(modeid); | ||
151 | // KWayland gives the refresh rate as int in mHz | 153 | // KWayland gives the refresh rate as int in mHz | ||
152 | mode->setRefreshRate(m.refreshRate / 1000.0); | 154 | mode->setRefreshRate(m.refreshRate / 1000.0); | ||
153 | mode->setSize(m.size); | 155 | mode->setSize(m.size); | ||
154 | mode->setName(modename); | 156 | mode->setName(modename); | ||
▲ Show 20 Lines • Show All 42 Lines • Show Last 20 Lines |
I think we typically use const...() instead of c...() but since this method is const, shouldn't be neccessary to begin with