Commit f0738406 authored by Gilles Caulier's avatar Gilles Caulier 🗼
Browse files

Make Labels keyboard shorcuts configurable by end user into KDE config panel...

Make Labels keyboard shorcuts configurable by end user into KDE config panel of each root digiKam window.
This include Rating, Color, and Pick Labels.
Unlike tag action shortcuts which are stored in digiKam DB, Labels action shortcuts are stored in each
XML GUI config file of each root digiKam window.
Because each root window manage shortcut individually for relevant GUI, you need to apply a keyboard shortcut
change in each root window setup, to be homogenous everywhere.
BUGS: 313856
FIXED-IN: 4.0.0
parent 5cab9ef5
......@@ -253,6 +253,9 @@ DigikamApp::DigikamApp()
d->modelCollection = new DigikamModelCollection;
// This manager must be created after collection setup and before accelerators setup.
d->tagsActionManager = new TagsActionMngr(this);
// First create everything, then connect.
// Otherwise some items may send signals and the slots can try
// to access items which were not created yet.
......@@ -260,13 +263,11 @@ DigikamApp::DigikamApp()
setupAccelerators();
setupActions();
setupStatusBar();
initGui();
setupViewConnections();
// This manager must be created after collection setup.
d->tagsActionManager = new TagsActionMngr(this);
applyMainWindowSettings(group);
// Check ICC profiles repository availability
......@@ -656,6 +657,9 @@ void DigikamApp::setupAccelerators()
d->pasteItemsAction = KStandardAction::paste(this, SIGNAL(signalPasteAlbumItemsSelection()), this);
actionCollection()->addAction("paste_album_selection", d->pasteItemsAction);
// Labels shortcuts must be registered here to be saved in XML GUI files if user customize it.
d->tagsActionManager->registerLabelsActions(actionCollection());
}
void DigikamApp::setupActions()
......@@ -2489,7 +2493,7 @@ void DigikamApp::preloadWindows()
ImageWindow::imageWindow();
LightTableWindow::lightTableWindow();
d->tagsActionManager->registerActionCollections();
d->tagsActionManager->registerTagsActionCollections();
}
void DigikamApp::slotDatabaseMigration()
......
......@@ -126,21 +126,12 @@ QString TagsActionMngr::colorShortcutPrefix() const
return d->colorShortcutPrefix;
}
void TagsActionMngr::registerActionCollections()
void TagsActionMngr::registerTagsActionCollections()
{
d->actionCollectionList.append(DigikamApp::instance()->actionCollection());
d->actionCollectionList.append(ImageWindow::imageWindow()->actionCollection());
d->actionCollectionList.append(LightTableWindow::lightTableWindow()->actionCollection());
createActions();
}
QList<KActionCollection*> TagsActionMngr::actionCollections() const
{
return d->actionCollectionList;
}
void TagsActionMngr::createActions()
{
// Create Tags shortcuts.
QList<int> tagIds = TagsCache::instance()->tagsWithProperty(TagPropertyName::tagKeyboardShortcut());
......@@ -149,35 +140,34 @@ void TagsActionMngr::createActions()
{
createTagActionShortcut(tagId);
}
}
QList<KActionCollection*> TagsActionMngr::actionCollections() const
{
return d->actionCollectionList;
}
void TagsActionMngr::registerLabelsActions(KActionCollection* const ac)
{
// Create Rating shortcuts.
foreach(KActionCollection* const ac, d->actionCollectionList)
for (int i = RatingMin ; i <= RatingMax ; ++i)
{
for (int i = RatingMin ; i <= RatingMax ; ++i)
{
createRatingActionShortcut(ac, i);
}
createRatingActionShortcut(ac, i);
}
// Create Color Label shortcuts.
foreach(KActionCollection* const ac, d->actionCollectionList)
for (int i = NoColorLabel ; i <= WhiteLabel ; ++i)
{
for (int i = NoColorLabel ; i <= WhiteLabel ; ++i)
{
createColorLabelActionShortcut(ac, i);
}
createColorLabelActionShortcut(ac, i);
}
// Create Pick Label shortcuts.
foreach(KActionCollection* const ac, d->actionCollectionList)
for (int i = NoPickLabel ; i <= AcceptedLabel ; ++i)
{
for (int i = NoPickLabel ; i <= AcceptedLabel ; ++i)
{
createPickLabelActionShortcut(ac, i);
}
createPickLabelActionShortcut(ac, i);
}
}
......@@ -188,7 +178,7 @@ bool TagsActionMngr::createRatingActionShortcut(KActionCollection* const ac, int
KAction* const action = ac->addAction(QString("%1-%2").arg(d->ratingShortcutPrefix).arg(rating));
action->setText(i18n("Assign Rating \"%1 Star\"", rating));
action->setShortcut(KShortcut(QString("CTRL+%1").arg(rating)));
action->setShortcutConfigurable(false);
action->setShortcutConfigurable(true);
action->forgetGlobalShortcut();
action->setData(rating);
......@@ -208,7 +198,7 @@ bool TagsActionMngr::createPickLabelActionShortcut(KActionCollection* const ac,
KAction* const action = ac->addAction(QString("%1-%2").arg(d->pickShortcutPrefix).arg(pickId));
action->setText(i18n("Assign Pick Label \"%1\"", PickLabelWidget::labelPickName((PickLabel)pickId)));
action->setShortcut(KShortcut(QString("ALT+%1").arg(pickId)));
action->setShortcutConfigurable(false);
action->setShortcutConfigurable(true);
action->forgetGlobalShortcut();
action->setData(pickId);
......@@ -228,7 +218,7 @@ bool TagsActionMngr::createColorLabelActionShortcut(KActionCollection* const ac,
KAction* const action = ac->addAction(QString("%1-%2").arg(d->colorShortcutPrefix).arg(colorId));
action->setText(i18n("Assign Color Label \"%1\"", ColorLabelWidget::labelColorName((ColorLabel)colorId)));
action->setShortcut(KShortcut(QString("ALT+CTRL+%1").arg(colorId)));
action->setShortcutConfigurable(false);
action->setShortcutConfigurable(true);
action->forgetGlobalShortcut();
action->setData(colorId);
......
......@@ -52,10 +52,19 @@ public:
explicit TagsActionMngr(QWidget* const parent);
~TagsActionMngr();
/** Register all action collections managed with keyboard shorcuts.
* Must be called after all root window instances created.
/** Register all tag actions to collections managed with keyboard shorcuts.
* Because Tags shortcuts are stored in database this method must be called after
* database initialization and after that all root window instances have been created.
*/
void registerActionCollections();
void registerTagsActionCollections();
/** Register all labels actions to collections managed with keyboard shorcuts.
* Unlike tags actions, labels shortcuts are stored in XML GUI file of each root windows,
* to be able to customize it through KDE keyboards shortcuts config panel.
* This method must be called before to DXmlGuiWindow::createGUI(), typically
* when window actions are registered to ActionCollection instance.
*/
void registerLabelsActions(KActionCollection* const ac);
/** Return the list of whole action collections managed.
*/
......@@ -96,11 +105,6 @@ private:
bool createTagActionShortcut(int tagId);
bool removeTagActionShortcut(int tagId);
/** Create all actions relevant of whole tags from DB which have a keyboard shortcut.
* This method is called by registerActionCollection() method.
*/
void createActions();
bool createRatingActionShortcut(KActionCollection* const ac, int rating);
bool createPickLabelActionShortcut(KActionCollection* const ac, int pickId);
bool createColorLabelActionShortcut(KActionCollection* const ac, int colorId);
......
......@@ -126,6 +126,7 @@
#include "slideshow.h"
#include "statusprogressbar.h"
#include "syncjob.h"
#include "tagsactionmngr.h"
#include "tagscache.h"
#include "tagspopupmenu.h"
#include "thememanager.h"
......@@ -461,6 +462,9 @@ void ImageWindow::setupActions()
createHelpActions();
// Labels shortcuts must be registered here to be saved in XML GUI files if user customize it.
TagsActionMngr::defaultManager()->registerLabelsActions(actionCollection());
// ---------------------------------------------------------------------------------
createGUI(xmlFile());
......
......@@ -80,6 +80,7 @@
#include "uifilevalidator.h"
#include "albummodel.h"
#include "databasechangesets.h"
#include "tagsactionmngr.h"
#include "thumbbardock.h"
#include "thumbnailsize.h"
#include "thumbnailloadthread.h"
......@@ -635,6 +636,9 @@ void LightTableWindow::setupActions()
altBackwardAction->setShortcut(KShortcut(Qt::SHIFT + Qt::Key_Space));
connect(altBackwardAction, SIGNAL(triggered()), this, SLOT(slotBackward()));
// Labels shortcuts must be registered here to be saved in XML GUI files if user customize it.
TagsActionMngr::defaultManager()->registerLabelsActions(actionCollection());
// ---------------------------------------------------------------------------------
createGUI(xmlFile());
......
Markdown is supported
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