qtpropertybrowserutils_p.h
Go to the documentation of this file.
1/****************************************************************************
2**
3** Copyright (C) 2013 Digia Plc and/or its subsidiary(-ies).
4** Contact: http://www.qt-project.org/legal
5**
6** This file is part of the Qt Solutions component.
7**
8** $QT_BEGIN_LICENSE:BSD$
9** You may use this file under the terms of the BSD license as follows:
10**
11** "Redistribution and use in source and binary forms, with or without
12** modification, are permitted provided that the following conditions are
13** met:
14** * Redistributions of source code must retain the above copyright
15** notice, this list of conditions and the following disclaimer.
16** * Redistributions in binary form must reproduce the above copyright
17** notice, this list of conditions and the following disclaimer in
18** the documentation and/or other materials provided with the
19** distribution.
20** * Neither the name of Digia Plc and its Subsidiary(-ies) nor the names
21** of its contributors may be used to endorse or promote products derived
22** from this software without specific prior written permission.
23**
24**
25** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
26** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
27** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
28** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
29** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
30** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
31** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
32** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
33** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
34** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
35** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE."
36**
37** $QT_END_LICENSE$
38**
39****************************************************************************/
40
41
42//
43// W A R N I N G
44// -------------
45//
46// This file is not part of the Qt API. It exists for the convenience
47// of Qt Designer. This header
48// file may change from version to version without notice, or even be removed.
49//
50// We mean it.
51//
52
53#pragma once
54
55#include <QIcon>
56#include <QMap>
57#include <QStringList>
58#include <QWidget>
59
60QT_BEGIN_NAMESPACE
61
62class QMouseEvent;
63class QCheckBox;
64class QLineEdit;
65
67{
68public:
70 void clear();
71
72 QStringList cursorShapeNames() const;
73 QMap<int, QIcon> cursorShapeIcons() const;
74 QString cursorToShapeName(const QCursor& cursor) const;
75 QIcon cursorToShapeIcon(const QCursor& cursor) const;
76 int cursorToValue(const QCursor& cursor) const;
77#ifndef QT_NO_CURSOR
78 QCursor valueToCursor(int value) const;
79#endif
80private:
81 void appendCursor(Qt::CursorShape shape, const QString& name, const QIcon& icon);
82 QStringList m_cursorNames;
83 QMap<int, QIcon> m_cursorIcons;
84 QMap<int, Qt::CursorShape> m_valueToCursorShape;
85 QMap<Qt::CursorShape, int> m_cursorShapeToValue;
86};
87
89{
90public:
91 static QPixmap brushValuePixmap(const QBrush& b);
92 static QIcon brushValueIcon(const QBrush& b);
93 static QString colorValueText(const QColor& c);
94 static QPixmap fontValuePixmap(const QFont& f);
95 static QIcon fontValueIcon(const QFont& f);
96 static QString fontValueText(const QFont& f);
97};
98
99class QtBoolEdit : public QWidget
100{
101 Q_OBJECT
102public:
103 QtBoolEdit(QWidget* parent = 0);
104
105 bool
107 {
108 return m_textVisible;
109 }
110
111 void setTextVisible(bool textVisible);
112
113 Qt::CheckState checkState() const;
114 void setCheckState(Qt::CheckState state);
115
116 bool isChecked() const;
117 void setChecked(bool c);
118
119 bool blockCheckBoxSignals(bool block);
120
121Q_SIGNALS:
122 void toggled(bool);
123
124protected:
125 void mousePressEvent(QMouseEvent* event) override;
126 void paintEvent(QPaintEvent*) override;
127
128private:
129 QCheckBox* m_checkBox;
130 bool m_textVisible;
131};
132
133class QtKeySequenceEdit : public QWidget
134{
135 Q_OBJECT
136public:
137 QtKeySequenceEdit(QWidget* parent = 0);
138
139 QKeySequence keySequence() const;
140 bool eventFilter(QObject* o, QEvent* e) override;
141public Q_SLOTS:
142 void setKeySequence(const QKeySequence& sequence);
143Q_SIGNALS:
144 void keySequenceChanged(const QKeySequence& sequence);
145
146protected:
147 void focusInEvent(QFocusEvent* e) override;
148 void focusOutEvent(QFocusEvent* e) override;
149 void keyPressEvent(QKeyEvent* e) override;
150 void keyReleaseEvent(QKeyEvent* e) override;
151 void paintEvent(QPaintEvent*) override;
152 bool event(QEvent* e) override;
153private slots:
154 void slotClearShortcut();
155
156private:
157 void handleKeyEvent(QKeyEvent* e);
158 int translateModifiers(Qt::KeyboardModifiers state, const QString& text) const;
159
160 int m_num;
161 QKeySequence m_keySequence;
162 QLineEdit* m_lineEdit;
163};
164
165QT_END_NAMESPACE
constexpr T c
void setTextVisible(bool textVisible)
void paintEvent(QPaintEvent *) override
void toggled(bool)
void setCheckState(Qt::CheckState state)
bool blockCheckBoxSignals(bool block)
void mousePressEvent(QMouseEvent *event) override
Qt::CheckState checkState() const
QtBoolEdit(QWidget *parent=0)
QCursor valueToCursor(int value) const
QStringList cursorShapeNames() const
QMap< int, QIcon > cursorShapeIcons() const
QIcon cursorToShapeIcon(const QCursor &cursor) const
QString cursorToShapeName(const QCursor &cursor) const
int cursorToValue(const QCursor &cursor) const
void paintEvent(QPaintEvent *) override
void focusInEvent(QFocusEvent *e) override
bool eventFilter(QObject *o, QEvent *e) override
void setKeySequence(const QKeySequence &sequence)
void keyReleaseEvent(QKeyEvent *e) override
void keyPressEvent(QKeyEvent *e) override
void focusOutEvent(QFocusEvent *e) override
bool event(QEvent *e) override
QKeySequence keySequence() const
QtKeySequenceEdit(QWidget *parent=0)
void keySequenceChanged(const QKeySequence &sequence)
static QString fontValueText(const QFont &f)
static QPixmap brushValuePixmap(const QBrush &b)
static QIcon fontValueIcon(const QFont &f)
static QIcon brushValueIcon(const QBrush &b)
static QString colorValueText(const QColor &c)
static QPixmap fontValuePixmap(const QFont &f)