[calligra/calligra/2.9] libs/flake: Update tooltips to include keyboard shortcut.
Jaroslaw Staniek
staniek at kde.org
Wed Aug 19 18:27:02 BST 2015
Please enter calligra-devel in the cc, it shall auto complete to the list.
On Wednesday, 19 August 2015, C. Boemann <cbo at boemann.dk> wrote:
> Yeah well it is used as a label in words, stage, sheets and flow, so
adding
> extra text makes it spill over and possibly even becoming unreadable
(depends
> on the tool obviously). Also
>
> and by asap I mean before the next release - sorry if that came out a bit
> harsh.
>
> But just because krita has a feature request doesn't mean we should
> short circuit the review process. If phabricator can't send to all of
calligra
> then we must use reviewboard instead.
>
> On Wednesday 19 August 2015 12:37:16 you wrote:
>> Hi Camilla,
>>
>> Before we "ASAP" revert or make it conditional, I'd like to know _what_
the
>> problem is you see with this patch. And it's a bit difficult right now
who
>> to add individually to review request on Phabricator, but Friedrich was
>> also cc'ed on the change.
>>
>> Anyway, since this patch delivers a feature users have been asking for
since
>> 2006 or so, asking for an immediate revert without explaining what the
>> problem is goes way too far.
>>
>> On Wed, 19 Aug 2015, C. Boemann wrote:
>> > please revert or make it conditional for krita only ASAP
>> >
>> > And in the future please add the rest of calligra as reviewers on
commits
>> > to shared areas
>> >
>> > Camilla Boemann
>> >
>> > On Tuesday 18 August 2015 17:45:58 Michael Abrahams wrote:
>> >> Git commit 8a450ef60839cf77486d1bb9eb25b63ffcb1e468 by Michael
> Abrahams.
>> >> Committed on 18/08/2015 at 17:45.
>> >> Pushed by abrahams into branch 'calligra/2.9'.
>> >>
>> >> Update tooltips to include keyboard shortcut.
>> >>
>> >> Summary:
>> >> Tooltips will automatically change with changes to shorcuts.
>> >>
>> >> Ref T199
>> >> BUG: 348626
>> >>
>> >> Reviewers: dkazakov, rempt
>> >>
>> >> Maniphest Tasks: T199
>> >>
>> >> Differential Revision: https://phabricator.kde.org/D245
>> >>
>> >> M +9 -4 libs/flake/KoToolManager.cpp
>> >> M +1 -1 libs/flake/KoToolManager.h
>> >> M +41 -9 libs/flake/KoToolManager_p.cpp
>> >> M +9 -2 libs/flake/KoToolManager_p.h
>> >>
>> >>
http://commits.kde.org/calligra/8a450ef60839cf77486d1bb9eb25b63ffcb1e468
>> >>
>> >> diff --git a/libs/flake/KoToolManager.cpp
b/libs/flake/KoToolManager.cpp
>> >> index 61e194c..16f817f 100644
>> >> --- a/libs/flake/KoToolManager.cpp
>> >> +++ b/libs/flake/KoToolManager.cpp
>> >> @@ -788,19 +788,24 @@ void
KoToolManager::registerTools(KActionCollection
>> >> *ac, KoCanvasController *con return;
>> >>
>> >> }
>> >>
>> >> + // Actions available during the use of individual tools
>> >>
>> >> 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());
>> >> - for (; it != actions.constEnd(); ++it) {
>> >> - if (!ac->action(it.key()))
>> >> - ac->addAction(it.key(), it.value());
>> >> + QHash<QString, KAction*>::const_iterator
>> >> action(actions.constBegin()); + for (; action !=
>> >> actions.constEnd();
>> >> ++action) {
>> >> + if (!ac->action(action.key()))
>> >> + ac->addAction(action.key(), action.value());
>> >>
>> >> }
>> >>
>> >> }
>> >>
>> >> +
>> >> + // Actions used to switch tools; connect slot to keep button
>> >> tooltips
>> >> updated foreach(ToolHelper * th, d->tools) {
>> >>
>> >> ToolAction* action = new ToolAction(this, th->id(),
>> >> th->toolTip(),
>> >>
>> >> ac); action->setShortcut(th->shortcut());
>> >>
>> >> ac->addAction(th->id(), action);
>> >>
>> >> + th->setAction(action);
>> >> + connect(action, SIGNAL(changed()), th,
SLOT(actionUpdated()));
>> >>
>> >> }
>> >>
>> >> }
>> >>
>> >> diff --git a/libs/flake/KoToolManager.h b/libs/flake/KoToolManager.h
>> >> index 6567346..fa12272 100644
>> >> --- a/libs/flake/KoToolManager.h
>> >> +++ b/libs/flake/KoToolManager.h
>> >> @@ -44,7 +44,7 @@ class QCursor;
>> >>
>> >> /// Struct for the createToolList return type.
>> >> struct KoToolButton {
>> >>
>> >> - QToolButton *button;///< a newly created button.
>> >> + QToolButton *button; ///< a newly created button.
>> >>
>> >> QString section; ///< The section the button wants to be
in.
>> >> int priority; ///< Lower number (higher priority) means
>> >>
>> >> coming first in the section. int buttonGroupId; ///< An unique ID
>> >> for
>> >> this button as passed by changedTool() diff --git
>> >> a/libs/flake/KoToolManager_p.cpp b/libs/flake/KoToolManager_p.cpp
index
>> >> bb0ab1a..c4d7d08 100644
>> >> --- a/libs/flake/KoToolManager_p.cpp
>> >> +++ b/libs/flake/KoToolManager_p.cpp
>> >> @@ -25,24 +25,33 @@
>> >>
>> >> #include <KoToolFactoryBase.h>
>> >> #include <QToolButton>
>> >> #include <kicon.h>
>> >>
>> >> +#include <klocale.h>
>> >>
>> >> #include <QtGlobal> // for qrand()
>> >>
>> >> -// ************ ToolHelper **********
>> >> +/* ************ ToolHelper **********
>> >> + * This class wrangles the tool factory, toolbox button and
switch-tool
>> >> action + * for a single tool. It assumes the will continue to live
once
>> >> it
>> >> is created. + * (Hiding the toolbox is OK.)
>> >> + */
>> >> +
>> >>
>> >> ToolHelper::ToolHelper(KoToolFactoryBase *tool)
>> >>
>> >> + : m_toolFactory(tool),
>> >> + m_uniqueId((int)qrand()),
>> >> + button(0),
>> >> + action(0)
>> >>
>> >> {
>> >>
>> >> - m_toolFactory = tool;
>> >> - m_uniqueId = (int) qrand();
>> >>
>> >> }
>> >>
>> >> QToolButton* ToolHelper::createButton()
>> >> {
>> >>
>> >> - QToolButton *but = new QToolButton();
>> >> - but->setObjectName(m_toolFactory->id());
>> >> - but->setIcon(KIcon(m_toolFactory->iconName()));
>> >> - but->setToolTip(m_toolFactory->toolTip());
>> >> - connect(but, SIGNAL(clicked()), this, SLOT(buttonPressed()));
>> >> - return but;
>> >> + button = new QToolButton();
>> >> + button->setObjectName(m_toolFactory->id());
>> >> + button->setIcon(KIcon(m_toolFactory->iconName()));
>> >> + button->setToolTip(buttonToolTip());
>> >> +
>> >> + connect(button, SIGNAL(clicked()), this, SLOT(buttonPressed()));
>> >> + return button;
>> >>
>> >> }
>> >>
>> >> void ToolHelper::buttonPressed()
>> >>
>> >> @@ -65,6 +74,20 @@ QString ToolHelper::toolTip() const
>> >>
>> >> return m_toolFactory->toolTip();
>> >>
>> >> }
>> >>
>> >> +QString ToolHelper::buttonToolTip() const
>> >> +{
>> >> + return shortcut().isEmpty() ?
>> >> + i18nc("@info:tooltip", "%1", toolTip()) :
>> >> + i18nc("@info:tooltip %2 is shortcut", "%1 (%2)", toolTip(),
>> >> + shortcut().toString());
>> >> +}
>> >> +
>> >> +void ToolHelper::actionUpdated()
>> >> +{
>> >> + if (button)
>> >> + button->setToolTip(buttonToolTip());
>> >> +}
>> >> +
>> >>
>> >> KoToolBase *ToolHelper::createTool(KoCanvasBase *canvas) const
>> >> {
>> >>
>> >> KoToolBase *tool = m_toolFactory->createTool(canvas);
>> >>
>> >> @@ -86,9 +109,18 @@ int ToolHelper::priority() const
>> >>
>> >> KShortcut ToolHelper::shortcut() const
>> >> {
>> >>
>> >> + if (action) {
>> >> + return action->shortcut();
>> >> + }
>> >> +
>> >>
>> >> return m_toolFactory->shortcut();
>> >>
>> >> }
>> >>
>> >> +void ToolHelper::setAction(KAction *a)
>> >> +{
>> >> + action = a;
>> >> +}
>> >> +
>> >>
>> >> // ************ Connector **********
>> >> Connector::Connector(KoShapeManager *parent)
>> >>
>> >> : QObject(parent),
>> >>
>> >> diff --git a/libs/flake/KoToolManager_p.h
b/libs/flake/KoToolManager_p.h
>> >> index b8ce539..e7e1b0f 100644
>> >> --- a/libs/flake/KoToolManager_p.h
>> >> +++ b/libs/flake/KoToolManager_p.h
>> >>
>> >> @@ -127,19 +127,26 @@ public:
>> >> int uniqueId() const {
>> >>
>> >> return m_uniqueId;
>> >>
>> >> }
>> >>
>> >> - /// wrapper around KoToolFactoryBase::shortcut()
>> >> + /// KAction->shortcut() if it exists, otherwise
>> >> KoToolFactoryBase::shortcut() KShortcut shortcut() const;
>> >> + /// Writes a tooltip for a button, appending the keyboard
shortcut
>> >> if
>> >> we have one + QString buttonToolTip() const;
>> >> + /// Associate an action with this tool
>> >> + void setAction(KAction *a);
>> >>
>> >> Q_SIGNALS:
>> >> - /// emitted when one of the generated buttons was pressed.
>> >> + /// Emitted when the generated toolbox button is pressed.
>> >>
>> >> void toolActivated(ToolHelper *tool);
>> >>
>> >> private Q_SLOTS:
>> >> void buttonPressed();
>> >>
>> >> + void actionUpdated();
>> >>
>> >> private:
>> >> KoToolFactoryBase *m_toolFactory;
>> >> int m_uniqueId;
>> >>
>> >> + QToolButton *button;
>> >> + KAction *action;
>> >>
>> >> };
>> >>
>> >> /// \internal
> _______________________________________________
> calligra-devel mailing list
> calligra-devel at kde.org
> https://mail.kde.org/mailman/listinfo/calligra-devel
>
--
regards, Jaroslaw Staniek
KDE:
: A world-wide network of software engineers, artists, writers, translators
: and facilitators committed to Free Software development - http://kde.org
Calligra Suite:
: A graphic art and office suite - http://calligra.org
Kexi:
: A visual database apps builder - http://calligra.org/kexi
Qt Certified Specialist:
: http://www.linkedin.com/in/jstaniek
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.kde.org/pipermail/calligra-devel/attachments/20150819/5d545999/attachment.htm>
More information about the calligra-devel
mailing list