mirror of
https://git.outfoxxed.me/quickshell/quickshell.git
synced 2025-11-06 19:14:57 +11:00
service/tray: mostly complete StatusNotifierItem implementation
Notably missing dbusmenu which makes it actually useful.
This commit is contained in:
parent
d47a7f2cff
commit
6214ac1002
25 changed files with 1321 additions and 4 deletions
33
src/services/status_notifier/trayimageprovider.cpp
Normal file
33
src/services/status_notifier/trayimageprovider.cpp
Normal file
|
|
@ -0,0 +1,33 @@
|
|||
#include "trayimageprovider.hpp"
|
||||
|
||||
#include <qlogging.h>
|
||||
#include <qloggingcategory.h>
|
||||
#include <qpixmap.h>
|
||||
#include <qsize.h>
|
||||
#include <qstring.h>
|
||||
|
||||
#include "host.hpp"
|
||||
|
||||
namespace qs::service::sni {
|
||||
|
||||
QPixmap
|
||||
TrayImageProvider::requestPixmap(const QString& id, QSize* size, const QSize& requestedSize) {
|
||||
auto split = id.split('/');
|
||||
if (split.size() != 2) {
|
||||
qCWarning(logStatusNotifierHost) << "Invalid image request:" << id;
|
||||
return QPixmap();
|
||||
}
|
||||
|
||||
auto* item = StatusNotifierHost::instance()->itemByService(split[0]);
|
||||
|
||||
if (item == nullptr) {
|
||||
qCWarning(logStatusNotifierHost) << "Image requested for nonexistant service" << split[0];
|
||||
return QPixmap();
|
||||
}
|
||||
|
||||
auto pixmap = item->createPixmap(requestedSize);
|
||||
if (size != nullptr) *size = pixmap.size();
|
||||
return pixmap;
|
||||
}
|
||||
|
||||
} // namespace qs::service::sni
|
||||
Loading…
Add table
Add a link
Reference in a new issue