1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149
|
/***************************************************************************
MenuManager.h - manager class for Kwave's menu structure
-------------------
begin : Sun Jun 4 2000
copyright : (C) 2000 by Thomas Eschenbacher
email : Thomas.Eschenbacher@gmx.de
***************************************************************************/
/***************************************************************************
* *
* This program is free software; you can redistribute it and/or modify *
* it under the terms of the GNU General Public License as published by *
* the Free Software Foundation; either version 2 of the License, or *
* (at your option) any later version. *
* *
***************************************************************************/
#ifndef MENU_MANAGER_H
#define MENU_MANAGER_H
#include "config.h"
#include "libkwavegui_export.h"
#include <QtGlobal>
#include <QMap>
#include <QObject>
class QString;
class QWidget;
class QMenuBar;
namespace Kwave
{
class MenuRoot;
/**
* @class MenuManager
* @brief Manager class for access to Kwave's menu subsystem.
*
* @note All commands must be emitted synchronously during X11 event
* processing instead of immediately through normal signal
* handling. This avoids trouble when a signal handler within
* the MenuNode class causes an action that deletes that menu
* node. <em>It took me one week to find that bug!</em>
*/
class LIBKWAVEGUI_EXPORT MenuManager: public QObject
{
Q_OBJECT
public:
/**
* Constructor.
* @param parent the menu's parent widget
* @param bar reference to the menu bar
*/
MenuManager(QWidget *parent, QMenuBar &bar);
/** Destructor. */
~MenuManager() override;
/**
* Executes menu commands.
* @param command string with the command
* @retval 0 if succeeded
* @retval -EINVAL if failed
*/
int executeCommand(const QString &command);
/**
* Deletes all entries of a numbered menu
* @param uid unique id string of the numbered menu
*/
void clearNumberedMenu(const QString &uid);
/**
* Add an entry to a numbered menu
* @param uid unique id string of the numbered menu
* @param entry name of the new entry (non-localized)
* @param param a parameter to use when the entry is
* activated (optional, pass QString() when using
* the text of the menu entry as parameter)
*/
void addNumberedMenuEntry(const QString &uid, const QString &entry,
const QString ¶m);
/**
* Selects an menu item within a group of menu items. All other
* items will be deselected and the new one will become the only
* selected one. (exclusive one-of-n-selection)
* @param group name of the menu group
* @param uid unique id string specifying the new selection
*/
void selectItem(const QString &group, const QString &uid);
/**
* Sets the text of a menu entry to a new value.
* @param uid unique id string of the menu node
* @param text the new text of the item
*/
void setItemText(const QString &uid, const QString &text);
/**
* Shows/hides a menu entry identified by an ID. Groups are
* not supported.
* @param uid unique id string of the menu node
* @param show true to show, false to hide
*/
void setItemVisible(const QString &uid, bool show);
public slots:
/**
* Checks/unchecks a menu node.
* @param uid unique id string of the menu node
* @param check true to set a checkmark, false to remove
*/
void setItemChecked(const QString &uid, bool check);
/**
* Enables/disables a menu node.
* @param uid unique id string of the menu node
* @param enable true to enable, false to disable
*/
void setItemEnabled(const QString &uid, bool enable);
signals:
/**
* Will be emitted if the command of a menu node
* should be executed.
* @see MenuNode.sigCommand()
*/
void sigMenuCommand(const QString &command);
private:
/** root node of the menu structure */
Kwave::MenuRoot *m_menu_root;
/** map of standard key names / key sequences */
static QMap<QString, QKeySequence> m_standard_keys;
};
}
#endif // _MENU_MANAGER_H_
//***************************************************************************
//***************************************************************************
|