aboutsummaryrefslogtreecommitdiffstats
path: root/src/plugins/extensionmanager/extensionsbrowser.h
blob: ff3dacac7b89e24a45d24d243f3fef5e4f078bf3 (plain)
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
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
// Copyright (C) 2023 The Qt Company Ltd.
// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR GPL-3.0-only WITH Qt-GPL-exception-1.0

#pragma once

#include <QWidget>

QT_FORWARD_DECLARE_CLASS(QLabel)

namespace Core::WelcomePageHelpers {
class TextFormat;
}

namespace ExtensionManager::Internal {

class ExtensionsModel;

class ExtensionsBrowser final : public QWidget
{
    Q_OBJECT

public:
    ExtensionsBrowser(ExtensionsModel *model, QWidget *parent = nullptr);
    ~ExtensionsBrowser();

    void setFilter(const QString &filter);

    void adjustToWidth(const int width);
    QSize sizeHint() const override;

    int extraListViewWidth() const; // Space for scrollbar, etc.

    void showEvent(QShowEvent *event) override;

    QModelIndex currentIndex() const;
    void selectIndex(const QModelIndex &index);

signals:
    void itemSelected(const QModelIndex &current, const QModelIndex &previous);

private:
    void fetchExtensions();

    class ExtensionsBrowserPrivate *d = nullptr;
};

constexpr static QSize iconBgSizeSmall{50, 50};
constexpr static QSize iconBgSizeBig{68, 68};
enum Size {
    SizeSmall,
    SizeBig,
};
QPixmap itemIcon(const QModelIndex &index, Size size);
QPixmap itemBadge(const QModelIndex &index, Size size);

} // ExtensionManager::Internal