diff options
author | Friedemann Kleint <Friedemann.Kleint@qt.io> | 2023-01-26 11:59:23 +0100 |
---|---|---|
committer | Friedemann Kleint <Friedemann.Kleint@qt.io> | 2023-01-26 14:40:28 +0100 |
commit | 0d48e8bd13db9ebafca13f0ba56c28bda5048afb (patch) | |
tree | 6579a5c7d090612b99486bcece2345051887a114 /src/designer/src/lib/shared | |
parent | 0d8837c4103f941297adc3c76cb0ae6f67b6e34b (diff) | |
download | qttools-0d48e8bd13db9ebafca13f0ba56c28bda5048afb.tar.gz |
Qt Designer: Remove some old-style connects
Pick-to: 6.5
Change-Id: I844e9f5217b6f14859aac7cba799d56938aa442f
Reviewed-by: Jarek Kobus <jaroslaw.kobus@qt.io>
Diffstat (limited to 'src/designer/src/lib/shared')
-rw-r--r-- | src/designer/src/lib/shared/qdesigner_taskmenu.cpp | 23 | ||||
-rw-r--r-- | src/designer/src/lib/shared/richtexteditor.cpp | 51 |
2 files changed, 36 insertions, 38 deletions
diff --git a/src/designer/src/lib/shared/qdesigner_taskmenu.cpp b/src/designer/src/lib/shared/qdesigner_taskmenu.cpp index 3fe3cd8c8..bcc97f25b 100644 --- a/src/designer/src/lib/shared/qdesigner_taskmenu.cpp +++ b/src/designer/src/lib/shared/qdesigner_taskmenu.cpp @@ -121,20 +121,22 @@ namespace qdesigner_internal { // Sub menu displaying the alignment options of a widget in a managed // grid/box layout cell. -class LayoutAlignmentMenu { +class LayoutAlignmentMenu : public QObject { + Q_OBJECT public: explicit LayoutAlignmentMenu(QObject *parent); QAction *subMenuAction() const { return m_subMenuAction; } - void connect(QObject *receiver, const char *aSlot); - // Set up enabled state and checked actions according to widget (managed box/grid) bool setAlignment(const QDesignerFormEditorInterface *core, QWidget *w); // Return the currently checked alignment Qt::Alignment alignment() const; +signals: + void changed(); + private: enum Actions { HorizNone, Left, HorizCenter, Right, VerticalNone, Top, VerticalCenter, Bottom }; static QAction *createAction(const QString &text, int data, QMenu *menu, QActionGroup *ag); @@ -155,13 +157,15 @@ QAction *LayoutAlignmentMenu::createAction(const QString &text, int data, QMenu return a; } -LayoutAlignmentMenu::LayoutAlignmentMenu(QObject *parent) : +LayoutAlignmentMenu::LayoutAlignmentMenu(QObject *parent) : QObject(parent), m_subMenuAction(new QAction(QDesignerTaskMenu::tr("Layout Alignment"), parent)), m_horizGroup(new QActionGroup(parent)), m_verticalGroup(new QActionGroup(parent)) { m_horizGroup->setExclusive(true); m_verticalGroup->setExclusive(true); + connect(m_horizGroup, &QActionGroup::triggered, this, &LayoutAlignmentMenu::changed); + connect(m_verticalGroup, &QActionGroup::triggered, this, &LayoutAlignmentMenu::changed); QMenu *menu = new QMenu; m_subMenuAction->setMenu(menu); @@ -177,12 +181,6 @@ LayoutAlignmentMenu::LayoutAlignmentMenu(QObject *parent) : m_actions[Bottom] = createAction(QDesignerTaskMenu::tr("Bottom"), Qt::AlignBottom, menu, m_verticalGroup); } -void LayoutAlignmentMenu::connect(QObject *receiver, const char *aSlot) -{ - QObject::connect(m_horizGroup, SIGNAL(triggered(QAction*)), receiver, aSlot); - QObject::connect(m_verticalGroup, SIGNAL(triggered(QAction*)), receiver, aSlot); -} - bool LayoutAlignmentMenu::setAlignment(const QDesignerFormEditorInterface *core, QWidget *w) { bool enabled; @@ -356,7 +354,8 @@ QDesignerTaskMenu::QDesignerTaskMenu(QWidget *widget, QObject *parent) : connect(d->m_containerFakeMethods, &QAction::triggered, this, &QDesignerTaskMenu::containerFakeMethods); connect(d->m_navigateToSlot, &QAction::triggered, this, &QDesignerTaskMenu::slotNavigateToSlot); connect(d->m_sizeActionGroup, &QActionGroup::triggered, this, &QDesignerTaskMenu::applySize); - d->m_layoutAlignmentMenu.connect(this, SLOT(slotLayoutAlignment())); + connect(&d->m_layoutAlignmentMenu, &LayoutAlignmentMenu::changed, + this, &QDesignerTaskMenu::slotLayoutAlignment); } QDesignerTaskMenu::~QDesignerTaskMenu() @@ -723,3 +722,5 @@ void QDesignerTaskMenu::slotLayoutAlignment() } // namespace qdesigner_internal QT_END_NAMESPACE + +#include "qdesigner_taskmenu.moc" diff --git a/src/designer/src/lib/shared/richtexteditor.cpp b/src/designer/src/lib/shared/richtexteditor.cpp index 5fbe04a77..dfd5dc1ba 100644 --- a/src/designer/src/lib/shared/richtexteditor.cpp +++ b/src/designer/src/lib/shared/richtexteditor.cpp @@ -40,6 +40,8 @@ QT_BEGIN_NAMESPACE +using namespace Qt::StringLiterals; + static const char RichTextDialogGroupC[] = "RichTextDialog"; static const char GeometryKeyC[] = "Geometry"; static const char TabKeyC[] = "Tab"; @@ -375,7 +377,6 @@ private: }; static QAction *createCheckableAction(const QIcon &icon, const QString &text, - QObject *receiver, const char *slot, QObject *parent = nullptr) { QAction *result = new QAction(parent); @@ -383,8 +384,6 @@ static QAction *createCheckableAction(const QIcon &icon, const QString &text, result->setText(text); result->setCheckable(true); result->setChecked(false); - if (slot) - QObject::connect(result, SIGNAL(triggered(bool)), receiver, slot); return result; } @@ -414,20 +413,20 @@ RichTextEditorToolBar::RichTextEditorToolBar(QDesignerFormEditorInterface *core, // Bold, italic and underline buttons m_bold_action = createCheckableAction( - createIconSet(QStringLiteral("textbold.png")), - tr("Bold"), editor, SLOT(setFontBold(bool)), this); + createIconSet(u"textbold.png"_s), tr("Bold"), this); + connect(m_bold_action, &QAction::triggered, editor, &RichTextEditor::setFontBold); m_bold_action->setShortcut(tr("CTRL+B")); addAction(m_bold_action); m_italic_action = createCheckableAction( - createIconSet(QStringLiteral("textitalic.png")), - tr("Italic"), editor, SLOT(setFontItalic(bool)), this); + createIconSet(u"textitalic.png"_s), tr("Italic"), this); + connect(m_italic_action, &QAction::triggered, editor, &RichTextEditor::setFontItalic); m_italic_action->setShortcut(tr("CTRL+I")); addAction(m_italic_action); m_underline_action = createCheckableAction( - createIconSet(QStringLiteral("textunder.png")), - tr("Underline"), editor, SLOT(setFontUnderline(bool)), this); + createIconSet(u"textunder.png"_s), tr("Underline"), this); + connect(m_underline_action, &QAction::triggered, editor, &RichTextEditor::setFontUnderline); m_underline_action->setShortcut(tr("CTRL+U")); addAction(m_underline_action); @@ -440,28 +439,25 @@ RichTextEditorToolBar::RichTextEditorToolBar(QDesignerFormEditorInterface *core, this, &RichTextEditorToolBar::alignmentActionTriggered); m_align_left_action = createCheckableAction( - createIconSet(QStringLiteral("textleft.png")), - tr("Left Align"), editor, nullptr, alignment_group); + createIconSet(u"textleft.png"_s), tr("Left Align"), alignment_group); addAction(m_align_left_action); m_align_center_action = createCheckableAction( - createIconSet(QStringLiteral("textcenter.png")), - tr("Center"), editor, nullptr, alignment_group); + createIconSet(u"textcenter.png"_s), tr("Center"), alignment_group); addAction(m_align_center_action); m_align_right_action = createCheckableAction( - createIconSet(QStringLiteral("textright.png")), - tr("Right Align"), editor, nullptr, alignment_group); + createIconSet(u"textright.png"_s), tr("Right Align"), alignment_group); addAction(m_align_right_action); m_align_justify_action = createCheckableAction( - createIconSet(QStringLiteral("textjustify.png")), - tr("Justify"), editor, nullptr, alignment_group); + createIconSet(u"textjustify.png"_s), tr("Justify"), alignment_group); addAction(m_align_justify_action); m_layoutDirectionAction = createCheckableAction( - createIconSet(QStringLiteral("righttoleft.png")), - tr("Right to Left"), this, SLOT(layoutDirectionChanged())); + createIconSet(u"righttoleft.png"_s), tr("Right to Left")); + connect(m_layoutDirectionAction, &QAction::triggered, + this, &RichTextEditorToolBar::layoutDirectionChanged); addAction(m_layoutDirectionAction); addSeparator(); @@ -469,15 +465,15 @@ RichTextEditorToolBar::RichTextEditorToolBar(QDesignerFormEditorInterface *core, // Superscript and subscript buttons m_valign_sup_action = createCheckableAction( - createIconSet(QStringLiteral("textsuperscript.png")), - tr("Superscript"), - this, SLOT(setVAlignSuper(bool)), this); + createIconSet(u"textsuperscript.png"_s), tr("Superscript"), this); + connect(m_valign_sup_action, &QAction::triggered, + this, &RichTextEditorToolBar::setVAlignSuper); addAction(m_valign_sup_action); m_valign_sub_action = createCheckableAction( - createIconSet(QStringLiteral("textsubscript.png")), - tr("Subscript"), - this, SLOT(setVAlignSub(bool)), this); + createIconSet(u"textsubscript.png"_s), tr("Subscript"), this); + connect(m_valign_sub_action, &QAction::triggered, + this, &RichTextEditorToolBar::setVAlignSub); addAction(m_valign_sub_action); addSeparator(); @@ -505,8 +501,9 @@ RichTextEditorToolBar::RichTextEditorToolBar(QDesignerFormEditorInterface *core, // Simplify rich text m_simplify_richtext_action - = createCheckableAction(createIconSet(QStringLiteral("simplifyrichtext.png")), - tr("Simplify Rich Text"), m_editor, SLOT(setSimplifyRichText(bool))); + = createCheckableAction(createIconSet(u"simplifyrichtext.png"_s), tr("Simplify Rich Text")); + connect(m_simplify_richtext_action, &QAction::triggered, + m_editor, &RichTextEditor::setSimplifyRichText); m_simplify_richtext_action->setChecked(m_editor->simplifyRichText()); connect(m_editor.data(), &RichTextEditor::simplifyRichTextChanged, m_simplify_richtext_action, &QAction::setChecked); |