aboutsummaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
authorGravatar Fabio Bas2010-09-01 09:01:22 +0000
committerGravatar Fabio Bas2010-09-01 09:01:22 +0000
commit9601f7bbcc4f4a0f24ed5e28f40c7f26ca4bbad3 (patch)
treeedbe66bbbc7a63d4b769d8d724d08cd013b1466d /src
parentrefix for #924 (diff)
downloadKVIrc-9601f7bbcc4f4a0f24ed5e28f40c7f26ca4bbad3.tar.gz
KVIrc-9601f7bbcc4f4a0f24ed5e28f40c7f26ca4bbad3.tar.bz2
KVIrc-9601f7bbcc4f4a0f24ed5e28f40c7f26ca4bbad3.zip
fix for #931
git-svn-id: https://svn.kvirc.de/svn/trunk/kvirc@4963 17fca916-40b9-46aa-a4ea-0a15b648b75c
Diffstat (limited to 'src')
-rw-r--r--src/kvirc/kvs/kvi_kvs_coresimplecommands_sz.cpp8
-rw-r--r--src/kvirc/ui/kvi_menubar.cpp19
-rw-r--r--src/kvirc/ui/kvi_menubar.h3
3 files changed, 10 insertions, 20 deletions
diff --git a/src/kvirc/kvs/kvi_kvs_coresimplecommands_sz.cpp b/src/kvirc/kvs/kvi_kvs_coresimplecommands_sz.cpp
index d9148c49b..411f0d4fb 100644
--- a/src/kvirc/kvs/kvi_kvs_coresimplecommands_sz.cpp
+++ b/src/kvirc/kvs/kvi_kvs_coresimplecommands_sz.cpp
@@ -342,11 +342,11 @@ namespace KviKvsCoreSimpleCommands
Adds an [b]existing[/b] popup menu to the current frame's menu bar.[br]
<visible_text> is used as menu identification and obviously as the visible
menu bar text for the new popup.[br]
- If a popup menu with the same <visible_text> already exists in the current frame
+ If a popup menu with the same <visible_text> or the same <menu_name> already exists in the current frame
it is removed first.[br]
<visible_text> can optionally contain the "&" character to identify
the popup menu accelerator.[br]
- [menu_name], if given, must be avalid name of a popup menu created earlier
+ [menu_name], if given, must be a valid name of a popup menu created earlier
with [cmd]defpopup[/cmd] (or the script center).[br]
If [menu_name] is not given, the popup menu identified by <visible_text> is removed.[br]
If the -i switch is used, <index> is a [b]zero based index[/b] of the default
@@ -357,10 +357,12 @@ namespace KviKvsCoreSimpleCommands
@seealso:
[cmd]defpopup[/cmd]
@examples:
+ [example]
setmenu -q -i=2 Test apopup
setmenu Test
setmenu ThisDoesNotExist
setmenu -q ThisDoesNotExist
+ [/example]
*/
KVSCSC(setmenu)
@@ -375,7 +377,7 @@ namespace KviKvsCoreSimpleCommands
{
if(!(KVSCSC_pWindow->frame()->mainMenuBar()->removeMenu(szVisibleText)))
{
- if(!KVSCSC_pSwitches->find('q',"quiet"))KVSCSC_pContext->warning(__tr2qs_ctx("No menu bar item with text '%Q'","kvs"),&szPopupName);
+ if(!KVSCSC_pSwitches->find('q',"quiet"))KVSCSC_pContext->warning(__tr2qs_ctx("No menu bar item with text '%Q'","kvs"),&szVisibleText);
}
return true;
}
diff --git a/src/kvirc/ui/kvi_menubar.cpp b/src/kvirc/ui/kvi_menubar.cpp
index 3363a8321..5f7eb35ba 100644
--- a/src/kvirc/ui/kvi_menubar.cpp
+++ b/src/kvirc/ui/kvi_menubar.cpp
@@ -47,9 +47,6 @@ KviMenuBar::KviMenuBar(KviFrame * par,const char * name)
setAutoFillBackground(false);
m_pFrm = par;
- m_iNumDefaultItems = 0;
- m_pDefaultItemId = 0;
-
KviTalPopupMenu * pop = new KviTalPopupMenu(this,"KVIrc");
connect(pop,SIGNAL(aboutToShow()),this,SLOT(setupMainPopup()));
#ifndef COMPILE_ON_MAC
@@ -91,16 +88,12 @@ KviMenuBar::KviMenuBar(KviFrame * par,const char * name)
KviMenuBar::~KviMenuBar()
{
if(m_pScriptItemList)delete m_pScriptItemList;
- if(m_pDefaultItemId)kvi_free(m_pDefaultItemId);
}
void KviMenuBar::addDefaultItem(const QString &text,KviTalPopupMenu * pop)
{
- m_iNumDefaultItems++;
- m_pDefaultItemId = (int *)kvi_realloc((void *)m_pDefaultItemId,sizeof(int) * m_iNumDefaultItems);
pop->menuAction()->setText(text);
addAction(pop->menuAction());
- m_pDefaultItemId[m_iNumDefaultItems - 1] = actions().indexOf(pop->menuAction());
}
void KviMenuBar::setupHelpPopup()
@@ -339,10 +332,10 @@ int KviMenuBar::getDefaultItemRealIndex(int iDefaultIndex)
{
if(iDefaultIndex < 0)
iDefaultIndex = 0;
- if(iDefaultIndex >= m_iNumDefaultItems)
- return m_pDefaultItemId[m_iNumDefaultItems - 1] + 1;
+ if(iDefaultIndex > actions().count())
+ iDefaultIndex = actions().count();
- return m_pDefaultItemId[iDefaultIndex];
+ return iDefaultIndex;
}
KviScriptMenuBarItem * KviMenuBar::findMenu(const QString &text)
@@ -372,7 +365,7 @@ bool KviMenuBar::removeMenu(const QString &text)
if(i)
{
disconnect(i->pPopup,SIGNAL(destroyed()),this,SLOT(menuDestroyed()));
- removeAction(actions().at(i->id));
+ removeAction(i->pPopup->menuAction());
m_pScriptItemList->removeRef(i);
return true;
}
@@ -384,7 +377,7 @@ void KviMenuBar::menuDestroyed()
KviScriptMenuBarItem * i = findMenu(((KviKvsPopupMenu *)sender()));
if(i)
{
- removeAction(actions().at(i->id));
+ // No need to remove the associated action: qt already did it (ticket #931)
m_pScriptItemList->removeRef(i);
}
}
@@ -405,9 +398,7 @@ void KviMenuBar::addMenu(const QString &text,KviKvsPopupMenu * p,int index)
if(index == -1 || index >= actions().count())
{
addAction(it->pPopup->menuAction());
- it->id = actions().indexOf(it->pPopup->menuAction());
} else {
- it->id = index;
insertAction(actions().value(index), it->pPopup->menuAction());
}
diff --git a/src/kvirc/ui/kvi_menubar.h b/src/kvirc/ui/kvi_menubar.h
index c5d28e780..7791d0da6 100644
--- a/src/kvirc/ui/kvi_menubar.h
+++ b/src/kvirc/ui/kvi_menubar.h
@@ -36,7 +36,6 @@ class KviKvsPopupMenu;
typedef struct _KviScriptMenuBarItem
{
- int id;
KviStr szPopupName;
KviKvsPopupMenu * pPopup;
KviStr szText;
@@ -54,8 +53,6 @@ protected:
KviTalPopupMenu * m_pRecentServersPopup;
KviFrame * m_pFrm;
KviPointerList<KviScriptMenuBarItem> * m_pScriptItemList;
- int m_iNumDefaultItems;
- int * m_pDefaultItemId;
protected:
KviScriptMenuBarItem * findMenu(const QString &text);
KviScriptMenuBarItem * findMenu(KviKvsPopupMenu * p);