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;
}
@ -127,7 +125,7 @@ bool KAction::isShortcutConfigurable() const
return property("isShortcutConfigurable").toBool();
}
void KAction::setShortcutConfigurable( bool b )
void KAction::setShortcutConfigurable(bool b)
{
setProperty("isShortcutConfigurable", b);
}
@ -135,61 +133,55 @@ 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);
}
void KAction::setShortcut( const KShortcut & shortcut, ShortcutTypes type )
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);
}
}
void KAction::setShortcut( const QKeySequence & keySeq, 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);
}
}
void KAction::setShortcuts(const QList<QKeySequence>& shortcuts, ShortcutTypes type)
void KAction::setShortcuts(const QList<QKeySequence> &shortcuts, ShortcutTypes type)
{
setShortcut(KShortcut(shortcuts), type);
}
const KShortcut & KAction::globalShortcut(ShortcutTypes type) const
const KShortcut& KAction::globalShortcut(ShortcutTypes type) const
{
Q_ASSERT(type);
if (type == DefaultShortcut)
if (type == KAction::DefaultShortcut) {
return d->defaultGlobalShortcut;
}
return d->globalShortcut;
}
void KAction::setGlobalShortcut( const KShortcut & shortcut, ShortcutTypes type,
GlobalShortcutLoading load )
void KAction::setGlobalShortcut(const KShortcut &shortcut, ShortcutTypes type,
GlobalShortcutLoading load)
{
Q_ASSERT(type);
bool changed = false;
@ -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;
}
@ -256,15 +248,13 @@ void KAction::forgetGlobalShortcut()
}
}
void KAction::setHelpText(const QString& text)
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

@ -210,11 +210,11 @@ class KDEUI_EXPORT KAction : public QWidgetAction
{
Q_OBJECT
Q_PROPERTY( KShortcut shortcut READ shortcut WRITE setShortcut )
Q_PROPERTY( bool shortcutConfigurable READ isShortcutConfigurable WRITE setShortcutConfigurable )
Q_PROPERTY( KShortcut globalShortcut READ globalShortcut WRITE setGlobalShortcut )
Q_PROPERTY( bool globalShortcutEnabled READ isGlobalShortcutEnabled )
Q_FLAGS( ShortcutType )
Q_PROPERTY(KShortcut shortcut READ shortcut WRITE setShortcut)
Q_PROPERTY(bool shortcutConfigurable READ isShortcutConfigurable WRITE setShortcutConfigurable)
Q_PROPERTY(KShortcut globalShortcut READ globalShortcut WRITE setGlobalShortcut)
Q_PROPERTY(bool globalShortcutEnabled READ isGlobalShortcutEnabled)
Q_FLAGS(ShortcutType)
public:
/**
@ -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
@ -288,7 +288,7 @@ public:
*
* @since 4.3
*/
void setHelpText(const QString& text);
void setHelpText(const QString &text);
/**
* Get the shortcut for this action.
@ -313,7 +313,7 @@ public:
* \param type type of shortcut to be set: active shortcut,
* default shortcut, or both (the default).
*/
void setShortcut(const KShortcut& shortcut, ShortcutTypes type = ShortcutTypes(ActiveShortcut | DefaultShortcut));
void setShortcut(const KShortcut &shortcut, ShortcutTypes type = ShortcutTypes(ActiveShortcut | DefaultShortcut));
/**
* \overload void setShortcut(const KShortcut& shortcut)
@ -327,7 +327,7 @@ public:
* \param type type of shortcut to be set: active shortcut,
* default shortcut, or both (default argument value).
*/
void setShortcut(const QKeySequence& shortcut, ShortcutTypes type = ShortcutTypes(ActiveShortcut | DefaultShortcut));
void setShortcut(const QKeySequence &shortcut, ShortcutTypes type = ShortcutTypes(ActiveShortcut | DefaultShortcut));
/**
* \overload void setShortcuts(const QList\<QKeySequence\>& shortcuts).
@ -341,7 +341,7 @@ public:
* \param type type of shortcut to be set: active shortcut,
* default shortcut, or both (default argument value).
*/
void setShortcuts(const QList<QKeySequence>& shortcuts, ShortcutTypes type = ShortcutTypes(ActiveShortcut | DefaultShortcut));
void setShortcuts(const QList<QKeySequence> &shortcuts, ShortcutTypes type = ShortcutTypes(ActiveShortcut | DefaultShortcut));
/**
* Returns true if this action's shortcut is configurable.
@ -406,7 +406,7 @@ public:
* \note the default shortcut will never be influenced by autoloading - it will be set as given.
* \sa globalShortcut()
*/
void setGlobalShortcut(const KShortcut& shortcut, ShortcutTypes type =
void setGlobalShortcut(const KShortcut &shortcut, ShortcutTypes type =
ShortcutTypes(ActiveShortcut | DefaultShortcut),
GlobalShortcutLoading loading = Autoloading);
@ -437,7 +437,7 @@ public:
/**
* @reimp
*/
bool event(QEvent*);
bool event(QEvent *event);
Q_SIGNALS:

View file

@ -27,9 +27,11 @@ class KAction;
class KActionPrivate
{
public:
public:
KActionPrivate()
: componentData(KGlobal::mainComponent()), globalShortcutEnabled(false), q(0)
: componentData(KGlobal::mainComponent()),
globalShortcutEnabled(false),
q(nullptr)
{
}

View file

@ -22,11 +22,9 @@
#include "kaction.h"
struct KActionCategoryPrivate
{
KActionCategoryPrivate( KActionCategory *host );
{
KActionCategoryPrivate(KActionCategory *host);
//! Our host
KActionCategory *q;
@ -37,109 +35,95 @@ struct KActionCategoryPrivate
//! List of actions
QList<QAction*> actions;
}; // class KActionCategoryPrivate
}; // class KActionCategoryPrivate
KActionCategory::KActionCategory(const QString &text, KActionCollection *parent)
: QObject(parent)
,d( new KActionCategoryPrivate(this) )
{
: QObject(parent),
d(new KActionCategoryPrivate(this))
{
d->text = text;
}
}
KActionCategory::~KActionCategory()
{
{
delete d;
}
}
const QList<QAction*> KActionCategory::actions() const
{
{
return d->actions;
}
}
QAction * KActionCategory::addAction(const QString &name, QAction *action)
{
QAction* KActionCategory::addAction(const QString &name, QAction *action)
{
collection()->addAction(name, action);
addAction(action);
return action;
}
}
KAction * KActionCategory::addAction(const QString &name, KAction *action)
{
KAction* KActionCategory::addAction(const QString &name, KAction *action)
{
collection()->addAction(name, action);
addAction(action);
return action;
}
}
KAction * KActionCategory::addAction(
KStandardAction::StandardAction actionType,
KAction* KActionCategory::addAction(KStandardAction::StandardAction actionType,
const QObject *receiver,
const char *member)
{
{
KAction *action = collection()->addAction(actionType, receiver, member);
addAction(action);
return action;
}
}
KAction * KActionCategory::addAction(
KStandardAction::StandardAction actionType,
KAction* KActionCategory::addAction(KStandardAction::StandardAction actionType,
const QString &name,
const QObject *receiver,
const char *member)
{
{
KAction *action = collection()->addAction(actionType, name, receiver, member);
addAction(action);
return action;
}
}
KAction *KActionCategory::addAction(
const QString &name,
KAction *KActionCategory::addAction(const QString &name,
const QObject *receiver,
const char *member)
{
{
KAction *action = collection()->addAction(name, receiver, member);
addAction(action);
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);
}
}
}
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:
// This method is called from KActionCollection with an QObject formerly
// known as a QAction during _k_actionDestroyed(). So don't do fancy stuff
@ -149,16 +133,18 @@ 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);
}
}
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.
*
@ -93,17 +90,16 @@ struct KActionCategoryPrivate;
* \endcode
*/
class KDEUI_EXPORT KActionCategory : public QObject
{
{
Q_OBJECT
Q_PROPERTY( QString text READ text WRITE setText )
Q_PROPERTY(QString text READ text WRITE setText)
public:
/**
* Default constructor
*/
explicit KActionCategory(const QString &text, KActionCollection *parent=NULL);
explicit KActionCategory(const QString &text, KActionCollection *parent = nullptr);
/**
* Destructor
@ -119,31 +115,27 @@ public:
* corresponding method of KActionCollection.
*/
//@{
QAction * addAction(const QString &name, QAction *action);
QAction* addAction(const QString &name, QAction *action);
KAction * addAction(const QString &name, KAction *action);
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);
@ -160,7 +152,7 @@ public:
/**
* The action collection this category is associated with.
*/
KActionCollection * collection() const;
KActionCollection* collection() const;
/**
* The action categorys descriptive text
@ -170,10 +162,9 @@ public:
/**
* Set the action categorys descriptive text.
*/
void setText(const QString& text);
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);
}
@ -576,9 +576,9 @@ void KFindDialog::KFindDialogPrivate::_k_showPlaceholders()
void KFindDialog::KFindDialogPrivate::_k_slotPlaceholdersAboutToShow()
{
placeholders->clear();
placeholders->addAction( new PlaceHolderAction(placeholders, i18n("Complete Match"), 0));
placeholders->addAction(new PlaceHolderAction(placeholders, i18n("Complete Match"), 0));
QRegExp r( q->pattern() );
QRegExp r(q->pattern());
uint n = r.captureCount();
for (uint i = 0; i < n; i++) {
placeholders->addAction(