CN115964042A - Menu generation method and device, storage medium and electronic equipment - Google Patents

Menu generation method and device, storage medium and electronic equipment Download PDF

Info

Publication number
CN115964042A
CN115964042A CN202211741091.5A CN202211741091A CN115964042A CN 115964042 A CN115964042 A CN 115964042A CN 202211741091 A CN202211741091 A CN 202211741091A CN 115964042 A CN115964042 A CN 115964042A
Authority
CN
China
Prior art keywords
menu
generator
item
target
structure data
Prior art date
Legal status (The legal status is an assumption and is not a legal conclusion. Google has not performed a legal analysis and makes no representation as to the accuracy of the status listed.)
Pending
Application number
CN202211741091.5A
Other languages
Chinese (zh)
Inventor
�田�浩
Current Assignee (The listed assignees may be inaccurate. Google has not performed a legal analysis and makes no representation or warranty as to the accuracy of the list.)
Netease Hangzhou Network Co Ltd
Original Assignee
Netease Hangzhou Network Co Ltd
Priority date (The priority date is an assumption and is not a legal conclusion. Google has not performed a legal analysis and makes no representation as to the accuracy of the date listed.)
Filing date
Publication date
Application filed by Netease Hangzhou Network Co Ltd filed Critical Netease Hangzhou Network Co Ltd
Priority to CN202211741091.5A priority Critical patent/CN115964042A/en
Publication of CN115964042A publication Critical patent/CN115964042A/en
Pending legal-status Critical Current

Links

Images

Landscapes

  • User Interface Of Digital Computer (AREA)

Abstract

The disclosure relates to a menu generation method and device, a storage medium and an electronic device, and relates to the technical field of computers, wherein the method comprises the following steps: acquiring a menu configuration file, and matching menu structure data in the menu configuration file with a target object generator; constructing a menu object according to the menu structure data and the target object generator, and adding the menu object to a pre-constructed child object list of a parent level menu item object; carrying out recursion processing on the menu objects included in the child object list to obtain a parent object and a child object, and generating a tree-structured object set according to the parent object and the child object; and creating a menu control corresponding to the menu object included in each hierarchy of the tree structure object set, and generating a target menu according to the menu control and the hierarchical relation between the menu controls. The present disclosure improves the generation efficiency of menus.

Description

Menu generation method and device, storage medium and electronic equipment
Technical Field
The embodiment of the disclosure relates to the technical field of computers, and in particular relates to a menu generation method, a menu generation device, a computer-readable storage medium and an electronic device.
Background
In the existing menu generation method, because the created menu is predefined well, the subsequent change is inconvenient, and the menu generation efficiency is low.
It is to be noted that the information invented in the background section above is only for enhancement of understanding of the background of the present disclosure, and thus may include information that does not constitute prior art known to those of ordinary skill in the art.
Disclosure of Invention
An object of the present disclosure is to provide a menu generation method, a menu generation apparatus, a computer-readable storage medium, and an electronic device, which overcome, at least to some extent, the problem of low menu generation efficiency due to the limitations and disadvantages of the related art.
According to an aspect of the present disclosure, there is provided a menu generation method, including:
acquiring a menu configuration file, and matching menu structure data in the menu configuration file with a target object generator;
constructing a menu object according to the menu structure data and the target object generator, and adding the menu object to a pre-constructed child object list of a parent level menu item object;
carrying out recursion processing on the menu objects included in the child object list to obtain a parent object and a child object, and generating a tree-structured object set according to the parent object and the child object;
and creating a menu control corresponding to the menu object included in the tree structure object set, and generating a target menu according to the menu control and the hierarchical relation between the menu controls.
According to an aspect of the present disclosure, there is provided a menu generating apparatus including:
the object generator matching module is used for acquiring a menu configuration file and matching menu structure data in the menu configuration file with a target object generator;
the menu object constructing module is used for constructing a menu object according to the menu structure data and the target object generator and adding the menu object to a pre-constructed child object list of a parent level menu item object;
a tree structure object set generating module, configured to perform recursive processing on the menu objects included in the child object list to obtain a parent object and a child object, and generate a tree structure object set according to the parent object and the child object;
and the user interface generating module is used for creating a menu control corresponding to the menu object included in the tree structure object set and generating a target menu according to the menu control and the hierarchical relation between the menu controls.
According to an aspect of the present disclosure, there is provided a computer-readable storage medium having stored thereon a computer program which, when executed by a processor, implements a method of generating a menu as described in any one of the above.
According to an aspect of the present disclosure, there is provided an electronic device including:
a processor; and
a memory for storing executable instructions of the processor;
wherein the processor is configured to perform the menu generation method of any one of the above via execution of the executable instructions.
According to the menu generating method provided by the embodiment of the disclosure, on one hand, the target object generator can be matched with the menu structure data in the menu configuration file; then, a menu object is built according to the menu structure data and the target object generator, and the menu object is added to a pre-built child object list of the parent level menu item object; further carrying out recursion processing on the menu objects in the child object list to obtain a parent object and a child object, and generating a tree structure object set according to the parent object and the child object; finally, a menu control corresponding to the menu object included in the tree structure object set is created, a target menu is generated according to the menu control and the hierarchical relation between the menu controls, the corresponding target menu can be directly generated according to the menu configuration file without presetting the menu, and the problem of low menu generation efficiency in the prior art is solved; on the other hand, the target object generator can be matched with the menu structure data in the menu configuration file; and then, the menu object is constructed according to the menu structure data and the target object generator, so that the multiplexing rate of the object generator and the menu generator is improved.
It is to be understood that both the foregoing general description and the following detailed description are exemplary and explanatory only and are not restrictive of the disclosure.
Drawings
The accompanying drawings, which are incorporated in and constitute a part of this specification, illustrate embodiments consistent with the present disclosure and together with the description, serve to explain the principles of the disclosure. It is to be understood that the drawings in the following description are merely exemplary of the disclosure, and that other drawings may be derived from those drawings by one of ordinary skill in the art without the exercise of inventive faculty.
Fig. 1 schematically shows a flowchart of a menu generation method according to an example embodiment of the present disclosure.
Fig. 2 schematically illustrates a structural example diagram of a menu generator according to an example embodiment of the present disclosure.
Fig. 3 schematically illustrates an example structure diagram of a menu profile according to an example embodiment of the present disclosure.
Fig. 4 schematically illustrates a structural example diagram of a menu object according to an example embodiment of the present disclosure.
Fig. 5 schematically illustrates a structural example diagram of a tree structure object set according to an example embodiment of the present disclosure.
Fig. 6 is a diagram schematically illustrating an example of a target menu generated by a menu control corresponding to a menu item object according to an example embodiment of the present disclosure.
Fig. 7 is a diagram schematically illustrating an example of a target menu generated by a menu control corresponding to a command item object according to an example embodiment of the present disclosure.
Fig. 8 schematically illustrates a flowchart of another menu generation method according to an example embodiment of the present disclosure.
Fig. 9 schematically shows a block diagram of a menu generation apparatus according to an example embodiment of the present disclosure.
Fig. 10 schematically illustrates an electronic device for implementing the above-described menu generation method according to an example embodiment of the present disclosure.
Detailed Description
Example embodiments will now be described more fully with reference to the accompanying drawings. Example embodiments may, however, be embodied in many different forms and should not be construed as limited to the examples set forth herein; rather, these embodiments are provided so that this disclosure will be thorough and complete, and will fully convey the concept of example embodiments to those skilled in the art. The described features, structures, or characteristics may be combined in any suitable manner in one or more embodiments. In the following description, numerous specific details are provided to give a thorough understanding of embodiments of the disclosure. One skilled in the relevant art will recognize, however, that the embodiments of the present disclosure can be practiced without one or more of the specific details, or with other methods, components, devices, steps, etc. In other instances, well-known technical solutions have not been shown or described in detail to avoid obscuring aspects of the present disclosure.
Furthermore, the drawings are merely schematic illustrations of the present disclosure and are not necessarily drawn to scale. The same reference numerals in the drawings denote the same or similar parts, and thus their repetitive description will be omitted. Some of the block diagrams shown in the figures are functional entities and do not necessarily correspond to physically or logically separate entities. These functional entities may be implemented in the form of software, or in one or more hardware modules or integrated circuits, or in different networks and/or processor devices and/or microcontroller devices.
Applications typically require interaction with the end User via a Graphical User Interface (GUI). Therefore, when the application program is developed, the appearance layout, the interactive logic, the dynamic presentation and the like related to the graphic user interface are compiled and become an important part in the whole application program development process; meanwhile, among various layouts and interactive components included in the graphical user interface, the menu is the most important interactive interface for receiving user instructions and executing corresponding operation operations.
At present, the development and implementation of graphical user interfaces are mostly completed by means of a special GUI programming framework, where Qt is a widely used programming framework. In the practical application process, the Qt has simple and easy-to-use characteristics and perfect module design, the object-oriented program design principle is completely used, and codes written based on the Qt can be directly used in a cross-platform mode, so that the Qt is popular among desktop end program developers, and Qt is used as an implementation mode of a graphical user interface of a plurality of famous desktop end software. Meanwhile, in the field of professional computer graphic image software, qt is almost equivalent to the industry specification, and mainstream software in the field, such as Maya engine, houdin engine, nuke engine, illusion engine and the like, provides the capability of using Qt to expand the graphic user interface and develop secondarily, so that developers can realize customized components, such as customized menus, customized dialog boxes and the like, on the software by means of Qt, and the interaction capability of the software is expanded.
Typically, menus and toolbars are defined separately when defining and categorizing different forms of interactive components in a layout; where a menu typically refers to a set of short text organized in a tree structure, and a toolbar typically refers to a set of icons arranged horizontally or vertically. However, in a broad sense, the functions of the menu and the toolbar are almost consistent, and a user clicks a specific text or an icon to expand the secondary content or trigger the application program to perform a corresponding specific operation. Moreover, the menu described in the exemplary embodiment of the present disclosure includes all interactive components organized in a tree structure in a broad sense for accepting user clicks and performing corresponding operations. Further, when the Qt is used to develop a graphical user interface of an application program, three ways of creating a menu mainly include visual design, object-oriented programming, and QML. Wherein:
on one hand, in the process of menu creation through a visual design mode, a graphical user interface design draft can be created through interactive component dragging, attribute setting, interface layout and other operations by means of visual graphical user interface design tools such as Qt Designer, qt Creator and the like attached to a Qt programming framework, then the design draft is automatically converted into Qt framework-based codes through the tools, and execution logic is continuously added on the basis of the codes; on the other hand, in the process of menu creation in an object-oriented programming mode, codes are directly written by using modules, interfaces and the like provided by the method according to the development specification of a Qt frame, and original components can be modified and expanded by an object-oriented programming means; meanwhile, the codes can call the core capability provided by the Qt framework during the operation, so that a corresponding graphical user interface is constructed and presented to a user; moreover, the code corresponding to the menu is directly compiled, so that the compiling efficiency is high, the customizability is strong, and the detailed control which is finer than that of the visual design can be realized; on the other hand, in the process of creating a menu by a QML (qtmeta-Object Language, qt Meta-Object Language, a novel markup Language developed for a graphical user interface), the method is equivalent to a new scheme in which the first two schemes are combined and supplemented with each other in terms of degree; meanwhile, the QML is a markup-type language specially developed for the Qt interface, can be directly written, can be generated by means of layout of a visual design tool, and can directly use JavaScript codes or call a C + + module in the QML to complete the part of command execution logic.
However, although the above three existing solutions have advantages in creating menus of graphical user interfaces, there are also obvious disadvantages: on one hand, the product of the visual design is only the component layout and the attribute description recorded by the markup language, and the generated code structure is relatively fixed, which is not beneficial to the modular split management of the code; moreover, the object-oriented programming scheme can accurately control the structural division, the composition mode and the logic expansion of the code module, and can complete the interface design and the development of back-end logic at one time, but the mode is not intuitive, has high requirements on the code compiling capability and needs to be repeatedly tested; further, QML is still not perfect up to now, and the supported component types are limited, have not been widely used, and have a certain extra learning cost; on the other hand, menus created by the above schemes are predefined well at one time, and if the menu content needs to be added or deleted subsequently, the visual design draft, the source code or the QML markup text needs to be adjusted again from the beginning in the same way; therefore, no matter the graphical interface tool is independently developed or the existing graphical interface tool is subjected to menu expansion, the modification mode greatly influences the efficiency of modifying the menu and increases the maintenance difficulty; on the other hand, the management modes of the menu are not uniform, and sometimes centralized management is used, so that all the expansion components, the expansion functions and the like relate to the newly added menu and the centralized menu definition module needs to be modified; if the respective self-management modes are used, codes and logics related to menu creation are dispersed in different expansion components and functions, management is difficult to be considered, and conflicts often occur even when the menus are created.
Based on this, the present exemplary embodiment first provides a menu generation method. Specifically, referring to fig. 1, the method for generating the menu may include the following steps:
s110, acquiring a menu configuration file, and matching menu structure data in the menu configuration file with a target object generator;
s120, constructing a menu object according to the menu structure data and the target object generator, and adding the menu object to a pre-constructed child object list of a parent level menu item object;
s130, carrying out recursion processing on the menu objects included in the child object list to obtain a parent object and a child object, and generating a tree structure object set according to the parent object and the child object;
and S140, creating a menu control corresponding to the menu object included in each level of the tree structure object set, and generating a target menu according to the menu control and the level relation between the menu controls.
In the above menu generating method, on one hand, the target object generator can be matched with the menu structure data in the menu configuration file; then, a menu object is built according to the menu structure data and the target object generator, and the menu object is added to a pre-built child object list of the parent level menu item object; further carrying out recursion processing on the menu objects in the child object list to obtain a parent object and a child object, and generating a tree structure object set according to the parent object and the child object; finally, a menu control corresponding to the menu object in the tree structure object set is created, a target menu is generated according to the menu control and the hierarchical relation between the menu controls, the corresponding target menu can be directly generated according to the menu configuration file without presetting the menu, and the problem of low menu generation efficiency in the prior art is solved; on the other hand, the target object generator can be matched with the menu structure data in the menu configuration file; and then, the menu object is constructed according to the menu structure data and the target object generator, so that the multiplexing rate of the object generator and the menu generator is improved.
Hereinafter, a generation method of a menu of an exemplary embodiment of the present disclosure will be explained and explained in detail with reference to the drawings.
First, the objects of the exemplary embodiments of the present disclosure are explained and illustrated. Specifically, in the menu generating method provided in the exemplary embodiment of the present disclosure, a new scheme for creating and managing a menu is provided, so as to solve the problems that the existing scheme lacks unified management on the menu and is inconvenient to add, delete and modify; in the specific application process, on one hand, the current situation that a Qt file (design draft or QML script) or a source code is required to be modified every time a menu is modified can be solved, the technical conditions required for maintaining the menu are reduced, further, the content management and the technical implementation of the menu can be separated, and the menu definition description can be directly modified to update the menu; on the other hand, the problem of menu management dispersion can be solved, the related menu management of different software environments and different service requirements is integrated on the same implementation mode, and the probability of repeated labor and conflict occurrence is reduced; on the other hand, the expandability of the related technical scheme for creating the menu can be improved, so that the menu creating scheme can be adapted to different software environments, even any target menu programming framework, and only targeted new implementation is needed when the menu creating scheme needs to be expanded, and the existing codes do not need to be modified.
Further, in order to solve the problems of uniformly managing menus, facilitating addition and deletion of menus, and improving code reuse rate when creating menus for different software environments, the method for generating menus according to the exemplary embodiment of the present disclosure further relates to a scheme for creating menus in an abstract, polymorphic, and recursive manner through configuration files and a series of generators, and a corresponding code implementation module. Specifically, firstly, a menu configuration file structure specification is defined, which is used for managing the structure, the content, the corresponding execution command and the like of the menu, so that the unified management of the information presented by the menu and the carried function is realized, and the information is not dispersed in codes; secondly, the configuration file describes the information required by the menu creation in a text form through simple format specifications and grammar keywords, thereby isolating the service design and technical realization of the menu, so that when the menu is maintained by adding, deleting, modifying and the like, only the text in the configuration file is required to be modified without any code modification; furthermore, module layering is carried out on code implementation related to a menu creating process, an object-oriented design principle is fully utilized, and different types of menu objects, different specific menu generators, different menu object generating functions and menu control creating functions are designed in an abstract mode, so that the analysis of configuration files and the creating process of a menu object tree are decoupled from a specific software environment, and menus described by the same menu configuration file are created in different software environments; meanwhile, if a new menu object type and a corresponding generating function are required to be added and a menu generator specific implementation aiming at a new software environment is required, only the code logic related to the new type needs to be separately implemented, the consistency of interface specifications is ensured by means of an inheritance mechanism, the added implementation is added into the running process in a registration or injection mode, and other module parts do not need to be modified at all.
Based on the above-mentioned description, it can be known that, in the menu generation method provided in the exemplary embodiment of the present disclosure, first, the structure of the menu, the icons, the prompt texts, the execution commands, and the like corresponding to each menu item may be defined by a configuration file format, and the configuration file manages the menu content in a unified manner; secondly, the configuration file can be analyzed into nested menu data objects through a configuration data analyzer; finally, defining an abstract menu generator, wherein the generator can create the nested menu data object obtained by the analyzer into a menu in an actual Qt environment; meanwhile, aiming at different software environments, the menu generation interface defined by the menu generation function can be realized by means of a standard Qt API and a specific API provided by the software, so that the Qt menu can be created in different software environments.
Next, the menu generator described in the exemplary embodiment of the present disclosure is explained and explained. Specifically, as shown in fig. 2, the menu generator 200 may include a menu object aggregator 210 and a menu generating function 220; the menu object aggregator includes a menu item object generator 211, a command item object generator 212 and a special item object generator 213; meanwhile, by deriving the abstract menu generator, a specific implementation 230 of the menu generator can be obtained; and all menu generator concrete implementations inherit from the abstract menu generator, that is, the menu generator concrete implementations can be various, and each contains related attributes and functional interfaces defined by the abstract menu generator, so that the different menu generator concrete implementations can be called in the same way and produce the same function.
In an example embodiment, in the generation process of a menu, firstly, a menu generator specifically reads in complete configuration data in a menu configuration file and transmits the complete configuration data to a menu object aggregator; then, the menu object aggregator recursively processes the incoming configuration data and uses the configuration data to create a series of menu objects, the types of which include special item objects, command item objects, menu item objects, and so on; meanwhile, as the menu item object has a child object list, the menu item object can be used as a parent object and can contain any type of object in the child object list, and finally, a nested tree structure object set which is expanded layer by layer from the root menu object is formed; further, the menu generator specifically realizes that after the nested tree structure object set is obtained, recursive processing is performed on the nested tree structure object set according to tree structure levels, and each menu object of each level calls a generation function of a corresponding type in the menu generator to create an actual target menu control. Since the object set keeps a nested tree structure, the father-son relation of any menu control is clear, and the whole menu can be created at one time.
Fig. 3 is a schematic diagram illustrating a structure of a menu configuration file 300 according to an exemplary embodiment of the present disclosure. Specifically, the menu configuration file described herein is mainly divided into two parts in the data structure: menu structure definition (menu structure data) 310 and command execution statement 320; the menu structure data can be used to describe the hierarchical relationship between the menu object sets of the tree structure, and the command execution statement list is a flat mapping without a hierarchical structure and is used to define the execution code corresponding to each command name. Further, the menu structure data can describe the hierarchical relationship of the whole menu object by a series of pre-agreed text keywords and corresponding character string values; the top layer of the menu object set is usually a menu item object, and only the menu item object can contain sub-items, so that when the top layer item type of the menu object set is not the menu item object, the whole menu object only has the top layer item, and does not have more hierarchical sub-items.
In an example embodiment, the menu structure data includes configuration information for menu items; the configuration information of the menu item includes an object name 311, object display information 312, an object sub-item list 313, and the like. Wherein object names must be unique in any same hierarchy, but the same object names are allowed to be used in different hierarchies; meanwhile, the object display information is used for defining the information and the style of the menu object actually displayed on the target menu, and the information and the style comprise texts, icons, prompts, styles and the like; further, the object sub-item list is a list composed of other menu objects of any type, which represents a secondary sub-object of the current menu object; moreover, for a certain type of sub-object of any hierarchy, the format and the structural specification of the configuration information are the same; the object sub-item list is theoretically optional, but in practice, the menu item objects that do not contain a sub-item list are invalid; special items should be used if it is desired to display only some additional information in the menu.
In an example embodiment, the menu structure data includes a command item and configuration information of a specific item; wherein, the configuration information of the command item may include a command name 321, an executed command statement 323, and the like; the configuration information of the special item includes a special item name, special item display information, additional information, and the like; meanwhile, the names of the command item and the special item must be unique in any same hierarchy, but the same names are allowed to be used in different hierarchies, and the command item and the special item have no sub item list; however, a particular item may have different sub-types that may be distinguished in the additional information, and different sub-types may add additional configuration data as needed in the additional information.
In an example embodiment, a command unique name and corresponding command execution codes are defined in the command execution statement, and the command execution codes can run in a specific software environment, so that the expected operation of the command is executed; when the corresponding command item is triggered, the software environment to which the corresponding command item belongs executes the corresponding command execution code; in practice, for simplicity, the command execution code is usually a call to a simple entry function, which calls other modules, functions and executes more complex operation logic, thereby avoiding writing too complex command execution code directly in the configuration file.
Fig. 4 is a schematic diagram illustrating a structure of a menu object in an exemplary embodiment of the present disclosure. Specifically, the menu objects described herein may include a menu item object 401, a command item object 402, and a special item object 403, and all of the above objects are inherited from abstract menu elements, that is, the abstract menu elements are common parent classes of all types of objects involved in the menu, and the menu item object, the special item object, and the command item object are subclasses of the abstract menu elements; furthermore, the abstract menu element contains object attribute information 404, a parent object 405, an object name 406, an object creation interface 407, and the like, and these parts are all inherited by all child class objects of the abstract menu element by default, that is, any type of menu object contains the contents of these parts.
In an example embodiment, the object attribute information contains information required by the object in completing the creation or execution process; the parent object is a pointer, if the current menu object is not the top-level item of the menu, the pointer points to the parent menu object, and the parent menu object is a menu item object; further, the object name is the same as the object name in the aforementioned described configuration information; the object creation interface is a calling interface for external calling to convert the current menu object into the actual target menu control; further, as described above, the menu item object is inherited from the abstract menu element, so that the content included in the abstract menu element is included in the menu item object, and in addition, the menu item object additionally includes a sub-object list and an interface for adding the sub-object.
Hereinafter, each step included in the generation method of the menu shown in fig. 1 will be further explained and explained with reference to fig. 2 to 4. Specifically, the method comprises the following steps:
in step S110, a menu configuration file is obtained, and a target object generator is matched for the menu structure data in the menu configuration file.
In the exemplary embodiment of the present disclosure, obtaining a menu configuration file, and matching a target object generator for menu structure data in the menu configuration file may be implemented as follows: acquiring a menu configuration file through a menu generator, and analyzing the menu configuration file to obtain menu structure data and command execution statements included in the menu configuration file; transmitting the menu structure data and the command execution statement to a menu object aggregator included in the menu generator; wherein the menu object aggregator comprises a plurality of object generators; and sequentially traversing a plurality of object generators included in the menu object aggregator, and determining a target object generator matched with the menu structure data from the plurality of object generators. The menu structure data described here is menu structure data having a plurality of different levels; in the process of practical application, the menu structure data and the command execution statements of different levels can be sequentially transmitted to a menu object aggregator in a menu generator in a layer-by-layer transmission mode; and then, the menu object aggregator sequentially matches the menu structure data of different levels one by one, so that the menu structure data of each different level are sequentially matched with the corresponding target object generator.
It should be added that, in the actual application process, in the process of transferring the menu structure data to the menu object aggregator and matching the target menu generator for each menu structure data, the processing is performed in a recursive loop manner until the menu structure data of each level is processed; and after the menu structure data is transmitted to the menu object aggregator, traversing all the menu structure data through the menu object aggregator, analyzing the menu structure data through a configuration data analyzer included in the menu object aggregator, and further matching the analyzed menu structure data with a target menu generator.
In an example embodiment, in order to match the target object generator for the menu structure data in the menu configuration file, the method for generating the menu further comprises: registering the object generator in the menu object aggregator; among them, the object generators include a menu item object generator, a command item object generator, and a special item object generator, etc., that is, the menu item object generator, the command item object generator, and the special item object generator need to be all registered in the menu object aggregator.
In an example embodiment, sequentially traversing a plurality of object generators included in a menu object aggregator, and determining a target object generator from the plurality of object generators that matches the menu structure data may be implemented by: firstly, sequentially traversing object generators registered in a menu object aggregator, and matching menu structure data through the currently traversed object generators to obtain a matching result; secondly, if the matching result is that the object generator can process the menu structure data of the type, stopping traversing, and taking the object generator as a target object generator of the menu structure data; if the matching result is that the object generator cannot process the menu structure data of the type, continuing traversing until the object generator can identify the menu structure data of the type and taking the object generator as a target object generator of the menu structure data; if all the object generators can not identify the menu structure data of the type, discarding the menu structure data, and sequentially identifying all the menu structure data of the hierarchy until all the target object generators of the menu structure data of the hierarchy are matched; wherein one type of object generator can only recognize one type of menu structure data, and the types of the object generators are mutually exclusive.
In the following, the specific matching procedure of the target object generator will be further explained and explained. Specifically, first, a menu item object generator, a command item object generator, and a special item object generator are respectively registered in the menu object aggregator, and the object generators are respectively used for converting configuration data in a menu configuration file into corresponding menu objects; it should be added that these object generators need to be registered to the menu object aggregator because the menu object aggregator itself is agnostic about what object types are contained in the menu, it needs to perform layer-by-layer loop processing on the menu structure definition in the menu configuration data (wherein, the layer-by-layer loop processing described herein is implemented by the menu object aggregator in cooperation with each object generator; specifically, the menu object aggregator traverses from the top layer of the menu structure data, tries to match the target object generator on the menu structure data contained in this layer, and transfers this piece of menu structure data to the target object generator after matching, and the target object generator first generates the current menu object and adds it to the child object list of its parent object, and then, if the type of the current menu object is a menu item (only has a child list), finds the next layer of menu structure data from the transferred configuration data, and returns to the menu object aggregator, and then repeats the above processes (i.e., performs one more matching, object generation, and the like processes, and the corresponding menu structure data of the registered menu structure in the layer is obtained by the respective attempted menu object generators; that is, the menu object aggregator can match the corresponding type of target object generator for the menu structure data only on the premise that the registration of the menu item object generator, the command item object generator, and the special item object generator has been completed in advance; further, after the object generator is registered, the menu object aggregator obtains a menu structure definition (menu structure data) which is read and transmitted by the menu generator, and sequentially traverses the items of the current level in the menu structure definition; meanwhile, for each acquired configuration item, sequentially and circularly traversing the registered object generators in the menu object aggregator, and trying to match the current configuration item until the object type corresponding to the configuration item and the target object generator corresponding to the configuration item are matched. It should be added here that, among the registered object generators in the menu object aggregator, each object generator can only process one specific menu object type (i.e. can only process one type of menu structure data), and these types are mutually exclusive; therefore, in the specific matching process, the loop traversal can be finished as long as one object generator can match the object type of the menu structure data corresponding to the current configuration item; of course, if no object generator can match the current configuration entry at the end of the loop traversal, the current configuration entry is directly discarded and the next configuration entry is processed.
In step S120, a menu object is constructed according to the menu structure data and the target object generator, and the menu object is added to a pre-constructed child object list of the parent menu item object.
In the exemplary embodiment of the present disclosure, constructing a menu object according to the menu structure data and the target object generator, and adding the menu object to a pre-constructed child object list of a parent menu item object may be implemented as follows: firstly, carrying out layer-by-layer cyclic processing on the menu structure data through the menu object aggregator to obtain menu object configuration information included in the menu structure data; secondly, calling a corresponding target object generator to generate the menu object according to the configuration information of the menu object, and calling an adding sub-object interface of the pre-constructed parent level menu item object; then, the menu object is added to the child object list of the parent level menu item object through the add child object interface. That is, in a specific application process, firstly, the menu object aggregator creates a root menu item object (parent menu item object) as a top node of the whole tree-shaped menu structure, the node is unique, and the subsequent whole menu hierarchy structure is added below the root menu item layer by layer, so as to form a tree-shaped structure; then, the menu object aggregator performs layer-by-layer cyclic processing on the menu structure data to obtain menu object configuration information contained in each layer, and the target menu generator matched with the menu object configuration information generates a menu object according to the menu object configuration information; and finally, calling an adding sub-object interface of the parent-level menu item object, and adding the generated menu object to a sub-object list of the parent-level menu item object.
In step S130, a recursive process is performed on the menu objects included in the child object list to obtain a parent object and a child object, and a tree structure object set is generated according to the parent object and the child object.
In this example embodiment, the parent level menu item object may be set as the parent object of the currently created menu object first; then recursively processing the currently created menu objects until all nested menu objects of the whole tree structure are generated, and further storing the obtained tree structure object set in a menu object aggregator; the obtained tree structure object set may specifically refer to fig. 5. Meanwhile, as can be known by referring to the tree structure object set described in fig. 5, the whole menu structure is a tree structure, where the menu item includes a sub-item list, and the sub-item list may include any type of menu object, that is, the sub-item of the menu item may be a command item object or a special item object, or may be another menu item object, and there may be a sub-item at the next level below the sub-menu item.
It should be added that, if the created menu object type is a menu item, it may contain sub-items, and then recursive processing needs to be performed on the menu sub-item list in the configuration data corresponding to the current menu item, that is, recursive processing needs to be performed on the menu object included in the sub-object list; if the created menu object type is not a menu item, the sub item is not included.
In step S140, a menu control corresponding to the menu object included in the tree structure object set is created, and a target menu is generated according to the menu control and the hierarchical relationship between the menu controls.
In the present exemplary embodiment, first, a menu control corresponding to a menu object included in each hierarchy of the tree structure object set is created; specifically, the method can be realized by the following steps: firstly, traversing the tree structure object set in a preset traversing mode layer by layer in sequence from a root menu item object in the tree structure object set, and transferring a menu generating function in the specific implementation of the menu generator to each traversed menu object; secondly, calling a target menu control generating function corresponding to each menu object through the menu generator to obtain a menu control corresponding to the menu object in each level in the tree structure object set; the method comprises the following steps of calling a target menu control generating function corresponding to each menu object through the menu generator to obtain a menu control corresponding to the menu object in each level in the tree structure object set, and realizing the following steps: firstly, determining a generation function required to be called for generating a menu control corresponding to each menu object according to the category of each menu object through the menu generator; and secondly, calling a target menu control generating function corresponding to each menu object through the menu generator, and generating a menu control corresponding to the menu object in each level in the tree structure object set through the generating function.
Hereinafter, a specific generation process of the menu control will be explained and explained. Specifically, firstly, since the concrete implementation of each menu generator is inherited from the abstract menu generator, additional operations can be added according to actual needs in the process of creating the menu control by each menu generator, which is not particularly limited in this example; secondly, sequentially traversing the whole tree structure object set (menu object tree) downwards layer by layer from a root menu item object in the tree structure object set, and transmitting a specific implementation of a menu generator into each traversed menu object; the step is equivalent to the step of injecting the menu creation implementation under the actual software environment into the corresponding menu object and calling the menu object, so that the corresponding menu control is created on the target menu of the actual software environment; moreover, the menu creation is realized in the injection-dependent mode, so that the menu object can be ensured to be independent of the actual software environment, all codes related to the actual software environment are encapsulated in the specific realization of the menu generator, different specific realizations of the menu generator only need to be written for different software environments, and the codes of other modules do not need to be modified at all; furthermore, in the specific implementation of the menu generator, a generating function for each menu object type is provided, and the generating function is used for creating the menu object as a corresponding menu control on the target menu in the actual software environment; meanwhile, interface specifications of the generated functions are defined in the abstract menu generator, and all the specific implementations of the menu generator are inherited from the abstract menu generator, so that the calling modes of the generated functions are uniform; moreover, since the specific implementation of the menu generator is related to the actual software environment and has no abstract generality, these generating functions may be registered in the specific implementation of the menu generator in a registration manner, or function codes may be directly written in the specific implementation of the menu generator, which is not particularly limited in this example; meanwhile, in the traversing process, the type attribute of each traversed menu object is used for judging which generating function the menu object should call, the menu object is transmitted into the generating function after the generating function is matched, and the generating function is executed to create an actual menu control; of course, if the generation function conforming to the object type is not matched, an abnormal error report is thrown out; furthermore, if the currently traversed menu object type is a menu item object, the sub-list of the currently traversed menu object type includes sub-level menu objects thereof, and recursive processing needs to be performed on the sub-level menu objects, so as to obtain sub-level menu controls of the sub-level menu objects, until all objects in the nested menu object set are traversed and generated; finally, before the menu control creating process is started and after the menu control creating process is completed, corresponding additional operations can be executed; the additional operation is null in the default condition, namely the step is directly skipped over, but the specific implementation of each menu generator can write the additional operation according to the actual requirement.
Secondly, after the menu control is obtained, a target menu can be generated according to the menu control and the hierarchical relation between the menu controls; the obtained target menu may specifically refer to fig. 6 and fig. 7; among them, in the target menu of the menu item objects shown in fig. 6, it may include a root menu item, a menu item object; the sub-item list of menu item objects shown in fig. 7 may include command item objects (e.g., center, aligned on both ends, left aligned, right aligned, etc.) therein. It should be added that the function of the menu item object described in the exemplary embodiment of the present disclosure is to expand, and when the menu item object is clicked, the sub-item list corresponding to the menu item object may be expanded, but the menu item object itself does not perform any operation, and does not generate any function on the software environment; meanwhile, the command item object has no sub-item and cannot be expanded, and corresponding command operation can be executed by clicking the command item object, so that the software environment is correspondingly changed; also, for a particular item, its role includes, but is not limited to, delimiters and the like.
Hereinafter, a generation method of the menu described in the exemplary embodiment of the present disclosure will be further explained and explained with reference to fig. 8. Specifically, referring to fig. 8, the method for generating the menu may include the following steps:
step S801, respectively registering a menu item object generator, a command item object generator and a special item object generator to the menu object aggregator;
step S802, the menu object aggregator firstly creates a root menu item object as the top node of the whole tree-shaped menu structure; wherein, the node is unique, the subsequent whole menu hierarchy structure is added below the root menu item layer by layer, thereby forming a tree structure;
step S803, the menu object aggregator obtains the menu structure definition which is read and transmitted by the menu generator, and the menu structure definition circularly traverses the object generator in sequence to match the menu structure data with the target object generator;
step S804, generating a corresponding menu object according to the current configuration item through the object generator, and calling an adding sub-object interface of the parent level menu item object to add the generated menu object to a sub-object list of the parent level menu item object;
step S805, generating a tree structure object set according to the sub-object list, sequentially traversing the whole tree structure object set layer by layer downwards, and transmitting the current menu generator into each traversed menu object to construct a menu control;
and step 806, generating a target menu according to the menu controls and the hierarchical relationship among the menu controls.
Up to this point, the generation method of the menu described in the exemplary embodiment of the present disclosure has been entirely realized. Based on the foregoing description, it can be seen that the method for generating a menu according to the exemplary embodiment of the present disclosure has at least the following advantages: on one hand, because the menu configuration file only contains the menu definition, but does not contain other irrelevant components of the application program and the target menu, and uses the text form and the structure which are easy to understand, the modification is easier and more intuitive than the interface design draft, the code, the QML script and the like which are involved in the prior proposal, and a developer only needs to modify the configuration file to complete the updating and maintenance of the menu without modifying a plurality of codes and repeatedly testing as before; on the other hand, the automatic aggregation processing of a plurality of configuration files can be realized, even the inheritance, the coverage, the conditional screening and the like of the configuration data on the logic are realized, so that different configuration data can be automatically loaded under different environmental conditions, and different menus can be obtained. The method further improves the dynamic generation characteristic and the changing capability of the menu, and a developer does not need to modify any codes in the whole process; on the other hand, the inheritance and polymorphic relation between the menu generating function and the specific implementation of various menu generators greatly improve the reusability of the menu generating function, and the same calling interface and processing logic are used, so that the same configuration file can be used for respectively generating menus under different software environments only by using different specific implementations of the menu generators, and the workload of repeatedly configuring the menu contents in different software environments is reduced; furthermore, the specific implementation of each menu creator is stateless and reusable, and can be continuously and repeatedly used once written out; therefore, developers can create different menus by using the same menu creator only by compiling different menu configuration files, and the whole process does not need to modify codes, so that the efficiency of creating, managing and changing the menus is greatly improved; in addition, one menu creator can process all menu creation works of the corresponding software environment, and developers do not need to repeatedly write codes and logics related to menu creation, so that the development efficiency of the target menu application program is remarkably improved.
It should be further added that, in the menu generation method described in the exemplary embodiment of the present disclosure, the menu creation and maintenance process is separated in business and technology by means of the menu configuration file and the abstracted menu generator design; meanwhile, although the example embodiments of the present disclosure have the Qt framework as a specific embodiment, the solution proposed by the present disclosure is actually applicable to any target menu programming framework, because the call related to the target menu programming framework is only implemented in the menu generator, and the menu creation can be implemented using the solution as long as the framework supports the creation of menu items, command items, and the like in a tree structure; moreover, on the basis that some software provides proprietary menu creation APIs (for example, maya and Nuke both provide their own menu creation APIs, which are simplified interfaces packaged on the basis of Qt in nature), these APIs may also be called in the specific implementation of the menu generator to implement menu creation by means of the solution described in the present disclosure; that is, the specific implementation of the menu generator related to the menu generation method described in the exemplary embodiment of the present disclosure is not limited to the menu creation API using the Qt framework.
The embodiment of the disclosure also provides a device for generating the menu. Specifically, referring to fig. 9, the menu generating apparatus may include an object generator matching module 910, a menu object constructing module 920, a tree structure object set generating module 930, and a user interface generating module 940.
Wherein:
an object generator matching module 910, configured to obtain a menu configuration file, and match a target object generator with menu structure data in the menu configuration file;
the menu object constructing module 920 may be configured to construct a menu object according to the menu structure data and the target object generator, and add the menu object to a pre-constructed child object list of a parent level menu item object;
a tree structure object set generating module 930, configured to perform recursive processing on the menu objects included in the child object list to obtain a parent object and a child object, and generate a tree structure object set according to the parent object and the child object;
the user interface generating module 940 may be configured to create a menu control corresponding to a menu object included in the tree structure object set, and generate a target menu according to the menu control and a hierarchical relationship between the menu controls.
In an example embodiment of the present disclosure, obtaining a menu configuration file and matching a target object generator for menu structure data in the menu configuration file includes: acquiring a menu configuration file through a menu generator, and analyzing the menu configuration file to obtain menu structure data and command execution statements included in the menu configuration file; transmitting the menu structure data and the command execution statement to a menu object aggregator included in the menu generator; wherein the menu object aggregator comprises a plurality of object generators; and sequentially traversing a plurality of object generators included in the menu object aggregator, and determining a target object generator matched with the menu structure data from the plurality of object generators.
In an example embodiment of the present disclosure, the menu generating apparatus further includes:
an object generator registration module for registering the object generator in the menu object aggregator; wherein the object generator includes at least one of a menu item object generator, a command item object generator, and a special item object generator.
In an example embodiment of the present disclosure, sequentially traversing a plurality of object generators included in a menu object aggregator, and determining a target object generator matching the menu structure data from the plurality of object generators, includes: sequentially traversing object generators included in the menu object aggregator, and matching menu structure data in the menu structure data through the currently traversed object generators to obtain a matching result; if the matching result is that the object generator can process the menu structure data of the type, stopping traversing and taking the object generator as a target object generator of the menu structure data; if the matching result is that the object generator can not process the menu structure data of the type, continuing traversing until the object generator can process the menu structure data of the type, and taking the object generator as a target object generator of the menu structure data; if all the object generators can not process the menu structure data of the type, discarding the menu object, and matching all the menu objects in sequence until the target object generators of the menu objects are matched; wherein one type of object generator can process only one type of menu structure data, and the types of the object generators are mutually exclusive.
In an example embodiment of the present disclosure, the menu structure data is used to describe hierarchical positional relationships between various different types of menu objects, and attribute configuration information of each menu object, and the command execution statements are used to define a mapping relationship between a list of command statements allowed to be executed by a command item and an abbreviation of each command statement; the menu structure data comprises attribute configuration information of a menu object, and the attribute configuration information of the menu object comprises a menu object name and menu object display information; wherein a menu item object in the menu object comprises the attribute configuration information and a sub item list; the menu object display information is used for defining the information and the style of the menu object actually displayed on the target menu, and comprises at least one of text, icons, prompts and display styles; the sub-item list of the menu item object is a list composed of other menu objects of any type, and the other menu objects are used for representing the secondary menu objects of the current menu item object.
In an example embodiment of the present disclosure, the menu item object, the command item object, and the special item object are subclasses of abstract menu elements; the abstract menu elements comprise attribute information of menu objects, parent objects and object creation interfaces; the attribute information of the menu object comprises information required by the menu object in the process of completing creation or execution; the parent object is a pointer, and if the current menu object is not a top-level item, the pointer of the parent object points to a parent-level menu item object of the current menu object; the object creation interface is for external calls to convert a current menu object into a menu control.
In an example embodiment of the present disclosure, constructing a menu object according to the menu structure data and the target object generator, and adding the menu object to a pre-constructed child object list of a parent menu item object, includes: generating the menu object through a target object generator corresponding to menu structure data, and filling attribute information in the menu object by using the menu structure data; calling an adding child object interface of the pre-constructed parent-level menu item object; and adding the menu object into a child object list of the parent level menu item object through the adding child object interface, and setting the parent level menu item object as a parent object of the menu object.
In an example embodiment of the present disclosure, creating a menu control corresponding to a menu object included in each level in a tree structure object set includes: traversing the tree structure object set from a root menu item object in the tree structure object set, and transferring a target menu control generating function in the menu generator to each traversed menu object; and calling a target menu control generating function corresponding to each menu object through the menu generator to obtain a menu control corresponding to the menu object in the tree structure object set.
In an example embodiment of the present disclosure, the obtaining, by the menu generator calling a target menu control generating function corresponding to each menu object, a menu control corresponding to a menu object included in a tree structure object set includes: determining a target menu control generation function required to be called for generating a menu control corresponding to each menu object according to the category of each menu object by the menu generator; and calling a target menu control generating function corresponding to each menu object through the menu generator, and generating a menu control corresponding to the menu object in the tree structure object set through the target menu control generating function.
The specific details of each module in the menu generating device have been described in detail in the corresponding menu generating method, and therefore are not described herein again.
It should be noted that although in the above detailed description several modules or units of the device for action execution are mentioned, such a division is not mandatory. Indeed, the features and functions of two or more modules or units described above may be embodied in one module or unit, according to embodiments of the present disclosure. Conversely, the features and functions of one module or unit described above may be further divided into embodiments by a plurality of modules or units.
Moreover, although the steps of the methods of the present disclosure are depicted in the drawings in a particular order, this does not require or imply that the steps must be performed in this particular order, or that all of the depicted steps must be performed, to achieve desirable results. Additionally or alternatively, certain steps may be omitted, multiple steps combined into one step execution, and/or one step broken down into multiple step executions, etc.
In an exemplary embodiment of the present disclosure, an electronic device capable of implementing the above method is also provided.
As will be appreciated by one skilled in the art, aspects of the present disclosure may be embodied as a system, method or program product. Accordingly, various aspects of the present disclosure may be embodied in the form of: an entirely hardware embodiment, an entirely software embodiment (including firmware, microcode, etc.) or an embodiment combining hardware and software aspects that may all generally be referred to herein as a "circuit," module "or" system.
An electronic device 1000 according to this embodiment of the disclosure is described below with reference to fig. 10. The electronic device 1000 shown in fig. 10 is only an example and should not bring any limitation to the functions and the scope of use of the embodiments of the present disclosure.
As shown in fig. 10, the electronic device 1000 is in the form of a general purpose computing device. The components of the electronic device 1000 may include, but are not limited to: the at least one processing unit 1010, the at least one memory unit 1020, a bus 1030 connecting different system components (including the memory unit 1020 and the processing unit 1010), and a display unit 1040.
Wherein the storage unit stores program code that is executable by the processing unit 1010 to cause the processing unit 1010 to perform steps according to various exemplary embodiments of the present disclosure described in the above section "exemplary methods" of the present specification. For example, the processing unit 1010 may execute step S110 as shown in fig. 1: acquiring a menu configuration file, and matching menu structure data in the menu configuration file with a target object generator; step S120: constructing a menu object according to the menu structure data and the target object generator, and adding the menu object to a pre-constructed child object list of a parent level menu item object; step S130: carrying out recursion processing on the menu objects included in the child object list to obtain a parent object and a child object, and generating a tree structure object set according to the parent object and the child object; step S140: and creating a menu control corresponding to the menu object in the tree structure object set, and generating a target menu according to the menu control and the hierarchical relation between the menu controls.
The storage unit 1020 may include readable media in the form of volatile memory units, such as a random access memory unit (RAM) 10201 and/or a cache memory unit 10202, and may further include a read-only memory unit (ROM) 10203.
The memory unit 1020 may also include a program/utility 10204 having a set (at least one) of program modules 10205, such program modules 10205 including, but not limited to: an operating system, one or more application programs, other program modules, and program data, each of which, or some combination thereof, may comprise an implementation of a network environment.
Bus 1030 may be any bus representing one or more of several types of bus structures, including a memory unit bus or memory unit controller, a peripheral bus, an accelerated graphics port, a processing unit, or a local bus using any of a variety of bus architectures.
The electronic device 1000 may also communicate with one or more external devices 1100 (e.g., keyboard, pointing device, bluetooth device, etc.), with one or more devices that enable a user to interact with the electronic device 1000, and/or with any devices (e.g., router, modem, etc.) that enable the electronic device 1000 to communicate with one or more other computing devices. Such communication may occur through input/output (I/O) interfaces 1050. Also, the electronic device 1000 may communicate with one or more networks (e.g., a Local Area Network (LAN), a Wide Area Network (WAN), and/or a public network such as the internet) via the network adapter 1060. As shown, the network adapter 1060 communicates with the other modules of the electronic device 1000 over the bus 1030. It should be understood that although not shown in the figures, other hardware and/or software modules may be used in conjunction with the electronic device 1000, including but not limited to: microcode, device drivers, redundant processing units, external disk drive arrays, RAID systems, tape drives, and data backup storage systems, among others.
Through the above description of the embodiments, those skilled in the art will readily understand that the exemplary embodiments described herein may be implemented by software, and may also be implemented by software in combination with necessary hardware. Therefore, the technical solution according to the embodiments of the present disclosure may be embodied in the form of a software product, which may be stored in a non-volatile storage medium (which may be a CD-ROM, a usb disk, a removable hard disk, etc.) or on a network, and includes several instructions to enable a computing device (which may be a personal computer, a server, a terminal device, or a network device, etc.) to execute the method according to the embodiments of the present disclosure.
In an exemplary embodiment of the present disclosure, there is also provided a computer readable storage medium having stored thereon a program product capable of implementing the above-described method of the present specification. In some possible embodiments, various aspects of the disclosure may also be implemented in the form of a program product comprising program code for causing a terminal device to perform the steps according to various exemplary embodiments of the disclosure described in the "exemplary methods" section above of this specification, when the program product is run on the terminal device.
According to the program product for implementing the above method of the embodiments of the present disclosure, it may employ a portable compact disc read only memory (CD-ROM) and include program codes, and may be run on a terminal device, such as a personal computer. However, the program product of the present disclosure is not limited thereto, and in this document, a readable storage medium may be any tangible medium that can contain, or store a program for use by or in connection with an instruction execution system, apparatus, or device.
The program product may employ any combination of one or more readable media. The readable medium may be a readable signal medium or a readable storage medium. A readable storage medium may be, for example, but not limited to, an electronic, magnetic, optical, electromagnetic, infrared, or semiconductor system, apparatus, or device, or any combination of the foregoing. More specific examples (a non-exhaustive list) of the readable storage medium include: an electrical connection having one or more wires, a portable disk, a hard disk, a Random Access Memory (RAM), a read-only memory (ROM), an erasable programmable read-only memory (EPROM or flash memory), an optical fiber, a portable compact disc read-only memory (CD-ROM), an optical storage device, a magnetic storage device, or any suitable combination of the foregoing.
A computer readable signal medium may include a propagated data signal with readable program code embodied therein, for example, in baseband or as part of a carrier wave. Such a propagated data signal may take many forms, including, but not limited to, electro-magnetic, optical, or any suitable combination thereof. A readable signal medium may be any readable medium that is not a readable storage medium and that can communicate, propagate, or transport a program for use by or in connection with an instruction execution system, apparatus, or device.
Program code embodied on a readable medium may be transmitted using any appropriate medium, including but not limited to wireless, wireline, optical fiber cable, RF, etc., or any suitable combination of the foregoing.
Program code for carrying out operations of the present disclosure may be written in any combination of one or more programming languages, including an object oriented programming language such as Java, C + +, or the like. The program code may execute entirely on the user's computing device, partly on the user's device, as a stand-alone software package, partly on the user's computing device and partly on a remote computing device, or entirely on the remote computing device or server. In situations involving remote computing devices, the remote computing devices may be connected to the user computing device through any kind of network, including a Local Area Network (LAN) or a Wide Area Network (WAN), or may be connected to external computing devices (e.g., through the internet using an internet service provider).
Furthermore, the above-described figures are merely schematic illustrations of processes included in methods according to exemplary embodiments of the present disclosure, and are not intended to be limiting. It will be readily understood that the processes shown in the above figures are not intended to indicate or limit the chronological order of the processes. In addition, it is also readily understood that these processes may be performed synchronously or asynchronously, e.g., in multiple modules.
Other embodiments of the disclosure will be apparent to those skilled in the art from consideration of the specification and practice of the invention disclosed herein. This application is intended to cover any variations, uses, or adaptations of the disclosure following, in general, the principles of the disclosure and including such departures from the present disclosure as come within known or customary practice within the art to which the disclosure pertains. It is intended that the specification and examples be considered as exemplary only, with a true scope and spirit of the disclosure being indicated by the following claims.

Claims (12)

1. A method for generating a menu, comprising:
acquiring a menu configuration file, and matching menu structure data in the menu configuration file with a target object generator;
constructing a menu object according to the menu structure data and the target object generator, and adding the menu object to a pre-constructed child object list of a parent level menu item object;
carrying out recursion processing on the menu objects included in the child object list to obtain a parent object and a child object, and generating a tree-structured object set according to the parent object and the child object;
and creating a menu control corresponding to the menu object in the tree structure object set, and generating a target menu according to the menu control and the hierarchical relation between the menu controls.
2. The method of claim 1, wherein obtaining a menu configuration file and matching a target object generator for menu structure data in the menu configuration file comprises:
acquiring a menu configuration file through a menu generator, and analyzing the menu configuration file to obtain menu structure data and command execution statements included in the menu configuration file;
transmitting the menu structure data and the command execution statement to a menu object aggregator included in the menu generator; wherein the menu object aggregator comprises a plurality of object generators;
and traversing a plurality of object generators included in the menu object aggregator in sequence, and determining a target object generator matched with the menu structure data from the plurality of object generators.
3. The method of generating a menu according to claim 2, wherein before sequentially traversing the object generators included in the menu object aggregator, the method of generating a menu further comprises:
registering the object generator in the menu object aggregator; wherein the object generator includes at least one of a menu item object generator, a command item object generator, and a special item object generator.
4. The method of claim 2, wherein traversing a plurality of object generators included in a menu object aggregator in sequence, determining a target object generator from the plurality of object generators that matches the menu structure data comprises:
sequentially traversing a plurality of object generators included in the menu object aggregator, and matching menu structure data in the menu structure data through the currently traversed object generators to obtain a matching result;
if the matching result is that the object generator can process the menu structure data of the type, stopping traversing, and taking the object generator as a target object generator of the menu structure data;
if the matching result is that the object generator can not process the menu structure data of the type, continuing traversing until the object generator can process the menu structure data of the type, and taking the object generator as a target object generator of the menu structure data;
if all the object generators cannot process the menu structure data of the type, discarding the menu object, and matching all the menu objects in sequence until all the target object generators of the menu objects are matched;
wherein one type of object generator can process only one type of menu structure data, and the types of the object generators are mutually exclusive.
5. The menu generation method according to any one of claims 2 to 4, wherein the menu structure data is used to describe a hierarchical position relationship between various different types of menu objects and attribute configuration information of each menu object, and the command execution statements are used to define a mapping relationship between a list of command statements allowed to be executed by a command item and an abbreviation of each command statement;
the menu structure data comprises attribute configuration information of a menu object, and the attribute configuration information of the menu object comprises a menu object name and menu object display information; wherein a menu item object in the menu object comprises the attribute configuration information and a sub item list;
the menu object display information is used for defining the information and the style of the menu object actually displayed on the target menu, and comprises at least one of text, icons, prompts and display styles;
the sub-item list of the menu item object is a list composed of other menu objects of any type, and the other menu objects are used for representing the secondary menu objects of the current menu item object.
6. A menu generation method according to any of claims 2 to 4, characterized in that the menu item objects, command item objects and special item objects are sub-classes of abstract menu elements;
the abstract menu elements comprise attribute information of menu objects, parent objects and object creation interfaces;
the attribute information of the menu object comprises information required by the menu object in the process of completing creation or execution;
the parent object is a pointer, and if the current menu object is not a top item, the pointer of the parent object points to a parent menu item object of the current menu object;
the object creation interface is for external calls to convert a current menu object into a menu control.
7. The method for generating a menu according to claim 1, wherein constructing a menu object according to the menu structure data and a target object generator, and adding the menu object to a pre-constructed child object list of a parent menu item object comprises:
generating the menu object through a target object generator corresponding to menu structure data, and filling attribute information in the menu object by using the menu structure data;
calling an adding child object interface of the pre-constructed parent-level menu item object;
and adding the menu object into a child object list of the parent menu item object through an adding child object interface, and setting the parent menu item object as a parent object of the menu object.
8. The method of generating a menu according to claim 1, wherein creating a menu control corresponding to a menu object included in the tree-structured object set includes:
traversing the tree structure object set from a root menu item object in the tree structure object set, and transferring a target menu control generating function in the menu generator to each traversed menu object;
and calling a target menu control generating function corresponding to each menu object through the menu generator to obtain a menu control corresponding to the menu object in the tree structure object set.
9. The method of claim 8, wherein the obtaining of the menu control corresponding to the menu object included in the tree structure object set by calling a target menu control generating function corresponding to each menu object through the menu generator comprises:
determining a target menu control generation function required to be called for generating a menu control corresponding to each menu object according to the category of each menu object by the menu generator;
and calling a target menu control generating function corresponding to each menu object through the menu generator, and generating a menu control corresponding to the menu object in the tree structure object set through the target menu control generating function.
10. An apparatus for generating a menu, comprising:
the object generator matching module is used for acquiring a menu configuration file and matching menu structure data in the menu configuration file with a target object generator;
the menu object construction module is used for constructing a menu object according to the menu structure data and the target object generator, and adding the menu object to a pre-constructed child object list of a parent level menu item object;
a tree structure object set generating module, configured to perform recursive processing on the menu objects included in the child object list to obtain a parent object and a child object, and generate a tree structure object set according to the parent object and the child object;
and the user interface generating module is used for creating a menu control corresponding to the menu object included in the tree structure object set and generating a target menu according to the menu control and the hierarchical relation between the menu controls.
11. A computer-readable storage medium, on which a computer program is stored, which computer program, when being executed by a processor, carries out the method of generating a menu according to any one of claims 1 to 9.
12. An electronic device, comprising:
a processor; and
a memory for storing executable instructions of the processor;
wherein the processor is configured to perform the method of generating a menu of any one of claims 1-9 via execution of the executable instructions.
CN202211741091.5A 2022-12-30 2022-12-30 Menu generation method and device, storage medium and electronic equipment Pending CN115964042A (en)

Priority Applications (1)

Application Number Priority Date Filing Date Title
CN202211741091.5A CN115964042A (en) 2022-12-30 2022-12-30 Menu generation method and device, storage medium and electronic equipment

Applications Claiming Priority (1)

Application Number Priority Date Filing Date Title
CN202211741091.5A CN115964042A (en) 2022-12-30 2022-12-30 Menu generation method and device, storage medium and electronic equipment

Publications (1)

Publication Number Publication Date
CN115964042A true CN115964042A (en) 2023-04-14

Family

ID=87352951

Family Applications (1)

Application Number Title Priority Date Filing Date
CN202211741091.5A Pending CN115964042A (en) 2022-12-30 2022-12-30 Menu generation method and device, storage medium and electronic equipment

Country Status (1)

Country Link
CN (1) CN115964042A (en)

Cited By (1)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN116185413A (en) * 2023-04-24 2023-05-30 山东捷瑞数字科技股份有限公司 Method, system, device and medium for generating specified menu based on three-dimensional engine

Cited By (1)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN116185413A (en) * 2023-04-24 2023-05-30 山东捷瑞数字科技股份有限公司 Method, system, device and medium for generating specified menu based on three-dimensional engine

Similar Documents

Publication Publication Date Title
US12086535B2 (en) Systems and methods of a script generation engine
US9465590B2 (en) Code generation framework for application program interface for model
US10489274B2 (en) Using emulation to disassociate verification from stimulus in functional test
US20090254881A1 (en) Code generation techniques for administrative tasks
US10162605B2 (en) Code snippet content recommendation to define an object literal
US10248386B2 (en) Generating a software complex using superordinate design input
US10572278B2 (en) Smart controls for user interface design and implementation
US20160321055A1 (en) Mapping between local and remote for seamless build and design time experience
US20190370028A1 (en) Managing discovery and selection of service interface specifications
US20140245269A1 (en) Compact encoding of node locations
US20200394055A1 (en) System and method for providing a configurable user interface using a self-describing data system
US11288062B2 (en) Automatic source code refactoring
CN104199647A (en) Visualization system and implementation method based on IBM host
CN106484389B (en) Action stream segment management
US9678856B2 (en) Annotated test interfaces
Song et al. Applying MDE tools at runtime: Experiments upon runtime models
US8875089B2 (en) Workspace model for interrelated projects
CN115964042A (en) Menu generation method and device, storage medium and electronic equipment
CN114217789A (en) Function component expansion method, device, equipment, storage medium and program product
WO2021129812A1 (en) Method and system for running artificial intelligence application, and device
CN113656001A (en) Platform component development method and device, computer equipment and storage medium
JP2023528102A (en) Dependency graph generation method, device, device, storage medium, and program product
US20230393836A1 (en) Method and apparatus for updating cloud platform
US20230418574A1 (en) Using a semantic tree of a compiler to execute a semantic code query against source code
CN117667112A (en) Self-adaptive generation method of front-end development document based on babel

Legal Events

Date Code Title Description
PB01 Publication
PB01 Publication
SE01 Entry into force of request for substantive examination
SE01 Entry into force of request for substantive examination