Changeset View
Changeset View
Standalone View
Standalone View
effects/startupfeedback/startupfeedback.cpp
Show All 22 Lines | |||||
23 | #include <QFile> | 23 | #include <QFile> | ||
24 | #include <QSize> | 24 | #include <QSize> | ||
25 | #include <QStyle> | 25 | #include <QStyle> | ||
26 | #include <QStandardPaths> | 26 | #include <QStandardPaths> | ||
27 | #include <QPainter> | 27 | #include <QPainter> | ||
28 | // KDE | 28 | // KDE | ||
29 | #include <KConfigGroup> | 29 | #include <KConfigGroup> | ||
30 | #include <KSharedConfig> | 30 | #include <KSharedConfig> | ||
31 | #include <KIconLoader> | | |||
32 | #include <KStartupInfo> | 31 | #include <KStartupInfo> | ||
33 | #include <KSelectionOwner> | 32 | #include <KSelectionOwner> | ||
34 | #include <KWindowSystem> | 33 | #include <KWindowSystem> | ||
35 | // KWin | 34 | // KWin | ||
36 | #include <kwinglutils.h> | 35 | #include <kwinglutils.h> | ||
37 | 36 | | |||
38 | // based on StartupId in KRunner by Lubos Lunak | 37 | // based on StartupId in KRunner by Lubos Lunak | ||
39 | // Copyright (C) 2001 Lubos Lunak <l.lunak@kde.org> | 38 | // Copyright (C) 2001 Lubos Lunak <l.lunak@kde.org> | ||
▲ Show 20 Lines • Show All 227 Lines • ▼ Show 20 Line(s) | |||||
267 | 266 | | |||
268 | void StartupFeedbackEffect::start(const QString& icon) | 267 | void StartupFeedbackEffect::start(const QString& icon) | ||
269 | { | 268 | { | ||
270 | if (m_type == NoFeedback) | 269 | if (m_type == NoFeedback) | ||
271 | return; | 270 | return; | ||
272 | if (!m_active) | 271 | if (!m_active) | ||
273 | effects->startMousePolling(); | 272 | effects->startMousePolling(); | ||
274 | m_active = true; | 273 | m_active = true; | ||
275 | // get ratio for bouncing cursor so we don't need to manually calculate the sizes for each icon size | | |||
276 | if (m_type == BouncingFeedback) | | |||
277 | m_bounceSizesRatio = IconSize(KIconLoader::Small) / 16.0; | | |||
278 | QPixmap iconPixmap = KIconLoader::global()->loadIcon(icon, KIconLoader::Small, 0, | | |||
279 | KIconLoader::DefaultState, QStringList(), nullptr, true); // return null pixmap if not found | | |||
280 | if (iconPixmap.isNull()) | | |||
281 | iconPixmap = SmallIcon(QStringLiteral("system-run")); | | |||
282 | prepareTextures(iconPixmap); | | |||
283 | auto readCursorSize = []() -> int { | 274 | auto readCursorSize = []() -> int { | ||
284 | // read details about the mouse-cursor theme define per default | 275 | // read details about the mouse-cursor theme define per default | ||
285 | KConfigGroup mousecfg(effects->inputConfig(), "Mouse"); | 276 | KConfigGroup mousecfg(effects->inputConfig(), "Mouse"); | ||
286 | QString size = mousecfg.readEntry("cursorSize", QString()); | 277 | QString size = mousecfg.readEntry("cursorSize", QString()); | ||
287 | 278 | | |||
288 | // fetch a reasonable size for the cursor-theme image | 279 | // fetch a reasonable size for the cursor-theme image | ||
289 | bool ok; | 280 | bool ok; | ||
290 | int cursorSize = size.toInt(&ok); | 281 | int cursorSize = size.toInt(&ok); | ||
291 | if (!ok) | 282 | if (!ok) | ||
292 | cursorSize = QApplication::style()->pixelMetric(QStyle::PM_LargeIconSize); | 283 | cursorSize = QApplication::style()->pixelMetric(QStyle::PM_LargeIconSize); | ||
293 | return cursorSize; | 284 | return cursorSize; | ||
294 | }; | 285 | }; | ||
295 | m_cursorSize = readCursorSize(); | 286 | m_cursorSize = readCursorSize(); | ||
287 | const int iconSize = m_cursorSize / 1.5; | ||||
zzag: What's this 1.5 factor? | |||||
broulik: Normal cursor size is 24, normal small icon size is 16. | |||||
288 | // get ratio for bouncing cursor so we don't need to manually calculate the sizes for each icon size | ||||
289 | if (m_type == BouncingFeedback) | ||||
290 | m_bounceSizesRatio = iconSize / 16.0; | ||||
291 | const QPixmap iconPixmap = QIcon::fromTheme(icon, QIcon::fromTheme(QStringLiteral("system-run"))).pixmap(iconSize); | ||||
292 | prepareTextures(iconPixmap); | ||||
296 | m_dirtyRect = m_currentGeometry = feedbackRect(); | 293 | m_dirtyRect = m_currentGeometry = feedbackRect(); | ||
297 | effects->addRepaint(m_dirtyRect); | 294 | effects->addRepaint(m_dirtyRect); | ||
298 | } | 295 | } | ||
299 | 296 | | |||
300 | void StartupFeedbackEffect::stop() | 297 | void StartupFeedbackEffect::stop() | ||
301 | { | 298 | { | ||
302 | if (m_active) | 299 | if (m_active) | ||
303 | effects->stopMousePolling(); | 300 | effects->stopMousePolling(); | ||
▲ Show 20 Lines • Show All 98 Lines • Show Last 20 Lines |
What's this 1.5 factor?