Changeset View
Changeset View
Standalone View
Standalone View
libtaskmanager/tasktools.cpp
Show All 24 Lines | |||||
25 | #include <KDesktopFile> | 25 | #include <KDesktopFile> | ||
26 | #include <kemailsettings.h> | 26 | #include <kemailsettings.h> | ||
27 | #include <KFileItem> | 27 | #include <KFileItem> | ||
28 | #include <KMimeTypeTrader> | 28 | #include <KMimeTypeTrader> | ||
29 | #include <KRun> | 29 | #include <KRun> | ||
30 | #include <KSharedConfig> | 30 | #include <KSharedConfig> | ||
31 | 31 | | |||
32 | #include <QDir> | 32 | #include <QDir> | ||
33 | #include <QGuiApplication> | ||||
34 | #include <QScreen> | ||||
33 | 35 | | |||
34 | namespace TaskManager | 36 | namespace TaskManager | ||
35 | { | 37 | { | ||
36 | 38 | | |||
37 | AppData appDataFromUrl(const QUrl &url, const QIcon &fallbackIcon) | 39 | AppData appDataFromUrl(const QUrl &url, const QIcon &fallbackIcon) | ||
38 | { | 40 | { | ||
39 | AppData data; | 41 | AppData data; | ||
40 | data.url = url; | 42 | data.url = url; | ||
▲ Show 20 Lines • Show All 193 Lines • ▼ Show 20 Line(s) | 226 | { | |||
234 | 236 | | |||
235 | if (aUrl.isValid() && aUrl == bUrl) { | 237 | if (aUrl.isValid() && aUrl == bUrl) { | ||
236 | return true; | 238 | return true; | ||
237 | } | 239 | } | ||
238 | 240 | | |||
239 | return false; | 241 | return false; | ||
240 | } | 242 | } | ||
241 | 243 | | |||
244 | QRect screenGeometry(const QPoint &pos) | ||||
245 | { | ||||
246 | if (pos.isNull()) { | ||||
247 | return QRect(); | ||||
248 | } | ||||
249 | | ||||
250 | const QList<QScreen *> &screens = QGuiApplication::screens(); | ||||
251 | QRect screenGeometry; | ||||
252 | int shortestDistance = INT_MAX; | ||||
253 | | ||||
254 | for (int i = 0; i < screens.count(); ++i) { | ||||
255 | const QRect &geometry = screens.at(i)->geometry(); | ||||
256 | | ||||
257 | if (geometry.contains(pos)) { | ||||
258 | return geometry; | ||||
259 | } | ||||
260 | | ||||
261 | int distance = QPoint(geometry.topLeft() - pos).manhattanLength(); | ||||
262 | distance = qMin(distance, QPoint(geometry.topRight() - pos).manhattanLength()); | ||||
263 | distance = qMin(distance, QPoint(geometry.bottomRight() - pos).manhattanLength()); | ||||
264 | distance = qMin(distance, QPoint(geometry.bottomLeft() - pos).manhattanLength()); | ||||
265 | | ||||
266 | if (distance < shortestDistance) { | ||||
267 | shortestDistance = distance; | ||||
268 | screenGeometry = geometry; | ||||
269 | } | ||||
270 | } | ||||
271 | | ||||
272 | return screenGeometry; | ||||
273 | } | ||||
274 | | ||||
242 | } | 275 | } |