18#include <QtDesigner/abstractformeditor.h>
19#include <QtDesigner/abstractpropertyeditor.h>
20#include <QtDesigner/propertysheet.h>
21#include <QtDesigner/qextensionmanager.h>
22#include <QtDesigner/abstractmetadatabase.h>
23#include <QtDesigner/abstractsettings.h>
25#include <QtWidgets/qmenu.h>
26#include <QtWidgets/qtoolbar.h>
27#include <QtWidgets/qsplitter.h>
28#include <QtWidgets/qapplication.h>
29#if QT_CONFIG(clipboard)
30#include <QtGui/qclipboard.h>
32#include <QtWidgets/qitemdelegate.h>
33#include <QtWidgets/qboxlayout.h>
34#include <QtWidgets/qlineedit.h>
35#include <QtWidgets/qlabel.h>
36#include <QtWidgets/qpushbutton.h>
37#include <QtWidgets/qtoolbutton.h>
39#include <QtGui/qaction.h>
40#include <QtGui/qactiongroup.h>
41#include <QtGui/qevent.h>
42#include <QtGui/qpainter.h>
44#include <QtCore/qitemselectionmodel.h>
45#include <QtCore/qregularexpression.h>
46#include <QtCore/qdebug.h>
47#include <QtCore/qbuffer.h>
51using namespace Qt::StringLiterals;
71 void paint(
QPainter *painter,
const QStyleOptionViewItem &option,
const QModelIndex &index)
const override
73 if (option.state & QStyle::State_Selected)
74 painter->fillRect(option.rect, option.palette.highlight());
76 QItemDelegate::paint(painter, option, index);
93#if QT_CONFIG(clipboard)
127#if QT_CONFIG(clipboard)
154 "editdelete.png"_L1);
285#if QT_CONFIG(clipboard)
315#if QT_CONFIG(clipboard)
393 sheet->setChanged(sheet->indexOf(iconPropertyC), !action->icon().isNull());
428 const int index = sheet->indexOf(name);
429 Q_ASSERT(index != -1);
430 sheet->setProperty(index, value);
431 sheet->setChanged(index,
true);
470static QDesignerFormWindowCommand *
setIconPropertyCommand(
const PropertySheetIconValue &newIcon, QAction *action, QDesignerFormWindowInterface *fw)
472 const QString iconProperty = iconPropertyC;
473 if (newIcon.isEmpty()) {
474 ResetPropertyCommand *cmd =
new ResetPropertyCommand(fw);
475 cmd->init(action, iconProperty);
478 SetPropertyCommand *cmd =
new SetPropertyCommand(fw);
479 cmd->init(action, iconProperty, QVariant::fromValue(newIcon));
488 const QString shortcutProperty = shortcutPropertyC;
489 if (ks.value().isEmpty()) {
490 ResetPropertyCommand *cmd =
new ResetPropertyCommand(fw);
491 cmd->init(action, shortcutProperty);
494 SetPropertyCommand *cmd =
new SetPropertyCommand(fw);
495 cmd->init(action, shortcutProperty, QVariant::fromValue(ks));
504 QObject *o, QDesignerFormWindowInterface *fw)
506 if (value == defaultValue) {
507 ResetPropertyCommand *cmd =
new ResetPropertyCommand(fw);
511 SetPropertyCommand *cmd =
new SetPropertyCommand(fw);
512 cmd->init(o, name, QVariant(value));
519 const int index = sheet->indexOf(name);
520 Q_ASSERT(index != -1);
627 :
tr(
"Remove actions");
637#if QT_CONFIG(clipboard)
677 static const QRegularExpression nonAsciiPattern(u"[^a-zA-Z_0-9]"_s);
678 Q_ASSERT(nonAsciiPattern.isValid());
679 text.replace(nonAsciiPattern,
"_"_L1);
680 static const QRegularExpression multipleSpacePattern(u"__*"_s);
681 Q_ASSERT(multipleSpacePattern.isValid());
682 text.replace(multipleSpacePattern,
"_"_L1);
683 if (text.endsWith(u'_'))
697 const ushort uc = c.unicode();
698 return (uc >=
'a' && uc <=
'z') || (uc >=
'A' && uc <=
'Z')
707 result.reserve(text.size());
708 bool lastCharAccepted =
false;
709 for (QChar c : text) {
710 const CharacterCategory cat = category(c);
711 if (cat != NonAsciiLetter) {
712 const bool acceptable = cat == DigitOrAsciiLetter;
714 result.append(lastCharAccepted ? c : c.toUpper());
715 lastCharAccepted = acceptable;
817#if QT_CONFIG(clipboard)
877#if QT_CONFIG(clipboard)
static constexpr auto toolTipPropertyC
static constexpr auto iconPropertyC
static constexpr auto textPropertyC
static constexpr auto shortcutPropertyC
static constexpr auto menuRolePropertyC
static constexpr auto actionEditorViewModeKey
static constexpr auto objectNamePropertyC
static constexpr auto checkablePropertyC
void drawFocus(QPainter *, const QStyleOptionViewItem &, const QRect &) const override
Renders the region within the rectangle specified by rect, indicating that it has the focus,...
void paint(QPainter *painter, const QStyleOptionViewItem &option, const QModelIndex &index) const override
This pure abstract function must be reimplemented if you want to provide custom rendering.
ActionGroupDelegate(QObject *parent)
Combined button and popup list for selecting options.
Auxiliary methods to store/retrieve settings.
static QDesignerFormWindowCommand * setKeySequencePropertyCommand(const PropertySheetKeySequenceValue &ks, QAction *action, QDesignerFormWindowInterface *fw)
static CharacterCategory category(QChar c)
static QDesignerFormWindowCommand * setIconPropertyCommand(const PropertySheetIconValue &newIcon, QAction *action, QDesignerFormWindowInterface *fw)
static void setInitialProperty(QDesignerPropertySheetExtension *sheet, const QString &name, const QVariant &value)
static void refreshIconPropertyChanged(const QAction *action, QDesignerPropertySheetExtension *sheet)
static QString underscore(QString text)
static QString textPropertyValue(const QDesignerPropertySheetExtension *sheet, const QString &name)
static QString camelCase(const QString &text)
QDesignerFormWindowCommand * setPropertyCommand(const QString &name, T value, T defaultValue, QObject *o, QDesignerFormWindowInterface *fw)