Changeset View
Changeset View
Standalone View
Standalone View
backends/qscreen/qscreenconfig.cpp
Show All 37 Lines | 37 | foreach(const QScreen * qscreen, QGuiApplication::screens()) { | |||
---|---|---|---|---|---|
38 | screenAdded(qscreen); | 38 | screenAdded(qscreen); | ||
39 | } | 39 | } | ||
40 | m_blockSignals = false; | 40 | m_blockSignals = false; | ||
41 | connect(qApp, &QGuiApplication::screenAdded, this, &QScreenConfig::screenAdded); | 41 | connect(qApp, &QGuiApplication::screenAdded, this, &QScreenConfig::screenAdded); | ||
42 | connect(qApp, &QGuiApplication::screenRemoved, this, &QScreenConfig::screenRemoved); | 42 | connect(qApp, &QGuiApplication::screenRemoved, this, &QScreenConfig::screenRemoved); | ||
43 | } | 43 | } | ||
44 | 44 | | |||
45 | QScreenConfig::~QScreenConfig() | 45 | QScreenConfig::~QScreenConfig() | ||
46 | { | 46 | { | ||
47 | foreach(auto output, m_outputMap.values()) { | 47 | qDeleteAll(m_outputMap); | ||
broulik: `qDeleteAll(m_outputMap);` | |||||
48 | delete output; | | |||
49 | } | | |||
50 | } | 48 | } | ||
51 | 49 | | |||
52 | ConfigPtr QScreenConfig::toKScreenConfig() const | 50 | ConfigPtr QScreenConfig::toKScreenConfig() const | ||
53 | { | 51 | { | ||
54 | ConfigPtr config(new Config); | 52 | ConfigPtr config(new Config); | ||
55 | config->setScreen(m_screen->toKScreenScreen()); | 53 | config->setScreen(m_screen->toKScreenScreen()); | ||
56 | updateKScreenConfig(config); | 54 | updateKScreenConfig(config); | ||
57 | return config; | 55 | return config; | ||
58 | } | 56 | } | ||
59 | 57 | | |||
60 | int QScreenConfig::outputId(const QScreen *qscreen) | 58 | int QScreenConfig::outputId(const QScreen *qscreen) | ||
61 | { | 59 | { | ||
62 | QList<int> ids; | 60 | QList<int> ids; | ||
broulik: This seems unused | |||||
63 | foreach(auto output, m_outputMap.values()) { | 61 | foreach(auto output, m_outputMap) { | ||
64 | if (qscreen == output->qscreen()) { | 62 | if (qscreen == output->qscreen()) { | ||
65 | return output->id(); | 63 | return output->id(); | ||
66 | } | 64 | } | ||
67 | } | 65 | } | ||
68 | m_lastOutputId++; | 66 | m_lastOutputId++; | ||
69 | return m_lastOutputId; | 67 | return m_lastOutputId; | ||
70 | } | 68 | } | ||
71 | 69 | | |||
Show All 9 Lines | 71 | { | |||
81 | } | 79 | } | ||
82 | } | 80 | } | ||
83 | 81 | | |||
84 | void QScreenConfig::screenRemoved(QScreen *qscreen) | 82 | void QScreenConfig::screenRemoved(QScreen *qscreen) | ||
85 | { | 83 | { | ||
86 | qCDebug(KSCREEN_QSCREEN) << "Screen removed" << qscreen << QGuiApplication::screens().count(); | 84 | qCDebug(KSCREEN_QSCREEN) << "Screen removed" << qscreen << QGuiApplication::screens().count(); | ||
87 | // Find output matching the QScreen object and remove it | 85 | // Find output matching the QScreen object and remove it | ||
88 | int removedOutputId = -1; | 86 | int removedOutputId = -1; | ||
89 | foreach(auto output, m_outputMap.values()) { | 87 | foreach(auto output, m_outputMap) { | ||
90 | if (output->qscreen() == qscreen) { | 88 | if (output->qscreen() == qscreen) { | ||
91 | removedOutputId = output->id(); | 89 | removedOutputId = output->id(); | ||
92 | m_outputMap.remove(removedOutputId); | 90 | m_outputMap.remove(removedOutputId); | ||
93 | delete output; | 91 | delete output; | ||
94 | } | 92 | } | ||
95 | } | 93 | } | ||
96 | Q_EMIT configChanged(toKScreenConfig()); | 94 | Q_EMIT configChanged(toKScreenConfig()); | ||
97 | } | 95 | } | ||
98 | 96 | | |||
99 | void QScreenConfig::updateKScreenConfig(ConfigPtr &config) const | 97 | void QScreenConfig::updateKScreenConfig(ConfigPtr &config) const | ||
100 | { | 98 | { | ||
101 | KScreen::ScreenPtr screen = config->screen(); | 99 | KScreen::ScreenPtr screen = config->screen(); | ||
102 | m_screen->updateKScreenScreen(screen); | 100 | m_screen->updateKScreenScreen(screen); | ||
103 | config->setScreen(screen); | 101 | config->setScreen(screen); | ||
104 | 102 | | |||
105 | //Removing removed outputs | 103 | //Removing removed outputs | ||
106 | KScreen::OutputList outputs = config->outputs(); | 104 | KScreen::OutputList outputs = config->outputs(); | ||
107 | Q_FOREACH(const KScreen::OutputPtr &output, outputs) { | 105 | Q_FOREACH(const KScreen::OutputPtr &output, outputs) { | ||
108 | if (!m_outputMap.keys().contains(output->id())) { | 106 | if (!m_outputMap.contains(output->id())) { | ||
109 | config->removeOutput(output->id()); | 107 | config->removeOutput(output->id()); | ||
110 | } | 108 | } | ||
111 | } | 109 | } | ||
112 | 110 | | |||
113 | // Add KScreen::Outputs that aren't in the list yet, handle primaryOutput | 111 | // Add KScreen::Outputs that aren't in the list yet, handle primaryOutput | ||
114 | KScreen::OutputList kscreenOutputs = config->outputs(); | 112 | KScreen::OutputList kscreenOutputs = config->outputs(); | ||
115 | foreach(QScreenOutput *output, m_outputMap.values()) { | 113 | foreach(QScreenOutput *output, m_outputMap) { | ||
116 | KScreen::OutputPtr kscreenOutput = kscreenOutputs[output->id()]; | 114 | KScreen::OutputPtr kscreenOutput = kscreenOutputs[output->id()]; | ||
117 | 115 | | |||
118 | if (!kscreenOutput) { | 116 | if (!kscreenOutput) { | ||
119 | kscreenOutput = output->toKScreenOutput(); | 117 | kscreenOutput = output->toKScreenOutput(); | ||
120 | kscreenOutputs.insert(kscreenOutput->id(), kscreenOutput); | 118 | kscreenOutputs.insert(kscreenOutput->id(), kscreenOutput); | ||
121 | } | 119 | } | ||
122 | output->updateKScreenOutput(kscreenOutput); | 120 | output->updateKScreenOutput(kscreenOutput); | ||
123 | if (QGuiApplication::primaryScreen() == output->qscreen()) { | 121 | if (QGuiApplication::primaryScreen() == output->qscreen()) { | ||
Show All 10 Lines |
qDeleteAll(m_outputMap);