summaryrefslogtreecommitdiffstats
path: root/src/designer/src/components/propertyeditor/pixmapeditor.h
blob: fd161c3df2ddf6bd2499cb94e9e61ebf00fcc77d (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
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
// Copyright (C) 2024 The Qt Company Ltd.
// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR GPL-3.0-only WITH Qt-GPL-exception-1.0

#ifndef PIXMAPEDITOR_H
#define PIXMAPEDITOR_H

#include <QtWidgets/qdialog.h>

#include <QtGui/qpixmap.h>

QT_BEGIN_NAMESPACE

class QLabel;
class QHBoxLayout;
class QToolButton;

class QDesignerFormEditorInterface;

namespace qdesigner_internal {

class DesignerPixmapCache;
class IconThemeEditor;

class IconThemeDialog : public QDialog
{
    Q_OBJECT
public:
    static QString getTheme(QWidget *parent, const QString &theme, bool *ok);
private:
    explicit IconThemeDialog(QWidget *parent);
    IconThemeEditor *m_editor;
};

class PixmapEditor : public QWidget
{
    Q_OBJECT
public:
    explicit PixmapEditor(QDesignerFormEditorInterface *core, QWidget *parent);

    void setSpacing(int spacing);
    void setPixmapCache(DesignerPixmapCache *cache);
    void setIconThemeModeEnabled(bool enabled);
public slots:
    void setPath(const QString &path);
    void setTheme(const QString &theme);
    void setDefaultPixmap(const QPixmap &pixmap);
    void setDefaultPixmapIcon(const QIcon &icon);

signals:
    void pathChanged(const QString &path);
    void themeChanged(const QString &theme);

protected:
    void contextMenuEvent(QContextMenuEvent *event) override;

private slots:
    void defaultActionActivated();
    void resourceActionActivated();
    void fileActionActivated();
    void themeActionActivated();
#if QT_CONFIG(clipboard)
    void copyActionActivated();
    void pasteActionActivated();
    void clipboardDataChanged();
#endif
private:
    void updateLabels();
    bool m_iconThemeModeEnabled;
    QDesignerFormEditorInterface *m_core;
    QLabel *m_pixmapLabel;
    QLabel *m_pathLabel;
    QToolButton *m_button;
    QAction *m_resourceAction;
    QAction *m_fileAction;
    QAction *m_themeAction;
    QAction *m_copyAction;
    QAction *m_pasteAction;
    QHBoxLayout *m_layout;
    QPixmap m_defaultPixmap;
    QString m_path;
    QString m_theme;
    DesignerPixmapCache *m_pixmapCache;
};

} // namespace qdesigner_internal

QT_END_NAMESPACE

#endif // PIXMAPEDITOR_H