Changeset View
Changeset View
Standalone View
Standalone View
host/mprisplugin.cpp
Show All 32 Lines | |||||
33 | #include "mprisplayer.h" | 33 | #include "mprisplayer.h" | ||
34 | 34 | | |||
35 | #include "settings.h" | 35 | #include "settings.h" | ||
36 | 36 | | |||
37 | #include <unistd.h> // getppid | 37 | #include <unistd.h> // getppid | ||
38 | 38 | | |||
39 | static const QString s_serviceName = QStringLiteral("org.mpris.MediaPlayer2.plasma-browser-integration"); | 39 | static const QString s_serviceName = QStringLiteral("org.mpris.MediaPlayer2.plasma-browser-integration"); | ||
40 | 40 | | |||
41 | static const int s_maxThumbnailSize = 512; | ||||
42 | | ||||
41 | MPrisPlugin::MPrisPlugin(QObject *parent) | 43 | MPrisPlugin::MPrisPlugin(QObject *parent) | ||
42 | : AbstractBrowserPlugin(QStringLiteral("mpris"), 1, parent) | 44 | : AbstractBrowserPlugin(QStringLiteral("mpris"), 1, parent) | ||
43 | , m_root(new MPrisRoot(this)) | 45 | , m_root(new MPrisRoot(this)) | ||
44 | , m_player(new MPrisPlayer(this)) | 46 | , m_player(new MPrisPlayer(this)) | ||
45 | , m_playbackStatus(QStringLiteral("Stopped")) | 47 | , m_playbackStatus(QStringLiteral("Stopped")) | ||
46 | , m_loopStatus(QStringLiteral("None")) | 48 | , m_loopStatus(QStringLiteral("None")) | ||
47 | { | 49 | { | ||
48 | 50 | | |||
▲ Show 20 Lines • Show All 434 Lines • ▼ Show 20 Line(s) | 478 | if (sizeParts.count() == 2) { | |||
483 | actualSize = QSize(width, height); | 485 | actualSize = QSize(width, height); | ||
484 | } | 486 | } | ||
485 | 487 | | |||
486 | const QString type = item.value(QStringLiteral("type")).toString(); | 488 | const QString type = item.value(QStringLiteral("type")).toString(); | ||
487 | if (!type.isEmpty() && !supportedImageMimes.contains(type.toUtf8())) { | 489 | if (!type.isEmpty() && !supportedImageMimes.contains(type.toUtf8())) { | ||
488 | continue; | 490 | continue; | ||
489 | } | 491 | } | ||
490 | 492 | | |||
491 | if (!biggest.isValid() || (actualSize.width() >= biggest.width() && actualSize.height() >= biggest.height())) { | 493 | if (!biggest.isValid() || | ||
fvogt: AFAICT this will not work as expected in cases such as 1920x1080 followed by 256x256. | |||||
494 | (actualSize.width() >= biggest.width() && actualSize.height() >= biggest.height() | ||||
495 | && actualSize.width() <= s_maxThumbnailSize && actualSize.height() <= s_maxThumbnailSize)) { | ||||
492 | artworkUrl = url; | 496 | artworkUrl = url; | ||
493 | biggest = actualSize; | 497 | biggest = actualSize; | ||
494 | } | 498 | } | ||
495 | } | 499 | } | ||
496 | 500 | | |||
497 | m_artworkUrl = artworkUrl; | 501 | m_artworkUrl = artworkUrl; | ||
498 | 502 | | |||
499 | emitPropertyChange(m_player, "Metadata"); | 503 | emitPropertyChange(m_player, "Metadata"); | ||
500 | } | 504 | } | ||
501 | 505 | | |||
502 | void MPrisPlugin::processCallbacks(const QJsonArray &data) | 506 | void MPrisPlugin::processCallbacks(const QJsonArray &data) | ||
503 | { | 507 | { | ||
504 | const bool canGoNext = data.contains(QLatin1String("nexttrack")); | 508 | const bool canGoNext = data.contains(QLatin1String("nexttrack")); | ||
505 | if (m_canGoNext != canGoNext) { | 509 | if (m_canGoNext != canGoNext) { | ||
Why change this line? With auto it was easier to read, just the & should be removed for clarity. Now it also accepts `xx42xx42xx" as valid size, while it didn't before. fvogt: Why change this line? With auto it was easier to read, just the `&` should be removed for… | |||||
506 | m_canGoNext = canGoNext; | 510 | m_canGoNext = canGoNext; | ||
507 | emitPropertyChange(m_player, "CanGoNext"); | 511 | emitPropertyChange(m_player, "CanGoNext"); | ||
508 | } | 512 | } | ||
509 | 513 | | |||
510 | const bool canGoPrevious = data.contains(QLatin1String("previoustrack")); | 514 | const bool canGoPrevious = data.contains(QLatin1String("previoustrack")); | ||
511 | if (m_canGoPrevious != canGoPrevious) { | 515 | if (m_canGoPrevious != canGoPrevious) { | ||
512 | m_canGoPrevious = canGoPrevious; | 516 | m_canGoPrevious = canGoPrevious; | ||
513 | emitPropertyChange(m_player, "CanGoPrevious"); | 517 | emitPropertyChange(m_player, "CanGoPrevious"); | ||
514 | } | 518 | } | ||
That's still equal to std::numeric_limits<qreal>::max() due to lacking precision. fvogt: That's still equal to `std::numeric_limits<qreal>::max()` due to lacking precision. | |||||
515 | } | 519 | } | ||
516 | 520 | | |||
517 | void MPrisPlugin::Raise() | 521 | void MPrisPlugin::Raise() | ||
518 | { | 522 | { | ||
519 | sendData(QStringLiteral("raise")); | 523 | sendData(QStringLiteral("raise")); | ||
520 | } | 524 | } | ||
521 | 525 | | |||
522 | void MPrisPlugin::Quit() | 526 | void MPrisPlugin::Quit() | ||
523 | { | 527 | { | ||
524 | 528 | | |||
525 | } | 529 | } | ||
526 | 530 | | |||
This algorithm only looks at the aspect ratio of the image, not the resolution. For 4096x4096, 1024x1024 and 512x512 you'll get the same effectiveSamples value, so it will load huge thumbnails again. fvogt: This algorithm only looks at the aspect ratio of the image, not the resolution. For 4096x4096… | |||||
527 | void MPrisPlugin::Next() | 531 | void MPrisPlugin::Next() | ||
528 | { | 532 | { | ||
529 | sendData(QStringLiteral("next")); | 533 | sendData(QStringLiteral("next")); | ||
530 | } | 534 | } | ||
531 | 535 | | |||
532 | void MPrisPlugin::Previous() | 536 | void MPrisPlugin::Previous() | ||
533 | { | 537 | { | ||
534 | sendData(QStringLiteral("previous")); | 538 | sendData(QStringLiteral("previous")); | ||
▲ Show 20 Lines • Show All 53 Lines • Show Last 20 Lines |
AFAICT this will not work as expected in cases such as 1920x1080 followed by 256x256.