-
Notifications
You must be signed in to change notification settings - Fork 2
/
Copy pathcmdlistwidget.h
41 lines (33 loc) · 1.01 KB
/
cmdlistwidget.h
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
#ifndef CMDLISTWIDGET_H
#define CMDLISTWIDGET_H
#include <QWidget>
#include <QListWidget>
#include <QList>
#include "Utils/systemapi.h"
class CMDListWidget : public QListWidget
{
Q_OBJECT
public:
using IconStrList = QList<QPair<QString, QString>>; // iconPath, text
CMDListWidget(QWidget* parent = nullptr);
void addIconItems(const IconStrList& list);
void adjustSizeEx(void);
void selectNext(void);
void selectPre(void);
QString selectedText(void);
private:
const int Item_H = DPI(25);
IconStrList listCache;
signals:
void itemActivedEx(QListWidgetItem* item); //双击或回车
void iconReady(QListWidgetItem* item, int index, QIcon icon); //icon加载完成
// QWidget interface
protected:
void keyPressEvent(QKeyEvent* event) override;
void wheelEvent(QWheelEvent* event) override;
// QWidget interface
protected:
void hideEvent(QHideEvent* event) override;
};
bool operator==(const QIcon& lhs, const QIcon& rhs); //定义运算符
#endif // CMDLISTWIDGET_H