BRIDGE+GUI: implement GuiMenuRemove
This commit is contained in:
parent
42b9b0f9dc
commit
c43b64cdec
|
|
@ -1356,6 +1356,11 @@ BRIDGE_IMPEXP void GuiMenuClear(int hMenu)
|
|||
_gui_sendmessage(GUI_MENU_CLEAR, (void*)(duint)hMenu, 0);
|
||||
}
|
||||
|
||||
BRIDGE_IMPEXP void GuiMenuRemove(int hEntryMenu)
|
||||
{
|
||||
_gui_sendmessage(GUI_MENU_REMOVE, (void*)(duint)hEntryMenu, 0);
|
||||
}
|
||||
|
||||
BRIDGE_IMPEXP bool GuiSelectionGet(int hWindow, SELECTIONDATA* selection)
|
||||
{
|
||||
return !!_gui_sendmessage(GUI_SELECTION_GET, (void*)(duint)hWindow, selection);
|
||||
|
|
|
|||
|
|
@ -1002,6 +1002,7 @@ typedef enum
|
|||
GUI_MENU_SET_ENTRY_HOTKEY, // param1=int hEntry, param2=const char* hack
|
||||
GUI_REF_SEARCH_GETROWCOUNT, // param1=unused, param2=unused
|
||||
GUI_REF_SEARCH_GETCELLCONTENT, // param1=int row, param2=int col
|
||||
GUI_MENU_REMOVE, // param1=int hEntryMenu, param2=unused
|
||||
} GUIMSG;
|
||||
|
||||
//GUI Typedefs
|
||||
|
|
@ -1116,6 +1117,7 @@ BRIDGE_IMPEXP int GuiMenuAdd(int hMenu, const char* title);
|
|||
BRIDGE_IMPEXP int GuiMenuAddEntry(int hMenu, const char* title);
|
||||
BRIDGE_IMPEXP void GuiMenuAddSeparator(int hMenu);
|
||||
BRIDGE_IMPEXP void GuiMenuClear(int hMenu);
|
||||
BRIDGE_IMPEXP void GuiMenuRemove(int hEntryMenu);
|
||||
BRIDGE_IMPEXP bool GuiSelectionGet(int hWindow, SELECTIONDATA* selection);
|
||||
BRIDGE_IMPEXP bool GuiSelectionSet(int hWindow, const SELECTIONDATA* selection);
|
||||
BRIDGE_IMPEXP bool GuiGetLineWindow(const char* title, char* text);
|
||||
|
|
|
|||
|
|
@ -360,11 +360,18 @@ void* Bridge::processMessage(GUIMSG type, void* param1, void* param2)
|
|||
case GUI_MENU_CLEAR:
|
||||
{
|
||||
BridgeResult result;
|
||||
emit menuClearMenu((int)param1);
|
||||
emit menuClearMenu((int)param1, false);
|
||||
result.Wait();
|
||||
}
|
||||
break;
|
||||
|
||||
case GUI_MENU_REMOVE:
|
||||
{
|
||||
BridgeResult result;
|
||||
emit menuRemoveMenuEntry((int)param1);
|
||||
result.Wait();
|
||||
}
|
||||
|
||||
case GUI_SELECTION_GET:
|
||||
{
|
||||
int hWindow = (int)param1;
|
||||
|
|
|
|||
|
|
@ -87,8 +87,8 @@ signals:
|
|||
void menuAddMenu(int hMenu, QString title);
|
||||
void menuAddMenuEntry(int hMenu, QString title);
|
||||
void menuAddSeparator(int hMenu);
|
||||
void menuClearMenu(int hMenu);
|
||||
void menuRemoveMenuEntry(int hEntry);
|
||||
void menuClearMenu(int hMenu, bool erase);
|
||||
void menuRemoveMenuEntry(int hEntryMenu);
|
||||
void selectionDisasmGet(SELECTIONDATA* selection);
|
||||
void selectionDisasmSet(const SELECTIONDATA* selection);
|
||||
void selectionDumpGet(SELECTIONDATA* selection);
|
||||
|
|
|
|||
|
|
@ -74,7 +74,7 @@ MainWindow::MainWindow(QWidget* parent)
|
|||
connect(Bridge::getBridge(), SIGNAL(menuAddMenu(int, QString)), this, SLOT(addMenu(int, QString)));
|
||||
connect(Bridge::getBridge(), SIGNAL(menuAddMenuEntry(int, QString)), this, SLOT(addMenuEntry(int, QString)));
|
||||
connect(Bridge::getBridge(), SIGNAL(menuAddSeparator(int)), this, SLOT(addSeparator(int)));
|
||||
connect(Bridge::getBridge(), SIGNAL(menuClearMenu(int)), this, SLOT(clearMenu(int)));
|
||||
connect(Bridge::getBridge(), SIGNAL(menuClearMenu(int, bool)), this, SLOT(clearMenu(int, bool)));
|
||||
connect(Bridge::getBridge(), SIGNAL(menuRemoveMenuEntry(int)), this, SLOT(removeMenuEntry(int)));
|
||||
connect(Bridge::getBridge(), SIGNAL(getStrWindow(QString, QString*)), this, SLOT(getStrWindow(QString, QString*)));
|
||||
connect(Bridge::getBridge(), SIGNAL(setIconMenu(int, QIcon)), this, SLOT(setIconMenu(int, QIcon)));
|
||||
|
|
@ -1047,7 +1047,7 @@ void MainWindow::addMenu(int hMenu, QString title)
|
|||
Bridge::getBridge()->setResult(-1);
|
||||
return;
|
||||
}
|
||||
int hMenuNew = hMenuNext++;
|
||||
int hMenuNew = hEntryMenuPool++;
|
||||
QWidget* parent = hMenu == -1 ? this : menu->parent;
|
||||
QMenu* wMenu = new QMenu(title, parent);
|
||||
wMenu->menuAction()->setVisible(false);
|
||||
|
|
@ -1071,7 +1071,7 @@ void MainWindow::addMenuEntry(int hMenu, QString title)
|
|||
return;
|
||||
}
|
||||
MenuEntryInfo newInfo;
|
||||
int hEntryNew = hEntryNext++;
|
||||
int hEntryNew = hEntryMenuPool++;
|
||||
newInfo.hEntry = hEntryNew;
|
||||
newInfo.hParentMenu = hMenu;
|
||||
QWidget* parent = hMenu == -1 ? this : menu->parent;
|
||||
|
|
@ -1106,7 +1106,7 @@ void MainWindow::addSeparator(int hMenu)
|
|||
Bridge::getBridge()->setResult();
|
||||
}
|
||||
|
||||
void MainWindow::clearMenu(int hMenu)
|
||||
void MainWindow::clearMenu(int hMenu, bool erase)
|
||||
{
|
||||
if(!mMenuList.size() || hMenu == -1)
|
||||
{
|
||||
|
|
@ -1130,24 +1130,39 @@ void MainWindow::clearMenu(int hMenu)
|
|||
{
|
||||
if(hMenu == mMenuList.at(i).hParentMenu) //we found a menu that has the menu as parent
|
||||
{
|
||||
clearMenu(mMenuList.at(i).hMenu); //delete children menus
|
||||
clearMenu(mMenuList.at(i).hMenu, false); //delete children menus
|
||||
delete mMenuList.at(i).mMenu; //delete the child menu object
|
||||
mMenuList.erase(mMenuList.begin() + i); //delete the child entry
|
||||
}
|
||||
}
|
||||
//hide the empty menu
|
||||
if(menu)
|
||||
menu->mMenu->menuAction()->setVisible(false);
|
||||
{
|
||||
if(erase)
|
||||
{
|
||||
//delete the menu itself
|
||||
for(int i = mMenuList.size() - 1; i > -1; i--)
|
||||
{
|
||||
if(hMenu == mMenuList.at(i).hMenu) //we found the menu
|
||||
{
|
||||
delete mMenuList.at(i).mMenu; //delete the menu object
|
||||
mMenuList.erase(mMenuList.begin() + i); //delete the menu entry
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
else
|
||||
menu->mMenu->menuAction()->setVisible(false);
|
||||
}
|
||||
Bridge::getBridge()->setResult();
|
||||
}
|
||||
|
||||
void MainWindow::initMenuApi()
|
||||
{
|
||||
//256 entries are reserved
|
||||
hEntryMenuPool = 256;
|
||||
mEntryList.clear();
|
||||
hEntryNext = 256;
|
||||
mMenuList.clear();
|
||||
hMenuNext = 256;
|
||||
}
|
||||
|
||||
void MainWindow::menuEntrySlot()
|
||||
|
|
@ -1161,11 +1176,11 @@ void MainWindow::menuEntrySlot()
|
|||
}
|
||||
}
|
||||
|
||||
void MainWindow::removeMenuEntry(int hEntry)
|
||||
void MainWindow::removeMenuEntry(int hEntryMenu)
|
||||
{
|
||||
for(int i = 0; i < mEntryList.size(); i++)
|
||||
{
|
||||
if(mEntryList.at(i).hEntry == hEntry)
|
||||
if(mEntryList.at(i).hEntry == hEntryMenu)
|
||||
{
|
||||
const MenuEntryInfo & entry = mEntryList.at(i);
|
||||
const MenuInfo* menu = findMenu(entry.hParentMenu);
|
||||
|
|
@ -1173,10 +1188,11 @@ void MainWindow::removeMenuEntry(int hEntry)
|
|||
parent->removeAction(entry.mAction);
|
||||
delete entry.mAction;
|
||||
mEntryList.erase(mEntryList.begin() + i);
|
||||
break;
|
||||
Bridge::getBridge()->setResult();
|
||||
return;
|
||||
}
|
||||
}
|
||||
Bridge::getBridge()->setResult();
|
||||
clearMenu(hEntryMenu, true);
|
||||
}
|
||||
|
||||
void MainWindow::setIconMenuEntry(int hEntry, QIcon icon)
|
||||
|
|
|
|||
|
|
@ -102,9 +102,9 @@ public slots:
|
|||
void addMenu(int hMenu, QString title);
|
||||
void addMenuEntry(int hMenu, QString title);
|
||||
void addSeparator(int hMenu);
|
||||
void clearMenu(int hMenu);
|
||||
void clearMenu(int hMenu, bool erase);
|
||||
void menuEntrySlot();
|
||||
void removeMenuEntry(int hEntry);
|
||||
void removeMenuEntry(int hEntryMenu);
|
||||
void setIconMenuEntry(int hEntry, QIcon icon);
|
||||
void setIconMenu(int hMenu, QIcon icon);
|
||||
void setCheckedMenuEntry(int hEntry, bool checked);
|
||||
|
|
@ -231,10 +231,9 @@ private:
|
|||
bool globalMenu;
|
||||
};
|
||||
|
||||
int hEntryMenuPool;
|
||||
QList<MenuEntryInfo> mEntryList;
|
||||
int hEntryNext;
|
||||
QList<MenuInfo> mMenuList;
|
||||
int hMenuNext;
|
||||
|
||||
void initMenuApi();
|
||||
const MenuInfo* findMenu(int hMenu);
|
||||
|
|
|
|||
Loading…
Reference in New Issue