aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorGravatar Noldor2008-04-18 20:16:18 +0000
committerGravatar Noldor2008-04-18 20:16:18 +0000
commit1bd4b7cee7daf6eaaaaaf0f3ebbb1f89bdcccf66 (patch)
tree7751a469946d914bf9e1d0cf63bce8645ca00660
parentIPC fix; Thanks to desowin (diff)
downloadKVIrc-1bd4b7cee7daf6eaaaaaf0f3ebbb1f89bdcccf66.tar.gz
KVIrc-1bd4b7cee7daf6eaaaaaf0f3ebbb1f89bdcccf66.tar.bz2
KVIrc-1bd4b7cee7daf6eaaaaaf0f3ebbb1f89bdcccf66.zip
more Q3PopupMenu port.
git-svn-id: https://svn.kvirc.de/svn/trunk/kvirc@1505 17fca916-40b9-46aa-a4ea-0a15b648b75c
-rw-r--r--src/kvilib/tal/kvi_tal_popupmenu.cpp43
-rw-r--r--src/kvilib/tal/kvi_tal_popupmenu.h7
-rw-r--r--src/kvirc/ui/kvi_menubar.cpp45
-rw-r--r--src/kvirc/ui/kvi_menubar.h1
4 files changed, 56 insertions, 40 deletions
diff --git a/src/kvilib/tal/kvi_tal_popupmenu.cpp b/src/kvilib/tal/kvi_tal_popupmenu.cpp
index 8b189d6a8..4e561dddb 100644
--- a/src/kvilib/tal/kvi_tal_popupmenu.cpp
+++ b/src/kvilib/tal/kvi_tal_popupmenu.cpp
@@ -37,11 +37,11 @@ KviTalPopupMenu::KviTalPopupMenu(QWidget * pParent,const QString &szName)
setObjectName(szName);
identifier=0;
}
-KviTalPopupMenu::~KviTalPopupMenu()
+KviTalPopupMenu::~KviTalPopupMenu()
{
}
-
-
+
+
int KviTalPopupMenu::insertItem(const QString &szText)
{
QAction *a=addAction(szText);
@@ -57,8 +57,6 @@ int KviTalPopupMenu::insertItem(const QPixmap &pix,const QString &szText)
}
int KviTalPopupMenu::insertItem(const QString &szText,int id)
{
- //return QMenu::insertItem(szText,id);
-
QAction *a=addAction(szText);
addAction(a);
actionsDict[id]=a;
@@ -67,38 +65,37 @@ int KviTalPopupMenu::insertItem(const QString &szText,int id)
int KviTalPopupMenu::insertItem(const QPixmap &pix,const QString &szText,int id)
{
- //return QMenu::insertItem(QIcon(pix),szText,id,-1);
QAction *a=addAction(QIcon(pix),szText);
actionsDict[id]=a;
return id;
}
-
+//FIXME
int KviTalPopupMenu::insertItem(const QString &szText,const QObject * pReceiver,const char * szSlot)
{
- //return QMenu::insertItem(szText,pReceiver,szSlot);
- QAction *a=addAction(szText,pReceiver,szSlot);
- actionsDict[identifier++]=a;
+ QAction * action = QMenu::addAction(szText);
+ connect(action,SIGNAL(triggered(bool)),pReceiver,szSlot);
+ actionsDict[identifier++]=action;
return identifier-1;
}
int KviTalPopupMenu::insertItem(const QPixmap &pix,const QString &szText,const QObject * pReceiver,const char * szSlot)
{
- //return QMenu::insertItem(QIcon(pix),szText,pReceiver,szSlot);
- QAction *a=addAction(QIcon(pix),szText,pReceiver,szSlot);
- actionsDict[identifier++]=a;
+ QAction * action = QMenu::addAction(pix,szText);
+ connect(action,SIGNAL(triggered(bool)),pReceiver,szSlot);
+ actionsDict[identifier++]=action;
return identifier-1;
}
-
+//
int KviTalPopupMenu::insertItem(const QPixmap &pix,const QString &szText,QMenu *pMenu)
{
-
+
QAction *a=addMenu(pMenu);
a->setText(szText);
a->setIcon(QIcon(pix));
actionsDict[identifier++]=a;
return identifier-1;
}
-
+
int KviTalPopupMenu::insertItem(const QString &szText,QMenu *pMenu)
{
//return QMenu::insertItem(szText,pMenu,-1,-1);
@@ -107,7 +104,7 @@ int KviTalPopupMenu::insertItem(const QString &szText,QMenu *pMenu)
actionsDict[identifier++]=a;
return identifier-1;
}
-
+
int KviTalPopupMenu::insertItem(QWidget * pWidget)
{
@@ -155,15 +152,15 @@ void KviTalPopupMenu::setItemEnabled(int id,bool bFlag)
int KviTalPopupMenu::insertSeparator()
{
QAction *a=addSeparator();
- actionsDict[identifier++]=a;
- return identifier-1;
+ //actionsDict[identifier++]=a;
+ return -1;
}
void KviTalPopupMenu::slottriggered(QAction *a)
{
QHashIterator<int, QAction *> i(actionsDict);
int count=0;
bool found=false;
- while (i.hasNext())
+ while (i.hasNext())
{
i.next();
if (i.value()!= a) count++;
@@ -172,6 +169,12 @@ void KviTalPopupMenu::slottriggered(QAction *a)
emit activated(count);
}
+void KviTalPopupMenu::slotActionTriggered(bool toggled)
+{
+ QAction * action = (QAction *)sender();
+ slottriggered(action);
+
+}
#ifndef COMPILE_USE_STANDALONE_MOC_SOURCES
#include "kvi_tal_popupmenu.moc"
#endif //!COMPILE_USE_STANDALONE_MOC_SOURCES
diff --git a/src/kvilib/tal/kvi_tal_popupmenu.h b/src/kvilib/tal/kvi_tal_popupmenu.h
index 36d719971..e1554c07d 100644
--- a/src/kvilib/tal/kvi_tal_popupmenu.h
+++ b/src/kvilib/tal/kvi_tal_popupmenu.h
@@ -53,11 +53,16 @@ public:
void setItemEnabled(int id,bool bFlag);
void setItemParameter(int id, int param);
int itemParameter(int id);
+ QAction *getAction(int id){
+ QAction *a=actionsDict.value(id);
+ return a?a:0;
+ };
void clear();
QString text(int);
int insertSeparator();
protected slots:
- void slottriggered(QAction *);
+ void slottriggered(QAction *);
+ void slotActionTriggered(bool);
signals:
void activated(int);
diff --git a/src/kvirc/ui/kvi_menubar.cpp b/src/kvirc/ui/kvi_menubar.cpp
index 63255c868..de88f65b3 100644
--- a/src/kvirc/ui/kvi_menubar.cpp
+++ b/src/kvirc/ui/kvi_menubar.cpp
@@ -113,62 +113,69 @@ void KviMenuBar::setupHelpPopup()
KviTalPopupMenu * help = (KviTalPopupMenu *)sender();
help->clear();
- // FIXME: Convert these to actions!
- int id = help->insertItem(*(g_pIconManager->getSmallIcon(KVI_SMALLICON_HELP)),__tr2qs("&Help Browser (Panel)"),m_pFrm,SLOT(executeInternalCommand(int)));
+ int id = help->insertItem(*(g_pIconManager->getSmallIcon(KVI_SMALLICON_HELP)),__tr2qs("&Help Browser (Panel)"));
+ debug ("Item %d named Help Browser (Panel)",id);
help->setItemParameter(id,KVI_INTERNALCOMMAND_HELP_NEWSTATICWINDOW);
- id = help->insertItem(*(g_pIconManager->getSmallIcon(KVI_SMALLICON_MDIHELP)),__tr2qs("Help Browser (&Window)"),m_pFrm,SLOT(executeInternalCommand(int)));
+ id = help->insertItem(*(g_pIconManager->getSmallIcon(KVI_SMALLICON_MDIHELP)),__tr2qs("Help Browser (&Window)"));
+ debug ("Item %d named Help Browser (Window)",id);
help->setItemParameter(id,KVI_INTERNALCOMMAND_HELP_NEWMDIWINDOW);
help->insertSeparator();
- id = help->insertItem(*(g_pIconManager->getSmallIcon(KVI_SMALLICON_IDEA)),__tr2qs("&Tip of the Day"),m_pFrm,SLOT(executeInternalCommand(int)));
+ id = help->insertItem(*(g_pIconManager->getSmallIcon(KVI_SMALLICON_IDEA)),__tr2qs("&Tip of the Day"));
+ debug ("Item %d named Help Browser (Tip of the Day)",id);
help->setItemParameter(id,KVI_INTERNALCOMMAND_TIP_OPEN);
help->insertSeparator();
- id = help->insertItem(*(g_pIconManager->getSmallIcon(KVI_SMALLICON_KVIRC)),__tr2qs("About &KVIrc"),m_pFrm,SLOT(executeInternalCommand(int)));
+ id = help->insertItem(*(g_pIconManager->getSmallIcon(KVI_SMALLICON_KVIRC)),__tr2qs("About &KVIrc"));
+ debug ("Item %d named Help Browser (About &KVIrc)",id);
+
help->setItemParameter(id,KVI_INTERNALCOMMAND_ABOUT_ABOUTKVIRC);
help->insertSeparator();
- id = help->insertItem(*(g_pIconManager->getSmallIcon(KVI_SMALLICON_HOMEPAGE)),__tr2qs("KVIrc Home&page"),m_pFrm,SLOT(executeInternalCommand(int)));
+ id = help->insertItem(*(g_pIconManager->getSmallIcon(KVI_SMALLICON_HOMEPAGE)),__tr2qs("KVIrc Home&page"));
help->setItemParameter(id,KVI_INTERNALCOMMAND_KVIRC_HOMEPAGE);
if(kvi_strEqualCIN(KviLocale::localeName(),"ru",2))
{
- id = help->insertItem(*(g_pIconManager->getSmallIcon(KVI_SMALLICON_HOMEPAGE)),__tr2qs("KVIrc Russian Home&page"),m_pFrm,SLOT(executeInternalCommand(int)));
+ id = help->insertItem(*(g_pIconManager->getSmallIcon(KVI_SMALLICON_HOMEPAGE)),__tr2qs("KVIrc Russian Home&page"));
help->setItemParameter(id,KVI_INTERNALCOMMAND_KVIRC_HOMEPAGE_RU);
}
if(kvi_strEqualCIN(KviLocale::localeName(),"fr",2))
{
- id = help->insertItem(*(g_pIconManager->getSmallIcon(KVI_SMALLICON_HOMEPAGE)),__tr2qs("KVIrc French Home&page"),m_pFrm,SLOT(executeInternalCommand(int)));
+ id = help->insertItem(*(g_pIconManager->getSmallIcon(KVI_SMALLICON_HOMEPAGE)),__tr2qs("KVIrc French Home&page"));
help->setItemParameter(id,KVI_INTERNALCOMMAND_KVIRC_HOMEPAGE_FR);
}
help->insertSeparator();
- id = help->insertItem(*(g_pIconManager->getSmallIcon(KVI_SMALLICON_MESSAGE)),__tr2qs("Subscribe to the Mailing List"),m_pFrm,SLOT(executeInternalCommand(int)));
+ id = help->insertItem(*(g_pIconManager->getSmallIcon(KVI_SMALLICON_MESSAGE)),__tr2qs("Subscribe to the Mailing List"));
help->setItemParameter(id,KVI_INTERNALCOMMAND_OPENURL_KVIRC_MAILINGLIST);
- id = help->insertItem(*(g_pIconManager->getSmallIcon(KVI_SMALLICON_BOMB)),__tr2qs("Report a Bug / Propose Improvements"),m_pFrm,SLOT(executeInternalCommand(int)));
+ id = help->insertItem(*(g_pIconManager->getSmallIcon(KVI_SMALLICON_BOMB)),__tr2qs("Report a Bug / Propose Improvements"));
help->setItemParameter(id,KVI_INTERNALCOMMAND_OPENURL_KVIRC_BUGTRACK);
help->insertSeparator();
- id = help->insertItem(*(g_pIconManager->getSmallIcon(KVI_SMALLICON_CHANNEL)),__tr2qs("Join KVIrc International Channel on Freenode"),m_pFrm,SLOT(executeInternalCommand(int)));
+ id = help->insertItem(*(g_pIconManager->getSmallIcon(KVI_SMALLICON_CHANNEL)),__tr2qs("Join KVIrc International Channel on Freenode"));
help->setItemParameter(id,KVI_INTERNALCOMMAND_OPENURL_KVIRC_ON_FREENODE);
- id = help->insertItem(*(g_pIconManager->getSmallIcon(KVI_SMALLICON_CHANNEL)),__tr2qs("Join KVIrc International Channel on IRCNet"),m_pFrm,SLOT(executeInternalCommand(int)));
+ id = help->insertItem(*(g_pIconManager->getSmallIcon(KVI_SMALLICON_CHANNEL)),__tr2qs("Join KVIrc International Channel on IRCNet"));
help->setItemParameter(id,KVI_INTERNALCOMMAND_OPENURL_KVIRC_ON_IRCNET);
if(kvi_strEqualCIN(KviLocale::localeName(),"it",2))
{
// join #kvirc.net on azzurra
- id = help->insertItem(*(g_pIconManager->getSmallIcon(KVI_SMALLICON_CHANNEL)),__tr2qs("Join KVIrc Italian Channel on AzzurraNet"),m_pFrm,SLOT(executeInternalCommand(int)));
+ id = help->insertItem(*(g_pIconManager->getSmallIcon(KVI_SMALLICON_CHANNEL)),__tr2qs("Join KVIrc Italian Channel on AzzurraNet"));
help->setItemParameter(id,KVI_INTERNALCOMMAND_OPENURL_KVIRC_IT_ON_AZZURRA);
}
if(kvi_strEqualCIN(KviLocale::localeName(),"fr",2))
{
// join #kvirc-fr on freenode
- id = help->insertItem(*(g_pIconManager->getSmallIcon(KVI_SMALLICON_CHANNEL)),__tr2qs("Join KVIrc French Channel on Freenode"),m_pFrm,SLOT(executeInternalCommand(int)));
+ id = help->insertItem(*(g_pIconManager->getSmallIcon(KVI_SMALLICON_CHANNEL)),__tr2qs("Join KVIrc French Channel on Freenode"));
help->setItemParameter(id,KVI_INTERNALCOMMAND_OPENURL_KVIRC_FR_ON_FREENODE);
// join #kvirc on europnet
- id = help->insertItem(*(g_pIconManager->getSmallIcon(KVI_SMALLICON_CHANNEL)),__tr2qs("Join KVIrc French Channel on EuropNet"),m_pFrm,SLOT(executeInternalCommand(int)));
+ id = help->insertItem(*(g_pIconManager->getSmallIcon(KVI_SMALLICON_CHANNEL)),__tr2qs("Join KVIrc French Channel on EuropNet"));
help->setItemParameter(id,KVI_INTERNALCOMMAND_OPENURL_KVIRC_FR_ON_EUROPNET);
}
- // add your localized #kvirc channels here...
+ connect(help,SIGNAL(activated(int)),this,SLOT(actionTriggered(int)));
+}
+void KviMenuBar::actionTriggered(int id)
+{
+ KviTalPopupMenu * help = (KviTalPopupMenu *)sender();
+ m_pFrm->executeInternalCommand(help->itemParameter(id));
}
-
void KviMenuBar::setupSettingsPopup()
{
- // FIXME: Move everything to actions!
-
+
KviTalPopupMenu * opt = (KviTalPopupMenu *)sender();
opt->clear();
diff --git a/src/kvirc/ui/kvi_menubar.h b/src/kvirc/ui/kvi_menubar.h
index 32cce8665..79d9888ce 100644
--- a/src/kvirc/ui/kvi_menubar.h
+++ b/src/kvirc/ui/kvi_menubar.h
@@ -78,6 +78,7 @@ protected slots:
void setupToolbarsPopup();
void setupToolsPopup();
void toolsPopupSelected(int id);
+ void actionTriggered(int id);
};
#endif //_KVI_MENUBAR_H_