mirror of
https://github.com/swift-project/pilotclient.git
synced 2026-04-05 01:05:34 +08:00
[AFV] CInputManager stores icon indexes instead of QPixmap instances
The GUI converts icon indexes to QPixmap indexes when needed. This fixes the context unittest that was broken by audio context changes.
This commit is contained in:
@@ -9,6 +9,8 @@
|
||||
#include "blackgui/models/actionitem.h"
|
||||
#include <QtAlgorithms>
|
||||
|
||||
using namespace BlackMisc;
|
||||
|
||||
namespace BlackGui
|
||||
{
|
||||
namespace Models
|
||||
@@ -21,6 +23,10 @@ namespace BlackGui
|
||||
m_action(action), m_actionName(name), m_icon(icon), m_parentItem(parentItem)
|
||||
{ }
|
||||
|
||||
CActionItem::CActionItem(const QString &action, const QString &name, CIcons::IconIndex icon, CActionItem *parentItem) :
|
||||
m_action(action), m_actionName(name), m_icon(CIcons::pixmapByIndex(icon)), m_parentItem(parentItem)
|
||||
{ }
|
||||
|
||||
CActionItem::~CActionItem()
|
||||
{
|
||||
qDeleteAll(m_childItems);
|
||||
|
||||
@@ -11,6 +11,7 @@
|
||||
#ifndef BLACKGUI_MODELS_ACTIONITEM_H
|
||||
#define BLACKGUI_MODELS_ACTIONITEM_H
|
||||
|
||||
#include "blackmisc/icons.h"
|
||||
#include <QList>
|
||||
#include <QString>
|
||||
#include <QPixmap>
|
||||
@@ -29,6 +30,9 @@ namespace BlackGui
|
||||
//! Constructor
|
||||
CActionItem(const QString &action, const QString &name, const QPixmap &icon, CActionItem *parentItem = nullptr);
|
||||
|
||||
//! Constructor
|
||||
CActionItem(const QString &action, const QString &name, BlackMisc::CIcons::IconIndex icon, CActionItem *parentItem = nullptr);
|
||||
|
||||
//! Destructor
|
||||
~CActionItem();
|
||||
|
||||
|
||||
@@ -103,7 +103,7 @@ namespace BlackGui
|
||||
m_rootItem.reset(new CActionItem(QString(), QString()));
|
||||
|
||||
Q_ASSERT_X(sApp && sApp->getInputManager(), Q_FUNC_INFO, "Missing input manager");
|
||||
const QMap<QString, QPixmap> availableActionsAndIcons = sApp->getInputManager()->allAvailableActionsAndIcons();
|
||||
const QMap<QString, BlackMisc::CIcons::IconIndex> availableActionsAndIcons = sApp->getInputManager()->allAvailableActionsAndIcons();
|
||||
QStringList keys = availableActionsAndIcons.keys();
|
||||
keys.sort();
|
||||
for (const QString &actionPath : as_const(keys))
|
||||
@@ -118,7 +118,7 @@ namespace BlackGui
|
||||
if (child == nullptr)
|
||||
{
|
||||
const bool isAction = currentPath == actionPath; // action istelf, or just a node?
|
||||
const QPixmap icon = isAction ? availableActionsAndIcons[actionPath] : CIcons::empty16();
|
||||
const BlackMisc::CIcons::IconIndex icon = isAction ? availableActionsAndIcons[actionPath] : CIcons::StandardIconEmpty16;
|
||||
child = new CActionItem(isAction ? actionPath : "", token, icon, parentItem);
|
||||
parentItem->appendChild(child);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user