Commit 31aebe61 authored by Michael Abrahams's avatar Michael Abrahams

Remove deprecated XMLGUI shortcut code

parent 48e07b98
......@@ -22,7 +22,6 @@
#include "canvas/kis_perspective_grid_manager.h"
#include <QAction>
#include <klocalizedstring.h>
#include <ktoggleaction.h>
#include <kactioncollection.h>
......
......@@ -28,7 +28,6 @@
#include <QHBoxLayout>
#include <QLabel>
#include <QToolButton>
#include <QAction>
#include <QPixmap>
#include <QWidgetAction>
......
......@@ -70,6 +70,7 @@ void KisShortcutsDialog::KisShortcutsDialogPrivate::changeShortcutScheme(const Q
auto it = m_collections.constBegin();
while (it != m_collections.constEnd()) {
it.value()->updateShortcuts();
// TODO: BAD
m_shortcutsEditor->addCollection(it.value(), it.key());
it++;
}
......
......@@ -58,15 +58,6 @@
Q_DECLARE_METATYPE(KisShortcutsEditorItem *)
KisShortcutsEditor::KisShortcutsEditor(KActionCollection *collection, QWidget *parent, ActionTypes actionType,
LetterShortcuts allowLetterShortcuts)
: QWidget(parent)
, d(new KisShortcutsEditorPrivate(this))
{
d->initGUI(actionType, allowLetterShortcuts);
addCollection(collection);
}
KisShortcutsEditor::KisShortcutsEditor(QWidget *parent, ActionTypes actionType, LetterShortcuts allowLetterShortcuts)
: QWidget(parent)
, d(new KisShortcutsEditorPrivate(this))
......
......@@ -44,7 +44,7 @@ class KisShortcutsEditorPrivate;
* already free of conflicts. If it is not, nothing will crash, but your users
* won't like the resulting behavior.
*
* TODO: What exactly is the problem?
* TODO: Find the right place to check for conflicts.
*/
......@@ -101,20 +101,6 @@ public:
LetterShortcutsAllowed
};
/**
* Constructor.
*
* @param collection the KActionCollection to configure
* @param parent parent widget
* @param actionTypes types of actions to display in this widget.
* @param allowLetterShortcuts set to LetterShortcutsDisallowed if unmodified alphanumeric
* keys ('A', '1', etc.) are not permissible shortcuts.
*/
KisShortcutsEditor(KActionCollection *collection,
QWidget *parent,
ActionTypes actionTypes = AllActions,
LetterShortcuts allowLetterShortcuts = LetterShortcutsAllowed);
/**
* \overload
*
......
......@@ -91,9 +91,6 @@ public:
void configureAction(QAction *action, const QDomAttr &attribute,
ShortcutOption shortcutOption = KXMLGUIFactoryPrivate::SetActiveShortcut);
/// STUBBED OUT. Lots of loading seems to happen here.
void applyShortcutScheme(KXMLGUIClient *client, const QList<QAction *> &actions /*, const QDomDocument &scheme */);
void refreshActionProperties(KXMLGUIClient *client, const QList<QAction *> &actions, const QDomDocument &doc);
void saveDefaultActionProperties(const QList<QAction *> &actions);
......@@ -287,7 +284,7 @@ void KXMLGUIFactory::addClient(KXMLGUIClient *client)
d->clientBuilderCustomTags.clear();
}
// load shortcut schemes, user-defined shortcuts and other action properties
// load user-defined shortcuts and other action properties
d->saveDefaultActionProperties(client->actionCollection()->actions());
if (!doc.isNull()) {
d->refreshActionProperties(client, client->actionCollection()->actions(), doc);
......@@ -335,20 +332,6 @@ void KXMLGUIFactory::addClient(KXMLGUIClient *client)
// qDebug() << "addClient took " << dt.elapsed();
}
void KXMLGUIFactory::refreshActionProperties()
{
Q_FOREACH (KXMLGUIClient *client, d->m_clients) {
d->guiClient = client;
QDomDocument doc = client->xmlguiBuildDocument();
if (doc.documentElement().isNull()) {
client->reloadXML();
doc = client->domDocument();
}
d->refreshActionProperties(client, client->actionCollection()->actions(), doc);
}
d->guiClient = 0;
}
// Find the right ActionProperties element, otherwise return null element
static QDomElement findActionPropertiesElement(const QDomDocument &doc)
{
......@@ -364,8 +347,10 @@ static QDomElement findActionPropertiesElement(const QDomDocument &doc)
void KXMLGUIFactoryPrivate::refreshActionProperties(KXMLGUIClient *client, const QList<QAction *> &actions, const QDomDocument &doc)
{
// try to find and apply shortcuts schemes
applyShortcutScheme(client, actions);
// These were used for applyShortcutScheme() but not for applyActionProperties()??
Q_UNUSED(client);
Q_UNUSED(actions);
// try to find and apply user-defined shortcuts
const QDomElement actionPropElement = findActionPropertiesElement(doc);
......@@ -401,15 +386,6 @@ void KXMLGUIFactoryPrivate::saveDefaultActionProperties(const QList<QAction *> &
}
}
void KXMLGUIFactory::changeShortcutScheme(const QString &scheme)
{
//qDebug(260) << "Changing shortcut scheme to" << scheme;
KConfigGroup cg = KSharedConfig::openConfig()->group("Shortcut Schemes");
cg.writeEntry("Current Scheme", scheme);
refreshActionProperties();
}
void KXMLGUIFactory::forgetClient(KXMLGUIClient *client)
{
d->m_clients.removeAll(client);
......@@ -683,70 +659,6 @@ void KXMLGUIFactoryPrivate::configureAction(QAction *action, const QDomAttr &att
}
}
void KXMLGUIFactoryPrivate::applyShortcutScheme(KXMLGUIClient *client,
const QList<QAction *> &actions
/*, const QDomDocument &scheme */)
{
// Deprecated - use KisShortcutsEditor and KisActionRegistry instead
Q_UNUSED(client);
Q_UNUSED(actions);
#if 0
KConfigGroup cg = KSharedConfig::openConfig()->group("Shortcut Schemes");
QString schemeName = cg.readEntry("Current Scheme", "Default");
//First clear all existing shortcuts
if (schemeName != QStringLiteral("Default")) {
Q_FOREACH (QAction *action, actions) {
action->setShortcuts(QList<QKeySequence>());
// We clear the default shortcut as well because the shortcut scheme will set its own defaults
action->setProperty("defaultShortcuts", QVariant::fromValue(QList<QKeySequence>()));
}
} else {
// apply saved default shortcuts
Q_FOREACH (QAction *action, actions) {
QVariant savedDefaultShortcut = action->property("_k_DefaultShortcut");
if (savedDefaultShortcut.isValid()) {
QList<QKeySequence> shortcut = savedDefaultShortcut.value<QList<QKeySequence> >();
//qDebug() << "scheme said" << shortcut.toString() << "for action" << kaction->objectName();
action->setShortcuts(shortcut);
action->setProperty("defaultShortcuts", QVariant::fromValue(shortcut));
}
}
}
if (scheme.isNull()) {
return;
}
QDomElement docElement = scheme.documentElement();
QDomElement actionPropElement = docElement.namedItem(QStringLiteral("ActionProperties")).toElement();
//Check if we really have the shortcut configuration here
if (!actionPropElement.isNull()) {
//qDebug(260) << "Applying shortcut scheme for XMLGUI client" << client->componentName();
//Apply all shortcuts we have
applyActionProperties(actionPropElement, KXMLGUIFactoryPrivate::SetDefaultShortcut);
//} else {
//qDebug(260) << "Invalid shortcut scheme file";
}
#endif
}
int KXMLGUIFactory::configureShortcuts(bool letterCutsOk, bool bSaveSettings)
{
KisShortcutsDialog dlg(KisShortcutsEditor::AllActions,
letterCutsOk ? KisShortcutsEditor::LetterShortcutsAllowed : KisShortcutsEditor::LetterShortcutsDisallowed,
qobject_cast<QWidget *>(parent()));
Q_FOREACH (KXMLGUIClient *client, d->m_clients) {
if (client) {
dlg.addCollection(client->actionCollection());
}
}
return dlg.configure(bSaveSettings);
}
// Find or create
QDomElement KXMLGUIFactory::actionPropertiesElement(QDomDocument &doc)
{
......
......@@ -172,31 +172,6 @@ public:
*/
void resetContainer(const QString &containerName, bool useTagName = false);
/**
* Use this method to reset and reread action properties (shortcuts, etc.) for all actions.
* This is needed, for example, when you change shortcuts scheme at runtime.
*/
void refreshActionProperties();
public Q_SLOTS:
/**
* Show a standard configure shortcut for every action in this factory.
*
* This slot can be connected directly to the action to configure shortcuts. This is very simple to
* do that by adding a single line
* \code
* KStandardAction::keyBindings( guiFactory(), SLOT( configureShortcuts() ), actionCollection() );
* \endcode
*
* @param bAllowLetterShortcuts Set to false if unmodified alphanumeric
* keys ('A', '1', etc.) are not permissible shortcuts.
* @param bSaveSettings if true, the settings will also be saved back to
* the *uirc file which they were intially read from.
*/
int configureShortcuts(bool bAllowLetterShortcuts = true, bool bSaveSettings = true);
void changeShortcutScheme(const QString &scheme);
Q_SIGNALS:
void clientAdded(KXMLGUIClient *client);
void clientRemoved(KXMLGUIClient *client);
......
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