mirror of
https://bitbucket.org/smil3y/kdelibs.git
synced 2025-02-24 10:52:49 +00:00
kdeui: format and indent
Signed-off-by: Ivailo Monev <xakepa10@gmail.com>
This commit is contained in:
parent
b1b18231d8
commit
6278217dc6
7 changed files with 450 additions and 450 deletions
|
@ -28,11 +28,12 @@
|
||||||
#include "kactioncategory.h"
|
#include "kactioncategory.h"
|
||||||
#include "kxmlguiclient.h"
|
#include "kxmlguiclient.h"
|
||||||
#include "kxmlguifactory.h"
|
#include "kxmlguifactory.h"
|
||||||
|
|
||||||
#include "kdebug.h"
|
|
||||||
#include "kglobal.h"
|
#include "kglobal.h"
|
||||||
#include "kaction.h"
|
#include "kaction.h"
|
||||||
#include "kaction_p.h"
|
#include "kaction_p.h"
|
||||||
|
#include "kcomponentdata.h"
|
||||||
|
#include "kconfiggroup.h"
|
||||||
|
#include "kdebug.h"
|
||||||
|
|
||||||
#include <QtXml/qdom.h>
|
#include <QtXml/qdom.h>
|
||||||
#include <QtCore/QSet>
|
#include <QtCore/QSet>
|
||||||
|
@ -41,8 +42,6 @@
|
||||||
#include <QtGui/QAction>
|
#include <QtGui/QAction>
|
||||||
|
|
||||||
#include <stdio.h>
|
#include <stdio.h>
|
||||||
#include "kcomponentdata.h"
|
|
||||||
#include "kconfiggroup.h"
|
|
||||||
|
|
||||||
class KActionCollectionPrivate
|
class KActionCollectionPrivate
|
||||||
{
|
{
|
||||||
|
@ -54,7 +53,6 @@ public:
|
||||||
connectTriggered(false),
|
connectTriggered(false),
|
||||||
connectHovered(false),
|
connectHovered(false),
|
||||||
q(nullptr)
|
q(nullptr)
|
||||||
|
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -425,7 +423,7 @@ void KActionCollection::readSettings(KConfigGroup *config)
|
||||||
if (kaction->isShortcutConfigurable() ) {
|
if (kaction->isShortcutConfigurable() ) {
|
||||||
const QString actionName = it.key();
|
const QString actionName = it.key();
|
||||||
const QString entry = config->readEntry(actionName, QString());
|
const QString entry = config->readEntry(actionName, QString());
|
||||||
if( !entry.isEmpty() ) {
|
if (!entry.isEmpty()) {
|
||||||
kaction->setShortcut(KShortcut(entry), KAction::ActiveShortcut);
|
kaction->setShortcut(KShortcut(entry), KAction::ActiveShortcut);
|
||||||
} else {
|
} else {
|
||||||
kaction->setShortcut(kaction->shortcut(KAction::DefaultShortcut));
|
kaction->setShortcut(kaction->shortcut(KAction::DefaultShortcut));
|
||||||
|
@ -557,7 +555,7 @@ void KActionCollection::writeSettings(KConfigGroup *config, bool writeAll, QActi
|
||||||
{
|
{
|
||||||
// If the caller didn't provide a config group we try to save the KXMLGUI
|
// If the caller didn't provide a config group we try to save the KXMLGUI
|
||||||
// Configuration file. If that succeeds we are finished.
|
// Configuration file. If that succeeds we are finished.
|
||||||
if (config == 0 && d->writeKXMLGUIConfigFile()) {
|
if (!config && d->writeKXMLGUIConfigFile()) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -54,359 +54,354 @@ class KXMLGUIClient;
|
||||||
*/
|
*/
|
||||||
class KDEUI_EXPORT KActionCollection : public QObject
|
class KDEUI_EXPORT KActionCollection : public QObject
|
||||||
{
|
{
|
||||||
friend class KXMLGUIClient;
|
friend class KXMLGUIClient;
|
||||||
|
|
||||||
Q_OBJECT
|
Q_OBJECT
|
||||||
|
|
||||||
Q_PROPERTY( QString configGroup READ configGroup WRITE setConfigGroup )
|
Q_PROPERTY(QString configGroup READ configGroup WRITE setConfigGroup)
|
||||||
Q_PROPERTY( bool configIsGlobal READ configIsGlobal WRITE setConfigGlobal )
|
Q_PROPERTY(bool configIsGlobal READ configIsGlobal WRITE setConfigGlobal)
|
||||||
|
|
||||||
public:
|
public:
|
||||||
/**
|
/**
|
||||||
* Constructor. Allows specification of a KComponentData other than the default
|
* Constructor. Allows specification of a KComponentData other than the default
|
||||||
* global KComponentData, where needed.
|
* global KComponentData, where needed.
|
||||||
*/
|
*/
|
||||||
explicit KActionCollection(QObject *parent, const KComponentData &cData = KComponentData());
|
explicit KActionCollection(QObject *parent, const KComponentData &cData = KComponentData());
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Destructor.
|
* Destructor.
|
||||||
*/
|
*/
|
||||||
virtual ~KActionCollection();
|
virtual ~KActionCollection();
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Access the list of all action collections in existence for this app
|
* Access the list of all action collections in existence for this app
|
||||||
*/
|
*/
|
||||||
static const QList<KActionCollection*>& allCollections();
|
static const QList<KActionCollection*>& allCollections();
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Clears the entire action collection, deleting all actions.
|
* Clears the entire action collection, deleting all actions.
|
||||||
*/
|
*/
|
||||||
void clear();
|
void clear();
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Associate all actions in this collection to the given \a widget.
|
* Associate all actions in this collection to the given \a widget.
|
||||||
* Unlike addAssociatedWidget, this method only adds all current actions
|
* Unlike addAssociatedWidget, this method only adds all current actions
|
||||||
* in the collection to the given widget. Any action added after this call
|
* in the collection to the given widget. Any action added after this call
|
||||||
* will not be added to the given widget automatically.
|
* will not be added to the given widget automatically.
|
||||||
* So this is just a shortcut for a foreach loop and a widget->addAction call.
|
* So this is just a shortcut for a foreach loop and a widget->addAction call.
|
||||||
*/
|
*/
|
||||||
void associateWidget(QWidget* widget) const;
|
void associateWidget(QWidget *widget) const;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Associate all actions in this collection to the given \a widget, including any actions
|
* Associate all actions in this collection to the given \a widget, including any actions
|
||||||
* added after this association is made.
|
* added after this association is made.
|
||||||
*
|
*
|
||||||
* This does not change the action's shortcut context, so if you need to have the actions only
|
* This does not change the action's shortcut context, so if you need to have the actions only
|
||||||
* trigger when the widget has focus, you'll need to set the shortcut context on each action
|
* trigger when the widget has focus, you'll need to set the shortcut context on each action
|
||||||
* to Qt::WidgetShortcut (or better still, Qt::WidgetWithChildrenShortcut with Qt 4.4+)
|
* to Qt::WidgetShortcut (or better still, Qt::WidgetWithChildrenShortcut with Qt 4.4+)
|
||||||
*/
|
*/
|
||||||
void addAssociatedWidget(QWidget* widget);
|
void addAssociatedWidget(QWidget *widget);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Remove an association between all actions in this collection and the given \a widget, i.e.
|
* Remove an association between all actions in this collection and the given \a widget, i.e.
|
||||||
* remove those actions from the widget, and stop associating newly added actions as well.
|
* remove those actions from the widget, and stop associating newly added actions as well.
|
||||||
*/
|
*/
|
||||||
void removeAssociatedWidget(QWidget* widget);
|
void removeAssociatedWidget(QWidget *widget);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Return a list of all associated widgets.
|
* Return a list of all associated widgets.
|
||||||
*/
|
*/
|
||||||
QList<QWidget*> associatedWidgets() const;
|
QList<QWidget*> associatedWidgets() const;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Clear all associated widgets and remove the actions from those widgets.
|
* Clear all associated widgets and remove the actions from those widgets.
|
||||||
*/
|
*/
|
||||||
void clearAssociatedWidgets();
|
void clearAssociatedWidgets();
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Returns the KConfig group with which settings will be loaded and saved.
|
* Returns the KConfig group with which settings will be loaded and saved.
|
||||||
*/
|
*/
|
||||||
QString configGroup() const;
|
QString configGroup() const;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Returns whether this action collection's configuration should be global to KDE ( \e true ),
|
* Returns whether this action collection's configuration should be global to KDE ( \e true ),
|
||||||
* or specific to the application ( \e false ).
|
* or specific to the application ( \e false ).
|
||||||
*/
|
*/
|
||||||
bool configIsGlobal() const;
|
bool configIsGlobal() const;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Sets \a group as the KConfig group with which settings will be loaded and saved.
|
* Sets \a group as the KConfig group with which settings will be loaded and saved.
|
||||||
*/
|
*/
|
||||||
void setConfigGroup( const QString& group );
|
void setConfigGroup(const QString &group);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Set whether this action collection's configuration should be global to KDE ( \e true ),
|
* Set whether this action collection's configuration should be global to KDE ( \e true ),
|
||||||
* or specific to the application ( \e false ).
|
* or specific to the application ( \e false ).
|
||||||
*/
|
*/
|
||||||
void setConfigGlobal( bool global );
|
void setConfigGlobal(bool global);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Read all key associations from @p config.
|
* Read all key associations from @p config.
|
||||||
*
|
*
|
||||||
* If @p config is zero, read all key associations from the
|
* If @p config is zero, read all key associations from the
|
||||||
* application's configuration file KGlobal::config(),
|
* application's configuration file KGlobal::config(),
|
||||||
* in the group set by setConfigGroup().
|
* in the group set by setConfigGroup().
|
||||||
*/
|
*/
|
||||||
void readSettings( KConfigGroup* config = 0 );
|
void readSettings(KConfigGroup *config = nullptr);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Import from @p config all configurable global key associations.
|
* Import from @p config all configurable global key associations.
|
||||||
*
|
*
|
||||||
* \since 4.1
|
* \since 4.1
|
||||||
*
|
*
|
||||||
* \param config Config object to read from
|
* \param config Config object to read from
|
||||||
*/
|
*/
|
||||||
void importGlobalShortcuts( KConfigGroup* config );
|
void importGlobalShortcuts(KConfigGroup *config);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Export the current configurable global key associations to @p config.
|
* Export the current configurable global key associations to @p config.
|
||||||
*
|
*
|
||||||
* \since 4.1
|
* \since 4.1
|
||||||
*
|
*
|
||||||
* \param config Config object to save to
|
* \param config Config object to save to
|
||||||
* \param writeDefaults set to true to write settings which are already at defaults.
|
* \param writeDefaults set to true to write settings which are already at defaults.
|
||||||
*/
|
*/
|
||||||
void exportGlobalShortcuts( KConfigGroup* config, bool writeDefaults = false ) const;
|
void exportGlobalShortcuts(KConfigGroup *config, bool writeDefaults = false) const;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Write the current configurable key associations to @a config. What the
|
* Write the current configurable key associations to @a config. What the
|
||||||
* function does if @a config is zero depends. If this action collection
|
* function does if @a config is zero depends. If this action collection
|
||||||
* belongs to a KXMLGuiClient the setting are saved to the kxmlgui
|
* belongs to a KXMLGuiClient the setting are saved to the kxmlgui
|
||||||
* definition file. If not the settings are written to the applications
|
* definition file. If not the settings are written to the applications
|
||||||
* config file.
|
* config file.
|
||||||
*
|
*
|
||||||
* \note oneAction() and writeDefaults() have no meaning for the kxmlgui
|
* \note oneAction() and writeDefaults() have no meaning for the kxmlgui
|
||||||
* configuration file.
|
* configuration file.
|
||||||
*
|
*
|
||||||
* \param config Config object to save to, or null (see above)
|
* \param config Config object to save to, or null (see above)
|
||||||
* \param writeDefaults set to true to write settings which are already at defaults.
|
* \param writeDefaults set to true to write settings which are already at defaults.
|
||||||
* \param oneAction pass an action here if you just want to save the values for one action, eg.
|
* \param oneAction pass an action here if you just want to save the values for one action, eg.
|
||||||
* if you know that action is the only one which has changed.
|
* if you know that action is the only one which has changed.
|
||||||
*/
|
*/
|
||||||
void writeSettings( KConfigGroup* config = 0, bool writeDefaults = false, QAction* oneAction = 0 ) const;
|
void writeSettings(KConfigGroup *config = nullptr, bool writeDefaults = false, QAction *oneAction = nullptr) const;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Returns the number of actions in the collection.
|
* Returns the number of actions in the collection.
|
||||||
*
|
*
|
||||||
* This is equivalent to actions().count().
|
* This is equivalent to actions().count().
|
||||||
*/
|
*/
|
||||||
int count() const;
|
int count() const;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Returns whether the action collection is empty or not.
|
* Returns whether the action collection is empty or not.
|
||||||
*/
|
*/
|
||||||
bool isEmpty() const;
|
bool isEmpty() const;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Return the QAction* at position "index" in the action collection.
|
* Return the QAction* at position "index" in the action collection.
|
||||||
*
|
*
|
||||||
* This is equivalent to actions().value(index);
|
* This is equivalent to actions().value(index);
|
||||||
*/
|
*/
|
||||||
QAction *action(int index) const;
|
QAction* action(int index) const;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Get the action with the given \a name from the action collection.
|
* Get the action with the given \a name from the action collection.
|
||||||
*
|
*
|
||||||
* @param name Name of the KAction
|
* @param name Name of the KAction
|
||||||
* @return A pointer to the KAction in the collection which matches the parameters or
|
* @return A pointer to the KAction in the collection which matches the parameters or
|
||||||
* null if nothing matches.
|
* null if nothing matches.
|
||||||
*/
|
*/
|
||||||
QAction* action( const QString& name ) const;
|
QAction* action(const QString &name) const;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Returns the list of KActions which belong to this action collection.
|
* Returns the list of KActions which belong to this action collection.
|
||||||
*
|
*
|
||||||
* The list is guaranteed to be in the same order the action were put into
|
* The list is guaranteed to be in the same order the action were put into
|
||||||
* the collection.
|
* the collection.
|
||||||
*/
|
*/
|
||||||
QList<QAction*> actions() const;
|
QList<QAction*> actions() const;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Returns the list of KActions without an QAction::actionGroup() which belong to this action collection.
|
* Returns the list of KActions without an QAction::actionGroup() which belong to this action collection.
|
||||||
*/
|
*/
|
||||||
const QList<QAction*> actionsWithoutGroup() const;
|
const QList<QAction*> actionsWithoutGroup() const;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Returns the list of all QActionGroups associated with actions in this action collection.
|
* Returns the list of all QActionGroups associated with actions in this action collection.
|
||||||
*/
|
*/
|
||||||
const QList<QActionGroup*> actionGroups() const;
|
const QList<QActionGroup*> actionGroups() const;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Set the \a componentData associated with this action collection.
|
* Set the \a componentData associated with this action collection.
|
||||||
*
|
*
|
||||||
* \warning Don't call this method on a KActionCollection that contains
|
* \warning Don't call this method on a KActionCollection that contains
|
||||||
* actions. This is not supported.
|
* actions. This is not supported.
|
||||||
*
|
*
|
||||||
* \param componentData the KComponentData which is to be associated with this action collection,
|
* \param componentData the KComponentData which is to be associated with this action collection,
|
||||||
* or an invalid KComponentData instance to indicate the default KComponentData.
|
* or an invalid KComponentData instance to indicate the default KComponentData.
|
||||||
*/
|
*/
|
||||||
void setComponentData(const KComponentData &componentData);
|
void setComponentData(const KComponentData &componentData);
|
||||||
|
|
||||||
/** The KComponentData with which this class is associated. */
|
/** The KComponentData with which this class is associated. */
|
||||||
KComponentData componentData() const;
|
KComponentData componentData() const;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* The parent KXMLGUIClient, or null if not available.
|
* The parent KXMLGUIClient, or null if not available.
|
||||||
*/
|
*/
|
||||||
const KXMLGUIClient *parentGUIClient() const;
|
const KXMLGUIClient* parentGUIClient() const;
|
||||||
|
|
||||||
Q_SIGNALS:
|
Q_SIGNALS:
|
||||||
/**
|
/**
|
||||||
* Indicates that \a action was inserted into this action collection.
|
* Indicates that \a action was inserted into this action collection.
|
||||||
*/
|
*/
|
||||||
void inserted( QAction* action );
|
void inserted(QAction *action);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Indicates that \a action was hovered.
|
* Indicates that \a action was hovered.
|
||||||
*/
|
*/
|
||||||
void actionHovered(QAction* action);
|
void actionHovered(QAction *action);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Indicates that \a action was triggered
|
* Indicates that \a action was triggered
|
||||||
*/
|
*/
|
||||||
void actionTriggered(QAction* action);
|
void actionTriggered(QAction *action);
|
||||||
|
|
||||||
protected Q_SLOTS:
|
protected Q_SLOTS:
|
||||||
/// Overridden to perform connections when someone wants to know whether an action was highlighted or triggered
|
/// Overridden to perform connections when someone wants to know whether an action was highlighted or triggered
|
||||||
virtual void connectNotify ( const char * signal );
|
virtual void connectNotify(const char *signal);
|
||||||
|
|
||||||
virtual void slotActionTriggered();
|
virtual void slotActionTriggered();
|
||||||
|
|
||||||
private Q_SLOTS:
|
private Q_SLOTS:
|
||||||
void slotActionHovered();
|
void slotActionHovered();
|
||||||
|
|
||||||
|
|
||||||
public:
|
public:
|
||||||
/**
|
/**
|
||||||
* Add an action under the given name to the collection.
|
* Add an action under the given name to the collection.
|
||||||
*
|
*
|
||||||
* Inserting an action that was previously inserted under a different name will replace the
|
* Inserting an action that was previously inserted under a different name will replace the
|
||||||
* old entry, i.e. the action will not be available under the old name anymore but only under
|
* old entry, i.e. the action will not be available under the old name anymore but only under
|
||||||
* the new one.
|
* the new one.
|
||||||
*
|
*
|
||||||
* Inserting an action under a name that is already used for another action will replace
|
* Inserting an action under a name that is already used for another action will replace
|
||||||
* the other action in the collection (but will not delete it).
|
* the other action in the collection (but will not delete it).
|
||||||
*
|
*
|
||||||
* @param name The name by which the action be retrieved again from the collection.
|
* @param name The name by which the action be retrieved again from the collection.
|
||||||
* @param action The action to add.
|
* @param action The action to add.
|
||||||
* @return the same as the action given as parameter. This is just for convenience
|
* @return the same as the action given as parameter. This is just for convenience
|
||||||
* (chaining calls) and consistency with the other addAction methods, you can also
|
* (chaining calls) and consistency with the other addAction methods, you can also
|
||||||
* simply ignore the return value.
|
* simply ignore the return value.
|
||||||
*/
|
*/
|
||||||
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);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Removes an action from the collection and deletes it.
|
* Removes an action from the collection and deletes it.
|
||||||
* @param action The action to remove.
|
* @param action The action to remove.
|
||||||
*/
|
*/
|
||||||
void removeAction(QAction *action);
|
void removeAction(QAction *action);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Removes an action from the collection.
|
* Removes an action from the collection.
|
||||||
* @param action the action to remove.
|
* @param action the action to remove.
|
||||||
*/
|
*/
|
||||||
QAction* takeAction(QAction *action);
|
QAction* takeAction(QAction *action);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Creates a new standard action, adds it to the collection and connects the
|
* Creates a new standard action, adds it to the collection and connects the
|
||||||
* action's triggered(bool) signal to the specified receiver/member. The
|
* action's triggered(bool) signal to the specified receiver/member. The
|
||||||
* newly created action is also returned.
|
* newly created action is also returned.
|
||||||
*
|
*
|
||||||
* Note: Using KStandardAction::OpenRecent will cause a different signal than
|
* Note: Using KStandardAction::OpenRecent will cause a different signal than
|
||||||
* triggered(bool) to be used, see KStandardAction for more information.
|
* triggered(bool) to be used, see KStandardAction for more information.
|
||||||
*
|
*
|
||||||
* The action can be retrieved later from the collection by its standard name as per
|
* The action can be retrieved later from the collection by its standard name as per
|
||||||
* KStandardAction::stdName.
|
* KStandardAction::stdName.
|
||||||
*
|
*
|
||||||
* @param actionType The standard action type of the action to create.
|
* @param actionType The standard action type of the action to create.
|
||||||
* @param receiver The QObject to connect the triggered(bool) signal to. Leave 0 if no
|
* @param receiver The QObject to connect the triggered(bool) signal to. Leave 0 if no
|
||||||
* connection is desired.
|
* connection is desired.
|
||||||
* @param member The SLOT to connect the triggered(bool) signal to. Leave 0 if no
|
* @param member The SLOT to connect the triggered(bool) signal to. Leave 0 if no
|
||||||
* connection is desired.
|
* connection is desired.
|
||||||
* @return new action of the given type ActionType.
|
* @return new action of the given type ActionType.
|
||||||
*/
|
*/
|
||||||
KAction *addAction(KStandardAction::StandardAction actionType, const QObject *receiver = 0, const char *member = 0);
|
KAction* addAction(KStandardAction::StandardAction actionType,
|
||||||
|
const QObject *receiver = nullptr, const char *member = nullptr);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Creates a new standard action, adds to the collection under the given name
|
* Creates a new standard action, adds to the collection under the given name
|
||||||
* and connects the action's triggered(bool) signal to the specified
|
* and connects the action's triggered(bool) signal to the specified
|
||||||
* receiver/member. The newly created action is also returned.
|
* receiver/member. The newly created action is also returned.
|
||||||
*
|
*
|
||||||
* Note: Using KStandardAction::OpenRecent will cause a different signal than
|
* Note: Using KStandardAction::OpenRecent will cause a different signal than
|
||||||
* triggered(bool) to be used, see KStandardAction for more information.
|
* triggered(bool) to be used, see KStandardAction for more information.
|
||||||
*
|
*
|
||||||
* The action can be retrieved later from the collection by the specified name.
|
* The action can be retrieved later from the collection by the specified name.
|
||||||
*
|
*
|
||||||
* @param actionType The standard action type of the action to create.
|
* @param actionType The standard action type of the action to create.
|
||||||
* @param name The name by which the action be retrieved again from the collection.
|
* @param name The name by which the action be retrieved again from the collection.
|
||||||
* @param receiver The QObject to connect the triggered(bool) signal to. Leave 0 if no
|
* @param receiver The QObject to connect the triggered(bool) signal to. Leave 0 if no
|
||||||
* connection is desired.
|
* connection is desired.
|
||||||
* @param member The SLOT to connect the triggered(bool) signal to. Leave 0 if no
|
* @param member The SLOT to connect the triggered(bool) signal to. Leave 0 if no
|
||||||
* connection is desired.
|
* connection is desired.
|
||||||
* @return new action of the given type ActionType.
|
* @return new action of the given type ActionType.
|
||||||
*/
|
*/
|
||||||
KAction *addAction(KStandardAction::StandardAction actionType, const QString &name,
|
KAction* addAction(KStandardAction::StandardAction actionType, const QString &name,
|
||||||
const QObject *receiver = 0, const char *member = 0);
|
const QObject *receiver = nullptr, const char *member = nullptr);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Creates a new action under the given name to the collection and connects
|
* Creates a new action under the given name to the collection and connects
|
||||||
* the action's triggered(bool) signal to the specified receiver/member. The
|
* the action's triggered(bool) signal to the specified receiver/member. The
|
||||||
* newly created action is returned.
|
* newly created action is returned.
|
||||||
*
|
*
|
||||||
* NOTE: KDE prior to 4.2 used the triggered() signal instead of the triggered(bool)
|
* Inserting an action that was previously inserted under a different name will replace the
|
||||||
* signal.
|
* old entry, i.e. the action will not be available under the old name anymore but only under
|
||||||
*
|
* the new one.
|
||||||
* Inserting an action that was previously inserted under a different name will replace the
|
*
|
||||||
* old entry, i.e. the action will not be available under the old name anymore but only under
|
* Inserting an action under a name that is already used for another action will replace
|
||||||
* the new one.
|
* the other action in the collection.
|
||||||
*
|
*
|
||||||
* Inserting an action under a name that is already used for another action will replace
|
* @param name The name by which the action be retrieved again from the collection.
|
||||||
* the other action in the collection.
|
* @param receiver The QObject to connect the triggered(bool) signal to. Leave 0 if no
|
||||||
*
|
* connection is desired.
|
||||||
* @param name The name by which the action be retrieved again from the collection.
|
* @param member The SLOT to connect the triggered(bool) signal to. Leave 0 if no
|
||||||
* @param receiver The QObject to connect the triggered(bool) signal to. Leave 0 if no
|
* connection is desired.
|
||||||
* connection is desired.
|
* @return new action of the given type ActionType.
|
||||||
* @param member The SLOT to connect the triggered(bool) signal to. Leave 0 if no
|
*/
|
||||||
* connection is desired.
|
KAction* addAction(const QString &name, const QObject *receiver = nullptr, const char *member = nullptr);
|
||||||
* @return new action of the given type ActionType.
|
|
||||||
*/
|
|
||||||
KAction *addAction(const QString &name, const QObject *receiver = 0, const char *member = 0);
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Creates a new action under the given name, adds it to the collection and connects the action's triggered(bool)
|
* Creates a new action under the given name, adds it to the collection and connects the action's triggered(bool)
|
||||||
* signal to the specified receiver/member. The receiver slot may accept either a bool or no
|
* signal to the specified receiver/member. The receiver slot may accept either a bool or no
|
||||||
* parameters at all (i.e. slotTriggered(bool) or slotTriggered() ).
|
* parameters at all (i.e. slotTriggered(bool) or slotTriggered() ).
|
||||||
* The type of the action is specified by the template parameter ActionType.
|
* The type of the action is specified by the template parameter ActionType.
|
||||||
*
|
*
|
||||||
* NOTE: KDE prior to 4.2 connected the triggered() signal instead of the triggered(bool)
|
* @param name The internal name of the action (e.g. "file-open").
|
||||||
* signal.
|
* @param receiver The QObject to connect the triggered(bool) signal to. Leave 0 if no
|
||||||
*
|
* connection is desired.
|
||||||
* @param name The internal name of the action (e.g. "file-open").
|
* @param member The SLOT to connect the triggered(bool) signal to. Leave 0 if no
|
||||||
* @param receiver The QObject to connect the triggered(bool) signal to. Leave 0 if no
|
* connection is desired.
|
||||||
* connection is desired.
|
* @return new action of the given type ActionType.
|
||||||
* @param member The SLOT to connect the triggered(bool) signal to. Leave 0 if no
|
*/
|
||||||
* connection is desired.
|
template<class ActionType>
|
||||||
* @return new action of the given type ActionType.
|
ActionType* add(const QString &name, const QObject *receiver = nullptr, const char *member = nullptr)
|
||||||
*/
|
{
|
||||||
template<class ActionType>
|
ActionType *a = new ActionType(this);
|
||||||
ActionType *add(const QString &name, const QObject *receiver = 0, const char *member = 0)
|
if (receiver && member) {
|
||||||
{
|
connect(a, SIGNAL(triggered(bool)), receiver, member);
|
||||||
ActionType *a = new ActionType(this);
|
}
|
||||||
if (receiver && member)
|
addAction(name, a);
|
||||||
connect(a, SIGNAL(triggered(bool)), receiver, member);
|
return a;
|
||||||
addAction(name, a);
|
}
|
||||||
return a;
|
|
||||||
}
|
|
||||||
|
|
||||||
private:
|
private:
|
||||||
Q_PRIVATE_SLOT(d, void _k_actionDestroyed(QObject *))
|
Q_PRIVATE_SLOT(d, void _k_actionDestroyed(QObject*))
|
||||||
Q_PRIVATE_SLOT(d, void _k_associatedWidgetDestroyed(QObject*))
|
Q_PRIVATE_SLOT(d, void _k_associatedWidgetDestroyed(QObject*))
|
||||||
|
|
||||||
KActionCollection( const KXMLGUIClient* parent ); // used by KXMLGUIClient
|
KActionCollection(const KXMLGUIClient *parent); // used by KXMLGUIClient
|
||||||
|
|
||||||
friend class KActionCollectionPrivate;
|
friend class KActionCollectionPrivate;
|
||||||
class KActionCollectionPrivate* const d;
|
class KActionCollectionPrivate* const d;
|
||||||
};
|
};
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
|
|
@ -26,49 +26,46 @@
|
||||||
*/
|
*/
|
||||||
|
|
||||||
#include "kactionmenu.h"
|
#include "kactionmenu.h"
|
||||||
|
#include "kdebug.h"
|
||||||
|
#include "klocale.h"
|
||||||
|
#include "kmenu.h"
|
||||||
|
|
||||||
#include <QToolButton>
|
#include <QToolButton>
|
||||||
#include <QToolBar>
|
#include <QToolBar>
|
||||||
|
|
||||||
#include <kdebug.h>
|
|
||||||
#include <klocale.h>
|
|
||||||
#include <kmenu.h>
|
|
||||||
|
|
||||||
class KActionMenuPrivate
|
class KActionMenuPrivate
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
KActionMenuPrivate()
|
KActionMenuPrivate()
|
||||||
{
|
{
|
||||||
m_delayed = true;
|
m_delayed = true;
|
||||||
m_stickyMenu = true;
|
m_stickyMenu = true;
|
||||||
}
|
}
|
||||||
~KActionMenuPrivate()
|
|
||||||
{
|
bool m_delayed;
|
||||||
}
|
bool m_stickyMenu;
|
||||||
bool m_delayed;
|
|
||||||
bool m_stickyMenu;
|
|
||||||
};
|
};
|
||||||
|
|
||||||
KActionMenu::KActionMenu(QObject *parent)
|
KActionMenu::KActionMenu(QObject *parent)
|
||||||
: KAction(parent)
|
: KAction(parent),
|
||||||
, d(new KActionMenuPrivate)
|
d(new KActionMenuPrivate())
|
||||||
{
|
{
|
||||||
setShortcutConfigurable( false );
|
setShortcutConfigurable(false);
|
||||||
}
|
}
|
||||||
|
|
||||||
KActionMenu::KActionMenu(const QString &text, QObject *parent)
|
KActionMenu::KActionMenu(const QString &text, QObject *parent)
|
||||||
: KAction(parent)
|
: KAction(parent),
|
||||||
, d(new KActionMenuPrivate)
|
d(new KActionMenuPrivate())
|
||||||
{
|
{
|
||||||
setShortcutConfigurable( false );
|
setShortcutConfigurable(false);
|
||||||
setText(text);
|
setText(text);
|
||||||
}
|
}
|
||||||
|
|
||||||
KActionMenu::KActionMenu(const KIcon & icon, const QString & text, QObject *parent)
|
KActionMenu::KActionMenu(const KIcon &icon, const QString &text, QObject *parent)
|
||||||
: KAction(icon, text, parent)
|
: KAction(icon, text, parent),
|
||||||
, d(new KActionMenuPrivate)
|
d(new KActionMenuPrivate())
|
||||||
{
|
{
|
||||||
setShortcutConfigurable( false );
|
setShortcutConfigurable(false);
|
||||||
}
|
}
|
||||||
|
|
||||||
KActionMenu::~KActionMenu()
|
KActionMenu::~KActionMenu()
|
||||||
|
@ -77,95 +74,104 @@ KActionMenu::~KActionMenu()
|
||||||
delete menu();
|
delete menu();
|
||||||
}
|
}
|
||||||
|
|
||||||
QWidget * KActionMenu::createWidget( QWidget * _parent )
|
QWidget * KActionMenu::createWidget(QWidget * _parent)
|
||||||
{
|
{
|
||||||
QToolBar *parent = qobject_cast<QToolBar *>(_parent);
|
QToolBar *parent = qobject_cast<QToolBar*>(_parent);
|
||||||
if (!parent)
|
if (!parent) {
|
||||||
return KAction::createWidget(_parent);
|
return KAction::createWidget(_parent);
|
||||||
QToolButton* button = new QToolButton(parent);
|
}
|
||||||
button->setAutoRaise(true);
|
QToolButton* button = new QToolButton(parent);
|
||||||
button->setFocusPolicy(Qt::NoFocus);
|
button->setAutoRaise(true);
|
||||||
button->setIconSize(parent->iconSize());
|
button->setFocusPolicy(Qt::NoFocus);
|
||||||
button->setToolButtonStyle(parent->toolButtonStyle());
|
button->setIconSize(parent->iconSize());
|
||||||
QObject::connect(parent, SIGNAL(iconSizeChanged(QSize)),
|
button->setToolButtonStyle(parent->toolButtonStyle());
|
||||||
button, SLOT(setIconSize(QSize)));
|
QObject::connect(
|
||||||
QObject::connect(parent, SIGNAL(toolButtonStyleChanged(Qt::ToolButtonStyle)),
|
parent, SIGNAL(iconSizeChanged(QSize)),
|
||||||
button, SLOT(setToolButtonStyle(Qt::ToolButtonStyle)));
|
button, SLOT(setIconSize(QSize))
|
||||||
button->setDefaultAction(this);
|
);
|
||||||
QObject::connect(button, SIGNAL(triggered(QAction*)), parent, SIGNAL(actionTriggered(QAction*)));
|
QObject::connect(
|
||||||
|
parent, SIGNAL(toolButtonStyleChanged(Qt::ToolButtonStyle)),
|
||||||
|
button, SLOT(setToolButtonStyle(Qt::ToolButtonStyle))
|
||||||
|
);
|
||||||
|
button->setDefaultAction(this);
|
||||||
|
QObject::connect(
|
||||||
|
button, SIGNAL(triggered(QAction*)),
|
||||||
|
parent, SIGNAL(actionTriggered(QAction*))
|
||||||
|
);
|
||||||
|
|
||||||
if (delayed())
|
if (delayed()) {
|
||||||
button->setPopupMode(QToolButton::DelayedPopup);
|
button->setPopupMode(QToolButton::DelayedPopup);
|
||||||
else if (stickyMenu())
|
} else if (stickyMenu()) {
|
||||||
button->setPopupMode(QToolButton::InstantPopup);
|
button->setPopupMode(QToolButton::InstantPopup);
|
||||||
else
|
} else {
|
||||||
button->setPopupMode(QToolButton::MenuButtonPopup);
|
button->setPopupMode(QToolButton::MenuButtonPopup);
|
||||||
|
}
|
||||||
|
|
||||||
return button;
|
return button;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void KActionMenu::addAction(QAction *action)
|
||||||
void KActionMenu::addAction( QAction * action )
|
|
||||||
{
|
{
|
||||||
menu()->addAction(action);
|
menu()->addAction(action);
|
||||||
}
|
}
|
||||||
|
|
||||||
QAction* KActionMenu::addSeparator()
|
QAction* KActionMenu::addSeparator()
|
||||||
{
|
{
|
||||||
QAction* separator = new QAction(this);
|
QAction* separator = new QAction(this);
|
||||||
separator->setSeparator(true);
|
separator->setSeparator(true);
|
||||||
addAction(separator);
|
addAction(separator);
|
||||||
return separator;
|
return separator;
|
||||||
}
|
}
|
||||||
|
|
||||||
QAction* KActionMenu::insertSeparator(QAction* before)
|
QAction* KActionMenu::insertSeparator(QAction *before)
|
||||||
{
|
{
|
||||||
QAction* separator = new QAction(this);
|
QAction* separator = new QAction(this);
|
||||||
separator->setSeparator(true);
|
separator->setSeparator(true);
|
||||||
insertAction(before, separator);
|
insertAction(before, separator);
|
||||||
return separator;
|
return separator;
|
||||||
}
|
}
|
||||||
|
|
||||||
void KActionMenu::insertAction( QAction * before, QAction * action )
|
void KActionMenu::insertAction(QAction *before, QAction *action)
|
||||||
{
|
{
|
||||||
menu()->insertAction(before, action);
|
menu()->insertAction(before, action);
|
||||||
}
|
}
|
||||||
|
|
||||||
void KActionMenu::removeAction( QAction * action )
|
void KActionMenu::removeAction(QAction *action)
|
||||||
{
|
{
|
||||||
menu()->removeAction(action);
|
menu()->removeAction(action);
|
||||||
}
|
}
|
||||||
|
|
||||||
bool KActionMenu::delayed() const {
|
bool KActionMenu::delayed() const
|
||||||
|
{
|
||||||
return d->m_delayed;
|
return d->m_delayed;
|
||||||
}
|
}
|
||||||
|
|
||||||
void KActionMenu::setDelayed(bool _delayed) {
|
void KActionMenu::setDelayed(bool _delayed)
|
||||||
|
{
|
||||||
d->m_delayed = _delayed;
|
d->m_delayed = _delayed;
|
||||||
}
|
}
|
||||||
|
|
||||||
bool KActionMenu::stickyMenu() const {
|
bool KActionMenu::stickyMenu() const
|
||||||
|
{
|
||||||
return d->m_stickyMenu;
|
return d->m_stickyMenu;
|
||||||
}
|
}
|
||||||
|
|
||||||
void KActionMenu::setStickyMenu(bool sticky) {
|
void KActionMenu::setStickyMenu(bool sticky)
|
||||||
|
{
|
||||||
d->m_stickyMenu = sticky;
|
d->m_stickyMenu = sticky;
|
||||||
}
|
}
|
||||||
|
|
||||||
KMenu* KActionMenu::menu()
|
KMenu* KActionMenu::menu()
|
||||||
{
|
{
|
||||||
if (!KAction::menu())
|
if (!KAction::menu()) {
|
||||||
setMenu(new KMenu());
|
setMenu(new KMenu());
|
||||||
|
}
|
||||||
return qobject_cast<KMenu*>(KAction::menu());
|
return qobject_cast<KMenu*>(KAction::menu());
|
||||||
}
|
}
|
||||||
|
|
||||||
void KActionMenu::setMenu(KMenu *menu)
|
void KActionMenu::setMenu(KMenu *menu)
|
||||||
{
|
{
|
||||||
KAction::setMenu( menu );
|
KAction::setMenu(menu);
|
||||||
}
|
}
|
||||||
|
|
||||||
/* vim: et sw=2 ts=2
|
|
||||||
*/
|
|
||||||
|
|
||||||
#include "moc_kactionmenu.cpp"
|
#include "moc_kactionmenu.cpp"
|
||||||
|
|
|
@ -46,21 +46,21 @@ class KMenu;
|
||||||
*/
|
*/
|
||||||
class KDEUI_EXPORT KActionMenu : public KAction
|
class KDEUI_EXPORT KActionMenu : public KAction
|
||||||
{
|
{
|
||||||
Q_OBJECT
|
Q_OBJECT
|
||||||
Q_PROPERTY( bool delayed READ delayed WRITE setDelayed )
|
Q_PROPERTY(bool delayed READ delayed WRITE setDelayed)
|
||||||
Q_PROPERTY( bool stickyMenu READ stickyMenu WRITE setStickyMenu )
|
Q_PROPERTY(bool stickyMenu READ stickyMenu WRITE setStickyMenu)
|
||||||
|
|
||||||
public:
|
public:
|
||||||
explicit KActionMenu(QObject *parent);
|
explicit KActionMenu(QObject *parent);
|
||||||
KActionMenu(const QString& text, QObject *parent);
|
KActionMenu(const QString &text, QObject *parent);
|
||||||
KActionMenu(const KIcon& icon, const QString& text, QObject *parent);
|
KActionMenu(const KIcon& icon, const QString &text, QObject *parent);
|
||||||
virtual ~KActionMenu();
|
virtual ~KActionMenu();
|
||||||
|
|
||||||
void addAction(QAction* action);
|
void addAction(QAction *action);
|
||||||
QAction* addSeparator();
|
QAction* addSeparator();
|
||||||
void insertAction(QAction* before, QAction* action);
|
void insertAction(QAction *before, QAction *action);
|
||||||
QAction* insertSeparator(QAction* before);
|
QAction* insertSeparator(QAction* before);
|
||||||
void removeAction(QAction* action);
|
void removeAction(QAction *action);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Returns this action's menu as a KMenu, if it is one.
|
* Returns this action's menu as a KMenu, if it is one.
|
||||||
|
@ -71,7 +71,7 @@ public:
|
||||||
/*
|
/*
|
||||||
* Overload of QAction::setMenu to make sure a KMenu is passed
|
* Overload of QAction::setMenu to make sure a KMenu is passed
|
||||||
**/
|
**/
|
||||||
void setMenu( KMenu *menu );
|
void setMenu(KMenu *menu);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Returns true if this action creates a delayed popup menu
|
* Returns true if this action creates a delayed popup menu
|
||||||
|
|
|
@ -49,7 +49,7 @@ public:
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
|
||||||
void init();
|
void init();
|
||||||
|
|
||||||
void _k_subActionTriggered(QAction*);
|
void _k_subActionTriggered(QAction*);
|
||||||
|
|
||||||
|
|
|
@ -40,61 +40,64 @@
|
||||||
class KPasteTextActionPrivate
|
class KPasteTextActionPrivate
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
KPasteTextActionPrivate(KPasteTextAction *parent)
|
KPasteTextActionPrivate(KPasteTextAction *parent)
|
||||||
: q(parent)
|
: q(parent)
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
|
||||||
~KPasteTextActionPrivate()
|
~KPasteTextActionPrivate()
|
||||||
{
|
{
|
||||||
delete m_popup;
|
delete m_popup;
|
||||||
}
|
}
|
||||||
|
|
||||||
void _k_menuAboutToShow();
|
void _k_menuAboutToShow();
|
||||||
void _k_slotTriggered(QAction*);
|
void _k_slotTriggered(QAction*);
|
||||||
|
|
||||||
void init();
|
void init();
|
||||||
|
|
||||||
KPasteTextAction *q;
|
KPasteTextAction *q;
|
||||||
KMenu *m_popup;
|
KMenu *m_popup;
|
||||||
bool m_mixedMode;
|
bool m_mixedMode;
|
||||||
};
|
};
|
||||||
|
|
||||||
KPasteTextAction::KPasteTextAction(QObject *parent)
|
KPasteTextAction::KPasteTextAction(QObject *parent)
|
||||||
: KAction(parent), d(new KPasteTextActionPrivate(this))
|
: KAction(parent),
|
||||||
|
d(new KPasteTextActionPrivate(this))
|
||||||
{
|
{
|
||||||
d->init();
|
d->init();
|
||||||
}
|
}
|
||||||
|
|
||||||
KPasteTextAction::KPasteTextAction(const QString &text, QObject *parent)
|
KPasteTextAction::KPasteTextAction(const QString &text, QObject *parent)
|
||||||
: KAction(parent), d(new KPasteTextActionPrivate(this))
|
: KAction(parent),
|
||||||
|
d(new KPasteTextActionPrivate(this))
|
||||||
{
|
{
|
||||||
d->init();
|
d->init();
|
||||||
setText(text);
|
setText(text);
|
||||||
}
|
}
|
||||||
|
|
||||||
KPasteTextAction::KPasteTextAction(const KIcon &icon, const QString &text, QObject *parent)
|
KPasteTextAction::KPasteTextAction(const KIcon &icon, const QString &text, QObject *parent)
|
||||||
: KAction(icon, text, parent), d(new KPasteTextActionPrivate(this))
|
: KAction(icon, text, parent),
|
||||||
|
d(new KPasteTextActionPrivate(this))
|
||||||
{
|
{
|
||||||
d->init();
|
d->init();
|
||||||
}
|
}
|
||||||
|
|
||||||
void KPasteTextActionPrivate::init()
|
void KPasteTextActionPrivate::init()
|
||||||
{
|
{
|
||||||
m_popup = new KMenu;
|
m_popup = new KMenu();
|
||||||
q->connect(m_popup, SIGNAL(aboutToShow()), q, SLOT(_k_menuAboutToShow()));
|
q->connect(m_popup, SIGNAL(aboutToShow()), q, SLOT(_k_menuAboutToShow()));
|
||||||
q->connect(m_popup, SIGNAL(triggered(QAction*)), q, SLOT(_k_slotTriggered(QAction*)));
|
q->connect(m_popup, SIGNAL(triggered(QAction*)), q, SLOT(_k_slotTriggered(QAction*)));
|
||||||
m_mixedMode = true;
|
m_mixedMode = true;
|
||||||
}
|
}
|
||||||
|
|
||||||
KPasteTextAction::~KPasteTextAction()
|
KPasteTextAction::~KPasteTextAction()
|
||||||
{
|
{
|
||||||
delete d;
|
delete d;
|
||||||
}
|
}
|
||||||
|
|
||||||
void KPasteTextAction::setMixedMode(bool mode)
|
void KPasteTextAction::setMixedMode(bool mode)
|
||||||
{
|
{
|
||||||
d->m_mixedMode = mode;
|
d->m_mixedMode = mode;
|
||||||
}
|
}
|
||||||
|
|
||||||
void KPasteTextActionPrivate::_k_menuAboutToShow()
|
void KPasteTextActionPrivate::_k_menuAboutToShow()
|
||||||
|
@ -103,25 +106,25 @@ void KPasteTextActionPrivate::_k_menuAboutToShow()
|
||||||
QStringList list;
|
QStringList list;
|
||||||
QDBusInterface klipper("org.kde.klipper", "/klipper", "org.kde.klipper.klipper");
|
QDBusInterface klipper("org.kde.klipper", "/klipper", "org.kde.klipper.klipper");
|
||||||
if (klipper.isValid()) {
|
if (klipper.isValid()) {
|
||||||
QDBusReply<QStringList> reply = klipper.call("getClipboardHistoryMenu");
|
QDBusReply<QStringList> reply = klipper.call("getClipboardHistoryMenu");
|
||||||
if (reply.isValid())
|
if (reply.isValid()) {
|
||||||
list = reply;
|
list = reply;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
QString clipboardText = qApp->clipboard()->text(QClipboard::Clipboard);
|
QString clipboardText = qApp->clipboard()->text(QClipboard::Clipboard);
|
||||||
if (list.isEmpty())
|
if (list.isEmpty()) {
|
||||||
list << clipboardText;
|
list << clipboardText;
|
||||||
|
}
|
||||||
bool found = false;
|
bool found = false;
|
||||||
const QFontMetrics fm = m_popup->fontMetrics();
|
const QFontMetrics fm = m_popup->fontMetrics();
|
||||||
foreach (const QString& string, list)
|
foreach (const QString &string, list) {
|
||||||
{
|
QString text = fm.elidedText(string.simplified(), Qt::ElideMiddle, fm.maxWidth() * 20);
|
||||||
QString text = fm.elidedText(string.simplified(), Qt::ElideMiddle, fm.maxWidth() * 20);
|
text.replace('&', "&&");
|
||||||
text.replace('&', "&&");
|
QAction* action = m_popup->addAction(text);
|
||||||
QAction* action = m_popup->addAction(text);
|
if (!found && string == clipboardText) {
|
||||||
if (!found && string == clipboardText)
|
action->setChecked(true);
|
||||||
{
|
found = true;
|
||||||
action->setChecked(true);
|
}
|
||||||
found = true;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -129,18 +132,16 @@ void KPasteTextActionPrivate::_k_slotTriggered(QAction* action)
|
||||||
{
|
{
|
||||||
QDBusInterface klipper("org.kde.klipper", "/klipper", "org.kde.klipper.klipper");
|
QDBusInterface klipper("org.kde.klipper", "/klipper", "org.kde.klipper.klipper");
|
||||||
if (klipper.isValid()) {
|
if (klipper.isValid()) {
|
||||||
QDBusReply<QString> reply = klipper.call("getClipboardHistoryItem",
|
QDBusReply<QString> reply = klipper.call("getClipboardHistoryItem", m_popup->actions().indexOf(action));
|
||||||
m_popup->actions().indexOf(action));
|
if (!reply.isValid()) {
|
||||||
if (!reply.isValid())
|
return;
|
||||||
return;
|
}
|
||||||
QString clipboardText = reply;
|
QString clipboardText = reply;
|
||||||
reply = klipper.call("setClipboardContents", clipboardText);
|
reply = klipper.call("setClipboardContents", clipboardText);
|
||||||
if (reply.isValid())
|
if (reply.isValid()) {
|
||||||
kDebug(129) << "Clipboard: " << qApp->clipboard()->text(QClipboard::Clipboard);
|
kDebug(129) << "Clipboard: " << qApp->clipboard()->text(QClipboard::Clipboard);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/* vim: et sw=2 ts=2
|
|
||||||
*/
|
|
||||||
|
|
||||||
#include "moc_kpastetextaction.cpp"
|
#include "moc_kpastetextaction.cpp"
|
||||||
|
|
|
@ -50,6 +50,8 @@ public:
|
||||||
*/
|
*/
|
||||||
explicit KPasteTextAction(QObject *parent);
|
explicit KPasteTextAction(QObject *parent);
|
||||||
|
|
||||||
|
virtual ~KPasteTextAction();
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Constructs an action with text; a shortcut may be specified by
|
* Constructs an action with text; a shortcut may be specified by
|
||||||
* the ampersand character (e.g. \"&Option\" creates a shortcut with key \e O )
|
* the ampersand character (e.g. \"&Option\" creates a shortcut with key \e O )
|
||||||
|
@ -77,8 +79,6 @@ public:
|
||||||
*/
|
*/
|
||||||
KPasteTextAction(const KIcon &icon, const QString &text, QObject *parent);
|
KPasteTextAction(const KIcon &icon, const QString &text, QObject *parent);
|
||||||
|
|
||||||
virtual ~KPasteTextAction();
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Controls the behavior of the clipboard history menu popup.
|
* Controls the behavior of the clipboard history menu popup.
|
||||||
*
|
*
|
||||||
|
@ -94,8 +94,8 @@ public:
|
||||||
private:
|
private:
|
||||||
KPasteTextActionPrivate * const d;
|
KPasteTextActionPrivate * const d;
|
||||||
|
|
||||||
Q_PRIVATE_SLOT( d, void _k_menuAboutToShow() )
|
Q_PRIVATE_SLOT(d, void _k_menuAboutToShow())
|
||||||
Q_PRIVATE_SLOT( d, void _k_slotTriggered(QAction*) )
|
Q_PRIVATE_SLOT(d, void _k_slotTriggered(QAction*))
|
||||||
};
|
};
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
|
Loading…
Add table
Reference in a new issue