[prev in list] [next in list] [prev in thread] [next in thread]
List: kde-commits
Subject: [calligra/frameworks] libs/flake: convert KAction to QAction
From: Sven Langkamp <sven.langkamp () gmail ! com>
Date: 2015-03-28 20:21:35
Message-ID: E1YbxEd-0002eR-5v () scm ! kde ! org
[Download RAW message or body]
Git commit 1031b4471fc46e202cb14227d29ebbc3af2d13fb by Sven Langkamp.
Committed on 28/03/2015 at 20:16.
Pushed by langkamp into branch 'frameworks'.
convert KAction to QAction
M +7 -7 libs/flake/KoToolBase.cpp
M +4 -4 libs/flake/KoToolBase.h
M +3 -3 libs/flake/KoToolBase_p.h
M +19 -19 libs/flake/KoToolManager.cpp
M +1 -1 libs/flake/KoToolManager_p.cpp
M +2 -2 libs/flake/KoToolManager_p.h
M +2 -2 libs/flake/KoToolProxy.cpp
M +2 -2 libs/flake/KoToolProxy.h
M +15 -15 libs/flake/tools/KoPathTool.cpp
M +15 -15 libs/flake/tools/KoPathTool.h
M +1 -1 libs/flake/tools/PathToolOptionWidget.cpp
http://commits.kde.org/calligra/1031b4471fc46e202cb14227d29ebbc3af2d13fb
diff --git a/libs/flake/KoToolBase.cpp b/libs/flake/KoToolBase.cpp
index 0a69e2d..b22ccc7 100644
--- a/libs/flake/KoToolBase.cpp
+++ b/libs/flake/KoToolBase.cpp
@@ -20,7 +20,7 @@
#include <QDebug>
-#include <kaction.h>
+#include <QAction>
#include "KoToolBase.h"
#include "KoToolBase_p.h"
@@ -69,7 +69,7 @@ KoToolBase::~KoToolBase()
// doc.appendChild(e);
// foreach(QAction *ac, d->actionCollection.values()) {
-// KAction *action = qobject_cast<KAction*>(ac);
+// QAction *action = qobject_cast<QAction*>(ac);
// if (action) {
// QDomElement a = doc.createElement("Action");
// a.setAttribute("name", action->objectName());
@@ -78,8 +78,8 @@ KoToolBase::~KoToolBase()
// a.setAttribute("whatsThis" , action->whatsThis());
// a.setAttribute("toolTip" , action->toolTip());
// a.setAttribute("iconText" , action->iconText());
-// a.setAttribute("shortcut" , \
action->shortcut(KAction::ActiveShortcut).toString());
-// a.setAttribute("defaultShortcut" , \
action->shortcut(KAction::DefaultShortcut).toString()); +// \
a.setAttribute("shortcut" , action->shortcut(QAction::ActiveShortcut).toString()); \
+// a.setAttribute("defaultShortcut" , \
action->shortcut(QAction::DefaultShortcut).toString()); // \
a.setAttribute("isCheckable" , QString((action->isChecked() ? "true" : "false"))); \
// a.setAttribute("statusTip", action->statusTip()); // \
e.appendChild(a); @@ -225,7 +225,7 @@ QList<QPointer<QWidget> > \
KoToolBase::optionWidgets() return d->optionWidgets;
}
-void KoToolBase::addAction(const QString &name, KAction *action)
+void KoToolBase::addAction(const QString &name, QAction *action)
{
Q_D(KoToolBase);
if (action->objectName().isEmpty()) {
@@ -234,13 +234,13 @@ void KoToolBase::addAction(const QString &name, KAction \
*action) d->actionCollection.insert(name, action);
}
-QHash<QString, KAction*> KoToolBase::actions() const
+QHash<QString, QAction *> KoToolBase::actions() const
{
Q_D(const KoToolBase);
return d->actionCollection;
}
-KAction *KoToolBase::action(const QString &name) const
+QAction *KoToolBase::action(const QString &name) const
{
Q_D(const KoToolBase);
return d->actionCollection.value(name);
diff --git a/libs/flake/KoToolBase.h b/libs/flake/KoToolBase.h
index 13828c1..810ffe5 100644
--- a/libs/flake/KoToolBase.h
+++ b/libs/flake/KoToolBase.h
@@ -36,7 +36,7 @@ class KoToolSelection;
class KoToolBasePrivate;
class KoShapeBasedDocumentBase;
-class KAction;
+class QAction;
class QAction;
class QKeyEvent;
class QWidget;
@@ -119,12 +119,12 @@ public:
/**
* Retrieves the entire collection of actions for the tool.
*/
- QHash<QString, KAction*> actions() const;
+ QHash<QString, QAction *> actions() const;
/**
* Retrieve an action by name.
*/
- KAction *action(const QString &name) const;
+ QAction *action(const QString &name) const;
/**
* Called when (one of) the mouse or stylus buttons is pressed.
@@ -458,7 +458,7 @@ protected:
* @param readWrite set this to ReadOnlyAction to keep the action available on
* read-only documents
*/
- void addAction(const QString &name, KAction *action);
+ void addAction(const QString &name, QAction *action);
/**
* Set the list of actions to be used as popup menu.
diff --git a/libs/flake/KoToolBase_p.h b/libs/flake/KoToolBase_p.h
index 991f25c..d8eaa34 100644
--- a/libs/flake/KoToolBase_p.h
+++ b/libs/flake/KoToolBase_p.h
@@ -34,7 +34,7 @@
#include <string.h> // for the qt version check
class QWidget;
-class KAction;
+class QAction;
class KoToolBase;
class KoCanvasBase;
@@ -80,10 +80,10 @@ public:
QList<QPointer<QWidget> > optionWidgets; ///< the optionwidgets associated with \
this tool QCursor currentCursor;
- QHash<QString, KAction*> actionCollection;
+ QHash<QString, QAction *> actionCollection;
QString toolId;
QList<QAction*> popupActionList;
- QSet<KAction*> readOnlyActions;
+ QSet<QAction *> readOnlyActions;
KoToolBase *q;
KoCanvasBase *canvas; ///< the canvas interface this tool will work for.
bool isInTextMode;
diff --git a/libs/flake/KoToolManager.cpp b/libs/flake/KoToolManager.cpp
index fece31b..5402fb1 100644
--- a/libs/flake/KoToolManager.cpp
+++ b/libs/flake/KoToolManager.cpp
@@ -55,7 +55,7 @@
#include <kactioncollection.h>
#include <kdebug.h>
#include <kglobal.h>
-#include <kaction.h>
+#include <QAction>
#include <klocale.h>
#include <QStack>
#include <QLabel>
@@ -89,16 +89,16 @@ public:
// 3. replace conflicting actions in the action collection
KActionCollection *canvasActionCollection = canvas->actionCollection();
- QHash<QString, KAction*> toolActions = activeTool->actions();
- QHash<QString, KAction*>::const_iterator it(toolActions.constBegin());
+ QHash<QString, QAction *> toolActions = activeTool->actions();
+ QHash<QString, QAction *>::const_iterator it(toolActions.constBegin());
for (; it != toolActions.constEnd(); ++it) {
if (canvasActionCollection) {
QString toolActionID = it.key();
- KAction *toolAction = it.value();
+ QAction *toolAction = it.value();
- KAction* action = \
qobject_cast<KAction*>(canvasActionCollection->action(it.key())); + \
QAction * action = qobject_cast<QAction*>(canvasActionCollection->action(it.key())); \
if (action) { canvasActionCollection->takeAction(action);
if (action != it.value()) {
@@ -111,7 +111,7 @@ public:
}
}
foreach(QAction *a, canvasActionCollection->actions()) {
- KAction *canvasAction = dynamic_cast<KAction*>(a);
+ QAction *canvasAction = dynamic_cast<QAction*>(a);
if (canvasAction && canvasAction->shortcut().toString() != "" && \
canvasAction->shortcut() == toolAction->shortcut()) { kWarning() << activeToolId << \
": action" << toolActionID << "conflicts with canvas action" << \
canvasAction->objectName() << "shortcut:" << \
canvasAction->shortcut().toString();
disabledCanvasShortcuts[canvasAction] = \
canvasAction->shortcut().toString(); @@ -131,14 +131,14 @@ public:
if (!activeTool)
return;
// disable actions of active tool
- foreach(KAction *action, activeTool->actions()) {
+ foreach(QAction *action, activeTool->actions()) {
action->setEnabled(false);
}
// enable actions which where disabled on activating the active tool
// and re-add them to the action collection
KActionCollection *ac = canvas->actionCollection();
- foreach(QPointer<KAction> action, disabledDisabledActions) {
+ foreach(QPointer<QAction> action, disabledDisabledActions) {
if (action) {
if (ac) {
ac->addAction(action->objectName(), action);
@@ -147,7 +147,7 @@ public:
}
disabledDisabledActions.clear();
- foreach(QPointer<KAction> action, disabledActions) {
+ foreach(QPointer<QAction> action, disabledActions) {
if (action) {
action->setEnabled(true);
if(ac) {
@@ -157,9 +157,9 @@ public:
}
disabledActions.clear();
- QMap<QPointer<KAction>, QString>::const_iterator \
it(disabledCanvasShortcuts.constBegin()); + QMap<QPointer<QAction>, \
QString>::const_iterator it(disabledCanvasShortcuts.constBegin()); for (; it != \
disabledCanvasShortcuts.constEnd(); ++it) {
- KAction *action = it.key();
+ QAction *action = it.key();
QString shortcut = it.value();
action->setShortcut(shortcut);
}
@@ -175,9 +175,9 @@ public:
const KoInputDevice inputDevice;
QWidget *dummyToolWidget; // the widget shown in the toolDocker.
QLabel *dummyToolLabel;
- QList<QPointer<KAction> > disabledActions; ///< disabled conflicting actions
- QList<QPointer<KAction> > disabledDisabledActions; ///< disabled conflicting \
actions that were already disabled
- QMap<QPointer<KAction>, QString> disabledCanvasShortcuts; ///< Shortcuts that \
were temporarily removed from canvas actions because the tool overrides + \
QList<QPointer<QAction> > disabledActions; ///< disabled conflicting actions + \
QList<QPointer<QAction> > disabledDisabledActions; ///< disabled conflicting actions \
that were already disabled + QMap<QPointer<QAction>, QString> \
disabledCanvasShortcuts; ///< Shortcuts that were temporarily removed from canvas \
actions because the tool overrides };
KoToolManager::Private::Private(KoToolManager *qq)
@@ -674,7 +674,7 @@ void KoToolManager::Private::switchInputDevice(const \
KoInputDevice &device)
// disable all actions for all tools in the all canvasdata objects for this \
canvas. foreach(CanvasData *cd, items) {
foreach(KoToolBase* tool, cd->allTools) {
- foreach(KAction* action, tool->actions()) {
+ foreach(QAction * action, tool->actions()) {
action->setEnabled(false);
}
}
@@ -790,8 +790,8 @@ void KoToolManager::registerTools(KActionCollection *ac, \
KoCanvasController *con
CanvasData *cd = d->canvasses.value(controller).first();
foreach(KoToolBase *tool, cd->allTools) {
- QHash<QString, KAction*> actions = tool->actions();
- QHash<QString, KAction*>::const_iterator it(actions.constBegin());
+ QHash<QString, QAction *> actions = tool->actions();
+ QHash<QString, QAction *>::const_iterator it(actions.constBegin());
for (; it != actions.constEnd(); ++it) {
if (!ac->action(it.key()))
ac->addAction(it.key(), it.value());
@@ -799,7 +799,7 @@ void KoToolManager::registerTools(KActionCollection *ac, \
KoCanvasController *con }
foreach(ToolHelper * th, d->tools) {
ToolAction* action = new ToolAction(this, th->id(), th->toolTip(), ac);
- action->setShortcut(th->shortcut());
+ action->setShortcut(th->shortcut().primary());
ac->addAction(th->id(), action);
}
}
@@ -1010,7 +1010,7 @@ QPair<QString, KoToolBase*> \
KoToolManager::createTools(KoCanvasController *contr
tl->setObjectName(tool->id());
- foreach(KAction *action, tl->actions()) {
+ foreach(QAction *action, tl->actions()) {
action->setEnabled(false);
}
diff --git a/libs/flake/KoToolManager_p.cpp b/libs/flake/KoToolManager_p.cpp
index 8a903fd..f770646 100644
--- a/libs/flake/KoToolManager_p.cpp
+++ b/libs/flake/KoToolManager_p.cpp
@@ -104,7 +104,7 @@ void Connector::selectionChanged()
// ************ ToolAction **********
ToolAction::ToolAction(KoToolManager* toolManager, QString id, QString name, QObject \
*parent)
- : KAction(name, parent),
+ : QAction(name, parent),
m_toolManager(toolManager),
m_toolID(id)
{
diff --git a/libs/flake/KoToolManager_p.h b/libs/flake/KoToolManager_p.h
index 19bb972..e8e5cb9 100644
--- a/libs/flake/KoToolManager_p.h
+++ b/libs/flake/KoToolManager_p.h
@@ -29,7 +29,7 @@
#include "KoInputDevice.h"
#include "KoToolManager.h"
-#include <kaction.h>
+#include <QAction>
class KoToolFactoryBase;
class KoShapeManager;
@@ -162,7 +162,7 @@ private:
/// \internal
/// Helper class to provide a action for tool shortcuts
-class ToolAction : public KAction
+class ToolAction : public QAction
{
Q_OBJECT
public:
diff --git a/libs/flake/KoToolProxy.cpp b/libs/flake/KoToolProxy.cpp
index 9528393..4aaff63 100644
--- a/libs/flake/KoToolProxy.cpp
+++ b/libs/flake/KoToolProxy.cpp
@@ -506,9 +506,9 @@ void KoToolProxyPrivate::setCanvasController(KoCanvasController \
*c) controller = c;
}
-QHash<QString, KAction*> KoToolProxy::actions() const
+QHash<QString, QAction *> KoToolProxy::actions() const
{
- return d->activeTool ? d->activeTool->actions() : QHash<QString, KAction*>();
+ return d->activeTool ? d->activeTool->actions() : QHash<QString, QAction *>();
}
bool KoToolProxy::hasSelection() const
diff --git a/libs/flake/KoToolProxy.h b/libs/flake/KoToolProxy.h
index a88ff7f..4f82af6 100644
--- a/libs/flake/KoToolProxy.h
+++ b/libs/flake/KoToolProxy.h
@@ -26,7 +26,7 @@
#include <QObject>
#include <QHash>
-class KAction;
+class QAction;
class QAction;
class QMouseEvent;
class QKeyEvent;
@@ -129,7 +129,7 @@ public:
* Retrieves the entire collection of actions for the active tool
* or an empty hash if there is no active tool yet.
*/
- QHash<QString, KAction*> actions() const;
+ QHash<QString, QAction *> actions() const;
/// returns true if the current tool holds a selection
bool hasSelection() const;
diff --git a/libs/flake/tools/KoPathTool.cpp b/libs/flake/tools/KoPathTool.cpp
index b985e4a..130d636 100644
--- a/libs/flake/tools/KoPathTool.cpp
+++ b/libs/flake/tools/KoPathTool.cpp
@@ -52,7 +52,7 @@
#include <KoIcon.h>
-#include <kaction.h>
+#include <QAction>
#include <kdebug.h>
#include <klocale.h>
#include <QPainter>
@@ -106,67 +106,67 @@ KoPathTool::KoPathTool(KoCanvasBase *canvas)
{
QActionGroup *points = new QActionGroup(this);
// m_pointTypeGroup->setExclusive(true);
- m_actionPathPointCorner = new KAction(koIcon("pathpoint-corner"), i18n("Corner \
point"), this); + m_actionPathPointCorner = new \
QAction(koIcon("pathpoint-corner"), i18n("Corner point"), this); \
addAction("pathpoint-corner", m_actionPathPointCorner); \
m_actionPathPointCorner->setData(KoPathPointTypeCommand::Corner); \
points->addAction(m_actionPathPointCorner);
- m_actionPathPointSmooth = new KAction(koIcon("pathpoint-smooth"), i18n("Smooth \
point"), this); + m_actionPathPointSmooth = new \
QAction(koIcon("pathpoint-smooth"), i18n("Smooth point"), this); \
addAction("pathpoint-smooth", m_actionPathPointSmooth); \
m_actionPathPointSmooth->setData(KoPathPointTypeCommand::Smooth); \
points->addAction(m_actionPathPointSmooth);
- m_actionPathPointSymmetric = new KAction(koIcon("pathpoint-symmetric"), \
i18n("Symmetric Point"), this); + m_actionPathPointSymmetric = new \
QAction(koIcon("pathpoint-symmetric"), i18n("Symmetric Point"), this); \
addAction("pathpoint-symmetric", m_actionPathPointSymmetric);
m_actionPathPointSymmetric->setData(KoPathPointTypeCommand::Symmetric);
points->addAction(m_actionPathPointSymmetric);
- m_actionCurvePoint = new KAction(koIcon("pathpoint-curve"), i18n("Make curve \
point"), this); + m_actionCurvePoint = new QAction(koIcon("pathpoint-curve"), \
i18n("Make curve point"), this); addAction("pathpoint-curve", m_actionCurvePoint);
connect(m_actionCurvePoint, SIGNAL(triggered()), this, SLOT(pointToCurve()));
- m_actionLinePoint = new KAction(koIcon("pathpoint-line"), i18n("Make line \
point"), this); + m_actionLinePoint = new QAction(koIcon("pathpoint-line"), \
i18n("Make line point"), this); addAction("pathpoint-line", m_actionLinePoint);
connect(m_actionLinePoint, SIGNAL(triggered()), this, SLOT(pointToLine()));
- m_actionLineSegment = new KAction(koIcon("pathsegment-line"), i18n("Segment to \
Line"), this); + m_actionLineSegment = new QAction(koIcon("pathsegment-line"), \
i18n("Segment to Line"), this); m_actionLineSegment->setShortcut(Qt::Key_F);
addAction("pathsegment-line", m_actionLineSegment);
connect(m_actionLineSegment, SIGNAL(triggered()), this, SLOT(segmentToLine()));
- m_actionCurveSegment = new KAction(koIcon("pathsegment-curve"), i18n("Segment to \
Curve"), this); + m_actionCurveSegment = new QAction(koIcon("pathsegment-curve"), \
i18n("Segment to Curve"), this); m_actionCurveSegment->setShortcut(Qt::Key_C);
addAction("pathsegment-curve", m_actionCurveSegment);
connect(m_actionCurveSegment, SIGNAL(triggered()), this, \
SLOT(segmentToCurve()));
- m_actionAddPoint = new KAction(koIcon("pathpoint-insert"), i18n("Insert point"), \
this); + m_actionAddPoint = new QAction(koIcon("pathpoint-insert"), i18n("Insert \
point"), this); addAction("pathpoint-insert", m_actionAddPoint);
m_actionAddPoint->setShortcut(Qt::Key_Insert);
connect(m_actionAddPoint, SIGNAL(triggered()), this, SLOT(insertPoints()));
- m_actionRemovePoint = new KAction(koIcon("pathpoint-remove"), i18n("Remove \
point"), this); + m_actionRemovePoint = new QAction(koIcon("pathpoint-remove"), \
i18n("Remove point"), this); m_actionRemovePoint->setShortcut(Qt::Key_Backspace);
addAction("pathpoint-remove", m_actionRemovePoint);
connect(m_actionRemovePoint, SIGNAL(triggered()), this, SLOT(removePoints()));
- m_actionBreakPoint = new KAction(koIcon("path-break-point"), i18n("Break at \
point"), this); + m_actionBreakPoint = new QAction(koIcon("path-break-point"), \
i18n("Break at point"), this); addAction("path-break-point", m_actionBreakPoint);
connect(m_actionBreakPoint, SIGNAL(triggered()), this, SLOT(breakAtPoint()));
- m_actionBreakSegment = new KAction(koIcon("path-break-segment"), i18n("Break at \
segment"), this); + m_actionBreakSegment = new \
QAction(koIcon("path-break-segment"), i18n("Break at segment"), this); \
addAction("path-break-segment", m_actionBreakSegment);
connect(m_actionBreakSegment, SIGNAL(triggered()), this, \
SLOT(breakAtSegment()));
- m_actionJoinSegment = new KAction(koIcon("pathpoint-join"), i18n("Join with \
segment"), this); + m_actionJoinSegment = new QAction(koIcon("pathpoint-join"), \
i18n("Join with segment"), this); m_actionJoinSegment->setShortcut(Qt::Key_J);
addAction("pathpoint-join", m_actionJoinSegment);
connect(m_actionJoinSegment, SIGNAL(triggered()), this, SLOT(joinPoints()));
- m_actionMergePoints = new KAction(koIcon("pathpoint-merge"), i18n("Merge \
points"), this); + m_actionMergePoints = new QAction(koIcon("pathpoint-merge"), \
i18n("Merge points"), this); addAction("pathpoint-merge", m_actionMergePoints);
connect(m_actionMergePoints, SIGNAL(triggered()), this, SLOT(mergePoints()));
- m_actionConvertToPath = new KAction(koIcon("convert-to-path"), i18n("To Path"), \
this); + m_actionConvertToPath = new QAction(koIcon("convert-to-path"), i18n("To \
Path"), this); m_actionConvertToPath->setShortcut(Qt::Key_P);
addAction("convert-to-path", m_actionConvertToPath);
connect(m_actionConvertToPath, SIGNAL(triggered()), this, \
SLOT(convertToPath()));
diff --git a/libs/flake/tools/KoPathTool.h b/libs/flake/tools/KoPathTool.h
index b12e0a2..8b03115 100644
--- a/libs/flake/tools/KoPathTool.h
+++ b/libs/flake/tools/KoPathTool.h
@@ -35,7 +35,7 @@ class KoInteractionStrategy;
class KoPathToolHandle;
class KoParameterShape;
-class KAction;
+class QAction;
/// The tool for editing a KoPathShape or a KoParameterShape
class FLAKE_TEST_EXPORT KoPathTool : public KoToolBase
@@ -129,20 +129,20 @@ private:
QButtonGroup *m_pointTypeGroup;
- KAction *m_actionPathPointCorner;
- KAction *m_actionPathPointSmooth;
- KAction *m_actionPathPointSymmetric;
- KAction *m_actionCurvePoint;
- KAction *m_actionLinePoint;
- KAction *m_actionLineSegment;
- KAction *m_actionCurveSegment;
- KAction *m_actionAddPoint;
- KAction *m_actionRemovePoint;
- KAction *m_actionBreakPoint;
- KAction *m_actionBreakSegment;
- KAction *m_actionJoinSegment;
- KAction *m_actionMergePoints;
- KAction *m_actionConvertToPath;
+ QAction *m_actionPathPointCorner;
+ QAction *m_actionPathPointSmooth;
+ QAction *m_actionPathPointSymmetric;
+ QAction *m_actionCurvePoint;
+ QAction *m_actionLinePoint;
+ QAction *m_actionLineSegment;
+ QAction *m_actionCurveSegment;
+ QAction *m_actionAddPoint;
+ QAction *m_actionRemovePoint;
+ QAction *m_actionBreakPoint;
+ QAction *m_actionBreakSegment;
+ QAction *m_actionJoinSegment;
+ QAction *m_actionMergePoints;
+ QAction *m_actionConvertToPath;
QCursor m_moveCursor;
Q_DECLARE_PRIVATE(KoToolBase)
diff --git a/libs/flake/tools/PathToolOptionWidget.cpp \
b/libs/flake/tools/PathToolOptionWidget.cpp index c19ad06..73c6dc6 100644
--- a/libs/flake/tools/PathToolOptionWidget.cpp
+++ b/libs/flake/tools/PathToolOptionWidget.cpp
@@ -19,7 +19,7 @@
#include "PathToolOptionWidget.h"
#include "KoPathTool.h"
-#include <kaction.h>
+#include <QAction>
PathToolOptionWidget::PathToolOptionWidget(KoPathTool *tool, QWidget *parent)
: QWidget(parent)
[prev in list] [next in list] [prev in thread] [next in thread]
Configure |
About |
News |
Add a list |
Sponsored by KoreLogic