kdeui: KAction constructors optimization

Signed-off-by: Ivailo Monev <xakepa10@gmail.com>
This commit is contained in:
Ivailo Monev 2023-08-27 19:17:10 +03:00
parent 558295b483
commit 3fcfdb2687
3 changed files with 16 additions and 23 deletions

View file

@ -41,11 +41,12 @@
// KActionPrivate
//---------------------------------------------------------------------
void KActionPrivate::init(KAction *q_ptr)
KActionPrivate::KActionPrivate(KAction *q_ptr)
: componentData(KGlobal::mainComponent()),
globalShortcutEnabled(false),
neverSetGlobalShortcut(true),
q(q_ptr)
{
q = q_ptr;
globalShortcutEnabled = false;
neverSetGlobalShortcut = true;
QObject::connect(q, SIGNAL(triggered(bool)), q, SLOT(slotTriggered()));
q->setProperty("isShortcutConfigurable", true);
}
@ -87,24 +88,21 @@ bool KAction::event(QEvent *event)
//---------------------------------------------------------------------
KAction::KAction(QObject *parent)
: QWidgetAction(parent),
d(new KActionPrivate())
d(new KActionPrivate(this))
{
d->init(this);
}
KAction::KAction(const QString &text, QObject *parent)
: QWidgetAction(parent),
d(new KActionPrivate())
d(new KActionPrivate(this))
{
d->init(this);
setText(text);
}
KAction::KAction(const KIcon &icon, const QString &text, QObject *parent)
: QWidgetAction(parent),
d(new KActionPrivate)
d(new KActionPrivate(this))
{
d->init(this);
setIcon(icon);
setText(text);
}

View file

@ -253,7 +253,7 @@ public:
* @param text The visible text for this action.
* @param parent The parent for this action.
*/
KAction(const QString& text, QObject *parent);
KAction(const QString &text, QObject *parent);
/**
* Constructs an action with text and icon; a shortcut may be specified by
@ -266,7 +266,7 @@ public:
* @param text The text that will be displayed.
* @param parent The parent for this action.
*/
KAction(const KIcon &icon, const QString& text, QObject *parent);
KAction(const KIcon &icon, const QString &text, QObject *parent);
/**
* Standard destructor

View file

@ -28,16 +28,10 @@ class KAction;
class KActionPrivate
{
public:
KActionPrivate()
: componentData(KGlobal::mainComponent()),
globalShortcutEnabled(false),
q(nullptr)
{
}
KActionPrivate(KAction *q_ptr);
void slotTriggered();
void init(KAction *q_ptr);
void setActiveGlobalShortcutNoEnable(const KShortcut &cut);
void maybeSetComponentData(const KComponentData &kcd)
@ -47,11 +41,12 @@ public:
}
}
KComponentData componentData; //this is **way** more lightweight than it looks
KShortcut globalShortcut, defaultGlobalShortcut;
KComponentData componentData; // this is **way** more lightweight than it looks
KShortcut globalShortcut;
KShortcut defaultGlobalShortcut;
bool globalShortcutEnabled : 1;
bool neverSetGlobalShortcut : 1;
bool globalShortcutEnabled;
bool neverSetGlobalShortcut;
KAction *q;
};