Hello community,

here is the log from the commit of package libyui for openSUSE:Factory checked 
in at 2016-12-01 10:25:35
++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
Comparing /work/SRC/openSUSE:Factory/libyui (Old)
 and      /work/SRC/openSUSE:Factory/.libyui.new (New)
++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++

Package is "libyui"

Changes:
--------
--- /work/SRC/openSUSE:Factory/libyui/libyui.changes    2016-10-22 
13:05:03.000000000 +0200
+++ /work/SRC/openSUSE:Factory/.libyui.new/libyui.changes       2016-12-01 
10:25:35.000000000 +0100
@@ -1,0 +2,7 @@
+Fri Nov 25 09:22:14 UTC 2016 - jreidin...@suse.com
+
+- implement shortcut conflicts resolver for menu buttons
+  (bsc#940817)
+- 3.2.9
+
+-------------------------------------------------------------------

Old:
----
  libyui-3.2.8.tar.bz2

New:
----
  libyui-3.2.9.tar.bz2

++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++

Other differences:
------------------
++++++ libyui-doc.spec ++++++
--- /var/tmp/diff_new_pack.fPdrfn/_old  2016-12-01 10:25:36.000000000 +0100
+++ /var/tmp/diff_new_pack.fPdrfn/_new  2016-12-01 10:25:36.000000000 +0100
@@ -20,7 +20,7 @@
 %define so_version 7
 
 Name:           %{parent}-doc
-Version:        3.2.8
+Version:        3.2.9
 Release:        0
 Source:         %{parent}-%{version}.tar.bz2
 

++++++ libyui.spec ++++++
--- /var/tmp/diff_new_pack.fPdrfn/_old  2016-12-01 10:25:36.000000000 +0100
+++ /var/tmp/diff_new_pack.fPdrfn/_new  2016-12-01 10:25:36.000000000 +0100
@@ -17,7 +17,7 @@
 
 
 Name:           libyui
-Version:        3.2.8
+Version:        3.2.9
 Release:        0
 Source:         %{name}-%{version}.tar.bz2
 

++++++ libyui-3.2.8.tar.bz2 -> libyui-3.2.9.tar.bz2 ++++++
diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' 
'--exclude=.svnignore' old/libyui-3.2.8/VERSION.cmake 
new/libyui-3.2.9/VERSION.cmake
--- old/libyui-3.2.8/VERSION.cmake      2016-10-20 14:46:08.000000000 +0200
+++ new/libyui-3.2.9/VERSION.cmake      2016-11-25 14:41:08.000000000 +0100
@@ -1,6 +1,6 @@
 SET( VERSION_MAJOR "3")
 SET( VERSION_MINOR "2" )
-SET( VERSION_PATCH "8" )
+SET( VERSION_PATCH "9" )
 SET( VERSION 
"${VERSION_MAJOR}.${VERSION_MINOR}.${VERSION_PATCH}${GIT_SHA1_VERSION}" )
 
 ##### This is need for the libyui core, ONLY.
diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' 
'--exclude=.svnignore' old/libyui-3.2.8/examples/MenuButtons.cc 
new/libyui-3.2.9/examples/MenuButtons.cc
--- old/libyui-3.2.8/examples/MenuButtons.cc    1970-01-01 01:00:00.000000000 
+0100
+++ new/libyui-3.2.9/examples/MenuButtons.cc    2016-11-25 14:41:08.000000000 
+0100
@@ -0,0 +1,60 @@
+/*
+  Copyright (c) 2016 SUSE LCC
+
+  Permission is hereby granted, free of charge, to any person obtaining
+  a copy of this software and associated documentation files (the
+  "Software"), to deal in the Software without restriction, including
+  without limitation the rights to use, copy, modify, merge, publish,
+  distribute, sublicense, and/or sell
+  copies of the Software, and to permit persons to whom the Software is
+  furnished to do so, subject to the following conditions:
+
+  The above copyright notice and this permission notice shall be
+  included in all copies or substantial portions of the Software.
+
+  THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+  IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+  FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT
+  SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM,
+  DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR
+  OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR
+  THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+*/
+
+
+// Menu Button example demonstrating also shortcut resolver.
+//
+// Compile with:
+//
+//     g++ -I/usr/include/yui -lyui MenuButtons.cc -o MenuButtons
+
+#include "YUI.h"
+#include "YWidgetFactory.h"
+#include "YDialog.h"
+#include "YLayoutBox.h"
+#include "YEvent.h"
+#include "YMenuButton.h"
+#include "YMenuItem.h"
+
+int main( int argc, char **argv )
+{
+    YDialog    * dialog = YUI::widgetFactory()->createPopupDialog();
+    YLayoutBox * vbox   = YUI::widgetFactory()->createVBox( dialog );
+    YUI::widgetFactory()->createLabel( vbox, "Hello, World!" );
+    YMenuButton* top = YUI::widgetFactory()->createMenuButton( vbox, "Menu!" );
+    YMenuItem *inner_item = new YMenuItem("&menu1");
+    top->addItem(inner_item);
+    top->addItem(new YMenuItem("&menu2"));
+    top->addItem(new YMenuItem("&Menu3")); // test upper letter as shortcut
+    top->addItem(new YMenuItem("menu4")); // even without shortcut marker it 
should find shortcut if possible
+    new YMenuItem(inner_item, "&submenu1");
+    new YMenuItem(inner_item, "&submenu2");
+    new YMenuItem(inner_item, "&submenu3");
+    new YMenuItem(inner_item, "&submenu4");
+
+    top->resolveShortcutConflicts();
+    top->rebuildMenuTree();
+
+    dialog->waitForEvent();
+    dialog->destroy();
+}
diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' 
'--exclude=.svnignore' old/libyui-3.2.8/package/libyui-doc.spec 
new/libyui-3.2.9/package/libyui-doc.spec
--- old/libyui-3.2.8/package/libyui-doc.spec    2016-10-20 14:46:08.000000000 
+0200
+++ new/libyui-3.2.9/package/libyui-doc.spec    2016-11-25 14:41:08.000000000 
+0100
@@ -20,7 +20,7 @@
 %define so_version 7
 
 Name:           %{parent}-doc
-Version:        3.2.8
+Version:        3.2.9
 Release:        0
 Source:         %{parent}-%{version}.tar.bz2
 
diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' 
'--exclude=.svnignore' old/libyui-3.2.8/package/libyui.changes 
new/libyui-3.2.9/package/libyui.changes
--- old/libyui-3.2.8/package/libyui.changes     2016-10-20 14:46:08.000000000 
+0200
+++ new/libyui-3.2.9/package/libyui.changes     2016-11-25 14:41:08.000000000 
+0100
@@ -1,4 +1,11 @@
 -------------------------------------------------------------------
+Fri Nov 25 09:22:14 UTC 2016 - jreidin...@suse.com
+
+- implement shortcut conflicts resolver for menu buttons
+  (bsc#940817)
+- 3.2.9
+
+-------------------------------------------------------------------
 Fri Oct 14 10:22:44 UTC 2016 - jreidin...@suse.com
 
 - Fixed a Wmismatched-tags warning on clang/OSX (gh#libyui/libyui#33)
diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' 
'--exclude=.svnignore' old/libyui-3.2.8/package/libyui.spec 
new/libyui-3.2.9/package/libyui.spec
--- old/libyui-3.2.8/package/libyui.spec        2016-10-20 14:46:08.000000000 
+0200
+++ new/libyui-3.2.9/package/libyui.spec        2016-11-25 14:41:08.000000000 
+0100
@@ -16,7 +16,7 @@
 #
 
 Name:           libyui
-Version:        3.2.8
+Version:        3.2.9
 Release:        0
 Source:         %{name}-%{version}.tar.bz2
 
diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' 
'--exclude=.svnignore' old/libyui-3.2.8/src/YMenuButton.cc 
new/libyui-3.2.9/src/YMenuButton.cc
--- old/libyui-3.2.8/src/YMenuButton.cc 2016-10-20 14:46:08.000000000 +0200
+++ new/libyui-3.2.9/src/YMenuButton.cc 2016-11-25 14:41:08.000000000 +0100
@@ -29,6 +29,7 @@
 #include "YUISymbols.h"
 #include "YMenuButton.h"
 #include "YMenuItem.h"
+#include "YShortcut.h"
 
 
 struct YMenuButtonPrivate
@@ -133,19 +134,79 @@
     return 0;
 }
 
-
-void
-YMenuButton::resolveShortcutConflicts()
+static void resolveShortcutsConflictFlat(YItemConstIterator begin, 
YItemConstIterator end)
 {
-    // TO DO
-    // TO DO
-    // TO DO
+    bool used[ sizeof( char ) << 8 ];
+    for ( unsigned i=0; i < sizeof( char ) << 8; i++ )
+       used[i] = false;
+    std::vector<YMenuItem*> conflicts;
+
+    for ( YItemConstIterator it = begin; it != end; ++it )
+    {
+       YMenuItem * item = dynamic_cast<YMenuItem *> (*it);
 
-    // For every menu level, make sure keyboard shortcuts are unique within 
that menu level.
-    // If necessary, change some of them (move the '&' character to some other 
character).
+       if ( item )
+       {
+           if ( item->hasChildren() )
+           {
+               resolveShortcutsConflictFlat(item->childrenBegin(), 
item->childrenEnd() );
+           }
 
+            char shortcut = 
YShortcut::normalized(YShortcut::findShortcut(item->label()));
 
-    // See YShortcutManager for more hints.
+            if (shortcut == 0)
+            {
+                conflicts.push_back(item);
+                yuiMilestone() << "No or invalid shortcut found " << 
item->label() << std::endl;
+            }
+            else if (used[(unsigned)shortcut])
+            {
+                conflicts.push_back(item);
+                yuiWarning() << "Conflicting shortcut found " << item->label() 
<< std::endl;
+            }
+            else
+            {
+                used[(unsigned)shortcut] = true;
+            }
+       }
+        else
+        {
+          yuiWarning() << "non menu item used in call " << (*it)->label() << 
std::endl;
+        }
+    }
+
+    // cannot use YShortcut directly as YItem is not YWidget
+    for(YMenuItem *i: conflicts)
+    {
+        std::string clean = YShortcut::cleanShortcutString(i->label());
+        char new_c = 0;
+
+        size_t index = 0;
+        for (; index < clean.size(); ++index)
+        {
+            char ch = YShortcut::normalized(clean[index]);
+            // ch is set to 0 by normalized if not valid
+            if (ch != 0 && !used[(unsigned)ch])
+            {
+                new_c = ch;
+                used[(unsigned)ch] = true;
+                break;
+            }
+        }
+
+        if (new_c != 0)
+        {
+            clean.insert(index, 1, YShortcut::shortcutMarker());
+            yuiMilestone() << "New label used: " << clean << std::endl;
+        }
+        i->setLabel(clean);
+    }
+}
+
+void
+YMenuButton::resolveShortcutConflicts()
+{
+    resolveShortcutsConflictFlat(itemsBegin(), itemsEnd());
 }
 
 
diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' 
'--exclude=.svnignore' old/libyui-3.2.8/src/YMenuButton.h 
new/libyui-3.2.9/src/YMenuButton.h
--- old/libyui-3.2.8/src/YMenuButton.h  2016-10-20 14:46:08.000000000 +0200
+++ new/libyui-3.2.9/src/YMenuButton.h  2016-11-25 14:41:08.000000000 +0100
@@ -98,6 +98,12 @@
      * items in this MenuButton. That index can be used later with
      * findMenuItem() to find the item by that index.
      *
+     * @note please do not forget to call after adding all elements
+     * #resolveShortcutConflicts and #rebuildMenuTree in this order. It is
+     * important to call it after all submenus are added otherwise it won't
+     * have proper shortcuts and won't be rendered.
+     * @see examples/MenuButton.cc.
+     *
      * Reimplemented from YSelectionWidget.
      **/
     virtual void addItem( YItem * item_disown );


Reply via email to