mirror of
https://github.com/Nheko-Reborn/nheko.git
synced 2024-10-31 10:00:46 +03:00
49 lines
1.2 KiB
C++
49 lines
1.2 KiB
C++
#pragma once
|
|
|
|
#include <QWidget>
|
|
|
|
#include "CacheStructs.h"
|
|
|
|
class QVBoxLayout;
|
|
class QLayoutItem;
|
|
|
|
class SuggestionsPopup : public QWidget
|
|
{
|
|
Q_OBJECT
|
|
|
|
public:
|
|
explicit SuggestionsPopup(QWidget *parent = nullptr);
|
|
|
|
void selectHoveredSuggestion();
|
|
|
|
public slots:
|
|
void addRooms(const std::vector<RoomSearchResult> &rooms);
|
|
|
|
//! Move to the next available suggestion item.
|
|
void selectNextSuggestion();
|
|
//! Move to the previous available suggestion item.
|
|
void selectPreviousSuggestion();
|
|
//! Remove hovering from all items.
|
|
void resetHovering();
|
|
//! Set hovering to the item in the given layout position.
|
|
void setHovering(int pos);
|
|
|
|
protected:
|
|
void paintEvent(QPaintEvent *event) override;
|
|
|
|
signals:
|
|
void itemSelected(const QString &user);
|
|
|
|
private:
|
|
QString displayName(QString roomid, QString userid);
|
|
void hoverSelection();
|
|
void resetSelection() { selectedItem_ = -1; }
|
|
void selectFirstItem() { selectedItem_ = 0; }
|
|
void selectLastItem();
|
|
void removeLayoutItemsAfter(size_t startingPos);
|
|
|
|
QVBoxLayout *layout_;
|
|
|
|
//! Counter for tab completion (cycling).
|
|
int selectedItem_ = -1;
|
|
};
|