[prev in list] [next in list] [prev in thread] [next in thread]
List: kde-commits
Subject: KDE/kdelibs/kdeui
From: David Faure <faure () kde ! org>
Date: 2010-10-27 19:39:52
Message-ID: 20101027193952.9E49BAC897 () svn ! kde ! org
[Download RAW message or body]
SVN commit 1190475 by dfaure:
Don't lose shortcut from actions when doing plugActionList. Followup to r1187590. \
Fixes Ctrl+1/2/3/4/5 in kontact.
M +6 -6 tests/kxmlgui_unittest.cpp
M +9 -12 xmlgui/kxmlguifactory.cpp
--- trunk/KDE/kdelibs/kdeui/tests/kxmlgui_unittest.cpp #1190474:1190475
@@ -590,7 +590,7 @@
"</gui>";
TestGuiClient client(xml);
- client.createActions(QStringList() << "view_add_to_new_group" << "action1");
+ client.createActions(QStringList() << "view_add_to_new_group");
QMainWindow mainWindow;
KXMLGUIBuilder builder(&mainWindow);
KXMLGUIFactory factory(&builder);
@@ -608,9 +608,13 @@
kDebug() << "Now plugging the actionlist";
+ KAction* action1 = new KAction(this);
+ action1->setObjectName("action1");
+ action1->setShortcut(KShortcut("Ctrl+2"));
QList<QAction*> actionList;
- actionList << client.actionCollection()->action("action1");
+ actionList << action1;
client.plugActionList("view_groups_list", actionList);
+ QCOMPARE(action1->shortcut().toString(), QString("Ctrl+2"));
//debugActions(menu->actions());
checkActions(menu->actions(), QStringList()
@@ -817,7 +821,6 @@
"</gui>";
TestXmlGuiWindow mainWindow(xml);
- mainWindow.setAutoSaveSettings(false);
mainWindow.createGUI();
checkActions(mainWindow.menuBar()->actions(), QStringList()
@@ -841,7 +844,6 @@
"</gui>";
TestXmlGuiWindow mainWindow(xml);
- mainWindow.setAutoSaveSettings(false);
mainWindow.createGUI();
checkActions(mainWindow.menuBar()->actions(), QStringList()
@@ -855,7 +857,6 @@
void KXmlGui_UnitTest::testMenusNoXmlFile()
{
TestXmlGuiWindow mainWindow;
- mainWindow.setAutoSaveSettings(false);
mainWindow.createGUIBad();
checkActions(mainWindow.menuBar()->actions(), QStringList()
@@ -930,7 +931,6 @@
TestXmlGuiWindow mainWindow(xml);
TestGuiClient* client = new TestGuiClient(xml);
mainWindow.insertChildClient(client);
- mainWindow.setAutoSaveSettings(false);
mainWindow.createGUI();
QVERIFY(mainWindow.factory()->clients().contains(client));
--- trunk/KDE/kdelibs/kdeui/xmlgui/kxmlguifactory.cpp #1190474:1190475
@@ -91,7 +91,7 @@
QDomDocument shortcutSchemeDoc(KXMLGUIClient *client);
void applyShortcutScheme(KXMLGUIClient *client, const QList<QAction*>& actions, \
const QDomDocument& scheme);
void refreshActionProperties(KXMLGUIClient *client, const QList<QAction*>& \
actions, const QDomDocument& doc);
- void saveDefaultActionProperties(KXMLGUIClient *client);
+ void saveDefaultActionProperties(const QList<QAction*>& actions);
ContainerNode *m_rootNode;
@@ -264,7 +264,7 @@
}
// load shortcut schemes, user-defined shortcuts and other action properties
- d->saveDefaultActionProperties(client);
+ d->saveDefaultActionProperties(client->actionCollection()->actions());
if (!doc.isNull())
d->refreshActionProperties(client, client->actionCollection()->actions(), \
doc);
@@ -357,33 +357,29 @@
applyActionProperties( actionPropElement );
}
-void KXMLGUIFactoryPrivate::saveDefaultActionProperties(KXMLGUIClient *client)
+void KXMLGUIFactoryPrivate::saveDefaultActionProperties(const QList<QAction *>& \
actions) {
// This method is called every time the user activated a new
// kxmlguiclient. We only want to execute the following code only once in
// the lifetime of an action.
- foreach (QAction *action, client->actionCollection()->actions())
- {
+ foreach (QAction *action, actions) {
// Skip actions we have seen already.
if (action->property("_k_DefaultShortcut").isValid()) continue;
- if (KAction* kaction = qobject_cast<KAction*>(action))
- {
+ if (KAction* kaction = qobject_cast<KAction*>(action)) {
// Check if the default shortcut is set
KShortcut defaultShortcut = kaction->shortcut(KAction::DefaultShortcut);
KShortcut activeShortcut = kaction->shortcut(KAction::ActiveShortcut);
+ //kDebug() << kaction->objectName() << "default=" << \
defaultShortcut.toString() << "active=" << activeShortcut.toString();
// Check if we have an empty default shortcut and an non empty
// custom shortcut. This should only happen if a developer called
// QAction::setShortcut on an KAction. Print out a warning and
// correct the mistake
- if ((!activeShortcut.isEmpty()) && defaultShortcut.isEmpty())
- {
+ if ((!activeShortcut.isEmpty()) && defaultShortcut.isEmpty()) {
kError(240) << "Shortcut for KAction " << kaction->objectName() << \
kaction->text() << "set with QShortcut::setShortcut()! See KAction \
documentation.";
kaction->setProperty("_k_DefaultShortcut", activeShortcut);
- }
- else
- {
+ } else {
kaction->setProperty("_k_DefaultShortcut", defaultShortcut);
}
}
@@ -571,6 +567,7 @@
d->m_rootNode->plugActionList( *d );
// Load shortcuts for these new actions
+ d->saveDefaultActionProperties(actionList);
d->refreshActionProperties(client, actionList, client->domDocument());
d->BuildState::reset();
[prev in list] [next in list] [prev in thread] [next in thread]
Configure |
About |
News |
Add a list |
Sponsored by KoreLogic