17#include <QtDesigner/abstractformeditor.h>
18#include <QtDesigner/abstractpropertyeditor.h>
19#include <QtDesigner/propertysheet.h>
20#include <QtDesigner/qextensionmanager.h>
21#include <QtDesigner/abstractmetadatabase.h>
22#include <QtDesigner/abstractsettings.h>
24#include <QtWidgets/qmenu.h>
25#include <QtWidgets/qtoolbar.h>
26#include <QtWidgets/qsplitter.h>
27#include <QtWidgets/qapplication.h>
28#if QT_CONFIG(clipboard)
29#include <QtGui/qclipboard.h>
31#include <QtWidgets/qitemdelegate.h>
32#include <QtWidgets/qboxlayout.h>
33#include <QtWidgets/qlineedit.h>
34#include <QtWidgets/qlabel.h>
35#include <QtWidgets/qpushbutton.h>
36#include <QtWidgets/qtoolbutton.h>
38#include <QtGui/qaction.h>
39#include <QtGui/qactiongroup.h>
40#include <QtGui/qevent.h>
41#include <QtGui/qpainter.h>
43#include <QtCore/qitemselectionmodel.h>
44#include <QtCore/qregularexpression.h>
45#include <QtCore/qdebug.h>
46#include <QtCore/qbuffer.h>
50using namespace Qt::StringLiterals;
70 void paint(
QPainter *painter,
const QStyleOptionViewItem &option,
const QModelIndex &index)
const override
72 if (option.state & QStyle::State_Selected)
73 painter->fillRect(option.rect, option.palette.highlight());
75 QItemDelegate::paint(painter, option, index);
92#if QT_CONFIG(clipboard)
126#if QT_CONFIG(clipboard)
153 "editdelete.png"_L1);
283#if QT_CONFIG(clipboard)
313#if QT_CONFIG(clipboard)
391 sheet->setChanged(sheet->indexOf(iconPropertyC), !action->icon().isNull());
426 const int index = sheet->indexOf(name);
427 Q_ASSERT(index != -1);
428 sheet->setProperty(index, value);
429 sheet->setChanged(index,
true);
468static QDesignerFormWindowCommand *
setIconPropertyCommand(
const PropertySheetIconValue &newIcon, QAction *action, QDesignerFormWindowInterface *fw)
470 const QString iconProperty = iconPropertyC;
471 if (newIcon.isEmpty()) {
472 ResetPropertyCommand *cmd =
new ResetPropertyCommand(fw);
473 cmd->init(action, iconProperty);
476 SetPropertyCommand *cmd =
new SetPropertyCommand(fw);
477 cmd->init(action, iconProperty, QVariant::fromValue(newIcon));
486 const QString shortcutProperty = shortcutPropertyC;
487 if (ks.value().isEmpty()) {
488 ResetPropertyCommand *cmd =
new ResetPropertyCommand(fw);
489 cmd->init(action, shortcutProperty);
492 SetPropertyCommand *cmd =
new SetPropertyCommand(fw);
493 cmd->init(action, shortcutProperty, QVariant::fromValue(ks));
502 QObject *o, QDesignerFormWindowInterface *fw)
504 if (value == defaultValue) {
505 ResetPropertyCommand *cmd =
new ResetPropertyCommand(fw);
509 SetPropertyCommand *cmd =
new SetPropertyCommand(fw);
510 cmd->init(o, name, QVariant(value));
517 const int index = sheet->indexOf(name);
518 Q_ASSERT(index != -1);
519 const PropertySheetStringValue ps = qvariant_cast<PropertySheetStringValue>(sheet->property(index));
625 :
tr(
"Remove actions");
635#if QT_CONFIG(clipboard)
675 static const QRegularExpression nonAsciiPattern(u"[^a-zA-Z_0-9]"_s);
676 Q_ASSERT(nonAsciiPattern.isValid());
677 text.replace(nonAsciiPattern,
"_"_L1);
678 static const QRegularExpression multipleSpacePattern(u"__*"_s);
679 Q_ASSERT(multipleSpacePattern.isValid());
680 text.replace(multipleSpacePattern,
"_"_L1);
681 if (text.endsWith(u'_'))
695 const ushort uc = c.unicode();
696 return (uc >=
'a' && uc <=
'z') || (uc >=
'A' && uc <=
'Z')
705 result.reserve(text.size());
706 bool lastCharAccepted =
false;
707 for (QChar c : text) {
708 const CharacterCategory cat = category(c);
709 if (cat != NonAsciiLetter) {
710 const bool acceptable = cat == DigitOrAsciiLetter;
712 result.append(lastCharAccepted ? c : c.toUpper());
713 lastCharAccepted = acceptable;
815#if QT_CONFIG(clipboard)
875#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)