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

View file

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

View file

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

View file

@ -22,11 +22,9 @@
#include "kaction.h" #include "kaction.h"
struct KActionCategoryPrivate struct KActionCategoryPrivate
{ {
KActionCategoryPrivate(KActionCategory *host);
KActionCategoryPrivate( KActionCategory *host );
//! Our host //! Our host
KActionCategory *q; KActionCategory *q;
@ -37,109 +35,95 @@ struct KActionCategoryPrivate
//! List of actions //! List of actions
QList<QAction*> actions; QList<QAction*> actions;
}; // class KActionCategoryPrivate }; // class KActionCategoryPrivate
KActionCategory::KActionCategory(const QString &text, KActionCollection *parent) KActionCategory::KActionCategory(const QString &text, KActionCollection *parent)
: QObject(parent) : QObject(parent),
,d( new KActionCategoryPrivate(this) ) d(new KActionCategoryPrivate(this))
{ {
d->text = text; d->text = text;
} }
KActionCategory::~KActionCategory() KActionCategory::~KActionCategory()
{ {
delete d; delete d;
} }
const QList<QAction*> KActionCategory::actions() const const QList<QAction*> KActionCategory::actions() const
{ {
return d->actions; return d->actions;
} }
QAction* KActionCategory::addAction(const QString &name, QAction *action)
QAction * KActionCategory::addAction(const QString &name, QAction *action) {
{
collection()->addAction(name, action); collection()->addAction(name, action);
addAction(action); addAction(action);
return action; return action;
} }
KAction* KActionCategory::addAction(const QString &name, KAction *action)
KAction * KActionCategory::addAction(const QString &name, KAction *action) {
{
collection()->addAction(name, action); collection()->addAction(name, action);
addAction(action); addAction(action);
return action; return action;
} }
KAction* KActionCategory::addAction(KStandardAction::StandardAction actionType,
KAction * KActionCategory::addAction(
KStandardAction::StandardAction actionType,
const QObject *receiver, const QObject *receiver,
const char *member) const char *member)
{ {
KAction *action = collection()->addAction(actionType, receiver, member); KAction *action = collection()->addAction(actionType, receiver, member);
addAction(action); addAction(action);
return action; return action;
} }
KAction* KActionCategory::addAction(KStandardAction::StandardAction actionType,
KAction * KActionCategory::addAction(
KStandardAction::StandardAction actionType,
const QString &name, const QString &name,
const QObject *receiver, const QObject *receiver,
const char *member) const char *member)
{ {
KAction *action = collection()->addAction(actionType, name, receiver, member); KAction *action = collection()->addAction(actionType, name, receiver, member);
addAction(action); addAction(action);
return action; return action;
} }
KAction *KActionCategory::addAction(const QString &name,
KAction *KActionCategory::addAction(
const QString &name,
const QObject *receiver, const QObject *receiver,
const char *member) const char *member)
{ {
KAction *action = collection()->addAction(name, receiver, member); KAction *action = collection()->addAction(name, receiver, member);
addAction(action); addAction(action);
return action; return action;
} }
void KActionCategory::addAction(QAction *action) void KActionCategory::addAction(QAction *action)
{ {
// Only add the action if wasn't added earlier. // Only add the action if wasn't added earlier.
if (!d->actions.contains(action)) if (!d->actions.contains(action)) {
{
d->actions.append(action); d->actions.append(action);
} }
} }
KActionCollection * KActionCategory::collection() const KActionCollection * KActionCategory::collection() const
{ {
return qobject_cast<KActionCollection*>(parent()); return qobject_cast<KActionCollection*>(parent());
} }
QString KActionCategory::text() const QString KActionCategory::text() const
{ {
return d->text; return d->text;
} }
void KActionCategory::setText(const QString &text) void KActionCategory::setText(const QString &text)
{ {
d->text = text; d->text = text;
} }
void KActionCategory::unlistAction(QAction *action) void KActionCategory::unlistAction(QAction *action)
{ {
// ATTENTION: // ATTENTION:
// This method is called from KActionCollection with an QObject formerly // This method is called from KActionCollection with an QObject formerly
// known as a QAction during _k_actionDestroyed(). So don't do fancy stuff // 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); int index = d->actions.indexOf(action);
// Action not found. // Action not found.
if (index==-1) return; if (index==-1) {
return;
}
// Remove the action // Remove the action
d->actions.takeAt(index); d->actions.takeAt(index);
} }
KActionCategoryPrivate::KActionCategoryPrivate( KActionCategory *host ) KActionCategoryPrivate::KActionCategoryPrivate( KActionCategory *host )
: q(host) : q(host)
{} {
}
#include "moc_kactioncategory.cpp" #include "moc_kactioncategory.cpp"

View file

@ -21,9 +21,10 @@
#ifndef KACTIONCATEGORY_H #ifndef KACTIONCATEGORY_H
#define KACTIONCATEGORY_H #define KACTIONCATEGORY_H
#include <QtCore/QObject> #include <QObject>
#include <QtCore/QString> #include <QString>
#include <QtCore/QList> #include <QList>
#include <QAction>
#include "kstandardaction.h" #include "kstandardaction.h"
#include "kactioncollection.h" #include "kactioncollection.h"
@ -32,10 +33,6 @@
class KAction; class KAction;
struct KActionCategoryPrivate; struct KActionCategoryPrivate;
#include <QAction>
/** /**
* Categorize actions for KShortcutsEditor. * Categorize actions for KShortcutsEditor.
* *
@ -93,17 +90,16 @@ struct KActionCategoryPrivate;
* \endcode * \endcode
*/ */
class KDEUI_EXPORT KActionCategory : public QObject class KDEUI_EXPORT KActionCategory : public QObject
{ {
Q_OBJECT Q_OBJECT
Q_PROPERTY(QString text READ text WRITE setText)
Q_PROPERTY( QString text READ text WRITE setText )
public: public:
/** /**
* Default constructor * Default constructor
*/ */
explicit KActionCategory(const QString &text, KActionCollection *parent=NULL); explicit KActionCategory(const QString &text, KActionCollection *parent = nullptr);
/** /**
* Destructor * Destructor
@ -119,31 +115,27 @@ public:
* corresponding method of KActionCollection. * 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( KAction* addAction(KStandardAction::StandardAction actionType,
KStandardAction::StandardAction actionType, const QObject *receiver = nullptr,
const QObject *receiver = NULL, const char *member = nullptr);
const char *member = NULL);
KAction * addAction( KAction* addAction(KStandardAction::StandardAction actionType,
KStandardAction::StandardAction actionType,
const QString &name, const QString &name,
const QObject *receiver = NULL, const QObject *receiver = nullptr,
const char *member = NULL); const char *member = nullptr);
KAction *addAction( KAction* addAction(const QString &name,
const QString &name, const QObject *receiver = nullptr,
const QObject *receiver = NULL, const char *member = nullptr);
const char *member = NULL);
template<class ActionType> template<class ActionType>
ActionType *add( ActionType* add(const QString &name,
const QString &name, const QObject *receiver = nullptr,
const QObject *receiver = NULL, const char *member = nullptr)
const char *member = NULL)
{ {
ActionType *action = collection()->add<ActionType>(name, receiver, member); ActionType *action = collection()->add<ActionType>(name, receiver, member);
addAction(action); addAction(action);
@ -160,7 +152,7 @@ public:
/** /**
* The action collection this category is associated with. * The action collection this category is associated with.
*/ */
KActionCollection * collection() const; KActionCollection* collection() const;
/** /**
* The action categorys descriptive text * The action categorys descriptive text
@ -170,10 +162,9 @@ public:
/** /**
* Set the action categorys descriptive text. * Set the action categorys descriptive text.
*/ */
void setText(const QString& text); void setText(const QString &text);
private: private:
/** /**
* Remove \action from this category if found. * 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) { if (!d->initialShowDone) {
d->initialShowDone = true; // only once d->initialShowDone = true; // only once
kDebug() << "showEvent\n"; kDebug() << "showEvent";
if (!d->findStrings.isEmpty()) { if (!d->findStrings.isEmpty()) {
setFindHistory(d->findStrings); setFindHistory(d->findStrings);
} }
@ -576,9 +576,9 @@ void KFindDialog::KFindDialogPrivate::_k_showPlaceholders()
void KFindDialog::KFindDialogPrivate::_k_slotPlaceholdersAboutToShow() void KFindDialog::KFindDialogPrivate::_k_slotPlaceholdersAboutToShow()
{ {
placeholders->clear(); 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(); uint n = r.captureCount();
for (uint i = 0; i < n; i++) { for (uint i = 0; i < n; i++) {
placeholders->addAction( placeholders->addAction(