mirror of
https://github.com/Cockatrice/Cockatrice.git
synced 2026-09-28 08:52:19 -07:00
Add card completion popups to chats and search fields
Completes @mention and [[card]] in chat, and card names in the deck editor, EDHREC, Archidekt, card art rules, and user card settings searches. Pops up an Arena-style list with mana pips and a card image preview, flipping the list order when the popup opens above the text field. Took 5 minutes Took 56 seconds Took 4 minutes Took 6 minutes
This commit is contained in:
parent
c08dc780a7
commit
06393f9859
22 changed files with 1375 additions and 285 deletions
|
|
@ -0,0 +1,65 @@
|
|||
/**
|
||||
* @file card_completer_styler.h
|
||||
* @ingroup UtilityWidgets
|
||||
*/
|
||||
//! \todo Document this file.
|
||||
|
||||
#ifndef CARD_COMPLETER_STYLER_H
|
||||
#define CARD_COMPLETER_STYLER_H
|
||||
|
||||
#include <QModelIndex>
|
||||
#include <QObject>
|
||||
|
||||
class CardInfoPictureEnlargedWidget;
|
||||
class QCompleter;
|
||||
class QKeyEvent;
|
||||
class QPoint;
|
||||
class ReversedCompleterModel;
|
||||
|
||||
/**
|
||||
* @brief Applies styled row painting and a card-image preview to a card completer.
|
||||
*
|
||||
* The completer popup rows are painted by CardCompleterDelegate and the image of
|
||||
* the currently selected (or hovered) row is shown beside the popup.
|
||||
*/
|
||||
class CardCompleterStyler : public QObject
|
||||
{
|
||||
Q_OBJECT
|
||||
public:
|
||||
/**
|
||||
* @brief Styles @p completer and follows its current selection.
|
||||
*
|
||||
* The styler is parented to the completer so it lives exactly as long as the
|
||||
* completer itself.
|
||||
*/
|
||||
static void apply(QCompleter *completer);
|
||||
|
||||
protected:
|
||||
bool eventFilter(QObject *obj, QEvent *ev) override;
|
||||
|
||||
private slots:
|
||||
void updatePreview(const QModelIndex &index);
|
||||
void updatePreviewFromHover(const QPoint &pos);
|
||||
void onCompletionReset();
|
||||
|
||||
private:
|
||||
explicit CardCompleterStyler(QCompleter *completer, QObject *parent = nullptr);
|
||||
|
||||
void showPreview();
|
||||
void hidePreview();
|
||||
void reposition();
|
||||
|
||||
void updateOrientation();
|
||||
void ensureClosestSelected();
|
||||
|
||||
bool handlePopupKeyPress(QKeyEvent *event);
|
||||
bool isPopupAboveWidget() const;
|
||||
|
||||
QCompleter *completer;
|
||||
ReversedCompleterModel *reversedModel;
|
||||
CardInfoPictureEnlargedWidget *preview;
|
||||
QModelIndex previewedIndex;
|
||||
bool above;
|
||||
};
|
||||
|
||||
#endif // CARD_COMPLETER_STYLER_H
|
||||
Loading…
Add table
Add a link
Reference in a new issue