kdeui: format and indent

Signed-off-by: Ivailo Monev <xakepa10@gmail.com>
This commit is contained in:
Ivailo Monev 2023-06-29 18:20:49 +03:00
parent b600997970
commit 45658d0d7c
6 changed files with 250 additions and 281 deletions

View file

@ -29,16 +29,14 @@
#include "kglobalaccel_p.h"
#include "klocale.h"
#include "kmessagebox.h"
#include "kdebug.h"
#include "kicon.h"
#include <QtGui/QApplication>
#include <QtGui/QHBoxLayout>
#include <QtGui/qevent.h>
#include <QtGui/QToolBar>
#include <kdebug.h>
#include "kicon.h"
//---------------------------------------------------------------------
// KActionPrivate
//---------------------------------------------------------------------
@ -48,9 +46,7 @@ void KActionPrivate::init(KAction *q_ptr)
q = q_ptr;
globalShortcutEnabled = false;
neverSetGlobalShortcut = true;
QObject::connect(q, SIGNAL(triggered(bool)), q, SLOT(slotTriggered()));
q->setProperty("isShortcutConfigurable", true);
}
@ -73,15 +69,16 @@ bool KAction::event(QEvent *event)
if(se->isAmbiguous()) {
KMessageBox::information(
NULL, // No widget to be seen around here
i18n( "The key sequence '%1' is ambiguous. Use 'Configure Shortcuts'\n"
i18n(
"The key sequence '%1' is ambiguous. Use 'Configure Shortcuts'\n"
"from the 'Settings' menu to solve the ambiguity.\n"
"No action will be triggered.",
se->key().toString(QKeySequence::NativeText)),
i18n("Ambiguous shortcut detected"));
"No action will be triggered.", se->key().toString(QKeySequence::NativeText)
),
i18n("Ambiguous shortcut detected")
);
return true;
}
}
return QAction::event(event);
}
@ -89,22 +86,24 @@ bool KAction::event(QEvent *event)
//---------------------------------------------------------------------
// KAction
//---------------------------------------------------------------------
KAction::KAction(QObject *parent)
: QWidgetAction(parent), d(new KActionPrivate)
: QWidgetAction(parent),
d(new KActionPrivate())
{
d->init(this);
}
KAction::KAction(const QString &text, QObject *parent)
: QWidgetAction(parent), d(new KActionPrivate)
: QWidgetAction(parent),
d(new KActionPrivate())
{
d->init(this);
setText(text);
}
KAction::KAction(const KIcon &icon, const QString &text, QObject *parent)
: QWidgetAction(parent), d(new KActionPrivate)
: QWidgetAction(parent),
d(new KActionPrivate)
{
d->init(this);
setIcon(icon);
@ -118,7 +117,6 @@ KAction::~KAction()
d->globalShortcutEnabled = false;
KGlobalAccel::self()->d->remove(this, KGlobalAccelPrivate::SetInactive);
}
delete d;
}
@ -135,13 +133,11 @@ void KAction::setShortcutConfigurable( bool b )
KShortcut KAction::shortcut(ShortcutTypes type) const
{
Q_ASSERT(type);
if (type == DefaultShortcut) {
QKeySequence primary = property("defaultPrimaryShortcut").value<QKeySequence>();
QKeySequence secondary = property("defaultAlternateShortcut").value<QKeySequence>();
return KShortcut(primary, secondary);
}
QKeySequence primary = shortcuts().value(0);
QKeySequence secondary = shortcuts().value(1);
return KShortcut(primary, secondary);
@ -150,12 +146,10 @@ KShortcut KAction::shortcut(ShortcutTypes type) const
void KAction::setShortcut(const KShortcut &shortcut, ShortcutTypes type)
{
Q_ASSERT(type);
if (type & DefaultShortcut) {
if (type & KAction::DefaultShortcut) {
setProperty("defaultPrimaryShortcut", shortcut.primary());
setProperty("defaultAlternateShortcut", shortcut.alternate());
}
if (type & ActiveShortcut) {
QAction::setShortcuts(shortcut);
}
@ -164,11 +158,10 @@ void KAction::setShortcut( const KShortcut & shortcut, ShortcutTypes type )
void KAction::setShortcut(const QKeySequence &keySeq, ShortcutTypes type)
{
Q_ASSERT(type);
if (type & DefaultShortcut)
if (type & KAction::DefaultShortcut) {
setProperty("defaultPrimaryShortcut", keySeq);
if (type & ActiveShortcut) {
}
if (type & KAction::ActiveShortcut) {
QAction::setShortcut(keySeq);
}
}
@ -181,10 +174,9 @@ void KAction::setShortcuts(const QList<QKeySequence>& shortcuts, ShortcutTypes t
const KShortcut& KAction::globalShortcut(ShortcutTypes type) const
{
Q_ASSERT(type);
if (type == DefaultShortcut)
if (type == KAction::DefaultShortcut) {
return d->defaultGlobalShortcut;
}
return d->globalShortcut;
}
@ -219,12 +211,12 @@ void KAction::setGlobalShortcut( const KShortcut & shortcut, ShortcutTypes type,
KGlobalAccel::self()->d->doRegister(this);
}
if ((type & DefaultShortcut) && d->defaultGlobalShortcut != shortcut) {
if ((type & KAction::DefaultShortcut) && d->defaultGlobalShortcut != shortcut) {
d->defaultGlobalShortcut = shortcut;
changed = true;
}
if ((type & ActiveShortcut) && d->globalShortcut != shortcut) {
if ((type & KAction::ActiveShortcut) && d->globalShortcut != shortcut) {
d->globalShortcut = shortcut;
changed = true;
}
@ -260,11 +252,9 @@ void KAction::setHelpText(const QString& text)
{
setStatusTip(text);
setToolTip(text);
if (whatsThis().isEmpty())
if (whatsThis().isEmpty()) {
setWhatsThis(text);
}
/* vim: et sw=2 ts=2
*/
}
#include "moc_kaction.cpp"

View file

@ -437,7 +437,7 @@ public:
/**
* @reimp
*/
bool event(QEvent*);
bool event(QEvent *event);
Q_SIGNALS:

View file

@ -29,7 +29,9 @@ class KActionPrivate
{
public:
KActionPrivate()
: componentData(KGlobal::mainComponent()), globalShortcutEnabled(false), q(0)
: componentData(KGlobal::mainComponent()),
globalShortcutEnabled(false),
q(nullptr)
{
}

View file

@ -22,10 +22,8 @@
#include "kaction.h"
struct KActionCategoryPrivate
{
KActionCategoryPrivate(KActionCategory *host);
//! Our host
@ -41,8 +39,8 @@ struct KActionCategoryPrivate
KActionCategory::KActionCategory(const QString &text, KActionCollection *parent)
: QObject(parent)
,d( new KActionCategoryPrivate(this) )
: QObject(parent),
d(new KActionCategoryPrivate(this))
{
d->text = text;
}
@ -53,13 +51,11 @@ KActionCategory::~KActionCategory()
delete d;
}
const QList<QAction*> KActionCategory::actions() const
{
return d->actions;
}
QAction* KActionCategory::addAction(const QString &name, QAction *action)
{
collection()->addAction(name, action);
@ -67,7 +63,6 @@ QAction * KActionCategory::addAction(const QString &name, QAction *action)
return action;
}
KAction* KActionCategory::addAction(const QString &name, KAction *action)
{
collection()->addAction(name, action);
@ -75,9 +70,7 @@ KAction * KActionCategory::addAction(const QString &name, KAction *action)
return action;
}
KAction * KActionCategory::addAction(
KStandardAction::StandardAction actionType,
KAction* KActionCategory::addAction(KStandardAction::StandardAction actionType,
const QObject *receiver,
const char *member)
{
@ -86,9 +79,7 @@ KAction * KActionCategory::addAction(
return action;
}
KAction * KActionCategory::addAction(
KStandardAction::StandardAction actionType,
KAction* KActionCategory::addAction(KStandardAction::StandardAction actionType,
const QString &name,
const QObject *receiver,
const char *member)
@ -98,9 +89,7 @@ KAction * KActionCategory::addAction(
return action;
}
KAction *KActionCategory::addAction(
const QString &name,
KAction *KActionCategory::addAction(const QString &name,
const QObject *receiver,
const char *member)
{
@ -109,12 +98,10 @@ KAction *KActionCategory::addAction(
return action;
}
void KActionCategory::addAction(QAction *action)
{
// Only add the action if wasn't added earlier.
if (!d->actions.contains(action))
{
if (!d->actions.contains(action)) {
d->actions.append(action);
}
}
@ -125,19 +112,16 @@ KActionCollection * KActionCategory::collection() const
return qobject_cast<KActionCollection*>(parent());
}
QString KActionCategory::text() const
{
return d->text;
}
void KActionCategory::setText(const QString &text)
{
d->text = text;
}
void KActionCategory::unlistAction(QAction *action)
{
// ATTENTION:
@ -149,7 +133,9 @@ void KActionCategory::unlistAction(QAction *action)
int index = d->actions.indexOf(action);
// Action not found.
if (index==-1) return;
if (index==-1) {
return;
}
// Remove the action
d->actions.takeAt(index);
@ -158,7 +144,7 @@ void KActionCategory::unlistAction(QAction *action)
KActionCategoryPrivate::KActionCategoryPrivate( KActionCategory *host )
: q(host)
{}
{
}
#include "moc_kactioncategory.cpp"

View file

@ -21,9 +21,10 @@
#ifndef KACTIONCATEGORY_H
#define KACTIONCATEGORY_H
#include <QtCore/QObject>
#include <QtCore/QString>
#include <QtCore/QList>
#include <QObject>
#include <QString>
#include <QList>
#include <QAction>
#include "kstandardaction.h"
#include "kactioncollection.h"
@ -32,10 +33,6 @@
class KAction;
struct KActionCategoryPrivate;
#include <QAction>
/**
* Categorize actions for KShortcutsEditor.
*
@ -95,7 +92,6 @@ struct KActionCategoryPrivate;
class KDEUI_EXPORT KActionCategory : public QObject
{
Q_OBJECT
Q_PROPERTY(QString text READ text WRITE setText)
public:
@ -103,7 +99,7 @@ public:
/**
* Default constructor
*/
explicit KActionCategory(const QString &text, KActionCollection *parent=NULL);
explicit KActionCategory(const QString &text, KActionCollection *parent = nullptr);
/**
* Destructor
@ -123,27 +119,23 @@ public:
KAction* addAction(const QString &name, KAction *action);
KAction * addAction(
KStandardAction::StandardAction actionType,
const QObject *receiver = NULL,
const char *member = NULL);
KAction* addAction(KStandardAction::StandardAction actionType,
const QObject *receiver = nullptr,
const char *member = nullptr);
KAction * addAction(
KStandardAction::StandardAction actionType,
KAction* addAction(KStandardAction::StandardAction actionType,
const QString &name,
const QObject *receiver = NULL,
const char *member = NULL);
const QObject *receiver = nullptr,
const char *member = nullptr);
KAction *addAction(
const QString &name,
const QObject *receiver = NULL,
const char *member = NULL);
KAction* addAction(const QString &name,
const QObject *receiver = nullptr,
const char *member = nullptr);
template<class ActionType>
ActionType *add(
const QString &name,
const QObject *receiver = NULL,
const char *member = NULL)
ActionType* add(const QString &name,
const QObject *receiver = nullptr,
const char *member = nullptr)
{
ActionType *action = collection()->add<ActionType>(name, receiver, member);
addAction(action);
@ -173,7 +165,6 @@ public:
void setText(const QString &text);
private:
/**
* Remove \action from this category if found.
*/
@ -192,4 +183,4 @@ private:
};
#endif /* #ifndef KACTIONCATEGORY_H */
#endif // KACTIONCATEGORY_H

View file

@ -299,7 +299,7 @@ void KFindDialog::showEvent(QShowEvent *e)
{
if (!d->initialShowDone) {
d->initialShowDone = true; // only once
kDebug() << "showEvent\n";
kDebug() << "showEvent";
if (!d->findStrings.isEmpty()) {
setFindHistory(d->findStrings);
}