Commit e3cc390e authored by Felix Ernst's avatar Felix Ernst 🇺🇦
Browse files

Delete custom kpToolAction class

This commit has no user-visible effect.

This commit deletes the kpToolAction class which is a KolourPaint-
specific subclass of KToggleAction.

kpToolAction used to have the specialised functionality of creating
a custom tooltip that showed the keyboard shortcut but this
functionality was removed in the previous commit because it
became redundant thanks to a frameworks change.

Because of this there is no reason left to keep this subclass
around. Instead its base class KToggleAction is used everywhere.
parent 906b97b4
Pipeline #208355 passed with stage
in 1 minute and 40 seconds
......@@ -215,7 +215,6 @@ set(kolourpaint_lib2_SRCS
${CMAKE_CURRENT_SOURCE_DIR}/tools/flow/kpToolFlowPixmapBase.cpp
${CMAKE_CURRENT_SOURCE_DIR}/tools/flow/kpToolPen.cpp
${CMAKE_CURRENT_SOURCE_DIR}/tools/flow/kpToolSpraycan.cpp
${CMAKE_CURRENT_SOURCE_DIR}/tools/kpToolAction.cpp
${CMAKE_CURRENT_SOURCE_DIR}/tools/kpToolColorPicker.cpp
${CMAKE_CURRENT_SOURCE_DIR}/tools/kpTool.cpp
${CMAKE_CURRENT_SOURCE_DIR}/tools/kpTool_Drawing.cpp
......
......@@ -40,7 +40,6 @@
#include "kpDefs.h"
#include "document/kpDocument.h"
#include "tools/kpToolAction.h"
#include "widgets/toolbars/kpToolToolBar.h"
#include "environments/tools/kpToolEnvironment.h"
......
......@@ -43,7 +43,6 @@
#include "document/kpDocument.h"
#include "layers/selections/image/kpImageSelectionTransparency.h"
#include "tools/kpTool.h"
#include "tools/kpToolAction.h"
#include "tools/flow/kpToolBrush.h"
#include "tools/flow/kpToolColorEraser.h"
#include "tools/kpToolColorPicker.h"
......@@ -242,7 +241,7 @@ void kpMainWindow::enableToolsDocumentActions (bool enable)
for (auto *tool : d->tools)
{
kpToolAction *action = tool->action();
KToggleAction *action = tool->action();
if (!enable && action->isChecked()) {
action->setChecked(false);
}
......
......@@ -41,7 +41,6 @@
#include "imagelib/kpColor.h"
#include "widgets/toolbars/kpColorToolBar.h"
#include "tools/kpToolAction.h"
#include "environments/tools/kpToolEnvironment.h"
#include "widgets/toolbars/kpToolToolBar.h"
#include "views/kpView.h"
......@@ -100,14 +99,16 @@ void kpTool::initAction ()
KActionCollection *ac = d->environ->actionCollection ();
Q_ASSERT (ac);
d->action = new kpToolAction(text(), objectName(), shortcutForKey(d->key),
this, SIGNAL(actionActivated()),
ac, objectName());
d->action = ac->add<KToggleAction>(objectName());
d->action->setText(text());
d->action->setWhatsThis(d->description);
d->action->setIcon(QIcon::fromTheme(objectName()));
ac->setDefaultShortcuts(d->action, shortcutForKey(d->key));
connect(d->action, &QAction::triggered, this, &kpTool::actionActivated);
// Make tools mutually exclusive by placing them in the same group.
d->action->setActionGroup(d->environ->toolsActionGroup ());
d->action->setWhatsThis(d->description);
}
//---------------------------------------------------------------------
......@@ -139,7 +140,7 @@ QList<QKeySequence> kpTool::shortcutForKey (int key)
//---------------------------------------------------------------------
// public
kpToolAction *kpTool::action () const
KToggleAction *kpTool::action () const
{
return d->action;
}
......
......@@ -50,12 +50,13 @@ class QMouseEvent;
class QImage;
class QWheelEvent;
class KToggleAction;
class kpColor;
class kpCommandHistory;
class kpDocument;
class kpView;
class kpViewManager;
class kpToolAction;
class kpToolEnvironment;
class kpToolToolBar;
......@@ -83,7 +84,7 @@ public:
QObject *parent, const QString &name);
~kpTool () override;
kpToolAction *action () const;
KToggleAction *action () const;
QString text () const;
......
/*
Copyright(c) 2003-2007 Clarence Dang <dang@kde.org>
Copyright(c) 2011 Martin Koller <kollix@aon.at>
All rights reserved.
Redistribution and use in source and binary forms, with or without
modification, are permitted provided that the following conditions
are met:
1. Redistributions of source code must retain the above copyright
notice, this list of conditions and the following disclaimer.
2. Redistributions in binary form must reproduce the above copyright
notice, this list of conditions and the following disclaimer in the
documentation and/or other materials provided with the distribution.
THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES(INCLUDING, BUT
NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/
#include "tools/kpToolAction.h"
#include <KActionCollection>
#include "tools/kpTool.h"
//---------------------------------------------------------------------
kpToolAction::kpToolAction(const QString &text,
const QString &pic, const QList<QKeySequence> &shortcut,
const QObject *receiver, const char *slot,
KActionCollection *ac, const QString &name)
: KToggleAction(QIcon::fromTheme(pic), text, ac)
{
ac->setDefaultShortcuts(this, shortcut);
if ( receiver && slot ) {
connect (this, SIGNAL(triggered(bool)), receiver, slot);
}
ac->addAction(name, this);
}
//---------------------------------------------------------------------
/*
Copyright (c) 2003-2007 Clarence Dang <dang@kde.org>
Copyright (c) 2011 Martin Koller <kollix@aon.at>
All rights reserved.
Redistribution and use in source and binary forms, with or without
modification, are permitted provided that the following conditions
are met:
1. Redistributions of source code must retain the above copyright
notice, this list of conditions and the following disclaimer.
2. Redistributions in binary form must reproduce the above copyright
notice, this list of conditions and the following disclaimer in the
documentation and/or other materials provided with the distribution.
THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/
#ifndef KP_TOOL_ACTION_H
#define KP_TOOL_ACTION_H
#include <KToggleAction>
class KActionCollection;
// Same as KToggleAction but shows the first single key trigger in the tooltip.
class kpToolAction : public KToggleAction
{
Q_OBJECT
public:
kpToolAction(const QString &text,
const QString &pic, const QList<QKeySequence> &shortcut,
const QObject *receiver, const char *slot,
KActionCollection *ac, const QString &name);
};
#endif // KP_TOOL_ACTION_H
......@@ -39,9 +39,8 @@
#undef environ // macro on win32
#endif
class kpToolAction;
class kpToolEnvironment;
class KToggleAction;
struct kpToolPrivate
{
......@@ -50,7 +49,7 @@ struct kpToolPrivate
QString description;
int key;
kpToolAction *action;
KToggleAction *action;
// Drawing state.
bool began;
......
......@@ -36,13 +36,14 @@
#include "generic/kpSetOverrideCursorSaver.h"
#include "layers/tempImage/kpTempImage.h"
#include "environments/tools/kpToolEnvironment.h"
#include "tools/kpToolAction.h"
#include "views/manager/kpViewManager.h"
#include "kpLogCategories.h"
#include <QWidget>
#include <KLocalizedString>
#include <KToggleAction>
#include <QIcon>
#include <QWidget>
//---------------------------------------------------------------------
......
......@@ -52,7 +52,6 @@
#include "widgets/toolbars/kpColorToolBar.h"
#include "kpDefs.h"
#include "pixmapfx/kpPixmapFX.h"
#include "tools/kpToolAction.h"
#include "environments/tools/kpToolEnvironment.h"
#include "widgets/toolbars/kpToolToolBar.h"
#include "views/kpView.h"
......
......@@ -37,11 +37,12 @@
#include <QKeyEvent>
#include <QToolButton>
#include <KToggleAction>
#include "kpLogCategories.h"
#include "kpDefs.h"
#include "tools/kpTool.h"
#include "tools/kpToolAction.h"
#include "widgets/toolbars/options/kpToolWidgetBrush.h"
#include "widgets/toolbars/options/kpToolWidgetEraserSize.h"
#include "widgets/toolbars/options/kpToolWidgetFillStyle.h"
......@@ -327,7 +328,7 @@ void kpToolToolBar::slotToolButtonClicked ()
if (m_currentTool)
{
kpToolAction *action = m_currentTool->action ();
KToggleAction *action = m_currentTool->action ();
if (action)
{
action->setChecked (true);
......
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment