show recipes visually instead of describing them in text
This commit is contained in:
@@ -1,28 +1,51 @@
|
||||
#pragma once
|
||||
|
||||
#include <string>
|
||||
|
||||
#include <QPixmap>
|
||||
#include <QString>
|
||||
#include <QWidget>
|
||||
|
||||
#include "SelectionContext.h"
|
||||
|
||||
class ItemTooltip;
|
||||
class QEvent;
|
||||
class QLabel;
|
||||
class QTimer;
|
||||
|
||||
// One buffered item: its icon, its count in a larger type, and a sub-line beneath the
|
||||
// count (REQ-UI-SINGLE-SELECTION). Boxed so a row of them reads as separate quantities
|
||||
// rather than as a run of text.
|
||||
//
|
||||
// Hovering it explains where its item comes from (REQ-UI-ITEM-TOOLTIP).
|
||||
class ItemChip : public QWidget
|
||||
{
|
||||
Q_OBJECT
|
||||
|
||||
public:
|
||||
// An empty icon leaves the icon off and the chip laid out around the text alone.
|
||||
ItemChip(const QPixmap& icon, QWidget* parent = nullptr);
|
||||
ItemChip(const SelectionContext& context, const std::string& itemId,
|
||||
const QPixmap& icon, QWidget* parent = nullptr);
|
||||
|
||||
void setCount(const QString& count);
|
||||
// Left empty for an item with nothing to say beneath its count.
|
||||
void setSubLine(const QString& subLine);
|
||||
|
||||
protected:
|
||||
void enterEvent(QEvent* event) override;
|
||||
void leaveEvent(QEvent* event) override;
|
||||
|
||||
private:
|
||||
QLabel* m_iconLabel;
|
||||
QLabel* m_countLabel;
|
||||
QLabel* m_subLineLabel;
|
||||
void showTooltip();
|
||||
|
||||
SelectionContext m_context;
|
||||
std::string m_itemId;
|
||||
QLabel* m_iconLabel;
|
||||
QLabel* m_countLabel;
|
||||
QLabel* m_subLineLabel;
|
||||
// Held back so a cursor crossing the chip on its way elsewhere does not flash the
|
||||
// tooltip, the way an ordinary tooltip is.
|
||||
QTimer* m_hoverTimer;
|
||||
// Built on the first hover, because most chips are never hovered at all.
|
||||
ItemTooltip* m_tooltip = nullptr;
|
||||
};
|
||||
|
||||
Reference in New Issue
Block a user