Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

IconEngine: Forward API to child icon engine #792

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
28 changes: 5 additions & 23 deletions src/core/iconinfo_p.h
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@
#include "../libfmqtglobals.h"
#include "iconinfo.h"
#include <gio/gio.h>
#include <private/qicon_p.h>

namespace Fm {

Expand Down Expand Up @@ -80,38 +81,19 @@ QString IconEngine::key() const {
void IconEngine::paint(QPainter* painter, const QRect& rect, QIcon::Mode mode, QIcon::State state) {
auto info = info_.lock();
if(info) {
info->internalQicon().paint(painter, rect, Qt::AlignCenter, mode, state);
info->internalQicon().data_ptr()->engine->paint(painter, rect, mode, state);
}
}

QPixmap IconEngine::pixmap(const QSize& size, QIcon::Mode mode, QIcon::State state) {
auto info = info_.lock();
return info ? info->internalQicon().pixmap(size, mode, state) : QPixmap{};
return info ? info->internalQicon().data_ptr()->engine->pixmap(size, mode, state) : QPixmap{};
}

void IconEngine::virtual_hook(int id, void* data) {
auto info = info_.lock();
switch(id) {
case QIconEngine::AvailableSizesHook: {
auto* args = reinterpret_cast<QIconEngine::AvailableSizesArgument*>(data);
args->sizes = info ? info->internalQicon().availableSizes(args->mode, args->state) : QList<QSize>{};
break;
}
case QIconEngine::IconNameHook: {
QString* result = reinterpret_cast<QString*>(data);
*result = info ? info->internalQicon().name() : QString{};
break;
}
case QIconEngine::IsNullHook: {
bool* result = reinterpret_cast<bool*>(data);
*result = info ? info->internalQicon().isNull() : true;
break;
}
case QIconEngine::ScaledPixmapHook: {
auto* arg = reinterpret_cast<QIconEngine::ScaledPixmapArgument*>(data);
arg->pixmap = info ? info->internalQicon().pixmap(arg->size, arg->mode, arg->state) : QPixmap{};
break;
}
if (info) {
info->internalQicon().data_ptr()->engine->virtual_hook(id, data);
}
}

Expand Down