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