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 <QMap>
56 #include <QIcon>
57 #include <QWidget>
58 #include <QStringList>
59 
60 QT_BEGIN_NAMESPACE
61 
62 class QMouseEvent;
63 class QCheckBox;
64 class QLineEdit;
65 
67 {
68 public:
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
80 private:
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 {
90 public:
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 
99 class QtBoolEdit : public QWidget
100 {
101  Q_OBJECT
102 public:
103  QtBoolEdit(QWidget* parent = 0);
104 
105  bool textVisible() const
106  {
107  return m_textVisible;
108  }
109  void setTextVisible(bool textVisible);
110 
111  Qt::CheckState checkState() const;
112  void setCheckState(Qt::CheckState state);
113 
114  bool isChecked() const;
115  void setChecked(bool c);
116 
117  bool blockCheckBoxSignals(bool block);
118 
119 Q_SIGNALS:
120  void toggled(bool);
121 
122 protected:
123  void mousePressEvent(QMouseEvent* event) override;
124  void paintEvent(QPaintEvent*) override;
125 
126 private:
127  QCheckBox* m_checkBox;
128  bool m_textVisible;
129 };
130 
131 class QtKeySequenceEdit : public QWidget
132 {
133  Q_OBJECT
134 public:
135  QtKeySequenceEdit(QWidget* parent = 0);
136 
137  QKeySequence keySequence() const;
138  bool eventFilter(QObject* o, QEvent* e) override;
139 public Q_SLOTS:
140  void setKeySequence(const QKeySequence& sequence);
141 Q_SIGNALS:
142  void keySequenceChanged(const QKeySequence& sequence);
143 protected:
144  void focusInEvent(QFocusEvent* e) override;
145  void focusOutEvent(QFocusEvent* e) override;
146  void keyPressEvent(QKeyEvent* e) override;
147  void keyReleaseEvent(QKeyEvent* e) override;
148  void paintEvent(QPaintEvent*) override;
149  bool event(QEvent* e) override;
150 private slots:
151  void slotClearShortcut();
152 private:
153  void handleKeyEvent(QKeyEvent* e);
154  int translateModifiers(Qt::KeyboardModifiers state, const QString& text) const;
155 
156  int m_num;
157  QKeySequence m_keySequence;
158  QLineEdit* m_lineEdit;
159 };
160 
161 QT_END_NAMESPACE
QtBoolEdit
Definition: qtpropertybrowserutils_p.h:99
QtPropertyBrowserUtils
Definition: qtpropertybrowserutils_p.h:88
QtKeySequenceEdit::keySequence
QKeySequence keySequence() const
Definition: qtpropertybrowserutils.cpp:470
QtPropertyBrowserUtils::brushValuePixmap
static QPixmap brushValuePixmap(const QBrush &b)
Definition: qtpropertybrowserutils.cpp:172
QtKeySequenceEdit::event
bool event(QEvent *e) override
Definition: qtpropertybrowserutils.cpp:535
QtCursorDatabase::valueToCursor
QCursor valueToCursor(int value) const
Definition: qtpropertybrowserutils.cpp:161
QtPropertyBrowserUtils::colorValueText
static QString colorValueText(const QColor &c)
Definition: qtpropertybrowserutils.cpp:200
QtBoolEdit::QtBoolEdit
QtBoolEdit(QWidget *parent=0)
Definition: qtpropertybrowserutils.cpp:234
QtBoolEdit::blockCheckBoxSignals
bool blockCheckBoxSignals(bool block)
Definition: qtpropertybrowserutils.cpp:303
QtKeySequenceEdit
Definition: qtpropertybrowserutils_p.h:131
QtCursorDatabase::QtCursorDatabase
QtCursorDatabase()
Definition: qtpropertybrowserutils.cpp:54
c
constexpr T c
Definition: UnscentedKalmanFilterTest.cpp:43
QtKeySequenceEdit::keyPressEvent
void keyPressEvent(QKeyEvent *e) override
Definition: qtpropertybrowserutils.cpp:516
QtCursorDatabase::cursorShapeNames
QStringList cursorShapeNames() const
Definition: qtpropertybrowserutils.cpp:118
QtKeySequenceEdit::setKeySequence
void setKeySequence(const QKeySequence &sequence)
Definition: qtpropertybrowserutils.cpp:458
QtPropertyBrowserUtils::fontValuePixmap
static QPixmap fontValuePixmap(const QFont &f)
Definition: qtpropertybrowserutils.cpp:206
QtCursorDatabase
Definition: qtpropertybrowserutils_p.h:66
QtKeySequenceEdit::eventFilter
bool eventFilter(QObject *o, QEvent *e) override
Definition: qtpropertybrowserutils.cpp:344
cxxopts::value
std::shared_ptr< Value > value()
Definition: cxxopts.hpp:926
QtKeySequenceEdit::QtKeySequenceEdit
QtKeySequenceEdit(QWidget *parent=0)
Definition: qtpropertybrowserutils.cpp:331
QtBoolEdit::setChecked
void setChecked(bool c)
Definition: qtpropertybrowserutils.cpp:291
QtKeySequenceEdit::focusInEvent
void focusInEvent(QFocusEvent *e) override
Definition: qtpropertybrowserutils.cpp:502
QtBoolEdit::paintEvent
void paintEvent(QPaintEvent *) override
Definition: qtpropertybrowserutils.cpp:321
QtCursorDatabase::cursorToValue
int cursorToValue(const QCursor &cursor) const
Definition: qtpropertybrowserutils.cpp:146
QtBoolEdit::setTextVisible
void setTextVisible(bool textVisible)
Definition: qtpropertybrowserutils.cpp:257
QtPropertyBrowserUtils::brushValueIcon
static QIcon brushValueIcon(const QBrush &b)
Definition: qtpropertybrowserutils.cpp:195
QtCursorDatabase::cursorToShapeName
QString cursorToShapeName(const QCursor &cursor) const
Definition: qtpropertybrowserutils.cpp:128
QtPropertyBrowserUtils::fontValueText
static QString fontValueText(const QFont &f)
Definition: qtpropertybrowserutils.cpp:227
QtBoolEdit::checkState
Qt::CheckState checkState() const
Definition: qtpropertybrowserutils.cpp:276
QtBoolEdit::isChecked
bool isChecked() const
Definition: qtpropertybrowserutils.cpp:286
QtBoolEdit::textVisible
bool textVisible() const
Definition: qtpropertybrowserutils_p.h:105
QtCursorDatabase::clear
void clear()
Definition: qtpropertybrowserutils.cpp:96
QtPropertyBrowserUtils::fontValueIcon
static QIcon fontValueIcon(const QFont &f)
Definition: qtpropertybrowserutils.cpp:222
QtBoolEdit::toggled
void toggled(bool)
QtBoolEdit::mousePressEvent
void mousePressEvent(QMouseEvent *event) override
Definition: qtpropertybrowserutils.cpp:308
QtCursorDatabase::cursorShapeIcons
QMap< int, QIcon > cursorShapeIcons() const
Definition: qtpropertybrowserutils.cpp:123
QtKeySequenceEdit::paintEvent
void paintEvent(QPaintEvent *) override
Definition: qtpropertybrowserutils.cpp:527
QtKeySequenceEdit::focusOutEvent
void focusOutEvent(QFocusEvent *e) override
Definition: qtpropertybrowserutils.cpp:509
QtCursorDatabase::cursorToShapeIcon
QIcon cursorToShapeIcon(const QCursor &cursor) const
Definition: qtpropertybrowserutils.cpp:140
QtKeySequenceEdit::keyReleaseEvent
void keyReleaseEvent(QKeyEvent *e) override
Definition: qtpropertybrowserutils.cpp:522
QtBoolEdit::setCheckState
void setCheckState(Qt::CheckState state)
Definition: qtpropertybrowserutils.cpp:281
QtKeySequenceEdit::keySequenceChanged
void keySequenceChanged(const QKeySequence &sequence)