Changeset View
Changeset View
Standalone View
Standalone View
krunner/view.cpp
Show First 20 Lines • Show All 89 Lines • ▼ Show 20 Line(s) | 86 | auto screenRemoved = [this](QScreen* screen) { | |||
---|---|---|---|---|---|
90 | } | 90 | } | ||
91 | }; | 91 | }; | ||
92 | 92 | | |||
93 | auto screenAdded = [this](QScreen* screen) { | 93 | auto screenAdded = [this](QScreen* screen) { | ||
94 | connect(screen, &QScreen::geometryChanged, this, &View::screenGeometryChanged); | 94 | connect(screen, &QScreen::geometryChanged, this, &View::screenGeometryChanged); | ||
95 | screenGeometryChanged(); | 95 | screenGeometryChanged(); | ||
96 | }; | 96 | }; | ||
97 | 97 | | |||
98 | foreach(QScreen* s, QGuiApplication::screens()) | 98 | const auto screens = QGuiApplication::screens(); | ||
99 | for (QScreen* s : screens) | ||||
99 | screenAdded(s); | 100 | screenAdded(s); | ||
100 | connect(qGuiApp, &QGuiApplication::screenAdded, this, screenAdded); | 101 | connect(qGuiApp, &QGuiApplication::screenAdded, this, screenAdded); | ||
101 | connect(qGuiApp, &QGuiApplication::screenRemoved, this, screenRemoved); | 102 | connect(qGuiApp, &QGuiApplication::screenRemoved, this, screenRemoved); | ||
102 | 103 | | |||
103 | connect(KWindowSystem::self(), &KWindowSystem::workAreaChanged, this, &View::resetScreenPos); | 104 | connect(KWindowSystem::self(), &KWindowSystem::workAreaChanged, this, &View::resetScreenPos); | ||
104 | 105 | | |||
105 | connect(this, &View::visibleChanged, this, &View::resetScreenPos); | 106 | connect(this, &View::visibleChanged, this, &View::resetScreenPos); | ||
106 | 107 | | |||
▲ Show 20 Lines • Show All 106 Lines • ▼ Show 20 Line(s) | 213 | if (isVisible() && !m_floating) { | |||
213 | positionOnScreen(); | 214 | positionOnScreen(); | ||
214 | } | 215 | } | ||
215 | } | 216 | } | ||
216 | 217 | | |||
217 | void View::positionOnScreen() | 218 | void View::positionOnScreen() | ||
218 | { | 219 | { | ||
219 | QScreen *shownOnScreen = QGuiApplication::primaryScreen(); | 220 | QScreen *shownOnScreen = QGuiApplication::primaryScreen(); | ||
220 | 221 | | |||
221 | Q_FOREACH (QScreen* screen, QGuiApplication::screens()) { | 222 | const auto screens = QGuiApplication::screens(); | ||
223 | for (QScreen* screen : screens) { | ||||
222 | if (screen->geometry().contains(QCursor::pos(screen))) { | 224 | if (screen->geometry().contains(QCursor::pos(screen))) { | ||
223 | shownOnScreen = screen; | 225 | shownOnScreen = screen; | ||
224 | break; | 226 | break; | ||
225 | } | 227 | } | ||
226 | } | 228 | } | ||
227 | 229 | | |||
228 | setScreen(shownOnScreen); | 230 | setScreen(shownOnScreen); | ||
229 | const QRect r = shownOnScreen->availableGeometry(); | 231 | const QRect r = shownOnScreen->availableGeometry(); | ||
▲ Show 20 Lines • Show All 159 Lines • Show Last 20 Lines |